From cf4643aa7d8139eb431439bd628c4cf3dee7a535 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 17 Feb 2019 16:55:50 +0200 Subject: [PATCH] tests: Force diff chan in p2ps_channel_active_go_and_station_different_mcc This test case was failing pretty frequently due to an issue in being able to send out the Provision Discovery Response frame on the operating channel. Now that wpa_supplicant has a fix for that issue, modify this test case to hit this error condition every time. In addition, make sure the possible exception from p2ps_exact_seek() does not get hidden with a failing remove_group() call in the finally section. Signed-off-by: Jouni Malinen --- tests/hwsim/p2p_utils.py | 8 ++++++-- tests/hwsim/test_p2ps.py | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/hwsim/p2p_utils.py b/tests/hwsim/p2p_utils.py index 3abc00a62..510385c2b 100644 --- a/tests/hwsim/p2p_utils.py +++ b/tests/hwsim/p2p_utils.py @@ -367,8 +367,12 @@ def go_neg_pbc_authorized(i_dev, r_dev, i_intent=None, r_intent=None, logger.info("Group formed") return [i_res, r_res] -def remove_group(dev1, dev2): - dev1.remove_group() +def remove_group(dev1, dev2, allow_failure=False): + try: + dev1.remove_group() + except: + if not allow_failure: + raise try: dev2.remove_group() except: diff --git a/tests/hwsim/test_p2ps.py b/tests/hwsim/test_p2ps.py index a1807d82f..e9ab57fe6 100644 --- a/tests/hwsim/test_p2ps.py +++ b/tests/hwsim/test_p2ps.py @@ -1587,9 +1587,11 @@ def test_p2ps_channel_active_go_and_station_different_mcc(dev, apdev): hapd = hostapd.add_ap(apdev[0], { "ssid": 'bss-channel-6', "channel": '6' }) + wpas.global_request("P2P_SET listen_channel 1") wpas.connect("bss-channel-6", key_mgmt="NONE", scan_freq="2437") # Add a P2P GO on the seeker + dev[1].global_request("P2P_SET listen_channel 1") dev[1].global_request("P2P_GROUP_ADD freq=2462 persistent") ev = dev[1].wait_global_event(["P2P-GROUP-STARTED"], timeout=10) if ev is None: @@ -1607,10 +1609,12 @@ def test_p2ps_channel_active_go_and_station_different_mcc(dev, apdev): ev1, ev0 = p2ps_provision(dev[1], wpas, adv_id) p2ps_connect_pd(wpas, dev[1], ev0, ev1) finally: + set_random_listen_chan(dev[1]) + set_random_listen_chan(wpas) wpas.request("DISCONNECT") hapd.disable() wpas.global_request("P2P_SERVICE_DEL asp all") - remove_group(wpas, dev[1]) + remove_group(wpas, dev[1], allow_failure=True) def test_p2ps_connect_p2p_device(dev): """P2PS connection using cfg80211 P2P Device"""