tests: Optimize ap_wps_init_through_wps_config
authorJouni Malinen <jouni@qca.qualcomm.com>
Thu, 27 Feb 2014 16:01:32 +0000 (18:01 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 27 Feb 2014 16:01:32 +0000 (18:01 +0200)
Wait a bit between WPS_CONFIG command and the first scan. This can avoid
an extra five second wait due to having to scan again if the initial
scan operations happens to be quick enough to happen before the AP has
updated its configuration.

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

index e4d93d8..ee82f6e 100644 (file)
@@ -130,6 +130,14 @@ def test_ap_wps_init_through_wps_config(dev, apdev):
     hapd = hostapd.Hostapd(apdev[0]['ifname'])
     if "FAIL" in hapd.request("WPS_CONFIG " + ssid.encode("hex") + " WPA2PSK CCMP " + "12345678".encode("hex")):
         raise Exception("WPS_CONFIG command failed")
+    ev = hapd.wait_event(["WPS-NEW-AP-SETTINGS"], timeout=5)
+    if ev is None:
+        raise Exception("Timeout on WPS-NEW-AP-SETTINGS events")
+    # It takes some time for the AP to update Beacon and Probe Response frames,
+    # so wait here before requesting the scan to be started to avoid adding
+    # extra five second wait to the test due to fetching obsolete scan results.
+    hapd.ping()
+    time.sleep(0.2)
     dev[0].connect(ssid, psk="12345678", scan_freq="2412", proto="WPA2",
                    pairwise="CCMP", group="CCMP")