From patchwork Thu Apr 7 05:38:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz.Dziedzic@tieto.com X-Patchwork-Id: 607253 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qgWck4XXHz9t5V for ; Thu, 7 Apr 2016 15:39:34 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=tieto.com header.i=@tieto.com header.b=Fb7C5dPr; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ao2f9-0005FC-2v; Thu, 07 Apr 2016 05:39:27 +0000 Received: from mail-lf0-x22f.google.com ([2a00:1450:4010:c07::22f]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ao2ef-0004x0-LH for hostap@lists.infradead.org; Thu, 07 Apr 2016 05:39:08 +0000 Received: by mail-lf0-x22f.google.com with SMTP id g184so49054725lfb.3 for ; Wed, 06 Apr 2016 22:38:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tieto.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Irt8iyhiiTahHrrVzJjlvhTBneW6NkVciTb7y5oplZE=; b=Fb7C5dPrTZuIg9Pf2AbYr1JW7LpRJB513XbHMf2S9fy0fCTjZpootFa/ij7rzBwJ/G n4CLCGOU4DcAuSnzXp0lslYqLxErMjOwM97xlahu2Wo/uEok8uNrFyIOlQ19aDPSIDIu jkE42cnD7N6liEs34sQewTqmm0t1aCe2jbF3c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Irt8iyhiiTahHrrVzJjlvhTBneW6NkVciTb7y5oplZE=; b=GOyoDfDhi8ENUi1rItGAeH8uEcZh69llfxEEfBTHhF6teqR/SVGUkl7E6ohYntwEX6 zbfWKyNgSccd3FOPwwzohtjIoXyGM0JuWWDEOPgRR8zmIJBrIzFIr3p0wdOJol+/yZWW lSaqtGpYzWEnkIgYotkr2VJIXPjZ9j8ZMaaP+dsJZXS87bwN/o7/cZMAzfLhz8MgmSve uc3WwZEd9CE5nPO42I1NvUJd6kmxwKRJKg8NNcevYiM7rkiORBK2qgGgXK0rYz1wzlzX l1ViHt2bzS6vjaQwlw41LOITyjTBwU/pe4LlmqMsAqSr0VIzk+QTHHYabVBo7Okpgq18 bNSQ== X-Gm-Message-State: AD7BkJImnFiP/zF61eJJXnjakGpqmO4zdRVL5Dj5epenRG1Mi1VBgRWfcwFg1sc2pBBMPEp2EHxdNaDa+eGC63q3+ZUU/OmxYZYqgHf3hbfQGdK9ZNLIVFMgPzrfVTZ4mtgqd/xDprbt10yYxQU3D2evWZ6dgPCOp6DVonXbgYs+97CbDNQ+hm73ALYgGAFah8dI X-Received: by 10.25.127.208 with SMTP id a199mr548275lfd.46.1460007516711; Wed, 06 Apr 2016 22:38:36 -0700 (PDT) Received: from localhost.localdomain ([213.192.73.50]) by smtp.gmail.com with ESMTPSA id f134sm938018lff.34.2016.04.06.22.38.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 06 Apr 2016 22:38:36 -0700 (PDT) From: Janusz Dziedzic To: hostap@lists.infradead.org Subject: [PATCH v2 07/17] tests: fix/remove HostapdGlobal() usage Date: Thu, 7 Apr 2016 07:38:05 +0200 Message-Id: <1460007495-17921-7-git-send-email-janusz.dziedzic@tieto.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1460007495-17921-1-git-send-email-janusz.dziedzic@tieto.com> References: <1460007495-17921-1-git-send-email-janusz.dziedzic@tieto.com> X-DomainID: tieto.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160406_223858_291211_9C7E8608 X-CRM114-Status: GOOD ( 11.51 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:4010:c07:0:0:0:22f listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@w1.fi, Janusz Dziedzic MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 --- 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'])