commit ad97dbee0874fcf3876247a60daeb5e643d79d77
parent 85259bb51906530f31a78b29c9bb2bf43e63e5ab
Author: James Prestwood <prestwoj@gmail.com>
Date: Thu, 10 Sep 2020 16:12:26 -0700
auto-t: ofono.py: fix timeout cleanup and wait for service
Ofono.py was not cleaning up the timeout, nor waiting for the ofono.org
service to come up before continuing.
Diffstat:
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/autotests/util/ofono.py b/autotests/util/ofono.py
@@ -1,4 +1,5 @@
import dbus
+import time
from gi.repository import GLib
SIM_AUTH_IFACE = 'org.ofono.SimAuthentication'
@@ -7,6 +8,14 @@ class Ofono(dbus.service.Object):
def __init__(self):
self._bus = dbus.SystemBus()
+ tries = 0
+
+ while not self._bus.name_has_owner('org.ofono'):
+ if tries > 100:
+ raise TimeoutError('Waiting for org.ofono service timed out')
+ tries += 1
+ time.sleep(0.1)
+
def enable_modem(self, path):
self._modem_path = path
self._modem_iface = dbus.Interface(
@@ -37,11 +46,13 @@ class Ofono(dbus.service.Object):
self._wait_timed_out = True
return False
- timeout = GLib.timeout_add_seconds(max_wait, wait_timeout_cb)
- context = mainloop.get_context()
- while (not self._sim_auth_up):
- context.iteration(may_block=True)
- if self._wait_timed_out:
- raise TimeoutError('waiting for SimAuthentication timed out')
+ try:
+ timeout = GLib.timeout_add_seconds(max_wait, wait_timeout_cb)
+ context = mainloop.get_context()
+ while (not self._sim_auth_up):
+ context.iteration(may_block=True)
+ if self._wait_timed_out:
+ raise TimeoutError('waiting for SimAuthentication timed out')
- GLib.source_remove(timeout)
+ finally:
+ GLib.source_remove(timeout)