Browse Source

tests: Add P2P invitation coverage during p2p_find

The new persistent_group_peer_dropped3 test case is similar to
persistent_group_peer_dropped with the difference being in the
responding device (the one from which the persistent group information
is dropped) is not issued a separate P2P_LISTEN command and instead, a
single P2P_FIND is used through the exchange to verify that this
operation does not get stopped unexpectedly. This is a regression test
case to verify that P2P_PENDING_INVITATION_RESPONSE case ends up calling
p2p_check_after_scan_tx_continuation() in non-success case. It should be
noted that this is dependent on timing: Action frame TX request needs to
occur during the P2P_FIND Search phase (scan). As such, not every
execution of this test case will hit the previous issue sequence, but
that should be hit every now and then.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
Jouni Malinen 9 years ago
parent
commit
601e55726c
2 changed files with 38 additions and 8 deletions
  1. 17 8
      tests/hwsim/p2p_utils.py
  2. 21 0
      tests/hwsim/test_p2p_persistent.py

+ 17 - 8
tests/hwsim/p2p_utils.py

@@ -75,14 +75,18 @@ WLAN_EID_SSID = 0
 WLAN_EID_SUPP_RATES = 1
 WLAN_EID_VENDOR_SPECIFIC = 221
 
-def go_neg_pin_authorized_persistent(i_dev, r_dev, i_intent=None, r_intent=None, i_method='enter', r_method='display', test_data=True):
-    r_dev.p2p_listen()
+def go_neg_pin_authorized_persistent(i_dev, r_dev, i_intent=None, r_intent=None,
+                                     i_method='enter', r_method='display',
+                                     test_data=True, r_listen=True):
+    if r_listen:
+        r_dev.p2p_listen()
     i_dev.p2p_listen()
     pin = r_dev.wps_read_pin()
     logger.info("Start GO negotiation " + i_dev.ifname + " -> " + r_dev.ifname)
     r_dev.p2p_go_neg_auth(i_dev.p2p_dev_addr(), pin, r_method,
                           go_intent=r_intent, persistent=True)
-    r_dev.p2p_listen()
+    if r_listen:
+        r_dev.p2p_listen()
     i_res = i_dev.p2p_go_neg_init(r_dev.p2p_dev_addr(), pin, i_method,
                                   timeout=20, go_intent=i_intent,
                                   persistent=True)
@@ -101,13 +105,16 @@ def terminate_group(go, cli):
     go.remove_group()
     cli.wait_go_ending_session()
 
-def invite(inv, resp, extra=None, persistent_reconnect=True):
+def invite(inv, resp, extra=None, persistent_reconnect=True, use_listen=True):
     addr = resp.p2p_dev_addr()
     if persistent_reconnect:
         resp.global_request("SET persistent_reconnect 1")
     else:
         resp.global_request("SET persistent_reconnect 0")
-    resp.p2p_listen()
+    if use_listen:
+        resp.p2p_listen()
+    else:
+        resp.p2p_find(social=True)
     if not inv.discover_peer(addr, social=True):
         raise Exception("Peer " + addr + " not found")
     inv.dump_monitor()
@@ -143,16 +150,18 @@ def check_result(go, cli):
         raise Exception("Persistent group not re-invoked as persistent (cli)")
     return [go_res, cli_res]
 
-def form(go, cli, test_data=True, reverse_init=False):
+def form(go, cli, test_data=True, reverse_init=False, r_listen=True):
     logger.info("Form a persistent group")
     if reverse_init:
         [i_res, r_res] = go_neg_pin_authorized_persistent(i_dev=cli, i_intent=0,
                                                           r_dev=go, r_intent=15,
-                                                          test_data=test_data)
+                                                          test_data=test_data,
+                                                          r_listen=r_listen)
     else:
         [i_res, r_res] = go_neg_pin_authorized_persistent(i_dev=go, i_intent=15,
                                                           r_dev=cli, r_intent=0,
-                                                          test_data=test_data)
+                                                          test_data=test_data,
+                                                          r_listen=r_listen)
     if not i_res['persistent'] or not r_res['persistent']:
         raise Exception("Formed group was not persistent")
     terminate_group(go, cli)

+ 21 - 0
tests/hwsim/test_p2p_persistent.py

@@ -634,3 +634,24 @@ def test_persistent_group_peer_dropped2(dev):
 
     logger.info("Verify that a new group can be formed")
     form(dev[0], dev[1])
+
+def test_persistent_group_peer_dropped3(dev):
+    """P2P persistent group formation and re-invocation with peer having dropped group (3)"""
+    form(dev[0], dev[1], reverse_init=True)
+    invite_from_cli(dev[0], dev[1])
+
+    logger.info("Remove group on the GO and try to invite from the client")
+    dev[0].request("REMOVE_NETWORK all")
+    invite(dev[1], dev[0], use_listen=False)
+    ev = dev[1].wait_global_event(["P2P-INVITATION-RESULT"], timeout=10)
+    if ev is None:
+        raise Exception("No invitation result seen")
+    if "status=8" not in ev:
+        raise Exception("Unexpected invitation result: " + ev)
+    networks = dev[1].list_networks(p2p=True)
+    if len(networks) > 0:
+        raise Exception("Unexpected network block on client")
+
+    time.sleep(0.2)
+    logger.info("Verify that a new group can be formed")
+    form(dev[0], dev[1], reverse_init=True, r_listen=False)