From b2eb3fe21c8aa70c697b9bef55d1a32e0ee3ff40 Mon Sep 17 00:00:00 2001
From: Jouni Malinen <j@w1.fi>
Date: Mon, 22 Dec 2014 22:07:54 +0200
Subject: [PATCH] tests: Fix ap_ht_40mhz_intolerant_ap

The previous design did not actually break from the wait loop when the
AP changed back to 40 MHz channel and as such, ended up waiting the full
30 second time. Furthermore, the five second delay time for returning
back to 40 MHz was not sufficiently long to test behavior correctly
since the STA did not have any chances of returning the next coex report
before the AP had returned to 40 MHz. Increase the AP wait time to 15
seconds so that the once per 10 seconds OBSS scan from the STA gets in
before changing back to 40 MHz channel (after the 40 MHz intolerant AP
gets disabled).

Signed-off-by: Jouni Malinen <j@w1.fi>
---
 tests/hwsim/test_ap_ht.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/tests/hwsim/test_ap_ht.py b/tests/hwsim/test_ap_ht.py
index bbd52708e..3f8b7b0f3 100644
--- a/tests/hwsim/test_ap_ht.py
+++ b/tests/hwsim/test_ap_ht.py
@@ -584,7 +584,7 @@ def test_ap_ht_40mhz_intolerant_ap(dev, apdev):
     params = { "ssid": "ht",
                "channel": "6",
                "ht_capab": "[HT40-]",
-               "obss_interval": "1" }
+               "obss_interval": "3" }
     hapd = hostapd.add_ap(apdev[0]['ifname'], params)
 
     dev[0].connect("ht", key_mgmt="NONE", scan_freq="2437")
@@ -613,15 +613,18 @@ def test_ap_ht_40mhz_intolerant_ap(dev, apdev):
         raise Exception("Failed to disable 40 MHz intolerant AP")
 
     # make sure the intolerant AP disappears from scan results more quickly
-    dev[0].scan(only_new=True)
-    dev[0].scan(freq="2432", only_new=True)
+    dev[0].scan(type="ONLY", freq="2432", only_new=True)
+    dev[0].scan(type="ONLY", freq="2432", only_new=True)
+    dev[0].dump_monitor()
 
     logger.info("Waiting for AP to move back to 40 MHz channel")
     ok = False
     for i in range(0, 30):
         time.sleep(1)
         if hapd.get_status_field("secondary_channel") == "-1":
+            logger.info("AP moved to 40 MHz channel")
             ok = True
+            break
     if not ok:
         raise Exception("AP did not move to 40 MHz channel")