]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Wait for AP-ENABLED
authorJouni Malinen <j@w1.fi>
Fri, 27 Dec 2013 06:27:44 +0000 (08:27 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 27 Dec 2013 16:11:07 +0000 (18:11 +0200)
It takes some time for hostapd to complete AP startup. In some cases,
this could potentially result in station starting a scan before the AP
is beaconing or ready to reply to probes. To avoid such race conditions,
wait for AP-ENABLED before going ahead with the test cases.

Signed-hostap: Jouni Malinen <j@w1.fi>

tests/hwsim/hostapd.py
tests/hwsim/test_ap_acs.py
tests/hwsim/test_ap_ht.py

index 12e4a9f86d5727f2cb29849166e6d3879d8bf944..ada6d6dcbf298c482f5ec4daa6214bd83f3b0728 100644 (file)
@@ -179,7 +179,7 @@ class Hostapd:
         hdr = struct.pack('<HH6B6B6BH', *t)
         self.request("MGMT_TX " + binascii.hexlify(hdr + msg['payload']))
 
-def add_ap(ifname, params):
+def add_ap(ifname, params, wait_enabled=True):
         logger.info("Starting AP " + ifname)
         hapd_global = HostapdGlobal()
         hapd_global.remove(ifname)
@@ -203,6 +203,10 @@ def add_ap(ifname, params):
             else:
                 hapd.set(f, v)
         hapd.enable()
+        if wait_enabled:
+            ev = hapd.wait_event(["AP-ENABLED"], timeout=30)
+            if ev is None:
+                raise Exception("AP startup timed out")
         return hapd
 
 def add_bss(phy, ifname, confname, ignore_error=False):
index d456b810688ea63ed62aa9b2006deda39b6dc642..cfa45abbbc7c04199516afced30b9da7bfd8da4a 100644 (file)
@@ -42,7 +42,7 @@ def test_ap_acs(dev, apdev):
     """Automatic channel selection"""
     params = hostapd.wpa2_params(ssid="test-acs", passphrase="12345678")
     params['channel'] = '0'
-    hapd = hostapd.add_ap(apdev[0]['ifname'], params)
+    hapd = hostapd.add_ap(apdev[0]['ifname'], params, wait_enabled=False)
     wait_acs(hapd)
 
     freq = hapd.get_status_field("freq")
index 5ab6fe9ee6a9bdb3b1876928367904a160507347..d0ee300a97a1606be9140224f846f445bb128972 100644 (file)
@@ -17,11 +17,11 @@ def test_ap_ht40_scan(dev, apdev):
     params = { "ssid": "test-ht40",
                "channel": "5",
                "ht_capab": "[HT40-]"}
-    hapd = hostapd.add_ap(apdev[0]['ifname'], params)
+    hapd = hostapd.add_ap(apdev[0]['ifname'], params, wait_enabled=False)
 
     state = hapd.get_status_field("state")
     if state != "HT_SCAN":
-        time.wait(0.1)
+        time.sleep(0.1)
         state = hapd.get_status_field("state")
         if state != "HT_SCAN":
             raise Exception("Unexpected interface state - expected HT_SCAN")