]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Add negative scan tests
authorJohannes Berg <johannes.berg@intel.com>
Tue, 8 Oct 2019 12:11:09 +0000 (14:11 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 27 Oct 2019 17:50:22 +0000 (19:50 +0200)
There was a bug in wmediumd in that it didn't set the
frequency of frames, and thus they were always received
by mac80211_hwsim, regardless of channel it was on.

Add two tests that verify we only find a single instance
of an AP if we only have that one, and run this both with
and without wmediumd.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
tests/hwsim/test_scan.py
tests/hwsim/test_wmediumd.py

index 0b302d5049a4d9a67013c699f74833cd5cb6941a..a1e41713ab0d15f169fb70979b083e8ed787caa9 100644 (file)
@@ -1886,3 +1886,20 @@ def test_connect_mbssid_open_1(dev, apdev):
     # able to start connection attempt.
     dev[0].request("REMOVE_NETWORK all")
     dev[0].dump_monitor()
+
+def test_scan_only_one(dev, apdev):
+    """Test that scanning with a single active AP only returns that one"""
+    dev[0].flush_scan_cache()
+    hostapd.add_ap(apdev[0], {"ssid": "test-scan"})
+    bssid = apdev[0]['bssid']
+
+    check_scan(dev[0], "use_id=1", test_busy=True)
+    dev[0].scan_for_bss(bssid, freq="2412")
+
+    status, stdout = hostapd.cmd_execute(dev[0], ['iw', dev[0].ifname, 'scan', 'dump'])
+    if status != 0:
+        raise Exception("iw scan dump failed with code %d" % status)
+    lines = stdout.split('\n')
+    entries = len(list(filter(lambda x: x.startswith('BSS '), lines)))
+    if entries != 1:
+        raise Exception("expected to find 1 BSS entry, got %d" % entries)
index 0a8810194ccdce6357fb60ab1d271847899871d1..a9d4c8e19bc0494f54ead93df23da96644e1a2e7 100644 (file)
@@ -9,6 +9,7 @@ from utils import HwsimSkip
 from wpasupplicant import WpaSupplicant
 from tshark import run_tshark
 from test_ap_open import _test_ap_open
+from test_scan import test_scan_only_one as _test_scan_only_one
 from test_wpas_mesh import check_mesh_support, check_mesh_group_added
 from test_wpas_mesh import check_mesh_peer_connected, add_open_mesh_network
 from test_wpas_mesh import check_mesh_group_removed
@@ -462,3 +463,21 @@ def _test_wmediumd_path_rann(dev, apdev):
         dev[i].mesh_group_remove()
         check_mesh_group_removed(dev[i])
         dev[i].dump_monitor()
+
+def test_wmediumd_scan_only_one(dev, apdev, params):
+    """
+    Test that scanning with a single active AP only returns that one
+    (with wmediumd enabled)
+    """
+    fd, fn = tempfile.mkstemp()
+    try:
+        f = os.fdopen(fd, 'w')
+        f.write(CFG % (apdev[0]['bssid'], dev[0].own_addr()))
+        f.close()
+        p = start_wmediumd(fn, params)
+        try:
+            _test_scan_only_one(dev, apdev)
+        finally:
+            stop_wmediumd(p, params)
+    finally:
+        os.unlink(fn)