]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Optimize ap_open_unexpected_assoc_event
authorJouni Malinen <jouni@qca.qualcomm.com>
Fri, 28 Nov 2014 14:28:36 +0000 (16:28 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 28 Nov 2014 21:02:29 +0000 (23:02 +0200)
Replace fixed sleep with waiting for a disconnection event. In addition,
remove unnecessary use of sudo.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
tests/hwsim/test_ap_open.py

index c5c0a3e95fefdfbbe955ff6d6977c541dc12e7b7..ad24cdd38bf63461ac3e2b55795e3adecf5c1f2c 100644 (file)
@@ -146,22 +146,22 @@ def test_ap_open_unexpected_assoc_event(dev, apdev):
     hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "open" })
     dev[0].connect("open", key_mgmt="NONE", scan_freq="2412")
     dev[0].request("DISCONNECT")
-    time.sleep(0.1)
+    dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=15)
     dev[0].dump_monitor()
     # This will be accepted due to matching network
-    subprocess.call(['sudo', 'iw', 'dev', dev[0].ifname, 'connect', 'open',
-                     "2412", apdev[0]['bssid']])
+    subprocess.call(['iw', 'dev', dev[0].ifname, 'connect', 'open', "2412",
+                     apdev[0]['bssid']])
     ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
     if ev is None:
         raise Exception("Association with the AP timed out")
     dev[0].dump_monitor()
 
     dev[0].request("REMOVE_NETWORK all")
-    time.sleep(0.1)
+    dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=5)
     dev[0].dump_monitor()
     # This will result in disconnection due to no matching network
-    subprocess.call(['sudo', 'iw', 'dev', dev[0].ifname, 'connect', 'open',
-                     "2412", apdev[0]['bssid']])
+    subprocess.call(['iw', 'dev', dev[0].ifname, 'connect', 'open', "2412",
+                     apdev[0]['bssid']])
     ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=15)
     if ev is None:
         raise Exception("Disconnection with the AP timed out")