From ef2bd5a3443a2cc94e417157c56340ed555cde18 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 28 Sep 2013 12:09:40 +0300 Subject: [PATCH] tests: Add a test case for P2P invitation test_p2p_go_invite verifies that GO can invite a peer in a case where the operating channel and peer's listen channel are different. Signed-hostap: Jouni Malinen --- tests/hwsim/test_p2p_invitation.py | 48 ++++++++++++++++++++++++++++++ tests/hwsim/wpasupplicant.py | 6 ++-- 2 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 tests/hwsim/test_p2p_invitation.py diff --git a/tests/hwsim/test_p2p_invitation.py b/tests/hwsim/test_p2p_invitation.py new file mode 100644 index 000000000..178ea3cf4 --- /dev/null +++ b/tests/hwsim/test_p2p_invitation.py @@ -0,0 +1,48 @@ +#!/usr/bin/python +# +# P2P invitation test cases +# Copyright (c) 2013, Jouni Malinen +# +# 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 + +def test_p2p_go_invite(dev): + """P2P GO inviting a client to join""" + addr0 = dev[0].p2p_dev_addr() + addr1 = dev[1].p2p_dev_addr() + + logger.info("Discover peer") + dev[1].p2p_listen() + if not dev[0].discover_peer(addr1, social=True): + raise Exception("Peer " + addr1 + " not found") + + logger.info("Start GO on non-social channel") + res = dev[0].p2p_start_go(freq=2417) + logger.debug("res: " + str(res)) + + logger.info("Invite peer to join the group") + dev[0].global_request("P2P_INVITE group=" + dev[0].group_ifname + " peer=" + addr1) + ev = dev[1].wait_global_event(["P2P-INVITATION-RECEIVED"], timeout=10) + if ev is None: + raise Exception("Timeout on invitation on peer") + ev = dev[0].wait_global_event(["P2P-INVITATION-RESULT"], timeout=10) + if ev is None: + raise Exception("Timeout on invitation on GO") + if "status=1" not in ev: + raise Exception("Unexpected invitation result") + + logger.info("Join the group") + pin = dev[1].wps_read_pin() + dev[0].p2p_go_authorize_client(pin) + dev[1].p2p_connect_group(addr0, pin, timeout=60) + logger.info("Client connected") + hwsim_utils.test_connectivity_p2p(dev[0], dev[1]) + + logger.info("Terminate group") + dev[0].remove_group() + dev[1].wait_go_ending_session() diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py index fa1710110..6f1340bbc 100644 --- a/tests/hwsim/wpasupplicant.py +++ b/tests/hwsim/wpasupplicant.py @@ -270,7 +270,7 @@ class WpaSupplicant: self.dump_monitor() return self.group_form_result(ev, expect_failure) - def p2p_go_neg_init(self, peer, pin, method, timeout=0, go_intent=None, expect_failure=False, persistent=False): + def p2p_go_neg_init(self, peer, pin, method, timeout=0, go_intent=None, expect_failure=False, persistent=False, freq=None): if not self.discover_peer(peer): raise Exception("Peer " + peer + " not found") self.dump_monitor() @@ -280,6 +280,8 @@ class WpaSupplicant: cmd = "P2P_CONNECT " + peer + " " + method if go_intent: cmd = cmd + ' go_intent=' + str(go_intent) + if freq: + cmd = cmd + ' freq=' + str(freq) if persistent: cmd = cmd + " persistent" if "OK" in self.global_request(cmd): @@ -356,7 +358,7 @@ class WpaSupplicant: else: cmd = cmd + " persistent=" + str(persistent) if freq: - cmd = cmd + " freq=" + freq + cmd = cmd + " freq=" + str(freq) if "OK" in self.global_request(cmd): ev = self.wait_global_event(["P2P-GROUP-STARTED"], timeout=5) if ev is None: