[PATCH v2 2/2] tests: hwsim: add dfs_chan_switch_precac
Janusz Dziedzic
janusz.dziedzic at gmail.com
Sun Oct 11 15:01:53 EDT 2020
Add test case that will check preCAC,
which is available for EU regulatory
domain.
Check if preCAC is not used for US.
Signed-off-by: Janusz Dziedzic <janusz.dziedzic at gmail.com>
---
tests/hwsim/test_dfs.py | 71 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 71 insertions(+)
diff --git a/tests/hwsim/test_dfs.py b/tests/hwsim/test_dfs.py
index 3efe6bb2d..137b1be93 100644
--- a/tests/hwsim/test_dfs.py
+++ b/tests/hwsim/test_dfs.py
@@ -652,3 +652,74 @@ def test_dfs_chan_switch(dev, apdev):
hwsim_utils.test_connectivity(dev[0], hapd)
finally:
clear_regdom(hapd, dev)
+
+def dfs_chan_switch_precac(dev, apdev, country):
+ """DFS channel switch pre CAC"""
+ try:
+ hapd = None
+
+ # Toggle regulatory - clean all preCAC
+ hostapd.cmd_execute(apdev[0], ['iw', 'reg', 'set', 'US'])
+
+ hapd = start_dfs_ap(apdev[0], country=country)
+
+ ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 70)
+ if "success=1" not in ev:
+ raise Exception("CAC failed")
+ if "freq=5260" not in ev:
+ raise Exception("Unexpected DFS freq result")
+ ev = hapd.wait_event(["AP-ENABLED"], timeout=5)
+ if not ev:
+ raise Exception("AP setup timed out")
+ freq = hapd.get_status_field("freq")
+ if freq != "5260":
+ raise Exception("Unexpected frequency")
+
+ # TODO add/connect station here
+ # Today skip this step while dev[0].connect()
+ # for some reason toggle regulatory to US
+ # and clean preCAC
+
+ # Back to non DFS channel
+ if "OK" not in hapd.request("CHAN_SWITCH 5 5180 ht"):
+ raise Exception("CHAN_SWITCH 5180 failed")
+
+ ev = hapd.wait_event(["AP-CSA-FINISHED"], timeout=5)
+ if not ev:
+ raise Exception("No CSA finished event - 5180")
+ freq = hapd.get_status_field("freq")
+ if freq != "5180":
+ raise Exception("Unexpected frequency")
+
+ # Today cfg80211 first send AP-CSA-FINISHED and next
+ # DFS-PRE-CAC-EXPIRED
+ ev = hapd.wait_event(["DFS-PRE-CAC-EXPIRED"], timeout=3)
+ if not ev and country == 'US':
+ raise Exception("US - no CAC-EXPIRED event")
+
+ # Back again to DFS channel (CAC passed)
+ if "OK" not in hapd.request("CHAN_SWITCH 5 5260 ht"):
+ raise Exception("CHAN_SWITCH 5260 failed")
+
+ if country == 'US':
+ # For non EU we should start CAC again
+ ev = wait_dfs_event(hapd, "DFS-CAC-START", 5)
+ if not ev:
+ raise Exception("No DFS CAC start event")
+ else:
+ # For EU preCAC should be used
+ ev = wait_dfs_event(hapd, "AP-CSA-FINISHED", 5)
+ if not ev:
+ raise Exception("No CSA finished event - 5260")
+ finally:
+ clear_regdom(hapd, dev)
+
+ at long_duration_test
+def test_dfs_eu_chan_switch_precac(dev, apdev):
+ """DFS channel switch pre CAC - ETSI domain"""
+ dfs_chan_switch_precac(dev, apdev, 'PL')
+
+ at long_duration_test
+def test_dfs_us_chan_switch_precac(dev, apdev):
+ """DFS channel switch pre CAC - FCC domain"""
+ dfs_chan_switch_precac(dev, apdev, 'US')
--
2.17.1
More information about the Hostap
mailing list