Pass apdev to HostapdGlobal() or just use hostapd.remove_bss(apdev) while we would like to work correctly with remote hosts. Signed-off-by: Janusz Dziedzic <janusz.dziedzic@xxxxxxxxx> --- tests/hwsim/test_ap_acs.py | 6 ++--- tests/hwsim/test_ap_config.py | 18 ++++++------- tests/hwsim/test_ap_dynamic.py | 59 +++++++++++++---------------------------- tests/hwsim/test_ap_hs20.py | 4 +-- tests/hwsim/test_ap_ht.py | 3 +-- tests/hwsim/test_ap_psk.py | 7 +---- tests/hwsim/test_ap_wps.py | 9 +++---- tests/hwsim/test_dfs.py | 10 ++----- tests/hwsim/test_hapd_ctrl.py | 2 +- tests/hwsim/test_hostapd_oom.py | 3 +-- tests/hwsim/test_p2p_grpform.py | 9 +++---- tests/hwsim/test_pmksa_cache.py | 4 +-- tests/hwsim/test_rfkill.py | 2 +- 13 files changed, 47 insertions(+), 89 deletions(-) diff --git a/tests/hwsim/test_ap_acs.py b/tests/hwsim/test_ap_acs.py index 8f1f492..05e1ad1 100644 --- a/tests/hwsim/test_ap_acs.py +++ b/tests/hwsim/test_ap_acs.py @@ -18,8 +18,7 @@ def force_prev_ap_on_24g(ap): # sufficient survey data from mac80211_hwsim. hostapd.add_ap(ap, { "ssid": "open" }) time.sleep(0.1) - hapd_global = hostapd.HostapdGlobal() - hapd_global.remove(ap['ifname']) + hostapd.remove_bss(ap) def force_prev_ap_on_5g(ap): # 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", "channel": "36", "country_code": "US" }) time.sleep(0.1) - hapd_global = hostapd.HostapdGlobal() - hapd_global.remove(ap['ifname']) + hostapd.remove_bss(ap) def wait_acs(hapd): ev = hapd.wait_event(["ACS-STARTED", "ACS-COMPLETED", "ACS-FAILED", diff --git a/tests/hwsim/test_ap_config.py b/tests/hwsim/test_ap_config.py index 18ab5c2..9bb5db9 100644 --- a/tests/hwsim/test_ap_config.py +++ b/tests/hwsim/test_ap_config.py @@ -8,43 +8,41 @@ import hostapd def test_ap_config_errors(dev, apdev): """Various hostapd configuration errors""" - hapd_global = hostapd.HostapdGlobal() - ifname = apdev[0]['ifname'] # IEEE 802.11d without country code params = { "ssid": "foo", "ieee80211d": "1" } hapd = hostapd.add_ap(apdev[0], params, no_enable=True) if "FAIL" not in hapd.request("ENABLE"): 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 params = { "ssid": "foo", "ieee80211h": "1" } hapd = hostapd.add_ap(apdev[0], params, no_enable=True) if "FAIL" not in hapd.request("ENABLE"): raise Exception("Unexpected ENABLE success (ieee80211h without ieee80211d") - hapd_global.remove(ifname) + hostapd.remove_bss(apdev[0]) # Power Constraint without IEEE 802.11d params = { "ssid": "foo", "local_pwr_constraint": "1" } hapd = hostapd.add_ap(apdev[0], params, no_enable=True) if "FAIL" not in hapd.request("ENABLE"): raise Exception("Unexpected ENABLE success (local_pwr_constraint without ieee80211d)") - hapd_global.remove(ifname) + hostapd.remove_bss(apdev[0]) # Spectrum management without Power Constraint params = { "ssid": "foo", "spectrum_mgmt_required": "1" } hapd = hostapd.add_ap(apdev[0], params, no_enable=True) if "FAIL" not in hapd.request("ENABLE"): 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 params = { "ssid": "foo", "ieee8021x": "1" } hapd = hostapd.add_ap(apdev[0], params, no_enable=True) if "FAIL" not in hapd.request("ENABLE"): raise Exception("Unexpected ENABLE success (ieee8021x)") - hapd_global.remove(ifname) + hostapd.remove_bss(apdev[0]) # RADIUS-PSK without macaddr_acl=2 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) if "FAIL" not in hapd.request("ENABLE"): raise Exception("Unexpected ENABLE success (wpa_psk_radius)") - hapd_global.remove(ifname) + hostapd.remove_bss(apdev[0]) # FT without NAS-Identifier params = { "wpa": "2", @@ -62,7 +60,7 @@ def test_ap_config_errors(dev, apdev): hapd = hostapd.add_ap(apdev[0], params, no_enable=True) if "FAIL" not in hapd.request("ENABLE"): raise Exception("Unexpected ENABLE success (FT without nas_identifier)") - hapd_global.remove(ifname) + hostapd.remove_bss(apdev[0]) # Hotspot 2.0 without WPA2/CCMP 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) if "FAIL" not in hapd.request("ENABLE"): raise Exception("Unexpected ENABLE success (HS 2.0 without WPA2/CCMP)") - hapd_global.remove(ifname) + hostapd.remove_bss(apdev[0]) diff --git a/tests/hwsim/test_ap_dynamic.py b/tests/hwsim/test_ap_dynamic.py index fb8e35c..091930d 100644 --- a/tests/hwsim/test_ap_dynamic.py +++ b/tests/hwsim/test_ap_dynamic.py @@ -199,11 +199,9 @@ def test_ap_multi_bss_config(dev, apdev): hostapd.remove_bss(apdev[0], ifname1) multi_check(dev, [ False, False, False ]) -def invalid_ap(hapd_global, ifname): - logger.info("Trying to start AP " + ifname + " with invalid configuration") - hapd_global.remove(ifname) - hapd_global.add(ifname) - hapd = hostapd.Hostapd(ifname) +def invalid_ap(ap): + logger.info("Trying to start AP " + ap['ifname'] + " with invalid configuration") + hapd = hostapd.add_ap(ap, {}, no_enable=True) if not hapd.ping(): raise Exception("Could not ping hostapd") hapd.set_defaults() @@ -220,9 +218,7 @@ def invalid_ap(hapd_global, ifname): def test_ap_invalid_config(dev, apdev): """Try to start AP with invalid configuration and fix configuration""" - hapd_global = hostapd.HostapdGlobal() - ifname = apdev[0]['ifname'] - hapd = invalid_ap(hapd_global, ifname) + hapd = invalid_ap(apdev[0]) logger.info("Fix configuration and start AP again") hapd.set("channel", "1") @@ -231,53 +227,45 @@ def test_ap_invalid_config(dev, apdev): def test_ap_invalid_config2(dev, apdev): """Try to start AP with invalid configuration and remove interface""" - hapd_global = hostapd.HostapdGlobal() - ifname = apdev[0]['ifname'] - hapd = invalid_ap(hapd_global, ifname) + hapd = invalid_ap(apdev[0]) logger.info("Remove interface with failed configuration") - hapd_global.remove(ifname) + hostapd.remove_bss(apdev[0]) def test_ap_remove_during_acs(dev, apdev): """Remove interface during ACS""" force_prev_ap_on_24g(apdev[0]) params = hostapd.wpa2_params(ssid="test-acs-remove", passphrase="12345678") params['channel'] = '0' - ifname = apdev[0]['ifname'] - hapd = hostapd.HostapdGlobal() hostapd.add_ap(apdev[0], params) - hapd.remove(ifname) + hostapd.remove_bss(apdev[0]) def test_ap_remove_during_acs2(dev, apdev): """Remove BSS during ACS in multi-BSS configuration""" force_prev_ap_on_24g(apdev[0]) ifname = apdev[0]['ifname'] ifname2 = ifname + "-2" - hapd_global = hostapd.HostapdGlobal() - hapd_global.add(ifname) - hapd = hostapd.Hostapd(ifname) + hapd = hostapd.add_ap(apdev[0], {}, no_enable=True) hapd.set_defaults() hapd.set("ssid", "test-acs-remove") hapd.set("channel", "0") hapd.set("bss", ifname2) hapd.set("ssid", "test-acs-remove2") hapd.enable() - hapd_global.remove(ifname) + hostapd.remove_bss(apdev[0]) def test_ap_remove_during_acs3(dev, apdev): """Remove second BSS during ACS in multi-BSS configuration""" force_prev_ap_on_24g(apdev[0]) ifname = apdev[0]['ifname'] ifname2 = ifname + "-2" - hapd_global = hostapd.HostapdGlobal() - hapd_global.add(ifname) - hapd = hostapd.Hostapd(ifname) + hapd = hostapd.add_ap(apdev[0], {}, no_enable=True) hapd.set_defaults() hapd.set("ssid", "test-acs-remove") hapd.set("channel", "0") hapd.set("bss", ifname2) hapd.set("ssid", "test-acs-remove2") hapd.enable() - hapd_global.remove(ifname2) + hostapd.remove_bss(apdev[0], ifname2) def test_ap_remove_during_ht_coex_scan(dev, apdev): """Remove interface during HT co-ex scan""" @@ -285,17 +273,14 @@ def test_ap_remove_during_ht_coex_scan(dev, apdev): params['channel'] = '1' params['ht_capab'] = "[HT40+]" ifname = apdev[0]['ifname'] - hapd = hostapd.HostapdGlobal() hostapd.add_ap(apdev[0], params) - hapd.remove(ifname) + hostapd.remove_bss(apdev[0]) def test_ap_remove_during_ht_coex_scan2(dev, apdev): """Remove BSS during HT co-ex scan in multi-BSS configuration""" ifname = apdev[0]['ifname'] ifname2 = ifname + "-2" - hapd_global = hostapd.HostapdGlobal() - hapd_global.add(ifname) - hapd = hostapd.Hostapd(ifname) + hapd = hostapd.add_ap(apdev[0], {}, no_enable=True) hapd.set_defaults() hapd.set("ssid", "test-ht-remove") hapd.set("channel", "1") @@ -303,15 +288,13 @@ def test_ap_remove_during_ht_coex_scan2(dev, apdev): hapd.set("bss", ifname2) hapd.set("ssid", "test-ht-remove2") hapd.enable() - hapd_global.remove(ifname) + hostapd.remove_bss(apdev[0]) def test_ap_remove_during_ht_coex_scan3(dev, apdev): """Remove second BSS during HT co-ex scan in multi-BSS configuration""" ifname = apdev[0]['ifname'] ifname2 = ifname + "-2" - hapd_global = hostapd.HostapdGlobal() - hapd_global.add(ifname) - hapd = hostapd.Hostapd(ifname) + hapd = hostapd.add_ap(apdev[0], {}, no_enable=True) hapd.set_defaults() hapd.set("ssid", "test-ht-remove") hapd.set("channel", "1") @@ -319,14 +302,11 @@ def test_ap_remove_during_ht_coex_scan3(dev, apdev): hapd.set("bss", ifname2) hapd.set("ssid", "test-ht-remove2") hapd.enable() - hapd_global.remove(ifname2) + hostapd.remove_bss(apdev[0], ifname2) def test_ap_enable_disable_reenable(dev, apdev): """Enable, disable, re-enable AP""" - ifname = apdev[0]['ifname'] - hapd_global = hostapd.HostapdGlobal() - hapd_global.add(ifname) - hapd = hostapd.Hostapd(ifname) + hapd = hostapd.add_ap(apdev[0], {}, no_enable=True) hapd.set_defaults() hapd.set("ssid", "dynamic") hapd.enable() @@ -366,7 +346,7 @@ def test_ap_bss_add_many(dev, apdev): finally: dev[0].request("SCAN_INTERVAL 5") ifname = apdev[0]['ifname'] - hapd = hostapd.HostapdGlobal() + hapd = hostapd.HostapdGlobal(apdev[0]) hapd.flush() for i in range(16): ifname2 = ifname + '-' + str(i) @@ -379,7 +359,6 @@ def test_ap_bss_add_many(dev, apdev): def _test_ap_bss_add_many(dev, apdev): ifname = apdev[0]['ifname'] hostapd.add_bss(apdev[0], ifname, 'bss-1.conf') - hapd = hostapd.HostapdGlobal() fname = '/tmp/hwsim-bss.conf' for i in range(16): ifname2 = ifname + '-' + str(i) @@ -404,7 +383,7 @@ def _test_ap_bss_add_many(dev, apdev): dev[0].request("DISCONNECT") dev[0].wait_disconnected(timeout=5) ifname2 = ifname + '-' + str(i) - hapd.remove(ifname2) + hostapd.remove_bss(apdev[0], ifname2) def test_ap_bss_add_reuse_existing(dev, apdev): """Dynamic BSS add operation reusing existing interface""" diff --git a/tests/hwsim/test_ap_hs20.py b/tests/hwsim/test_ap_hs20.py index 1d449a1..a4e6179 100644 --- a/tests/hwsim/test_ap_hs20.py +++ b/tests/hwsim/test_ap_hs20.py @@ -1732,7 +1732,7 @@ def test_ap_hs20_min_bandwidth_home_hidden_ssid_in_scan_res(dev, apdev): "ignore_broadcast_ssid": "1" }) dev[0].scan_for_bss(bssid, freq=2412) hapd.disable() - hapd_global = hostapd.HostapdGlobal() + hapd_global = hostapd.HostapdGlobal(apdev[0]) hapd_global.flush() hapd_global.remove(apdev[0]['ifname']) @@ -2898,7 +2898,7 @@ def test_ap_hs20_hidden_ssid_in_scan_res(dev, apdev): "ignore_broadcast_ssid": "1" }) dev[0].scan_for_bss(bssid, freq=2412) hapd.disable() - hapd_global = hostapd.HostapdGlobal() + hapd_global = hostapd.HostapdGlobal(apdev[0]) hapd_global.flush() hapd_global.remove(apdev[0]['ifname']) diff --git a/tests/hwsim/test_ap_ht.py b/tests/hwsim/test_ap_ht.py index cd52578..2089218 100644 --- a/tests/hwsim/test_ap_ht.py +++ b/tests/hwsim/test_ap_ht.py @@ -683,8 +683,7 @@ def test_olbc(dev, apdev): if status['olbc'] != '1' or status['olbc_ht'] != '1': raise Exception("Missing OLBC information") - hapd_global = hostapd.HostapdGlobal() - hapd_global.remove(apdev[1]['ifname']) + hostapd.remove_bss(apdev[1]) logger.info("Waiting for OLBC state to time out") cleared = False diff --git a/tests/hwsim/test_ap_psk.py b/tests/hwsim/test_ap_psk.py index d5c22af..b0d359b 100644 --- a/tests/hwsim/test_ap_psk.py +++ b/tests/hwsim/test_ap_psk.py @@ -2125,13 +2125,8 @@ def test_rsn_ie_proto_psk_sta(dev, apdev): def test_ap_cli_order(dev, apdev): ssid = "test-rsn-setup" passphrase = 'zzzzzzzz' - ifname = apdev[0]['ifname'] - - hapd_global = hostapd.HostapdGlobal() - hapd_global.remove(ifname) - hapd_global.add(ifname) - hapd = hostapd.Hostapd(ifname) + hapd = hostapd.add_ap(apdev[0], {}, no_enable=True) hapd.set_defaults() hapd.set('ssid', ssid) hapd.set('wpa_passphrase', passphrase) diff --git a/tests/hwsim/test_ap_wps.py b/tests/hwsim/test_ap_wps.py index aded40b..405b419 100644 --- a/tests/hwsim/test_ap_wps.py +++ b/tests/hwsim/test_ap_wps.py @@ -292,8 +292,7 @@ def test_ap_wps_twice(dev, apdev): params = { "ssid": ssid, "eap_server": "1", "wps_state": "2", "wpa_passphrase": "12345678", "wpa": "2", "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP" } - hostapd.add_ap(apdev[0], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.add_ap(apdev[0], params) logger.info("WPS provisioning step") hapd.request("WPS_PBC") dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412") @@ -303,11 +302,9 @@ def test_ap_wps_twice(dev, apdev): dev[0].request("DISCONNECT") logger.info("Restart AP with different passphrase and re-run WPS") - hapd_global = hostapd.HostapdGlobal() - hapd_global.remove(apdev[0]['ifname']) + hostapd.remove_bss(apdev[0]) params['wpa_passphrase'] = 'another passphrase' - hostapd.add_ap(apdev[0], params) - hapd = hostapd.Hostapd(apdev[0]['ifname']) + hapd = hostapd.add_ap(apdev[0], params) logger.info("WPS provisioning step") hapd.request("WPS_PBC") dev[0].dump_monitor() diff --git a/tests/hwsim/test_dfs.py b/tests/hwsim/test_dfs.py index 49b0611..5b7b3ac 100644 --- a/tests/hwsim/test_dfs.py +++ b/tests/hwsim/test_dfs.py @@ -28,14 +28,8 @@ def wait_dfs_event(hapd, event, timeout): def start_dfs_ap(ap, allow_failure=False, ssid="dfs", ht=True, ht40=False, ht40minus=False, vht80=False, vht20=False, chanlist=None, channel=None): - ifname = ap['ifname'] - logger.info("Starting AP " + ifname + " on DFS channel") - hapd_global = hostapd.HostapdGlobal() - hapd_global.remove(ifname) - hapd_global.add(ifname) - hapd = hostapd.Hostapd(ifname) - if not hapd.ping(): - raise Exception("Could not ping hostapd") + logger.info("Starting AP " + ap['ifname'] + " on DFS channel") + hapd = hostapd.add_ap(ap, {}, no_enable=True) hapd.set_defaults() hapd.set("ssid", ssid) hapd.set("country_code", "FI") diff --git a/tests/hwsim/test_hapd_ctrl.py b/tests/hwsim/test_hapd_ctrl.py index d148b65..4359f7e 100644 --- a/tests/hwsim/test_hapd_ctrl.py +++ b/tests/hwsim/test_hapd_ctrl.py @@ -443,7 +443,7 @@ def test_hapd_ctrl_global(dev, apdev): params = { "ssid": ssid } ifname = apdev[0]['ifname'] hapd = hostapd.add_ap(apdev[0], params) - hapd_global = hostapd.HostapdGlobal() + hapd_global = hostapd.HostapdGlobal(apdev[0]) res = hapd_global.request("IFNAME=" + ifname + " PING") if "PONG" not in res: raise Exception("Could not ping hostapd interface " + ifname + " via global control interface") diff --git a/tests/hwsim/test_hostapd_oom.py b/tests/hwsim/test_hostapd_oom.py index 1f714d9..ab885d2 100644 --- a/tests/hwsim/test_hostapd_oom.py +++ b/tests/hwsim/test_hostapd_oom.py @@ -13,7 +13,6 @@ from utils import HwsimSkip def hostapd_oom_loop(apdev, params, start_func="main"): hapd = hostapd.add_ap(apdev[0], { "ssid": "ctrl" }) - hapd_global = hostapd.HostapdGlobal() count = 0 for i in range(1, 1000): @@ -22,7 +21,7 @@ def hostapd_oom_loop(apdev, params, start_func="main"): try: hostapd.add_ap(apdev[1], params, timeout=2.5) logger.info("Iteration %d - success" % i) - hapd_global.remove(apdev[1]['ifname']) + hostapd.remove_bss(apdev[1]) state = hapd.request('GET_ALLOC_FAIL') logger.info("GET_ALLOC_FAIL: " + state) diff --git a/tests/hwsim/test_p2p_grpform.py b/tests/hwsim/test_p2p_grpform.py index 5ea010e..1f729e6 100644 --- a/tests/hwsim/test_p2p_grpform.py +++ b/tests/hwsim/test_p2p_grpform.py @@ -596,9 +596,8 @@ def test_go_neg_two_peers(dev): if "status=5" not in ev: raise Exception("Unexpected status code in rejection: " + ev) -def clear_pbc_overlap(dev, ifname): - hapd_global = hostapd.HostapdGlobal() - hapd_global.remove(ifname) +def clear_pbc_overlap(dev, ap): + hostapd.remove_bss(ap) dev[0].request("P2P_CANCEL") dev[1].request("P2P_CANCEL") dev[0].p2p_stop_find() @@ -645,7 +644,7 @@ def test_grpform_pbc_overlap(dev, apdev): if ev is None: 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): """P2P group formation during PBC overlap using group interfaces""" @@ -683,7 +682,7 @@ def test_grpform_pbc_overlap_group_iface(dev, apdev): # the group interface. 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): """P2P group formation fails while using group interface""" diff --git a/tests/hwsim/test_pmksa_cache.py b/tests/hwsim/test_pmksa_cache.py index 88a8df8..1cb0724 100644 --- a/tests/hwsim/test_pmksa_cache.py +++ b/tests/hwsim/test_pmksa_cache.py @@ -756,7 +756,7 @@ def test_pmksa_cache_size_limit(dev, apdev): _test_pmksa_cache_size_limit(dev, apdev) finally: try: - hapd = hostapd.HostapdGlobal() + hapd = hostapd.HostapdGlobal(apdev[0]) hapd.flush() hapd.remove(apdev[0]['ifname']) except: @@ -791,7 +791,7 @@ def _test_pmksa_cache_size_limit(dev, apdev): elif i + 1 != entries: raise Exception("Unexpected number of PMKSA entries") - hapd = hostapd.HostapdGlobal() + hapd = hostapd.HostapdGlobal(apdev[0]) hapd.flush() hapd.remove(apdev[0]['ifname']) diff --git a/tests/hwsim/test_rfkill.py b/tests/hwsim/test_rfkill.py index cb1e863..3b0aa6c 100644 --- a/tests/hwsim/test_rfkill.py +++ b/tests/hwsim/test_rfkill.py @@ -207,7 +207,7 @@ def test_rfkill_hostapd(dev, apdev): dev[0].request("DISCONNECT") hapd.disable() - hglobal = HostapdGlobal() + hglobal = HostapdGlobal(apdev[0]) hglobal.flush() hglobal.remove(apdev[0]['ifname']) -- 1.9.1 _______________________________________________ Hostap mailing list Hostap@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/hostap