From b134397b11b6518ee0529955f395bd15603094c9 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 4 Dec 2015 23:15:11 +0200 Subject: [PATCH] tests: P2P persistent group formation, re-invocation, and cancel 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 --- tests/hwsim/p2p_utils.py | 10 ++++---- tests/hwsim/test_p2p_persistent.py | 37 ++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/tests/hwsim/p2p_utils.py b/tests/hwsim/p2p_utils.py index d4b8d8d39..ff6612f88 100644 --- a/tests/hwsim/p2p_utils.py +++ b/tests/hwsim/p2p_utils.py @@ -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): diff --git a/tests/hwsim/test_p2p_persistent.py b/tests/hwsim/test_p2p_persistent.py index 7c0873927..b9201bc96 100644 --- a/tests/hwsim/test_p2p_persistent.py +++ b/tests/hwsim/test_p2p_persistent.py @@ -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])