mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2025-02-20 11:40:40 +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:
parent
9e32ea5e80
commit
6bffa395d9
@ -12,7 +12,6 @@ from iwd import NetworkType
|
|||||||
class TestConnectAutoconnect(unittest.TestCase):
|
class TestConnectAutoconnect(unittest.TestCase):
|
||||||
|
|
||||||
def check_connect(self, wd, device, ssid, throws):
|
def check_connect(self, wd, device, ssid, throws):
|
||||||
wd.wait(3);
|
|
||||||
ordered_networks = device.get_ordered_networks()
|
ordered_networks = device.get_ordered_networks()
|
||||||
ordered_network = None
|
ordered_network = None
|
||||||
|
|
||||||
@ -31,18 +30,12 @@ class TestConnectAutoconnect(unittest.TestCase):
|
|||||||
ordered_network.network_object.connect()
|
ordered_network.network_object.connect()
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
try:
|
|
||||||
ordered_network.network_object.connect()
|
ordered_network.network_object.connect()
|
||||||
except:
|
|
||||||
del wd
|
|
||||||
raise
|
|
||||||
|
|
||||||
condition = 'obj.connected'
|
condition = 'obj.connected'
|
||||||
wd.wait_for_object_condition(ordered_network.network_object, condition)
|
wd.wait_for_object_condition(ordered_network.network_object, condition)
|
||||||
|
|
||||||
def check_autoconnect(self, wd, device, ssid, throws):
|
def check_autoconnect(self, wd, device, ssid, throws):
|
||||||
wd.wait(3);
|
|
||||||
|
|
||||||
if throws is None:
|
if throws is None:
|
||||||
condition = 'obj.state == DeviceState.connected'
|
condition = 'obj.state == DeviceState.connected'
|
||||||
wd.wait_for_object_condition(device, condition)
|
wd.wait_for_object_condition(device, condition)
|
||||||
@ -61,33 +54,37 @@ class TestConnectAutoconnect(unittest.TestCase):
|
|||||||
condition = 'obj.state == DeviceState.disconnected'
|
condition = 'obj.state == DeviceState.disconnected'
|
||||||
wd.wait_for_object_condition(device, condition)
|
wd.wait_for_object_condition(device, condition)
|
||||||
|
|
||||||
def validate(self, ssid, autoconnect, throws = None, use_agent = False):
|
def validate_connection(self, wd, ssid, autoconnect, throws = None,
|
||||||
|
use_agent = False):
|
||||||
wd = IWD(True)
|
|
||||||
wd.wait(1);
|
|
||||||
|
|
||||||
if use_agent:
|
if use_agent:
|
||||||
psk_agent = PSKAgent("secret123")
|
psk_agent = PSKAgent("secret123")
|
||||||
wd.register_psk_agent(psk_agent)
|
wd.register_psk_agent(psk_agent)
|
||||||
|
|
||||||
devices = wd.list_devices();
|
devices = wd.list_devices(1);
|
||||||
self.assertIsNotNone(devices)
|
self.assertIsNotNone(devices)
|
||||||
device = devices[0]
|
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:
|
if autoconnect:
|
||||||
self.check_autoconnect(wd, device, ssid, throws)
|
self.check_autoconnect(wd, device, ssid, throws)
|
||||||
else:
|
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)
|
self.check_connect(wd, device, ssid, throws)
|
||||||
|
|
||||||
if use_agent:
|
if use_agent:
|
||||||
wd.unregister_psk_agent(psk_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
|
del wd
|
||||||
|
Loading…
x
Reference in New Issue
Block a user