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/.
Pau Espin Pedrol gerrit-no-reply at lists.osmocom.orgHello Jenkins Builder,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/2697
to look at the new patch set (#2).
ofono_client: Power off modem when resource is freed
Change-Id: Ibde7573267f1c63d075cf0147ed614a4b1ff46c8
---
M selftest/suite_test.py
M src/osmo_gsm_tester/ofono_client.py
M src/osmo_gsm_tester/resource.py
M src/osmo_gsm_tester/suite.py
4 files changed, 42 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/97/2697/2
diff --git a/selftest/suite_test.py b/selftest/suite_test.py
index 16342c5..cc0bc5e 100755
--- a/selftest/suite_test.py
+++ b/selftest/suite_test.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
import os
import _prep
-from osmo_gsm_tester import log, suite, config, report
+from osmo_gsm_tester import log, suite, config, report, ofono_client
config.ENV_CONF = './suite_test'
@@ -50,5 +50,11 @@
assert "type:'EpicFail' message: This failure is expected" in output
assert "raise Failure('EpicFail', 'This failure is expected')" in output
+# Avoid ofono_client trying to power off automatically the modems when resources
+# are freed. The output is difficult to catch and depending on the fact that the
+# host has ofono service running the output will differ. On top, we also avoid
+# using ofono for resource reservation by setting manually the modem paths in
+# the config.
+s.resources_pool.free_cb_list.remove(ofono_client.freed_resource_poweroff)
print('\n- graceful exit.')
# vim: expandtab tabstop=4 shiftwidth=4
diff --git a/src/osmo_gsm_tester/ofono_client.py b/src/osmo_gsm_tester/ofono_client.py
index 8c19dfd..5cfa60e 100644
--- a/src/osmo_gsm_tester/ofono_client.py
+++ b/src/osmo_gsm_tester/ofono_client.py
@@ -148,6 +148,15 @@
else:
log_obj.raise_exn('No free modem found with IMSI', imsi)
+def freed_resource_poweroff(log_obj, to_be_freed, reserved):
+ modem_to_be = to_be_freed.get(resource.R_MODEM)
+ if not modem_to_be:
+ return
+ for freed_dict in modem_to_be:
+ dbus_obj = systembus_get(freed_dict['path'])
+ log_obj.dbg('free modem resource, poweroff:', freed_dict['path'])
+ modem_set_powered_sync(log_obj, dbus_obj, False)
+
class Modem(log.Origin):
'convenience for ofono Modem interaction'
diff --git a/src/osmo_gsm_tester/resource.py b/src/osmo_gsm_tester/resource.py
index 6483cb6..cbe83e9 100644
--- a/src/osmo_gsm_tester/resource.py
+++ b/src/osmo_gsm_tester/resource.py
@@ -85,6 +85,7 @@
self.state_dir = config.get_state_dir()
self.set_name(conf=self.config_path, state=self.state_dir.path)
self.reserve_cb_list = []
+ self.free_cb_list = []
self.read_conf()
def read_conf(self):
@@ -108,6 +109,25 @@
previously reserved.
'''
self.reserve_cb_list.append(cb)
+
+ def add_on_free_cb(self, cb):
+ '''
+ Add a hook to be able to read/modify parameters to previously reserved
+ resources being freed. This is callback is called while the state lock
+ is being hold.
+
+ cb method will be called as follows: cb(origin, to_be_freed,
+ reserved)
+
+ 'origin' a log.Origin() instance which can be sued to log information.
+
+ 'to_be_reserved' A Resources() instance which represents the resources
+ that are being freed now.
+
+ 'reserved' A Resources() instance which represents the current reserved
+ resources set, without the subset of to_be_freed resources.
+ '''
+ self.free_cb_list.append(cb)
def reserve(self, origin, want):
'''
@@ -182,6 +202,11 @@
rrfile_path = self.state_dir.mk_parentdir(RESERVED_RESOURCES_FILE)
reserved = Resources(config.read(rrfile_path, if_missing_return={}))
reserved.drop(to_be_freed)
+ for cb in self.free_cb_list:
+ try:
+ cb(self, to_be_freed, reserved)
+ except Exception:
+ self.log_exn()
config.write(rrfile_path, reserved)
self.forget_freed(to_be_freed)
diff --git a/src/osmo_gsm_tester/suite.py b/src/osmo_gsm_tester/suite.py
index eecea91..a96e454 100644
--- a/src/osmo_gsm_tester/suite.py
+++ b/src/osmo_gsm_tester/suite.py
@@ -182,6 +182,7 @@
self.set_log_category(log.C_TST)
self.resources_pool = resource.ResourcesPool()
self.resources_pool.add_on_reserve_cb(ofono_client.reserved_resource_populate_path)
+ self.resources_pool.add_on_free_cb(ofono_client.freed_resource_poweroff)
def mark_start(self):
self.tests = []
--
To view, visit https://gerrit.osmocom.org/2697
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ibde7573267f1c63d075cf0147ed614a4b1ff46c8
Gerrit-PatchSet: 2
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder