Change in osmo-gsm-tester[master]: ms_driver: Allow to specify env and binary name/path

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Holger Freyther gerrit-no-reply at lists.osmocom.org
Mon Nov 5 06:51:41 UTC 2018


Holger Freyther has uploaded this change for review. ( https://gerrit.osmocom.org/11596


Change subject: ms_driver: Allow to specify env and binary name/path
......................................................................

ms_driver: Allow to specify env and binary name/path

For the proper trial/suite integration we can't assume that the
virtphy/mobile are in the PATH and that they can be executed
direcyly (e.g. need a LD_LIBRARY_PATH to be applied).

Introduce BinaryOptions to pass the name/path of the two executables
and the env to use. Default this to virtphy/mobile and an empty
environment.

Change-Id: I79a57e53bc20613ac061453c24fd29a6d05e1721
---
M src/osmo_gsm_tester/ms_driver.py
M src/osmo_ms_driver/__main__.py
M src/osmo_ms_driver/location_update_test.py
M src/osmo_ms_driver/starter.py
4 files changed, 27 insertions(+), 15 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/96/11596/1

diff --git a/src/osmo_gsm_tester/ms_driver.py b/src/osmo_gsm_tester/ms_driver.py
index a4d81c1..f46efa3 100644
--- a/src/osmo_gsm_tester/ms_driver.py
+++ b/src/osmo_gsm_tester/ms_driver.py
@@ -20,7 +20,7 @@
 from osmo_ms_driver.cdf import cdfs
 from osmo_ms_driver.event_server import EventServer
 from osmo_ms_driver.simple_loop import SimpleLoop
-from osmo_ms_driver.location_update_test import MassUpdateLocationTest
+from osmo_ms_driver.location_update_test import BinaryOptions, MassUpdateLocationTest
 
 import os.path
 import shutil
@@ -83,7 +83,9 @@
 
         self._ev_server = EventServer("ev_server", event_server_path)
         self._ev_server.listen(self._loop)
-        self._test_case = MassUpdateLocationTest("mass", self._num_ms, self._cdf, self._ev_server, self.event_server_sk_tmp_dir)
+        options = BinaryOptions("virtphy", "mobile", None)
+        self._test_case = MassUpdateLocationTest("mass", options, self._num_ms, self._cdf,
+                                                 self._ev_server, self.event_server_sk_tmp_dir)
 
         # TODO: We should pass subscribers down to the test and not get it from
         # there.
diff --git a/src/osmo_ms_driver/__main__.py b/src/osmo_ms_driver/__main__.py
index 1573084..265ce47 100644
--- a/src/osmo_ms_driver/__main__.py
+++ b/src/osmo_ms_driver/__main__.py
@@ -20,6 +20,7 @@
 from .simple_loop import SimpleLoop
 from .location_update_test import MassUpdateLocationTest
 from .cdf import cdfs
+from .starter import BinaryOptions
 from osmo_gsm_tester import log
 
 # System modules
@@ -82,7 +83,8 @@
     ev_server.listen(loop)
 
     # Just a single test for now.
-    test = MassUpdateLocationTest("lu_test", args.num_ms, cdf, ev_server, tmp_dir)
+    options = BinaryOptions("virtphy", "mobile", None)
+    test = MassUpdateLocationTest("lu_test", options, args.num_ms, cdf, ev_server, tmp_dir)
     atexit.register(test.stop_all)
 
     # Run until everything has been launched
diff --git a/src/osmo_ms_driver/location_update_test.py b/src/osmo_ms_driver/location_update_test.py
index 010c278..87b3e4e 100644
--- a/src/osmo_ms_driver/location_update_test.py
+++ b/src/osmo_ms_driver/location_update_test.py
@@ -56,8 +56,9 @@
     TEMPLATE_LUA = "osmo-mobile-lu.lua"
     TEMPLATE_CFG = "osmo-mobile.cfg"
 
-    def __init__(self, name, number_of_ms, cdf_function, event_server, tmp_dir):
+    def __init__(self, name, options, number_of_ms, cdf_function, event_server, tmp_dir):
         super().__init__(log.C_RUN, name)
+        self._binary_options = options
         self._number_of_ms = number_of_ms
         self._cdf = cdf_function
         self._cdf.set_target(number_of_ms)
@@ -71,10 +72,12 @@
         for i in range(0, number_of_ms):
             ms_name = "%.5d" % i
 
-            phy = OsmoVirtPhy(ms_name, tmp_dir)
+            phy = OsmoVirtPhy(options.virtphy, options.env,
+                              ms_name, tmp_dir)
             self._phys.append(phy)
 
-            launcher = OsmoMobile(ms_name, tmp_dir, self.TEMPLATE_LUA,
+            launcher = OsmoMobile(options.mobile, options.env,
+                                ms_name, tmp_dir, self.TEMPLATE_LUA,
                                 self.TEMPLATE_CFG, imsi_gen,
                                 phy.phy_filename(),
                                 event_server.server_path())
diff --git a/src/osmo_ms_driver/starter.py b/src/osmo_ms_driver/starter.py
index 5218a57..2ffb33a 100644
--- a/src/osmo_ms_driver/starter.py
+++ b/src/osmo_ms_driver/starter.py
@@ -18,6 +18,7 @@
 
 from osmo_gsm_tester import log, template
 
+import collections
 import os
 import os.path
 import subprocess
@@ -26,9 +27,13 @@
 _devnull = open(os.devnull, 'w')
 #_devnull = open('/dev/stdout', 'w')
 
+BinaryOptions = collections.namedtuple("BinaryOptions", ["virtphy", "mobile", "env"])
+
 class Launcher(log.Origin):
-    def __init__(self, base_name, name_number, tmp_dir):
+    def __init__(self, binary, env, base_name, name_number, tmp_dir):
         super().__init__(log.C_RUN, "{}/{}".format(base_name, name_number))
+        self._binary = binary
+        self._env = env
         self._name_number = name_number
         self._tmp_dir = tmp_dir
 
@@ -36,8 +41,8 @@
         return self._name_number
 
 class OsmoVirtPhy(Launcher):
-    def __init__(self, name_number, tmp_dir):
-        super().__init__("osmo-ms-virt-phy", name_number, tmp_dir)
+    def __init__(self, binary, env, name_number, tmp_dir):
+        super().__init__(binary, env, "osmo-ms-virt-phy", name_number, tmp_dir)
         self._phy_filename = os.path.join(self._tmp_dir, "osmocom_l2_" + self._name_number)
         self._vphy_proc = None
 
@@ -49,9 +54,9 @@
             raise log.Error('Path for unix socket is longer than max allowed len for unix socket path (107):', self._phy_filename)
 
         self.log("Starting virtphy process")
-        args = ["virtphy", "--l1ctl-sock=" + self._phy_filename]
+        args = [self._binary, "--l1ctl-sock=" + self._phy_filename]
         self.log(' '.join(args))
-        self._vphy_proc = subprocess.Popen(args, stderr=_devnull, stdout=_devnull)
+        self._vphy_proc = subprocess.Popen(args, stderr=_devnull, stdout=_devnull, env=self._env)
 
     def verify_ready(self):
         while True:
@@ -65,8 +70,8 @@
             self._vphy_proc.terminate()
 
 class OsmoMobile(Launcher):
-    def __init__(self, name_number, tmp_dir, lua_tmpl, cfg_tmpl, imsi_ki_generator, phy_filename, ev_server_path):
-        super().__init__("osmo-ms-mob", name_number, tmp_dir)
+    def __init__(self, binary, env, name_number, tmp_dir, lua_tmpl, cfg_tmpl, imsi_ki_generator, phy_filename, ev_server_path):
+        super().__init__(binary, env, "osmo-ms-mob", name_number, tmp_dir)
         self._lua_template = lua_tmpl
         self._cfg_template = cfg_tmpl
         self._imsi_ki_generator = imsi_ki_generator
@@ -117,9 +122,9 @@
 
         self.log("Starting process")
         # Let the kernel pick an unused port for the VTY.
-        args = ["mobile", "-c", mob_filename, "--vty-port=0"]
+        args = [self._binary, "-c", mob_filename, "--vty-port=0"]
         self.log(' '.join(args))
-        self._omob_proc = subprocess.Popen(args, stderr=_devnull, stdout=_devnull)
+        self._omob_proc = subprocess.Popen(args, stderr=_devnull, stdout=_devnull, env=self._env)
 
     def kill(self):
         """Clean up things."""

-- 
To view, visit https://gerrit.osmocom.org/11596
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I79a57e53bc20613ac061453c24fd29a6d05e1721
Gerrit-Change-Number: 11596
Gerrit-PatchSet: 1
Gerrit-Owner: Holger Freyther <holger at freyther.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181105/f9fad27a/attachment.htm>


More information about the gerrit-log mailing list