mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-22 13:02:44 +01:00
autotests: Always clean up in testAP
Make sure stop_ap is called on success and on failure in both tests so that one can succeed after the other has failed. Also make sure to move both interfaces out of autoconnect state.
This commit is contained in:
parent
700b7de175
commit
1024562e1d
@ -69,34 +69,37 @@ class Test(unittest.TestCase):
|
|||||||
wd = IWD()
|
wd = IWD()
|
||||||
|
|
||||||
dev1, dev2 = wd.list_devices(2)
|
dev1, dev2 = wd.list_devices(2)
|
||||||
|
dev1.disconnect()
|
||||||
|
dev2.disconnect()
|
||||||
|
|
||||||
self.client_connect(wd, dev1)
|
self.client_connect(wd, dev1)
|
||||||
|
|
||||||
dev1.start_ap('TestAP2', 'Password2')
|
dev1.start_ap('TestAP2', 'Password2')
|
||||||
|
|
||||||
condition = 'not obj.scanning'
|
try:
|
||||||
wd.wait_for_object_condition(dev2, condition)
|
condition = 'not obj.scanning'
|
||||||
dev2.scan()
|
wd.wait_for_object_condition(dev2, condition)
|
||||||
condition = 'obj.scanning'
|
dev2.scan()
|
||||||
wd.wait_for_object_condition(dev2, condition)
|
condition = 'obj.scanning'
|
||||||
condition = 'not obj.scanning'
|
wd.wait_for_object_condition(dev2, condition)
|
||||||
wd.wait_for_object_condition(dev2, condition)
|
condition = 'not obj.scanning'
|
||||||
|
wd.wait_for_object_condition(dev2, condition)
|
||||||
|
|
||||||
ordered_networks = dev2.get_ordered_networks()
|
ordered_networks = dev2.get_ordered_networks()
|
||||||
self.assertEqual(len(ordered_networks), 2)
|
self.assertEqual(len(ordered_networks), 2)
|
||||||
networks = { n.name: n for n in ordered_networks }
|
networks = { n.name: n for n in ordered_networks }
|
||||||
self.assertEqual(networks['TestAP1'].type, NetworkType.psk)
|
self.assertEqual(networks['TestAP1'].type, NetworkType.psk)
|
||||||
self.assertEqual(networks['TestAP2'].type, NetworkType.psk)
|
self.assertEqual(networks['TestAP2'].type, NetworkType.psk)
|
||||||
|
|
||||||
psk_agent = PSKAgent('InvalidPassword')
|
psk_agent = PSKAgent('InvalidPassword')
|
||||||
wd.register_psk_agent(psk_agent)
|
wd.register_psk_agent(psk_agent)
|
||||||
|
|
||||||
with self.assertRaises(iwd.FailedEx):
|
with self.assertRaises(iwd.FailedEx):
|
||||||
networks['TestAP2'].network_object.connect()
|
networks['TestAP2'].network_object.connect()
|
||||||
|
|
||||||
wd.unregister_psk_agent(psk_agent)
|
wd.unregister_psk_agent(psk_agent)
|
||||||
|
finally:
|
||||||
dev1.stop_ap()
|
dev1.stop_ap()
|
||||||
|
|
||||||
# Finally test dev1 can go to client mode and connect again
|
# Finally test dev1 can go to client mode and connect again
|
||||||
self.client_connect(wd, dev1)
|
self.client_connect(wd, dev1)
|
||||||
|
@ -62,53 +62,56 @@ class Test(unittest.TestCase):
|
|||||||
wd = IWD()
|
wd = IWD()
|
||||||
|
|
||||||
dev1, dev2 = wd.list_devices(2)
|
dev1, dev2 = wd.list_devices(2)
|
||||||
|
dev1.disconnect()
|
||||||
|
dev2.disconnect()
|
||||||
|
|
||||||
self.client_connect(wd, dev1)
|
self.client_connect(wd, dev1)
|
||||||
|
|
||||||
dev1.start_ap('TestAP2', 'Password2')
|
dev1.start_ap('TestAP2', 'Password2')
|
||||||
|
|
||||||
condition = 'not obj.scanning'
|
|
||||||
wd.wait_for_object_condition(dev2, condition)
|
|
||||||
dev2.scan()
|
|
||||||
condition = 'obj.scanning'
|
|
||||||
wd.wait_for_object_condition(dev2, condition)
|
|
||||||
condition = 'not obj.scanning'
|
|
||||||
wd.wait_for_object_condition(dev2, condition)
|
|
||||||
|
|
||||||
ordered_networks = dev2.get_ordered_networks()
|
|
||||||
self.assertEqual(len(ordered_networks), 2)
|
|
||||||
networks = { n.name: n for n in ordered_networks }
|
|
||||||
self.assertEqual(networks['TestAP1'].type, NetworkType.psk)
|
|
||||||
self.assertEqual(networks['TestAP2'].type, NetworkType.psk)
|
|
||||||
|
|
||||||
psk_agent = PSKAgent('Password2')
|
|
||||||
wd.register_psk_agent(psk_agent)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
dev2.disconnect()
|
condition = 'not obj.scanning'
|
||||||
condition = 'not obj.connected'
|
wd.wait_for_object_condition(dev2, condition)
|
||||||
|
dev2.scan()
|
||||||
|
condition = 'obj.scanning'
|
||||||
|
wd.wait_for_object_condition(dev2, condition)
|
||||||
|
condition = 'not obj.scanning'
|
||||||
wd.wait_for_object_condition(dev2, condition)
|
wd.wait_for_object_condition(dev2, condition)
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
networks['TestAP2'].network_object.connect()
|
ordered_networks = dev2.get_ordered_networks()
|
||||||
|
self.assertEqual(len(ordered_networks), 2)
|
||||||
|
networks = { n.name: n for n in ordered_networks }
|
||||||
|
self.assertEqual(networks['TestAP1'].type, NetworkType.psk)
|
||||||
|
self.assertEqual(networks['TestAP2'].type, NetworkType.psk)
|
||||||
|
|
||||||
condition = 'obj.connected'
|
psk_agent = PSKAgent('Password2')
|
||||||
wd.wait_for_object_condition(networks['TestAP2'].network_object,
|
wd.register_psk_agent(psk_agent)
|
||||||
condition)
|
|
||||||
|
|
||||||
testutil.test_iface_operstate(dev2.name)
|
try:
|
||||||
testutil.test_ifaces_connected(dev1.name, dev2.name)
|
dev2.disconnect()
|
||||||
|
condition = 'not obj.connected'
|
||||||
|
wd.wait_for_object_condition(dev2, condition)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
wd.unregister_psk_agent(psk_agent)
|
networks['TestAP2'].network_object.connect()
|
||||||
|
|
||||||
dev2.disconnect()
|
condition = 'obj.connected'
|
||||||
|
wd.wait_for_object_condition(networks['TestAP2'].network_object,
|
||||||
|
condition)
|
||||||
|
|
||||||
condition = 'not obj.connected'
|
testutil.test_iface_operstate(dev2.name)
|
||||||
wd.wait_for_object_condition(networks['TestAP2'].network_object,
|
testutil.test_ifaces_connected(dev1.name, dev2.name)
|
||||||
condition)
|
|
||||||
|
|
||||||
dev1.stop_ap()
|
wd.unregister_psk_agent(psk_agent)
|
||||||
|
|
||||||
|
dev2.disconnect()
|
||||||
|
|
||||||
|
condition = 'not obj.connected'
|
||||||
|
wd.wait_for_object_condition(networks['TestAP2'].network_object,
|
||||||
|
condition)
|
||||||
|
finally:
|
||||||
|
dev1.stop_ap()
|
||||||
|
|
||||||
# Finally test dev1 can go to client mode and connect again
|
# Finally test dev1 can go to client mode and connect again
|
||||||
self.client_connect(wd, dev1)
|
self.client_connect(wd, dev1)
|
||||||
|
Loading…
Reference in New Issue
Block a user