diff mbox

[v2,12/12] tests: P2PS channel handling

Message ID 1444296967-20844-13-git-send-email-ilan.peer@intel.com
State Accepted
Headers show

Commit Message

Ilan Peer Oct. 8, 2015, 9:36 a.m. UTC
Add tests to verify proper handling of channel considerations
in P2PS PD.

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

Comments

Jouni Malinen Oct. 11, 2015, 4:15 p.m. UTC | #1
On Thu, Oct 08, 2015 at 12:36:07PM +0300, Ilan Peer wrote:
> Add tests to verify proper handling of channel considerations
> in P2PS PD.

> diff --git a/tests/hwsim/test_p2ps.py b/tests/hwsim/test_p2ps.py

> +def test_p2ps_channel_both_connected_same(dev, apdev):
> +    """P2PS connection with P2PS method - stations connected on same channel"""

This fails for me every time even when run as a single test case with
vm-run.sh. This is with unmodified test scripts and configuration. The
failure is "Exception: P2P-GROUP-STARTED timeout on 02:00:00:00:00:00".
It looks like dev[0] has some strange issues with scan when trying to
join the group. This happens when processing the "P2P_CONNECT
42:00:00:00:01:00 12345670 p2ps persistent join" command. This sends a
scan triger to the driver and that command seems to succeed and there is
even a scan trigger event indicating that the scan started. However, the
test script times out after ten seconds of not having seen scan results.

It looks like the scans of all channels while associated takes a bit
over ten seconds. Increasing the timeout for P2P-GROUP-STARTED in
p2ps_connect_pd() for the join case is enough to make this pass.
However, there is not really much need for making this test case take so
long by forcing a full channel scan while connected. "freq=2437"
argument should be added to the P2P_CONNECT-join command to make this
use a single channel scan.

> +    dev[0].global_request("P2P_SET listen_channel 6")
> +    dev[1].global_request("P2P_SET listen_channel 6")

I don't want to do this for dev[0] and ideally not for dev[1] either.
Using random listen channels on the devices gives a significant extra
coverage for testing and that needs to remain until such time that there
is proper test cases going through all different combinations of P2P
operations and matching vs. non-matching listen channels.

For now, I'll replace this with use of dev[2] and dev[1] and setting a
random listen_chan at the end of the test case.

> +def test_p2ps_channel_active_go_and_station_same(dev, apdev):

> +    dev[0].global_request("P2P_SET listen_channel 11")
> +    dev[1].global_request("P2P_SET listen_channel 11")

Same here..

> +        p2ps_connect_pd(dev[0], dev[1], ev0, ev1)

This was also timing out on full scan while connected, so fixed it with
"freq=2462" added to the P2P_CONNECT-join command.

> +def test_p2ps_channel_active_go_and_station_different(dev, apdev):
> +        # Add a P2P GO on the seeker. Force the listen channel to be the same,
> +        # as extended listen will not kick as long as P2P GO is waiting for
> +        # initial connection.
> +        dev[1].global_request("P2P_SET listen_channel 11")

Same as above, i.e., returning random listen channel at the end of the
test case.
Ilan Peer Oct. 12, 2015, 1:34 p.m. UTC | #2
> -----Original Message-----
> From: Jouni Malinen [mailto:j@w1.fi]
> Sent: Sunday, October 11, 2015 19:16
> To: Peer, Ilan
> Cc: hostap@lists.shmoo.com
> Subject: Re: [PATCH v2 12/12] tests: P2PS channel handling
> 
> On Thu, Oct 08, 2015 at 12:36:07PM +0300, Ilan Peer wrote:
> > Add tests to verify proper handling of channel considerations in P2PS
> > PD.
> 
> > diff --git a/tests/hwsim/test_p2ps.py b/tests/hwsim/test_p2ps.py
> 
> > +def test_p2ps_channel_both_connected_same(dev, apdev):
> > +    """P2PS connection with P2PS method - stations connected on same
> channel"""
> 
> This fails for me every time even when run as a single test case with vm-
> run.sh. This is with unmodified test scripts and configuration. The failure is
> "Exception: P2P-GROUP-STARTED timeout on 02:00:00:00:00:00".
> It looks like dev[0] has some strange issues with scan when trying to join the
> group. This happens when processing the "P2P_CONNECT
> 42:00:00:00:01:00 12345670 p2ps persistent join" command. This sends a
> scan triger to the driver and that command seems to succeed and there is
> even a scan trigger event indicating that the scan started. However, the test
> script times out after ten seconds of not having seen scan results.
> 

