[PATCH 2/3] tests: add connecting-while-CSA tests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Johannes Berg <johannes.berg@xxxxxxxxx>

Add a few tests to validate what happens with connections
while an AP is doing CSA:
 - quiet to diff channel (shouldn't connect)
 - quiet to same channel (shouldn't connect)
 - non-quiet to diff channel (shouldn't connect)
 - non-quiet to same channel (should connect)

Signed-off-by: Johannes Berg <johannes.berg@xxxxxxxxx>
---
 tests/hwsim/test_ap_csa.py | 63 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/tests/hwsim/test_ap_csa.py b/tests/hwsim/test_ap_csa.py
index c9ac73291a21..f05eaf1d7ecd 100644
--- a/tests/hwsim/test_ap_csa.py
+++ b/tests/hwsim/test_ap_csa.py
@@ -193,3 +193,66 @@ def test_ap_csa_disable(dev, apdev):
     ap.enable()
     dev[0].wait_disconnected()
     dev[0].wait_connected()
+
+def _assoc_while_csa(dev, apdev, freq_to, blocktx):
+    params = {
+        "ssid": "ap-csa",
+        "hw_mode": "a",
+        "country_code": "FI",
+        "channel": "36",
+        "ieee80211n": "0",
+    }
+    ap = hostapd.add_ap(apdev[0], params)
+    count = 100 if blocktx else 20
+    delay = 1 + count / 10
+    cmd = f"CHAN_SWITCH {count} {freq_to}"
+    if blocktx:
+        cmd += " blocktx"
+    ap.request(cmd)
+
+    ev = ap.wait_event(["CTRL-EVENT-STARTED-CHANNEL-SWITCH"], timeout=10)
+    if ev is None:
+        raise Exception("Channel switch start event not seen")
+    if f"freq={freq_to}" not in ev:
+        raise Exception("Unexpected channel in CS started event")
+    try:
+        dev[0].connect("ap-csa", key_mgmt="NONE", scan_freq="5180",
+                       wait_connect=False)
+        if blocktx or freq_to != 5180:
+            ev = dev[0].wait_event(["CTRL-EVENT-SSID-TEMP-DISABLED",
+                                    "CTRL-EVENT-CONNECTED"], timeout=9)
+            if not ev: # this is fine, at least we didn't connect
+                return
+            if not "CTRL-EVENT-SSID-TEMP-DISABLED" in ev:
+                raise Exception("Erroneously connected!")
+            if not 'auth_failures=1' in ev:
+                raise Exception(f'Should have auth failures in "{ev}"')
+            # wait for CSA to finish and connect then
+            time.sleep(delay)
+            dev[0].connect("ap-csa", key_mgmt="NONE", scan_freq=str(freq_to))
+        else:
+            dev[0].wait_connected()
+            if freq_to != 5180:
+                wait_channel_switch(dev[0], freq_to)
+    finally:
+        dev[0].request("DISCONNECT")
+        clear_regdom(ap, dev)
+
+@long_duration_test
+def test_assoc_while_csa_same_blocktx(dev, apdev):
+    "Check we don't associate while AP is doing quiet CSA (same channel)"
+    _assoc_while_csa(dev, apdev, 5180, True)
+
+def test_assoc_while_csa_same(dev, apdev):
+    "Check we _do_ associate while AP is doing CSA (same channel)"
+    _assoc_while_csa(dev, apdev, 5180, False)
+
+@long_duration_test
+def test_assoc_while_csa_diff_blocktx(dev, apdev):
+    "Check we don't associate while AP is doing quiet CSA (different channel)"
+    _assoc_while_csa(dev, apdev, 5200, True)
+
+@long_duration_test
+def test_assoc_while_csa_diff(dev, apdev):
+    "Check we don't associate while AP is doing CSA (different channel)"
+    _assoc_while_csa(dev, apdev, 5200, False)
-- 
2.44.0


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux