auto-t: prepare autotests for test-runner re-write
PATCH v4 1/26 auto-t: prepare autotests for test-runner re-write
The tests basically remained the same with a few minor changes. The wiphy_map and in turn hostapd_map are no longer used. This was already partially converted a long time ago when the 'config' parameter was added to HostapdCLI. This patch fully converts all autotests to use 'config' rather than looking up by interface.
Some test scripts were named 'test.py' which was fine before but the new rewrite actually loads each python test as a module. The name 'test' is too ambiguous and causes issues due to a native python module with the same name. All of these files were renamed to 'connection_test.py'.
---
.../{test.py => connection_test.py} | 0
.../testAP/{test.py => connection_test.py} | 9 ++--
autotests/testAP/failure_test.py | 6 +--
autotests/testAPRoam/connection_test.py | 2 -
.../testBSSBlacklist/all_blacklisted_test.py | 4 --
autotests/testBSSBlacklist/bad_pass_test.py | 4 --
autotests/testBSSBlacklist/connection_test.py | 1 -
.../testBSSBlacklist/temp_blacklist_test.py | 4 --
.../connect_command_test.py | 42 +++++++------------
.../disconnect_by_ap_test.py | 4 +-
autotests/testEAP-AKA/connection_test.py | 1 -
.../testEAP-PEAPv0-CryptoBinding/ISK_test.py | 1 -
.../NoISK_test.py | 1 -
.../testEAP-PEAPv0-CryptoBinding/main.conf | 2 -
autotests/testEAP-PWD/connection_test.py | 1 -
autotests/testEAP-SIM/connection_test.py | 1 -
.../connection_test.py | 11 ++---
.../testEAP-TTLS-CHAP/connection_test.py | 1 -
.../testEAP-TTLS-MSCHAP/connection_test.py | 1 -
autotests/testEAP-TTLS-PAP/connection_test.py | 1 -
autotests/testEAP-WPS-Frag/wps_frag_test.py | 4 +-
autotests/testEAP-WPS/four_digit_pin_test.py | 4 +-
autotests/testEAP-WPS/pin_test.py | 4 +-
autotests/testEAP-WPS/push_button_test.py | 5 +--
autotests/testFILS/fils_256_test.py | 1 -
autotests/testFILS/fils_384_test.py | 1 -
.../{test.py => connection_test.py} | 2 +-
.../{test.py => connection_test.py} | 2 +-
.../{test.py => connection_test.py} | 2 +-
.../{test.py => connection_test.py} | 2 +-
.../{test.py => connection_test.py} | 17 +++++---
.../{test.py => connection_test.py} | 2 +-
.../{test.py => connection_test.py} | 2 +-
autotests/testOWE/connection_test.py | 1 -
autotests/testOWE/renegotiate_test.py | 1 -
.../{test.py => connection_test.py} | 2 +-
.../{test.py => connection_test.py} | 0
autotests/testSAE/connection_test.py | 10 ++---
autotests/testSAE/group_20_connection_test.py | 10 ++---
.../testSAQuery-spoofing/connection_test.py | 2 +-
autotests/testSAQuery/connection_test.py | 2 +-
41 files changed, 56 insertions(+), 117 deletions(-)
rename autotests/testAP-no-support/{test.py => connection_test.py} (100%)
rename autotests/testAP/{test.py => connection_test.py} (94%)
delete mode 100644 autotests/testEAP-PEAPv0-CryptoBinding/main.conf
rename autotests/testFT-8021x-roam/{test.py => connection_test.py} (99%)
rename autotests/testFT-FILS-SHA256/{test.py => connection_test.py} (99%)
rename autotests/testFT-FILS-SHA384/{test.py => connection_test.py} (99%)
rename autotests/testFT-PSK-over-DS/{test.py => connection_test.py} (99%)
rename autotests/testFT-PSK-roam/{test.py => connection_test.py} (96%)
rename autotests/testFT-SAE-roam/{test.py => connection_test.py} (99%)
rename autotests/testHT-VHT/{test.py => connection_test.py} (98%)
rename autotests/testPreauth-roam/{test.py => connection_test.py} (98%)
rename autotests/testRSSIAgent/{test.py => connection_test.py} (100%)autotests/testAP-no-support/connection_test.py renamed from autotests/testAP-no-support/test.py +0 -0
autotests/testAP/connection_test.py renamed from autotests/testAP/test.py +5 -4
@@ -3,17 +3,17 @@ import unittest import sys, os -sys.path.append('../util') import iwd from iwd import IWD from iwd import PSKAgent from iwd import NetworkType -import hostapd +from hostapd import HostapdCLI import testutil class Test(unittest.TestCase): def client_connect(self, wd, dev): + hostapd = HostapdCLI(config='psk-ccmp.conf') ordered_network = dev.get_ordered_network('TestAP1', True)
@@ -30,8 +30,7 @@ class Test(unittest.TestCase): wd.unregister_psk_agent(psk_agent) testutil.test_iface_operstate(dev.name) - testutil.test_ifaces_connected(list(hostapd.hostapd_map.keys())[0], - dev.name) + testutil.test_ifaces_connected(hostapd.ifname, dev.name) dev.disconnect()
@@ -57,6 +56,7 @@ class Test(unittest.TestCase): wd.wait_for_object_condition(dev2, condition) ordered_networks = dev2.get_ordered_networks() + networks = { n.name: n for n in ordered_networks } self.assertEqual(networks['TestAP1'].type, NetworkType.psk) self.assertEqual(networks['TestAP2'].type, NetworkType.psk)
@@ -66,6 +66,7 @@ class Test(unittest.TestCase): try: dev2.disconnect() + condition = 'not obj.connected' wd.wait_for_object_condition(dev2, condition) except:
autotests/testAP/failure_test.py +3 -3
@@ -8,12 +8,13 @@ import iwd from iwd import IWD from iwd import PSKAgent from iwd import NetworkType -import hostapd +from hostapd import HostapdCLI import testutil class Test(unittest.TestCase): def client_connect(self, wd, dev): + hostapd = HostapdCLI(config='psk-ccmp.conf') ordered_network = dev.get_ordered_network('TestAP1', True)
@@ -30,8 +31,7 @@ class Test(unittest.TestCase): wd.unregister_psk_agent(psk_agent) testutil.test_iface_operstate(dev.name) - testutil.test_ifaces_connected(list(hostapd.hostapd_map.keys())[0], - dev.name) + testutil.test_ifaces_connected(hostapd.ifname, dev.name) dev.disconnect()
autotests/testAPRoam/connection_test.py +0 -2
@@ -10,8 +10,6 @@ from iwd import PSKAgent from iwd import NetworkType from hostapd import HostapdCLI -from hostapd import hostapd_map - from hwsim import Hwsim class Test(unittest.TestCase):
autotests/testBSSBlacklist/all_blacklisted_test.py +0 -4
@@ -10,12 +10,8 @@ from iwd import PSKAgent from iwd import NetworkType from hostapd import HostapdCLI -from hostapd import hostapd_map - from hwsim import Hwsim -import time - class Test(unittest.TestCase): def test_connection_success(self):
autotests/testBSSBlacklist/bad_pass_test.py +0 -4
@@ -10,12 +10,8 @@ from iwd import PSKAgent from iwd import NetworkType from hostapd import HostapdCLI -from hostapd import hostapd_map - from hwsim import Hwsim -import time - class Test(unittest.TestCase): def test_connection_success(self):
autotests/testBSSBlacklist/connection_test.py +0 -1
@@ -10,7 +10,6 @@ from iwd import PSKAgent from iwd import NetworkType from hostapd import HostapdCLI -from hostapd import hostapd_map from hwsim import Hwsim
autotests/testBSSBlacklist/temp_blacklist_test.py +0 -4
@@ -10,12 +10,8 @@ from iwd import PSKAgent from iwd import NetworkType from hostapd import HostapdCLI -from hostapd import hostapd_map - from hwsim import Hwsim -import time - class Test(unittest.TestCase): def test_connection_success(self):
autotests/testClientNonInteractive/connect_command_test.py +14 -28
105 lines not on this page · raw message
autotests/testDisconnectByAP/disconnect_by_ap_test.py +1 -3
@@ -10,7 +10,6 @@ from iwd import DeviceState from iwd import NetworkType from hostapd import HostapdCLI -from hostapd import hostapd_map class Test(unittest.TestCase):
@@ -20,8 +19,7 @@ class Test(unittest.TestCase): devices = wd.list_devices(1) device = devices[0] - hostapd_if = list(hostapd_map.values())[0] - hostapd = HostapdCLI(hostapd_if) + hostapd = HostapdCLI(config='ssidOpen.conf') device.scan()
autotests/testEAP-AKA/connection_test.py +0 -1
@@ -10,7 +10,6 @@ from iwd import NetworkType from hlrauc import AuthCenter from hostapd import HostapdCLI -from hostapd import hostapd_map class Test(unittest.TestCase):
autotests/testEAP-PEAPv0-CryptoBinding/ISK_test.py +0 -1
@@ -11,7 +11,6 @@ from iwd import NetworkType import testutil from hostapd import HostapdCLI -from hostapd import hostapd_map class Test(unittest.TestCase):
autotests/testEAP-PEAPv0-CryptoBinding/NoISK_test.py +0 -1
@@ -11,7 +11,6 @@ from iwd import NetworkType import testutil from hostapd import HostapdCLI -from hostapd import hostapd_map class Test(unittest.TestCase):
autotests/testEAP-PEAPv0-CryptoBinding/main.conf deleted +0 -2
@@ -1,2 +0,0 @@ -[General] -UseDefaultInterface=true
autotests/testEAP-PWD/connection_test.py +0 -1
@@ -10,7 +10,6 @@ from iwd import PSKAgent from iwd import NetworkType from hostapd import HostapdCLI -from hostapd import hostapd_map class Test(unittest.TestCase):
autotests/testEAP-SIM/connection_test.py +0 -1
@@ -10,7 +10,6 @@ from iwd import NetworkType from hlrauc import AuthCenter from hostapd import HostapdCLI -from hostapd import hostapd_map class Test(unittest.TestCase):
autotests/testEAP-TLS-embedded-pems/connection_test.py +3 -8
@@ -9,23 +9,18 @@ from iwd import IWD from iwd import PSKAgent from iwd import NetworkType import testutil -import hostapd +from hostapd import HostapdCLI class Test(unittest.TestCase): def do_test_connection_success(self, ssid, passphrase=None): + hostapd = HostapdCLI(config=ssid + '.conf') wd = IWD() if passphrase: psk_agent = PSKAgent(passphrase) wd.register_psk_agent(psk_agent) - hostapd_ifname = None - for ifname in hostapd.hostapd_map: - if ssid + '.conf' in hostapd.hostapd_map[ifname].config: - hostapd_ifname = ifname - break - devices = wd.list_devices(1) device = devices[0]
@@ -52,7 +47,7 @@ class Test(unittest.TestCase): wd.wait_for_object_condition(ordered_network.network_object, condition) testutil.test_iface_operstate() - testutil.test_ifaces_connected(hostapd_ifname, device.name) + testutil.test_ifaces_connected(hostapd.ifname, device.name) device.disconnect()
autotests/testEAP-TTLS-CHAP/connection_test.py +0 -1
@@ -11,7 +11,6 @@ from iwd import PSKAgent from iwd import NetworkType from hostapd import HostapdCLI -from hostapd import hostapd_map class Test(unittest.TestCase):
autotests/testEAP-TTLS-MSCHAP/connection_test.py +0 -1
@@ -11,7 +11,6 @@ from iwd import PSKAgent from iwd import NetworkType from hostapd import HostapdCLI -from hostapd import hostapd_map class Test(unittest.TestCase):
autotests/testEAP-TTLS-PAP/connection_test.py +0 -1
@@ -11,7 +11,6 @@ from iwd import PSKAgent from iwd import NetworkType from hostapd import HostapdCLI -from hostapd import hostapd_map class Test(unittest.TestCase):
autotests/testEAP-WPS-Frag/wps_frag_test.py +1 -3
@@ -9,7 +9,6 @@ from iwd import IWD from iwd import DeviceState from hostapd import HostapdCLI -from hostapd import hostapd_map class Test(unittest.TestCase):
@@ -32,8 +31,7 @@ class Test(unittest.TestCase): @classmethod def setUpClass(cls): - cls.hostapd_if = list(hostapd_map.values())[0] - cls.hostapd = HostapdCLI(cls.hostapd_if) + cls.hostapd = HostapdCLI(config='ssid-wps-small-mtu.conf') cls.hostapd.wps_push_button()
autotests/testEAP-WPS/four_digit_pin_test.py +1 -3
@@ -9,7 +9,6 @@ from iwd import IWD from iwd import DeviceState from hostapd import HostapdCLI -from hostapd import hostapd_map class Test(unittest.TestCase):
@@ -39,8 +38,7 @@ class Test(unittest.TestCase): @classmethod def setUpClass(cls): - cls.hostapd_if = list(hostapd_map.values())[0] - cls.hostapd = HostapdCLI(cls.hostapd_if) + cls.hostapd = HostapdCLI(config='ssidWPS.conf') @classmethod def tearDownClass(cls):
autotests/testEAP-WPS/pin_test.py +1 -3
@@ -9,7 +9,6 @@ from iwd import IWD from iwd import DeviceState from hostapd import HostapdCLI -from hostapd import hostapd_map class Test(unittest.TestCase):
@@ -42,8 +41,7 @@ class Test(unittest.TestCase): @classmethod def setUpClass(cls): - cls.hostapd_if = list(hostapd_map.values())[0] - cls.hostapd = HostapdCLI(cls.hostapd_if) + cls.hostapd = HostapdCLI(config='ssidWPS.conf') @classmethod def tearDownClass(cls):
autotests/testEAP-WPS/push_button_test.py +1 -4
@@ -9,8 +9,6 @@ from iwd import IWD from iwd import DeviceState from hostapd import HostapdCLI -from hostapd import hostapd_map - class Test(unittest.TestCase): def push_button_success(self, wd):
@@ -38,8 +36,7 @@ class Test(unittest.TestCase): @classmethod def setUpClass(cls): - cls.hostapd_if = list(hostapd_map.values())[0] - cls.hostapd = HostapdCLI(cls.hostapd_if) + cls.hostapd = HostapdCLI(config='ssidWPS.conf') @classmethod def tearDownClass(cls):
autotests/testFILS/fils_256_test.py +0 -1
@@ -9,7 +9,6 @@ import iwd from iwd import IWD from iwd import PSKAgent from iwd import NetworkType -from hostapd import hostapd_map from hostapd import HostapdCLI import testutil
autotests/testFILS/fils_384_test.py +0 -1
@@ -9,7 +9,6 @@ import iwd from iwd import IWD from iwd import PSKAgent from iwd import NetworkType -from hostapd import hostapd_map from hostapd import HostapdCLI import testutil
autotests/testFT-8021x-roam/connection_test.py renamed from autotests/testFT-8021x-roam/test.py +1 -1
@@ -8,7 +8,7 @@ import iwd from iwd import IWD from iwd import NetworkType from hwsim import Hwsim -from hostapd import HostapdCLI, hostapd_map +from hostapd import HostapdCLI import testutil class Test(unittest.TestCase):
autotests/testFT-FILS-SHA256/connection_test.py renamed from autotests/testFT-FILS-SHA256/test.py +1 -1
@@ -9,7 +9,7 @@ from iwd import IWD from iwd import PSKAgent from iwd import NetworkType from hwsim import Hwsim -from hostapd import HostapdCLI, hostapd_map +from hostapd import HostapdCLI import testutil class Test(unittest.TestCase):
autotests/testFT-FILS-SHA384/connection_test.py renamed from autotests/testFT-FILS-SHA384/test.py +1 -1
@@ -9,7 +9,7 @@ from iwd import IWD from iwd import PSKAgent from iwd import NetworkType from hwsim import Hwsim -from hostapd import HostapdCLI, hostapd_map +from hostapd import HostapdCLI import testutil class Test(unittest.TestCase):
autotests/testFT-PSK-over-DS/connection_test.py renamed from autotests/testFT-PSK-over-DS/test.py +1 -1
@@ -9,7 +9,7 @@ from iwd import IWD from iwd import PSKAgent from iwd import NetworkType from hwsim import Hwsim -from hostapd import HostapdCLI, hostapd_map +from hostapd import HostapdCLI import testutil class Test(unittest.TestCase):
autotests/testFT-PSK-roam/connection_test.py renamed from autotests/testFT-PSK-roam/test.py +11 -6
@@ -9,7 +9,7 @@ from iwd import IWD from iwd import PSKAgent from iwd import NetworkType from hwsim import Hwsim -from hostapd import HostapdCLI, hostapd_map +from hostapd import HostapdCLI import testutil class Test(unittest.TestCase):
@@ -24,12 +24,14 @@ class Test(unittest.TestCase): rule1.source = self.bss_radio[1].addresses[0] rule1.bidirectional = True - wd = IWD() + wd = self.wd psk_agent = PSKAgent("EasilyGuessedPassword") wd.register_psk_agent(psk_agent) device = wd.list_devices(1)[0] + # prevent autoconnect + device.disconnect() # Check that iwd selects BSS 0 first rule0.signal = -2000
@@ -107,12 +109,14 @@ class Test(unittest.TestCase): rule1.source = self.bss_radio[1].addresses[0] rule1.bidirectional = True - wd = IWD() + wd = self.wd psk_agent = PSKAgent("EasilyGuessedPassword") wd.register_psk_agent(psk_agent) device = wd.list_devices(1)[0] + # prevent autoconnect + device.disconnect() # Check that iwd selects BSS 0 first rule0.signal = -2000
@@ -176,6 +180,8 @@ class Test(unittest.TestCase): testutil.test_ifaces_connected(self.bss_hostapd[1].ifname, device.name) self.assertRaises(Exception, testutil.test_ifaces_connected, (self.bss_hostapd[0].ifname, device.name)) + def setUp(self): + self.wd = IWD() def tearDown(self): os.system('ifconfig "' + self.bss_hostapd[0].ifname + '" down')
@@ -184,15 +190,14 @@ class Test(unittest.TestCase): os.system('ifconfig "' + self.bss_hostapd[1].ifname + '" up') hwsim = Hwsim() - wd = IWD() - device = wd.list_devices(1)[0] + device = self.wd.list_devices(1)[0] try: device.disconnect() except: pass condition = 'obj.state == DeviceState.disconnected' - wd.wait_for_object_condition(device, condition) + self.wd.wait_for_object_condition(device, condition) for rule in list(hwsim.rules.keys()): del hwsim.rules[rule]
autotests/testFT-SAE-roam/connection_test.py renamed from autotests/testFT-SAE-roam/test.py +1 -1
@@ -9,7 +9,7 @@ from iwd import IWD from iwd import PSKAgent from iwd import NetworkType from hwsim import Hwsim -from hostapd import HostapdCLI, hostapd_map +from hostapd import HostapdCLI import testutil class Test(unittest.TestCase):
autotests/testHT-VHT/connection_test.py renamed from autotests/testHT-VHT/test.py +1 -1
@@ -9,9 +9,9 @@ from iwd import IWD from iwd import PSKAgent from iwd import NetworkType from hwsim import Hwsim -from hostapd import HostapdCLI, hostapd_map import testutil from time import sleep +from hostapd import HostapdCLI class Test(unittest.TestCase): def do_connect(self, wd, device, hostapd):
autotests/testOWE/connection_test.py +0 -1
@@ -7,7 +7,6 @@ sys.path.append('../util') import iwd from iwd import IWD from iwd import NetworkType -from hostapd import hostapd_map from hostapd import HostapdCLI import testutil
autotests/testOWE/renegotiate_test.py +0 -1
@@ -7,7 +7,6 @@ sys.path.append('../util') import iwd from iwd import IWD from iwd import NetworkType -from hostapd import hostapd_map from hostapd import HostapdCLI import testutil
autotests/testPreauth-roam/connection_test.py renamed from autotests/testPreauth-roam/test.py +1 -1
@@ -9,7 +9,7 @@ from iwd import IWD from iwd import PSKAgent from iwd import NetworkType from hwsim import Hwsim -from hostapd import HostapdCLI, hostapd_map +from hostapd import HostapdCLI import testutil class Test(unittest.TestCase):
autotests/testRSSIAgent/connection_test.py renamed from autotests/testRSSIAgent/test.py +0 -0
autotests/testSAE/connection_test.py +3 -7
@@ -8,17 +8,13 @@ import iwd from iwd import IWD from iwd import PSKAgent from iwd import NetworkType -from hostapd import hostapd_map +from hostapd import HostapdCLI import testutil class Test(unittest.TestCase): def validate_connection(self, wd): - hostapd_if = None - - for hostapd in hostapd_map.values(): - if hostapd.config == 'ssidSAE.conf': - hostapd_if = hostapd.name + hostapd = HostapdCLI(config='ssidSAE.conf') psk_agent = PSKAgent("secret123") wd.register_psk_agent(psk_agent)
@@ -56,7 +52,7 @@ class Test(unittest.TestCase): wd.wait(2) testutil.test_iface_operstate(intf=device.name) - testutil.test_ifaces_connected(if0=device.name, if1=hostapd_if) + testutil.test_ifaces_connected(if0=device.name, if1=hostapd.ifname) device.disconnect()
autotests/testSAE/group_20_connection_test.py +3 -7
@@ -8,17 +8,13 @@ import iwd from iwd import IWD from iwd import PSKAgent from iwd import NetworkType -from hostapd import hostapd_map +from hostapd import HostapdCLI import testutil class Test(unittest.TestCase): def validate_connection(self, wd): - hostapd_if = None - - for hostapd in hostapd_map.values(): - if hostapd.config == 'ssidSAE-20.conf': - hostapd_if = hostapd.name + hostapd = HostapdCLI(config='ssidSAE-20.conf') psk_agent = PSKAgent("secret123") wd.register_psk_agent(psk_agent)
@@ -56,7 +52,7 @@ class Test(unittest.TestCase): wd.wait(2) testutil.test_iface_operstate(intf=device.name) - testutil.test_ifaces_connected(if0=device.name, if1=hostapd_if) + testutil.test_ifaces_connected(if0=device.name, if1=hostapd.ifname) device.disconnect()
autotests/testSAQuery-spoofing/connection_test.py +1 -1
@@ -9,7 +9,7 @@ from iwd import IWD from iwd import PSKAgent from iwd import NetworkType from hwsim import Hwsim -from hostapd import HostapdCLI, hostapd_map +from hostapd import HostapdCLI from time import sleep
autotests/testSAQuery/connection_test.py +1 -1
@@ -8,7 +8,7 @@ import iwd from iwd import IWD from iwd import PSKAgent from iwd import NetworkType -from hostapd import HostapdCLI, hostapd_map +from hostapd import HostapdCLI class Test(unittest.TestCase):
Signature · 1 line
2.21.3
PATCH v4 2/26 auto-t: introduce pure python test-runner re-write
This patch completely re-writes test-runner in Python. This was done because the existing C test-runner had some clunky work arounds and maintaining or adding new features was starting to become a huge pain.
There were a few aspects of test-runner which continually had to be dealt with when adding any new functionality:
* Argument parsing: Adding new arguments to test-runner wasn't so bad, but if you wanted those arguments passed into the VM it became a huge pain. Arguments needed to be parsed, then re-formatted into the qemu command line, then re-parsed in a special order (backwards) once in the VM. The burden for adding new arguments was quite high so it was avoided (at least by me) at all costs.
* The separation between C and Python: The tests are all written in python, but the executables, radios, and interfaces were all created from C. The way we solved this was by encoding the require info as environment variables, then parsing those from Python. It worked, but it was, again, a huge pain.
* Process management: It started with all processes being launched from C, but eventually tests required the ability to start IWD, or kill hostapd ungracefully in order to test certain functionality. Since the processes were tracked in C, Python had no way of signalling that it killed a process and when it started one C had no idea. This was mitigated (basically by killall), but it was no where close to an elegant solution.
Re-writing test-runner in python solves all these problems and will be much easier to maintain.
* Argument parsing: Now all arguments are forwarded automatically to the VM. The ArgParse library takes care of parsing and each argument is stored in a dictionary.
* Separation between C and Python: No more C, so no more separation.
* Process management: Python will now manage all processes. This allows a test to kill, restart, or start a new process and not have to remember the PID or to kill it after the test.
There are a few more important aspects of the python implementation that should now be considered when writing new tests:
* The IWD constructor now has different default arugments. IWD will always be started unless specified and the configuration directory will always be /tmp
* Any non *.py file in the test directory will be copied to /tmp. This avoids the need for 'tmpfs_extra_stuff' completely.
* ctrl_interface will automatically be appended to every hostapd config. There is no need to include this in a config file from now on.
* Test cleanup is extremely important. All tests get run in the same interpreter now and the tests themselves are actually loaded as python modules. This means e.g. if you somehow kept a reference to IWD() any subsequent tests would not start since IWD is still running.
* For debugging, the test context can be printed which shows running processes, radios, and interfaces.
Three non-native python modules were used: PrettyTable, colored, and pyroute2
$ pip3 install prettytable $ pip3 install termcolor $ pip3 install pyroute2 --- autotests/util/config.py | 6 + tools/py_runner.py | 1263 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 1269 insertions(+) create mode 100644 autotests/util/config.py create mode 100755 tools/py_runner.py
autotests/util/config.py new file +6 -0
@@ -0,0 +1,6 @@ +# +# Acts as a global store for test information. 'ctx' is set by the creator of +# of the TestContext (test-runner). +# + +ctx = {}
tools/py_runner.py new file +1263 -0
1,263 lines not on this page · raw message
Signature · 1 line
2.21.3
PATCH v4 3/26 auto-t: hostapd.py: update to work with test-runner rewrite
In reply to James PrestwoodBefore hostapd was initialized using the wiphy_map which has now gone away. Instead we have a global config module which contains a single 'ctx'. This is the centeral store for all test information.
This patch converts hostapd.py to lookup instances by already initialized Hostapd object. The interface parameter was removed since all tests have been converted to use config= instead.
In addition HostapdCLI was changed to allow no parameters if there is only a single hostapd instance.
--- autotests/util/hostapd.py | 100 +++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 56 deletions(-)
autotests/util/hostapd.py +44 -56
@@ -1,11 +1,11 @@ #!/usr/bin/python3 import os, os.path -from wiphy import wiphy_map import re import socket import select import time from gi.repository import GLib +from config import ctx chan_freq_map = [ None,
@@ -28,31 +28,26 @@ chan_freq_map = [ ctrl_count = 0 mainloop = GLib.MainLoop() -hostapd_map = {ifname: intf for wname, wiphy in wiphy_map.items() - for ifname, intf in wiphy.interface_map.items() - if wiphy.use == 'hostapd'} - class HostapdCLI: - def _init_hostapd(self, interface=None, config=None): + def _init_hostapd(self, config=None): global ctrl_count + interface = None + + if not config and len(ctx.hostapd.instances) > 1: + raise Exception('config must be provided if more than one hostapd instance exists') - if not interface and not config: - raise Exception('interface or config must be provided') + hapd = ctx.hostapd[config] - if not interface: - for intf in hostapd_map.values(): - if intf.config == config: - interface = intf - break + self.interface = hapd.intf + self.config = hapd.config - if not interface: + if not self.interface: raise Exception('config %s not found' % config) - self.ifname = interface.name - self.socket_path = os.path.dirname(interface.ctrl_interface) + self.ifname = self.interface.name + self.socket_path = os.path.dirname(self.interface.ctrl_interface) - self.cmdline = 'hostapd_cli -p"' + self.socket_path + '" -i"' + \ - self.ifname + '"' + self.cmdline = ['hostapd_cli', '-p', self.socket_path, '-i', self.ifname] if not hasattr(self, '_hostapd_restarted'): self._hostapd_restarted = False
@@ -61,6 +56,7 @@ class HostapdCLI: str(ctrl_count) self.ctrl_sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) self.ctrl_sock.bind(self.local_ctrl) + self.ctrl_sock.connect(self.socket_path + '/' + self.ifname) if 'OK' not in self._ctrl_request('ATTACH'):
@@ -68,8 +64,8 @@ class HostapdCLI: ctrl_count = ctrl_count + 1 - def __init__(self, interface=None, config=None): - self._init_hostapd(interface, config) + def __init__(self, config=None): + self._init_hostapd(config) def wait_for_event(self, event, timeout=10): global mainloop
@@ -115,53 +111,49 @@ class HostapdCLI: def _del_hostapd(self, force=False): self.ctrl_sock.close() + os.remove(self.local_ctrl) if self._hostapd_restarted: - if force: - os.system('killall -9 hostapd') - else: - os.system('killall hostapd') + ctx.stop_process(ctx.hostapd.process, force) - os.system('ifconfig %s down' % self.ifname) - os.system('ifconfig %s up' % self.ifname) + self.interface.set_interface_state('down') + self.interface.set_interface_state('up') def __del__(self): self._del_hostapd() def wps_push_button(self): - os.system(self.cmdline + ' wps_pbc') + ctx.start_process(self.cmdline + ['wps_pbc'], wait=True) def wps_pin(self, pin): - os.system(self.cmdline + ' wps_pin any ' + pin) + cmd = self.cmdline + ['wps_pin', 'any', pin] + ctx.start_process(cmd, wait=True) def deauthenticate(self, client_address): - os.system(self.cmdline + ' deauthenticate ' + client_address) + cmd = self.cmdline + ['deauthenticate', client_address] + ctx.start_process(cmd, wait=True) def eapol_reauth(self, client_address): cmd = 'IFNAME=' + self.ifname + ' EAPOL_REAUTH ' + client_address - s = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) - s.connect(self.socket_path + '/' + self.ifname) - s.sendall(cmd.encode('utf-8')) - s.close() + self.ctrl_sock.sendall(cmd.encode('utf-8')) def reload(self): # Seemingly all three commands needed for the instance to notice # interface's address change - cmds = 'reload\ndisable\nenable\n' - proc = os.popen(self.cmdline, mode='w') - lines = proc.write(cmds) - proc.close() + ctx.start_process(self.cmdline + ['reload'], wait=True) + ctx.start_process(self.cmdline + ['disable'], wait=True) + ctx.start_process(self.cmdline + ['enable'], wait=True) def list_sta(self): - proc = os.popen(self.cmdline + ' list_sta') - lines = proc.read() - proc.close() + proc = ctx.start_process(self.cmdline + ['list_sta']) + proc.pid.wait() + lines = proc.pid.stdout.read().decode('utf-8') return [line for line in lines.split('\n') if line] def set_neighbor(self, addr, ssid, nr): - os.system(self.cmdline + ' set_neighbor ' + addr + ' ssid=\\""' + ssid + - '"\\" nr=' + nr) + cmd = self.cmdline + ['set_neighbor', addr, 'ssid=\\""%s"\\"' % ssid, 'nr=%s' % nr] + ctx.start_process(cmd, wait=True) def send_bss_transition(self, device, nr_list): # Send a BSS transition to a station (device). nr_list should be an
@@ -170,7 +162,7 @@ class HostapdCLI: # consistent with the set_neighbor() API, i.e. the same neighbor report # string could be used in both API's. pref = 1 - cmd = self.cmdline + ' bss_tm_req ' + device + cmd = self.cmdline + ['bss_tm_req', device] for i in nr_list: addr = i[0] nr = i[1]
@@ -180,19 +172,15 @@ class HostapdCLI: chan_num=nr[10:12] phy_num=nr[14:16] - cmd += ' pref=%s neighbor=%s,%s,%s,%s,%s' % \ - (str(pref), addr, bss_info, op_class, chan_num, phy_num) + cmd += ['pref=%s' % str(pref), 'neighbor=%s,%s,%s,%s,%s' % \ + (addr, bss_info, op_class, chan_num, phy_num)] pref += 1 - os.system(cmd) - - @staticmethod - def kill_all(): - os.system('killall hostapd') + ctx.start_process(cmd, wait=True) def get_config_value(self, key): # first find the right config file - with open(hostapd_map[self.ifname].config, 'r') as f: + with open(self.config, 'r') as f: # read in config file and search for key cfg = f.read() match = re.search(r'%s=.*' % key, cfg)
@@ -200,6 +188,7 @@ class HostapdCLI: return match.group(0).split('=')[1] return None + def get_freq(self): return chan_freq_map[int(self.get_config_value('channel'))]
@@ -209,21 +198,20 @@ class HostapdCLI: ''' # set flag so hostapd can be killed after the test self._hostapd_restarted = True - intf = hostapd_map[self.ifname] self._del_hostapd(force=True) - os.system('hostapd -g %s -i %s %s &' % - (intf.ctrl_interface, intf.name, intf.config)) + ctx.start_hostapd() # Give hostapd a second to start and initialize the control interface time.sleep(1) # New hostapd process, so re-init - self._init_hostapd(intf) + self._init_hostapd(config=self.config) def req_beacon(self, addr, request): ''' Send a RRM Beacon request ''' - os.system(self.cmdline + ' req_beacon ' + addr + ' ' + request) + cmd = self.cmdline + ['req_beacon', addr, request] + ctx.start_process(cmd, wait=True)
Signature · 1 line
2.21.3
PATCH v4 4/26 auto-t: testutil.py: update to work with test-runner rewrite
In reply to James PrestwoodSimilar to the others, testutil.py was converted to use the global test context to lookup radios/interfaces rather than the wiphy_map
--- autotests/util/testutil.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
autotests/util/testutil.py +4 -3
@@ -5,8 +5,8 @@ import fcntl import struct import select -import wiphy import iwd +from config import ctx HWSIM_ETHERTYPE = 0x0800 HWSIM_PACKETLEN = 250
@@ -54,8 +54,9 @@ def tx(fromsock, tosock, src, dst): def test_connected(if0=None, if1=None, group=True): if if0 is None or if1 is None: iwd_list = [dev.name for dev in iwd.IWD.get_instance().list_devices()] - non_iwd_list = [ifname for w in wiphy.wiphy_map.values() - for ifname in w.interface_map] + + non_iwd_list = [rad.interface.name for rad in ctx.radios if rad.interface is not None] + for intf in iwd_list + non_iwd_list: if if0 is None: if0 = intf
Signature · 1 line
2.21.3
PATCH v4 5/26 auto-t: ofono.py: fix timeout cleanup and wait for service
In reply to James PrestwoodOfono.py was not cleaning up the timeout, nor waiting for the ofono.org service to come up before continuing.
--- autotests/util/ofono.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-)
autotests/util/ofono.py +18 -7
@@ -1,4 +1,5 @@ import dbus +import time from gi.repository import GLib SIM_AUTH_IFACE = 'org.ofono.SimAuthentication'
@@ -7,6 +8,14 @@ class Ofono(dbus.service.Object): def __init__(self): self._bus = dbus.SystemBus() + tries = 0 + + while not self._bus.name_has_owner('org.ofono'): + if tries > 100: + raise TimeoutError('Waiting for org.ofono service timed out') + tries += 1 + time.sleep(0.1) + def enable_modem(self, path): self._modem_path = path self._modem_iface = dbus.Interface(
@@ -37,11 +46,13 @@ class Ofono(dbus.service.Object): self._wait_timed_out = True return False - timeout = GLib.timeout_add_seconds(max_wait, wait_timeout_cb) - context = mainloop.get_context() - while (not self._sim_auth_up): - context.iteration(may_block=True) - if self._wait_timed_out: - raise TimeoutError('waiting for SimAuthentication timed out') + try: + timeout = GLib.timeout_add_seconds(max_wait, wait_timeout_cb) + context = mainloop.get_context() + while (not self._sim_auth_up): + context.iteration(may_block=True) + if self._wait_timed_out: + raise TimeoutError('waiting for SimAuthentication timed out') - GLib.source_remove(timeout) + finally: + GLib.source_remove(timeout)
Signature · 1 line
2.21.3
PATCH v4 6/26 auto-t: iwd.py: update to work with test-runner rewrite
In reply to James Prestwoodiwd.py was updated to use the TestContext APIs to start/stop IWD. This makes the process managment consistent between starting IWD from test-runner or from the IWD() constructor.
The psk agent is now tracked, and destroyed upon __del__. This is to fix issues where a test throws an exception and never unregisters the agent, causing future tests to fail.
The configuration directory was also chaged to /tmp by default. This was done since all tests which used this used /tmp anyways.
The GLib mainloop was removed, and instead put into test-runner itself. Now any mainloop operations can use ctx.mainloop instead
--- autotests/util/iwd.py | 123 +++++++++++++++++++----------------------- 1 file changed, 56 insertions(+), 67 deletions(-)
autotests/util/iwd.py +56 -67
@@ -15,7 +15,7 @@ import weakref from abc import ABCMeta, abstractmethod from enum import Enum -import wiphy +from config import ctx IWD_STORAGE_DIR = '/var/lib/iwd' IWD_CONFIG_DIR = '/etc/iwd'
@@ -39,10 +39,6 @@ IWD_STATION_INTERFACE = 'net.connman.iwd.Station' IWD_AGENT_MANAGER_PATH = '/net/connman/iwd' IWD_TOP_LEVEL_PATH = '/' - -dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) - - class UnknownDBusEx(Exception): pass class InProgressEx(dbus.DBusException): pass class FailedEx(dbus.DBusException): pass
@@ -108,7 +104,7 @@ class AsyncOpAbstract(object): self._exception = _convert_dbus_ex(ex) def _wait_for_async_op(self): - context = mainloop.get_context() + context = ctx.mainloop.get_context() while not self._is_completed: context.iteration(may_block=True)
@@ -533,8 +529,8 @@ class Device(IWDDBusAbstract): if addr not in props['ConnectedPeers']: return - GLib.timeout_add(int(30 * 1000), wait_timeout_cb) - context = mainloop.get_context() + GLib.timeout_add(int(50 * 1000), wait_timeout_cb) + context = ctx.mainloop.get_context() while not self._adhoc_prop_found: context.iteration(may_block=True) if self._adhoc_timed_out:
@@ -561,8 +557,8 @@ class Device(IWDDBusAbstract): if addr in props['ConnectedPeers']: return - GLib.timeout_add(int(15 * 1000), wait_timeout_cb) - context = mainloop.get_context() + GLib.timeout_add(int(50 * 1000), wait_timeout_cb) + context = ctx.mainloop.get_context() while not self._adhoc_prop_found: context.iteration(may_block=True) if self._adhoc_timed_out:
@@ -873,7 +869,11 @@ class DeviceList(collections.Mapping): class IWD(AsyncOpAbstract): - '''''' + ''' + Start an IWD instance. By default IWD should already be running, but + some tests do require starting IWD using this constructor (by passing + start_iwd_daemon=True) + ''' _bus = dbus.SystemBus() _object_manager_if = None
@@ -881,41 +881,22 @@ class IWD(AsyncOpAbstract): _iwd_proc = None _devices = None _instance = None + psk_agent = None - def __init__(self, start_iwd_daemon = False, - iwd_config_dir = IWD_CONFIG_DIR): - global mainloop - mainloop = GLib.MainLoop() + def __init__(self, start_iwd_daemon = False, iwd_config_dir = '/tmp'): + if start_iwd_daemon and ctx.is_process_running('iwd'): + raise Exception("IWD requested to start but is already running") if start_iwd_daemon: - args = [] - iwd_wiphys = [wname for wname, wiphy in wiphy.wiphy_map.items() - if wiphy.use == 'iwd'] - whitelist = ','.join(iwd_wiphys) - - if os.environ.get('IWD_TEST_VALGRIND', None) == 'on': - args.append('valgrind') - args.append('--leak-check=full') - args.append('--log-file=/tmp/valgrind.log') - - os.environ["CONFIGURATION_DIRECTORY"] = iwd_config_dir; - - args.append('iwd') - args.append('-p') - args.append(whitelist) - args.append('-d') - - import subprocess - iwd_proc = subprocess.Popen(args) - - self._iwd_proc = iwd_proc + self._iwd_proc = ctx.start_iwd(iwd_config_dir) tries = 0 while not self._bus.name_has_owner(IWD_SERVICE): - if os.environ['IWD_TEST_TIMEOUTS'] == 'on': + if ctx.args.gdb == 'None': if tries > 100: if start_iwd_daemon: - iwd_proc.terminate() + ctx.stop_process(self._iwd_proc) + self._iwd_proc = None raise TimeoutError('IWD has failed to start') tries += 1 time.sleep(0.1)
@@ -927,20 +908,17 @@ class IWD(AsyncOpAbstract): IWD._instance = weakref.ref(self) def __del__(self): - if self._iwd_proc is None: - return + if self.psk_agent: + self.unregister_psk_agent(self.psk_agent) self._object_manager_if = None self._agent_manager_if = None self._known_networks = None self._devices = None - self._iwd_proc.terminate() - self._iwd_proc.wait() - - self._iwd_proc = None - - del os.environ["CONFIGURATION_DIRECTORY"] + if self._iwd_proc is not None: + ctx.stop_process(self._iwd_proc) + self._iwd_proc = None @property def _object_manager(self):
@@ -966,15 +944,18 @@ class IWD(AsyncOpAbstract): self._wait_timed_out = True return False - timeout = GLib.timeout_add_seconds(max_wait, wait_timeout_cb) - context = mainloop.get_context() - while not eval(condition_str): - context.iteration(may_block=True) - if self._wait_timed_out and os.environ['IWD_TEST_TIMEOUTS'] == 'on': - raise TimeoutError('[' + condition_str + ']'\ - ' condition was not met in '\ - + str(max_wait) + ' sec') - GLib.source_remove(timeout) + try: + timeout = GLib.timeout_add_seconds(max_wait, wait_timeout_cb) + context = ctx.mainloop.get_context() + while not eval(condition_str): + context.iteration(may_block=True) + if self._wait_timed_out and ctx.args.gdb == None: + raise TimeoutError('[' + condition_str + ']'\ + ' condition was not met in '\ + + str(max_wait) + ' sec') + finally: + if not self._wait_timed_out: + GLib.source_remove(timeout) def wait(self, time): self._wait_timed_out = False
@@ -982,10 +963,14 @@ class IWD(AsyncOpAbstract): self._wait_timed_out = True return False - GLib.timeout_add(int(time * 1000), wait_timeout_cb) - context = mainloop.get_context() - while not self._wait_timed_out: - context.iteration(may_block=True) + try: + timeout = GLib.timeout_add(int(time * 1000), wait_timeout_cb) + context = ctx.mainloop.get_context() + while not self._wait_timed_out: + context.iteration(may_block=True) + finally: + if not self._wait_timed_out: + GLib.source_remove(timeout) @staticmethod def clear_storage():
@@ -1031,14 +1016,16 @@ class IWD(AsyncOpAbstract): self._wait_timed_out = True return False - timeout = GLib.timeout_add_seconds(max_wait, wait_timeout_cb) - context = mainloop.get_context() - while len(self._devices) < wait_to_appear: - context.iteration(may_block=True) - if self._wait_timed_out: - raise TimeoutError('IWD has no associated devices') - - GLib.source_remove(timeout) + try: + timeout = GLib.timeout_add_seconds(max_wait, wait_timeout_cb) + context = ctx.mainloop.get_context() + while len(self._devices) < wait_to_appear: + context.iteration(may_block=True) + if self._wait_timed_out: + raise TimeoutError('IWD has no associated devices') + finally: + if not self._wait_timed_out: + GLib.source_remove(timeout) return list(self._devices.values())
@@ -1062,6 +1049,7 @@ class IWD(AsyncOpAbstract): reply_handler=self._success, error_handler=self._failure) self._wait_for_async_op() + self.psk_agent = psk_agent def unregister_psk_agent(self, psk_agent): self._agent_manager.UnregisterAgent(
@@ -1070,6 +1058,7 @@ class IWD(AsyncOpAbstract): reply_handler=self._success, error_handler=self._failure) self._wait_for_async_op() + self.psk_agent = None @staticmethod def get_instance():
Signature · 1 line
2.21.3
PATCH v4 7/26 auto-t: remove wiphy.py
In reply to James PrestwoodThis is no longer needed
--- autotests/util/wiphy.py | 32 -------------------------------- 1 file changed, 32 deletions(-) delete mode 100644 autotests/util/wiphy.py
autotests/util/wiphy.py deleted +0 -32
@@ -1,32 +0,0 @@ -#! /usr/bin/python3 -import os -import collections - -wiphy_map = {} - -Wiphy = collections.namedtuple('Wiphy', ['name', 'use', 'interface_map']) - -Intf = collections.namedtuple('Intf', - ['name', 'wiphy', 'ctrl_interface', 'config']) - -def parse_list(): - for entry in os.environ['TEST_WIPHY_LIST'].split('\n'): - wname, use_str = entry.split('=', 1) - use = use_str.split(',') - - if wname not in wiphy_map: - wiphy_map[wname] = Wiphy(use=use[0], name=wname, interface_map={}) - - if len(use) <= 1: - continue - - intf = {} - intf['name'] = None - intf['wiphy'] = wiphy_map[wname] - intf['ctrl_interface'] = None - intf['config'] = None - intf.update(dict([param.split('=', 1) for param in use[1:]])) - - wiphy_map[wname].interface_map[intf['name']] = Intf(**intf) - -parse_list()
Signature · 1 line
2.21.3
PATCH v4 8/26 auto-t: fix hidden network test
In reply to James PrestwoodThis test was never 100% reliable, and after the test-runner re-write it became extremely unreliable. The issue came down to the very common block of code thats present in many tests where we wait for obj.scanning then not obj.scanning. This is fine when a dbus scan() is explicitly done before, otherwise it could lead to problems. Without a dbus scan explicitly called we are assuming a periodic scan will happen. If it already happen the initial wait for obj.scanning will never return and time out.
This probably needs to be changed in several tests, but for this specific case we can remove the waits completely. Since check_autoconnect_hidden_network has a 30 second wait on DeviceState.connected this will ultimately time out if anything goes wrong. There isn't any great reason to wait for scanning (for this test specifically).
A minor style change was also made when initializing IWD. The values passed in this test are now the default, so no arguments need to be passed.
--- .../connect_after_hidden_connect_test.py | 2 +- autotests/testHiddenNetworks/validation.py | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-)
autotests/testHiddenNetworks/connect_after_hidden_connect_test.py +1 -1
@@ -27,7 +27,7 @@ class TestConnectionAfterHiddenNetwork(unittest.TestCase): self._ex = ex def test_connection(self): - wd = IWD(True, '/tmp') + wd = IWD(True) psk_agent = PSKAgent("secret123") wd.register_psk_agent(psk_agent)
autotests/testHiddenNetworks/validation.py +1 -7
@@ -50,11 +50,6 @@ class TestConnectAutoConnect(unittest.TestCase): device = devices[0] if autoconnect: - condition = 'obj.scanning' - wd.wait_for_object_condition(device, condition) - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - self.check_autoconnect_hidden_network(wd, device, ssid, throws) else: if wait_periodic_scan:
@@ -71,7 +66,6 @@ class TestConnectAutoConnect(unittest.TestCase): def validate(self, ssid, autoconnect, throws = None, use_agent = False, wait_periodic_scan = False): - wd = IWD(True, '/tmp') - + wd = IWD(True) self.validate_connection(wd, ssid, autoconnect, throws, use_agent, wait_periodic_scan)
Signature · 1 line
2.21.3
PATCH v4 9/26 auto-t: fix testSAE autoconnect_test.py
In reply to James PrestwoodThis test was unreliable since it was assuming a periodic scan would happen at just the right time. Instead since we are expecting autoconnect we can just wait for DeviceState.connected then after we are connected verify the network was correct.
--- autotests/testSAE/autoconnect_test.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
autotests/testSAE/autoconnect_test.py +4 -9
@@ -23,20 +23,15 @@ class Test(unittest.TestCase): devices[2].disconnect() devices[3].disconnect() - condition = 'obj.scanning' - wd.wait_for_object_condition(device, condition) + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(device, condition, 30) - condition = 'not obj.scanning' + condition = 'obj.connected_network is not None' wd.wait_for_object_condition(device, condition) ordered_network = device.get_ordered_network('ssidSAE') - self.assertEqual(ordered_network.type, NetworkType.psk) - - condition = 'obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - device.wait_for_connected() + self.assertTrue(ordered_network.network_object.connected) device.disconnect()
Signature · 1 line
2.21.3
PATCH v4 10/26 auto-t: skip ofono tests if ofonod isn't running
In reply to James Prestwood--- autotests/testEAP-AKA-ofono/connection_test.py | 4 ++++ autotests/testEAP-AKA-prime-ofono/connection_test.py | 4 ++++ autotests/testEAP-SIM-ofono/connection_test.py | 4 ++++ 3 files changed, 12 insertions(+)
autotests/testEAP-AKA-ofono/connection_test.py +4 -0
@@ -9,6 +9,7 @@ from iwd import IWD from iwd import NetworkType from hlrauc import AuthCenter from ofono import Ofono +from config import ctx class Test(unittest.TestCase):
@@ -56,6 +57,9 @@ class Test(unittest.TestCase): auth.stop() @classmethod def setUpClass(cls): + if not ctx.is_process_running('ofonod'): + cls.skipTest(cls, "ofono not running") + IWD.copy_to_storage('ssidEAP-AKA.8021x') @classmethod
autotests/testEAP-AKA-prime-ofono/connection_test.py +4 -0
@@ -9,6 +9,7 @@ from iwd import IWD from iwd import NetworkType from hlrauc import AuthCenter from ofono import Ofono +from config import ctx class Test(unittest.TestCase):
@@ -57,6 +58,9 @@ class Test(unittest.TestCase): @classmethod def setUpClass(cls): + if not ctx.is_process_running('ofonod'): + cls.skipTest(cls, "ofono not running") + IWD.copy_to_storage('ssidEAP-AKA.8021x') @classmethod
autotests/testEAP-SIM-ofono/connection_test.py +4 -0
@@ -9,6 +9,7 @@ from iwd import IWD from iwd import NetworkType from hlrauc import AuthCenter from ofono import Ofono +from config import ctx class Test(unittest.TestCase):
@@ -57,6 +58,9 @@ class Test(unittest.TestCase): @classmethod def setUpClass(cls): + if not ctx.is_process_running('ofonod'): + cls.skipTest(cls, "ofono not running") + IWD.copy_to_storage('ssidEAP-SIM.8021x') @classmethod
Signature · 1 line
2.21.3
PATCH v4 11/26 auto-t: replace hard-coded interfaces
In reply to James Prestwoodtest-runner now supports interface name replacement inside hostapd config files. Since a given test configuration doesn't know what interface names there will be $ifaceN can be specified instead e.g.
rsn_preauth_interfaces=$iface0 $iface1
The $ifaceN values will be replace with actual interface names when the test is started.
This patch also removes ctrl_interface inside the hostapd config files as this is no longer required.
--- autotests/testPreauth-roam/eaptls-preauth-1.conf | 3 +-- autotests/testPreauth-roam/eaptls-preauth-2.conf | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)
autotests/testPreauth-roam/eaptls-preauth-1.conf +1 -2
@@ -2,7 +2,6 @@ hw_mode=g channel=1 ssid=TestPreauth utf8_ssid=1 -ctrl_interface=/var/run/hostapd wpa=2 wpa_key_mgmt=WPA-EAP
@@ -24,7 +23,7 @@ radius_server_auth_port=1812 nas_identifier=testeap1 rsn_preauth=1 -rsn_preauth_interfaces=wln0 wln1 +rsn_preauth_interfaces=$iface0 $iface1 disable_pmksa_caching=0 # Allow PMK cache to be shared opportunistically among configured interfaces
autotests/testPreauth-roam/eaptls-preauth-2.conf +1 -2
@@ -2,7 +2,6 @@ hw_mode=g channel=2 ssid=TestPreauth utf8_ssid=1 -ctrl_interface=/var/run/hostapd wpa=2 wpa_key_mgmt=WPA-EAP
@@ -20,7 +19,7 @@ auth_server_port=1812 auth_server_shared_secret=secret rsn_preauth=1 -rsn_preauth_interfaces=wln0 wln1 +rsn_preauth_interfaces=$iface0 $iface1 disable_pmksa_caching=0 # Allow PMK cache to be shared opportunistically among configured interfaces
Signature · 1 line
2.21.3
PATCH v4 12/26 auto-t: remove device.wait_for_connected
In reply to James PrestwoodI had added this without realizing wait_for_object_condition can do this already using the device object.
--- autotests/testSAE/clogging_test.py | 3 ++- autotests/util/iwd.py | 25 ------------------------- 2 files changed, 2 insertions(+), 26 deletions(-)
autotests/testSAE/clogging_test.py +2 -1
@@ -48,7 +48,8 @@ class Test(unittest.TestCase): wd.wait_for_object_condition(n.network_object, condition) for d in devices: - d.wait_for_connected() + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(d, condition) for d in devices: d.disconnect()
autotests/util/iwd.py +0 -25
@@ -564,31 +564,6 @@ class Device(IWDDBusAbstract): if self._adhoc_timed_out: raise TimeoutError("Timed out waiting for peer %s" % addr) - def wait_for_connected(self): - if str(self.state) == "connected": - return - - self._connected_success = False - self._connected_timed_out = False - - def wait_timeout_cb(): - self._connected_timed_out = True - return False - - def connected_prop_changed(iface, changed, invalid): - if changed.get('State', None): - if changed['State'] == 'connected': - self._connected_success = True - - self._prop_proxy.connect_to_signal('PropertiesChanged', - connected_prop_changed) - GLib.timeout_add(int(15 * 1000), wait_timeout_cb) - context = mainloop.get_context() - while not self._connected_success: - context.iteration(may_block=True) - if self._connected_timed_out: - raise TimeoutError("Timed out waiting for connected") - def __str__(self, prefix = ''): return prefix + 'Device: ' + self.device_path + '\n'\ + prefix + '\tName:\t\t' + self.name + '\n'\
Signature · 1 line
2.21.3
PATCH v4 13/26 tools: post test-runner rewrite cleanup
In reply to James PrestwoodRemoved test-runner.c, and renamed py_runner to test-runner. Removed tools/test-runner from .gitignore.
This was done as a separate commit to avoid a nasty diff between the existing test runner, and the new python version
---
.gitignore | 1 -
Makefile.am | 7 -------
tools/{py_runner.py => test-runner} | 0
3 files changed, 8 deletions(-)
rename tools/{py_runner.py => test-runner} (100%).gitignore +0 -1
@@ -33,7 +33,6 @@ wired/ead.8 wired/ead.service tools/hwsim tools/hwsim.1 -tools/test-runner tools/probe-req unit/test-cmac-aes unit/test-arc4
Makefile.am +0 -7
@@ -366,13 +366,6 @@ man_MANS += tools/hwsim.1 endif endif -if TOOLS -noinst_PROGRAMS += tools/test-runner - -tools_test_runner_SOURCES = tools/test-runner.c -tools_test_runner_LDADD = $(ell_ldadd) -endif - unit_tests = unit/test-cmac-aes \ unit/test-hmac-md5 unit/test-hmac-sha1 unit/test-hmac-sha256 \ unit/test-prf-sha1 unit/test-kdf-sha256 \
tools/test-runner renamed from tools/py_runner.py +0 -0
Signature · 1 line
2.21.3
PATCH v4 14/26 doc: update test runner docs
In reply to James Prestwood--- doc/test-runner.txt | 117 +++++++++++++------------------------------- 1 file changed, 34 insertions(+), 83 deletions(-)
doc/test-runner.txt +34 -83
@@ -17,18 +17,21 @@ OS: Name: Tested ver.: 1. qemu 2.4.1 - 2. Linux kernel 4.20 + 2. Linux kernel 4.20+ 3. dbus-daemon 1.11.18 4. ifconfig 2.10-alpha 5. iw 3.17 6. python 2.7 7. haveged no ver. avail. - 8. hostapd commit id: 31d3692 + 8. hostapd recent 9. <iwd>/tools/hwsim 0.0 10. <iwd>/src/iwd 0.0 + 11. ofono (optional) + 12. phonesim (optional) -Note: You will need ell-key-crypto branch, not the master branch from the tree -in step 2 above. +Note: The version for hostapd is listed as 'recent'. Older hostapd versions +will work but we are continually adopting new features from hostapd and using +those to test. Its recommended to use a recent release of hostapd. Note: The test-runner mounts host's file system in readonly mode and executes the above binaries inside of an emulated environment directly from it.
@@ -100,7 +103,6 @@ By default the test-runner will search for the kernel image in these locations: An arbitrary kernel image location can be specified by using '--kernel <path>' parameter into test-runner. - Running Automated Tests ======================= Before running any tests, its expected that the folder /var/lib/iwd exists on
@@ -113,8 +115,8 @@ By default, the automated test configuration directories reside in '<iwd>/autotests' and have a mandatory prefix of 'test'. <iwd>/autotests/test1 - /test2 - ... + /test2 + ... The test configurations along with test cases in <iwd>/autotests/test* directories will be discovered and executed by test-runner in sequential
@@ -133,6 +135,10 @@ The command line may look as follows: $ sudo ./test-runner -t test1,test3,/home/test4 +Glob matching is also supported when specifying a test list: + + $ sudo ./test-runner -t testWPA* + Creating Test Configurations ============================
@@ -145,7 +151,11 @@ A typical test configuration directory may consist of these types of files: *Test or *Test.py The set of test cases for IWD functionality implemented using Python scripting language. These files must have one of the two predefined - suffixes: 'Test' or 'Test.py' + suffixes: 'test' or 'test.py'. The file name + must also be more descriptive than simply 'test'. + e.g. 'connection_test' or 'failure_test'. Files + named 'test' will not be dynamically loaded due + to python module naming overlap. *.conf A configuration file for an instance of hostapd (Defined in hw.conf) service.
@@ -164,6 +174,9 @@ A typical contents of a test configuration directory may look as follows: networkScanTest networkConnectTest.py +Note: Any additional files in your test directory will be copied to /tmp inside +the VM. These additional file should be referenced using /tmp/<file> inside +any configuration file for hostapd. Defining Network ----------------
@@ -187,61 +200,26 @@ supplicant running IWD: # has a range of [1, 100]. num_radios=3 -# Definition of the radio configuration identifiers. These identifiers are used -# to map the APs and IWD to the radios with the particular hardware properties. -# This field is optional. If identifier is omitted from this list, then the -# default radio properties will be used as they are defined in mac80211_hwsim -# driver to satisfy a total number of radios requested in 'num_radios' field. -radio_confs=rad0:rad1 - # Maximum execution interval per Python script file in seconds. This field is # optional. # Default: 20 seconds. #max_test_exec_interval_sec=5 -# List of paths inside of a test configuration directory for which -# the symlinks will be created inside of /tmp. Such paths can be used -# to specify an absolute path to the needed files inside of IWD and Hostapd -# configuration files. -# Example: -# <some path>/test1/certs -# misc -# -# certs and misc directories will be respectively mapped to: -# -# /tmp/certs -# misc -# -# This field is optional. -#tmpfs_extra_stuff=certs:misc - -# Flag to prevent test-runner from starting IWD. Therefore, it may later be -# started from the python test cases. -# This field is optional. Default: 1 (true) -#start_iwd=0 - -# Configuration directory to use for IWD daemon. IWD expects 'main.conf' to be -# inside of the specified directory. -# This field is optional. Default: /etc/iwd -#iwd_config_dir=/etc/iwd - # # The following two configuration groups are examples of the radio # configurations. # # This group of settings allows to specify a set of properties for a radio. The -# name of the group represents a radio identifier and must be predefined in -# 'radio_confs' field inside of 'SETUP' group. This configuration group is -# optional. -# TODO: explain each one of the properties. +# name of the group represents a radio identifier. These configuration groups +# are optional. [rad0] -channels=2 -p2p_device=1 -use_chanctx=1 -# Properties of the second radio. This configuration group is optional. -[rad1] -p2p=0 +# For each radX group you can specify radio properties: +# Disables the provided interface type(s): +disable_iftype=ap,p2p + +# Disables the provided cipher types: +disable_cipher=ccmp,bip # 'HOSTAPD' configuration group identifies a set of access points (AP) for the # current network topology. Each key/value pair represents a single AP that is
@@ -253,8 +231,12 @@ p2p=0 [HOSTAPD] rad0=ap1.conf rad1=ap2.conf -#~~~~~~~~~~~~~~~~~~ end of hw.conf ~~~~~~~~~~~~~~~~~~~~~~~~~ +# 'radius_server' is a special option used to specify a hostapd instance which +# acts as a radius server only (not an access point). This option does not +# require an additional 'num_radios' to be used. +radius_server=radius.conf +#~~~~~~~~~~~~~~~~~~ end of hw.conf ~~~~~~~~~~~~~~~~~~~~~~~~~ Configuring Access Points -------------------------
@@ -358,37 +340,6 @@ For more information on Python unit test framework refer to the following page: http://pyunit.sourceforge.net/pyunit.html - -Examples of the framework usage: - -#~~~~~~~~~~~~~~~~~~~~~~~~~ alwaysPassingTest.py ~~~~~~~~~~~~~~~~~~~~~~~~~ -#!/usr/bin/python - -import unittest - -class TestPassingCase(unittest.TestCase): - - def test_pass(self): - self.assertTrue(True) - -if __name__ == '__main__': - unittest.main() -#~~~~~~~~~~~~~~~~~~ end of alwaysPassingTest.py ~~~~~~~~~~~~~~~~~~~~~~~~~ - -#~~~~~~~~~~~~~~~~~~~~~~~~~ alwaysFailingTest.py ~~~~~~~~~~~~~~~~~~~~~~~~~ -#!/usr/bin/python - -import unittest - -class TestFailingCase(unittest.TestCase): - - def test_fail(self): - self.assertTrue(False) - -if __name__ == '__main__': - unittest.main() -#~~~~~~~~~~~~~~~~~~ end of alwaysFailingTest.py ~~~~~~~~~~~~~~~~~~~~~~~~~ - Using hardware passthrough ---------------------------
Signature · 1 line
2.21.3
PATCH v4 15/26 auto-t: hwsim: wait for method return
In reply to James PrestwoodIt is not safe to assume that the python dbus implementation will wait for a method to return. The documentation says this with respect to reply_handler/error_handler:
"If both are None, the implementation may request that no reply is sent"
To stay on the safe side we should always include the error/reply handlers and wait for the operation to complete.
--- autotests/util/hwsim.py | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-)
autotests/util/hwsim.py +23 -8
@@ -58,7 +58,9 @@ class Rule(HwsimDBusAbstract): @source.setter def source(self, value): - self._prop_proxy.Set(self._iface_name, 'Source', value) + self._prop_proxy.Set(self._iface_name, 'Source', value, reply_handler=self._success, + error_handler=self._failure) + self._wait_for_async_op() @property def destination(self):
@@ -66,7 +68,9 @@ class Rule(HwsimDBusAbstract): @destination.setter def destination(self, value): - self._prop_proxy.Set(self._iface_name, 'Destination', value) + self._prop_proxy.Set(self._iface_name, 'Destination', value, reply_handler=self._success, + error_handler=self._failure) + self._wait_for_async_op() @property def bidirectional(self):
@@ -75,7 +79,8 @@ class Rule(HwsimDBusAbstract): @bidirectional.setter def bidirectional(self, value): self._prop_proxy.Set(self._iface_name, 'Bidirectional', - dbus.Boolean(value)) + dbus.Boolean(value), reply_handler=self._success, error_handler=self._failure) + self._wait_for_async_op() @property def frequency(self):
@@ -84,7 +89,8 @@ class Rule(HwsimDBusAbstract): @frequency.setter def frequency(self, value): self._prop_proxy.Set(self._iface_name, 'Frequency', - dbus.UInt32(value)) + dbus.UInt32(value), reply_handler=self._success, error_handler=self._failure) + self._wait_for_async_op() @property def priority(self):
@@ -93,7 +99,8 @@ class Rule(HwsimDBusAbstract): @priority.setter def priority(self, value): self._prop_proxy.Set(self._iface_name, 'Priority', - dbus.Int16(value)) + dbus.Int16(value), reply_handler=self._success, error_handler=self._failure) + self._wait_for_async_op() @property def signal(self):
@@ -102,7 +109,8 @@ class Rule(HwsimDBusAbstract): @signal.setter def signal(self, value): self._prop_proxy.Set(self._iface_name, 'SignalStrength', - dbus.Int16(value)) + dbus.Int16(value), reply_handler=self._success, error_handler=self._failure) + self._wait_for_async_op() @property def drop(self):
@@ -110,7 +118,9 @@ class Rule(HwsimDBusAbstract): @drop.setter def drop(self, value): - self._prop_proxy.Set(self._iface_name, 'Drop', dbus.Boolean(value)) + self._prop_proxy.Set(self._iface_name, 'Drop', dbus.Boolean(value), + reply_handler=self._success, error_handler=self._failure) + self._wait_for_async_op() @property def delay(self):
@@ -118,7 +128,9 @@ class Rule(HwsimDBusAbstract): @delay.setter def delay(self, value): - self._prop_proxy.Set(self._iface_name, 'Delay', dbus.UInt32(value)) + self._prop_proxy.Set(self._iface_name, 'Delay', dbus.UInt32(value), + reply_handler=self._success, error_handler=self._failure) + self._wait_for_async_op() def remove(self): self._iface.Remove(reply_handler=self._success,
@@ -126,6 +138,9 @@ class Rule(HwsimDBusAbstract): self._wait_for_async_op() + def __del__(self): + self.remove() + def __str__(self, prefix = ''): return prefix + 'Rule: ' + self.path + '\n' + \ prefix + '\tSource:\t\t' + self.source + '\n' + \
Signature · 1 line
2.21.3
PATCH v4 16/26 auto-t: Increase all test timeouts
In reply to James PrestwoodSlower systems may not be able to make some timeouts that tests mandated. All timeouts were increased significantly to allow tests to pass on slow systems.
--- autotests/testAPRoam/connection_test.py | 4 ++-- autotests/testBSSBlacklist/connection_test.py | 4 ++-- autotests/testFT-8021x-roam/connection_test.py | 8 ++++---- autotests/testFT-FILS-SHA256/connection_test.py | 4 ++-- autotests/testFT-FILS-SHA384/connection_test.py | 4 ++-- autotests/testFT-PSK-over-DS/connection_test.py | 4 ++-- autotests/testFT-PSK-roam/connection_test.py | 4 ++-- autotests/testFT-SAE-roam/connection_test.py | 8 ++++---- autotests/testHiddenNetworks/validation.py | 6 +++--- autotests/testKnownNetworks/known_network_test.py | 4 ++-- autotests/testPreauth-roam/connection_test.py | 4 ++-- autotests/testRSSIAgent/connection_test.py | 2 +- autotests/testSAE/autoconnect_test.py | 2 +- autotests/testScan/requested_scan_test.py | 4 ++-- autotests/util/iwd.py | 8 ++++---- autotests/util/testutil.py | 2 +- tools/test-runner | 2 +- 17 files changed, 37 insertions(+), 37 deletions(-)
autotests/testAPRoam/connection_test.py +2 -2
@@ -60,10 +60,10 @@ class Test(unittest.TestCase): (bss_radio[2].addresses[0], '8f0000005103060603000000')]) condition = 'obj.state == DeviceState.roaming' - wd.wait_for_object_condition(device, condition, 15) + wd.wait_for_object_condition(device, condition) condition = 'obj.state != DeviceState.roaming' - wd.wait_for_object_condition(device, condition, 5) + wd.wait_for_object_condition(device, condition) self.assertEqual(device.state, iwd.DeviceState.connected) self.assertTrue(bss_hostapd[1].list_sta())
autotests/testBSSBlacklist/connection_test.py +2 -2
@@ -99,10 +99,10 @@ class Test(unittest.TestCase): # Now we wait... AutoConnect should take over condition = 'obj.state == DeviceState.connecting' - wd.wait_for_object_condition(device, condition, 15) + wd.wait_for_object_condition(device, condition) condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition, 15) + wd.wait_for_object_condition(device, condition) # Same as before, make sure we didn't connect to the blacklisted AP. self.assertNotIn(device.address, bss_hostapd[0].list_sta())
autotests/testFT-8021x-roam/connection_test.py +4 -4
@@ -75,12 +75,12 @@ class Test(unittest.TestCase): rule0.signal = -8000 condition = 'obj.state == DeviceState.roaming' - wd.wait_for_object_condition(device, condition, 10) + wd.wait_for_object_condition(device, condition) # Check that iwd is on BSS 1 once out of roaming state and doesn't # go through 'disconnected', 'autoconnect', 'connecting' in between condition = 'obj.state != DeviceState.roaming' - wd.wait_for_object_condition(device, condition, 5) + wd.wait_for_object_condition(device, condition) self.assertEqual(device.state, iwd.DeviceState.connected) self.assertTrue(self.bss_hostapd[1].list_sta())
@@ -151,12 +151,12 @@ class Test(unittest.TestCase): rule0.drop = False condition = 'obj.state == DeviceState.roaming' - wd.wait_for_object_condition(device, condition, 20) + wd.wait_for_object_condition(device, condition) # Check that iwd is on BSS 1 once out of roaming state and doesn't # go through 'disconnected', 'autoconnect', 'connecting' in between condition = 'obj.state != DeviceState.roaming' - wd.wait_for_object_condition(device, condition, 5) + wd.wait_for_object_condition(device, condition) self.assertEqual(device.state, iwd.DeviceState.connected) self.assertTrue(self.bss_hostapd[1].list_sta())
autotests/testFT-FILS-SHA256/connection_test.py +2 -2
@@ -105,12 +105,12 @@ class Test(unittest.TestCase): rule0.signal = -8000 condition = 'obj.state == DeviceState.roaming' - wd.wait_for_object_condition(device, condition, 10) + wd.wait_for_object_condition(device, condition) # Check that iwd is on BSS 1 once out of roaming state and doesn't # go through 'disconnected', 'autoconnect', 'connecting' in between condition = 'obj.state != DeviceState.roaming' - wd.wait_for_object_condition(device, condition, 5) + wd.wait_for_object_condition(device, condition) self.assertEqual(device.state, iwd.DeviceState.connected) self.assertTrue(self.bss_hostapd[1].list_sta())
autotests/testFT-FILS-SHA384/connection_test.py +2 -2
@@ -105,12 +105,12 @@ class Test(unittest.TestCase): rule0.signal = -8000 condition = 'obj.state == DeviceState.roaming' - wd.wait_for_object_condition(device, condition, 10) + wd.wait_for_object_condition(device, condition) # Check that iwd is on BSS 1 once out of roaming state and doesn't # go through 'disconnected', 'autoconnect', 'connecting' in between condition = 'obj.state != DeviceState.roaming' - wd.wait_for_object_condition(device, condition, 5) + wd.wait_for_object_condition(device, condition) self.assertEqual(device.state, iwd.DeviceState.connected) self.assertTrue(self.bss_hostapd[1].list_sta())
autotests/testFT-PSK-over-DS/connection_test.py +2 -2
@@ -81,12 +81,12 @@ class Test(unittest.TestCase): rule0.signal = -8000 condition = 'obj.state == DeviceState.roaming' - wd.wait_for_object_condition(device, condition, 10) + wd.wait_for_object_condition(device, condition) # Check that iwd is on BSS 1 once out of roaming state and doesn't # go through 'disconnected', 'autoconnect', 'connecting' in between condition = 'obj.state != DeviceState.roaming' - wd.wait_for_object_condition(device, condition, 5) + wd.wait_for_object_condition(device, condition) self.assertEqual(device.state, iwd.DeviceState.connected) self.assertTrue(self.bss_hostapd[1].list_sta())
autotests/testFT-PSK-roam/connection_test.py +2 -2
@@ -83,12 +83,12 @@ class Test(unittest.TestCase): rule0.signal = -8000 condition = 'obj.state == DeviceState.roaming' - wd.wait_for_object_condition(device, condition, 10) + wd.wait_for_object_condition(device, condition) # Check that iwd is on BSS 1 once out of roaming state and doesn't # go through 'disconnected', 'autoconnect', 'connecting' in between condition = 'obj.state != DeviceState.roaming' - wd.wait_for_object_condition(device, condition, 5) + wd.wait_for_object_condition(device, condition) self.assertEqual(device.state, iwd.DeviceState.connected) self.assertTrue(self.bss_hostapd[1].list_sta())
autotests/testFT-SAE-roam/connection_test.py +4 -4
@@ -86,12 +86,12 @@ class Test(unittest.TestCase): rule0.signal = -8000 condition = 'obj.state == DeviceState.roaming' - wd.wait_for_object_condition(device, condition, 10) + wd.wait_for_object_condition(device, condition) # Check that iwd is on BSS 1 once out of roaming state and doesn't # go through 'disconnected', 'autoconnect', 'connecting' in between condition = 'obj.state != DeviceState.roaming' - wd.wait_for_object_condition(device, condition, 5) + wd.wait_for_object_condition(device, condition) rule1.signal = -2000
@@ -112,10 +112,10 @@ class Test(unittest.TestCase): rule2.signal = -1000 condition = 'obj.state == DeviceState.roaming' - wd.wait_for_object_condition(device, condition, 15) + wd.wait_for_object_condition(device, condition) condition = 'obj.state != DeviceState.roaming' - wd.wait_for_object_condition(device, condition, 5) + wd.wait_for_object_condition(device, condition) self.assertEqual(device.state, iwd.DeviceState.connected) self.assertTrue(self.bss_hostapd[2].list_sta())
autotests/testHiddenNetworks/validation.py +3 -3
@@ -20,12 +20,12 @@ class TestConnectAutoConnect(unittest.TestCase): device.connect_hidden_network(ssid) condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition, 30) + wd.wait_for_object_condition(device, condition) def check_autoconnect_hidden_network(self, wd, device, ssid, throws): if throws is None: condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition, 30) + wd.wait_for_object_condition(device, condition) condition = 'obj.connected_network is not None' wd.wait_for_object_condition(device, condition)
@@ -37,7 +37,7 @@ class TestConnectAutoConnect(unittest.TestCase): device.disconnect() condition = 'obj.state == DeviceState.disconnected' - wd.wait_for_object_condition(device, condition, 30) + wd.wait_for_object_condition(device, condition) def validate_connection(self, wd, ssid, autoconnect, throws, use_agent, wait_periodic_scan):
autotests/testKnownNetworks/known_network_test.py +2 -2
@@ -56,7 +56,7 @@ class Test(unittest.TestCase): IWD.copy_to_storage('known_networks/ssidPSK.psk') condition = 'len(obj.list_known_networks()) == 5' - wd.wait_for_object_condition(wd, condition, 1) + wd.wait_for_object_condition(wd, condition) expected = ['ssidNew', 'ssidOpen', 'ssidPSK', 'ssidEAP-TLS', 'Hotspot Network']
@@ -65,7 +65,7 @@ class Test(unittest.TestCase): IWD.remove_from_storage('ssidPSK.psk') condition = 'len(obj.list_known_networks()) == 4' - wd.wait_for_object_condition(wd, condition, 1) + wd.wait_for_object_condition(wd, condition) for net in known_networks: net.forget()
autotests/testPreauth-roam/connection_test.py +2 -2
@@ -91,14 +91,14 @@ class Test(unittest.TestCase): rule0.signal = -8000 condition = 'obj.state == DeviceState.roaming' - wd.wait_for_object_condition(device, condition, 15) + wd.wait_for_object_condition(device, condition) # TODO: verify that the PMK from preauthentication was used # Check that iwd is on BSS 1 once out of roaming state and doesn't # go through 'disconnected', 'autoconnect', 'connecting' in between condition = 'obj.state != DeviceState.roaming' - wd.wait_for_object_condition(device, condition, 5) + wd.wait_for_object_condition(device, condition) self.assertEqual(device.state, iwd.DeviceState.connected) self.assertTrue(bss_hostapd[1].list_sta())
autotests/testRSSIAgent/connection_test.py +1 -1
@@ -71,7 +71,7 @@ class Test(unittest.TestCase): rule.signal = centre agent.level = -1 condition = 'obj.level == ' + str(level) - wd.wait_for_object_condition(agent, condition, 3) + wd.wait_for_object_condition(agent, condition) self.assertTrue(agent.calls > 0) self.assertEqual(agent.device_path, device.device_path)
autotests/testSAE/autoconnect_test.py +1 -1
@@ -24,7 +24,7 @@ class Test(unittest.TestCase): devices[3].disconnect() condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition, 30) + wd.wait_for_object_condition(device, condition) condition = 'obj.connected_network is not None' wd.wait_for_object_condition(device, condition)
autotests/testScan/requested_scan_test.py +2 -2
@@ -36,9 +36,9 @@ class Test(unittest.TestCase): device = devices[0] condition = 'obj.scanning' - wd.wait_for_object_condition(device, condition, 20) + wd.wait_for_object_condition(device, condition) condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition, 20) + wd.wait_for_object_condition(device, condition) device.scan()
autotests/util/iwd.py +4 -4
@@ -867,8 +867,8 @@ class IWD(AsyncOpAbstract): tries = 0 while not self._bus.name_has_owner(IWD_SERVICE): - if ctx.args.gdb == 'None': - if tries > 100: + if not ctx.args.gdb: + if tries > 200: if start_iwd_daemon: ctx.stop_process(self._iwd_proc) self._iwd_proc = None
@@ -913,7 +913,7 @@ class IWD(AsyncOpAbstract): IWD_AGENT_MANAGER_INTERFACE) return self._agent_manager_if - def wait_for_object_condition(self, obj, condition_str, max_wait = 15): + def wait_for_object_condition(self, obj, condition_str, max_wait = 50): self._wait_timed_out = False def wait_timeout_cb(): self._wait_timed_out = True
@@ -982,7 +982,7 @@ class IWD(AsyncOpAbstract): def remove_from_storage(file_name): os.system('rm -rf ' + IWD_STORAGE_DIR + '/\'' + file_name + '\'') - def list_devices(self, wait_to_appear = 0, max_wait = 15): + def list_devices(self, wait_to_appear = 0, max_wait = 50): if not wait_to_appear: return list(self._devices.values())
autotests/util/testutil.py +1 -1
@@ -82,7 +82,7 @@ def test_connected(if0=None, if1=None, group=True): rec.append(False) while not all(rec): - r, w, x = select.select([sock0, sock1], [], [], 1.0) + r, w, x = select.select([sock0, sock1], [], [], 10) if not r: raise Exception('timeout waiting for packets: ' + repr(rec))
tools/test-runner +1 -1
@@ -43,7 +43,7 @@ config = None intf_id = 0 rad_id = 0 -TEST_MAX_TIMEOUT = 45 +TEST_MAX_TIMEOUT = 120 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
Signature · 1 line
2.21.3
PATCH v4 17/26 auto-t: fix SAE FT test and update
In reply to James PrestwoodUpdated testFT-SAE-roam to use the TestContext APIs as well as fixed the failure which was introduced after requiring stricter AKM logic for SAE networks. The new failure was due to the hostapd config not including the standard SAE AKM which is actually required by the spec.
--- autotests/testFT-SAE-roam/connection_test.py | 22 ++++++++++++-------- autotests/testFT-SAE-roam/ft-psk-3.conf | 2 -- autotests/testFT-SAE-roam/ft-sae-1.conf | 4 +--- autotests/testFT-SAE-roam/ft-sae-2.conf | 4 +--- 4 files changed, 15 insertions(+), 17 deletions(-)
autotests/testFT-SAE-roam/connection_test.py +13 -9
@@ -11,9 +11,12 @@ from iwd import NetworkType from hwsim import Hwsim from hostapd import HostapdCLI import testutil +from config import ctx class Test(unittest.TestCase): def test_roam_success(self): + wd = IWD() + hwsim = Hwsim() rule0 = hwsim.rules.create()
@@ -28,8 +31,6 @@ class Test(unittest.TestCase): rule2.source = self.bss_radio[2].addresses[0] rule2.bidirectional = True - wd = IWD() - psk_agent = PSKAgent("EasilyGuessedPassword") wd.register_psk_agent(psk_agent)
@@ -158,17 +159,20 @@ class Test(unittest.TestCase): hwsim.get_radio('rad1'), hwsim.get_radio('rad2') ] - # Set interface addresses to those expected by hostapd config files - os.system('ifconfig "' + cls.bss_hostapd[0].ifname + - '" down hw ether 12:00:00:00:00:01 up') - os.system('ifconfig "' + cls.bss_hostapd[1].ifname + - '" down hw ether 12:00:00:00:00:02 up') - os.system('ifconfig "' + cls.bss_hostapd[2].ifname + - '" down hw ether 12:00:00:00:00:03 up') + ctx.start_process(['ifconfig', cls.bss_hostapd[0].ifname, 'down', 'hw', \ + 'ether', '12:00:00:00:00:01', 'up'], wait=True) + ctx.start_process(['ifconfig', cls.bss_hostapd[1].ifname, 'down', 'hw', \ + 'ether', '12:00:00:00:00:02', 'up'], wait=True) + ctx.start_process(['ifconfig', cls.bss_hostapd[2].ifname, 'down', 'hw', \ + 'ether', '12:00:00:00:00:03', 'up'], wait=True) + # Set interface addresses to those expected by hostapd config files cls.bss_hostapd[0].reload() + cls.bss_hostapd[0].wait_for_event("AP-ENABLED") cls.bss_hostapd[1].reload() + cls.bss_hostapd[1].wait_for_event("AP-ENABLED") cls.bss_hostapd[2].reload() + cls.bss_hostapd[2].wait_for_event("AP-ENABLED") # Fill in the neighbor AP tables in both BSSes. By default each # instance knows only about current BSS, even inside one hostapd
autotests/testFT-SAE-roam/ft-psk-3.conf +0 -2
@@ -16,8 +16,6 @@ wpa_passphrase=EasilyGuessedPassword wpa_ptk_rekey=30 wpa_group_rekey=80 ieee80211w=2 -rsn_preauth=1 -rsn_preauth_interfaces=lo disable_pmksa_caching=0 # Allow PMK cache to be shared opportunistically among configured interfaces # and BSSes (i.e., all configurations within a single hostapd process).
autotests/testFT-SAE-roam/ft-sae-1.conf +1 -3
@@ -10,14 +10,12 @@ nas_identifier=dummy1 wpa=2 # Can support SAE and FT-SAE (space separated list) and/or EAP at the same # time but we want to force FT -wpa_key_mgmt=FT-SAE +wpa_key_mgmt=FT-SAE SAE sae_password=EasilyGuessedPassword|mac=ff:ff:ff:ff:ff:ff wpa_pairwise=CCMP wpa_ptk_rekey=30 wpa_group_rekey=80 ieee80211w=2 -rsn_preauth=1 -rsn_preauth_interfaces=lo disable_pmksa_caching=0 # Allow PMK cache to be shared opportunistically among configured interfaces # and BSSes (i.e., all configurations within a single hostapd process).
autotests/testFT-SAE-roam/ft-sae-2.conf +1 -3
@@ -10,14 +10,12 @@ nas_identifier=dummy2 wpa=2 # Can support SAE and FT-SAE (space separated list) and/or EAP at the same # time but we want to force FT -wpa_key_mgmt=FT-SAE +wpa_key_mgmt=FT-SAE SAE sae_password=EasilyGuessedPassword|mac=ff:ff:ff:ff:ff:ff wpa_pairwise=CCMP wpa_ptk_rekey=30 wpa_group_rekey=80 ieee80211w=2 -rsn_preauth=1 -rsn_preauth_interfaces=lo disable_pmksa_caching=0 # Allow PMK cache to be shared opportunistically among configured interfaces # and BSSes (i.e., all configurations within a single hostapd process).
Signature · 1 line
2.21.3
PATCH v4 18/26 auto-t: update testClientNonInteractive to use TestContext
In reply to James PrestwoodThis makes any iwctl output hidden unless enabled via the verbose option.
--- .../connect_command_test.py | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-)
autotests/testClientNonInteractive/connect_command_test.py +12 -14
@@ -8,6 +8,7 @@ import iwd from iwd import IWD import testutil import subprocess +from config import ctx class Test(unittest.TestCase):
@@ -34,11 +35,10 @@ class Test(unittest.TestCase): # Use --dontaks cmd-line option with self.assertRaises(subprocess.CalledProcessError): - subprocess.check_call(['iwctl', '-d', 'station', - device.name, 'connect', ssid]) + ctx.start_process(['iwctl', 'd', 'station', device.name, 'connect', ssid], check=True) - subprocess.check_call(['iwctl', '-P', 'passphrase', - 'station', device.name, 'connect', ssid]) + ctx.start_process(['iwctl', '-P', 'passphrase', 'station', device.name, 'connect', ssid], + check=True) self.check_connection_success(ssid)
@@ -47,9 +47,8 @@ class Test(unittest.TestCase): device = self.wd.list_devices(1)[0] - subprocess.check_call(['iwctl', '-u', 'user', '-p', 'password', - 'station', device.name, 'connect', ssid]) - + ctx.start_process(['iwctl', '-u', 'user', '-p', 'password', 'station', \ + device.name, 'connect', ssid], check=True) self.check_connection_success(ssid) def test_connection_with_password(self):
@@ -57,8 +56,8 @@ class Test(unittest.TestCase): device = self.wd.list_devices(1)[0] - subprocess.check_call(['iwctl', '-p', 'password', - 'station', device.name, 'connect', ssid]) + ctx.start_process(['iwctl', '-p', 'password', 'station', device.name, 'connect', ssid], + check=True) self.check_connection_success(ssid)
@@ -68,8 +67,8 @@ class Test(unittest.TestCase): device = self.wd.list_devices(1)[0] with self.assertRaises(subprocess.CalledProcessError): - subprocess.check_call(['iwctl', '-P', 'incorrect_passphrase', - 'station', device.name, 'connect', ssid]) + ctx.start_process(['iwctl', '-P', 'incorrect_passphrase', 'station', device.name, \ + 'connect', ssid], check=True) def test_invalid_command_line_option(self): ssid = 'ssidPassphrase'
@@ -77,14 +76,13 @@ class Test(unittest.TestCase): device = self.wd.list_devices(1)[0] with self.assertRaises(subprocess.CalledProcessError): - subprocess.check_call(['iwctl', '-z', - 'station', device.name, 'connect', ssid]) + ctx.start_process(['iwctl', '-z', 'station', device.name, 'connect', ssid], check=True) def test_invalid_command(self): device = self.wd.list_devices(1)[0] with self.assertRaises(subprocess.CalledProcessError): - subprocess.check_call(['iwctl', 'inexistent', 'command']) + ctx.start_process(['iwctl', 'inexistent', 'command'], check=True) @classmethod def setUpClass(cls):
Signature · 1 line
2.21.3
PATCH v4 19/26 auto-t: update testAgent to use TestContext
In reply to James PrestwoodThis hides iwctl output unless verbose is specified
--- autotests/testAgent/agent_test.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
autotests/testAgent/agent_test.py +3 -2
@@ -10,6 +10,7 @@ from iwd import PSKAgent from iwd import NetworkType import testutil import subprocess +from config import ctx class Test(unittest.TestCase):
@@ -57,7 +58,7 @@ class Test(unittest.TestCase): def test_connection_with_other_agent(self): wd = IWD() - iwctl = subprocess.Popen(['iwctl', '-P', 'secret_ssid2']) + iwctl = ctx.start_process(['iwctl', '-P', 'secret_ssid2']).pid # Let iwctl to start and register its agent. wd.wait(2)
@@ -72,7 +73,7 @@ class Test(unittest.TestCase): wd = IWD() - iwctl = subprocess.Popen(['iwctl', '-P', 'secret_ssid2']) + iwctl = ctx.start_process(['iwctl', '-P', 'secret_ssid2']).pid # Let iwctl to start and register its agent. wd.wait(2)
Signature · 1 line
2.21.3
PATCH v4 20/26 auto-t: fix testBSSBlacklist
In reply to James PrestwoodThere 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.
--- .../testBSSBlacklist/all_blacklisted_test.py | 11 ++++++++--- autotests/testBSSBlacklist/bad_pass_test.py | 8 +++++++- autotests/testBSSBlacklist/connection_test.py | 9 +++++++-- autotests/testBSSBlacklist/temp_blacklist_test.py | 15 ++++++++++++++- 4 files changed, 36 insertions(+), 7 deletions(-)
autotests/testBSSBlacklist/all_blacklisted_test.py +8 -3
@@ -37,7 +37,7 @@ class Test(unittest.TestCase): rule2 = hwsim.rules.create() rule2.source = bss_radio[2].addresses[0] rule2.bidirectional = True - rule2.signal = -10000 + rule2.signal = -9000 wd = IWD(True)
@@ -72,17 +72,22 @@ class Test(unittest.TestCase): rule0.drop = False rule1.drop = False + rule2.drop = False # This connect should work ordered_network.network_object.connect() - condition = 'obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(device, condition) self.assertIn(device.address, bss_hostapd[0].list_sta()) wd.unregister_psk_agent(psk_agent) + rule0.remove() + rule1.remove() + rule2.remove() + @classmethod def setUpClass(cls): pass
autotests/testBSSBlacklist/bad_pass_test.py +7 -1
@@ -39,7 +39,7 @@ class Test(unittest.TestCase): rule2.bidirectional = True rule2.signal = -4000 - wd = IWD(True, '/tmp') + wd = IWD(True) psk_agent = PSKAgent("wrong_password") wd.register_psk_agent(psk_agent)
@@ -80,6 +80,12 @@ class Test(unittest.TestCase): condition = 'obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) + wd.unregister_psk_agent(psk_agent) + + rule0.remove() + rule1.remove() + rule2.remove() + @classmethod def setUpClass(cls): pass
autotests/testBSSBlacklist/connection_test.py +7 -2
@@ -10,7 +10,6 @@ from iwd import PSKAgent from iwd import NetworkType from hostapd import HostapdCLI - from hwsim import Hwsim import time
@@ -42,7 +41,7 @@ class Test(unittest.TestCase): rule2.bidirectional = True rule2.signal = -4000 - wd = IWD(True, '/tmp') + wd = IWD(True) psk_agent = PSKAgent("secret123") wd.register_psk_agent(psk_agent)
@@ -67,6 +66,8 @@ class Test(unittest.TestCase): condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) + rule0.drop = True + ordered_network.network_object.connect(wait=False) # 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) + rule0.remove() + rule1.remove() + rule2.remove() + @classmethod def setUpClass(cls): IWD.copy_to_storage('main.conf')
autotests/testBSSBlacklist/temp_blacklist_test.py +14 -1
@@ -39,7 +39,7 @@ class Test(unittest.TestCase): rule2.bidirectional = True rule2.signal = -2000 - wd = IWD(True, '/tmp') + wd = IWD(True) psk_agent = PSKAgent("secret123") wd.register_psk_agent(psk_agent)
@@ -63,6 +63,9 @@ class Test(unittest.TestCase): 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()) # 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() + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(dev2, condition) + # We should have temporarily blacklisted the first BSS, and connected # to this one. self.assertIn(dev2.address, bss_hostapd[1].list_sta())
@@ -111,10 +117,17 @@ class Test(unittest.TestCase): 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()) wd.unregister_psk_agent(psk_agent) + rule0.remove() + rule1.remove() + rule2.remove() + @classmethod def setUpClass(cls): IWD.copy_to_storage('main.conf')
Signature · 1 line
2.21.3
PATCH v4 21/26 auto-t: fix testAP
In reply to James PrestwoodAs with other tests, wait on device state instead of the network object. The connectivity test was also changed to not check for group traffic since AP does not negotiate the IGTK at this time.
--- autotests/testAP/connection_test.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
autotests/testAP/connection_test.py +5 -6
@@ -24,8 +24,8 @@ class Test(unittest.TestCase): ordered_network.network_object.connect() - condition = 'obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(dev, condition) wd.unregister_psk_agent(psk_agent)
@@ -74,12 +74,11 @@ class Test(unittest.TestCase): networks['TestAP2'].network_object.connect() - condition = 'obj.connected' - wd.wait_for_object_condition(networks['TestAP2'].network_object, - condition) + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(dev2, condition) testutil.test_iface_operstate(dev2.name) - testutil.test_ifaces_connected(dev1.name, dev2.name) + testutil.test_ifaces_connected(dev1.name, dev2.name, group=False) wd.unregister_psk_agent(psk_agent)
Signature · 1 line
2.21.3
PATCH v4 22/26 auto-t: fix testAPRoam
In reply to James PrestwoodThis test occationally fails due to no hwsim rules. Basically we were just expecting iwd to connect to one of 3 access points but the ranking was equal, so it chose the first in the scan list.
Now a signal strength is assigned to each AP to steer IWD into connecting to the expected AP.
--- autotests/testAPRoam/connection_test.py | 29 +++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-)
autotests/testAPRoam/connection_test.py +27 -2
@@ -24,6 +24,22 @@ class Test(unittest.TestCase): hwsim.get_radio('rad1'), hwsim.get_radio('rad2') ] + rule0 = hwsim.rules.create() + rule0.source = bss_radio[0].addresses[0] + rule0.bidirectional = True + + rule1 = hwsim.rules.create() + rule1.source = bss_radio[1].addresses[0] + rule1.bidirectional = True + + rule2 = hwsim.rules.create() + rule2.source = bss_radio[2].addresses[0] + rule2.bidirectional = True + + rule0.signal = -2000 + rule1.signal = -2500 + rule2.signal = -3000 + wd = IWD() psk_agent = PSKAgent("secret123")
@@ -49,8 +65,10 @@ class Test(unittest.TestCase): ordered_network.network_object.connect() - condition = 'obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(device, condition) + + bss_hostapd[0].wait_for_event('AP-STA-CONNECTED') self.assertTrue(bss_hostapd[0].list_sta()) self.assertFalse(bss_hostapd[1].list_sta())
@@ -65,6 +83,9 @@ class Test(unittest.TestCase): condition = 'obj.state != DeviceState.roaming' wd.wait_for_object_condition(device, condition) + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(device, condition) + self.assertEqual(device.state, iwd.DeviceState.connected) self.assertTrue(bss_hostapd[1].list_sta()) device.disconnect()
@@ -74,6 +95,10 @@ class Test(unittest.TestCase): wd.unregister_psk_agent(psk_agent) + rule0.remove() + rule1.remove() + rule2.remove() + @classmethod def setUpClass(cls): pass
Signature · 1 line
2.21.3
PATCH v4 23/26 auto-t: harden testHotspot
In reply to James PrestwoodThis test occationally failed, and it uses the old style of waiting for connected on the network object instead of the device object.
The hwsim rule was also moved ahead of the IWD() initializer which ensures that IWD doesn't scan before the rule can be set/processed.
--- autotests/testHotspot/anqp_delay_test.py | 11 ++++++----- autotests/testHotspot/hessid_test.py | 4 ++-- autotests/testHotspot/hotspot_test.py | 4 ++-- autotests/testHotspot/roaming_test.py | 4 ++-- 4 files changed, 12 insertions(+), 11 deletions(-)
autotests/testHotspot/anqp_delay_test.py +6 -5
@@ -23,10 +23,8 @@ class Test(unittest.TestCase): rule0 = hwsim.rules.create() rule0.source = bss_radio.addresses[0] rule0.bidirectional = True - # Force the case where ANQP does not finish before Connect() comes in - rule0.delay = 100 - wd = IWD(True, '/tmp') + wd = IWD(True) hapd = HostapdCLI(config='ssidHotspot.conf')
@@ -53,12 +51,15 @@ class Test(unittest.TestCase): condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) + # Force the case where ANQP does not finish before Connect() comes in + rule0.delay = 100 + ordered_network.network_object.connect() rule0.delay = 1 - condition = 'obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(device, condition) testutil.test_iface_operstate() testutil.test_ifaces_connected(device.name, hapd.ifname)
autotests/testHotspot/hessid_test.py +2 -2
@@ -42,8 +42,8 @@ class Test(unittest.TestCase): ordered_network.network_object.connect() - condition = 'obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(device, condition) testutil.test_iface_operstate() testutil.test_ifaces_connected(device.name, hapd.ifname)
autotests/testHotspot/hotspot_test.py +2 -2
@@ -42,8 +42,8 @@ class Test(unittest.TestCase): ordered_network.network_object.connect() - condition = 'obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(device, condition) testutil.test_iface_operstate() testutil.test_ifaces_connected(device.name, hapd.ifname)
autotests/testHotspot/roaming_test.py +2 -2
@@ -42,8 +42,8 @@ class Test(unittest.TestCase): ordered_network.network_object.connect() - condition = 'obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(device, condition) testutil.test_iface_operstate() testutil.test_ifaces_connected(device.name, hapd.ifname)
Signature · 1 line
2.21.3
PATCH v4 24/26 auto-t: fix testWPA2 to wait for device object
In reply to James Prestwood--- autotests/testWPA2/connection_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
autotests/testWPA2/connection_test.py +2 -2
@@ -38,8 +38,8 @@ class Test(unittest.TestCase): ordered_network.network_object.connect() - condition = 'obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(device, condition) testutil.test_iface_operstate() testutil.test_ifaces_connected()
Signature · 1 line
2.21.3
PATCH v4 25/26 auto-t: fix testPreauth-roam
In reply to James PrestwoodChanged to wait for DeviceState instead of network object as well as moved hwsim rules ahead of the IWD initializer to avoid IWD scanning before the rules are fully in place.
--- autotests/testPreauth-roam/connection_test.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
autotests/testPreauth-roam/connection_test.py +6 -6
@@ -44,14 +44,14 @@ class Test(unittest.TestCase): bss_hostapd[1].set_neighbor(bss_radio[0].addresses[0], 'TestPreauth', bss0_nr) - wd = IWD() - - device = wd.list_devices(1)[0] - # Check that iwd selects BSS 0 first rule0.signal = -2500 rule1.signal = -3500 + wd = IWD() + + device = wd.list_devices(1)[0] + condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition)
@@ -76,8 +76,8 @@ class Test(unittest.TestCase): ordered_network.network_object.connect() - condition = 'obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(device, condition) self.assertTrue(bss_hostapd[0].list_sta()) self.assertFalse(bss_hostapd[1].list_sta())
Signature · 1 line
2.21.3
PATCH v4 26/26 auto-t: fix testFT-PSK-roam
In reply to James PrestwoodSwitched around hwsim rules with the IWD initializer to avoid IWD periodically scanning before hwsim rules are in place. Removed some unneeded code during teardown.
--- autotests/testFT-PSK-roam/connection_test.py | 39 ++++++-------------- autotests/testFT-PSK-roam/hw.conf | 1 + 2 files changed, 13 insertions(+), 27 deletions(-)
autotests/testFT-PSK-roam/connection_test.py +12 -27
@@ -24,7 +24,11 @@ class Test(unittest.TestCase): rule1.source = self.bss_radio[1].addresses[0] rule1.bidirectional = True - wd = self.wd + # Check that iwd selects BSS 0 first + rule0.signal = -2000 + rule1.signal = -2500 + + wd = IWD(True) psk_agent = PSKAgent("EasilyGuessedPassword") wd.register_psk_agent(psk_agent)
@@ -33,10 +37,6 @@ class Test(unittest.TestCase): # prevent autoconnect device.disconnect() - # Check that iwd selects BSS 0 first - rule0.signal = -2000 - rule1.signal = -2500 - condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition)
@@ -61,8 +61,8 @@ class Test(unittest.TestCase): ordered_network.network_object.connect() - condition = 'obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(device, condition) self.assertTrue(self.bss_hostapd[0].list_sta()) self.assertFalse(self.bss_hostapd[1].list_sta())
@@ -109,7 +109,11 @@ class Test(unittest.TestCase): rule1.source = self.bss_radio[1].addresses[0] rule1.bidirectional = True - wd = self.wd + # Check that iwd selects BSS 0 first + rule0.signal = -2000 + rule1.signal = -2500 + + wd = IWD(True) psk_agent = PSKAgent("EasilyGuessedPassword") wd.register_psk_agent(psk_agent)
@@ -118,10 +122,6 @@ class Test(unittest.TestCase): # prevent autoconnect device.disconnect() - # Check that iwd selects BSS 0 first - rule0.signal = -2000 - rule1.signal = -2500 - condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition)
@@ -180,8 +180,6 @@ class Test(unittest.TestCase): testutil.test_ifaces_connected(self.bss_hostapd[1].ifname, device.name) self.assertRaises(Exception, testutil.test_ifaces_connected, (self.bss_hostapd[0].ifname, device.name)) - def setUp(self): - self.wd = IWD() def tearDown(self): os.system('ifconfig "' + self.bss_hostapd[0].ifname + '" down')
@@ -189,19 +187,6 @@ class Test(unittest.TestCase): os.system('ifconfig "' + self.bss_hostapd[0].ifname + '" up') os.system('ifconfig "' + self.bss_hostapd[1].ifname + '" up') - hwsim = Hwsim() - device = self.wd.list_devices(1)[0] - try: - device.disconnect() - except: - pass - - condition = 'obj.state == DeviceState.disconnected' - self.wd.wait_for_object_condition(device, condition) - - for rule in list(hwsim.rules.keys()): - del hwsim.rules[rule] - @classmethod def setUpClass(cls): hwsim = Hwsim()
autotests/testFT-PSK-roam/hw.conf +1 -0
@@ -3,6 +3,7 @@ num_radios=3 max_test_exec_interval_sec=45 tmpfs_extra_stuff=main.conf needs_hwsim=1 +start_iwd=0 [HOSTAPD] rad0=ft-psk-ccmp-1.conf
Signature · 1 line
2.21.3