diff mbox

tests: Make wnm_bss_tm_req_with_mbo_ie more robust

Message ID 1497248968-25795-2-git-send-email-andrei.otcheretianski@intel.com
State Accepted
Headers show

Commit Message

Andrei Otcheretianski June 12, 2017, 6:29 a.m. UTC
On slow machines or inside VM it may take some time for "DISCONNECTED"
event to arrive. Since the retry delay counter is started already, it
may result in less than 5 seconds time between "DISCONNECTED" and
"CONNECTED" events.
Fix the test by taking more accurate timestamps between the events.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
---
 tests/hwsim/test_wnm.py | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

Comments

Jouni Malinen July 18, 2017, 11:12 a.m. UTC | #1
On Mon, Jun 12, 2017 at 09:29:28AM +0300, Andrei Otcheretianski wrote:
> On slow machines or inside VM it may take some time for "DISCONNECTED"
> event to arrive. Since the retry delay counter is started already, it
> may result in less than 5 seconds time between "DISCONNECTED" and
> "CONNECTED" events.
> Fix the test by taking more accurate timestamps between the events.

Thanks, applied.
diff mbox

Patch

diff --git a/tests/hwsim/test_wnm.py b/tests/hwsim/test_wnm.py
index 4a526a8..eeb2350 100644
--- a/tests/hwsim/test_wnm.py
+++ b/tests/hwsim/test_wnm.py
@@ -16,6 +16,7 @@  import hostapd
 from wpasupplicant import WpaSupplicant
 from utils import alloc_fail, fail_test, wait_fail_trigger
 from wlantest import Wlantest
+from datetime import datetime
 
 @remote_compatible
 def test_wnm_bss_transition_mgmt(dev, apdev):
@@ -1548,6 +1549,8 @@  def test_wnm_bss_tm_req_with_mbo_ie(dev, apdev):
     if ev is None or "reason=3" not in ev:
         raise Exception("Timeout waiting for MBO-TRANSITION-REASON event")
 
+    t0 = datetime.now()
+
     ev = hapd.wait_event(['BSS-TM-RESP'], timeout=10)
     if ev is None:
         raise Exception("No BSS Transition Management Response")
@@ -1562,16 +1565,16 @@  def test_wnm_bss_tm_req_with_mbo_ie(dev, apdev):
     if 'OK' not in dev[0].request("SCAN_INTERVAL 1"):
         raise Exception("Failed to set scan interval")
 
+    # Wait until connected
+    ev = dev[0].wait_event(['CTRL-EVENT-CONNECTED'], 10)
+    if ev is None:
+        raise Exception("Station did not connect")
+
     # Make sure no connection is made during the retry delay
-    ev = dev[0].wait_event(['CTRL-EVENT-CONNECTED'], 5)
-    if ev is not None:
+    time_diff = datetime.now() - t0
+    if time_diff.total_seconds() < 5:
         raise Exception("Station connected before assoc retry delay was over")
 
-    # After the assoc retry delay is over, we can reconnect
-    ev = dev[0].wait_event(['CTRL-EVENT-CONNECTED'], 5)
-    if ev is None:
-        raise Exception("Station did not connect after assoc retry delay is over")
-
     if "OK" not in dev[0].request("SET mbo_cell_capa 3"):
         raise Exception("Failed to set STA as cellular data not-capable")