Browse Source

tests: NFC connection handover to form a new P2P group and IP pool OOM

Signed-off-by: Jouni Malinen <j@w1.fi>
Jouni Malinen 9 years ago
parent
commit
bd4b9ee5ca
1 changed files with 47 additions and 0 deletions
  1. 47 0
      tests/hwsim/test_nfc_p2p.py

+ 47 - 0
tests/hwsim/test_nfc_p2p.py

@@ -10,6 +10,7 @@ import logging
 logger = logging.getLogger(__name__)
 
 import hwsim_utils
+from utils import alloc_fail
 
 grpform_events = ["P2P-GROUP-STARTED",
                   "P2P-GO-NEG-FAILURE",
@@ -83,6 +84,52 @@ def test_nfc_p2p_go_neg(dev):
     hwsim_utils.test_connectivity_p2p(dev[0], dev[1])
     check_ip_addr(res1)
 
+def test_nfc_p2p_go_neg_ip_pool_oom(dev):
+    """NFC connection handover to form a new P2P group and IP pool OOM"""
+    set_ip_addr_info(dev[0])
+    ip = dev[0].request("GET ip_addr_go")
+    if ip != "192.168.42.1":
+        raise Exception("Unexpected ip_addr_go returned: " + ip)
+    dev[0].global_request("SET p2p_go_intent 10")
+    logger.info("Perform NFC connection handover")
+    req = dev[0].global_request("NFC_GET_HANDOVER_REQ NDEF P2P-CR").rstrip()
+    if "FAIL" in req:
+        raise Exception("Failed to generate NFC connection handover request")
+    sel = dev[1].global_request("NFC_GET_HANDOVER_SEL NDEF P2P-CR").rstrip()
+    if "FAIL" in sel:
+        raise Exception("Failed to generate NFC connection handover select")
+    dev[0].dump_monitor()
+    dev[1].dump_monitor()
+
+    with alloc_fail(dev[0], 1, "bitfield_alloc;wpa_init"):
+        res = dev[1].global_request("NFC_REPORT_HANDOVER RESP P2P " + req + " " + sel)
+        if "FAIL" in res:
+            raise Exception("Failed to report NFC connection handover to wpa_supplicant(resp)")
+        res = dev[0].global_request("NFC_REPORT_HANDOVER INIT P2P " + req + " " + sel)
+        if "FAIL" in res:
+            raise Exception("Failed to report NFC connection handover to wpa_supplicant(init)")
+
+        ev = dev[0].wait_global_event(["P2P-GROUP-STARTED",
+                                       "P2P-GO-NEG-FAILURE",
+                                       "P2P-GROUP-FORMATION-FAILURE",
+                                       "WPS-PIN-NEEDED"], timeout=15)
+        if ev is None:
+            raise Exception("Group formation timed out")
+        res0 = dev[0].group_form_result(ev)
+
+    ev = dev[1].wait_global_event(["P2P-GROUP-STARTED",
+                                   "P2P-GO-NEG-FAILURE",
+                                   "P2P-GROUP-FORMATION-FAILURE",
+                                   "WPS-PIN-NEEDED"], timeout=1)
+    if ev is None:
+        raise Exception("Group formation timed out")
+    res1 = dev[1].group_form_result(ev)
+    logger.info("Group formed")
+
+    hwsim_utils.test_connectivity_p2p(dev[0], dev[1])
+    if 'ip_addr' in res1:
+        raise Exception("Unexpectedly received IP address from GO")
+
 def test_nfc_p2p_go_neg_reverse(dev):
     """NFC connection handover to form a new P2P group (responder becomes GO)"""
     set_ip_addr_info(dev[1])