3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-22 06:29:23 +01:00

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.
This commit is contained in:
James Prestwood 2020-09-10 16:12:41 -07:00 committed by Denis Kenzior
parent b9cb6134d6
commit 7b933db78a
4 changed files with 36 additions and 7 deletions

View File

@ -37,7 +37,7 @@ class Test(unittest.TestCase):
rule2 = hwsim.rules.create() rule2 = hwsim.rules.create()
rule2.source = bss_radio[2].addresses[0] rule2.source = bss_radio[2].addresses[0]
rule2.bidirectional = True rule2.bidirectional = True
rule2.signal = -10000 rule2.signal = -9000
wd = IWD(True) wd = IWD(True)
@ -72,17 +72,22 @@ class Test(unittest.TestCase):
rule0.drop = False rule0.drop = False
rule1.drop = False rule1.drop = False
rule2.drop = False
# This connect should work # This connect should work
ordered_network.network_object.connect() ordered_network.network_object.connect()
condition = 'obj.connected' condition = 'obj.state == DeviceState.connected'
wd.wait_for_object_condition(ordered_network.network_object, condition) wd.wait_for_object_condition(device, condition)
self.assertIn(device.address, bss_hostapd[0].list_sta()) self.assertIn(device.address, bss_hostapd[0].list_sta())
wd.unregister_psk_agent(psk_agent) wd.unregister_psk_agent(psk_agent)
rule0.remove()
rule1.remove()
rule2.remove()
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
pass pass

View File

@ -39,7 +39,7 @@ class Test(unittest.TestCase):
rule2.bidirectional = True rule2.bidirectional = True
rule2.signal = -4000 rule2.signal = -4000
wd = IWD(True, '/tmp') wd = IWD(True)
psk_agent = PSKAgent("wrong_password") psk_agent = PSKAgent("wrong_password")
wd.register_psk_agent(psk_agent) wd.register_psk_agent(psk_agent)
@ -80,6 +80,12 @@ class Test(unittest.TestCase):
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)
wd.unregister_psk_agent(psk_agent)
rule0.remove()
rule1.remove()
rule2.remove()
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
pass pass

View File

@ -10,7 +10,6 @@ from iwd import PSKAgent
from iwd import NetworkType from iwd import NetworkType
from hostapd import HostapdCLI from hostapd import HostapdCLI
from hwsim import Hwsim from hwsim import Hwsim
import time import time
@ -42,7 +41,7 @@ class Test(unittest.TestCase):
rule2.bidirectional = True rule2.bidirectional = True
rule2.signal = -4000 rule2.signal = -4000
wd = IWD(True, '/tmp') wd = IWD(True)
psk_agent = PSKAgent("secret123") psk_agent = PSKAgent("secret123")
wd.register_psk_agent(psk_agent) wd.register_psk_agent(psk_agent)
@ -67,6 +66,8 @@ class Test(unittest.TestCase):
condition = 'not obj.connected' condition = 'not obj.connected'
wd.wait_for_object_condition(ordered_network.network_object, condition) wd.wait_for_object_condition(ordered_network.network_object, condition)
rule0.drop = True
ordered_network.network_object.connect(wait=False) ordered_network.network_object.connect(wait=False)
# Have AP1 drop all packets, should result in a connection timeout # 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) wd.unregister_psk_agent(psk_agent)
rule0.remove()
rule1.remove()
rule2.remove()
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
IWD.copy_to_storage('main.conf') IWD.copy_to_storage('main.conf')

View File

@ -39,7 +39,7 @@ class Test(unittest.TestCase):
rule2.bidirectional = True rule2.bidirectional = True
rule2.signal = -2000 rule2.signal = -2000
wd = IWD(True, '/tmp') wd = IWD(True)
psk_agent = PSKAgent("secret123") psk_agent = PSKAgent("secret123")
wd.register_psk_agent(psk_agent) wd.register_psk_agent(psk_agent)
@ -63,6 +63,9 @@ class Test(unittest.TestCase):
ordered_network.network_object.connect() 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()) self.assertIn(dev1.address, bss_hostapd[2].list_sta())
# dev1 now connected, this should max out the first AP, causing the next # 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() 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 # We should have temporarily blacklisted the first BSS, and connected
# to this one. # to this one.
self.assertIn(dev2.address, bss_hostapd[1].list_sta()) self.assertIn(dev2.address, bss_hostapd[1].list_sta())
@ -111,10 +117,17 @@ class Test(unittest.TestCase):
ordered_network.network_object.connect() 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()) self.assertIn(dev2.address, bss_hostapd[2].list_sta())
wd.unregister_psk_agent(psk_agent) wd.unregister_psk_agent(psk_agent)
rule0.remove()
rule1.remove()
rule2.remove()
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
IWD.copy_to_storage('main.conf') IWD.copy_to_storage('main.conf')