tests: Increase DFS coverage even without hwsim support

This allows some more of the hostapd DFS operations to be executed even
before mac80211_hwsim supports CAC.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2014-03-22 17:14:44 +02:00
parent 986eedcdc4
commit 4f62bfefa4

View file

@ -24,12 +24,8 @@ def wait_dfs_event(hapd, event, timeout):
raise Exception("Unexpected DFS event")
return ev
def start_dfs_ap(ap):
def start_dfs_ap(ap, allow_failure=False):
ifname = ap['ifname']
logger.info("Reset regulatory setup")
subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
time.sleep(1)
subprocess.call(['sudo', 'iw', 'reg', 'set', 'FI'])
logger.info("Starting AP " + ifname + " on DFS channel")
hapd_global = hostapd.HostapdGlobal()
hapd_global.remove(ifname)
@ -52,15 +48,21 @@ def start_dfs_ap(ap):
state = hapd.get_status_field("state")
if state != "DFS":
raise Exception("Unexpected interface state")
if allow_failure:
logger.info("Interface state not DFS: " + state)
return None
raise Exception("Unexpected interface state: " + state)
return hapd
def test_dfs(dev, apdev):
"""DFS CAC functionality on clear channel"""
try:
hapd = start_dfs_ap(apdev[0], allow_failure=True)
if hapd is None:
if not os.path.exists("dfs"):
return "skip"
hapd = start_dfs_ap(apdev[0])
raise Exception("Failed to start DFS AP")
ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 70)
if "success=1" not in ev:
@ -82,11 +84,15 @@ def test_dfs(dev, apdev):
#TODO: need to fix hwsim for DFS?!
#dev[0].connect("dfs", key_mgmt="NONE")
finally:
subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
def test_dfs_radar(dev, apdev):
"""DFS CAC functionality with radar detected"""
if not os.path.exists("dfs"):
return "skip"
try:
hapd = start_dfs_ap(apdev[0])
hapd.request("RADAR DETECTED freq=5260 ht_enabled=1 chan_width=1")
@ -126,3 +132,13 @@ def test_dfs_radar(dev, apdev):
#TODO: need to fix hwsim for DFS?!
#dev[0].connect("dfs", key_mgmt="NONE")
finally:
subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
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.request("RADAR DETECTED freq=5260 ht_enabled=1 chan_width=1")
hapd.request("RADAR DETECTED freq=2412 ht_enabled=1 chan_width=1")