2013-03-09 15:30:25 +01:00
|
|
|
#!/usr/bin/python
|
|
|
|
#
|
|
|
|
# P2P autonomous GO 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.
|
|
|
|
|
2013-03-09 17:24:32 +01:00
|
|
|
import time
|
2013-03-09 15:30:25 +01:00
|
|
|
import logging
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
import hwsim_utils
|
|
|
|
|
2013-03-09 16:51:22 +01:00
|
|
|
def autogo(go):
|
2013-03-09 15:30:25 +01:00
|
|
|
logger.info("Start autonomous GO " + go.ifname)
|
|
|
|
res = go.p2p_start_go()
|
|
|
|
logger.debug("res: " + str(res))
|
|
|
|
|
2013-03-09 16:51:22 +01:00
|
|
|
def connect_cli(go, client):
|
2013-03-09 15:30:25 +01:00
|
|
|
logger.info("Try to connect the client to the GO")
|
|
|
|
pin = client.wps_read_pin()
|
|
|
|
go.p2p_go_authorize_client(pin)
|
|
|
|
client.p2p_connect_group(go.p2p_dev_addr(), pin, timeout=60)
|
2013-03-09 16:51:22 +01:00
|
|
|
logger.info("Client connected")
|
2013-03-09 15:30:25 +01:00
|
|
|
hwsim_utils.test_connectivity_p2p(go, client)
|
|
|
|
|
|
|
|
def test_autogo(dev):
|
2013-03-09 16:51:22 +01:00
|
|
|
autogo(dev[0])
|
|
|
|
connect_cli(dev[0], dev[1])
|
2013-03-09 15:30:25 +01:00
|
|
|
dev[0].remove_group()
|
|
|
|
try:
|
|
|
|
dev[1].remove_group()
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
2013-03-09 16:51:22 +01:00
|
|
|
def test_autogo_2cli(dev):
|
|
|
|
autogo(dev[0])
|
|
|
|
connect_cli(dev[0], dev[1])
|
|
|
|
connect_cli(dev[0], dev[2])
|
|
|
|
hwsim_utils.test_connectivity_p2p(dev[1], dev[2])
|
|
|
|
dev[2].remove_group()
|
|
|
|
dev[1].remove_group()
|
|
|
|
dev[0].remove_group()
|
|
|
|
|
2013-03-09 17:24:32 +01:00
|
|
|
def test_autogo_tdls(dev):
|
|
|
|
autogo(dev[0])
|
|
|
|
connect_cli(dev[0], dev[1])
|
|
|
|
connect_cli(dev[0], dev[2])
|
|
|
|
hwsim_utils.test_connectivity_p2p(dev[1], dev[2])
|
|
|
|
addr2 = dev[2].p2p_interface_addr()
|
|
|
|
dev[1].tdls_setup(addr2)
|
|
|
|
time.sleep(1)
|
|
|
|
hwsim_utils.test_connectivity_p2p(dev[1], dev[2])
|
|
|
|
dev[1].tdls_teardown(addr2)
|
|
|
|
time.sleep(1)
|
|
|
|
hwsim_utils.test_connectivity_p2p(dev[1], dev[2])
|
|
|
|
dev[2].remove_group()
|
|
|
|
dev[1].remove_group()
|
|
|
|
dev[0].remove_group()
|
|
|
|
|
2013-03-09 15:30:25 +01:00
|
|
|
def add_tests(tests):
|
|
|
|
tests.append(test_autogo)
|
2013-03-09 16:51:22 +01:00
|
|
|
tests.append(test_autogo_2cli)
|
2013-03-09 17:24:32 +01:00
|
|
|
tests.append(test_autogo_tdls)
|