eiwd

no dbus iwd with iwctl functionality
git clone https://git.daat.foo/repos/eiwd.git
Log | Files | Refs | Submodules | README | LICENSE

stop_retry_test.py (3404B)


      1 #!/usr/bin/python3
      2 
      3 import unittest
      4 import sys
      5 
      6 sys.path.append('../util')
      7 import iwd
      8 from iwd import IWD
      9 from iwd import PSKAgent
     10 from iwd import NetworkType
     11 
     12 import testutil
     13 
     14 from hostapd import HostapdCLI
     15 from hwsim import Hwsim
     16 
     17 class Test(unittest.TestCase):
     18     # Test that we do not periodically retry roaming if the transition looks
     19     # like this: LOW [roam] [new bss] HIGH.
     20     def test_stop_retry(self):
     21         hwsim = Hwsim()
     22 
     23         bss_hostapd = [ HostapdCLI(config='ssid1.conf'),
     24                         HostapdCLI(config='ssid2.conf') ]
     25         bss_radio =  [ hwsim.get_radio('rad0'),
     26                        hwsim.get_radio('rad1') ]
     27 
     28         rule0 = hwsim.rules.create()
     29         rule0.source = bss_radio[0].addresses[0]
     30         rule0.bidirectional = True
     31         rule0.enabled = True
     32 
     33         rule1 = hwsim.rules.create()
     34         rule1.source = bss_radio[1].addresses[0]
     35         rule1.bidirectional = True
     36         rule1.enabled = True
     37 
     38         HostapdCLI.group_neighbors(*bss_hostapd)
     39 
     40         # Start in the vicinity of BSS 0, check that iwd connects to BSS 0
     41         rule0.signal = -2000
     42         rule1.signal = -5000
     43 
     44         wd = IWD()
     45 
     46         psk_agent = PSKAgent("secret123")
     47         wd.register_psk_agent(psk_agent)
     48 
     49         devices = wd.list_devices(1)
     50         device = devices[0]
     51 
     52         ordered_network = device.get_ordered_network('TestRoamRetry', full_scan=True)
     53 
     54         self.assertEqual(ordered_network.type, NetworkType.psk)
     55 
     56         condition = 'not obj.connected'
     57         wd.wait_for_object_condition(ordered_network.network_object, condition)
     58 
     59         ordered_network.network_object.connect()
     60 
     61         condition = 'obj.state == DeviceState.connected'
     62         wd.wait_for_object_condition(device, condition)
     63 
     64         bss_hostapd[0].wait_for_event('AP-STA-CONNECTED %s' % device.address)
     65 
     66         # Now push the signal below the RSSI threshold and check that iwd
     67         # connects to BSS 1
     68         rule0.signal = -8000
     69 
     70         # Check that iwd is on BSS 1 once out of roaming state and doesn't
     71         # go through 'disconnected', 'autoconnect', 'connecting' in between
     72         from_condition = 'obj.state == DeviceState.roaming'
     73         to_condition = 'obj.state == DeviceState.connected'
     74         wd.wait_for_object_change(device, from_condition, to_condition)
     75 
     76         bss_hostapd[1].wait_for_event('AP-STA-CONNECTED %s' % device.address)
     77 
     78         # Now make sure that we don't roam anymore. In order to catch this via
     79         # DeviceState, a suitable roaming target needs to be available. So jack
     80         # up the RSSI of BSS 0 again. The retry interval is 60 seconds, so we
     81         # should have roamed within that timeframe. Wait just a little longer
     82         # to account for the slowness of the autotest environment.
     83         rule0.signal = -2000
     84 
     85         condition = 'obj.state == DeviceState.roaming'
     86         self.assertRaises(TimeoutError, wd.wait_for_object_condition, device,
     87                           condition, max_wait=10)
     88 
     89         device.disconnect()
     90 
     91         condition = 'not obj.connected'
     92         wd.wait_for_object_condition(ordered_network.network_object, condition)
     93 
     94         wd.unregister_psk_agent(psk_agent)
     95 
     96         rule0.remove()
     97         rule1.remove()
     98 
     99     @classmethod
    100     def setUpClass(cls):
    101         pass
    102 
    103     @classmethod
    104     def tearDownClass(cls):
    105         IWD.clear_storage()
    106 
    107 if __name__ == '__main__':
    108     unittest.main(exit=True)