]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: P2P persistent group formation, re-invocation, and cancel
authorJouni Malinen <jouni@qca.qualcomm.com>
Fri, 4 Dec 2015 21:15:11 +0000 (23:15 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 4 Dec 2015 21:15:11 +0000 (23:15 +0200)
Verify that P2P_CANCEL gets rejected on fully re-invoked persistent
group. This did not work properly before the last couple of commits and
before this week, the P2P_CANCEL on a separate group interface in P2p
Client role could result in use of freed memory and process termination.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
tests/hwsim/p2p_utils.py
tests/hwsim/test_p2p_persistent.py

index d4b8d8d3973a1796b45b866a73643d4e580a6d0c..ff6612f885a5fde623d21f5bdb3d330aeef0d17d 100644 (file)
@@ -158,20 +158,22 @@ def form(go, cli, test_data=True, reverse_init=False):
     else:
         return i_res
 
-def invite_from_cli(go, cli):
+def invite_from_cli(go, cli, terminate=True):
     logger.info("Re-invoke persistent group from client")
     invite(cli, go)
     [go_res, cli_res] = check_result(go, cli)
     hwsim_utils.test_connectivity_p2p(go, cli)
-    terminate_group(go, cli)
+    if terminate:
+        terminate_group(go, cli)
     return [go_res, cli_res]
 
-def invite_from_go(go, cli):
+def invite_from_go(go, cli, terminate=True):
     logger.info("Re-invoke persistent group from GO")
     invite(go, cli)
     [go_res, cli_res] = check_result(go, cli)
     hwsim_utils.test_connectivity_p2p(go, cli)
-    terminate_group(go, cli)
+    if terminate:
+        terminate_group(go, cli)
     return [go_res, cli_res]
 
 def autogo(go, freq=None, persistent=None):
index 7c08739276fa001ce6bc1bc6fa480c652230b1ce..b9201bc96141c5c1aafaffe484157a9f9a8eede1 100644 (file)
@@ -553,3 +553,40 @@ def test_persistent_group_profile_add(dev):
 
     dev[0].remove_group()
     dev[1].wait_go_ending_session()
+
+def test_persistent_group_cancel_on_cli(dev):
+    """P2P persistent group formation, re-invocation, and cancel"""
+    dev[0].global_request("SET p2p_no_group_iface 0")
+    dev[1].global_request("SET p2p_no_group_iface 0")
+    form(dev[0], dev[1])
+
+    invite_from_go(dev[0], dev[1], terminate=False)
+    if "FAIL" not in dev[1].global_request("P2P_CANCEL"):
+        raise Exception("P2P_CANCEL succeeded unexpectedly on CLI")
+    if "FAIL" not in dev[0].global_request("P2P_CANCEL"):
+        raise Exception("P2P_CANCEL succeeded unexpectedly on GO")
+    terminate_group(dev[0], dev[1])
+
+    invite_from_cli(dev[0], dev[1], terminate=False)
+    if "FAIL" not in dev[1].global_request("P2P_CANCEL"):
+        raise Exception("P2P_CANCEL succeeded unexpectedly on CLI")
+    if "FAIL" not in dev[0].global_request("P2P_CANCEL"):
+        raise Exception("P2P_CANCEL succeeded unexpectedly on GO")
+    terminate_group(dev[0], dev[1])
+
+def test_persistent_group_cancel_on_cli2(dev):
+    """P2P persistent group formation, re-invocation, and cancel (2)"""
+    form(dev[0], dev[1])
+    invite_from_go(dev[0], dev[1], terminate=False)
+    if "FAIL" not in dev[1].global_request("P2P_CANCEL"):
+        raise Exception("P2P_CANCEL succeeded unexpectedly on CLI")
+    if "FAIL" not in dev[0].global_request("P2P_CANCEL"):
+        raise Exception("P2P_CANCEL succeeded unexpectedly on GO")
+    terminate_group(dev[0], dev[1])
+
+    invite_from_cli(dev[0], dev[1], terminate=False)
+    if "FAIL" not in dev[1].global_request("P2P_CANCEL"):
+        raise Exception("P2P_CANCEL succeeded unexpectedly on CLI")
+    if "FAIL" not in dev[0].global_request("P2P_CANCEL"):
+        raise Exception("P2P_CANCEL succeeded unexpectedly on GO")
+    terminate_group(dev[0], dev[1])