]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Verify DFS channel switch both in and outside ETSI
authorJouni Malinen <j@w1.fi>
Sat, 13 May 2017 17:01:06 +0000 (20:01 +0300)
committerJouni Malinen <j@w1.fi>
Sat, 13 May 2017 17:01:44 +0000 (20:01 +0300)
The behavior will be different based on the uniform spreading
requirement.

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

index c6bce1c971ea24043cebabf5a56fdd40d0191b82..91c78088192ebe256018bacae48010559fb1696d 100644 (file)
@@ -28,12 +28,12 @@ def wait_dfs_event(hapd, event, timeout):
 
 def start_dfs_ap(ap, allow_failure=False, ssid="dfs", ht=True, ht40=False,
                  ht40minus=False, vht80=False, vht20=False, chanlist=None,
-                 channel=None):
+                 channel=None, country="FI"):
     ifname = ap['ifname']
     logger.info("Starting AP " + ifname + " on DFS channel")
     hapd = hostapd.add_ap(ap, {}, no_enable=True)
     hapd.set("ssid", ssid)
-    hapd.set("country_code", "FI")
+    hapd.set("country_code", country)
     hapd.set("ieee80211d", "1")
     hapd.set("ieee80211h", "1")
     hapd.set("hw_mode", "a")
@@ -85,7 +85,7 @@ def test_dfs(dev, apdev):
     """DFS CAC functionality on clear channel"""
     try:
         hapd = None
-        hapd = start_dfs_ap(apdev[0], allow_failure=True)
+        hapd = start_dfs_ap(apdev[0], allow_failure=True, country="US")
 
         ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 70)
         if "success=1" not in ev:
@@ -134,6 +134,75 @@ def test_dfs(dev, apdev):
         subprocess.call(['iw', 'reg', 'set', '00'])
         dev[0].flush_scan_cache()
 
+def test_dfs_etsi(dev, apdev, params):
+    """DFS and uniform spreading requirement for ETSI [long]"""
+    if not params['long']:
+        raise HwsimSkip("Skip test case with long duration due to --long not specified")
+    try:
+        hapd = None
+        hapd = start_dfs_ap(apdev[0], allow_failure=True)
+
+        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")
+
+        state = hapd.get_status_field("state")
+        if state != "ENABLED":
+            raise Exception("Unexpected interface state")
+
+        freq = hapd.get_status_field("freq")
+        if freq != "5260":
+            raise Exception("Unexpected frequency")
+
+        dev[0].connect("dfs", key_mgmt="NONE")
+        hwsim_utils.test_connectivity(dev[0], hapd)
+
+        hapd.request("RADAR DETECTED freq=%s ht_enabled=1 chan_width=1" % freq)
+        ev = hapd.wait_event(["DFS-RADAR-DETECTED"], timeout=5)
+        if ev is None:
+            raise Exception("DFS-RADAR-DETECTED event not reported")
+        if "freq=%s" % freq not in ev:
+            raise Exception("Incorrect frequency in radar detected event: " + ev)
+        ev = hapd.wait_event(["DFS-NEW-CHANNEL"], timeout=5)
+        if ev is None:
+            raise Exception("DFS-NEW-CHANNEL event not reported")
+        if "freq=%s" % freq in ev:
+            raise Exception("Channel did not change after radar was detected")
+
+        ev = hapd.wait_event(["AP-CSA-FINISHED", "DFS-CAC-START"], timeout=10)
+        if ev is None:
+            raise Exception("AP-CSA-FINISHED or DFS-CAC-START event not reported")
+        if "DFS-CAC-START" in ev:
+            # The selected new channel requires CAC
+            ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 70)
+            if "success=1" not in ev:
+                raise Exception("CAC failed")
+
+            ev = hapd.wait_event(["AP-ENABLED"], timeout=5)
+            if not ev:
+                raise Exception("AP setup timed out")
+            ev = hapd.wait_event(["AP-STA-CONNECTED"], timeout=30)
+            if not ev:
+                raise Exception("STA did not reconnect on new DFS channel")
+        else:
+            # The new channel did not require CAC - try again
+            if "freq=%s" % freq in ev:
+                raise Exception("Channel did not change after radar was detected(2)")
+            time.sleep(1)
+        hwsim_utils.test_connectivity(dev[0], hapd)
+    finally:
+        dev[0].request("DISCONNECT")
+        if hapd:
+            hapd.request("DISABLE")
+        subprocess.call(['iw', 'reg', 'set', '00'])
+        dev[0].flush_scan_cache()
+
 def test_dfs_radar(dev, apdev):
     """DFS CAC functionality with radar detected"""
     try: