From: Jouni Malinen Date: Sun, 20 Dec 2015 10:59:19 +0000 (+0200) Subject: tests: Fix scan result clearing in ssid_hidden* X-Git-Tag: hostap_2_6~1149 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7c7234a583278367b105955153ac6985582ce534;p=thirdparty%2Fhostap.git tests: Fix scan result clearing in ssid_hidden* These test cases were supposed to clear the cfg80211 and wpa_supplicant scan caches in the end to avoid causing issues to the following test cases. This did not work properly after introduction of the support for aborting a pending scan. Fix this by using the flush_scan_cache() function and waiting within the test case until the final scan operation completes. This issue was triggered by ssid_hidden/ssid_hidden2 followed by ext_password_interworking (though, not every time). Signed-off-by: Jouni Malinen --- diff --git a/tests/hwsim/test_ssid.py b/tests/hwsim/test_ssid.py index ca0479e21..569258513 100644 --- a/tests/hwsim/test_ssid.py +++ b/tests/hwsim/test_ssid.py @@ -60,6 +60,15 @@ def test_ssid_utf8(dev, apdev): if len(sta3) != 0: raise Exception("Unexpected STA iteration result (did not stop)") +def clear_scan_cache(hapd, dev): + # clear BSS table to avoid issues in following test cases + dev[0].request("REMOVE_NETWORK all") + dev[1].request("REMOVE_NETWORK all") + dev[0].wait_disconnected() + hapd.disable() + dev[0].flush_scan_cache() + dev[1].flush_scan_cache() + def test_ssid_hidden(dev, apdev): """Hidden SSID""" hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": 'secret', @@ -70,14 +79,7 @@ def test_ssid_hidden(dev, apdev): ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1) if ev is not None: raise Exception("Unexpected connection") - dev[0].request("DISCONNECT") - dev[1].request("DISCONNECT") - # clear BSS table to avoid issues in following test cases - hapd.disable() - dev[0].request("BSS_FLUSH 0") - dev[0].request("SCAN freq=2412 only_new=1") - dev[1].request("BSS_FLUSH 0") - dev[1].request("SCAN freq=2412 only_new=1") + clear_scan_cache(hapd, dev) def test_ssid_hidden2(dev, apdev): """Hidden SSID using zero octets as payload""" @@ -89,14 +91,7 @@ def test_ssid_hidden2(dev, apdev): ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1) if ev is not None: raise Exception("Unexpected connection") - dev[0].request("DISCONNECT") - dev[1].request("DISCONNECT") - # clear BSS table to avoid issues in following test cases - hapd.disable() - dev[0].request("BSS_FLUSH 0") - dev[0].request("SCAN freq=2412 only_new=1") - dev[1].request("BSS_FLUSH 0") - dev[1].request("SCAN freq=2412 only_new=1") + clear_scan_cache(hapd, dev) def test_ssid_hidden_wpa2(dev, apdev): """Hidden SSID with WPA2-PSK""" @@ -109,11 +104,4 @@ def test_ssid_hidden_wpa2(dev, apdev): ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1) if ev is not None: raise Exception("Unexpected connection") - dev[0].request("DISCONNECT") - dev[1].request("DISCONNECT") - # clear BSS table to avoid issues in following test cases - hapd.disable() - dev[0].request("BSS_FLUSH 0") - dev[0].request("SCAN freq=2412 only_new=1") - dev[1].request("BSS_FLUSH 0") - dev[1].request("SCAN freq=2412 only_new=1") + clear_scan_cache(hapd, dev)