[PATCH 10/17] tests: change list_networks() to use global interface with P2P

Ilan Peer ilan.peer
Tue May 5 02:36:58 PDT 2015


From: Ben Rosenfeld <ben.rosenfeld at intel.com>

list_networks() always used the wlanX control interface to query
for the current list of networks. However, when a dedicated P2P
Device is used, the global control interface should be used.

Fix this by adding an optional parameter indicating that
the P2P networks are requested, and in such a case use
the global control interface.

In addition update test_p2p_persistent to use the argument
when needed.

Signed-off-by: Ben Rosenfeld <ben.rosenfeld at intel.com>
---
 tests/hwsim/test_p2p_persistent.py | 10 +++++-----
 tests/hwsim/wpasupplicant.py       |  7 +++++--
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/tests/hwsim/test_p2p_persistent.py b/tests/hwsim/test_p2p_persistent.py
index 65bf904..65bbc31 100644
--- a/tests/hwsim/test_p2p_persistent.py
+++ b/tests/hwsim/test_p2p_persistent.py
@@ -119,7 +119,7 @@ def test_persistent_group(dev):
 
     logger.info("Remove group on the client and try to invite from GO")
     id = None
-    for n in dev[0].list_networks():
+    for n in dev[0].list_networks(p2p=True):
         if "[P2P-PERSISTENT]" in n['flags']:
             id = n['id']
             break
@@ -143,7 +143,7 @@ def test_persistent_group(dev):
     if "FAIL" not in dev[1].request("REMOVE_NETWORK 1234567"):
         raise Exception("REMOVE_NETWORK succeeded unexpectedly")
     dev[1].request("REMOVE_NETWORK all")
-    if len(dev[1].list_networks()) > 0:
+    if len(dev[1].list_networks(p2p=True)) > 0:
         raise Exception("Unexpected network block remaining")
     invite(dev[0], dev[1])
     ev = dev[0].wait_global_event(["P2P-INVITATION-RESULT"], timeout=10)
@@ -201,7 +201,7 @@ def test_persistent_group_per_sta_psk(dev):
     dev[2].dump_monitor()
 
     for i in range(0, 3):
-        networks = dev[i].list_networks()
+        networks = dev[i].list_networks(p2p=True)
         if len(networks) != 1:
             raise Exception("Unexpected number of networks")
         if "[P2P-PERSISTENT]" not in networks[0]['flags']:
@@ -399,7 +399,7 @@ def test_persistent_go_client_list(dev):
 
     res = dev[0].p2p_start_go(persistent=True)
     id = None
-    for n in dev[0].list_networks():
+    for n in dev[0].list_networks(p2p=True):
         if "[P2P-PERSISTENT]" in n['flags']:
             id = n['id']
             break
@@ -548,7 +548,7 @@ def test_persistent_group_already_running(dev):
     listen_freq = peer['listen_freq']
     dev[0].dump_monitor()
     dev[1].dump_monitor()
-    networks = dev[0].list_networks()
+    networks = dev[0].list_networks(p2p=True)
     if len(networks) != 1:
         raise Exception("Unexpected number of networks")
     if "[P2P-PERSISTENT]" not in networks[0]['flags']:
diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py
index 1cdcc09..ffa8435 100644
--- a/tests/hwsim/wpasupplicant.py
+++ b/tests/hwsim/wpasupplicant.py
@@ -198,8 +198,11 @@ class WpaSupplicant:
             raise Exception("SET_NETWORK failed")
         return None
 
-    def list_networks(self):
-        res = self.request("LIST_NETWORKS")
+    def list_networks(self, p2p=False):
+        if (p2p):
+            res = self.global_request("LIST_NETWORKS")
+        else:
+            res = self.request("LIST_NETWORKS")
         lines = res.splitlines()
         networks = []
         for l in lines:
-- 
1.9.1




More information about the Hostap mailing list