From 7b933db78a84b4d680d926b3d505be98f022965f Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Thu, 10 Sep 2020 16:12:41 -0700 Subject: [PATCH] auto-t: fix testBSSBlacklist There were a number of fixes here. The waits were changed to wait on the device state instead of the network state and hwsim rules were removed after the test as to not interfere with future tests. One of the rules was setting the signal to -10000 wich was causing the ranking to be zero. --- .../testBSSBlacklist/all_blacklisted_test.py | 11 ++++++++--- autotests/testBSSBlacklist/bad_pass_test.py | 8 +++++++- autotests/testBSSBlacklist/connection_test.py | 9 +++++++-- autotests/testBSSBlacklist/temp_blacklist_test.py | 15 ++++++++++++++- 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/autotests/testBSSBlacklist/all_blacklisted_test.py b/autotests/testBSSBlacklist/all_blacklisted_test.py index 099804a8..d3ed7acc 100644 --- a/autotests/testBSSBlacklist/all_blacklisted_test.py +++ b/autotests/testBSSBlacklist/all_blacklisted_test.py @@ -37,7 +37,7 @@ class Test(unittest.TestCase): rule2 = hwsim.rules.create() rule2.source = bss_radio[2].addresses[0] rule2.bidirectional = True - rule2.signal = -10000 + rule2.signal = -9000 wd = IWD(True) @@ -72,17 +72,22 @@ class Test(unittest.TestCase): rule0.drop = False rule1.drop = False + rule2.drop = False # This connect should work ordered_network.network_object.connect() - condition = 'obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(device, condition) self.assertIn(device.address, bss_hostapd[0].list_sta()) wd.unregister_psk_agent(psk_agent) + rule0.remove() + rule1.remove() + rule2.remove() + @classmethod def setUpClass(cls): pass diff --git a/autotests/testBSSBlacklist/bad_pass_test.py b/autotests/testBSSBlacklist/bad_pass_test.py index 220ffcc8..b2ceb998 100644 --- a/autotests/testBSSBlacklist/bad_pass_test.py +++ b/autotests/testBSSBlacklist/bad_pass_test.py @@ -39,7 +39,7 @@ class Test(unittest.TestCase): rule2.bidirectional = True rule2.signal = -4000 - wd = IWD(True, '/tmp') + wd = IWD(True) psk_agent = PSKAgent("wrong_password") wd.register_psk_agent(psk_agent) @@ -80,6 +80,12 @@ class Test(unittest.TestCase): condition = 'obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) + wd.unregister_psk_agent(psk_agent) + + rule0.remove() + rule1.remove() + rule2.remove() + @classmethod def setUpClass(cls): pass diff --git a/autotests/testBSSBlacklist/connection_test.py b/autotests/testBSSBlacklist/connection_test.py index 0a51b8cb..8083fc92 100644 --- a/autotests/testBSSBlacklist/connection_test.py +++ b/autotests/testBSSBlacklist/connection_test.py @@ -10,7 +10,6 @@ from iwd import PSKAgent from iwd import NetworkType from hostapd import HostapdCLI - from hwsim import Hwsim import time @@ -42,7 +41,7 @@ class Test(unittest.TestCase): rule2.bidirectional = True rule2.signal = -4000 - wd = IWD(True, '/tmp') + wd = IWD(True) psk_agent = PSKAgent("secret123") wd.register_psk_agent(psk_agent) @@ -67,6 +66,8 @@ class Test(unittest.TestCase): condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) + rule0.drop = True + ordered_network.network_object.connect(wait=False) # Have AP1 drop all packets, should result in a connection timeout @@ -140,6 +141,10 @@ class Test(unittest.TestCase): wd.unregister_psk_agent(psk_agent) + rule0.remove() + rule1.remove() + rule2.remove() + @classmethod def setUpClass(cls): IWD.copy_to_storage('main.conf') diff --git a/autotests/testBSSBlacklist/temp_blacklist_test.py b/autotests/testBSSBlacklist/temp_blacklist_test.py index b2b57035..2a9590b8 100644 --- a/autotests/testBSSBlacklist/temp_blacklist_test.py +++ b/autotests/testBSSBlacklist/temp_blacklist_test.py @@ -39,7 +39,7 @@ class Test(unittest.TestCase): rule2.bidirectional = True rule2.signal = -2000 - wd = IWD(True, '/tmp') + wd = IWD(True) psk_agent = PSKAgent("secret123") wd.register_psk_agent(psk_agent) @@ -63,6 +63,9 @@ class Test(unittest.TestCase): ordered_network.network_object.connect() + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(dev1, condition) + self.assertIn(dev1.address, bss_hostapd[2].list_sta()) # dev1 now connected, this should max out the first AP, causing the next @@ -85,6 +88,9 @@ class Test(unittest.TestCase): ordered_network.network_object.connect() + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(dev2, condition) + # We should have temporarily blacklisted the first BSS, and connected # to this one. self.assertIn(dev2.address, bss_hostapd[1].list_sta()) @@ -111,10 +117,17 @@ class Test(unittest.TestCase): ordered_network.network_object.connect() + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(dev2, condition) + self.assertIn(dev2.address, bss_hostapd[2].list_sta()) wd.unregister_psk_agent(psk_agent) + rule0.remove() + rule1.remove() + rule2.remove() + @classmethod def setUpClass(cls): IWD.copy_to_storage('main.conf')