tests: P2P NFC Tag with group interface
authorJouni Malinen <j@w1.fi>
Sat, 12 Apr 2014 20:37:14 +0000 (23:37 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 13 Apr 2014 07:26:53 +0000 (10:26 +0300)
Signed-off-by: Jouni Malinen <j@w1.fi>
tests/hwsim/test_nfc_p2p.py

index b0ed1a6..3b1644b 100644 (file)
@@ -306,6 +306,54 @@ def test_nfc_p2p_static_handover_tagdev_client(dev):
     hwsim_utils.test_connectivity_p2p(dev[0], dev[1])
     check_ip_addr(res1)
 
+def test_nfc_p2p_static_handover_tagdev_client_group_iface(dev):
+    """NFC static handover to form a new P2P group (NFC Tag device becomes P2P Client with group iface)"""
+
+    set_ip_addr_info(dev[0])
+
+    logger.info("Perform NFC connection handover")
+
+    res = dev[1].request("SET p2p_listen_reg_class 81")
+    res2 = dev[1].request("SET p2p_listen_channel 6")
+    if "FAIL" in res or "FAIL" in res2:
+        raise Exception("Could not set Listen channel")
+    pw = dev[1].request("WPS_NFC_TOKEN NDEF").rstrip()
+    if "FAIL" in pw:
+        raise Exception("Failed to generate password token")
+    dev[1].request("SET p2p_no_group_iface 0")
+    res = dev[1].request("P2P_SET nfc_tag 1").rstrip()
+    if "FAIL" in res:
+        raise Exception("Failed to enable NFC Tag for P2P static handover")
+    sel = dev[1].request("NFC_GET_HANDOVER_SEL NDEF P2P-CR-TAG").rstrip()
+    if "FAIL" in sel:
+        raise Exception("Failed to generate NFC connection handover select")
+    res = dev[1].request("P2P_LISTEN")
+    if "FAIL" in res:
+        raise Exception("Failed to start Listen mode")
+    dev[1].dump_monitor()
+
+    dev[0].dump_monitor()
+    dev[0].request("SET p2p_go_intent 10")
+    res = dev[0].request("WPS_NFC_TAG_READ " + sel)
+    if "FAIL" in res:
+        raise Exception("Failed to provide NFC tag contents to wpa_supplicant")
+
+    ev = dev[0].wait_event(grpform_events, timeout=15)
+    if ev is None:
+        raise Exception("Group formation timed out")
+    res0 = dev[0].group_form_result(ev)
+
+    ev = dev[1].wait_event(grpform_events, timeout=1)
+    if ev is None:
+        raise Exception("Group formation timed out")
+    res1 = dev[1].group_form_result(ev)
+    logger.info("Group formed")
+
+    if res1['role'] != 'client' or res0['role'] != 'GO':
+        raise Exception("Unexpected roles negotiated")
+    hwsim_utils.test_connectivity_p2p(dev[0], dev[1])
+    check_ip_addr(res1)
+
 def test_nfc_p2p_static_handover_tagdev_go(dev):
     """NFC static handover to form a new P2P group (NFC Tag device becomes GO)"""