[PATCH 6/7] tests: wmm-ac: test wmm_ac_status and roaming case

Ilan Peer ilan.peer at intel.com
Sun Dec 28 21:15:02 EST 2014


From: Eliad Peller <eliad at wizery.com>

Make sure the wmm_ac_status command reflects correctly
the existing tspecs after add_ts/del_ts commands.

Add a new test to verify all tspecs are removed on
roaming (while ieee802.11r is not implemented).

Signed-off-by: Eliad Peller <eliadx.peller at intel.com>
---
 tests/hwsim/test_wpas_wmm_ac.py | 24 +++++++++++++++++++++---
 tests/hwsim/wpasupplicant.py    | 16 ++++++++++++++++
 2 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/tests/hwsim/test_wpas_wmm_ac.py b/tests/hwsim/test_wpas_wmm_ac.py
index f68866e..d3c4007 100644
--- a/tests/hwsim/test_wpas_wmm_ac.py
+++ b/tests/hwsim/test_wpas_wmm_ac.py
@@ -20,12 +20,12 @@ def add_wmm_ap(apdev, acm_list):
     for ac in acm_list:
         params["wmm_ac_%s_acm" % (ac.lower())] = "1"
 
-    return hostapd.add_ap(apdev[0]['ifname'], params)
+    return hostapd.add_ap(apdev['ifname'], params)
 
 def test_tspec(dev, apdev):
     """Basic addts/delts tests"""
     # configure ap with VO and VI requiring admission-control
-    hapd = add_wmm_ap(apdev, ["VO", "VI"])
+    hapd = add_wmm_ap(apdev[0], ["VO", "VI"])
     dev[0].connect("wmm_ac", key_mgmt="NONE", scan_freq="2462")
     hwsim_utils.test_connectivity(dev[0], hapd)
     status = dev[0].request("WMM_AC_STATUS")
@@ -112,7 +112,7 @@ def test_tspec(dev, apdev):
 def test_tspec_protocol(dev, apdev):
     """Protocol tests for addts/delts"""
     # configure ap with VO and VI requiring admission-control
-    hapd = add_wmm_ap(apdev, ["VO", "VI"])
+    hapd = add_wmm_ap(apdev[0], ["VO", "VI"])
     dev[0].connect("wmm_ac", key_mgmt="NONE", scan_freq="2462")
 
     dev[0].dump_monitor()
@@ -245,3 +245,21 @@ def test_tspec_not_enabled(dev, apdev):
     msg['bssid'] = apdev[0]['bssid']
     msg['payload'] = struct.pack('BBBB', 17, 2, 0, 0)
     hapd.mgmt_tx(msg)
+
+def test_tspec_ap_roam_open(dev, apdev):
+    """Roam between two open APs while having tspecs"""
+    hapd0 = add_wmm_ap(apdev[0], ["VO", "VI"])
+    dev[0].connect("wmm_ac", key_mgmt="NONE")
+    hwsim_utils.test_connectivity(dev[0], hapd0)
+    dev[0].add_ts(5, 6)
+
+    hapd1 = add_wmm_ap(apdev[1], ["VO", "VI"])
+    dev[0].scan(type="ONLY", freq="2462")
+    dev[0].roam(apdev[1]['bssid'])
+    hwsim_utils.test_connectivity(dev[0], hapd1)
+    if dev[0].tspecs():
+        raise Exception("TSPECs weren't deleted on roaming")
+
+    dev[0].scan(type="ONLY", freq="2462")
+    dev[0].roam(apdev[0]['bssid'])
+    hwsim_utils.test_connectivity(dev[0], hapd0)
diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py
index 3f5bd6f..75f0458 100644
--- a/tests/hwsim/wpasupplicant.py
+++ b/tests/hwsim/wpasupplicant.py
@@ -723,6 +723,15 @@ class WpaSupplicant:
             raise Exception("Failed to request TDLS teardown")
         return None
 
+    """return (tsid, up) tuples representing current tspecs"""
+    def tspecs(self):
+        res = self.request("WMM_AC_STATUS")
+        tspecs = re.findall(r"TSID=(\d+) UP=(\d+)", res)
+        tspecs = [tuple(map(int, tspec)) for tspec in tspecs]
+
+        logger.debug("tspecs: " + str(tspecs))
+        return tspecs
+
     def add_ts(self, tsid, up, direction="downlink", expect_failure=False,
                extra=None):
         params = {
@@ -754,6 +763,9 @@ class WpaSupplicant:
         if "tsid=%d" % (tsid) not in ev:
             raise Exception("ADDTS failed (invalid tsid in TSPEC-ADDED)")
 
+        if not (tsid, up) in self.tspecs():
+            raise Exception("ADDTS failed (tsid not in tspec list)")
+
     def del_ts(self, tsid):
         if self.request("WMM_AC_DELTS %d" % (tsid)).strip() != "OK":
             raise Exception("DELTS failed")
@@ -764,6 +776,10 @@ class WpaSupplicant:
         if "tsid=%d" % (tsid) not in ev:
             raise Exception("DELTS failed (invalid tsid in TSPEC-REMOVED)")
 
+        tspecs = [(t, u) for (t, u) in self.tspecs() if t == tsid]
+        if tspecs:
+            raise Exception("DELTS failed (still in tspec list)")
+
     def connect(self, ssid=None, ssid2=None, **kwargs):
         logger.info("Connect STA " + self.ifname + " to AP")
         id = self.add_network()
-- 
1.8.3.2



More information about the HostAP mailing list