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])