From 1f53fe0310cf124d404283d8044881735ee6e83b Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Thu, 22 Jan 2015 20:53:03 +0200 Subject: [PATCH] tests: P2P group formation using PBC multiple times in a row This verifies that PBC session overlap detection does not get indicated when forming the group with the same peer multiple times. Signed-off-by: Jouni Malinen --- tests/hwsim/test_p2p_grpform.py | 32 ++++++++++++++++++++++++++++++++ tests/hwsim/wpasupplicant.py | 5 ++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/tests/hwsim/test_p2p_grpform.py b/tests/hwsim/test_p2p_grpform.py index 57c6ff3a6..ac432dc00 100644 --- a/tests/hwsim/test_p2p_grpform.py +++ b/tests/hwsim/test_p2p_grpform.py @@ -143,6 +143,26 @@ def go_neg_pbc(i_dev, r_dev, i_intent=None, r_intent=None, i_freq=None, r_freq=N i_dev.dump_monitor() return [i_res, r_res] +def go_neg_pbc_authorized(i_dev, r_dev, i_intent=None, r_intent=None, + expect_failure=False, i_freq=None, r_freq=None): + i_dev.p2p_listen() + logger.info("Start GO negotiation " + i_dev.ifname + " -> " + r_dev.ifname) + r_dev.p2p_go_neg_auth(i_dev.p2p_dev_addr(), None, "pbc", + go_intent=r_intent, freq=r_freq) + r_dev.p2p_listen() + i_res = i_dev.p2p_go_neg_init(r_dev.p2p_dev_addr(), None, "pbc", timeout=20, + go_intent=i_intent, + expect_failure=expect_failure, freq=i_freq) + r_res = r_dev.p2p_go_neg_auth_result(expect_failure=expect_failure) + logger.debug("i_res: " + str(i_res)) + logger.debug("r_res: " + str(r_res)) + r_dev.dump_monitor() + i_dev.dump_monitor() + if expect_failure: + return + logger.info("Group formed") + return [i_res, r_res] + def remove_group(dev1, dev2): dev1.remove_group() try: @@ -896,3 +916,15 @@ def test_p2p_unauthorize(dev): ev = dev[0].wait_global_event(["P2P-GO-NEG-REQUEST"], timeout=10) if ev is None: raise Exception("No GO Negotiation Request RX reported") + +def test_grpform_pbc_multiple(dev): + """P2P group formation using PBC multiple times in a row""" + try: + dev[1].request("SET passive_scan 1") + for i in range(5): + [i_res, r_res] = go_neg_pbc_authorized(i_dev=dev[0], i_intent=15, + r_dev=dev[1], r_intent=0) + remove_group(dev[0], dev[1]) + finally: + dev[1].request("SET passive_scan 0") + dev[1].flush_scan_cache() diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py index ebfec6241..08fd6875a 100644 --- a/tests/hwsim/wpasupplicant.py +++ b/tests/hwsim/wpasupplicant.py @@ -501,7 +501,10 @@ class WpaSupplicant: if not self.discover_peer(peer): raise Exception("Peer " + peer + " not found") self.dump_monitor() - cmd = "P2P_CONNECT " + peer + " " + pin + " " + method + " auth" + if pin: + cmd = "P2P_CONNECT " + peer + " " + pin + " " + method + " auth" + else: + cmd = "P2P_CONNECT " + peer + " " + method + " auth" if go_intent: cmd = cmd + ' go_intent=' + str(go_intent) if freq: