tests: Replace HostapdGlobal() + remove() with hostapd.remove_bss()

This can be used to work with remote hosts.

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
This commit is contained in:
Janusz Dziedzic 2016-04-07 07:38:05 +02:00 committed by Jouni Malinen
parent b29c46beb9
commit 1728a2e73c
6 changed files with 17 additions and 25 deletions

View file

@ -18,8 +18,7 @@ def force_prev_ap_on_24g(ap):
# sufficient survey data from mac80211_hwsim. # sufficient survey data from mac80211_hwsim.
hostapd.add_ap(ap, { "ssid": "open" }) hostapd.add_ap(ap, { "ssid": "open" })
time.sleep(0.1) time.sleep(0.1)
hapd_global = hostapd.HostapdGlobal() hostapd.remove_bss(ap)
hapd_global.remove(ap['ifname'])
def force_prev_ap_on_5g(ap): def force_prev_ap_on_5g(ap):
# For now, make sure the last operating channel was on 5 GHz band to get # For now, make sure the last operating channel was on 5 GHz band to get
@ -27,8 +26,7 @@ def force_prev_ap_on_5g(ap):
hostapd.add_ap(ap, { "ssid": "open", "hw_mode": "a", hostapd.add_ap(ap, { "ssid": "open", "hw_mode": "a",
"channel": "36", "country_code": "US" }) "channel": "36", "country_code": "US" })
time.sleep(0.1) time.sleep(0.1)
hapd_global = hostapd.HostapdGlobal() hostapd.remove_bss(ap)
hapd_global.remove(ap['ifname'])
def wait_acs(hapd): def wait_acs(hapd):
ev = hapd.wait_event(["ACS-STARTED", "ACS-COMPLETED", "ACS-FAILED", ev = hapd.wait_event(["ACS-STARTED", "ACS-COMPLETED", "ACS-FAILED",

View file

@ -8,43 +8,41 @@ import hostapd
def test_ap_config_errors(dev, apdev): def test_ap_config_errors(dev, apdev):
"""Various hostapd configuration errors""" """Various hostapd configuration errors"""
hapd_global = hostapd.HostapdGlobal()
ifname = apdev[0]['ifname']
# IEEE 802.11d without country code # IEEE 802.11d without country code
params = { "ssid": "foo", "ieee80211d": "1" } params = { "ssid": "foo", "ieee80211d": "1" }
hapd = hostapd.add_ap(apdev[0], params, no_enable=True) hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
if "FAIL" not in hapd.request("ENABLE"): if "FAIL" not in hapd.request("ENABLE"):
raise Exception("Unexpected ENABLE success (ieee80211d without country_code)") raise Exception("Unexpected ENABLE success (ieee80211d without country_code)")
hapd_global.remove(ifname) hostapd.remove_bss(apdev[0])
# IEEE 802.11h without IEEE 802.11d # IEEE 802.11h without IEEE 802.11d
params = { "ssid": "foo", "ieee80211h": "1" } params = { "ssid": "foo", "ieee80211h": "1" }
hapd = hostapd.add_ap(apdev[0], params, no_enable=True) hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
if "FAIL" not in hapd.request("ENABLE"): if "FAIL" not in hapd.request("ENABLE"):
raise Exception("Unexpected ENABLE success (ieee80211h without ieee80211d") raise Exception("Unexpected ENABLE success (ieee80211h without ieee80211d")
hapd_global.remove(ifname) hostapd.remove_bss(apdev[0])
# Power Constraint without IEEE 802.11d # Power Constraint without IEEE 802.11d
params = { "ssid": "foo", "local_pwr_constraint": "1" } params = { "ssid": "foo", "local_pwr_constraint": "1" }
hapd = hostapd.add_ap(apdev[0], params, no_enable=True) hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
if "FAIL" not in hapd.request("ENABLE"): if "FAIL" not in hapd.request("ENABLE"):
raise Exception("Unexpected ENABLE success (local_pwr_constraint without ieee80211d)") raise Exception("Unexpected ENABLE success (local_pwr_constraint without ieee80211d)")
hapd_global.remove(ifname) hostapd.remove_bss(apdev[0])
# Spectrum management without Power Constraint # Spectrum management without Power Constraint
params = { "ssid": "foo", "spectrum_mgmt_required": "1" } params = { "ssid": "foo", "spectrum_mgmt_required": "1" }
hapd = hostapd.add_ap(apdev[0], params, no_enable=True) hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
if "FAIL" not in hapd.request("ENABLE"): if "FAIL" not in hapd.request("ENABLE"):
raise Exception("Unexpected ENABLE success (spectrum_mgmt_required without local_pwr_constraint)") raise Exception("Unexpected ENABLE success (spectrum_mgmt_required without local_pwr_constraint)")
hapd_global.remove(ifname) hostapd.remove_bss(apdev[0])
# IEEE 802.1X without authentication server # IEEE 802.1X without authentication server
params = { "ssid": "foo", "ieee8021x": "1" } params = { "ssid": "foo", "ieee8021x": "1" }
hapd = hostapd.add_ap(apdev[0], params, no_enable=True) hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
if "FAIL" not in hapd.request("ENABLE"): if "FAIL" not in hapd.request("ENABLE"):
raise Exception("Unexpected ENABLE success (ieee8021x)") raise Exception("Unexpected ENABLE success (ieee8021x)")
hapd_global.remove(ifname) hostapd.remove_bss(apdev[0])
# RADIUS-PSK without macaddr_acl=2 # RADIUS-PSK without macaddr_acl=2
params = hostapd.wpa2_params(ssid="foo", passphrase="12345678") params = hostapd.wpa2_params(ssid="foo", passphrase="12345678")
@ -52,7 +50,7 @@ def test_ap_config_errors(dev, apdev):
hapd = hostapd.add_ap(apdev[0], params, no_enable=True) hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
if "FAIL" not in hapd.request("ENABLE"): if "FAIL" not in hapd.request("ENABLE"):
raise Exception("Unexpected ENABLE success (wpa_psk_radius)") raise Exception("Unexpected ENABLE success (wpa_psk_radius)")
hapd_global.remove(ifname) hostapd.remove_bss(apdev[0])
# FT without NAS-Identifier # FT without NAS-Identifier
params = { "wpa": "2", params = { "wpa": "2",
@ -62,7 +60,7 @@ def test_ap_config_errors(dev, apdev):
hapd = hostapd.add_ap(apdev[0], params, no_enable=True) hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
if "FAIL" not in hapd.request("ENABLE"): if "FAIL" not in hapd.request("ENABLE"):
raise Exception("Unexpected ENABLE success (FT without nas_identifier)") raise Exception("Unexpected ENABLE success (FT without nas_identifier)")
hapd_global.remove(ifname) hostapd.remove_bss(apdev[0])
# Hotspot 2.0 without WPA2/CCMP # Hotspot 2.0 without WPA2/CCMP
params = hostapd.wpa2_params(ssid="foo") params = hostapd.wpa2_params(ssid="foo")
@ -77,4 +75,4 @@ def test_ap_config_errors(dev, apdev):
hapd = hostapd.add_ap(apdev[0], params, no_enable=True) hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
if "FAIL" not in hapd.request("ENABLE"): if "FAIL" not in hapd.request("ENABLE"):
raise Exception("Unexpected ENABLE success (HS 2.0 without WPA2/CCMP)") raise Exception("Unexpected ENABLE success (HS 2.0 without WPA2/CCMP)")
hapd_global.remove(ifname) hostapd.remove_bss(apdev[0])

View file

@ -351,7 +351,6 @@ def test_ap_bss_add_many(dev, apdev):
def _test_ap_bss_add_many(dev, apdev): def _test_ap_bss_add_many(dev, apdev):
ifname = apdev[0]['ifname'] ifname = apdev[0]['ifname']
hostapd.add_bss(apdev[0], ifname, 'bss-1.conf') hostapd.add_bss(apdev[0], ifname, 'bss-1.conf')
hapd = hostapd.HostapdGlobal()
fname = '/tmp/hwsim-bss.conf' fname = '/tmp/hwsim-bss.conf'
for i in range(16): for i in range(16):
ifname2 = ifname + '-' + str(i) ifname2 = ifname + '-' + str(i)
@ -376,7 +375,7 @@ def _test_ap_bss_add_many(dev, apdev):
dev[0].request("DISCONNECT") dev[0].request("DISCONNECT")
dev[0].wait_disconnected(timeout=5) dev[0].wait_disconnected(timeout=5)
ifname2 = ifname + '-' + str(i) ifname2 = ifname + '-' + str(i)
hapd.remove(ifname2) hostapd.remove_bss(apdev[0], ifname2)
def test_ap_bss_add_reuse_existing(dev, apdev): def test_ap_bss_add_reuse_existing(dev, apdev):
"""Dynamic BSS add operation reusing existing interface""" """Dynamic BSS add operation reusing existing interface"""

View file

@ -683,8 +683,7 @@ def test_olbc(dev, apdev):
if status['olbc'] != '1' or status['olbc_ht'] != '1': if status['olbc'] != '1' or status['olbc_ht'] != '1':
raise Exception("Missing OLBC information") raise Exception("Missing OLBC information")
hapd_global = hostapd.HostapdGlobal() hostapd.remove_bss(apdev[1])
hapd_global.remove(apdev[1]['ifname'])
logger.info("Waiting for OLBC state to time out") logger.info("Waiting for OLBC state to time out")
cleared = False cleared = False

View file

@ -13,7 +13,6 @@ from utils import HwsimSkip
def hostapd_oom_loop(apdev, params, start_func="main"): def hostapd_oom_loop(apdev, params, start_func="main"):
hapd = hostapd.add_ap(apdev[0], { "ssid": "ctrl" }) hapd = hostapd.add_ap(apdev[0], { "ssid": "ctrl" })
hapd_global = hostapd.HostapdGlobal()
count = 0 count = 0
for i in range(1, 1000): for i in range(1, 1000):
@ -22,7 +21,7 @@ def hostapd_oom_loop(apdev, params, start_func="main"):
try: try:
hostapd.add_ap(apdev[1], params, timeout=2.5) hostapd.add_ap(apdev[1], params, timeout=2.5)
logger.info("Iteration %d - success" % i) logger.info("Iteration %d - success" % i)
hapd_global.remove(apdev[1]['ifname']) hostapd.remove_bss(apdev[1])
state = hapd.request('GET_ALLOC_FAIL') state = hapd.request('GET_ALLOC_FAIL')
logger.info("GET_ALLOC_FAIL: " + state) logger.info("GET_ALLOC_FAIL: " + state)

View file

@ -605,9 +605,8 @@ def test_go_neg_two_peers(dev):
if "status=5" not in ev: if "status=5" not in ev:
raise Exception("Unexpected status code in rejection: " + ev) raise Exception("Unexpected status code in rejection: " + ev)
def clear_pbc_overlap(dev, ifname): def clear_pbc_overlap(dev, ap):
hapd_global = hostapd.HostapdGlobal() hostapd.remove_bss(ap)
hapd_global.remove(ifname)
dev[0].request("P2P_CANCEL") dev[0].request("P2P_CANCEL")
dev[1].request("P2P_CANCEL") dev[1].request("P2P_CANCEL")
dev[0].p2p_stop_find() dev[0].p2p_stop_find()
@ -654,7 +653,7 @@ def test_grpform_pbc_overlap(dev, apdev):
if ev is None: if ev is None:
raise Exception("PBC overlap not reported") raise Exception("PBC overlap not reported")
clear_pbc_overlap(dev, apdev[0]['ifname']) clear_pbc_overlap(dev, apdev[0])
def test_grpform_pbc_overlap_group_iface(dev, apdev): def test_grpform_pbc_overlap_group_iface(dev, apdev):
"""P2P group formation during PBC overlap using group interfaces""" """P2P group formation during PBC overlap using group interfaces"""
@ -692,7 +691,7 @@ def test_grpform_pbc_overlap_group_iface(dev, apdev):
# the group interface. # the group interface.
logger.info("PBC overlap not reported") logger.info("PBC overlap not reported")
clear_pbc_overlap(dev, apdev[0]['ifname']) clear_pbc_overlap(dev, apdev[0])
def test_grpform_goneg_fail_with_group_iface(dev): def test_grpform_goneg_fail_with_group_iface(dev):
"""P2P group formation fails while using group interface""" """P2P group formation fails while using group interface"""