mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-01 15:49:49 +01:00
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".
This commit is contained in:
parent
fb1296e9c0
commit
003c1dbc97
@ -798,7 +798,7 @@ class IWD(AsyncOpAbstract):
|
|||||||
assert not os.path.isabs(source)
|
assert not os.path.isabs(source)
|
||||||
shutil.copy(source, IWD_STORAGE_DIR)
|
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:
|
if not wait_to_appear:
|
||||||
return list(self._devices.values())
|
return list(self._devices.values())
|
||||||
|
|
||||||
@ -809,7 +809,7 @@ class IWD(AsyncOpAbstract):
|
|||||||
|
|
||||||
timeout = GLib.timeout_add_seconds(max_wait, wait_timeout_cb)
|
timeout = GLib.timeout_add_seconds(max_wait, wait_timeout_cb)
|
||||||
context = mainloop.get_context()
|
context = mainloop.get_context()
|
||||||
while len(self._devices) == 0:
|
while len(self._devices) < wait_to_appear:
|
||||||
context.iteration(may_block=True)
|
context.iteration(may_block=True)
|
||||||
if self._wait_timed_out:
|
if self._wait_timed_out:
|
||||||
raise TimeoutError('IWD has no associated devices')
|
raise TimeoutError('IWD has no associated devices')
|
||||||
|
Loading…
Reference in New Issue
Block a user