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

login
register
mail settings
Submitter Ilan Peer
Date Jan. 1, 2014, 1:32 p.m.
Message ID <1388583133-14842-6-git-send-email-ilan.peer@intel.com>
Download mbox | patch
Permalink /patch/305965/
State New
Headers show

Comments

Ilan Peer - Jan. 1, 2014, 1:32 p.m.
From: Andrei Otcheretianski <andrei.otcheretianski@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@intel.com>
---
 tests/hwsim/test_ap_csa.py |   22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

Patch

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)