Cleanup this code as much as possible to be ready for usage with remote hosts. Signed-off-by: Janusz Dziedzic <janusz.dziedzic@xxxxxxxxx> --- tests/hwsim/hostapd.py | 2 + tests/hwsim/test_ap_acs.py | 9 +-- tests/hwsim/test_ap_config.py | 18 +++--- tests/hwsim/test_ap_dynamic.py | 126 ++++++++++++++------------------------- tests/hwsim/test_ap_hs20.py | 12 ++-- tests/hwsim/test_ap_ht.py | 3 +- tests/hwsim/test_ap_psk.py | 19 ++---- tests/hwsim/test_ap_vlan.py | 3 +- tests/hwsim/test_ap_wps.py | 12 ++-- tests/hwsim/test_dfs.py | 47 +++++++-------- tests/hwsim/test_fst_module.py | 18 +++--- tests/hwsim/test_hapd_ctrl.py | 6 +- tests/hwsim/test_hostapd_oom.py | 3 +- tests/hwsim/test_module_tests.py | 4 +- tests/hwsim/test_p2p_grpform.py | 9 ++- tests/hwsim/test_pmksa_cache.py | 4 +- tests/hwsim/test_rfkill.py | 2 +- 17 files changed, 116 insertions(+), 181 deletions(-) diff --git a/tests/hwsim/hostapd.py b/tests/hwsim/hostapd.py index 084c43e..d053e98 100644 --- a/tests/hwsim/hostapd.py +++ b/tests/hwsim/hostapd.py @@ -409,6 +409,7 @@ def add_bss(phy, apdev, confname, ignore_error=False): hapd = Hostapd(dev) if not hapd.ping(): raise Exception("Could not ping hostapd") + return hapd def add_iface(apdev, confname): ifname = apdev['ifname'] @@ -424,6 +425,7 @@ def add_iface(apdev, confname): hapd = Hostapd(dev) if not hapd.ping(): raise Exception("Could not ping hostapd") + return hapd def remove_bss(apdev): ifname = apdev['ifname'] diff --git a/tests/hwsim/test_ap_acs.py b/tests/hwsim/test_ap_acs.py index 8f1f492..6d7b5dc 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", @@ -95,8 +93,7 @@ def test_ap_multi_bss_acs(dev, apdev): force_prev_ap_on_24g(apdev[0]) # start the actual test - hostapd.add_iface(apdev[0], 'multi-bss-acs.conf') - hapd = hostapd.Hostapd(ifname) + hapd = hostapd.add_iface(apdev[0], 'multi-bss-acs.conf') hapd.enable() wait_acs(hapd) 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 420f95f..a1da66c 100644 --- a/tests/hwsim/test_ap_dynamic.py +++ b/tests/hwsim/test_ap_dynamic.py @@ -188,8 +188,7 @@ def test_ap_multi_bss_config(dev, apdev): apdev2['ifname'] = apdev[0]['ifname'] + '-2' apdev3['ifname'] = apdev[0]['ifname'] + '-3' logger.info("Set up three BSSes with one configuration file") - hostapd.add_iface(apdev1, 'multi-bss.conf') - hapd = hostapd.Hostapd(apdev1) + hapd = hostapd.add_iface(apdev1, 'multi-bss.conf') hapd.enable() multi_check(dev, [ True, True, True ]) hostapd.remove_bss(apdev2) @@ -199,8 +198,7 @@ def test_ap_multi_bss_config(dev, apdev): hostapd.remove_bss(apdev1) multi_check(dev, [ False, False, False ]) - hostapd.add_iface(apdev1, 'multi-bss.conf') - hapd = hostapd.Hostapd(apdev1) + hapd = hostapd.add_iface(apdev1, 'multi-bss.conf') hapd.enable() hostapd.remove_bss(apdev1) multi_check(dev, [ False, False, False ]) @@ -237,93 +235,64 @@ def test_ap_remove_during_acs(dev, apdev): 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(apdev[0]) - 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) + ifname2 = apdev[0]['ifname'] + "-2" + params = { "ssid" : "test-acs-remove", + "channel" : "0", + "bss" : ifname2, + "ssid" : "test-acs-remove2"} + hostapd.add_ap(apdev[0], params) + 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(apdev[0]) - 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) + ifname2 = apdev[0]['ifname'] + "-2" + params = { "ssid" : "test-acs-remove", + "channel" : "0", + "bss" : ifname2, + "ssid" : "test-acs-remove2" } + hostapd.add_ap(apdev[0], params) + hostapd.remove_bss(apdev[0]) def test_ap_remove_during_ht_coex_scan(dev, apdev): """Remove interface during HT co-ex scan""" params = hostapd.wpa2_params(ssid="test-ht-remove", passphrase="12345678") 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(apdev[0]) - hapd.set_defaults() - hapd.set("ssid", "test-ht-remove") - hapd.set("channel", "1") - hapd.set("ht_capab", "[HT40+]") - hapd.set("bss", ifname2) - hapd.set("ssid", "test-ht-remove2") - hapd.enable() - hapd_global.remove(ifname) + ifname2 = apdev[0]['ifname'] + "-2" + params = { "ssid" : "test-ht-remove", + "channel" : "1", + "ht_capab" : "[HT40+]", + "bss" : ifname2, + "ssid" : "test-ht-remove2" } + hostapd.add_ap(apdev[0], params) + 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(apdev[0]) - hapd.set_defaults() - hapd.set("ssid", "test-ht-remove") - hapd.set("channel", "1") - hapd.set("ht_capab", "[HT40+]") - hapd.set("bss", ifname2) - hapd.set("ssid", "test-ht-remove2") - hapd.enable() - hapd_global.remove(ifname2) + ifname2 = apdev[0]['ifname'] + "-2" + params = { "ssid" : "test-ht-remove", + "channel" : "1", + "ht_capab" : "[HT40+]", + "bss" : ifname2, + "ssid" : "test-ht-remove2" } + hostapd.add_ap(apdev[0], params) + hostapd.remove_bss(apdev[0]) 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(apdev[0]) - hapd.set_defaults() - hapd.set("ssid", "dynamic") + hapd = hostapd.add_ap(apdev[0], { "ssid" : "dynamic"}, no_enable=True) hapd.enable() ev = hapd.wait_event(["AP-ENABLED"], timeout=30) if ev is None: @@ -364,7 +333,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) @@ -378,7 +347,7 @@ def _test_ap_bss_add_many(dev, apdev): apdev1 = apdev[0].copy() phy = 'phy3' hostapd.add_bss(phy, apdev1, 'bss-1.conf') - hapd = hostapd.HostapdGlobal() + hapd = hostapd.HostapdGlobal(apdev[0]) fname = '/tmp/hwsim-bss.conf' for i in range(16): apdev2 = apdev[0].copy() @@ -418,9 +387,9 @@ def test_ap_bss_add_reuse_existing(dev, apdev): hostapd.remove_bss(apdev2) subprocess.check_call(["iw", "dev", apdev2['ifname'], "del"]) -def hapd_bss_out_of_mem(hapd, phy, confname, count, func): +def hapd_bss_out_of_mem(dev, hapd, phy, confname, count, func): with alloc_fail(hapd, count, func): - hapd_global = hostapd.HostapdGlobal() + hapd_global = hostapd.HostapdGlobal(dev) res = hapd_global.ctrl.request("ADD bss_config=" + phy + ":" + confname) if "OK" in res: raise Exception("add_bss succeeded") @@ -433,18 +402,18 @@ def test_ap_bss_add_out_of_memory(dev, apdev): apdev2 = apdev[0].copy() apdev2['ifname'] = apdev[0]['ifname'] + '-2' - hapd_bss_out_of_mem(hapd2, 'phy3', 'bss-1.conf', 1, 'hostapd_add_iface') + hapd_bss_out_of_mem(apdev[1], hapd2, 'phy3', 'bss-1.conf', 1, 'hostapd_add_iface') for i in range(1, 3): - hapd_bss_out_of_mem(hapd2, 'phy3', 'bss-1.conf', + hapd_bss_out_of_mem(apdev[1], hapd2, 'phy3', 'bss-1.conf', i, 'hostapd_interface_init_bss') - hapd_bss_out_of_mem(hapd2, 'phy3', 'bss-1.conf', + hapd_bss_out_of_mem(apdev[1], hapd2, 'phy3', 'bss-1.conf', 1, 'ieee802_11_build_ap_params') hostapd.add_bss('phy3', apdev1, 'bss-1.conf') - hapd_bss_out_of_mem(hapd2, 'phy3', 'bss-2.conf', + hapd_bss_out_of_mem(apdev[1], hapd2, 'phy3', 'bss-2.conf', 1, 'hostapd_interface_init_bss') - hapd_bss_out_of_mem(hapd2, 'phy3', 'bss-2.conf', + hapd_bss_out_of_mem(apdev[1], hapd2, 'phy3', 'bss-2.conf', 1, 'ieee802_11_build_ap_params') hostapd.add_bss('phy3', apdev2, 'bss-2.conf') @@ -476,12 +445,7 @@ def test_ap_multi_bss(dev, apdev): def test_ap_add_with_driver(dev, apdev): """Add hostapd interface with driver specified""" - ifname = apdev[0]['ifname'] - hapd_global = hostapd.HostapdGlobal() - hapd_global.add(ifname, driver="nl80211") - hapd = hostapd.Hostapd(apdev[0]) - hapd.set_defaults() - hapd.set("ssid", "dynamic") + hapd = hostapd.add_ap(apdev[0], { "ssid" : "dynamic" }, no_enable=True) hapd.enable() ev = hapd.wait_event(["AP-ENABLED"], timeout=30) if ev is None: diff --git a/tests/hwsim/test_ap_hs20.py b/tests/hwsim/test_ap_hs20.py index f36cb16..9fc4d0a 100644 --- a/tests/hwsim/test_ap_hs20.py +++ b/tests/hwsim/test_ap_hs20.py @@ -1729,12 +1729,10 @@ def test_ap_hs20_min_bandwidth_home_hidden_ssid_in_scan_res(dev, apdev): bssid = apdev[0]['bssid'] hapd = hostapd.add_ap(apdev[0], { "ssid": 'secret', - "ignore_broadcast_ssid": "1" }) + "ignore_broadcast_ssid": "1" }) dev[0].scan_for_bss(bssid, freq=2412) hapd.disable() - hapd_global = hostapd.HostapdGlobal() - hapd_global.flush() - hapd_global.remove(apdev[0]['ifname']) + hostapd.remove_bss(apdev[0]) params = hs20_ap_params() hostapd.add_ap(apdev[0], params) @@ -2895,12 +2893,10 @@ def test_ap_hs20_hidden_ssid_in_scan_res(dev, apdev): bssid = apdev[0]['bssid'] hapd = hostapd.add_ap(apdev[0], { "ssid": 'secret', - "ignore_broadcast_ssid": "1" }) + "ignore_broadcast_ssid": "1" }) dev[0].scan_for_bss(bssid, freq=2412) hapd.disable() - hapd_global = hostapd.HostapdGlobal() - hapd_global.flush() - hapd_global.remove(apdev[0]['ifname']) + hostapd.remove_bss(apdev[0]) params = hs20_ap_params() params['hessid'] = bssid diff --git a/tests/hwsim/test_ap_ht.py b/tests/hwsim/test_ap_ht.py index 63aae42..0775010 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 93bac83..8ab6864 100644 --- a/tests/hwsim/test_ap_psk.py +++ b/tests/hwsim/test_ap_psk.py @@ -2125,19 +2125,12 @@ 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(apdev[0]) - hapd.set_defaults() - hapd.set('ssid', ssid) - hapd.set('wpa_passphrase', passphrase) - hapd.set('rsn_pairwise', 'CCMP') - hapd.set('wpa_key_mgmt', 'WPA-PSK') - hapd.set('wpa', '2') + params = { 'ssid' : ssid, + 'wpa_passphrase' : passphrase, + 'rsn_pairwise' : 'CCMP', + 'wpa_key_mgmt' : 'WPA-PSK', + 'wpa' : '2' } + hapd = hostapd.add_ap(apdev[0], params, no_enable = True) hapd.enable() cfg = hapd.get_config() if cfg['group_cipher'] != 'CCMP': diff --git a/tests/hwsim/test_ap_vlan.py b/tests/hwsim/test_ap_vlan.py index 8a7962d..4c9a24a 100644 --- a/tests/hwsim/test_ap_vlan.py +++ b/tests/hwsim/test_ap_vlan.py @@ -330,8 +330,7 @@ def ap_vlan_iface_cleanup_multibss(dev, apdev, cfgfile): ifname = apdev[0]['ifname'] # start the actual test - hostapd.add_iface(apdev[0], cfgfile) - hapd = hostapd.Hostapd(apdev[0]) + hapd = hostapd.add_iface(apdev[0], cfgfile) apdev1 = { "ifname" : "wlan3-2" } hapd1 = hostapd.Hostapd(apdev1, 1) hapd1.enable() diff --git a/tests/hwsim/test_ap_wps.py b/tests/hwsim/test_ap_wps.py index b69e22f..1f03ba6 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]) + 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]) + hapd = hostapd.add_ap(apdev[0], params) logger.info("WPS provisioning step") hapd.request("WPS_PBC") dev[0].dump_monitor() @@ -2287,8 +2284,7 @@ def test_ap_wps_auto_setup_with_config_file(dev, apdev): f.write("ssid=wps\n") f.write("eap_server=1\n") f.write("wps_state=1\n") - hostapd.add_bss('phy3', apdev[0], conffile) - hapd = hostapd.Hostapd(apdev[0]) + hapd = hostapd.add_bss('phy3', apdev[0], conffile) hapd.request("WPS_PBC") dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412") dev[0].request("WPS_PBC " + apdev[0]['bssid']) diff --git a/tests/hwsim/test_dfs.py b/tests/hwsim/test_dfs.py index e4c9bdb..6cde3cb 100644 --- a/tests/hwsim/test_dfs.py +++ b/tests/hwsim/test_dfs.py @@ -28,40 +28,33 @@ 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(ap) - hapd_global.remove(ifname) - hapd_global.add(ifname) - hapd = hostapd.Hostapd(ap) - if not hapd.ping(): - raise Exception("Could not ping hostapd") - hapd.set_defaults() - hapd.set("ssid", ssid) - hapd.set("country_code", "FI") - hapd.set("ieee80211d", "1") - hapd.set("ieee80211h", "1") - hapd.set("hw_mode", "a") - hapd.set("channel", "52") + logger.info("Starting AP " + ap['ifname'] + " on DFS channel") + params = { "ssid" : ssid, + "country_code" : "FI", + "ieee80211d" : "1", + "ieee80211h" : "1", + "hw_mode" : "a", + "channel" : "52" } if not ht: - hapd.set("ieee80211n", "0") + params["ieee80211n"] = "0" if ht40: - hapd.set("ht_capab", "[HT40+]") + params["ht_capab"] = "[HT40+]" elif ht40minus: - hapd.set("ht_capab", "[HT40-]") - hapd.set("channel", "56") + params["ht_capab"] = "[HT40-]" + params["channel"] = "56" if vht80: - hapd.set("ieee80211ac", "1") - hapd.set("vht_oper_chwidth", "1") - hapd.set("vht_oper_centr_freq_seg0_idx", "58") + params["ieee80211ac"] = "1" + params["vht_oper_chwidth"] = "1" + params["vht_oper_centr_freq_seg0_idx"] = "58" if vht20: - hapd.set("ieee80211ac", "1") - hapd.set("vht_oper_chwidth", "0") - hapd.set("vht_oper_centr_freq_seg0_idx", "0") + params["ieee80211ac"] = "1" + params["vht_oper_chwidth"] = "0" + params["vht_oper_centr_freq_seg0_idx"] = "0" if chanlist: - hapd.set("chanlist", chanlist) + params["chanlist"] = chanlist if channel: - hapd.set("channel", str(channel)) + params["channel"] = str(channel) + hapd = hostapd.add_ap(ap, params, no_enable=True) hapd.enable() ev = wait_dfs_event(hapd, "DFS-CAC-START", 5) diff --git a/tests/hwsim/test_fst_module.py b/tests/hwsim/test_fst_module.py index 4ed4adf..9400770 100644 --- a/tests/hwsim/test_fst_module.py +++ b/tests/hwsim/test_fst_module.py @@ -762,7 +762,7 @@ def test_fst_sta_connect_to_non_fst_ap(dev, apdev, test_params): finally: sta2.disconnect_from_external_ap() fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2) - hostapd.HostapdGlobal().remove(iface) + hostapd.remove_bss(ap) def test_fst_sta_connect_to_fst_ap(dev, apdev, test_params): """FST STA connecting to FST AP""" @@ -851,7 +851,7 @@ def test_fst_second_sta_connect_to_non_fst_ap(dev, apdev, test_params): sta1.disconnect() sta2.disconnect_from_external_ap() fst_module_aux.stop_two_ap_sta_pairs(fst_ap1, fst_ap2, sta1, sta2) - hostapd.HostapdGlobal().remove(iface) + hostapd.remove_bss(ap) def test_fst_second_sta_connect_to_fst_ap(dev, apdev, test_params): """FST STA 2nd connecting to FST AP""" @@ -883,7 +883,7 @@ def test_fst_second_sta_connect_to_fst_ap(dev, apdev, test_params): sta1.disconnect() sta2.disconnect_from_external_ap() fst_module_aux.stop_two_ap_sta_pairs(fst_ap1, fst_ap2, sta1, sta2) - hostapd.HostapdGlobal().remove(iface) + hostapd.remove_bss(ap) def test_fst_disconnect_1_of_2_stas_from_non_fst_ap(dev, apdev, test_params): """FST disconnect 1 of 2 STAs from non-FST AP""" @@ -916,7 +916,7 @@ def test_fst_disconnect_1_of_2_stas_from_non_fst_ap(dev, apdev, test_params): sta1.disconnect() sta2.disconnect_from_external_ap() fst_module_aux.stop_two_ap_sta_pairs(fst_ap1, fst_ap2, sta1, sta2) - hostapd.HostapdGlobal().remove(iface) + hostapd.remove_bss(ap) def test_fst_disconnect_1_of_2_stas_from_fst_ap(dev, apdev, test_params): """FST disconnect 1 of 2 STAs from FST AP""" @@ -949,7 +949,7 @@ def test_fst_disconnect_1_of_2_stas_from_fst_ap(dev, apdev, test_params): sta1.disconnect() sta2.disconnect_from_external_ap() fst_module_aux.stop_two_ap_sta_pairs(fst_ap1, fst_ap2, sta1, sta2) - hostapd.HostapdGlobal().remove(iface) + hostapd.remove_bss(ap) def test_fst_disconnect_2_of_2_stas_from_non_fst_ap(dev, apdev, test_params): """FST disconnect 2 of 2 STAs from non-FST AP""" @@ -984,7 +984,7 @@ def test_fst_disconnect_2_of_2_stas_from_non_fst_ap(dev, apdev, test_params): sta1.disconnect() sta2.disconnect_from_external_ap() fst_module_aux.stop_two_ap_sta_pairs(fst_ap1, fst_ap2, sta1, sta2) - hostapd.HostapdGlobal().remove(iface) + hostapd.remove_bss(ap) def test_fst_disconnect_2_of_2_stas_from_fst_ap(dev, apdev, test_params): """FST disconnect 2 of 2 STAs from FST AP""" @@ -1036,7 +1036,7 @@ def test_fst_disconnect_2_of_2_stas_from_fst_ap(dev, apdev, test_params): sta1.disconnect() sta2.disconnect_from_external_ap() fst_module_aux.stop_two_ap_sta_pairs(fst_ap1, fst_ap2, sta1, sta2) - hostapd.HostapdGlobal().remove(iface) + hostapd.remove_bss(ap) def test_fst_disconnect_non_fst_sta(dev, apdev, test_params): """FST disconnect non-FST STA""" @@ -1420,7 +1420,7 @@ def test_fst_ap_remove_session_bad_session_id(dev, apdev, test_params): def test_fst_ap_ctrl_iface(dev, apdev, test_params): """FST control interface behavior""" - hglobal = hostapd.HostapdGlobal() + hglobal = hostapd.HostapdGlobal(apdev[0]) start_num_groups = 0 res = hglobal.request("FST-MANAGER LIST_GROUPS") del hglobal @@ -2345,7 +2345,7 @@ def fst_setup_req(dev, hglobal, freq, dst, req, stie, mbie="", no_wait=False): break def fst_start_and_connect(apdev, group, sgroup): - hglobal = hostapd.HostapdGlobal() + hglobal = hostapd.HostapdGlobal(apdev[0]) if "OK" not in hglobal.request("FST-MANAGER TEST_REQUEST IS_SUPPORTED"): raise HwsimSkip("No FST testing support") diff --git a/tests/hwsim/test_hapd_ctrl.py b/tests/hwsim/test_hapd_ctrl.py index d148b65..a37f3f2 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") @@ -471,7 +471,7 @@ def test_hapd_dup_network_global_wpa2(dev, apdev): dst_ifname = apdev[1]['ifname'] dst_hapd = hostapd.add_ap(apdev[1], dst_params, no_enable=True) - hapd_global = hostapd.HostapdGlobal() + hapd_global = hostapd.HostapdGlobal(apdev[0]) for param in [ "wpa", "wpa_passphrase", "wpa_key_mgmt", "rsn_pairwise" ]: dup_network(hapd_global, src_ifname, dst_ifname, param) @@ -500,7 +500,7 @@ def test_hapd_dup_network_global_wpa(dev, apdev): dst_ifname = apdev[1]['ifname'] dst_hapd = hostapd.add_ap(apdev[1], dst_params, no_enable=True) - hapd_global = hostapd.HostapdGlobal() + hapd_global = hostapd.HostapdGlobal(apdev[0]) for param in [ "wpa", "wpa_psk", "wpa_key_mgmt", "wpa_pairwise" ]: dup_network(hapd_global, src_ifname, dst_ifname, param) 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_module_tests.py b/tests/hwsim/test_module_tests.py index 2e96c45..6761f6e 100644 --- a/tests/hwsim/test_module_tests.py +++ b/tests/hwsim/test_module_tests.py @@ -21,8 +21,8 @@ def test_module_wpa_supplicant(dev, apdev, params): if "FAIL - should not have called this function" in res: raise Exception("eloop test failed") -def test_module_hostapd(dev): +def test_module_hostapd(dev, apdev): """hostapd module tests""" - hapd_global = hostapd.HostapdGlobal() + hapd_global = hostapd.HostapdGlobal(apdev[0]) if "OK" not in hapd_global.ctrl.request("MODULE_TESTS"): raise Exception("Module tests failed") diff --git a/tests/hwsim/test_p2p_grpform.py b/tests/hwsim/test_p2p_grpform.py index 5ea010e..24918b0 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, apdev): + hostapd.remove_bss(apdev) 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