From 003c1dbc977749bc93d7122a1985689807d78a26 Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Mon, 2 Jul 2018 10:02:07 -0700 Subject: [PATCH] auto-t: Changed list_devices() wait_to_appear to int The list_devices API has a race condition where sometimes it will return zero or less than the expected number of devices and fail the test. A fix is in place for when only a single devices is expected, but some tests expect more than one device. This changes wait_to_appear to an integer, and the caller can specify the number of devices they expect to get back. The default stays as it was, zero or "return cached devices". --- autotests/util/iwd.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autotests/util/iwd.py b/autotests/util/iwd.py index f432feb1..c8b1326d 100755 --- a/autotests/util/iwd.py +++ b/autotests/util/iwd.py @@ -798,7 +798,7 @@ class IWD(AsyncOpAbstract): assert not os.path.isabs(source) shutil.copy(source, IWD_STORAGE_DIR) - def list_devices(self, wait_to_appear = False, max_wait = 15): + def list_devices(self, wait_to_appear = 0, max_wait = 15): if not wait_to_appear: return list(self._devices.values()) @@ -809,7 +809,7 @@ class IWD(AsyncOpAbstract): timeout = GLib.timeout_add_seconds(max_wait, wait_timeout_cb) context = mainloop.get_context() - while len(self._devices) == 0: + while len(self._devices) < wait_to_appear: context.iteration(may_block=True) if self._wait_timed_out: raise TimeoutError('IWD has no associated devices')