[PATCH 5/5] hwsim: Skip CSA tests if the driver doesn't support it

Ilan Peer ilan.peer
Wed Jan 1 05:32:13 PST 2014


From: Andrei Otcheretianski <andrei.otcheretianski at intel.com>

Check wether wpa_supplicant or hostapd on the ap interface
support channel switch announcement and skip the tests
otherwise.

Signed-hostap: Andrei Otcheretianski <andrei.otcheretianski at intel.com>
---
 tests/hwsim/test_ap_csa.py |   22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/tests/hwsim/test_ap_csa.py b/tests/hwsim/test_ap_csa.py
index 9b2feb0..61ef86e 100644
--- a/tests/hwsim/test_ap_csa.py
+++ b/tests/hwsim/test_ap_csa.py
@@ -30,9 +30,21 @@ def switch_channel(ap, count, freq):
         raise Exception("Unexpected channel in CSA finished event")
     time.sleep(0.1)
 
+# This function checks wether the provided dev, which may be either
+# WpaSupplicant or Hostapd supports CSA
+def csa_supported(dev):
+    # For WpaSupplicant we check driver's capability with get_driver_status
+    if hasattr(dev, 'get_driver_status'):
+        res = dev.get_driver_status()
+        return (int(res['capa.flags'], 0) & 0x40000000) != 0
+    # Otherwise it's Hostapd and CSA support is published with STATUS command
+    return int(dev.get_status_field('csa_supported') or 0)
+
 def test_ap_csa_1_switch(dev, apdev):
     """AP Channel Switch, one switch"""
     ap = connect(dev[0], apdev)
+    if not csa_supported(ap):
+        return "skip"
 
     hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
     switch_channel(ap, 10, 2462)
@@ -41,6 +53,8 @@ def test_ap_csa_1_switch(dev, apdev):
 def test_ap_csa_2_switches(dev, apdev):
     """AP Channel Switch, two switches"""
     ap = connect(dev[0], apdev)
+    if not csa_supported(ap):
+        return "skip"
 
     hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
     switch_channel(ap, 10, 2462)
@@ -51,6 +65,8 @@ def test_ap_csa_2_switches(dev, apdev):
 def test_ap_csa_1_switch_count_0(dev, apdev):
     """AP Channel Switch, one switch with count 0"""
     ap = connect(dev[0], apdev)
+    if not csa_supported(ap):
+        return "skip"
 
     hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
     switch_channel(ap, 0, 2462)
@@ -59,6 +75,8 @@ def test_ap_csa_1_switch_count_0(dev, apdev):
 def test_ap_csa_2_switches_count_0(dev, apdev):
     """AP Channel Switch, two switches with count 0"""
     ap = connect(dev[0], apdev)
+    if not csa_supported(ap):
+        return "skip"
 
     hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
     switch_channel(ap, 0, 2462)
@@ -69,6 +87,8 @@ def test_ap_csa_2_switches_count_0(dev, apdev):
 def test_ap_csa_1_switch_count_1(dev, apdev):
     """AP Channel Switch, one switch with count 1"""
     ap = connect(dev[0], apdev)
+    if not csa_supported(ap):
+        return "skip"
 
     hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
     switch_channel(ap, 1, 2462)
@@ -77,6 +97,8 @@ def test_ap_csa_1_switch_count_1(dev, apdev):
 def test_ap_csa_2_switches_count_1(dev, apdev):
     """AP Channel Switch, two switches with count 1"""
     ap = connect(dev[0], apdev)
+    if not csa_supported(ap):
+        return "skip"
 
     hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
     switch_channel(ap, 1, 2462)
-- 
1.7.10.4




More information about the Hostap mailing list