eiwd

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

netconfig_roam_test.py (2872B)


      1 #! /usr/bin/python3
      2 
      3 import unittest
      4 import sys, os
      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 from iwd import DeviceState
     12 from hwsim import Hwsim
     13 from hostapd import HostapdCLI
     14 import testutil
     15 
     16 class Test(unittest.TestCase):
     17     def test_roam_before_netconfig(self):
     18         wd = IWD(True)
     19 
     20         device = wd.list_devices(1)[0]
     21         device.get_ordered_network('TestFT', full_scan=True)
     22         device.connect_bssid(self.bss_hostapd[1].bssid, wait=False)
     23 
     24         self.bss_hostapd[1].wait_for_event(f'AP-STA-CONNECTED {device.address}')
     25         device.wait_for_event("connecting (netconfig)")
     26 
     27         roam_to = 0
     28         roam_from = 1
     29 
     30         # Roam back and forth, ensuring that the state transitions between
     31         # roaming and connecting (netconfig).
     32         for _ in range(0, 5):
     33             self.rules[roam_to].signal = -2000
     34             self.rules[roam_from].signal = -8000
     35 
     36             # Station should internally transition to roaming, but remain in a
     37             # connecting state on DBus
     38             device.wait_for_event("ft-roaming")
     39             self.assertEqual(device.state, DeviceState.connecting)
     40 
     41             self.bss_hostapd[roam_to].wait_for_event(f'AP-STA-CONNECTED {device.address}')
     42             device.wait_for_event("connecting (netconfig)")
     43 
     44             tmp = roam_from
     45             roam_from = roam_to
     46             roam_to = tmp
     47 
     48         self.bss_hostapd[roam_from].deauthenticate(device.address)
     49         condition = 'obj.state == DeviceState.disconnected'
     50         wd.wait_for_object_condition(device, condition)
     51 
     52     def tearDown(self):
     53         os.system('ip link set "' + self.bss_hostapd[0].ifname + '" down')
     54         os.system('ip link set "' + self.bss_hostapd[1].ifname + '" down')
     55         os.system('ip link set "' + self.bss_hostapd[0].ifname + '" up')
     56         os.system('ip link set "' + self.bss_hostapd[1].ifname + '" up')
     57 
     58     @classmethod
     59     def setUpClass(cls):
     60         hwsim = Hwsim()
     61 
     62         IWD.copy_to_storage('TestFT.psk')
     63 
     64         cls.bss_hostapd = [ HostapdCLI(config='ft-psk-ccmp-1.conf'),
     65                             HostapdCLI(config='ft-psk-ccmp-2.conf') ]
     66 
     67         rule0 = hwsim.rules.create()
     68         rule0.source = cls.bss_hostapd[0].bssid
     69         rule0.signal = -6000
     70         rule0.enabled = True
     71 
     72         rule1 = hwsim.rules.create()
     73         rule1.source = cls.bss_hostapd[1].bssid
     74         rule1.signal = -2000
     75         rule1.enabled = True
     76 
     77         cls.rules = [rule0, rule1]
     78 
     79         cls.bss_hostapd[0].set_address('12:00:00:00:00:01')
     80         cls.bss_hostapd[1].set_address('12:00:00:00:00:02')
     81 
     82         HostapdCLI.group_neighbors(*cls.bss_hostapd)
     83 
     84     @classmethod
     85     def tearDownClass(cls):
     86         IWD.clear_storage()
     87         cls.bss_hostapd = None
     88         cls.rules = None
     89 
     90 if __name__ == '__main__':
     91     unittest.main(exit=True)