3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-02 10:09:23 +01:00
iwd/autotests/testScan/periodic_scan_test.py
James Prestwood 836f0d9a08 auto-t: set autoconnect=True for tests that need it
After the default behavior was changed to disable autoconnect there
were several tests which still needed it to be turned on.
2021-08-12 16:59:05 -05:00

69 lines
1.7 KiB
Python

#!/usr/bin/python3
import unittest
import sys
sys.path.append('../util')
import iwd
from iwd import IWD
class Test(unittest.TestCase):
dict = {
'ssid_open': False,
'ssid_psk': False,
'ssid_8021x': False,
'ssid_hidden_1': False,
}
def set_network(self, ssid):
if ssid not in self.dict:
return
if self.dict[ssid]:
raise Exception('Duplicated list entry')
self.dict[ssid] = True
def validate_scan(self, wd):
devices = wd.list_devices(1)
self.assertIsNotNone(devices)
device = devices[0]
device.autoconnect = True
# Device initiates a passive periodic scan.
condition = 'obj.scanning'
wd.wait_for_object_condition(device, condition)
condition = 'not obj.scanning'
wd.wait_for_object_condition(device, condition)
# Hidden networks observed in the scan results, device initialtes a
# second active periodic scan to discover the known hidden networks.
condition = 'obj.scanning'
wd.wait_for_object_condition(device, condition)
condition = 'not obj.scanning'
wd.wait_for_object_condition(device, condition)
ordered_networks = device.get_ordered_networks()
for network in ordered_networks:
self.set_network(network.name)
def test_scan(self):
wd = IWD(True, '/tmp')
self.validate_scan(wd)
for ssid, seen in self.dict.items():
self.assertEqual(seen, True)
@classmethod
def setUpClass(cls):
IWD.copy_to_storage('ssid_hidden_1.open')
@classmethod
def tearDownClass(cls):
IWD.clear_storage()
if __name__ == '__main__':
unittest.main(exit=True)