diff mbox

[2/9] tests: Wait for scan to complete on all interfaces in reset()

Message ID 1435842900-25523-3-git-send-email-ilan.peer@intel.com
State Accepted
Headers show

Commit Message

Ilan Peer July 2, 2015, 1:14 p.m. UTC
From: Andrei Otcheretianski <andrei.otcheretianski@intel.com>

When wpasupplicant executes reset() it waits until all the ongoing
scans are completed. However it checks the status of the wlanX interface
only. If a dedicated P2P device interface is used, scan may be still
running on the P2P Device interface, e.g., P2P_FIND. This might affect
subsequent tests.

Fix this by waiting until the scan is done both on wlanX and P2P
Device interfaces.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Reviewed-by: Ilan Peer <ilan.peer@intel.com>
---
 tests/hwsim/wpasupplicant.py | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

Comments

Jouni Malinen July 8, 2015, 2:42 p.m. UTC | #1
On Thu, Jul 02, 2015 at 04:14:53PM +0300, Ilan Peer wrote:
> When wpasupplicant executes reset() it waits until all the ongoing
> scans are completed. However it checks the status of the wlanX interface
> only. If a dedicated P2P device interface is used, scan may be still
> running on the P2P Device interface, e.g., P2P_FIND. This might affect
> subsequent tests.
> 
> Fix this by waiting until the scan is done both on wlanX and P2P
> Device interfaces.

Thanks, applied.
diff mbox

Patch

diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py
index 4323ff5..1531969 100644
--- a/tests/hwsim/wpasupplicant.py
+++ b/tests/hwsim/wpasupplicant.py
@@ -138,8 +138,10 @@  class WpaSupplicant:
 
         iter = 0
         while iter < 60:
-            state = self.get_driver_status_field("scan_state")
-            if "SCAN_STARTED" in state or "SCAN_REQUESTED" in state:
+            state1 = self.get_driver_status_field("scan_state")
+            state2 = self.get_driver_status_field("scan_state", ifname="p2p-dev-" + self.ifname)
+            states = str(state1) + " " + str(state2)
+            if "SCAN_STARTED" in states or "SCAN_REQUESTED" in states:
                 logger.info(self.ifname + ": Waiting for scan operation to complete before continuing")
                 time.sleep(1)
             else:
@@ -354,8 +356,11 @@  class WpaSupplicant:
             return vals[field]
         return None
 
-    def get_driver_status(self):
-        res = self.request("STATUS-DRIVER")
+    def get_driver_status(self, ifname=None):
+        if ifname is None:
+            res = self.request("STATUS-DRIVER")
+        else:
+            res = self.global_request("IFNAME=%s STATUS-DRIVER" % ifname)
         lines = res.splitlines()
         vals = dict()
         for l in lines:
@@ -367,8 +372,8 @@  class WpaSupplicant:
             vals[name] = value
         return vals
 
-    def get_driver_status_field(self, field):
-        vals = self.get_driver_status()
+    def get_driver_status_field(self, field, ifname=None):
+        vals = self.get_driver_status(ifname)
         if field in vals:
             return vals[field]
         return None