[PATCH 6/7] tests: Use the global control interface in test_nfc_p2p.py

Ilan Peer ilan.peer at intel.com
Thu Feb 5 20:31:01 EST 2015


This patch handles only a subset of the changed. The rest will
be handled in the proceeding patch.

Signed-off-by: David Spinadel <david.spinadel at intel.com>
Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
 tests/hwsim/test_nfc_p2p.py | 166 ++++++++++++++++++++++----------------------
 1 file changed, 83 insertions(+), 83 deletions(-)

diff --git a/tests/hwsim/test_nfc_p2p.py b/tests/hwsim/test_nfc_p2p.py
index 66de717..3e601c8 100644
--- a/tests/hwsim/test_nfc_p2p.py
+++ b/tests/hwsim/test_nfc_p2p.py
@@ -19,10 +19,10 @@ grpform_events = ["P2P-GROUP-STARTED",
                   "WPS-FAIL"]
 
 def set_ip_addr_info(dev):
-    dev.request("SET ip_addr_go 192.168.42.1")
-    dev.request("SET ip_addr_mask 255.255.255.0")
-    dev.request("SET ip_addr_start 192.168.42.100")
-    dev.request("SET ip_addr_end 192.168.42.199")
+    dev.global_request("SET ip_addr_go 192.168.42.1")
+    dev.global_request("SET ip_addr_mask 255.255.255.0")
+    dev.global_request("SET ip_addr_start 192.168.42.100")
+    dev.global_request("SET ip_addr_end 192.168.42.199")
 
 def check_ip_addr(res):
     if 'ip_addr' not in res:
@@ -41,24 +41,24 @@ def check_ip_addr(res):
 def test_nfc_p2p_go_neg(dev):
     """NFC connection handover to form a new P2P group (initiator becomes GO)"""
     set_ip_addr_info(dev[0])
-    dev[0].request("SET p2p_go_intent 10")
+    dev[0].global_request("SET p2p_go_intent 10")
     logger.info("Perform NFC connection handover")
-    req = dev[0].request("NFC_GET_HANDOVER_REQ NDEF P2P-CR").rstrip()
+    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].request("NFC_GET_HANDOVER_SEL NDEF P2P-CR").rstrip()
+    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()
-    res = dev[1].request("NFC_REPORT_HANDOVER RESP P2P " + req + " " + sel)
+    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].request("NFC_REPORT_HANDOVER INIT P2P " + req + " " + sel)
+    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_event(["P2P-GROUP-STARTED",
+    ev = dev[0].wait_global_event(["P2P-GROUP-STARTED",
                             "P2P-GO-NEG-FAILURE",
                             "P2P-GROUP-FORMATION-FAILURE",
                             "WPS-PIN-NEEDED"], timeout=15)
@@ -66,7 +66,7 @@ def test_nfc_p2p_go_neg(dev):
         raise Exception("Group formation timed out")
     res0 = dev[0].group_form_result(ev)
 
-    ev = dev[1].wait_event(["P2P-GROUP-STARTED",
+    ev = dev[1].wait_global_event(["P2P-GROUP-STARTED",
                             "P2P-GO-NEG-FAILURE",
                             "P2P-GROUP-FORMATION-FAILURE",
                             "WPS-PIN-NEEDED"], timeout=1)
@@ -83,24 +83,24 @@ def test_nfc_p2p_go_neg(dev):
 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])
-    dev[0].request("SET p2p_go_intent 3")
+    dev[0].global_request("SET p2p_go_intent 3")
     logger.info("Perform NFC connection handover")
-    req = dev[0].request("NFC_GET_HANDOVER_REQ NDEF P2P-CR").rstrip()
+    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].request("NFC_GET_HANDOVER_SEL NDEF P2P-CR").rstrip()
+    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()
-    res = dev[1].request("NFC_REPORT_HANDOVER RESP P2P " + req + " " + sel)
+    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].request("NFC_REPORT_HANDOVER INIT P2P " + req + " " + sel)
+    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_event(["P2P-GROUP-STARTED",
+    ev = dev[0].wait_global_event(["P2P-GROUP-STARTED",
                             "P2P-GO-NEG-FAILURE",
                             "P2P-GROUP-FORMATION-FAILURE",
                             "WPS-PIN-NEEDED"], timeout=15)
@@ -108,7 +108,7 @@ def test_nfc_p2p_go_neg_reverse(dev):
         raise Exception("Group formation timed out")
     res0 = dev[0].group_form_result(ev)
 
-    ev = dev[1].wait_event(["P2P-GROUP-STARTED",
+    ev = dev[1].wait_global_event(["P2P-GROUP-STARTED",
                             "P2P-GO-NEG-FAILURE",
                             "P2P-GROUP-FORMATION-FAILURE",
                             "WPS-PIN-NEEDED"], timeout=1)
@@ -128,22 +128,22 @@ def test_nfc_p2p_initiator_go(dev):
     logger.info("Start autonomous GO")
     dev[0].p2p_start_go()
     logger.info("Perform NFC connection handover")
-    req = dev[0].request("NFC_GET_HANDOVER_REQ NDEF P2P-CR").rstrip()
+    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].request("NFC_GET_HANDOVER_SEL NDEF P2P-CR").rstrip()
+    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()
-    res = dev[1].request("NFC_REPORT_HANDOVER RESP P2P " + req + " " + sel)
+    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].request("NFC_REPORT_HANDOVER INIT P2P " + req + " " + sel)
+    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[1].wait_event(["P2P-GROUP-STARTED"], timeout=15)
+    ev = dev[1].wait_global_event(["P2P-GROUP-STARTED"], timeout=15)
     if ev is None:
         raise Exception("Connection to the group timed out")
     res1 = dev[1].group_form_result(ev)
@@ -158,22 +158,22 @@ def test_nfc_p2p_responder_go(dev):
     logger.info("Start autonomous GO")
     dev[1].p2p_start_go()
     logger.info("Perform NFC connection handover")
-    req = dev[0].request("NFC_GET_HANDOVER_REQ NDEF P2P-CR").rstrip()
+    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].request("NFC_GET_HANDOVER_SEL NDEF P2P-CR").rstrip()
+    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()
-    res = dev[1].request("NFC_REPORT_HANDOVER RESP P2P " + req + " " + sel)
+    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].request("NFC_REPORT_HANDOVER INIT P2P " + req + " " + sel)
+    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_event(["P2P-GROUP-STARTED"], timeout=15)
+    ev = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=15)
     if ev is None:
         raise Exception("Connection to the group timed out")
     res0 = dev[0].group_form_result(ev)
