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,16 +79,44 @@ 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")
params = { 'ssid': "test-wnm-mbo", id = dev[1].add_network()
'mbo': '1', dev[1].set_network(id, "mode", "2")
"country_code": "US", dev[1].set_network_quoted(id, "ssid", "country-clear")
'ieee80211d': '1', dev[1].set_network(id, "key_mgmt", "NONE")
"ieee80211n": "1", dev[1].set_network(id, "frequency", "2412")
"hw_mode": "a", dev[1].set_network(id, "scan_freq", "2412")
"channel": "36" } dev[1].select_network(id)
hapd = hostapd.add_ap(apdev[0], params, no_enable=True) 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",
'mbo': '1',
"country_code": "US",
'ieee80211d': '1',
"ieee80211n": "1",
"hw_mode": "a",
"channel": "36" }
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,42 +129,66 @@ 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" # For now, allow operating class 129 to be missing since not all
fi = "515354737475767778797a7b808182" # installed regdb files include the 160 MHz channels.
us = "515354737475767778797a7b7c7d7e7f808182" expected2 = expected.replace('808182', '8082')
jp = "51525354737475767778797a7b808182" # For now, allow operating classes 121-123 to be missing since not all
bd = "5153547c7d7e7f80" # installed regdb files include the related US DFS channels.
sy = "515354" expected2 = expected2.replace('78797a7b7c', '787c')
if res2 != expected and res2 != expected2:
raise Exception("Unexpected supp_op_class string (country=%s, 2.4 GHz): %s (expected: %s)" % (country, res2, expected))
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))
tests = [ ("ZA", za, za2, za5, True), def test_mbo_supp_oper_classes_za(dev, apdev):
("FI", fi, fi2, fi5, True), """MBO and supported operating classes (ZA)"""
("US", us, us2, us5, True), run_mbo_supp_oper_class(dev, apdev, "ZA",
("JP", jp, jp2, jp5, True), "515354737475767778797a7b808182", True)
("BD", bd, bd2, bd5, False),
("SY", sy, sy2, sy5, False) ] def test_mbo_supp_oper_classes_fi(dev, apdev):
for country, expected, res2, res5, inc5 in tests: """MBO and supported operating classes (FI)"""
# For now, allow operating class 129 to be missing since not all run_mbo_supp_oper_class(dev, apdev, "FI",
# installed regdb files include the 160 MHz channels. "515354737475767778797a7b808182", True)
expected2 = expected.replace('808182', '8082')
# For now, allow operating classes 121-123 to be missing since not all def test_mbo_supp_oper_classes_us(dev, apdev):
# installed regdb files include the related US DFS channels. """MBO and supported operating classes (US)"""
expected2 = expected2.replace('78797a7b7c', '787c') run_mbo_supp_oper_class(dev, apdev, "US",
if res2 != expected and res2 != expected2: "515354737475767778797a7b7c7d7e7f808182", True)
raise Exception("Unexpected supp_op_class string (country=%s, 2.4 GHz): %s (expected: %s)" % (country, res2, expected))
if inc5 and res5 != expected and res5 != expected2: def test_mbo_supp_oper_classes_jp(dev, apdev):
raise Exception("Unexpected supp_op_class string (country=%s, 5 GHz): %s (expected: %s)" % (country, res5, expected)) """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"""