tests: GO Negotiation with both devices using GO intent 15

Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2013-03-09 13:52:59 +02:00
parent c68f9a61c6
commit 809079d3ea
2 changed files with 26 additions and 7 deletions

View file

@ -11,18 +11,20 @@ logger = logging.getLogger(__name__)
import hwsim_utils import hwsim_utils
def go_neg_pin_authorized(i_dev, r_dev, i_intent=7, r_intent=7): def go_neg_pin_authorized(i_dev, r_dev, i_intent=None, r_intent=None, expect_failure=False):
r_dev.p2p_listen() r_dev.p2p_listen()
i_dev.p2p_listen() i_dev.p2p_listen()
pin = r_dev.wps_read_pin() pin = r_dev.wps_read_pin()
logger.info("Start GO negotiation " + i_dev.ifname + " -> " + r_dev.ifname) logger.info("Start GO negotiation " + i_dev.ifname + " -> " + r_dev.ifname)
r_dev.p2p_go_neg_auth(i_dev.p2p_dev_addr(), pin, "display") r_dev.p2p_go_neg_auth(i_dev.p2p_dev_addr(), pin, "display", go_intent=r_intent)
i_res = i_dev.p2p_go_neg_init(r_dev.p2p_dev_addr(), pin, "enter", timeout=15) i_res = i_dev.p2p_go_neg_init(r_dev.p2p_dev_addr(), pin, "enter", timeout=15, go_intent=i_intent, expect_failure=expect_failure)
r_res = r_dev.p2p_go_neg_auth_result() r_res = r_dev.p2p_go_neg_auth_result(expect_failure=expect_failure)
logger.debug("i_res: " + str(i_res)) logger.debug("i_res: " + str(i_res))
logger.debug("r_res: " + str(r_res)) logger.debug("r_res: " + str(r_res))
r_dev.dump_monitor() r_dev.dump_monitor()
i_dev.dump_monitor() i_dev.dump_monitor()
if expect_failure:
return
logger.info("Group formed") logger.info("Group formed")
hwsim_utils.test_connectivity_p2p(r_dev, i_dev) hwsim_utils.test_connectivity_p2p(r_dev, i_dev)
@ -42,6 +44,10 @@ def test_grpform2(dev):
except: except:
pass 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)
def add_tests(tests): def add_tests(tests):
tests.append(test_grpform) tests.append(test_grpform)
tests.append(test_grpform2) tests.append(test_grpform2)
tests.append(test_both_go_intent_15)

View file

@ -102,35 +102,47 @@ class WpaSupplicant:
res['go_dev_addr'] = s[7] res['go_dev_addr'] = s[7]
return res return res
def p2p_go_neg_auth(self, peer, pin, method): def p2p_go_neg_auth(self, peer, pin, method, go_intent=None):
if not self.discover_peer(peer): if not self.discover_peer(peer):
raise Exception("Peer " + peer + " not found") raise Exception("Peer " + peer + " not found")
self.dump_monitor() self.dump_monitor()
cmd = "P2P_CONNECT " + peer + " " + pin + " " + method + " auth" cmd = "P2P_CONNECT " + peer + " " + pin + " " + method + " auth"
if go_intent:
cmd = cmd + ' go_intent=' + str(go_intent)
if "OK" in self.request(cmd): if "OK" in self.request(cmd):
return None return None
raise Exception("P2P_CONNECT (auth) failed") raise Exception("P2P_CONNECT (auth) failed")
def p2p_go_neg_auth_result(self, timeout=1): def p2p_go_neg_auth_result(self, timeout=1, expect_failure=False):
ev = self.wait_event("P2P-GROUP-STARTED", timeout); ev = self.wait_event("P2P-GROUP-STARTED", timeout);
if ev is None: if ev is None:
if expect_failure:
return None
raise Exception("Group formation timed out") raise Exception("Group formation timed out")
self.dump_monitor() self.dump_monitor()
if expect_failure:
raise Exception("Group formation succeeded when expecting failure")
return self.group_form_result(ev) return self.group_form_result(ev)
def p2p_go_neg_init(self, peer, pin, method, timeout=0): def p2p_go_neg_init(self, peer, pin, method, timeout=0, go_intent=None, expect_failure=False):
if not self.discover_peer(peer): if not self.discover_peer(peer):
raise Exception("Peer " + peer + " not found") raise Exception("Peer " + peer + " not found")
self.dump_monitor() self.dump_monitor()
cmd = "P2P_CONNECT " + peer + " " + pin + " " + method cmd = "P2P_CONNECT " + peer + " " + pin + " " + method
if go_intent:
cmd = cmd + ' go_intent=' + str(go_intent)
if "OK" in self.request(cmd): if "OK" in self.request(cmd):
if timeout == 0: if timeout == 0:
self.dump_monitor() self.dump_monitor()
return None return None
ev = self.wait_event("P2P-GROUP-STARTED", timeout) ev = self.wait_event("P2P-GROUP-STARTED", timeout)
if ev is None: if ev is None:
if expect_failure:
return None
raise Exception("Group formation timed out") raise Exception("Group formation timed out")
self.dump_monitor() self.dump_monitor()
if expect_failure:
raise Exception("Group formation succeeded when expecting failure")
return self.group_form_result(ev) return self.group_form_result(ev)
raise Exception("P2P_CONNECT failed") raise Exception("P2P_CONNECT failed")
@ -141,6 +153,7 @@ class WpaSupplicant:
time.sleep(0.1) time.sleep(0.1)
while self.mon.pending(): while self.mon.pending():
ev = self.mon.recv() ev = self.mon.recv()
logger.debug(self.ifname + ": " + ev)
if event in ev: if event in ev:
return ev return ev
return None return None