From d47e31954b807f402e53d85f9c821f381a13b519 Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Mon, 25 Feb 2019 12:29:33 -0800 Subject: [PATCH] auto-t: add test for HT/VHT rates This is a VERY simple test for HT/VHT. Since there are so many potential options in the IE this really just tests that drops in RSSI will cause IWD to choose a different BSS, even if that means choosing HT over VHT, or even basic rates over HT/VHT. --- autotests/testHT-VHT/ht.conf | 10 ++ autotests/testHT-VHT/hw.conf | 11 +++ autotests/testHT-VHT/main.conf | 2 + autotests/testHT-VHT/non-ht-vht.conf | 7 ++ autotests/testHT-VHT/test.py | 137 +++++++++++++++++++++++++++ autotests/testHT-VHT/vht.conf | 13 +++ 6 files changed, 180 insertions(+) create mode 100644 autotests/testHT-VHT/ht.conf create mode 100644 autotests/testHT-VHT/hw.conf create mode 100644 autotests/testHT-VHT/main.conf create mode 100644 autotests/testHT-VHT/non-ht-vht.conf create mode 100644 autotests/testHT-VHT/test.py create mode 100644 autotests/testHT-VHT/vht.conf diff --git a/autotests/testHT-VHT/ht.conf b/autotests/testHT-VHT/ht.conf new file mode 100644 index 00000000..b5dbc0d5 --- /dev/null +++ b/autotests/testHT-VHT/ht.conf @@ -0,0 +1,10 @@ +hw_mode=a +channel=2 +ssid=testSSID + +wpa=2 +wpa_pairwise=CCMP +wpa_passphrase=secret123 + +ieee80211n=1 +channel=36 diff --git a/autotests/testHT-VHT/hw.conf b/autotests/testHT-VHT/hw.conf new file mode 100644 index 00000000..98e1b2ea --- /dev/null +++ b/autotests/testHT-VHT/hw.conf @@ -0,0 +1,11 @@ +[SETUP] +num_radios=4 +max_test_exec_interval_sec=45 +reg_domain=US +iwd_config_dir=/tmp +tmpfs_extra_stuff=main.conf + +[HOSTAPD] +rad0=non-ht-vht.conf +rad1=ht.conf +rad2=vht.conf diff --git a/autotests/testHT-VHT/main.conf b/autotests/testHT-VHT/main.conf new file mode 100644 index 00000000..c7eaf63a --- /dev/null +++ b/autotests/testHT-VHT/main.conf @@ -0,0 +1,2 @@ +[Scan] +disable_mac_address_randomization=true diff --git a/autotests/testHT-VHT/non-ht-vht.conf b/autotests/testHT-VHT/non-ht-vht.conf new file mode 100644 index 00000000..ae6e2dac --- /dev/null +++ b/autotests/testHT-VHT/non-ht-vht.conf @@ -0,0 +1,7 @@ +hw_mode=g +channel=1 +ssid=testSSID + +wpa=2 +wpa_pairwise=CCMP +wpa_passphrase=secret123 diff --git a/autotests/testHT-VHT/test.py b/autotests/testHT-VHT/test.py new file mode 100644 index 00000000..0e49d61e --- /dev/null +++ b/autotests/testHT-VHT/test.py @@ -0,0 +1,137 @@ +#! /usr/bin/python3 + +import unittest +import sys + +sys.path.append('../util') +import iwd +from iwd import IWD +from iwd import PSKAgent +from iwd import NetworkType +from hwsim import Hwsim +from hostapd import HostapdCLI +from wiphy import wiphy_map +import testutil +from time import sleep + +class Test(unittest.TestCase): + def do_connect(self, wd, device, hostapd): + condition = 'not obj.scanning' + wd.wait_for_object_condition(device, condition) + + device.scan() + + condition = 'obj.scanning' + wd.wait_for_object_condition(device, condition) + + condition = 'not obj.scanning' + wd.wait_for_object_condition(device, condition) + + ordered_network = device.get_ordered_network('testSSID') + + self.assertEqual(ordered_network.type, NetworkType.psk) + + condition = 'not obj.connected' + wd.wait_for_object_condition(ordered_network.network_object, condition) + + ordered_network.network_object.connect() + + condition = 'obj.connected' + wd.wait_for_object_condition(ordered_network.network_object, condition) + + sleep(1) + + testutil.test_iface_operstate() + testutil.test_ifaces_connected(device.name, hostapd.ifname) + + device.disconnect() + + condition = 'not obj.connected' + wd.wait_for_object_condition(ordered_network.network_object, condition) + + def test_connection_success(self): + hwsim = Hwsim() + non_ht_hostapd = None + ht_hostapd = None + non_ht_radio = None + ht_radio = None + vht_radio = None + + for wname in wiphy_map: + wiphy = wiphy_map[wname] + intf = list(wiphy.values())[0] + if intf.config and intf.config == 'non-ht-vht.conf': + non_ht_hostapd = HostapdCLI(intf) + + for path in hwsim.radios: + radio = hwsim.radios[path] + if radio.name == wname: + non_ht_radio = radio + + elif intf.config and intf.config == 'ht.conf': + ht_hostapd = HostapdCLI(intf) + + for path in hwsim.radios: + radio = hwsim.radios[path] + if radio.name == wname: + ht_radio = radio + elif intf.config and intf.config == 'vht.conf': + vht_hostapd = HostapdCLI(intf) + + for path in hwsim.radios: + radio = hwsim.radios[path] + if radio.name == wname: + vht_radio = radio + else: + continue + + self.assertIsNotNone(non_ht_hostapd) + self.assertIsNotNone(ht_hostapd) + self.assertIsNotNone(vht_hostapd) + + rule0 = hwsim.rules.create() + rule0.source = vht_radio.addresses[0] + rule0.bidirectional = True + rule0.signal = -2000 + + rule1 = hwsim.rules.create() + rule1.source = ht_radio.addresses[0] + rule1.bidirectional = True + rule1.signal = -2000 + + rule2 = hwsim.rules.create() + rule2.source = non_ht_radio.addresses[0] + rule2.bidirectional = True + rule2.signal = -2000 + + wd = IWD() + + psk_agent = PSKAgent("secret123") + wd.register_psk_agent(psk_agent) + + device = wd.list_devices(1)[0] + + self.do_connect(wd, device, vht_hostapd) + + # lower VHT BSS signal, HT should now be preferred + rule0.signal = -6000 + + self.do_connect(wd, device, ht_hostapd) + + # lower HT BSS signal, basic rate BSS should now be preferred + rule1.signal = -6000 + + self.do_connect(wd, device, non_ht_hostapd) + + wd.unregister_psk_agent(psk_agent) + + @classmethod + def setUpClass(cls): + pass + + @classmethod + def tearDownClass(cls): + IWD.clear_storage() + +if __name__ == '__main__': + unittest.main(exit=True) diff --git a/autotests/testHT-VHT/vht.conf b/autotests/testHT-VHT/vht.conf new file mode 100644 index 00000000..23453a76 --- /dev/null +++ b/autotests/testHT-VHT/vht.conf @@ -0,0 +1,13 @@ +ssid=testSSID +wpa=2 +wpa_pairwise=CCMP +wpa_passphrase=secret123 + +country_code=US +hw_mode=a +ieee80211d=1 +ieee80211h=1 +ieee80211n=1 +ieee80211ac=1 + +channel=36