From 5924d4c105ac3024f919ddb41e684548779caa9d Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 30 Mar 2013 20:16:30 +0200 Subject: [PATCH] P2P: Add a test case for discovering a P2P client in a group Signed-hostap: Jouni Malinen --- tests/hwsim/test_p2p_discovery.py | 17 +++++++++++++++++ tests/hwsim/wpasupplicant.py | 4 +++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/hwsim/test_p2p_discovery.py b/tests/hwsim/test_p2p_discovery.py index b2a068487..f53e8539b 100644 --- a/tests/hwsim/test_p2p_discovery.py +++ b/tests/hwsim/test_p2p_discovery.py @@ -9,6 +9,8 @@ import logging logger = logging.getLogger(__name__) +import hwsim_utils + def test_discovery(dev): """P2P device discovery and provision discovery""" addr0 = dev[0].p2p_dev_addr() @@ -79,3 +81,18 @@ def test_discovery(dev): dev[0].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") diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py index 68dbaec0e..a67a6efb4 100644 --- a/tests/hwsim/wpasupplicant.py +++ b/tests/hwsim/wpasupplicant.py @@ -250,7 +250,7 @@ class WpaSupplicant: raise Exception("Group could not be removed") self.group_ifname = None - def p2p_start_go(self, persistent=None): + def p2p_start_go(self, persistent=None, freq=None): self.dump_monitor() cmd = "P2P_GROUP_ADD" if persistent is None: @@ -259,6 +259,8 @@ class WpaSupplicant: cmd = cmd + " persistent" else: cmd = cmd + " persistent=" + str(persistent) + if freq: + cmd = cmd + " freq=" + freq if "OK" in self.request(cmd): ev = self.wait_event(["P2P-GROUP-STARTED"], timeout=5) if ev is None: