tests: Add GO Negotiation without pre-authorization
This is the most common sequence for initiating GO Negotiation, so include a test case that uses threads to follow both peers at the same time to allow GO Negotiation to be re-initiated. Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
4d7d61b689
commit
c4fff52c89
1 changed files with 43 additions and 0 deletions
|
@ -8,9 +8,43 @@
|
|||
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
import time
|
||||
import threading
|
||||
import Queue
|
||||
|
||||
import hwsim_utils
|
||||
|
||||
def go_neg_init(i_dev, r_dev, pin, i_method, i_intent, res):
|
||||
logger.debug("Initiate GO Negotiation from i_dev")
|
||||
i_res = i_dev.p2p_go_neg_init(r_dev.p2p_dev_addr(), pin, i_method, timeout=15, go_intent=i_intent)
|
||||
logger.debug("i_res: " + str(i_res))
|
||||
res.put(i_res)
|
||||
|
||||
def go_neg_pin(i_dev, r_dev, i_intent=None, r_intent=None, i_method='enter', r_method='display'):
|
||||
r_dev.p2p_listen()
|
||||
i_dev.p2p_listen()
|
||||
pin = r_dev.wps_read_pin()
|
||||
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, args=(i_dev, r_dev, pin, i_method, i_intent, res))
|
||||
t.start()
|
||||
logger.debug("Wait for GO Negotiation Request on r_dev")
|
||||
ev = r_dev.wait_event(["P2P-GO-NEG-REQUEST"], timeout=15)
|
||||
if ev is None:
|
||||
raise Exception("GO Negotiation timed out")
|
||||
r_dev.dump_monitor()
|
||||
logger.debug("Re-initiate GO Negotiation from r_dev")
|
||||
r_res = r_dev.p2p_go_neg_init(i_dev.p2p_dev_addr(), pin, r_method, go_intent=r_intent, timeout=15)
|
||||
logger.debug("r_res: " + str(r_res))
|
||||
r_dev.dump_monitor()
|
||||
t.join()
|
||||
i_res = res.get()
|
||||
logger.debug("i_res: " + str(i_res))
|
||||
logger.info("Group formed")
|
||||
hwsim_utils.test_connectivity_p2p(r_dev, i_dev)
|
||||
i_dev.dump_monitor()
|
||||
|
||||
def go_neg_pin_authorized(i_dev, r_dev, i_intent=None, r_intent=None, expect_failure=False, i_go_neg_status=None, i_method='enter', r_method='display'):
|
||||
r_dev.p2p_listen()
|
||||
i_dev.p2p_listen()
|
||||
|
@ -49,6 +83,14 @@ def test_grpform2(dev):
|
|||
except:
|
||||
pass
|
||||
|
||||
def test_grpform3(dev):
|
||||
go_neg_pin(i_dev=dev[0], i_intent=15, r_dev=dev[1], r_intent=0)
|
||||
dev[0].remove_group()
|
||||
try:
|
||||
dev[1].remove_group()
|
||||
except:
|
||||
pass
|
||||
|
||||
def test_both_go_intent_15(dev):
|
||||
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)
|
||||
|
||||
|
@ -61,6 +103,7 @@ def test_both_go_neg_enter(dev):
|
|||
def add_tests(tests):
|
||||
tests.append(test_grpform)
|
||||
tests.append(test_grpform2)
|
||||
tests.append(test_grpform3)
|
||||
tests.append(test_both_go_intent_15)
|
||||
tests.append(test_both_go_neg_display)
|
||||
tests.append(test_both_go_neg_enter)
|
||||
|
|
Loading…
Reference in a new issue