Updated to hostap_2_6
[mech_eap.git] / libeap / tests / hwsim / test_p2p_concurrency.py
index 16be8c6..81545cc 100644 (file)
@@ -4,6 +4,7 @@
 # This software may be distributed under the terms of the BSD license.
 # See README for more details.
 
+from remotehost import remote_compatible
 import logging
 logger = logging.getLogger()
 import subprocess
@@ -11,27 +12,21 @@ import time
 
 import hwsim_utils
 import hostapd
-from test_p2p_grpform import go_neg_pin_authorized
-from test_p2p_grpform import go_neg_pbc
-from test_p2p_grpform import check_grpform_results
-from test_p2p_grpform import remove_group
-from test_p2p_persistent import form
-from test_p2p_persistent import invite_from_cli
-from test_p2p_persistent import invite_from_go
-from test_p2p_persistent import invite
+from p2p_utils import *
 from test_ap_ht import clear_scan_cache
 from utils import HwsimSkip
 
+@remote_compatible
 def test_concurrent_autogo(dev, apdev):
     """Concurrent P2P autonomous GO"""
     logger.info("Connect to an infrastructure AP")
     dev[0].request("P2P_SET cross_connect 0")
-    hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
+    hapd = hostapd.add_ap(apdev[0], { "ssid": "test-open" })
     dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2412")
     hwsim_utils.test_connectivity(dev[0], hapd)
 
     logger.info("Start a P2P group while associated to an AP")
-    dev[0].request("SET p2p_no_group_iface 0")
+    dev[0].global_request("SET p2p_no_group_iface 0")
     dev[0].p2p_start_go()
     pin = dev[1].wps_read_pin()
     dev[0].p2p_go_authorize_client(pin)
@@ -46,7 +41,7 @@ def test_concurrent_autogo(dev, apdev):
 
 def test_concurrent_autogo_5ghz_ht40(dev, apdev):
     """Concurrent P2P autonomous GO on 5 GHz and HT40 co-ex"""
-    clear_scan_cache(apdev[1]['ifname'])
+    clear_scan_cache(apdev[1])
     try:
         hapd = None
         hapd2 = None
@@ -55,20 +50,20 @@ def test_concurrent_autogo_5ghz_ht40(dev, apdev):
                    "channel": "153",
                    "country_code": "US",
                    "ht_capab": "[HT40-]" }
-        hapd2 = hostapd.add_ap(apdev[1]['ifname'], params)
+        hapd2 = hostapd.add_ap(apdev[1], params)
 
         params = { "ssid": "test-open-5",
                    "hw_mode": "a",
                    "channel": "149",
                    "country_code": "US" }
-        hapd = hostapd.add_ap(apdev[0]['ifname'], params)
+        hapd = hostapd.add_ap(apdev[0], params)
 
         dev[0].request("P2P_SET cross_connect 0")
         dev[0].scan_for_bss(apdev[0]['bssid'], freq=5745)
         dev[0].scan_for_bss(apdev[1]['bssid'], freq=5765)
         dev[0].connect("test-open-5", key_mgmt="NONE", scan_freq="5745")
 
-        dev[0].request("SET p2p_no_group_iface 0")
+        dev[0].global_request("SET p2p_no_group_iface 0")
         if "OK" not in dev[0].global_request("P2P_GROUP_ADD ht40"):
             raise Exception("P2P_GROUP_ADD failed")
         ev = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=5)
@@ -103,7 +98,7 @@ def test_concurrent_autogo_5ghz_ht40(dev, apdev):
 def test_concurrent_autogo_crossconnect(dev, apdev):
     """Concurrent P2P autonomous GO"""
     dev[0].global_request("P2P_SET cross_connect 1")
-    hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
+    hapd = hostapd.add_ap(apdev[0], { "ssid": "test-open" })
     dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2412")
 
     dev[0].global_request("SET p2p_no_group_iface 0")
@@ -137,15 +132,16 @@ def test_concurrent_autogo_crossconnect(dev, apdev):
         raise Exception("Timeout on cross connection disabled event")
     dev[0].global_request("P2P_SET cross_connect 0")
 
+@remote_compatible
 def test_concurrent_p2pcli(dev, apdev):
     """Concurrent P2P client join"""
     logger.info("Connect to an infrastructure AP")
-    hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
+    hapd = hostapd.add_ap(apdev[0], { "ssid": "test-open" })
     dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2412")
     hwsim_utils.test_connectivity(dev[0], hapd)
 
     logger.info("Join a P2P group while associated to an AP")
-    dev[0].request("SET p2p_no_group_iface 0")
+    dev[0].global_request("SET p2p_no_group_iface 0")
     dev[1].p2p_start_go(freq=2412)
     pin = dev[0].wps_read_pin()
     dev[1].p2p_go_authorize_client(pin)
@@ -158,15 +154,16 @@ def test_concurrent_p2pcli(dev, apdev):
     logger.info("Confirm AP connection after P2P group removal")
     hwsim_utils.test_connectivity(dev[0], hapd)
 
+@remote_compatible
 def test_concurrent_grpform_go(dev, apdev):
     """Concurrent P2P group formation to become GO"""
     logger.info("Connect to an infrastructure AP")
