tests: Optimize ap_qosmap test cases

Avoid unnecessary DATA_TEST_CONFIG calls and wlantest_cli invocations to
speed up the test cases. This drops ap_qosmap execution time from about
14 seconds to under 3 seconds.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2014-12-23 17:46:34 +02:00
parent 4905f1ebfe
commit 6d930a1eef
2 changed files with 76 additions and 57 deletions

View file

@ -13,7 +13,7 @@ logger = logging.getLogger()
from wpasupplicant import WpaSupplicant from wpasupplicant import WpaSupplicant
def run_connectivity_test(dev1, dev2, tos, dev1group=False, dev2group=False, def run_connectivity_test(dev1, dev2, tos, dev1group=False, dev2group=False,
ifname1=None, ifname2=None): ifname1=None, ifname2=None, config=True):
addr1 = dev1.own_addr() addr1 = dev1.own_addr()
if not dev1group and isinstance(dev1, WpaSupplicant): if not dev1group and isinstance(dev1, WpaSupplicant):
addr1 = dev1.get_driver_status_field('addr') addr1 = dev1.get_driver_status_field('addr')
@ -26,25 +26,26 @@ def run_connectivity_test(dev1, dev2, tos, dev1group=False, dev2group=False,
dev2.dump_monitor() dev2.dump_monitor()
try: try:
cmd = "DATA_TEST_CONFIG 1" if config:
if ifname1: cmd = "DATA_TEST_CONFIG 1"
cmd = cmd + " ifname=" + ifname1 if ifname1:
if dev1group: cmd = cmd + " ifname=" + ifname1
res = dev1.group_request(cmd) if dev1group:
else: res = dev1.group_request(cmd)
res = dev1.request(cmd) else:
if "OK" not in res: res = dev1.request(cmd)
raise Exception("Failed to enable data test functionality") if "OK" not in res:
raise Exception("Failed to enable data test functionality")
cmd = "DATA_TEST_CONFIG 1" cmd = "DATA_TEST_CONFIG 1"
if ifname2: if ifname2:
cmd = cmd + " ifname=" + ifname2 cmd = cmd + " ifname=" + ifname2
if dev2group: if dev2group:
res = dev2.group_request(cmd) res = dev2.group_request(cmd)
else: else:
res = dev2.request(cmd) res = dev2.request(cmd)
if "OK" not in res: if "OK" not in res:
raise Exception("Failed to enable data test functionality") raise Exception("Failed to enable data test functionality")
cmd = "DATA_TEST_TX {} {} {}".format(addr2, addr1, tos) cmd = "DATA_TEST_TX {} {} {}".format(addr2, addr1, tos)
if dev1group: if dev1group:
@ -102,18 +103,19 @@ def run_connectivity_test(dev1, dev2, tos, dev1group=False, dev2group=False,
if "DATA-TEST-RX ff:ff:ff:ff:ff:ff {}".format(addr2) not in ev: if "DATA-TEST-RX ff:ff:ff:ff:ff:ff {}".format(addr2) not in ev:
raise Exception("Unexpected dev2->dev1 broadcast data result") raise Exception("Unexpected dev2->dev1 broadcast data result")
finally: finally:
if dev1group: if config:
dev1.group_request("DATA_TEST_CONFIG 0") if dev1group:
else: dev1.group_request("DATA_TEST_CONFIG 0")
dev1.request("DATA_TEST_CONFIG 0") else:
if dev2group: dev1.request("DATA_TEST_CONFIG 0")
dev2.group_request("DATA_TEST_CONFIG 0") if dev2group:
else: dev2.group_request("DATA_TEST_CONFIG 0")
dev2.request("DATA_TEST_CONFIG 0") else:
dev2.request("DATA_TEST_CONFIG 0")
def test_connectivity(dev1, dev2, dscp=None, tos=None, max_tries=1, def test_connectivity(dev1, dev2, dscp=None, tos=None, max_tries=1,
dev1group=False, dev2group=False, dev1group=False, dev2group=False,
ifname1=None, ifname2=None): ifname1=None, ifname2=None, config=True):
if dscp: if dscp:
tos = dscp << 2 tos = dscp << 2
if not tos: if not tos:
@ -124,7 +126,7 @@ def test_connectivity(dev1, dev2, dscp=None, tos=None, max_tries=1,
for i in range(0, max_tries): for i in range(0, max_tries):
try: try:
run_connectivity_test(dev1, dev2, tos, dev1group, dev2group, run_connectivity_test(dev1, dev2, tos, dev1group, dev2group,
ifname1, ifname2) ifname1, ifname2, config=config)
success = True success = True
break break
except Exception, e: except Exception, e:

View file

@ -13,20 +13,22 @@ import hwsim_utils
import hostapd import hostapd
from wlantest import Wlantest from wlantest import Wlantest
def check_qos_map(ap, hapd, dev, dscp, tid, ap_tid=None): def check_qos_map(ap, hapd, dev, sta, dscp, tid, ap_tid=None):
if not ap_tid: if not ap_tid:
ap_tid = tid ap_tid = tid
bssid = ap['bssid'] bssid = ap['bssid']
sta = dev.p2p_interface_addr()
wt = Wlantest() wt = Wlantest()
wt.clear_sta_counters(bssid, sta) wt.clear_sta_counters(bssid, sta)
hwsim_utils.test_connectivity(dev, hapd, dscp=dscp) hwsim_utils.test_connectivity(dev, hapd, dscp=dscp, config=False)
time.sleep(0.02) time.sleep(0.02)
[ tx, rx ] = wt.get_tid_counters(bssid, sta) tx = wt.get_tx_tid(bssid, sta, tid)
if tx[tid] == 0: if tx == 0:
[ tx, rx ] = wt.get_tid_counters(bssid, sta)
logger.info("Expected TX DSCP " + str(dscp) + " with TID " + str(tid) + " but counters: " + str(tx)) logger.info("Expected TX DSCP " + str(dscp) + " with TID " + str(tid) + " but counters: " + str(tx))
raise Exception("No STA->AP data frame using the expected TID") raise Exception("No STA->AP data frame using the expected TID")
if rx[ap_tid] == 0: rx = wt.get_rx_tid(bssid, sta, ap_tid)
if rx == 0:
[ tx, rx ] = wt.get_tid_counters(bssid, sta)
logger.info("Expected RX DSCP " + str(dscp) + " with TID " + str(ap_tid) + " but counters: " + str(rx)) logger.info("Expected RX DSCP " + str(dscp) + " with TID " + str(ap_tid) + " but counters: " + str(rx))
raise Exception("No AP->STA data frame using the expected TID") raise Exception("No AP->STA data frame using the expected TID")
@ -41,28 +43,33 @@ def test_ap_qosmap(dev, apdev):
hapd = hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412") dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
time.sleep(0.1) time.sleep(0.1)
check_qos_map(apdev[0], hapd, dev[0], 53, 2) addr = dev[0].p2p_interface_addr()
check_qos_map(apdev[0], hapd, dev[0], 22, 6) dev[0].request("DATA_TEST_CONFIG 1")
check_qos_map(apdev[0], hapd, dev[0], 8, 0) hapd.request("DATA_TEST_CONFIG 1")
check_qos_map(apdev[0], hapd, dev[0], 15, 0) check_qos_map(apdev[0], hapd, dev[0], addr, 53, 2)
check_qos_map(apdev[0], hapd, dev[0], 0, 1) check_qos_map(apdev[0], hapd, dev[0], addr, 22, 6)
check_qos_map(apdev[0], hapd, dev[0], 7, 1) check_qos_map(apdev[0], hapd, dev[0], addr, 8, 0)
check_qos_map(apdev[0], hapd, dev[0], 16, 3) check_qos_map(apdev[0], hapd, dev[0], addr, 15, 0)
check_qos_map(apdev[0], hapd, dev[0], 31, 3) check_qos_map(apdev[0], hapd, dev[0], addr, 0, 1)
check_qos_map(apdev[0], hapd, dev[0], 32, 4) check_qos_map(apdev[0], hapd, dev[0], addr, 7, 1)
check_qos_map(apdev[0], hapd, dev[0], 39, 4) check_qos_map(apdev[0], hapd, dev[0], addr, 16, 3)
check_qos_map(apdev[0], hapd, dev[0], 40, 6) check_qos_map(apdev[0], hapd, dev[0], addr, 31, 3)
check_qos_map(apdev[0], hapd, dev[0], 47, 6) check_qos_map(apdev[0], hapd, dev[0], addr, 32, 4)
check_qos_map(apdev[0], hapd, dev[0], 48, 7) check_qos_map(apdev[0], hapd, dev[0], addr, 39, 4)
check_qos_map(apdev[0], hapd, dev[0], 55, 7) check_qos_map(apdev[0], hapd, dev[0], addr, 40, 6)
check_qos_map(apdev[0], hapd, dev[0], addr, 47, 6)
check_qos_map(apdev[0], hapd, dev[0], addr, 48, 7)
check_qos_map(apdev[0], hapd, dev[0], addr, 55, 7)
hapd.request("SET_QOS_MAP_SET 22,6,8,15,0,7,255,255,16,31,32,39,255,255,40,47,48,55") hapd.request("SET_QOS_MAP_SET 22,6,8,15,0,7,255,255,16,31,32,39,255,255,40,47,48,55")
hapd.request("SEND_QOS_MAP_CONF " + dev[0].get_status_field("address")) hapd.request("SEND_QOS_MAP_CONF " + dev[0].get_status_field("address"))
check_qos_map(apdev[0], hapd, dev[0], 53, 7) check_qos_map(apdev[0], hapd, dev[0], addr, 53, 7)
check_qos_map(apdev[0], hapd, dev[0], 22, 6) check_qos_map(apdev[0], hapd, dev[0], addr, 22, 6)
check_qos_map(apdev[0], hapd, dev[0], 48, 7) check_qos_map(apdev[0], hapd, dev[0], addr, 48, 7)
check_qos_map(apdev[0], hapd, dev[0], 55, 7) check_qos_map(apdev[0], hapd, dev[0], addr, 55, 7)
check_qos_map(apdev[0], hapd, dev[0], 56, 56 >> 3) check_qos_map(apdev[0], hapd, dev[0], addr, 56, 56 >> 3)
check_qos_map(apdev[0], hapd, dev[0], 63, 63 >> 3) check_qos_map(apdev[0], hapd, dev[0], addr, 63, 63 >> 3)
dev[0].request("DATA_TEST_CONFIG 0")
hapd.request("DATA_TEST_CONFIG 0")
def test_ap_qosmap_default(dev, apdev): def test_ap_qosmap_default(dev, apdev):
"""QoS mapping with default values""" """QoS mapping with default values"""
@ -70,8 +77,13 @@ def test_ap_qosmap_default(dev, apdev):
params = { "ssid": ssid } params = { "ssid": ssid }
hapd = hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412") dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
addr = dev[0].p2p_interface_addr()
dev[0].request("DATA_TEST_CONFIG 1")
hapd.request("DATA_TEST_CONFIG 1")
for dscp in [ 0, 7, 8, 15, 16, 23, 24, 31, 32, 39, 40, 47, 48, 55, 56, 63]: for dscp in [ 0, 7, 8, 15, 16, 23, 24, 31, 32, 39, 40, 47, 48, 55, 56, 63]:
check_qos_map(apdev[0], hapd, dev[0], dscp, dscp >> 3) check_qos_map(apdev[0], hapd, dev[0], addr, dscp, dscp >> 3)
dev[0].request("DATA_TEST_CONFIG 0")
hapd.request("DATA_TEST_CONFIG 0")
def test_ap_qosmap_default_acm(dev, apdev): def test_ap_qosmap_default_acm(dev, apdev):
"""QoS mapping with default values and ACM=1 for VO/VI""" """QoS mapping with default values and ACM=1 for VO/VI"""
@ -99,13 +111,18 @@ def test_ap_qosmap_default_acm(dev, apdev):
"wmm_ac_vo_acm": "1" } "wmm_ac_vo_acm": "1" }
hapd = hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412") dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
addr = dev[0].p2p_interface_addr()
dev[0].request("DATA_TEST_CONFIG 1")
hapd.request("DATA_TEST_CONFIG 1")
for dscp in [ 0, 7, 8, 15, 16, 23, 24, 31, 32, 39, 40, 47, 48, 55, 56, 63]: for dscp in [ 0, 7, 8, 15, 16, 23, 24, 31, 32, 39, 40, 47, 48, 55, 56, 63]:
ap_tid = dscp >> 3 ap_tid = dscp >> 3
tid = ap_tid tid = ap_tid
# downgrade VI/VO to BE # downgrade VI/VO to BE
if tid in [ 4, 5, 6, 7 ]: if tid in [ 4, 5, 6, 7 ]:
tid = 3 tid = 3
check_qos_map(apdev[0], hapd, dev[0], dscp, tid, ap_tid) check_qos_map(apdev[0], hapd, dev[0], addr, dscp, tid, ap_tid)
dev[0].request("DATA_TEST_CONFIG 0")
hapd.request("DATA_TEST_CONFIG 0")
def test_ap_qosmap_invalid(dev, apdev): def test_ap_qosmap_invalid(dev, apdev):
"""QoS mapping ctrl_iface error handling""" """QoS mapping ctrl_iface error handling"""