I thought that I've eliminated this when using the same frequency for the listen
channel and operating frequency (got clean results on 2 different setups and VM). I'll
try to have another look at this in mac80211_hwsim.

> It looks like the scans of all channels while associated takes a bit over ten
> seconds. Increasing the timeout for P2P-GROUP-STARTED in
> p2ps_connect_pd() for the join case is enough to make this pass.
> However, there is not really much need for making this test case take so long
> by forcing a full channel scan while connected. "freq=2437"
> argument should be added to the P2P_CONNECT-join command to make this
> use a single channel scan.
> 
> > +    dev[0].global_request("P2P_SET listen_channel 6")
> > +    dev[1].global_request("P2P_SET listen_channel 6")
> 
> I don't want to do this for dev[0] and ideally not for dev[1] either.
> Using random listen channels on the devices gives a significant extra coverage
> for testing and that needs to remain until such time that there is proper test
> cases going through all different combinations of P2P operations and
> matching vs. non-matching listen channels.
> 
> For now, I'll replace this with use of dev[2] and dev[1] and setting a random
> listen_chan at the end of the test case.
> 

Sure. This is much cleaner.

> > +def test_p2ps_channel_active_go_and_station_same(dev, apdev):
> 
> > +    dev[0].global_request("P2P_SET listen_channel 11")
> > +    dev[1].global_request("P2P_SET listen_channel 11")
> 
> Same here..
> 
> > +        p2ps_connect_pd(dev[0], dev[1], ev0, ev1)
> 
> This was also timing out on full scan while connected, so fixed it with
> "freq=2462" added to the P2P_CONNECT-join command.
> 
> > +def test_p2ps_channel_active_go_and_station_different(dev, apdev):
> > +        # Add a P2P GO on the seeker. Force the listen channel to be the
> same,
> > +        # as extended listen will not kick as long as P2P GO is waiting for
> > +        # initial connection.
> > +        dev[1].global_request("P2P_SET listen_channel 11")
> 
> Same as above, i.e., returning random listen channel at the end of the test
> case.
> 
> --


Thanks again,

Ilan.
Ilan Peer Oct. 13, 2015, 1:55 p.m. UTC | #3
> -----Original Message-----
> From: hostap-bounces@lists.shmoo.com [mailto:hostap-
> bounces@lists.shmoo.com] On Behalf Of Peer, Ilan
> Sent: Monday, October 12, 2015 16:35
> To: Jouni Malinen
> Cc: hostap@lists.shmoo.com
> Subject: RE: [PATCH v2 12/12] tests: P2PS channel handling
> 
> 
> 
> > -----Original Message-----
> > From: Jouni Malinen [mailto:j@w1.fi]
> > Sent: Sunday, October 11, 2015 19:16
> > To: Peer, Ilan
> > Cc: hostap@lists.shmoo.com
> > Subject: Re: [PATCH v2 12/12] tests: P2PS channel handling
> >
> > On Thu, Oct 08, 2015 at 12:36:07PM +0300, Ilan Peer wrote:
> > > Add tests to verify proper handling of channel considerations in
> > > P2PS PD.
> >
> > > diff --git a/tests/hwsim/test_p2ps.py b/tests/hwsim/test_p2ps.py
> >
> > > +def test_p2ps_channel_both_connected_same(dev, apdev):
> > > +    """P2PS connection with P2PS method - stations connected on
> > > +same
> > channel"""
> >
> > This fails for me every time even when run as a single test case with
> > vm- run.sh. This is with unmodified test scripts and configuration.
> > The failure is
> > "Exception: P2P-GROUP-STARTED timeout on 02:00:00:00:00:00".
> > It looks like dev[0] has some strange issues with scan when trying to
> > join the group. This happens when processing the "P2P_CONNECT
> > 42:00:00:00:01:00 12345670 p2ps persistent join" command. This sends a
> > scan triger to the driver and that command seems to succeed and there
> > is even a scan trigger event indicating that the scan started.
> > However, the test script times out after ten seconds of not having seen scan
> results.
> >
> 
> I thought that I've eliminated this when using the same frequency for the
> listen channel and operating frequency (got clean results on 2 different
> setups and VM). I'll try to have another look at this in mac80211_hwsim.
> 

