tests: Fix workaround for limited channel survey in mac80211_hwsim

The way the current channel survey is implemented in mac80211_hwsim
requires for the ACS test cases to be run immediately after the same
radio has been on the expected operating band. This was worked around in
one of the test cases and errors ignored in couple. Extend this
workaround to cover all the test cases.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Jouni Malinen 2015-03-03 16:01:52 +02:00 committed by Jouni Malinen
parent 9416e47f47
commit 19ec6070ff

View file

@ -11,6 +11,23 @@ import time
import hostapd import hostapd
def force_prev_ap_on_24g(ap):
# For now, make sure the last operating channel was on 2.4 GHz band to get
# sufficient survey data from mac80211_hwsim.
hostapd.add_ap(ap['ifname'], { "ssid": "open" })
time.sleep(0.1)
hapd_global = hostapd.HostapdGlobal()
hapd_global.remove(ap['ifname'])
def force_prev_ap_on_5g(ap):
# For now, make sure the last operating channel was on 5 GHz band to get
# sufficient survey data from mac80211_hwsim.
hostapd.add_ap(ap['ifname'], { "ssid": "open", "hw_mode": "a",
"channel": "36", "country_code": "US" })
time.sleep(0.1)
hapd_global = hostapd.HostapdGlobal()
hapd_global.remove(ap['ifname'])
def wait_acs(hapd): def wait_acs(hapd):
ev = hapd.wait_event(["ACS-STARTED", "ACS-COMPLETED", "ACS-FAILED", ev = hapd.wait_event(["ACS-STARTED", "ACS-COMPLETED", "ACS-FAILED",
"AP-ENABLED", "AP-DISABLED"], timeout=5) "AP-ENABLED", "AP-DISABLED"], timeout=5)
@ -42,6 +59,7 @@ def wait_acs(hapd):
def test_ap_acs(dev, apdev): def test_ap_acs(dev, apdev):
"""Automatic channel selection""" """Automatic channel selection"""
force_prev_ap_on_24g(apdev[0])
params = hostapd.wpa2_params(ssid="test-acs", passphrase="12345678") params = hostapd.wpa2_params(ssid="test-acs", passphrase="12345678")
params['channel'] = '0' params['channel'] = '0'
hapd = hostapd.add_ap(apdev[0]['ifname'], params, wait_enabled=False) hapd = hostapd.add_ap(apdev[0]['ifname'], params, wait_enabled=False)
@ -56,13 +74,7 @@ def test_ap_acs(dev, apdev):
def test_ap_multi_bss_acs(dev, apdev): def test_ap_multi_bss_acs(dev, apdev):
"""hostapd start with a multi-BSS configuration file using ACS""" """hostapd start with a multi-BSS configuration file using ACS"""
ifname = apdev[0]['ifname'] ifname = apdev[0]['ifname']
force_prev_ap_on_24g(apdev[0])
# make sure the current channel is on 2.4 GHz band as a workaround for the
# limited survey functionality in mac80211_hwsim
hostapd.add_ap(ifname, { "ssid": "test" })
time.sleep(0.1)
hapd_global = hostapd.HostapdGlobal()
hapd_global.remove(ifname)
# start the actual test # start the actual test
hostapd.add_iface(ifname, 'multi-bss-acs.conf') hostapd.add_iface(ifname, 'multi-bss-acs.conf')
@ -80,6 +92,7 @@ def test_ap_multi_bss_acs(dev, apdev):
def test_ap_acs_40mhz(dev, apdev): def test_ap_acs_40mhz(dev, apdev):
"""Automatic channel selection for 40 MHz channel""" """Automatic channel selection for 40 MHz channel"""
force_prev_ap_on_24g(apdev[0])
params = hostapd.wpa2_params(ssid="test-acs", passphrase="12345678") params = hostapd.wpa2_params(ssid="test-acs", passphrase="12345678")
params['channel'] = '0' params['channel'] = '0'
params['ht_capab'] = '[HT40+]' params['ht_capab'] = '[HT40+]'
@ -99,26 +112,18 @@ def test_ap_acs_5ghz(dev, apdev):
"""Automatic channel selection on 5 GHz""" """Automatic channel selection on 5 GHz"""
try: try:
hapd = None hapd = None
force_prev_ap_on_5g(apdev[0])
params = hostapd.wpa2_params(ssid="test-acs", passphrase="12345678") params = hostapd.wpa2_params(ssid="test-acs", passphrase="12345678")
params['hw_mode'] = 'a' params['hw_mode'] = 'a'
params['channel'] = '0' params['channel'] = '0'
params['country_code'] = 'US' params['country_code'] = 'US'
hapd = hostapd.add_ap(apdev[0]['ifname'], params, wait_enabled=False) hapd = hostapd.add_ap(apdev[0]['ifname'], params, wait_enabled=False)
# TODO: Remove exception acceptance once mac80211_hwsim supports ACS on wait_acs(hapd)
# 5 GHz freq = hapd.get_status_field("freq")
run = False if int(freq) < 5000:
try: raise Exception("Unexpected frequency")
wait_acs(hapd)
run = True
except Exception, e:
logger.info("Ignore exception due to missing hwsim support: " + str(e))
if run: dev[0].connect("test-acs", psk="12345678", scan_freq=freq)
freq = hapd.get_status_field("freq")
if int(freq) < 5000:
raise Exception("Unexpected frequency")
dev[0].connect("test-acs", psk="12345678", scan_freq=freq)
finally: finally:
dev[0].request("DISCONNECT") dev[0].request("DISCONNECT")
@ -131,31 +136,23 @@ def test_ap_acs_5ghz_40mhz(dev, apdev):
"""Automatic channel selection on 5 GHz for 40 MHz channel""" """Automatic channel selection on 5 GHz for 40 MHz channel"""
try: try:
hapd = None hapd = None
force_prev_ap_on_5g(apdev[0])
params = hostapd.wpa2_params(ssid="test-acs", passphrase="12345678") params = hostapd.wpa2_params(ssid="test-acs", passphrase="12345678")
params['hw_mode'] = 'a' params['hw_mode'] = 'a'
params['channel'] = '0' params['channel'] = '0'
params['ht_capab'] = '[HT40+]' params['ht_capab'] = '[HT40+]'
params['country_code'] = 'US' params['country_code'] = 'US'
hapd = hostapd.add_ap(apdev[0]['ifname'], params, wait_enabled=False) hapd = hostapd.add_ap(apdev[0]['ifname'], params, wait_enabled=False)
# TODO: Remove exception acceptance once mac80211_hwsim supports ACS on wait_acs(hapd)
# 5 GHz freq = hapd.get_status_field("freq")
run = False if int(freq) < 5000:
try: raise Exception("Unexpected frequency")
wait_acs(hapd)
run = True
except Exception, e:
logger.info("Ignore exception due to missing hwsim support: " + str(e))
if run: sec = hapd.get_status_field("secondary_channel")
freq = hapd.get_status_field("freq") if int(sec) == 0:
if int(freq) < 5000: raise Exception("Secondary channel not set")
raise Exception("Unexpected frequency")
sec = hapd.get_status_field("secondary_channel") dev[0].connect("test-acs", psk="12345678", scan_freq=freq)
if int(sec) == 0:
raise Exception("Secondary channel not set")
dev[0].connect("test-acs", psk="12345678", scan_freq=freq)
finally: finally:
dev[0].request("DISCONNECT") dev[0].request("DISCONNECT")
@ -168,6 +165,7 @@ def test_ap_acs_vht(dev, apdev):
"""Automatic channel selection for VHT""" """Automatic channel selection for VHT"""
try: try:
hapd = None hapd = None
force_prev_ap_on_5g(apdev[0])
params = hostapd.wpa2_params(ssid="test-acs", passphrase="12345678") params = hostapd.wpa2_params(ssid="test-acs", passphrase="12345678")
params['hw_mode'] = 'a' params['hw_mode'] = 'a'
params['channel'] = '0' params['channel'] = '0'
@ -176,25 +174,16 @@ def test_ap_acs_vht(dev, apdev):
params['ieee80211ac'] = '1' params['ieee80211ac'] = '1'
params['vht_oper_chwidth'] = '1' params['vht_oper_chwidth'] = '1'
hapd = hostapd.add_ap(apdev[0]['ifname'], params, wait_enabled=False) hapd = hostapd.add_ap(apdev[0]['ifname'], params, wait_enabled=False)
# TODO: Remove exception acceptance once mac80211_hwsim supports ACS on wait_acs(hapd)
# 5 GHz freq = hapd.get_status_field("freq")
run = False if int(freq) < 5000:
try: raise Exception("Unexpected frequency")
wait_acs(hapd)
run = True
except Exception, e:
logger.info("Ignore exception due to missing hwsim support: " + str(e))
if run: sec = hapd.get_status_field("secondary_channel")
freq = hapd.get_status_field("freq") if int(sec) == 0:
if int(freq) < 5000: raise Exception("Secondary channel not set")
raise Exception("Unexpected frequency")
sec = hapd.get_status_field("secondary_channel") dev[0].connect("test-acs", psk="12345678", scan_freq=freq)
if int(sec) == 0:
raise Exception("Secondary channel not set")
dev[0].connect("test-acs", psk="12345678", scan_freq=freq)
finally: finally:
dev[0].request("DISCONNECT") dev[0].request("DISCONNECT")
@ -205,6 +194,7 @@ def test_ap_acs_vht(dev, apdev):
def test_ap_acs_bias(dev, apdev): def test_ap_acs_bias(dev, apdev):
"""Automatic channel selection with bias values""" """Automatic channel selection with bias values"""
force_prev_ap_on_24g(apdev[0])
params = hostapd.wpa2_params(ssid="test-acs", passphrase="12345678") params = hostapd.wpa2_params(ssid="test-acs", passphrase="12345678")
params['channel'] = '0' params['channel'] = '0'
params['acs_chan_bias'] = '1:0.8 3:1.2 6:0.7 11:0.8' params['acs_chan_bias'] = '1:0.8 3:1.2 6:0.7 11:0.8'