@@ -266,36 +266,36 @@ def test_nfc_p2p_static_handover_tagdev_client(dev):
 
     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")
+    res = dev[1].global_request("SET p2p_listen_reg_class 81")
+    res2 = dev[1].global_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()
+    pw = dev[1].global_request("WPS_NFC_TOKEN NDEF").rstrip()
     if "FAIL" in pw:
         raise Exception("Failed to generate password token")
-    res = dev[1].request("P2P_SET nfc_tag 1").rstrip()
+    res = dev[1].global_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()
+    sel = dev[1].global_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")
+    res = dev[1].global_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)
+    dev[0].global_request("SET p2p_go_intent 10")
+    res = dev[0].global_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)
+    ev = dev[0].wait_global_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)
+    ev = dev[1].wait_global_event(grpform_events, timeout=1)
     if ev is None:
         raise Exception("Group formation timed out")
     res1 = dev[1].group_form_result(ev)
@@ -313,37 +313,37 @@ def test_nfc_p2p_static_handover_tagdev_client_group_iface(dev):
 
     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")
+    res = dev[1].global_request("SET p2p_listen_reg_class 81")
+    res2 = dev[1].global_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()
+    pw = dev[1].global_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()
+    dev[1].global_request("SET p2p_no_group_iface 0")
+    res = dev[1].global_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()
+    sel = dev[1].global_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")
+    res = dev[1].global_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)
+    dev[0].global_request("SET p2p_go_intent 10")
+    res = dev[0].global_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)
+    ev = dev[0].wait_global_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)
+    ev = dev[1].wait_global_event(grpform_events, timeout=1)
     if ev is None:
         raise Exception("Group formation timed out")
     res1 = dev[1].group_form_result(ev)
@@ -361,36 +361,36 @@ def test_nfc_p2p_static_handover_tagdev_go(dev):
 
     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")
+    res = dev[1].global_request("SET p2p_listen_reg_class 81")
+    res2 = dev[1].global_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()
+    pw = dev[1].global_request("WPS_NFC_TOKEN NDEF").rstrip()
     if "FAIL" in pw:
         raise Exception("Failed to generate password token")
-    res = dev[1].request("P2P_SET nfc_tag 1").rstrip()
+    res = dev[1].global_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()
+    sel = dev[1].global_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")
+    res = dev[1].global_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 3")
-    res = dev[0].request("WPS_NFC_TAG_READ " + sel)
+    dev[0].global_request("SET p2p_go_intent 3")
+    res = dev[0].global_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)
+    ev = dev[0].wait_global_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)
+    ev = dev[1].wait_global_event(grpform_events, timeout=1)
     if ev is None:
         raise Exception("Group formation timed out")
     res1 = dev[1].group_form_result(ev)
@@ -408,36 +408,36 @@ def test_nfc_p2p_static_handover_tagdev_go_forced_freq(dev):
 
     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")
+    res = dev[1].global_request("SET p2p_listen_reg_class 81")
+    res2 = dev[1].global_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()
+    pw = dev[1].global_request("WPS_NFC_TOKEN NDEF").rstrip()
     if "FAIL" in pw:
         raise Exception("Failed to generate password token")
