diff mbox

[4/6] tests: Test no P2P GO move when invitation is in progress

Message ID 1446560701-30841-5-git-send-email-ilan.peer@intel.com
State Changes Requested
Headers show

Commit Message

Peer, Ilan Nov. 3, 2015, 2:24 p.m. UTC
Add a test to verify that a P2P GO does not start a CSA
once invitation signalling is done, and the P2P client is
about to connect.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
---
 tests/hwsim/test_p2p_channel.py | 64 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)

Comments

Jouni Malinen Nov. 21, 2015, 4:33 p.m. UTC | #1
On Tue, Nov 03, 2015 at 04:24:59PM +0200, Ilan Peer wrote:
> Add a test to verify that a P2P GO does not start a CSA
> once invitation signalling is done, and the P2P client is
> about to connect.

Could you please clarify how this is supposed to work? The long wait for
CSA seems to be completed before starting the invitation and there is no
checks for CSA after the invitation is started.
Peer, Ilan Nov. 22, 2015, 10:51 a.m. UTC | #2
Hi Jouni,

> -----Original Message-----
> From: Jouni Malinen [mailto:j@w1.fi]
> Sent: Saturday, November 21, 2015 18:34
> To: Peer, Ilan
> Cc: hostap@lists.infradead.org
> Subject: Re: [PATCH 4/6] tests: Test no P2P GO move when invitation is in
> progress
> 
> On Tue, Nov 03, 2015 at 04:24:59PM +0200, Ilan Peer wrote:
> > Add a test to verify that a P2P GO does not start a CSA once
> > invitation signalling is done, and the P2P client is about to connect.
> 
> Could you please clarify how this is supposed to work? The long wait for CSA
> seems to be completed before starting the invitation and there is no checks
> for CSA after the invitation is started.
> 

1. This is based on the timing of P2P GO move which is 30 seconds after the P2P GO has started. The test waits 29.9 seconds after the P2P GO has started and starts the invitation flow, assuming that the P2P GO CSA evaluation is going to happen in 100ms. As this is timing sensitive, I'll change this so it would depend on testing configuration over the control interface.

2. A P2P GO CSA after the invitation is no longer expected, as during the invitation signaling the P2P GO includes only its current operating channel in the channel list. Since the P2P spec requires that the channels in the channel list in the invitation response are a subset of the channels in the channel list in the invitation request, the invitation signaling ends up with only a single channel in the group common frequencies, so when a P2P CSA is considered again, there are no valid channels to move to. I'll clarify this in the test.

Thanks,

Ilan.
diff mbox

Patch

diff --git a/tests/hwsim/test_p2p_channel.py b/tests/hwsim/test_p2p_channel.py
index 53e4ea5..dd89df1 100644
--- a/tests/hwsim/test_p2p_channel.py
+++ b/tests/hwsim/test_p2p_channel.py
@@ -918,3 +918,67 @@  def test_p2p_go_move_scm_multi(dev, apdev, params):
     finally:
         dev[0].global_request("P2P_SET disallow_freq ")
         dev[0].global_request("SET p2p_go_freq_change_policy 2")
+
+def test_p2p_delay_go_csa(dev, apdev, params):
+    """P2P GO CSA delayed when inviting a P2P Device to an active P2P Group [long]"""
+    if not params['long']:
+        raise HwsimSkip("Skip test case with long duration due to --long not specified")
+
+    with HWSimRadio(n_channels=2) as (radio, iface):
+        wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
+        wpas.interface_add(iface)
+
+        wpas.global_request("SET p2p_no_group_iface 0")
+
+        if wpas.get_mcc() < 2:
+           raise Exception("New radio does not support MCC")
+
+        addr0 = wpas.p2p_dev_addr()
+        addr1 = dev[1].p2p_dev_addr()
+
+        try:
+            hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": 'bss-2.4ghz',
+                                                        "channel": '1' })
+
+            wpas.connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412")
+
+            dev[1].p2p_listen();
+	    if not wpas.discover_peer(addr1, social=True):
+		raise Exception("Peer " + addr1 + " not found")
+
+            wpas.global_request("SET p2p_go_freq_change_policy 0")
+	    wpas.dump_monitor()
+
+            logger.info("Start GO on channel 6")
+            res = autogo(wpas, freq=2437)
+	    go_start = time.time();
+            if res['freq'] != "2437":
+               raise Exception("GO set on a freq=%s instead of 2437" % res['freq'])
+
+	    if not dev[1].discover_peer(addr0, social=False):
+		raise Exception("Peer " + addr1 + " not found")
+
+            pin = dev[1].wps_read_pin()
+	    dev[1].global_request("P2P_CONNECT " + addr0 + " " + pin + " join auth")
+            dev[1].p2p_listen();
+
+            logger.info("Sleep while P2P GO CSA is not allowed")
+	    ev = wpas.wait_group_event(["P2P-REMOVE-AND-REFORM-GROUP",
+		                       "AP-CSA-FINISHED"], timeout= 29.9 -
+				       (time.time() - go_start))
+	    if ev is not None:
+	        raise Exception("Unexpected + " + ev + " event")
+
+            logger.info("Starting invitation")
+            wpas.p2p_go_authorize_client(pin)
+	    wpas.global_request("P2P_INVITE group=" + wpas.group_ifname + " peer=" + addr1)
+	    ev = dev[1].wait_global_event(["P2P-INVITATION-RECEIVED",
+		    "P2P-GROUP-STARTED"], timeout=10)
+
+	    if ev is None:
+	        raise Exception("Timeout on invitation on peer")
+	    if "P2P-INVITATION-RECEIVED" in ev:
+                raise Exception("Unexpected request to accept pre-authorized invitation")
+
+        finally:
+            wpas.global_request("SET p2p_go_freq_change_policy 2")