eiwd

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

roam_ap_disconnect_test.py (3498B)


      1 #! /usr/bin/python3
      2 
      3 import unittest
      4 import sys, os
      5 
      6 sys.path.append('../util')
      7 from iwd import IWD
      8 from iwd import NetworkType
      9 from hwsim import Hwsim
     10 from hostapd import HostapdCLI
     11 
     12 class Test(unittest.TestCase):
     13     #
     14     # Tests a crash reported where multiple roam scans combined with an AP
     15     # disconnect result in a crash getting scan results.
     16     #
     17     def validate(self, wd):
     18         device = wd.list_devices(1)[0]
     19 
     20         ordered_network = device.get_ordered_network('TestFT', full_scan=True)
     21 
     22         self.assertEqual(ordered_network.type, NetworkType.psk)
     23 
     24         condition = 'not obj.connected'
     25         wd.wait_for_object_condition(ordered_network.network_object, condition)
     26 
     27         device.connect_bssid(self.bss_hostapd[0].bssid)
     28 
     29         condition = 'obj.state == DeviceState.connected'
     30         wd.wait_for_object_condition(device, condition)
     31 
     32         # Since both BSS's have low signal, the roam should fail and trigger
     33         # another roam scan.
     34         device.wait_for_event('roam-scan-triggered', timeout=30)
     35         device.wait_for_event('no-roam-candidates', timeout=60)
     36 
     37         # Hostapd sends disconnect
     38         self.bss_hostapd[0].disable()
     39 
     40         # IWD should recover, and not crash
     41         condition = 'obj.state == DeviceState.disconnected'
     42         wd.wait_for_object_condition(device, condition)
     43 
     44     def test_ap_disconnect_no_neighbors(self):
     45         self.validate(self.wd)
     46 
     47     def test_ap_disconnect_neighbors(self):
     48         HostapdCLI.group_neighbors(*self.bss_hostapd)
     49 
     50         self.validate(self.wd)
     51 
     52     def setUp(self):
     53         self.wd = IWD(True)
     54         self.bss_hostapd[0].reload()
     55         self.bss_hostapd[0].wait_for_event("AP-ENABLED")
     56 
     57     def tearDown(self):
     58         os.system('ip link set "' + self.bss_hostapd[0].ifname + '" down')
     59         os.system('ip link set "' + self.bss_hostapd[1].ifname + '" down')
     60         os.system('ip link set "' + self.bss_hostapd[0].ifname + '" up')
     61         os.system('ip link set "' + self.bss_hostapd[1].ifname + '" up')
     62 
     63         self.bss_hostapd[0].remove_neighbor(self.bss_hostapd[1].bssid)
     64         self.bss_hostapd[1].remove_neighbor(self.bss_hostapd[0].bssid)
     65 
     66         self.wd.stop()
     67         self.wd = None
     68 
     69     @classmethod
     70     def setUpClass(cls):
     71         hwsim = Hwsim()
     72 
     73         IWD.copy_to_storage('TestFT.psk')
     74 
     75         cls.bss_hostapd = [ HostapdCLI(config='ft-psk-ccmp-1.conf'),
     76                             HostapdCLI(config='ft-psk-ccmp-2.conf'),
     77                             HostapdCLI(config='ft-psk-ccmp-3.conf') ]
     78         cls.bss_hostapd[1].disable()
     79         cls.bss_hostapd[2].disable()
     80 
     81         cls.bss_hostapd[0].set_value('ocv', '0')
     82         cls.bss_hostapd[0].set_value('ieee80211w', '0')
     83 
     84         rad0 = hwsim.get_radio('rad0')
     85         rad1 = hwsim.get_radio('rad1')
     86 
     87         cls.rule0 = hwsim.rules.create()
     88         cls.rule0.source = rad0.addresses[0]
     89         cls.rule0.bidirectional = True
     90         cls.rule0.signal = -8000
     91         cls.rule0.enabled = True
     92 
     93         cls.rule1 = hwsim.rules.create()
     94         cls.rule1.source = rad1.addresses[0]
     95         cls.rule1.bidirectional = True
     96         cls.rule1.signal = -8500
     97         cls.rule1.enabled = True
     98 
     99         cls.bss_hostapd[0].set_address('12:00:00:00:00:01')
    100         cls.bss_hostapd[1].set_address('12:00:00:00:00:02')
    101 
    102     @classmethod
    103     def tearDownClass(cls):
    104         IWD.clear_storage()
    105         cls.bss_hostapd = None
    106         cls.rule0.remove()
    107         cls.rule1.remove()
    108 
    109 if __name__ == '__main__':
    110     unittest.main(exit=True)