From 08e4bd875121498f8d850ad97f5694af010a3d27 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Wed, 5 Mar 2014 00:36:37 +0200 Subject: [PATCH] tests: PD-before-GO-Neg workaround Signed-off-by: Jouni Malinen --- tests/hwsim/test_p2p_grpform.py | 20 +++++++++++++++----- tests/hwsim/wpasupplicant.py | 4 +++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/tests/hwsim/test_p2p_grpform.py b/tests/hwsim/test_p2p_grpform.py index 7c0ded5b3..093bc1667 100644 --- a/tests/hwsim/test_p2p_grpform.py +++ b/tests/hwsim/test_p2p_grpform.py @@ -93,24 +93,28 @@ def go_neg_pin_authorized(i_dev, r_dev, i_intent=None, r_intent=None, expect_fai hwsim_utils.test_connectivity_p2p(r_dev, i_dev) return [i_res, r_res] -def go_neg_init_pbc(i_dev, r_dev, i_intent, res, freq): +def go_neg_init_pbc(i_dev, r_dev, i_intent, res, freq, provdisc): logger.debug("Initiate GO Negotiation from i_dev") try: i_res = i_dev.p2p_go_neg_init(r_dev.p2p_dev_addr(), None, "pbc", - timeout=20, go_intent=i_intent, freq=freq) + timeout=20, go_intent=i_intent, freq=freq, + provdisc=provdisc) logger.debug("i_res: " + str(i_res)) except Exception, e: i_res = None logger.info("go_neg_init_pbc thread caught an exception from p2p_go_neg_init: " + str(e)) res.put(i_res) -def go_neg_pbc(i_dev, r_dev, i_intent=None, r_intent=None, i_freq=None, r_freq=None): - r_dev.p2p_find(social=True) +def go_neg_pbc(i_dev, r_dev, i_intent=None, r_intent=None, i_freq=None, r_freq=None, provdisc=False, r_listen=False): + if r_listen: + r_dev.p2p_listen() + else: + r_dev.p2p_find(social=True) i_dev.p2p_find(social=True) logger.info("Start GO negotiation " + i_dev.ifname + " -> " + r_dev.ifname) r_dev.dump_monitor() res = Queue.Queue() - t = threading.Thread(target=go_neg_init_pbc, args=(i_dev, r_dev, i_intent, res, i_freq)) + t = threading.Thread(target=go_neg_init_pbc, args=(i_dev, r_dev, i_intent, res, i_freq, provdisc)) t.start() logger.debug("Wait for GO Negotiation Request on r_dev") ev = r_dev.wait_global_event(["P2P-GO-NEG-REQUEST"], timeout=15) @@ -227,6 +231,12 @@ def test_grpform_pbc(dev): raise Exception("Unexpected device roles") remove_group(dev[0], dev[1]) +def test_grpform_pd(dev): + """P2P group formation with PD-before-GO-Neg workaround""" + [i_res, r_res] = go_neg_pbc(i_dev=dev[0], provdisc=True, r_dev=dev[1], r_listen=True) + check_grpform_results(i_res, r_res) + remove_group(dev[0], dev[1]) + def test_both_go_intent_15(dev): """P2P GO Negotiation with both devices using GO intent 15""" go_neg_pin_authorized(i_dev=dev[0], i_intent=15, r_dev=dev[1], r_intent=15, expect_failure=True, i_go_neg_status=9) diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py index 14875087c..cdcf9ad54 100644 --- a/tests/hwsim/wpasupplicant.py +++ b/tests/hwsim/wpasupplicant.py @@ -440,7 +440,7 @@ class WpaSupplicant: self.dump_monitor() return self.group_form_result(ev, expect_failure, go_neg_res) - def p2p_go_neg_init(self, peer, pin, method, timeout=0, go_intent=None, expect_failure=False, persistent=False, freq=None): + def p2p_go_neg_init(self, peer, pin, method, timeout=0, go_intent=None, expect_failure=False, persistent=False, freq=None, provdisc=False): if not self.discover_peer(peer): raise Exception("Peer " + peer + " not found") self.dump_monitor() @@ -454,6 +454,8 @@ class WpaSupplicant: cmd = cmd + ' freq=' + str(freq) if persistent: cmd = cmd + " persistent" + if provdisc: + cmd = cmd + " provdisc" if "OK" in self.global_request(cmd): if timeout == 0: self.dump_monitor()