P2P: Add a test case for discovering a P2P client in a group

Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2013-03-30 20:16:30 +02:00
parent 558d69e3ba
commit 5924d4c105
2 changed files with 20 additions and 1 deletions

View file

@ -9,6 +9,8 @@
import logging import logging
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
import hwsim_utils
def test_discovery(dev): def test_discovery(dev):
"""P2P device discovery and provision discovery""" """P2P device discovery and provision discovery"""
addr0 = dev[0].p2p_dev_addr() addr0 = dev[0].p2p_dev_addr()
@ -79,3 +81,18 @@ def test_discovery(dev):
dev[0].p2p_stop_find dev[0].p2p_stop_find
dev[1].p2p_stop_find dev[1].p2p_stop_find
def test_discovery_group_client(dev):
"""P2P device discovery for a client in a group"""
logger.info("Start autonomous GO " + dev[0].ifname)
res = dev[0].p2p_start_go(freq="2422")
logger.debug("res: " + str(res))
logger.info("Connect a client to the GO")
pin = dev[1].wps_read_pin()
dev[0].p2p_go_authorize_client(pin)
dev[1].p2p_connect_group(dev[0].p2p_dev_addr(), pin, timeout=60)
logger.info("Client connected")
hwsim_utils.test_connectivity_p2p(dev[0], dev[1])
logger.info("Try to discover a P2P client in a group")
if not dev[2].discover_peer(dev[1].p2p_dev_addr(), social=False):
raise Exception("Could not discover group client")

View file

@ -250,7 +250,7 @@ class WpaSupplicant:
raise Exception("Group could not be removed") raise Exception("Group could not be removed")
self.group_ifname = None self.group_ifname = None
def p2p_start_go(self, persistent=None): def p2p_start_go(self, persistent=None, freq=None):
self.dump_monitor() self.dump_monitor()
cmd = "P2P_GROUP_ADD" cmd = "P2P_GROUP_ADD"
if persistent is None: if persistent is None:
@ -259,6 +259,8 @@ class WpaSupplicant:
cmd = cmd + " persistent" cmd = cmd + " persistent"
else: else:
cmd = cmd + " persistent=" + str(persistent) cmd = cmd + " persistent=" + str(persistent)
if freq:
cmd = cmd + " freq=" + freq
if "OK" in self.request(cmd): if "OK" in self.request(cmd):
ev = self.wait_event(["P2P-GROUP-STARTED"], timeout=5) ev = self.wait_event(["P2P-GROUP-STARTED"], timeout=5)
if ev is None: if ev is None: