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/.
Neels Hofmeyr gerrit-no-reply at lists.osmocom.orgReview at https://gerrit.osmocom.org/2772 fix multi-suite runs: implement modem cleanup After a suite was done, the modem object would linger. If two suites were run consecutively, the first suite's modem objects would still log incoming SMS. Add an object cleanup mechanism in the SuiteRun class. Start by adding a cleanup() to the Modem object and subscribing created modems there. Move the modem_obj() function into SuiteRun, there is no use of it being separate, and it makes for better logging. Change-Id: I0048d33e661d683a263c98128cd5c38b8d897dab --- M src/osmo_gsm_tester/ofono_client.py M src/osmo_gsm_tester/suite.py 2 files changed, 25 insertions(+), 6 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/72/2772/1 diff --git a/src/osmo_gsm_tester/ofono_client.py b/src/osmo_gsm_tester/ofono_client.py index 9425671..c5ae1ff 100644 --- a/src/osmo_gsm_tester/ofono_client.py +++ b/src/osmo_gsm_tester/ofono_client.py @@ -98,10 +98,13 @@ # { I_SMS: ( token1, token2, ... ), } self.connected_signals = util.listdict() - def __del__(self): + def cleanup(self): self.unwatch_interfaces() for interface_name in list(self.connected_signals.keys()): self.remove_signals(interface_name) + + def __del__(self): + self.cleanup() def get_new_dbus_obj(self): return systembus_get(self.modem_path) @@ -268,6 +271,10 @@ } self.dbus.watch_interfaces() + def cleanup(self): + self.dbus.cleanup() + self.dbus = None + def properties(self, *args, **kwargs): '''Return a dict of properties on this modem. For the actual arguments, see ModemDbusInteraction.properties(), which this function calls. The diff --git a/src/osmo_gsm_tester/suite.py b/src/osmo_gsm_tester/suite.py index 6a1796f..75c461e 100644 --- a/src/osmo_gsm_tester/suite.py +++ b/src/osmo_gsm_tester/suite.py @@ -174,6 +174,7 @@ trial = None resources_pool = None reserved_resources = None + objects_to_clean_up = None _resource_requirements = None _config = None _processes = None @@ -185,6 +186,16 @@ self.set_name(suite_scenario_str) self.set_log_category(log.C_TST) self.resources_pool = resource.ResourcesPool() + + def register_for_cleanup(self, *obj): + assert all([hasattr(o, 'cleanup') for o in obj]) + self.objects_to_clean_up = self.objects_to_clean_up or [] + self.objects_to_clean_up.extend(obj) + + def objects_cleanup(self): + while self.objects_to_clean_up: + obj = self.objects_to_clean_up.pop() + obj.cleanup() def mark_start(self): self.tests = [] @@ -248,6 +259,7 @@ # base exception is raised. Make sure to stop processes in this # finally section. Resources are automatically freed with 'atexit'. self.stop_processes() + self.objects_cleanup() self.free_resources() event_loop.unregister_poll_func(self.poll) self.duration = time.time() - self.start_timestamp @@ -306,7 +318,11 @@ return bts_obj(self, self.reserved_resources.get(resource.R_BTS)) def modem(self): - return modem_obj(self.reserved_resources.get(resource.R_MODEM)) + conf = self.reserved_resources.get(resource.R_MODEM) + self.dbg('create Modem object', conf=conf) + modem = ofono_client.Modem(conf) + self.register_for_cleanup(modem) + return modem def modems(self, count): l = [] @@ -397,9 +413,5 @@ if bts_class is None: raise RuntimeError('No such BTS type is defined: %r' % bts_type) return bts_class(suite_run, conf) - -def modem_obj(conf): - log.dbg(None, None, 'create Modem object', conf=conf) - return ofono_client.Modem(conf) # vim: expandtab tabstop=4 shiftwidth=4 -- To view, visit https://gerrit.osmocom.org/2772 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0048d33e661d683a263c98128cd5c38b8d897dab Gerrit-PatchSet: 1 Gerrit-Project: osmo-gsm-tester Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>