From bcfcb247db68391e94b21783a2239e0ba5741d38 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 20 Mar 2021 00:22:28 +0200 Subject: [PATCH] tests: hostapd airtime policy configuration Add minimal testing for airtime policy configuration. mac80211_hwsim does not actually support this functionality, so this is just for testing coverage of src/ap/airtime_policy.c. Signed-off-by: Jouni Malinen --- tests/hwsim/example-hostapd.config | 1 + tests/hwsim/test_ap_params.py | 61 ++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/tests/hwsim/example-hostapd.config b/tests/hwsim/example-hostapd.config index 8b466e8ae..d01a1d2ed 100644 --- a/tests/hwsim/example-hostapd.config +++ b/tests/hwsim/example-hostapd.config @@ -113,3 +113,4 @@ CONFIG_DPP=y CONFIG_DPP2=y CONFIG_WEP=y CONFIG_PASN=y +CONFIG_AIRTIME_POLICY=y diff --git a/tests/hwsim/test_ap_params.py b/tests/hwsim/test_ap_params.py index 5da861593..72ac8e443 100644 --- a/tests/hwsim/test_ap_params.py +++ b/tests/hwsim/test_ap_params.py @@ -909,3 +909,64 @@ def test_ap_notify_mgmt_frames_disabled(dev, apdev): ev = hapd.wait_event(["AP-MGMT-FRAME-RECEIVED"], timeout=0.1) if ev is not None: raise Exception("Unexpected AP-MGMT-FRAME-RECEIVED") + +def test_ap_airtime_policy_static(dev, apdev): + """Airtime policy - static""" + ssid = "test-wpa2-psk" + passphrase = 'qwertyuiop' + params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) + params['airtime_mode'] = "1" + params['airtime_update_interval'] = "200" + params['airtime_sta_weight'] = dev[0].own_addr() + " 512" + hapd = hostapd.add_ap(apdev[0], params) + dev[0].connect(ssid, psk=passphrase, scan_freq="2412") + dev[1].connect(ssid, psk=passphrase, scan_freq="2412") + time.sleep(1) + +def test_ap_airtime_policy_per_bss_dynamic(dev, apdev): + """Airtime policy - per-BSS dynamic""" + ssid = "test-wpa2-psk" + passphrase = 'qwertyuiop' + params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) + params['airtime_mode'] = "2" + params['airtime_update_interval'] = "200" + params['airtime_bss_weight'] = "2" + hapd = hostapd.add_ap(apdev[0], params) + dev[0].connect(ssid, psk=passphrase, scan_freq="2412") + dev[1].connect(ssid, psk=passphrase, scan_freq="2412") + time.sleep(1) + +def test_ap_airtime_policy_per_bss_limit(dev, apdev): + """Airtime policy - per-BSS limit""" + ssid = "test-wpa2-psk" + passphrase = 'qwertyuiop' + params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) + params['airtime_mode'] = "3" + params['airtime_update_interval'] = "200" + params['airtime_bss_weight'] = "2" + params['airtime_bss_limit'] = "1" + hapd = hostapd.add_ap(apdev[0], params) + dev[0].connect(ssid, psk=passphrase, scan_freq="2412") + dev[1].connect(ssid, psk=passphrase, scan_freq="2412") + time.sleep(1) + hapd.set("force_backlog_bytes", "1") + time.sleep(1) + +def test_ap_airtime_policy_per_bss_limit_invalid(dev, apdev): + """Airtime policy - per-BSS limit (invalid)""" + ssid = "test-wpa2-psk" + passphrase = 'qwertyuiop' + params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) + params['airtime_mode'] = "3" + params['airtime_update_interval'] = "0" + params['airtime_bss_weight'] = "2" + params['airtime_bss_limit'] = "1" + hapd = hostapd.add_ap(apdev[0], params, no_enable=True) + if "FAIL" not in hapd.request("ENABLE"): + raise Exception("Invalid airtime policy configuration accepted") + hapd.set("airtime_update_interval", "200") + hapd.enable() + hapd.set("airtime_update_interval", "0") + dev[0].connect(ssid, psk=passphrase, scan_freq="2412") + dev[1].connect(ssid, psk=passphrase, scan_freq="2412") + time.sleep(1)