-    res = dev[1].request("P2P_SET nfc_tag 1").rstrip()
+    res = dev[1].global_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()
+    sel = dev[1].global_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")
+    res = dev[1].global_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 3")
-    res = dev[0].request("WPS_NFC_TAG_READ " + sel + " freq=2442")
+    dev[0].global_request("SET p2p_go_intent 3")
+    res = dev[0].global_request("WPS_NFC_TAG_READ " + sel + " freq=2442")
     if "FAIL" in res:
         raise Exception("Failed to provide NFC tag contents to wpa_supplicant")
 
-    ev = dev[0].wait_event(grpform_events, timeout=15)
+    ev = dev[0].wait_global_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)
+    ev = dev[1].wait_global_event(grpform_events, timeout=1)
     if ev is None:
         raise Exception("Group formation timed out")
     res1 = dev[1].group_form_result(ev)
@@ -496,29 +496,29 @@ def test_nfc_p2p_static_handover_join_tagdev_client(dev):
     logger.info("Start autonomous GO")
     dev[0].p2p_start_go()
 
-    dev[1].request("SET ignore_old_scan_res 1")
-    dev[2].request("SET ignore_old_scan_res 1")
+    dev[1].global_request("SET ignore_old_scan_res 1")
+    dev[2].global_request("SET ignore_old_scan_res 1")
 
     logger.info("Write NFC Tag on the P2P Client")
-    res = dev[1].request("P2P_LISTEN")
+    res = dev[1].global_request("P2P_LISTEN")
     if "FAIL" in res:
         raise Exception("Failed to start Listen mode")
-    pw = dev[1].request("WPS_NFC_TOKEN NDEF").rstrip()
+    pw = dev[1].global_request("WPS_NFC_TOKEN NDEF").rstrip()
     if "FAIL" in pw:
         raise Exception("Failed to generate password token")
-    res = dev[1].request("P2P_SET nfc_tag 1").rstrip()
+    res = dev[1].global_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()
+    sel = dev[1].global_request("NFC_GET_HANDOVER_SEL NDEF P2P-CR-TAG").rstrip()
     if "FAIL" in sel:
         raise Exception("Failed to generate NFC connection handover select")
 
     logger.info("Read NFC Tag on the GO to trigger invitation")
-    res = dev[0].request("WPS_NFC_TAG_READ " + sel)
+    res = dev[0].global_request("WPS_NFC_TAG_READ " + sel)
     if "FAIL" in res:
         raise Exception("Failed to provide NFC tag contents to wpa_supplicant")
 
-    ev = dev[1].wait_event(grpform_events, timeout=30)
+    ev = dev[1].wait_global_event(grpform_events, timeout=30)
     if ev is None:
         raise Exception("Joining the group timed out")
     res = dev[1].group_form_result(ev)
@@ -526,25 +526,25 @@ def test_nfc_p2p_static_handover_join_tagdev_client(dev):
     check_ip_addr(res)
 
     logger.info("Write NFC Tag on another P2P Client")
-    res = dev[2].request("P2P_LISTEN")
+    res = dev[2].global_request("P2P_LISTEN")
     if "FAIL" in res:
         raise Exception("Failed to start Listen mode")
-    pw = dev[2].request("WPS_NFC_TOKEN NDEF").rstrip()
+    pw = dev[2].global_request("WPS_NFC_TOKEN NDEF").rstrip()
     if "FAIL" in pw:
         raise Exception("Failed to generate password token")
-    res = dev[2].request("P2P_SET nfc_tag 1").rstrip()
+    res = dev[2].global_request("P2P_SET nfc_tag 1").rstrip()
     if "FAIL" in res:
         raise Exception("Failed to enable NFC Tag for P2P static handover")
-    sel = dev[2].request("NFC_GET_HANDOVER_SEL NDEF P2P-CR-TAG").rstrip()
+    sel = dev[2].global_request("NFC_GET_HANDOVER_SEL NDEF P2P-CR-TAG").rstrip()
     if "FAIL" in sel:
         raise Exception("Failed to generate NFC connection handover select")
 
     logger.info("Read NFC Tag on the GO to trigger invitation")
-    res = dev[0].request("WPS_NFC_TAG_READ " + sel)
+    res = dev[0].global_request("WPS_NFC_TAG_READ " + sel)
     if "FAIL" in res:
         raise Exception("Failed to provide NFC tag contents to wpa_supplicant")
 
-    ev = dev[2].wait_event(grpform_events, timeout=30)
+    ev = dev[2].wait_global_event(grpform_events, timeout=30)
     if ev is None:
         raise Exception("Joining the group timed out")
     res = dev[2].group_form_result(ev)
-- 
1.8.3.2



More information about the HostAP mailing list