commit 6bffa395d9416c54779a799d53ed11e453669198
parent 9e32ea5e80148ca2298348ce0616d6be0ac6d41e
Author: Tim Kourt <tim.a.kourt@linux.intel.com>
Date: Mon, 2 Jul 2018 16:17:35 -0700
auto-t: ConnectAutoconnect
1) wait for a device to become available
2) add try, except block for the clean termination of iwd in
the case of a failure
3) remove waits
4) eliminate a race condition on get_ordered_networks()
Diffstat:
1 file changed, 19 insertions(+), 22 deletions(-)
diff --git a/autotests/testConnectAutoconnect/validation.py b/autotests/testConnectAutoconnect/validation.py
@@ -12,7 +12,6 @@ from iwd import NetworkType
class TestConnectAutoconnect(unittest.TestCase):
def check_connect(self, wd, device, ssid, throws):
- wd.wait(3);
ordered_networks = device.get_ordered_networks()
ordered_network = None
@@ -31,18 +30,12 @@ class TestConnectAutoconnect(unittest.TestCase):
ordered_network.network_object.connect()
return
else:
- try:
- ordered_network.network_object.connect()
- except:
- del wd
- raise
+ ordered_network.network_object.connect()
condition = 'obj.connected'
wd.wait_for_object_condition(ordered_network.network_object, condition)
def check_autoconnect(self, wd, device, ssid, throws):
- wd.wait(3);
-
if throws is None:
condition = 'obj.state == DeviceState.connected'
wd.wait_for_object_condition(device, condition)
@@ -61,33 +54,37 @@ class TestConnectAutoconnect(unittest.TestCase):
condition = 'obj.state == DeviceState.disconnected'
wd.wait_for_object_condition(device, condition)
- def validate(self, ssid, autoconnect, throws = None, use_agent = False):
-
- wd = IWD(True)
- wd.wait(1);
-
+ def validate_connection(self, wd, ssid, autoconnect, throws = None,
+ use_agent = False):
if use_agent:
psk_agent = PSKAgent("secret123")
wd.register_psk_agent(psk_agent)
- devices = wd.list_devices();
+ devices = wd.list_devices(1);
self.assertIsNotNone(devices)
device = devices[0]
+ condition = 'obj.scanning'
+ wd.wait_for_object_condition(device, condition)
+
+ condition = 'not obj.scanning'
+ wd.wait_for_object_condition(device, condition)
+
if autoconnect:
self.check_autoconnect(wd, device, ssid, throws)
else:
- condition = 'not obj.scanning'
- wd.wait_for_object_condition(device, condition)
-
- device.scan()
-
- condition = 'not obj.scanning'
- wd.wait_for_object_condition(device, condition)
-
self.check_connect(wd, device, ssid, throws)
if use_agent:
wd.unregister_psk_agent(psk_agent)
+ def validate(self, ssid, autoconnect, throws = None, use_agent = False):
+ wd = IWD(True)
+
+ try:
+ self.validate_connection(wd, ssid, autoconnect, throws, use_agent)
+ except:
+ del wd
+ raise
+
del wd