2013-03-02 05:22:28 -05:00
|
|
|
#!/usr/bin/python
|
|
|
|
#
|
|
|
|
# P2P group formation test cases
|
|
|
|
# Copyright (c) 2013, Jouni Malinen <j@w1.fi>
|
|
|
|
#
|
|
|
|
# This software may be distributed under the terms of the BSD license.
|
|
|
|
# See README for more details.
|
|
|
|
|
|
|
|
import logging
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
import hwsim_utils
|
|
|
|
|
2013-03-09 08:52:57 -05:00
|
|
|
def go_neg_pin_authorized(i_dev, r_dev, i_intent=None, r_intent=None, expect_failure=False, i_go_neg_status=None):
|
2013-03-02 05:22:28 -05:00
|
|
|
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)
|
2013-03-09 06:52:59 -05:00
|
|
|
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, go_intent=i_intent, expect_failure=expect_failure)
|
|
|
|
r_res = r_dev.p2p_go_neg_auth_result(expect_failure=expect_failure)
|
2013-03-09 06:36:35 -05:00
|
|
|
logger.debug("i_res: " + str(i_res))
|
|
|
|
logger.debug("r_res: " + str(r_res))
|
2013-03-02 05:22:28 -05:00
|
|
|
r_dev.dump_monitor()
|
|
|
|
i_dev.dump_monitor()
|
2013-03-09 08:52:57 -05:00
|
|
|
if i_go_neg_status:
|
|
|
|
if i_res['result'] != 'go-neg-failed':
|
|
|
|
raise Exception("Expected GO Negotiation failure not reported")
|
|
|
|
if i_res['status'] != i_go_neg_status:
|
|
|
|
raise Exception("Expected GO Negotiation status not seen")
|
2013-03-09 06:52:59 -05:00
|
|
|
if expect_failure:
|
|
|
|
return
|
2013-03-02 05:22:28 -05:00
|
|
|
logger.info("Group formed")
|
|
|
|
hwsim_utils.test_connectivity_p2p(r_dev, i_dev)
|
|
|
|
|
|
|
|
def test_grpform(dev):
|
|
|
|
go_neg_pin_authorized(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_grpform2(dev):
|
|
|
|
go_neg_pin_authorized(i_dev=dev[0], i_intent=0, r_dev=dev[1], r_intent=15)
|
|
|
|
dev[0].remove_group()
|
|
|
|
try:
|
|
|
|
dev[1].remove_group()
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
2013-03-09 06:52:59 -05:00
|
|
|
def test_both_go_intent_15(dev):
|
2013-03-09 08:52:57 -05:00
|
|
|
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)
|
2013-03-09 06:52:59 -05:00
|
|
|
|
2013-03-02 05:22:28 -05:00
|
|
|
def add_tests(tests):
|
|
|
|
tests.append(test_grpform)
|
|
|
|
tests.append(test_grpform2)
|
2013-03-09 06:52:59 -05:00
|
|
|
tests.append(test_both_go_intent_15)
|