[PATCH] hwsim tests: work around iw scan getting stuck

Johannes Berg johannes at sipsolutions.net
Fri Jul 17 16:24:58 EDT 2015

From: Johannes Berg <johannes.berg at intel.com>

On recent kernels, it seems that something changed (scheduler?)
that makes hwsim send the scan done event so quickly that iw isn't
scheduled back in to listen for it, causing iw to get stuck.

Work around this by using the scan trigger command (it'll be quick
enough so that we don't really need to wait) and the scan trigger
and dump commands where the results are required (and use a small
sleep there instead of waiting for the scan results.)

I'll try to fix this separately in iw later.

Signed-off-by: Johannes Berg <johannes.berg at intel.com>
 tests/hwsim/test_ap_ht.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tests/hwsim/test_ap_ht.py b/tests/hwsim/test_ap_ht.py
index e6895c55c28c..8a8aa9f98d5e 100644
--- a/tests/hwsim/test_ap_ht.py
+++ b/tests/hwsim/test_ap_ht.py
@@ -17,7 +17,7 @@ from test_ap_csa import csa_supported
 def clear_scan_cache(ifname):
     subprocess.call(['ifconfig', ifname, 'up'])
-    subprocess.call(['iw', ifname, 'scan', 'freq', '2412', 'flush'])
+    subprocess.call(['iw', ifname, 'scan', 'trigger', 'freq', '2412', 'flush'])
     subprocess.call(['ifconfig', ifname, 'down'])
@@ -144,7 +144,9 @@ def test_ap_ht40_scan_not_affected(dev, apdev):
     hostapd.add_ap(apdev[1]['ifname'], params)
     subprocess.call(['ifconfig', apdev[0]['ifname'], 'up'])
-    subprocess.call(['iw', apdev[0]['ifname'], 'scan', 'freq', '2462'],
+    subprocess.call(['iw', apdev[0]['ifname'], 'scan', 'trigger', 'freq', '2462'])
+    time.sleep(0.5)
+    subprocess.call(['iw', apdev[0]['ifname'], 'scan', 'dump'],
                     stdout=open('/dev/null', 'w'))
     subprocess.call(['ifconfig', apdev[0]['ifname'], 'down'])

More information about the HostAP mailing list