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.orgReview at https://gerrit.osmocom.org/6917 ms: Create a starter for virtphy and mobile application In the long run we might not want to start the virtphy but for now virtphy+mobile belong together. Start virtphy first as mobile will not handle a missing socket gracefully. Change-Id: I5c6d742842d7f3e0a1858436ef3f8634d8c0582d --- A src/osmo_ms_driver/starter.py 1 file changed, 110 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/17/6917/1 diff --git a/src/osmo_ms_driver/starter.py b/src/osmo_ms_driver/starter.py new file mode 100644 index 0000000..8b6c591 --- /dev/null +++ b/src/osmo_ms_driver/starter.py @@ -0,0 +1,110 @@ +# osmo_ms_driver: Starter for processes +# Help to start processes over time. +# +# Copyright (C) 2018 by Holger Hans Peter Freyther +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +from osmo_gsm_tester import log, template + +import os +import os.path +import subprocess + +_devnull = open(os.devnull, 'w') +#_devnull = open('/dev/stdout', 'w') + +class Launcher(log.Origin): + """ + I launch an OsmocomBB mobile and the virtphy. In the future we + might want to test with real phones and then don't launch the + virtphy. This needs to be handled once we move to bare iron. + + >>> Launcher("0000", "mobile", "mobile.tmpl", {}) + osmo-ms/0000 + """ + def __init__(self, name_number, tmp_dir, lua_tmpl, cfg_tmpl, imsi_ki_generator, ev_server_path): + super().__init__(log.C_RUN, "osmo-ms/" + name_number) + self._lua_template = lua_tmpl + self._cfg_template = cfg_tmpl + self._name_number = name_number + self._tmp_dir = tmp_dir + self._imsi_ki_generator = imsi_ki_generator + self._ev_server_path = ev_server_path + + def name_number(self): + return self._name_number + + def write_lua_cfg(self): + lua_support = os.path.join(os.path.dirname(__file__), 'lua') + cfg = { + 'test': { + 'event_path': self._ev_server_path, + 'lua_support': lua_support, + } + } + lua_cfg_file = os.path.join(self._tmp_dir, "lua_" + self._name_number + ".lua") + lua_script = template.render(self._lua_template, cfg) + with open(lua_cfg_file, 'w') as w: + w.write(lua_script) + return lua_cfg_file + + def write_mob_cfg(self, lua_filename, phy_filename): + (imsi, ki) = next(self._imsi_ki_generator) + cfg = { + 'test': { + 'script': lua_filename, + 'virt_phy': phy_filename, + 'imsi': imsi, + 'ki_comp128': ki, + 'ms_number': self._name_number, + } + } + mob_cfg_file = os.path.join(self._tmp_dir, "mob_" + self._name_number + ".cfg") + mob_vty = template.render(self._cfg_template, cfg) + with open(mob_cfg_file, 'w') as w: + w.write(mob_vty) + return mob_cfg_file + + def start_virtphy(self, loop): + self._phy_filename = os.path.join(self._tmp_dir, "osmocom_l2_" + self._name_number) + + self.log("Starting virtphy process") + args = ["virtphy", "--l1ctl-sock=" + self._phy_filename] + self.log(' '.join(args)) + self._vphy_proc = subprocess.Popen(args, stderr=_devnull, stdout=_devnull) + + def verify_phy_ready(self): + while True: + if os.path.exists(self._phy_filename): + return + import time + time.sleep(0.2) + + def start_mobile(self, loop): + lua_filename = self.write_lua_cfg() + mob_filename = self.write_mob_cfg(lua_filename, self._phy_filename) + + self.log("Starting process") + # Let the kernel pick an unused port for the VTY. + args = ["mobile", "-c", mob_filename, "--vty-port=0"] + self.log(' '.join(args)) + self._omob_proc = subprocess.Popen(args, stderr=_devnull, stdout=_devnull) + + def kill(self): + """Clean up things.""" + if self._vphy_proc: + self._vphy_proc.kill() + if self._omob_proc: + self._omob_proc.kill() -- To view, visit https://gerrit.osmocom.org/6917 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5c6d742842d7f3e0a1858436ef3f8634d8c0582d Gerrit-PatchSet: 1 Gerrit-Project: osmo-gsm-tester Gerrit-Branch: master Gerrit-Owner: Holger Freyther <holger at freyther.de>