FWIW, I was not able to reproduce the 10 seconds timeout. Scanning on all the channels
while associated takes around 5.5 seconds, as mac80211 toggles between the
operating channel (dwell for 200 msec) and the scan channels. Even when stressing
the system (using the 'stress' utility) the worst scan time I got was less than 6 seconds. 

Regards,

Ilan.
diff mbox

Patch

diff --git a/tests/hwsim/test_p2ps.py b/tests/hwsim/test_p2ps.py
index 8c13592..ac4f040 100644
--- a/tests/hwsim/test_p2ps.py
+++ b/tests/hwsim/test_p2ps.py
@@ -12,6 +12,7 @@  import re
 
 import hwsim_utils
 from wpasupplicant import WpaSupplicant
+import hostapd
 from test_p2p_grpform import check_grpform_results
 from test_p2p_grpform import remove_group
 from test_p2p_persistent import go_neg_pin_authorized_persistent
@@ -135,12 +136,15 @@  def p2ps_parse_event(ev, *args):
         ret += (m.group(1) if m is not None else None,)
     return ret
 
-def p2ps_provision(seeker, advertiser, adv_id, auto_accept=True, method="1000", adv_cpt=None, seeker_cpt=None):
+def p2ps_provision(seeker, advertiser, adv_id, auto_accept=True, method="1000",
+                   adv_cpt=None, seeker_cpt=None, handler=None, adv_role=None,
+                   seeker_role=None):
     addr0 = seeker.p2p_dev_addr()
     addr1 = advertiser.p2p_dev_addr()
 
     seeker.asp_provision(addr1, adv_id=str(adv_id), adv_mac=addr1, session_id=1,
-                         session_mac=addr0, method=method, cpt=seeker_cpt)
+                         session_mac=addr0, method=method, cpt=seeker_cpt,
+                         role=seeker_role)
 
     if not auto_accept or method == "100":
         pin = None
