X-Git-Url: http://www.project-moonshot.org/gitweb/?p=mech_eap.git;a=blobdiff_plain;f=libeap%2Ftests%2Fhwsim%2Ftest_dfs.py;h=75a3c257eced930c42593bfd6eab2d7895816d82;hp=592736e3a334508ac6bcf17b6125d24c0cba17ca;hb=d1dd9aae6741e74f20bfc35e1db598652680279d;hpb=bd3bd69af16ab99706ba70ed11a3e291e968e5c6 diff --git a/libeap/tests/hwsim/test_dfs.py b/libeap/tests/hwsim/test_dfs.py index 592736e..75a3c25 100644 --- a/libeap/tests/hwsim/test_dfs.py +++ b/libeap/tests/hwsim/test_dfs.py @@ -4,6 +4,7 @@ # This software may be distributed under the terms of the BSD license. # See README for more details. +from remotehost import remote_compatible import os import subprocess import time @@ -26,16 +27,11 @@ def wait_dfs_event(hapd, event, timeout): return ev def start_dfs_ap(ap, allow_failure=False, ssid="dfs", ht=True, ht40=False, - ht40minus=False, vht80=False, vht20=False, chanlist=None): + ht40minus=False, vht80=False, vht20=False, chanlist=None, + channel=None): ifname = ap['ifname'] logger.info("Starting AP " + ifname + " on DFS channel") - hapd_global = hostapd.HostapdGlobal() - hapd_global.remove(ifname) - hapd_global.add(ifname) - hapd = hostapd.Hostapd(ifname) - if not hapd.ping(): - raise Exception("Could not ping hostapd") - hapd.set_defaults() + hapd = hostapd.add_ap(ap, {}, no_enable=True) hapd.set("ssid", ssid) hapd.set("country_code", "FI") hapd.set("ieee80211d", "1") @@ -59,6 +55,8 @@ def start_dfs_ap(ap, allow_failure=False, ssid="dfs", ht=True, ht40=False, hapd.set("vht_oper_centr_freq_seg0_idx", "0") if chanlist: hapd.set("chanlist", chanlist) + if channel: + hapd.set("channel", str(channel)) hapd.enable() ev = wait_dfs_event(hapd, "DFS-CAC-START", 5) @@ -115,18 +113,18 @@ def test_dfs(dev, apdev): if ev is None: raise Exception("DFS-RADAR-DETECTED event not reported") if "freq=5260" not in ev: - raise Exception("Incorrect frequency in radar detected event: " + ev); + raise Exception("Incorrect frequency in radar detected event: " + ev) ev = hapd.wait_event(["DFS-NEW-CHANNEL"], timeout=70) if ev is None: raise Exception("DFS-NEW-CHANNEL event not reported") if "freq=5260" in ev: - raise Exception("Channel did not change after radar was detected"); + raise Exception("Channel did not change after radar was detected") ev = hapd.wait_event(["AP-CSA-FINISHED"], timeout=70) if ev is None: raise Exception("AP-CSA-FINISHED event not reported") if "freq=5260" in ev: - raise Exception("Channel did not change after radar was detected(2)"); + raise Exception("Channel did not change after radar was detected(2)") time.sleep(1) hwsim_utils.test_connectivity(dev[0], hapd) finally: @@ -216,10 +214,11 @@ def test_dfs_radar(dev, apdev): subprocess.call(['iw', 'reg', 'set', '00']) dev[0].flush_scan_cache() +@remote_compatible def test_dfs_radar_on_non_dfs_channel(dev, apdev): """DFS radar detection test code on non-DFS channel""" params = { "ssid": "radar" } - hapd = hostapd.add_ap(apdev[0]['ifname'], params) + hapd = hostapd.add_ap(apdev[0], params) hapd.request("RADAR DETECTED freq=5260 ht_enabled=1 chan_width=1") hapd.request("RADAR DETECTED freq=2412 ht_enabled=1 chan_width=1") @@ -400,3 +399,39 @@ def test_dfs_radar_ht40minus(dev, apdev): hapd.request("DISABLE") subprocess.call(['iw', 'reg', 'set', '00']) dev[0].flush_scan_cache() + +def test_dfs_ht40_minus(dev, apdev, params): + """DFS CAC functionality on channel 104 HT40- [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, ht40minus=True, + channel=104) + + ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 70) + if "success=1" not in ev: + raise Exception("CAC failed") + if "freq=5520" 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 != "5520": + raise Exception("Unexpected frequency") + + dev[0].connect("dfs", key_mgmt="NONE", scan_freq="5520") + 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()