commit 5519faecbaebcc8db2fe048921da35e6015ad322
parent 4f5010f69db1c8af39ae411ee1e605933e298d0b
Author: James Prestwood <prestwoj@gmail.com>
Date: Thu, 12 Aug 2021 13:38:09 -0700
auto-t: iwd.py: make scan_if_needed True by default
There is a common block of code in nearly every test which is incorrect,
most likely a copy-paste from long ago. It goes something like:
wd.wait_for_object_condition(device, 'not obj.scanning')
device.scan()
wd.wait_for_object_condition(device, 'not obj.scanning')
network = device.get_ordered_network("ssid")
The problem here is that sometimes the scanning property does not get
updated fast enough before device.scan() returns, meaning get_ordered_network
comes up with nothing. Some tests pass scan_if_needed=True which 'fixes'
this but ends up re-scanning after the original scan finishes.
To put this to rest scan_if_needed is now defaulted to True, and no
explicit scan should be needed.
Diffstat:
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/autotests/util/iwd.py b/autotests/util/iwd.py
@@ -410,7 +410,7 @@ class Device(IWDDBusAbstract):
self._wait_for_async_op()
- def get_ordered_networks(self, scan_if_needed = False):
+ def get_ordered_networks(self, scan_if_needed = True):
'''Return the list of networks found in the most recent
scan, sorted by their user interface importance
score as calculated by iwd. If the device is
@@ -432,7 +432,13 @@ class Device(IWDDBusAbstract):
elif not scan_if_needed:
return None
- self.scan()
+ condition = 'not obj.scanning'
+ IWD._wait_for_object_condition(self, condition)
+
+ try:
+ self.scan()
+ except InProgressEx:
+ pass
condition = 'obj.scanning'
IWD._wait_for_object_condition(self, condition)
@@ -448,7 +454,7 @@ class Device(IWDDBusAbstract):
return None
- def get_ordered_network(self, network, scan_if_needed = False):
+ def get_ordered_network(self, network, scan_if_needed = True):
'''Returns a single network from ordered network call, or None if the
network wasn't found. If the network is not found an exception is
raised, this removes the need to extra asserts in autotests.