-    hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
+    hapd = hostapd.add_ap(apdev[0], { "ssid": "test-open" })
     dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2412")
     hwsim_utils.test_connectivity(dev[0], hapd)
 
     logger.info("Form a P2P group while associated to an AP")
-    dev[0].request("SET p2p_no_group_iface 0")
+    dev[0].global_request("SET p2p_no_group_iface 0")
 
     [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
                                            r_dev=dev[1], r_intent=0)
@@ -176,15 +173,16 @@ def test_concurrent_grpform_go(dev, apdev):
     logger.info("Confirm AP connection after P2P group removal")
     hwsim_utils.test_connectivity(dev[0], hapd)
 
+@remote_compatible
 def test_concurrent_grpform_cli(dev, apdev):
     """Concurrent P2P group formation to become P2P Client"""
     logger.info("Connect to an infrastructure AP")
-    hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
+    hapd = hostapd.add_ap(apdev[0], { "ssid": "test-open" })
     dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2412")
     hwsim_utils.test_connectivity(dev[0], hapd)
 
     logger.info("Form a P2P group while associated to an AP")
-    dev[0].request("SET p2p_no_group_iface 0")
+    dev[0].global_request("SET p2p_no_group_iface 0")
 
     [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=0,
                                            r_dev=dev[1], r_intent=15)
@@ -194,14 +192,15 @@ def test_concurrent_grpform_cli(dev, apdev):
     logger.info("Confirm AP connection after P2P group removal")
     hwsim_utils.test_connectivity(dev[0], hapd)
 
+@remote_compatible
 def test_concurrent_grpform_while_connecting(dev, apdev):
     """Concurrent P2P group formation while connecting to an AP"""
     logger.info("Start connection to an infrastructure AP")
-    hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
+    hapd = hostapd.add_ap(apdev[0], { "ssid": "test-open" })
     dev[0].connect("test-open", key_mgmt="NONE", wait_connect=False)
 
     logger.info("Form a P2P group while connecting to an AP")
-    dev[0].request("SET p2p_no_group_iface 0")
+    dev[0].global_request("SET p2p_no_group_iface 0")
 
     [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_freq=2412,
                                            r_dev=dev[1], r_freq=2412)
@@ -211,15 +210,16 @@ def test_concurrent_grpform_while_connecting(dev, apdev):
     logger.info("Confirm AP connection after P2P group removal")
     hwsim_utils.test_connectivity(dev[0], hapd)
 
+@remote_compatible
 def test_concurrent_grpform_while_connecting2(dev, apdev):
     """Concurrent P2P group formation while connecting to an AP (2)"""
     logger.info("Start connection to an infrastructure AP")
-    hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
+    hapd = hostapd.add_ap(apdev[0], { "ssid": "test-open" })
     dev[0].connect("test-open", key_mgmt="NONE", wait_connect=False)
     dev[1].flush_scan_cache()
 
     logger.info("Form a P2P group while connecting to an AP")
-    dev[0].request("SET p2p_no_group_iface 0")
+    dev[0].global_request("SET p2p_no_group_iface 0")
 
     [i_res, r_res] = go_neg_pbc(i_dev=dev[0], i_intent=15, i_freq=2412,
                                 r_dev=dev[1], r_intent=0, r_freq=2412)
@@ -230,14 +230,15 @@ def test_concurrent_grpform_while_connecting2(dev, apdev):
     dev[0].wait_completed()
     hwsim_utils.test_connectivity(dev[0], hapd)
 
+@remote_compatible
 def test_concurrent_grpform_while_connecting3(dev, apdev):
     """Concurrent P2P group formation while connecting to an AP (3)"""
     logger.info("Start connection to an infrastructure AP")
-    hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
+    hapd = hostapd.add_ap(apdev[0], { "ssid": "test-open" })
     dev[0].connect("test-open", key_mgmt="NONE", wait_connect=False)
 
     logger.info("Form a P2P group while connecting to an AP")
-    dev[0].request("SET p2p_no_group_iface 0")
+    dev[0].global_request("SET p2p_no_group_iface 0")
 
     [i_res, r_res] = go_neg_pbc(i_dev=dev[1], i_intent=15, i_freq=2412,
                                 r_dev=dev[0], r_intent=0, r_freq=2412)
@@ -248,10 +249,11 @@ def test_concurrent_grpform_while_connecting3(dev, apdev):
     dev[0].wait_completed()
     hwsim_utils.test_connectivity(dev[0], hapd)
 
+@remote_compatible
 def test_concurrent_persistent_group(dev, apdev):
     """Concurrent P2P persistent group"""
     logger.info("Connect to an infrastructure AP")
-    hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open", "channel": "2" })
+    hostapd.add_ap(apdev[0], { "ssid": "test-open", "channel": "2" })
     dev[0].global_request("SET p2p_no_group_iface 0")
     dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2417")
 
@@ -274,7 +276,7 @@ def test_concurrent_invitation_channel_mismatch(dev, apdev):
     dev[1].dump_monitor()
 
     logger.info("Connect to an infrastructure AP")
-    hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open", "channel": "2" })
+    hostapd.add_ap(apdev[0], { "ssid": "test-open", "channel": "2" })
     dev[0].global_request("SET p2p_no_group_iface 0")
     dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2417")
     invite(dev[1], dev[0], extra="freq=2412")