[PATCH 3/3] tests: Add rfkill tests for P2P Device operations

Ilan Peer ilan.peer at intel.com
Thu Dec 17 05:54:12 PST 2015


Add a couple of tests for rfkill with P2P Device operations
(with and without P2P Device interface).

Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
 tests/hwsim/test_rfkill.py | 49 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/tests/hwsim/test_rfkill.py b/tests/hwsim/test_rfkill.py
index 425b40f..887c865 100644
--- a/tests/hwsim/test_rfkill.py
+++ b/tests/hwsim/test_rfkill.py
@@ -14,6 +14,7 @@ import hwsim_utils
 from wpasupplicant import WpaSupplicant
 from rfkill import RFKill
 from utils import HwsimSkip
+from hwsim import HWSimRadio
 
 def get_rfkill(dev):
     phy = dev.get_driver_status_field("phyname")
@@ -116,6 +117,54 @@ def test_rfkill_autogo(dev, apdev):
         rfk0.unblock()
         rfk1.unblock()
 
+def _test_rfkill_p2p_discovery(dev0, dev1):
+    """rfkill block/unblock P2P Discovery"""
+    rfk0 = get_rfkill(dev0)
+    rfk1 = get_rfkill(dev1)
+
+    try:
+        addr0 = dev0.p2p_dev_addr()
+
+        logger.info("rfkill block 0")
+        rfk0.block()
+        logger.info("rfkill block 1")
+        rfk1.block()
+
+	if "OK" in dev0.p2p_listen():
+	    raise Exception("P2P Listen success although in rfkill");
+
+	if "OK" in dev1.p2p_find():
+	    raise Exception("P2P Find success although in rfkill");
+
+        logger.info("rfkill unblock 0")
+        rfk0.unblock()
+        logger.info("rfkill unblock 1")
+        rfk1.unblock()
+
+        time.sleep(1)
+
+	if not "OK" in dev0.p2p_listen():
+	    raise Exception("P2P Listen failed after unblocking rfkill");
+
+	if not dev1.discover_peer(addr0, social=True):
+	    raise Exception("Failed to discover peer after unblocking rfkill");
+
+    finally:
+        rfk0.unblock()
+        rfk1.unblock()
+
+def test_rfkill_p2p_discovery(dev, apdev):
+    """rfkill block/unblock P2P Discovery"""
+    _test_rfkill_p2p_discovery(dev[0], dev[1])
+
+def test_rfkill_p2p_discovery_p2p_dev(dev, apdev):
+    """rfkill block/unblock P2P Discovery with P2P Device"""
+    with HWSimRadio(use_p2p_device=True) as (radio, iface):
+        wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
+        wpas.interface_add(iface)
+	_test_rfkill_p2p_discovery(dev[0], wpas)
+	_test_rfkill_p2p_discovery(wpas, dev[1])
+
 def test_rfkill_hostapd(dev, apdev):
     """rfkill block/unblock during and prior to hostapd operations"""
     hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "open" })
-- 
1.9.1




More information about the Hostap mailing list