]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Make active scans more robust
authorJouni Malinen <j@w1.fi>
Thu, 22 Jan 2015 20:38:38 +0000 (22:38 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 22 Jan 2015 22:52:40 +0000 (00:52 +0200)
This makes testing under very heavy load or under extensive kernel
debugging options more robust by allowing number of test cases to scan
multiple times before giving up on active scans. The main reason for
many of the related test failures is in Probe Response frame from
hostapd not getting out quickly enough especially when multiple BSSes
are operating.

Signed-off-by: Jouni Malinen <j@w1.fi>
tests/hwsim/test_ap_dynamic.py
tests/hwsim/test_ap_eap.py
tests/hwsim/test_wpas_ctrl.py

index 0b359d8460520e66e2c656be3005d8f5c7ec188e..f067fcb67a1e26be93495f2a2de149e69405d5b4 100644 (file)
@@ -35,7 +35,7 @@ def test_ap_change_ssid(dev, apdev):
     dev[0].set_network_quoted(id, "ssid", "test-wpa2-psk-new")
     dev[0].connect_network(id)
 
-def multi_check(dev, check):
+def multi_check(dev, check, scan_opt=True):
     id = []
     num_bss = len(check)
     for i in range(0, num_bss):
@@ -49,6 +49,9 @@ def multi_check(dev, check):
     for i in range(num_bss):
         if not check[i]:
             continue
+        bssid = '02:00:00:00:03:0' + str(i)
+        if scan_opt:
+            dev[i].scan_for_bss(bssid, freq=2412)
         id.append(dev[i].connect("bss-" + str(i + 1), key_mgmt="NONE",
                                  scan_freq="2412", wait_connect=True))
     first = True
@@ -78,6 +81,15 @@ def multi_check(dev, check):
 
 def test_ap_bss_add_remove(dev, apdev):
     """Dynamic BSS add/remove operations with hostapd"""
+    try:
+        _test_ap_bss_add_remove(dev, apdev)
+    finally:
+        for i in range(3):
+            dev[i].request("SCAN_INTERVAL 5")
+
+def _test_ap_bss_add_remove(dev, apdev):
+    for i in range(3):
+        dev[i].request("SCAN_INTERVAL 1")
     ifname1 = apdev[0]['ifname']
     ifname2 = apdev[0]['ifname'] + '-2'
     ifname3 = apdev[0]['ifname'] + '-3'
@@ -143,14 +155,14 @@ def test_ap_bss_add_remove_during_ht_scan(dev, apdev):
     ifname2 = apdev[0]['ifname'] + '-2'
     hostapd.add_bss('phy3', ifname1, 'bss-ht40-1.conf')
     hostapd.add_bss('phy3', ifname2, 'bss-ht40-2.conf')
-    multi_check(dev, [ True, True ])
+    multi_check(dev, [ True, True ], scan_opt=False)
     hostapd.remove_bss(ifname2)
     hostapd.remove_bss(ifname1)
 
     hostapd.add_bss('phy3', ifname1, 'bss-ht40-1.conf')
     hostapd.add_bss('phy3', ifname2, 'bss-ht40-2.conf')
     hostapd.remove_bss(ifname2)
-    multi_check(dev, [ True, False ])
+    multi_check(dev, [ True, False ], scan_opt=False)
     hostapd.remove_bss(ifname1)
 
     hostapd.add_bss('phy3', ifname1, 'bss-ht40-1.conf')
index 07db924bfa6b38ad65470bce7a00f55e28b75ff8..7f430e411a244259de7a200f4321f6bd99662ed4 100644 (file)
@@ -306,6 +306,8 @@ def _test_ap_wpa2_eap_sim_ext(dev, apdev):
     if ev is None:
         raise Exception("EAP failure not reported")
     dev[0].request("DISCONNECT")
+    dev[0].wait_disconnected()
+    time.sleep(0.1)
 
     dev[0].select_network(id, freq="2412")
     ev = dev[0].wait_event(["CTRL-REQ-SIM"], timeout=15)
@@ -322,6 +324,8 @@ def _test_ap_wpa2_eap_sim_ext(dev, apdev):
     if ev is None:
         raise Exception("EAP failure not reported")
     dev[0].request("DISCONNECT")
+    dev[0].wait_disconnected()
+    time.sleep(0.1)
 
     dev[0].select_network(id, freq="2412")
     ev = dev[0].wait_event(["CTRL-REQ-SIM"], timeout=15)
@@ -338,6 +342,8 @@ def _test_ap_wpa2_eap_sim_ext(dev, apdev):
     if ev is None:
         raise Exception("EAP failure not reported")
     dev[0].request("DISCONNECT")
+    dev[0].wait_disconnected()
+    time.sleep(0.1)
 
     dev[0].select_network(id, freq="2412")
     ev = dev[0].wait_event(["CTRL-REQ-SIM"], timeout=15)
@@ -354,6 +360,8 @@ def _test_ap_wpa2_eap_sim_ext(dev, apdev):
     if ev is None:
         raise Exception("EAP failure not reported")
     dev[0].request("DISCONNECT")
+    dev[0].wait_disconnected()
+    time.sleep(0.1)
 
     dev[0].select_network(id, freq="2412")
     ev = dev[0].wait_event(["CTRL-REQ-SIM"], timeout=15)
@@ -370,6 +378,8 @@ def _test_ap_wpa2_eap_sim_ext(dev, apdev):
     if ev is None:
         raise Exception("EAP failure not reported")
     dev[0].request("DISCONNECT")
+    dev[0].wait_disconnected()
+    time.sleep(0.1)
 
     dev[0].select_network(id, freq="2412")
     ev = dev[0].wait_event(["CTRL-REQ-SIM"], timeout=15)
@@ -386,6 +396,8 @@ def _test_ap_wpa2_eap_sim_ext(dev, apdev):
     if ev is None:
         raise Exception("EAP failure not reported")
     dev[0].request("DISCONNECT")
+    dev[0].wait_disconnected()
+    time.sleep(0.1)
 
     dev[0].select_network(id, freq="2412")
     ev = dev[0].wait_event(["CTRL-REQ-SIM"], timeout=15)
@@ -559,6 +571,7 @@ def _test_ap_wpa2_eap_aka_ext(dev, apdev):
         raise Exception("EAP failure not reported")
     dev[0].request("DISCONNECT")
     dev[0].wait_disconnected()
+    time.sleep(0.1)
 
     dev[0].select_network(id, freq="2412")
     ev = dev[0].wait_event(["CTRL-REQ-SIM"], timeout=15)
@@ -586,6 +599,7 @@ def _test_ap_wpa2_eap_aka_ext(dev, apdev):
         raise Exception("EAP failure not reported")
     dev[0].request("DISCONNECT")
     dev[0].wait_disconnected()
+    time.sleep(0.1)
 
     tests = [ ":UMTS-AUTH:00112233445566778899aabbccddeeff:00112233445566778899aabbccddeeff:0011223344",
               ":UMTS-AUTH:34",
@@ -611,6 +625,7 @@ def _test_ap_wpa2_eap_aka_ext(dev, apdev):
             raise Exception("EAP failure not reported")
         dev[0].request("DISCONNECT")
         dev[0].wait_disconnected()
+        time.sleep(0.1)
 
 def test_ap_wpa2_eap_aka_prime(dev, apdev):
     """WPA2-Enterprise connection using EAP-AKA'"""
@@ -1207,6 +1222,7 @@ def test_ap_wpa2_eap_tls_diff_ca_trust(dev, apdev):
                         only_add_network=True, scan_freq="2412")
 
     dev[0].request("DISCONNECT")
+    dev[0].wait_disconnected()
     dev[0].dump_monitor()
     dev[0].select_network(id, freq="2412")
 
@@ -1233,6 +1249,7 @@ def test_ap_wpa2_eap_tls_diff_ca_trust2(dev, apdev):
                         only_add_network=True, scan_freq="2412")
 
     dev[0].request("DISCONNECT")