@@ -156,6 +160,9 @@  def p2ps_provision(seeker, advertiser, adv_id, auto_accept=True, method="1000",
         if ev is None:
             raise Exception("P2P-PROV-DISC-FAILURE timeout on seeker side")
 
+        if handler:
+            handler(seeker, advertiser)
+
         # Put seeker into a listen state, since we expect the deferred flow to
         # continue.
         seeker.p2p_ext_listen(500, 500)
@@ -186,7 +193,7 @@  def p2ps_provision(seeker, advertiser, adv_id, auto_accept=True, method="1000",
         advertiser.asp_provision(peer, adv_id=advert_id, adv_mac=advert_mac,
                                  session_id=int(session, 0),
                                  session_mac=session_mac, status=12,
-                                 cpt=adv_cpt)
+                                 cpt=adv_cpt, role=adv_role)
 
         ev1 = seeker.wait_global_event(["P2PS-PROV-DONE"], timeout=10)
         if ev1 is None:
@@ -347,10 +354,13 @@  def p2ps_connect_pd(dev0, dev1, ev0, ev1, pin=None):
                 raise Exception("Device " + dev_go.p2p_dev_addr() + " failed to become GO")
             if join_address is None:
                 raise Exception("Device " + dev_cli.p2p_dev_addr() + " failed to become CLI")
-            ev = dev_go.wait_global_event(["P2P-GROUP-STARTED"], timeout=10)
-            if ev is None:
-                raise Exception("P2P-GROUP-STARTED timeout on " + dev_go.p2p_dev_addr())
-            dev_go.group_form_result(ev)
+
+            if not dev_go.get_group_ifname().startswith('p2p-'):
+                ev = dev_go.wait_global_event(["P2P-GROUP-STARTED"], timeout=10)
+                if ev is None:
+                    raise Exception("P2P-GROUP-STARTED timeout on " + dev_go.p2p_dev_addr())
+                dev_go.group_form_result(ev)
+
             if go_method != "p2ps":
                 ev = dev_go.group_request("WPS_PIN any " + pin)
                 if ev is None:
@@ -1027,3 +1037,375 @@  def test_p2ps_feature_capability_udp_mac_nonautoaccept(dev):
     p2ps_test_feature_capability_cpt(dev, adv_cpt="UDP:MAC",
                                      seeker_cpt="MAC:UDP", adv_role="0",
                                      result="MAC")
+
+def test_p2ps_channel_one_connected(dev, apdev):
+    """P2PS connection with P2PS method - one of the stations connected"""
+    set_no_group_iface(dev[0], 0)
+    set_no_group_iface(dev[1], 0)
+
+    try:
+        hapd = hostapd.add_ap(apdev[0]['ifname'],
+                              { "ssid": 'bss-2.4ghz', "channel": '7' })
+        dev[1].connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2442")
+
+        (grp_ifname0, grp_ifname1, ifnames) = p2ps_connect_p2ps_method(dev, keep_group=True)
+        freq = dev[0].get_group_status_field('freq');
+
+        if freq != '2442':
+            raise Exception('Unexpected frequency for group 2442 != ' + freq)
+    finally:
+        remove_group(dev[0], dev[1])
+        dev[0].global_request("P2P_SERVICE_DEL asp all")
+
+def test_p2ps_channel_both_connected_same(dev, apdev):
+    """P2PS connection with P2PS method - stations connected on same channel"""
+    set_no_group_iface(dev[0], 0)
+    set_no_group_iface(dev[1], 0)
+
+    dev[0].global_request("P2P_SET listen_channel 6")
+    dev[1].global_request("P2P_SET listen_channel 6")
+    try:
+        hapd = hostapd.add_ap(apdev[0]['ifname'],
+                              { "ssid": 'bss-2.4ghz', "channel": '6' })
+
+        dev[0].connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2437")
+        dev[1].connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2437")
+
+        (grp_ifname0, grp_ifname1, ifnames) = p2ps_connect_p2ps_method(dev, keep_group=True)
+        freq = dev[0].get_group_status_field('freq');
+
+        if freq != '2437':
+            raise Exception('Unexpected frequency for group 2437!=' + freq)
+    finally:
+        remove_group(dev[0], dev[1])
+        dev[0].global_request("P2P_SERVICE_DEL asp all")
+
+def disconnect_handler(seeker, advertiser):
+    advertiser.request("DISCONNECT")
+    advertiser.wait_disconnected(timeout=1)
+
+def test_p2ps_channel_both_connected_different(dev, apdev):
+    """P2PS connection with P2PS method - stations connected on different channel"""
+    if dev[0].get_mcc() > 1:
+        raise HwsimSkip('Skip due to MCC being enabled')
+
+    set_no_group_iface(dev[0], 0)
+    set_no_group_iface(dev[1], 0)
+
+    try:
+        hapd1 = hostapd.add_ap(apdev[0]['ifname'],
+                               { "ssid": 'bss-channel-3', "channel": '3' })
+
+        hapd2 = hostapd.add_ap(apdev[1]['ifname'],
+                               { "ssid": 'bss-channel-10', "channel": '10' })
+
+        dev[0].connect("bss-channel-3", key_mgmt="NONE", scan_freq="2422")
+        dev[1].connect("bss-channel-10", key_mgmt="NONE", scan_freq="2457")
+
+        p2ps_advertise(r_dev=dev[0], r_role='2',
+                       svc_name='org.wi-fi.wfds.send.rx',
+                       srv_info='I can receive files upto size 2 GB')
+        [adv_id, rcvd_svc_name] = p2ps_exact_seek(i_dev=dev[1], r_dev=dev[0],
+                                                  svc_name='org.wi-fi.wfds.send.rx',
+                                                  srv_info='2 GB')
+
+        ev1, ev0 = p2ps_provision(dev[1], dev[0], adv_id, auto_accept=False,
+                                  handler=disconnect_handler)
+        p2ps_connect_pd(dev[0], dev[1], ev0, ev1)
+        freq = dev[0].get_group_status_field('freq');
+        if freq != '2457':
+            raise Exception('Unexpected frequency for group 2457 != ' + freq)
+    finally:
+        remove_group(dev[0], dev[1])
+        dev[0].global_request("P2P_SERVICE_DEL asp all")
+
+def test_p2ps_channel_both_connected_different_mcc(dev, apdev):
+    """P2PS connection with P2PS method - stations connected on different channels with mcc"""
+    if dev[0].get_mcc() == 1:
+        raise HwsimSkip('Skip case due to MCC not enabled')
+
+    set_no_group_iface(dev[0], 0)
+    set_no_group_iface(dev[1], 0)
+
+    try:
+        hapd1 = hostapd.add_ap(apdev[0]['ifname'],
+                               { "ssid": 'bss-channel-3', "channel": '3' })
+
+        hapd2 = hostapd.add_ap(apdev[1]['ifname'],
+                               { "ssid": 'bss-channel-10', "channel": '10' })
+
+        dev[0].connect("bss-channel-3", key_mgmt="NONE", scan_freq="2422")
+        dev[1].connect("bss-channel-10", key_mgmt="NONE", scan_freq="2457")
+
+        (grp_ifname0, grp_ifname1, ifnames) = p2ps_connect_p2ps_method(dev, keep_group=True)
+        freq = dev[0].get_group_status_field('freq');
+
+        if freq != '2422' and freq != '2457':
+            raise Exception('Unexpected frequency for group =' + freq)
+    finally:
+        remove_group(dev[0], dev[1])
+        dev[0].global_request("P2P_SERVICE_DEL asp all")
+
+def clear_disallow_handler(seeker, advertiser):
+    advertiser.global_request("P2P_SET disallow_freq ")
+
+def test_p2ps_channel_disallow_freq(dev, apdev):
+    """P2PS connection with P2PS method - disallow freqs"""
+    set_no_group_iface(dev[0], 0)
+    set_no_group_iface(dev[1], 0)
+
+    try:
+        dev[0].global_request("P2P_SET disallow_freq 2412-2457")
+        dev[1].global_request("P2P_SET disallow_freq 2417-2462")
+
+        p2ps_advertise(r_dev=dev[0], r_role='2',
+                       svc_name='org.wi-fi.wfds.send.rx',
+                       srv_info='I can receive files upto size 2 GB')
+
+        [adv_id, rcvd_svc_name] = p2ps_exact_seek(i_dev=dev[1], r_dev=dev[0],
+                                                  svc_name='org.wi-fi.wfds.send.rx',
+                                                  srv_info='2 GB')
+
+        ev1, ev0 = p2ps_provision(dev[1], dev[0], adv_id, auto_accept=False,
+                                  handler=clear_disallow_handler)
+        p2ps_connect_pd(dev[0], dev[1], ev0, ev1)
+
+        freq = dev[0].get_group_status_field('freq');
+        if freq != '2412':
+            raise Exception('Unexpected frequency for group 2412 != ' + freq)
+    finally:
+        remove_group(dev[0], dev[1])
+        dev[0].global_request("P2P_SERVICE_DEL asp all")
+        dev[0].global_request("P2P_SET disallow_freq ")
+        dev[1].global_request("P2P_SET disallow_freq ")
+
+def test_p2ps_channel_sta_connected_disallow_freq(dev, apdev):
+    """P2PS connection with P2PS method - one station and disallow freqs"""
+    if dev[0].get_mcc() > 1:
+        raise HwsimSkip('Skip due to MCC being enabled')
+
+    set_no_group_iface(dev[0], 0)
+    set_no_group_iface(dev[1], 0)
+
+    try:
+        dev[0].global_request("P2P_SET disallow_freq 2437")
+        hapd = hostapd.add_ap(apdev[0]['ifname'],
+                              { "ssid": 'bss-channel-6', "channel": '6' })
+
+        dev[1].connect("bss-channel-6", key_mgmt="NONE", scan_freq="2437")
+
+        p2ps_advertise(r_dev=dev[0], r_role='2',
+                       svc_name='org.wi-fi.wfds.send.rx',
+                       srv_info='I can receive files upto size 2 GB')
+        [adv_id, rcvd_svc_name] = p2ps_exact_seek(i_dev=dev[1], r_dev=dev[0],
+                                                  svc_name='org.wi-fi.wfds.send.rx',
+                                                  srv_info='2 GB')
+
+        ev1, ev0 = p2ps_provision(dev[1], dev[0], adv_id, auto_accept=False,
+                                  handler=clear_disallow_handler)
+        p2ps_connect_pd(dev[0], dev[1], ev0, ev1)
+
+        freq = dev[0].get_group_status_field('freq');
+        if freq != '2437':
+            raise Exception('Unexpected frequency for group 2437 != ' + freq)
+    finally:
+        remove_group(dev[0], dev[1])
+        dev[0].global_request("P2P_SET disallow_freq ")
+        dev[0].global_request("P2P_SERVICE_DEL asp all")
+
+def test_p2ps_channel_sta_connected_disallow_freq_mcc(dev, apdev):
+    """P2PS connection with P2PS method - one station and disallow freqs with mcc"""
+    if dev[0].get_mcc() == 1:
+        raise HwsimSkip('Skip due to MCC not being enabled')
+
+    set_no_group_iface(dev[0], 0)
+    set_no_group_iface(dev[1], 0)
+
+    try:
+        dev[0].global_request("P2P_SET disallow_freq 2437")
+        hapd1 = hostapd.add_ap(apdev[0]['ifname'],
+                               { "ssid": 'bss-channel-6', "channel": '6' })
+
+        dev[1].connect("bss-channel-6", key_mgmt="NONE", scan_freq="2437")
+
+        (grp_ifname0, grp_ifname1, ifnames) = p2ps_connect_p2ps_method(dev, keep_group=True)
+
+        freq = dev[0].get_group_status_field('freq');
+        if freq == '2437':
+            raise Exception('Unexpected frequency=2437')
+    finally:
+        remove_group(dev[0], dev[1])
+        dev[0].global_request("P2P_SET disallow_freq ")
+        dev[0].global_request("P2P_SERVICE_DEL asp all")
+
+def test_p2ps_active_go_adv(dev, apdev):
+    """P2PS connection with P2PS method - active GO on advertiser"""
+    set_no_group_iface(dev[0], 0)
+    set_no_group_iface(dev[1], 0)
+
+    try:
+        # Add a P2P GO
+        dev[0].global_request("P2P_GROUP_ADD persistent")
+        ev = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=10)
+        if ev is None:
+            raise Exception("P2P-GROUP-STARTED timeout on " + dev[0].p2p_dev_addr())
+
+        dev[0].group_form_result(ev)
+
+        p2ps_advertise(r_dev=dev[0], r_role='4',
+                       svc_name='org.wi-fi.wfds.send.rx',
+                       srv_info='I can receive files upto size 2 GB')
+        [adv_id, rcvd_svc_name] = p2ps_exact_seek(i_dev=dev[1], r_dev=dev[0],
+                                                  svc_name='org.wi-fi.wfds.send.rx',
+                                                  single_peer_expected=False)
+
+        ev1, ev0 = p2ps_provision(dev[1], dev[0], adv_id)
+
+        # explicitly stop find/listen as otherwise the long listen started by
+        # the advertiser would prevent the seeker to connect with the P2P GO
+        dev[0].p2p_stop_find()
+        p2ps_connect_pd(dev[0], dev[1], ev0, ev1)
+    finally:
+        remove_group(dev[0], dev[1])
+        dev[0].global_request("P2P_SERVICE_DEL asp all")
+
+
+def test_p2ps_active_go_seeker(dev, apdev):
+    """P2PS connection with P2PS method - active GO on seeker"""
+    set_no_group_iface(dev[0], 0)
+    set_no_group_iface(dev[1], 0)
+
+    try:
+        # Add a P2P GO on the seeker
+        dev[1].global_request("P2P_GROUP_ADD persistent")
+        ev = dev[1].wait_global_event(["P2P-GROUP-STARTED"], timeout=10)
+        if ev is None:
+            raise Exception("P2P-GROUP-STARTED timeout on " + dev[1].p2p_dev_addr())
+
+        dev[1].group_form_result(ev)
+
+        p2ps_advertise(r_dev=dev[0], r_role='2',
+                       svc_name='org.wi-fi.wfds.send.rx',
+                       srv_info='I can receive files upto size 2 GB')
+        [adv_id, rcvd_svc_name] = p2ps_exact_seek(i_dev=dev[1], r_dev=dev[0],
+                                                  svc_name='org.wi-fi.wfds.send.rx',
+                                                  srv_info='2 GB')
+
+        ev1, ev0 = p2ps_provision(dev[1], dev[0], adv_id)
+        p2ps_connect_pd(dev[0], dev[1], ev0, ev1)
+    finally:
+        remove_group(dev[0], dev[1])
+        dev[0].global_request("P2P_SERVICE_DEL asp all")
+
+def test_p2ps_channel_active_go_and_station_same(dev, apdev):
+    """P2PS connection, active P2P GO and station on channel"""
+    set_no_group_iface(dev[0], 0)
+    set_no_group_iface(dev[1], 0)
+
+    dev[0].global_request("P2P_SET listen_channel 11")
+    dev[1].global_request("P2P_SET listen_channel 11")
+    try:
+        hapd = hostapd.add_ap(apdev[0]['ifname'],
+                              { "ssid": 'bss-channel-11', "channel": '11' })
+
+        dev[0].connect("bss-channel-11", key_mgmt="NONE", scan_freq="2462")
+
+        # Add a P2P GO on the seeker
+        dev[1].global_request("P2P_GROUP_ADD freq=2462 persistent")
+        ev = dev[1].wait_global_event(["P2P-GROUP-STARTED"], timeout=10)
+        if ev is None:
+            raise Exception("P2P-GROUP-STARTED timeout on " + dev[1].p2p_dev_addr())
+
+        dev[1].group_form_result(ev)
+
+        p2ps_advertise(r_dev=dev[0], r_role='2',
+                       svc_name='org.wi-fi.wfds.send.rx',
+                       srv_info='I can receive files upto size 2 GB')
+        [adv_id, rcvd_svc_name] = p2ps_exact_seek(i_dev=dev[1], r_dev=dev[0],
+                                                  svc_name='org.wi-fi.wfds.send.rx',
+                                                  srv_info='2 GB')
+
+        ev1, ev0 = p2ps_provision(dev[1], dev[0], adv_id)
+        p2ps_connect_pd(dev[0], dev[1], ev0, ev1)
+    finally:
+        remove_group(dev[0], dev[1])
+        dev[0].global_request("P2P_SERVICE_DEL asp all")
+
+def test_p2ps_channel_active_go_and_station_different(dev, apdev):
+    """P2PS connection, active P2P GO and station on channel"""
+    if dev[0].get_mcc() > 1:
+        raise HwsimSkip('Skip due to MCC being enabled')
+
+    set_no_group_iface(dev[0], 0)
+    set_no_group_iface(dev[1], 0)
+
+    try:
+        hapd = hostapd.add_ap(apdev[0]['ifname'],
+                              { "ssid": 'bss-channel-2', "channel": '2' })
+
+        dev[0].connect("bss-channel-2", key_mgmt="NONE", scan_freq="2417")
+
+        # Add a P2P GO on the seeker. Force the listen channel to be the same,
+        # as extended listen will not kick as long as P2P GO is waiting for
+        # initial connection.
+        dev[1].global_request("P2P_SET listen_channel 11")
+        dev[1].global_request("P2P_GROUP_ADD freq=2462 persistent")
+        ev = dev[1].wait_global_event(["P2P-GROUP-STARTED"], timeout=10)
+        if ev is None:
+            raise Exception("P2P-GROUP-STARTED timeout on " + dev[1].p2p_dev_addr())
+
+        dev[1].group_form_result(ev)
+
+        p2ps_advertise(r_dev=dev[0], r_role='2',
+                       svc_name='org.wi-fi.wfds.send.rx',
+                       srv_info='I can receive files upto size 2 GB')
+        [adv_id, rcvd_svc_name] = p2ps_exact_seek(i_dev=dev[1], r_dev=dev[0],
+                                                  svc_name='org.wi-fi.wfds.send.rx',
+                                                  srv_info='2 GB')
+
+        ev1, ev0 = p2ps_provision(dev[1], dev[0], adv_id, auto_accept=False,
+                                  handler=disconnect_handler, adv_role='2',
+                                  seeker_role='4')
+        p2ps_connect_pd(dev[0], dev[1], ev0, ev1)
+        freq = dev[0].get_group_status_field('freq');
+        if freq != '2462':
+            raise Exception('Unexpected frequency for group 2462!=' + freq)
+    finally:
+        dev[0].global_request("P2P_SERVICE_DEL asp all")
+
+def test_p2ps_channel_active_go_and_station_different_mcc(dev, apdev):
+    """P2PS connection, active P2P GO and station on channel"""
+    if dev[0].get_mcc() == 1:
+        raise HwsimSkip('Skip due to MCC not being enabled')
+
+    set_no_group_iface(dev[0], 0)
+    set_no_group_iface(dev[1], 0)
+
+    try:
+        hapd = hostapd.add_ap(apdev[0]['ifname'],
+                              { "ssid": 'bss-channel-6', "channel": '6' })
+
+        dev[0].connect("bss-channel-6", key_mgmt="NONE", scan_freq="2437")
+
+        # Add a P2P GO on the seeker
+        dev[1].global_request("P2P_GROUP_ADD freq=2462 persistent")
+        ev = dev[1].wait_global_event(["P2P-GROUP-STARTED"], timeout=10)
+        if ev is None:
+            raise Exception("P2P-GROUP-STARTED timeout on " + dev[1].p2p_dev_addr())
+
+        dev[1].group_form_result(ev)
+
+        p2ps_advertise(r_dev=dev[0], r_role='2',
+                       svc_name='org.wi-fi.wfds.send.rx',
+                       srv_info='I can receive files upto size 2 GB')
+        [adv_id, rcvd_svc_name] = p2ps_exact_seek(i_dev=dev[1], r_dev=dev[0],
+                                                  svc_name='org.wi-fi.wfds.send.rx',
+                                                  srv_info='2 GB')
+
+        ev1, ev0 = p2ps_provision(dev[1], dev[0], adv_id)
+        p2ps_connect_pd(dev[0], dev[1], ev0, ev1)
+    finally:
+        remove_group(dev[0], dev[1])
+        dev[0].request("DISCONNECT")
+        hapd.disable()
+        dev[0].global_request("P2P_SERVICE_DEL asp all")