3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-26 09:32:34 +01:00

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()
This commit is contained in:
Tim Kourt 2018-07-02 16:17:35 -07:00 committed by Denis Kenzior
parent 9e32ea5e80
commit 6bffa395d9

View File

@ -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