]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Fix scan result clearing in ssid_hidden*
authorJouni Malinen <j@w1.fi>
Sun, 20 Dec 2015 10:59:19 +0000 (12:59 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 20 Dec 2015 15:25:41 +0000 (17:25 +0200)
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 <j@w1.fi>
tests/hwsim/test_ssid.py

index ca0479e216d77a4cc936242e34e1dd2cbcab7889..5692585131d4504a072e88cdb6cf014278bc6117 100644 (file)
@@ -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)