[PATCH 2/2] tests: add basic PS tests for ap_open

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ap_open_sta_ps checks whether a STA told its hardware to
enter power save after enabling power save.

ap_open_ps_mc_buf checks whether an AP properly buffers
and releases mcast frames when a STA with PS active is
associated.

Signed-off-by: Thomas Pedersen <thomas@xxxxxxxxxxxx>
---
 tests/hwsim/test_ap_open.py | 57 +++++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/tests/hwsim/test_ap_open.py b/tests/hwsim/test_ap_open.py
index 0d83438c4..a260226af 100644
--- a/tests/hwsim/test_ap_open.py
+++ b/tests/hwsim/test_ap_open.py
@@ -491,6 +491,63 @@ def test_ap_open_disconnect_in_ps(dev, apdev, params):
         if state != 2:
             raise Exception("Didn't observe TIM bit getting set and unset (state=%d)" % state)
 
+def test_ap_open_sta_ps(dev, apdev, params):
+    """test sta PS operation"""
+    hapd = hostapd.add_ap(apdev[0], {"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")
+
+    time.sleep(0.2)
+    # enable power save mode
+    dev[0].cmd_execute(['iw', 'dev', dev[0].ifname, 'set', 'power_save', 'on'])
+
+    hwsim_utils.test_connectivity(dev[0], hapd)
+    # give time to enter PS
+    time.sleep(0.2)
+
+    try:
+        phyname = dev[0].get_driver_status_field("phyname")
+        hw_conf = '/sys/kernel/debug/ieee80211/' + phyname + '/hw_conf'
+        with open(hw_conf, 'r') as f:
+            hw_conf = int(f.read())
+
+        if not hw_conf & 2:
+            raise Exception("STA didn't enter Power Save!")
+    except FileNotFoundError:
+        raise HwsimSkip("kernel doesn't support inspecting HW PS state")
+
+def test_ap_open_ps_mc_buf(dev, apdev, params):
+    """test sta PS operation"""
+    hapd = hostapd.add_ap(apdev[0], {"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")
+
+    # enable power save mode
+    dev[0].cmd_execute(['iw', 'dev', dev[0].ifname, 'set', 'power_save', 'on'])
+    # give time to enter PS
+    time.sleep(0.3)
+
+    # test mcast frames are released
+    hwsim_utils.test_mcast_connectivity(hapd, dev[0])
+
+    # check frames were buffered until DTIM
+    out = run_tshark(os.path.join(params['logdir'], "hwsim0.pcapng"),
+                     "wlan.fc.type_subtype == 0x0008", ["wlan.tim.bmapctl.multicast"])
+
+    for line in out.splitlines():
+        buffered_mcast = int(line)
+        if buffered_mcast == 1:
+            break
+
+    if buffered_mcast != 1:
+        raise Exception("AP didn't buffer mcast frames!")
+
 @remote_compatible
 def test_ap_open_select_network(dev, apdev):
     """Open mode connection and SELECT_NETWORK to change network"""
-- 
2.20.1


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux