tests: Split mbo_supp_oper_classes into multiple test cases

In addition, add even more workarounds for cfg80211 regulatory state
clearing since this test case seems to be the most likely one to fail
due to country=98 issues.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2019-01-05 00:21:41 +02:00
parent 02a4ac0feb
commit cc0a04ac86

View file

@ -54,7 +54,9 @@ def run_mbo_supp_oper_classes(dev, apdev, hapd, hapd2, country):
sta = hapd.get_sta(addr) sta = hapd.get_sta(addr)
res5 = sta['supp_op_classes'][2:] res5 = sta['supp_op_classes'][2:]
dev[0].wait_regdom(country_ie=True) dev[0].wait_regdom(country_ie=True)
time.sleep(0.1)
hapd.disable() hapd.disable()
time.sleep(0.1)
dev[0].request("REMOVE_NETWORK all") dev[0].request("REMOVE_NETWORK all")
dev[0].request("ABORT_SCAN") dev[0].request("ABORT_SCAN")
dev[0].wait_disconnected() dev[0].wait_disconnected()
@ -67,7 +69,9 @@ def run_mbo_supp_oper_classes(dev, apdev, hapd, hapd2, country):
sta = hapd2.get_sta(addr) sta = hapd2.get_sta(addr)
res2 = sta['supp_op_classes'][2:] res2 = sta['supp_op_classes'][2:]
dev[0].wait_regdom(country_ie=True) dev[0].wait_regdom(country_ie=True)
time.sleep(0.1)
hapd2.disable() hapd2.disable()
time.sleep(0.1)
dev[0].request("REMOVE_NETWORK all") dev[0].request("REMOVE_NETWORK all")
dev[0].request("ABORT_SCAN") dev[0].request("ABORT_SCAN")
dev[0].wait_disconnected() dev[0].wait_disconnected()
@ -75,8 +79,34 @@ def run_mbo_supp_oper_classes(dev, apdev, hapd, hapd2, country):
return res2, res5 return res2, res5
def test_mbo_supp_oper_classes(dev, apdev): def clear_country(dev):
"""MBO and supported operating classes""" logger.info("Try to clear country")
id = dev[1].add_network()
dev[1].set_network(id, "mode", "2")
dev[1].set_network_quoted(id, "ssid", "country-clear")
dev[1].set_network(id, "key_mgmt", "NONE")
dev[1].set_network(id, "frequency", "2412")
dev[1].set_network(id, "scan_freq", "2412")
dev[1].select_network(id)
ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"])
if ev:
dev[0].connect("country-clear", key_mgmt="NONE", scan_freq="2412")
dev[1].request("DISCONNECT")
dev[0].wait_disconnected()
dev[0].request("DISCONNECT")
dev[0].request("ABORT_SCAN")
time.sleep(1)
dev[0].dump_monitor()
dev[1].dump_monitor()
def wait_regdom_changes(dev):
for i in range(10):
ev = dev.wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.1)
if ev is None:
break
def run_mbo_supp_oper_class(dev, apdev, country, expected, inc5):
if inc5:
params = { 'ssid': "test-wnm-mbo", params = { 'ssid': "test-wnm-mbo",
'mbo': '1', 'mbo': '1',
"country_code": "US", "country_code": "US",
@ -85,6 +115,8 @@ def test_mbo_supp_oper_classes(dev, apdev):
"hw_mode": "a", "hw_mode": "a",
"channel": "36" } "channel": "36" }
hapd = hostapd.add_ap(apdev[0], params, no_enable=True) hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
else:
hapd = None
params = { 'ssid': "test-wnm-mbo-2", params = { 'ssid': "test-wnm-mbo-2",
'mbo': '1', 'mbo': '1',
@ -97,32 +129,26 @@ def test_mbo_supp_oper_classes(dev, apdev):
try: try:
dev[0].request("STA_AUTOCONNECT 0") dev[0].request("STA_AUTOCONNECT 0")
za2, za5 = run_mbo_supp_oper_classes(dev, apdev, hapd, hapd2, "ZA") res2, res5 = run_mbo_supp_oper_classes(dev, apdev, hapd, hapd2, country)
fi2, fi5 = run_mbo_supp_oper_classes(dev, apdev, hapd, hapd2, "FI")
us2, us5 = run_mbo_supp_oper_classes(dev, apdev, hapd, hapd2, "US")
jp2, jp5 = run_mbo_supp_oper_classes(dev, apdev, hapd, hapd2, "JP")
bd2, bd5 = run_mbo_supp_oper_classes(dev, apdev, None, hapd2, "BD")
sy2, sy5 = run_mbo_supp_oper_classes(dev, apdev, None, hapd2, "SY")
finally: finally:
dev[0].dump_monitor() dev[0].dump_monitor()
set_reg("00", apdev[0], apdev[1], dev[0])
ev = dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=1)
dev[0].request("STA_AUTOCONNECT 1") dev[0].request("STA_AUTOCONNECT 1")
wait_regdom_changes(dev[0])
country1 = dev[0].get_driver_status_field("country")
logger.info("Country code at the end (1): " + country1)
set_reg("00", apdev[0], apdev[1], dev[0])
country2 = dev[0].get_driver_status_field("country")
logger.info("Country code at the end (2): " + country2)
for i in range(5):
ev = dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=1)
if ev is None or "init=USER type=WORLD" in ev:
break
wait_regdom_changes(dev[0])
country3 = dev[0].get_driver_status_field("country")
logger.info("Country code at the end (3): " + country3)
if country3 != "00":
clear_country(dev)
za = "515354737475767778797a7b808182"
fi = "515354737475767778797a7b808182"
us = "515354737475767778797a7b7c7d7e7f808182"
jp = "51525354737475767778797a7b808182"
bd = "5153547c7d7e7f80"
sy = "515354"
tests = [ ("ZA", za, za2, za5, True),
("FI", fi, fi2, fi5, True),
("US", us, us2, us5, True),
("JP", jp, jp2, jp5, True),
("BD", bd, bd2, bd5, False),
("SY", sy, sy2, sy5, False) ]
for country, expected, res2, res5, inc5 in tests:
# For now, allow operating class 129 to be missing since not all # For now, allow operating class 129 to be missing since not all
# installed regdb files include the 160 MHz channels. # installed regdb files include the 160 MHz channels.
expected2 = expected.replace('808182', '8082') expected2 = expected.replace('808182', '8082')
@ -134,6 +160,36 @@ def test_mbo_supp_oper_classes(dev, apdev):
if inc5 and res5 != expected and res5 != expected2: if inc5 and res5 != expected and res5 != expected2:
raise Exception("Unexpected supp_op_class string (country=%s, 5 GHz): %s (expected: %s)" % (country, res5, expected)) raise Exception("Unexpected supp_op_class string (country=%s, 5 GHz): %s (expected: %s)" % (country, res5, expected))
def test_mbo_supp_oper_classes_za(dev, apdev):
"""MBO and supported operating classes (ZA)"""
run_mbo_supp_oper_class(dev, apdev, "ZA",
"515354737475767778797a7b808182", True)
def test_mbo_supp_oper_classes_fi(dev, apdev):
"""MBO and supported operating classes (FI)"""
run_mbo_supp_oper_class(dev, apdev, "FI",
"515354737475767778797a7b808182", True)
def test_mbo_supp_oper_classes_us(dev, apdev):
"""MBO and supported operating classes (US)"""
run_mbo_supp_oper_class(dev, apdev, "US",
"515354737475767778797a7b7c7d7e7f808182", True)
def test_mbo_supp_oper_classes_jp(dev, apdev):
"""MBO and supported operating classes (JP)"""
run_mbo_supp_oper_class(dev, apdev, "JP",
"51525354737475767778797a7b808182", True)
def test_mbo_supp_oper_classes_bd(dev, apdev):
"""MBO and supported operating classes (BD)"""
run_mbo_supp_oper_class(dev, apdev, "BD",
"5153547c7d7e7f80", False)
def test_mbo_supp_oper_classes_sy(dev, apdev):
"""MBO and supported operating classes (SY)"""
run_mbo_supp_oper_class(dev, apdev, "SY",
"515354", False)
def test_mbo_assoc_disallow(dev, apdev, params): def test_mbo_assoc_disallow(dev, apdev, params):
"""MBO and association disallowed""" """MBO and association disallowed"""
hapd1 = hostapd.add_ap(apdev[0], { "ssid": "MBO", "mbo": "1" }) hapd1 = hostapd.add_ap(apdev[0], { "ssid": "MBO", "mbo": "1" })