+    dev[0].wait_disconnected()
     dev[0].dump_monitor()
     dev[0].select_network(id, freq="2412")
 
@@ -1254,6 +1271,7 @@ def test_ap_wpa2_eap_tls_diff_ca_trust3(dev, apdev):
                         ca_cert="auth_serv/ca.pem",
                         wait_connect=True, scan_freq="2412")
     dev[0].request("DISCONNECT")
+    dev[0].wait_disconnected()
     dev[0].dump_monitor()
     dev[0].set_network_quoted(id, "ca_cert", "auth_serv/ca-incorrect.pem")
     dev[0].select_network(id, freq="2412")
index 5d77aa676b92e882c2c8b0cfea6a4400beed37fb..eb3220619ac819c505dc8bf18459534bbded77a4 100644 (file)
@@ -708,12 +708,13 @@ def test_wpas_ctrl_disallow_aps(dev, apdev):
 
     dev[0].connect("test", key_mgmt="NONE", scan_freq="2412")
     hostapd.add_ap(apdev[1]['ifname'], params)
+    dev[0].scan_for_bss(apdev[1]['bssid'], freq="2412")
     dev[0].dump_monitor()
     if "OK" not in dev[0].request("SET disallow_aps bssid 00:11:22:33:44:55 bssid 00:22:33:44:55:66"):
         raise Exception("Failed to set disallow_aps")
     if "OK" not in dev[0].request("SET disallow_aps bssid " + apdev[0]['bssid']):
         raise Exception("Failed to set disallow_aps")
-    ev = dev[0].wait_connected(timeout=15, error="Reassociation timed out")
+    ev = dev[0].wait_connected(timeout=30, error="Reassociation timed out")
     if apdev[1]['bssid'] not in ev:
         raise Exception("Unexpected BSSID")