[PATCH] hwsim tests: add test to check disconnect in powersave

Johannes Berg johannes
Fri Jan 9 02:48:16 PST 2015


From: Johannes Berg <johannes.berg at intel.com>

The kernel had two bugs (one in hwsim and one more important
one in mac80211) in this area, add a test to make sure we can
disconnect without any kernel issues while in powersave.

Change-Id: Iec74967a54926e718af2935a4c9c837c6ce3252c
Signed-off-by: Johannes Berg <johannes.berg at intel.com>
---
 tests/hwsim/hwsim_utils.py  |  5 +++--
 tests/hwsim/test_ap_open.py | 25 +++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/tests/hwsim/hwsim_utils.py b/tests/hwsim/hwsim_utils.py
index edf0a4242472..842e8d09df10 100644
--- a/tests/hwsim/hwsim_utils.py
+++ b/tests/hwsim/hwsim_utils.py
@@ -115,7 +115,8 @@ def run_connectivity_test(dev1, dev2, tos, dev1group=False, dev2group=False,
 
 def test_connectivity(dev1, dev2, dscp=None, tos=None, max_tries=1,
                       dev1group=False, dev2group=False,
-                      ifname1=None, ifname2=None, config=True):
+                      ifname1=None, ifname2=None, config=True,
+                      ignore_errors=False):
     if dscp:
         tos = dscp << 2
     if not tos:
@@ -133,7 +134,7 @@ def test_connectivity(dev1, dev2, dscp=None, tos=None, max_tries=1,
             last_err = e
             if i + 1 < max_tries:
                 time.sleep(1)
-    if not success:
+    if not success and not ignore_errors:
         raise Exception(last_err)
 
 def test_connectivity_iface(dev1, dev2, ifname, dscp=None, tos=None,
diff --git a/tests/hwsim/test_ap_open.py b/tests/hwsim/test_ap_open.py
index 7a646b8ab407..f4b3bcfb023f 100644
--- a/tests/hwsim/test_ap_open.py
+++ b/tests/hwsim/test_ap_open.py
@@ -201,3 +201,28 @@ def test_ap_open_out_of_memory(dev, apdev):
     # verify that a new interface can still be added when memory allocation does
     # not fail
     hostapd.add_ap(apdev[1]['ifname'], { "ssid": "open" })
+
+def test_ap_open_disconnect_in_ps(dev, apdev):
+    """disconnect with the client in PS to regression-test a kernel bug"""
+    hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "open" })
+    dev[0].connect("open", key_mgmt="NONE", scan_freq="2412",
+                   bg_scan_period="0")
+    ev = hapd.wait_event([ "AP-STA-CONNECTED" ], timeout=5)
+    if ev is None:
+        raise Exception("No connection event received from hostapd")
+
+    def set_ps(val):
+        psf = open('/sys/kernel/debug/ieee80211/phy0/hwsim/ps', 'w')
+        psf.write('%d\n' % val)
+        psf.close()
+
+    # set to manual PS-Poll
+    set_ps(3)
+    try:
+        # just use this to inject some traffic
+        hwsim_utils.test_connectivity(dev[0], hapd, ignore_errors=True)
+
+        # disconnect - with traffic pending - shouldn't cause kernel warnings
+        dev[0].request("DISCONNECT")
+    finally:
+        set_ps(0)
-- 
2.1.1




More information about the Hostap mailing list