tests: Check rrm capabilities with a helper function

And also move couple of these checks to the beginning of the test case.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2017-01-07 13:39:49 +02:00
parent 317c19c5aa
commit 073167de7b

View file

@ -18,6 +18,11 @@ from wpasupplicant import WpaSupplicant
from utils import HwsimSkip, alloc_fail, fail_test, wait_fail_trigger from utils import HwsimSkip, alloc_fail, fail_test, wait_fail_trigger
from test_ap_ht import clear_scan_cache from test_ap_ht import clear_scan_cache
def check_rrm_support(dev):
rrm = int(dev.get_driver_status_field("capa.rrm_flags"), 16)
if rrm & 0x5 != 0x5 and rrm & 0x10 != 0x10:
raise HwsimSkip("Required RRM capabilities are not supported")
nr="00112233445500000000510107" nr="00112233445500000000510107"
lci="01000800101298c0b512926666f6c2f1001c00004104050000c00012" lci="01000800101298c0b512926666f6c2f1001c00004104050000c00012"
civic="01000b0011223344556677889900998877665544332211aabbccddeeff" civic="01000b0011223344556677889900998877665544332211aabbccddeeff"
@ -149,6 +154,8 @@ def test_rrm_neighbor_db(dev, apdev):
def test_rrm_neighbor_rep_req(dev, apdev): def test_rrm_neighbor_rep_req(dev, apdev):
"""wpa_supplicant ctrl_iface NEIGHBOR_REP_REQUEST""" """wpa_supplicant ctrl_iface NEIGHBOR_REP_REQUEST"""
check_rrm_support(dev[0])
nr1="00112233445500000000510107" nr1="00112233445500000000510107"
nr2="00112233445600000000510107" nr2="00112233445600000000510107"
nr3="dd112233445500000000510107" nr3="dd112233445500000000510107"
@ -167,10 +174,6 @@ def test_rrm_neighbor_rep_req(dev, apdev):
raise Exception("Request succeeded unexpectedly (AP without RRM 2)") raise Exception("Request succeeded unexpectedly (AP without RRM 2)")
dev[0].request("DISCONNECT") dev[0].request("DISCONNECT")
rrm = int(dev[0].get_driver_status_field("capa.rrm_flags"), 16)
if rrm & 0x5 != 0x5 and rrm & 0x10 != 0x10:
raise HwsimSkip("Required RRM capabilities are not supported")
dev[0].connect("test2", key_mgmt="NONE", scan_freq="2412") dev[0].connect("test2", key_mgmt="NONE", scan_freq="2412")
if "OK" not in dev[0].request("NEIGHBOR_REP_REQUEST"): if "OK" not in dev[0].request("NEIGHBOR_REP_REQUEST"):
@ -255,10 +258,7 @@ def test_rrm_neighbor_rep_req(dev, apdev):
def test_rrm_lci_req(dev, apdev): def test_rrm_lci_req(dev, apdev):
"""hostapd lci request""" """hostapd lci request"""
check_rrm_support(dev[0])
rrm = int(dev[0].get_driver_status_field("capa.rrm_flags"), 16)
if rrm & 0x5 != 0x5 and rrm & 0x10 != 0x10:
raise HwsimSkip("Required RRM capabilities are not supported")
params = { "ssid": "rrm", "rrm_neighbor_report": "1" } params = { "ssid": "rrm", "rrm_neighbor_report": "1" }
hapd = hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
@ -291,9 +291,7 @@ def test_rrm_lci_req(dev, apdev):
def test_rrm_lci_req_oom(dev, apdev): def test_rrm_lci_req_oom(dev, apdev):
"""LCI report generation OOM""" """LCI report generation OOM"""
rrm = int(dev[0].get_driver_status_field("capa.rrm_flags"), 16) check_rrm_support(dev[0])
if rrm & 0x5 != 0x5 and rrm & 0x10 != 0x10:
raise HwsimSkip("Required RRM capabilities are not supported")
params = { "ssid": "rrm", "rrm_neighbor_report": "1" } params = { "ssid": "rrm", "rrm_neighbor_report": "1" }
hapd = hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
@ -316,16 +314,14 @@ def test_rrm_lci_req_oom(dev, apdev):
def test_rrm_neighbor_rep_req_from_conf(dev, apdev): def test_rrm_neighbor_rep_req_from_conf(dev, apdev):
"""wpa_supplicant ctrl_iface NEIGHBOR_REP_REQUEST and hostapd config""" """wpa_supplicant ctrl_iface NEIGHBOR_REP_REQUEST and hostapd config"""
check_rrm_support(dev[0])
params = { "ssid": "test2", "rrm_neighbor_report": "1", params = { "ssid": "test2", "rrm_neighbor_report": "1",
"stationary_ap": "1", "lci": lci, "civic": civic } "stationary_ap": "1", "lci": lci, "civic": civic }
hapd = hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
bssid = apdev[0]['bssid'] bssid = apdev[0]['bssid']
rrm = int(dev[0].get_driver_status_field("capa.rrm_flags"), 16)
if rrm & 0x5 != 0x5 and rrm & 0x10 != 0x10:
raise HwsimSkip("Required RRM capabilities are not supported")
dev[0].connect("test2", key_mgmt="NONE", scan_freq="2412") dev[0].connect("test2", key_mgmt="NONE", scan_freq="2412")
if "OK" not in dev[0].request("NEIGHBOR_REP_REQUEST"): if "OK" not in dev[0].request("NEIGHBOR_REP_REQUEST"):
@ -334,14 +330,12 @@ def test_rrm_neighbor_rep_req_from_conf(dev, apdev):
def test_rrm_neighbor_rep_req_timeout(dev, apdev): def test_rrm_neighbor_rep_req_timeout(dev, apdev):
"""wpa_supplicant behavior on NEIGHBOR_REP_REQUEST response timeout""" """wpa_supplicant behavior on NEIGHBOR_REP_REQUEST response timeout"""
check_rrm_support(dev[0])
params = { "ssid": "test2", "rrm_neighbor_report": "1", params = { "ssid": "test2", "rrm_neighbor_report": "1",
"stationary_ap": "1", "lci": lci, "civic": civic } "stationary_ap": "1", "lci": lci, "civic": civic }
hapd = hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
rrm = int(dev[0].get_driver_status_field("capa.rrm_flags"), 16)
if rrm & 0x5 != 0x5 and rrm & 0x10 != 0x10:
raise HwsimSkip("Required RRM capabilities are not supported")
dev[0].connect("test2", key_mgmt="NONE", scan_freq="2412") dev[0].connect("test2", key_mgmt="NONE", scan_freq="2412")
hapd.set("ext_mgmt_frame_handling", "1") hapd.set("ext_mgmt_frame_handling", "1")
@ -355,14 +349,12 @@ def test_rrm_neighbor_rep_req_timeout(dev, apdev):
def test_rrm_neighbor_rep_req_oom(dev, apdev): def test_rrm_neighbor_rep_req_oom(dev, apdev):
"""wpa_supplicant ctrl_iface NEIGHBOR_REP_REQUEST OOM""" """wpa_supplicant ctrl_iface NEIGHBOR_REP_REQUEST OOM"""
check_rrm_support(dev[0])
params = { "ssid": "test2", "rrm_neighbor_report": "1", params = { "ssid": "test2", "rrm_neighbor_report": "1",
"stationary_ap": "1", "lci": lci, "civic": civic } "stationary_ap": "1", "lci": lci, "civic": civic }
hapd = hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
rrm = int(dev[0].get_driver_status_field("capa.rrm_flags"), 16)
if rrm & 0x5 != 0x5 and rrm & 0x10 != 0x10:
raise HwsimSkip("Required RRM capabilities are not supported")
dev[0].connect("test2", key_mgmt="NONE", scan_freq="2412") dev[0].connect("test2", key_mgmt="NONE", scan_freq="2412")
with alloc_fail(dev[0], 1, "wpabuf_alloc;wpas_rrm_process_neighbor_rep"): with alloc_fail(dev[0], 1, "wpabuf_alloc;wpas_rrm_process_neighbor_rep"):
@ -382,14 +374,12 @@ def test_rrm_neighbor_rep_req_oom(dev, apdev):
def test_rrm_neighbor_rep_req_disconnect(dev, apdev): def test_rrm_neighbor_rep_req_disconnect(dev, apdev):
"""wpa_supplicant behavior on disconnection during NEIGHBOR_REP_REQUEST""" """wpa_supplicant behavior on disconnection during NEIGHBOR_REP_REQUEST"""
check_rrm_support(dev[0])
params = { "ssid": "test2", "rrm_neighbor_report": "1", params = { "ssid": "test2", "rrm_neighbor_report": "1",
"stationary_ap": "1", "lci": lci, "civic": civic } "stationary_ap": "1", "lci": lci, "civic": civic }
hapd = hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
rrm = int(dev[0].get_driver_status_field("capa.rrm_flags"), 16)
if rrm & 0x5 != 0x5 and rrm & 0x10 != 0x10:
raise HwsimSkip("Required RRM capabilities are not supported")
if "FAIL" not in dev[0].request("NEIGHBOR_REP_REQUEST"): if "FAIL" not in dev[0].request("NEIGHBOR_REP_REQUEST"):
raise Exception("Request accepted while disconnected") raise Exception("Request accepted while disconnected")
@ -407,13 +397,11 @@ def test_rrm_neighbor_rep_req_disconnect(dev, apdev):
def test_rrm_neighbor_rep_req_not_supported(dev, apdev): def test_rrm_neighbor_rep_req_not_supported(dev, apdev):
"""NEIGHBOR_REP_REQUEST for AP not supporting neighbor report""" """NEIGHBOR_REP_REQUEST for AP not supporting neighbor report"""
check_rrm_support(dev[0])
params = { "ssid": "test2", "rrm_beacon_report": "1" } params = { "ssid": "test2", "rrm_beacon_report": "1" }
hapd = hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
rrm = int(dev[0].get_driver_status_field("capa.rrm_flags"), 16)
if rrm & 0x5 != 0x5 and rrm & 0x10 != 0x10:
raise HwsimSkip("Required RRM capabilities are not supported")
dev[0].connect("test2", key_mgmt="NONE", scan_freq="2412") dev[0].connect("test2", key_mgmt="NONE", scan_freq="2412")
if "FAIL" not in dev[0].request("NEIGHBOR_REP_REQUEST"): if "FAIL" not in dev[0].request("NEIGHBOR_REP_REQUEST"):
@ -421,14 +409,12 @@ def test_rrm_neighbor_rep_req_not_supported(dev, apdev):
def test_rrm_neighbor_rep_req_busy(dev, apdev): def test_rrm_neighbor_rep_req_busy(dev, apdev):
"""wpa_supplicant and concurrent NEIGHBOR_REP_REQUEST commands""" """wpa_supplicant and concurrent NEIGHBOR_REP_REQUEST commands"""
check_rrm_support(dev[0])
params = { "ssid": "test2", "rrm_neighbor_report": "1", params = { "ssid": "test2", "rrm_neighbor_report": "1",
"stationary_ap": "1", "lci": lci, "civic": civic } "stationary_ap": "1", "lci": lci, "civic": civic }
hapd = hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
rrm = int(dev[0].get_driver_status_field("capa.rrm_flags"), 16)
if rrm & 0x5 != 0x5 and rrm & 0x10 != 0x10:
raise HwsimSkip("Required RRM capabilities are not supported")
dev[0].connect("test2", key_mgmt="NONE", scan_freq="2412") dev[0].connect("test2", key_mgmt="NONE", scan_freq="2412")
hapd.set("ext_mgmt_frame_handling", "1") hapd.set("ext_mgmt_frame_handling", "1")
@ -444,10 +430,7 @@ def test_rrm_neighbor_rep_req_busy(dev, apdev):
def test_rrm_ftm_range_req(dev, apdev): def test_rrm_ftm_range_req(dev, apdev):
"""hostapd FTM range request command""" """hostapd FTM range request command"""
check_rrm_support(dev[0])
rrm = int(dev[0].get_driver_status_field("capa.rrm_flags"), 16)
if rrm & 0x5 != 0x5 and rrm & 0x10 != 0x10:
raise HwsimSkip("Required RRM capabilities are not supported")
params = { "ssid": "rrm", "rrm_neighbor_report": "1" } params = { "ssid": "rrm", "rrm_neighbor_report": "1" }
hapd = hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)