[PATCH 13/13] tests: add wpas wmm-ac test

Ilan Peer ilan.peer at intel.com
Tue Oct 21 08:16:52 EDT 2014


From: Eliad Peller <eliad at wizery.com>

Add basic wpas tests for wmm-ac tspecs addition/deletion

Signed-off-by: Eliad Peller <eliadx.peller at intel.com>
---
 tests/hwsim/test_wpas_wmm_ac.py | 54 +++++++++++++++++++++++++++++++++++++++++
 tests/hwsim/wpasupplicant.py    | 30 +++++++++++++++++++++++
 2 files changed, 84 insertions(+)
 create mode 100644 tests/hwsim/test_wpas_wmm_ac.py

diff --git a/tests/hwsim/test_wpas_wmm_ac.py b/tests/hwsim/test_wpas_wmm_ac.py
new file mode 100644
index 0000000..bd076fe
--- /dev/null
+++ b/tests/hwsim/test_wpas_wmm_ac.py
@@ -0,0 +1,54 @@
+# Test cases for wpa_supplicant wmm-ac operations
+# Copyright (c) 2014, Intel Corporation
+#
+# This software may be distributed under the terms of the BSD license.
+# See README for more details.
+
+import logging
+logger = logging.getLogger()
+
+import hwsim_utils
+import hostapd
+
+def add_wmm_ap(apdev, acm_list):
+    params = { "ssid": "wmm_ac",
+               "hw_mode": "g",
+               "channel": "11",
+               "wmm_enabled" : "1"}
+
+    for ac in acm_list:
+        params["wmm_ac_%s_acm" % (ac.lower())] = "1"
+
+    return hostapd.add_ap(apdev[0]['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"])
+    dev[0].connect("wmm_ac", key_mgmt="NONE", scan_freq="2462")
+    hwsim_utils.test_connectivity(dev[0], hapd)
+
+    tsid = 5
+
+    # make sure we fail when the ac is not configured for acm
+    try:
+        dev[0].add_ts(tsid, 3)
+        raise Exception("ADDTS succeeded although it should have failed")
+    except Exception, e:
+        if not str(e).startswith("ADDTS failed"):
+            raise
+
+    # add tspec for UP=6
+    dev[0].add_ts(tsid, 6)
+
+    # using the same tsid for a different ac is invalid
+    try:
+        dev[0].add_ts(tsid, 5)
+        raise Exception("ADDTS succeeded although it should have failed")
+    except Exception, e:
+        if not str(e).startswith("ADDTS failed"):
+            raise
+
+    # update the tspec for a different UP of the same ac
+    dev[0].add_ts(tsid, 7)
+    dev[0].del_ts(tsid)
diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py
index 7734f2a..9fc9f17 100644
--- a/tests/hwsim/wpasupplicant.py
+++ b/tests/hwsim/wpasupplicant.py
@@ -700,6 +700,36 @@ class WpaSupplicant:
             raise Exception("Failed to request TDLS teardown")
         return None
 
+    def add_ts(self, tsid, up):
+        params = {
+            "sba": 9000,
+            "nominal_msdu_size": 1500,
+            "min_phy_rate": 6000000,
+            "mean_data_rate": 1500,
+        }
+        cmd = "WMM_AC_ADDTS downlink tsid=%d up=%d" % (tsid, up)
+        for (key, value) in params.iteritems():
+            cmd += " %s=%d" % (key, value)
+
+        if self.request(cmd).strip() != "OK":
+            raise Exception("ADDTS failed (tsid=%d up=%d)" % (tsid, up))
+
+        ev = self.wait_event(["TSPEC-ADDED"], timeout=1)
+        if ev is None:
+            raise Exception("ADDTS failed (time out)")
+        if "tsid=%d" % (tsid) not in ev:
+            raise Exception("ADDTS failed (invalid tsid in TSPEC-ADDED)")
+
+    def del_ts(self, tsid):
+        if self.request("WMM_AC_DELTS %d" % (tsid)).strip() != "OK":
+            raise Exception("DELTS failed")
+
+        ev = self.wait_event(["TSPEC-REMOVED"], timeout=1)
+        if ev is None:
+            raise Exception("DELTS failed (time out)")
+        if "tsid=%d" % (tsid) not in ev:
+            raise Exception("DELTS failed (invalid tsid in TSPEC-REMOVED)")
+
     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