aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJouni Malinen <jouni@qca.qualcomm.com>2016-01-04 21:25:26 (GMT)
committerJouni Malinen <j@w1.fi>2016-01-04 21:25:26 (GMT)
commitde8a45b6cee9757da6516c07780c572ae75d5bf0 (patch)
tree09b9534398feae4392e089c6de8b56653e48c96f /tests
parentaeb408fff1e227e3bbc957661cf70f4531a75179 (diff)
downloadhostap-de8a45b6cee9757da6516c07780c572ae75d5bf0.zip
hostap-de8a45b6cee9757da6516c07780c572ae75d5bf0.tar.gz
hostap-de8a45b6cee9757da6516c07780c572ae75d5bf0.tar.bz2
tests: Make P2P discovery on non-social channel cases more robust
The test cases discovery_ctrl_char_in_devname and discovery_group_client tried to allow three P2P_FIND instances to be used before reporting an error. However, this did not really work properly since the second and third attempts would likely fail to start the initial special P2P_FIND scan due to an already ongoing p2p_scan operation. Fix this by stopping the previous P2P_FIND and waiting for the scan to complete if a retry is needed. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/hwsim/test_p2p_discovery.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/hwsim/test_p2p_discovery.py b/tests/hwsim/test_p2p_discovery.py
index c102fcc..22ce173 100644
--- a/tests/hwsim/test_p2p_discovery.py
+++ b/tests/hwsim/test_p2p_discovery.py
@@ -124,7 +124,9 @@ def test_discovery_group_client(dev):
hwsim_utils.test_connectivity_p2p(dev[0], dev[1])
logger.info("Try to discover a P2P client in a group")
if not dev[2].discover_peer(dev[1].p2p_dev_addr(), social=False, timeout=10):
+ stop_p2p_find_and_wait(dev[2])
if not dev[2].discover_peer(dev[1].p2p_dev_addr(), social=False, timeout=10):
+ stop_p2p_find_and_wait(dev[2])
if not dev[2].discover_peer(dev[1].p2p_dev_addr(), social=False, timeout=10):
raise Exception("Could not discover group client")
@@ -159,6 +161,15 @@ def test_discovery_group_client(dev):
if ev is None:
raise Exception("Timeout on waiting for GO Negotiation Request")
+def stop_p2p_find_and_wait(dev):
+ dev.request("P2P_STOP_FIND")
+ for i in range(10):
+ res = dev.get_driver_status_field("scan_state")
+ if "SCAN_STARTED" not in res and "SCAN_REQUESTED" not in res:
+ break
+ logger.debug("Waiting for final P2P_FIND scan to complete")
+ time.sleep(0.02)
+
def test_discovery_ctrl_char_in_devname(dev):
"""P2P device discovery and control character in Device Name"""
try:
@@ -177,7 +188,9 @@ def _test_discovery_ctrl_char_in_devname(dev):
dev[1].scan_for_bss(bssid, freq=2422)
dev[1].p2p_connect_group(addr0, pin, timeout=60, freq=2422)
if not dev[2].discover_peer(addr1, social=False, freq=2422, timeout=5):
+ stop_p2p_find_and_wait(dev[2])
if not dev[2].discover_peer(addr1, social=False, freq=2422, timeout=5):
+ stop_p2p_find_and_wait(dev[2])
if not dev[2].discover_peer(addr1, social=False, freq=2422,
timeout=5):
raise Exception("Could not discover group client")