tests: Fix multi_check() for remote testing

Don't use hardcoded BSSID; instead use the real BSSID from the device.

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@gmail.com>
This commit is contained in:
Janusz Dziedzic 2020-01-12 23:02:25 +01:00 committed by Jouni Malinen
parent ba1ff57ad2
commit e206c93f31

View file

@ -37,7 +37,7 @@ def test_ap_change_ssid(dev, apdev):
dev[0].set_network_quoted(id, "ssid", "test-wpa2-psk-new")
dev[0].connect_network(id)
def multi_check(dev, check, scan_opt=True):
def multi_check(apdev, dev, check, scan_opt=True):
id = []
num_bss = len(check)
for i in range(0, num_bss):
@ -51,7 +51,7 @@ def multi_check(dev, check, scan_opt=True):
for i in range(num_bss):
if not check[i]:
continue
bssid = '02:00:00:00:03:0' + str(i)
bssid = hostapd.bssid_inc(apdev, i)
if scan_opt:
dev[i].scan_for_bss(bssid, freq=2412)
id.append(dev[i].connect("bss-" + str(i + 1), key_mgmt="NONE",
@ -98,59 +98,59 @@ def _test_ap_bss_add_remove(dev, apdev):
ifname3 = apdev[0]['ifname'] + '-3'
logger.info("Set up three BSSes one by one")
hostapd.add_bss(apdev[0], ifname1, 'bss-1.conf')
multi_check(dev, [True, False, False])
multi_check(apdev[0], dev, [True, False, False])
hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf')
multi_check(dev, [True, True, False])
multi_check(apdev[0], dev, [True, True, False])
hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf')
multi_check(dev, [True, True, True])
multi_check(apdev[0], dev, [True, True, True])
logger.info("Remove the last BSS and re-add it")
hostapd.remove_bss(apdev[0], ifname3)
multi_check(dev, [True, True, False])
multi_check(apdev[0], dev, [True, True, False])
hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf')
multi_check(dev, [True, True, True])
multi_check(apdev[0], dev, [True, True, True])
logger.info("Remove the middle BSS and re-add it")
hostapd.remove_bss(apdev[0], ifname2)
multi_check(dev, [True, False, True])
multi_check(apdev[0], dev, [True, False, True])
hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf')
multi_check(dev, [True, True, True])
multi_check(apdev[0], dev, [True, True, True])
logger.info("Remove the first BSS and re-add it and other BSSs")
hostapd.remove_bss(apdev[0], ifname1)
multi_check(dev, [False, False, False])
multi_check(apdev[0], dev, [False, False, False])
hostapd.add_bss(apdev[0], ifname1, 'bss-1.conf')
hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf')
hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf')
multi_check(dev, [True, True, True])
multi_check(apdev[0], dev, [True, True, True])
logger.info("Remove two BSSes and re-add them")
hostapd.remove_bss(apdev[0], ifname2)
multi_check(dev, [True, False, True])
multi_check(apdev[0], dev, [True, False, True])
hostapd.remove_bss(apdev[0], ifname3)
multi_check(dev, [True, False, False])
multi_check(apdev[0], dev, [True, False, False])
hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf')
multi_check(dev, [True, True, False])
multi_check(apdev[0], dev, [True, True, False])
hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf')
multi_check(dev, [True, True, True])
multi_check(apdev[0], dev, [True, True, True])
logger.info("Remove three BSSes in and re-add them")
hostapd.remove_bss(apdev[0], ifname3)
multi_check(dev, [True, True, False])
multi_check(apdev[0], dev, [True, True, False])
hostapd.remove_bss(apdev[0], ifname2)
multi_check(dev, [True, False, False])
multi_check(apdev[0], dev, [True, False, False])
hostapd.remove_bss(apdev[0], ifname1)
multi_check(dev, [False, False, False])
multi_check(apdev[0], dev, [False, False, False])
hostapd.add_bss(apdev[0], ifname1, 'bss-1.conf')
multi_check(dev, [True, False, False])
multi_check(apdev[0], dev, [True, False, False])
hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf')
multi_check(dev, [True, True, False])
multi_check(apdev[0], dev, [True, True, False])
hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf')
multi_check(dev, [True, True, True])
multi_check(apdev[0], dev, [True, True, True])
logger.info("Test error handling if a duplicate ifname is tried")
hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf', ignore_error=True)
multi_check(dev, [True, True, True])
multi_check(apdev[0], dev, [True, True, True])
def test_ap_bss_add_remove_during_ht_scan(dev, apdev):
"""Dynamic BSS add during HT40 co-ex scan"""
@ -160,20 +160,20 @@ def test_ap_bss_add_remove_during_ht_scan(dev, apdev):
ifname2 = apdev[0]['ifname'] + '-2'
hostapd.add_bss(apdev[0], ifname1, 'bss-ht40-1.conf')
hostapd.add_bss(apdev[0], ifname2, 'bss-ht40-2.conf')
multi_check(dev, [True, True], scan_opt=False)
multi_check(apdev[0], dev, [True, True], scan_opt=False)
hostapd.remove_bss(apdev[0], ifname2)
hostapd.remove_bss(apdev[0], ifname1)
hostapd.add_bss(apdev[0], ifname1, 'bss-ht40-1.conf')
hostapd.add_bss(apdev[0], ifname2, 'bss-ht40-2.conf')
hostapd.remove_bss(apdev[0], ifname2)
multi_check(dev, [True, False], scan_opt=False)
multi_check(apdev[0], dev, [True, False], scan_opt=False)
hostapd.remove_bss(apdev[0], ifname1)
hostapd.add_bss(apdev[0], ifname1, 'bss-ht40-1.conf')
hostapd.add_bss(apdev[0], ifname2, 'bss-ht40-2.conf')
hostapd.remove_bss(apdev[0], ifname1)
multi_check(dev, [False, False])
multi_check(apdev[0], dev, [False, False])
def test_ap_multi_bss_config(dev, apdev):
"""hostapd start with a multi-BSS configuration file"""
@ -185,18 +185,18 @@ def test_ap_multi_bss_config(dev, apdev):
logger.info("Set up three BSSes with one configuration file")
hapd = hostapd.add_iface(apdev[0], 'multi-bss.conf')
hapd.enable()
multi_check(dev, [True, True, True])
multi_check(apdev[0], dev, [True, True, True])
hostapd.remove_bss(apdev[0], ifname2)
multi_check(dev, [True, False, True])
multi_check(apdev[0], dev, [True, False, True])
hostapd.remove_bss(apdev[0], ifname3)
multi_check(dev, [True, False, False])
multi_check(apdev[0], dev, [True, False, False])
hostapd.remove_bss(apdev[0], ifname1)
multi_check(dev, [False, False, False])
multi_check(apdev[0], dev, [False, False, False])
hapd = hostapd.add_iface(apdev[0], 'multi-bss.conf')
hapd.enable()
hostapd.remove_bss(apdev[0], ifname1)
multi_check(dev, [False, False, False])
multi_check(apdev[0], dev, [False, False, False])
def invalid_ap(ap):
logger.info("Trying to start AP " + ap['ifname'] + " with invalid configuration")
@ -507,7 +507,7 @@ def test_ap_bss_config_file(dev, apdev, params):
res = subprocess.check_call(cmd)
if res != 0:
raise Exception("Could not start hostapd: %s" % str(res))
multi_check(dev, [True, True, True])
multi_check(apdev[0], dev, [True, True, True])
for i in range(0, 3):
dev[i].request("DISCONNECT")