tests: Add connecting-while-CSA tests
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@intel.com>
This commit is contained in:
parent
d43eb71da7
commit
41fd49958d
1 changed files with 64 additions and 0 deletions
|
@ -193,3 +193,67 @@ 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")
|
||||
dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=1)
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue