From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH v2 4/4] auto-t: add test for known frequency sorting/maximum
Date: Wed, 24 Jan 2024 05:40:01 -0800 [thread overview]
Message-ID: <20240124134001.20453-4-prestwoj@gmail.com> (raw)
In-Reply-To: <20240124134001.20453-1-prestwoj@gmail.com>
Modify the existing frequency test to check that the ordering
lines up with the ranking of the BSS.
Add a test to check that quick scans limit the number of known
frequencies.
---
autotests/testKnownNetworks/frequency_test.py | 110 ++++++++++++++++--
autotests/testKnownNetworks/hw.conf | 1 +
2 files changed, 102 insertions(+), 9 deletions(-)
diff --git a/autotests/testKnownNetworks/frequency_test.py b/autotests/testKnownNetworks/frequency_test.py
index 83e51c06..c2fd1290 100644
--- a/autotests/testKnownNetworks/frequency_test.py
+++ b/autotests/testKnownNetworks/frequency_test.py
@@ -4,17 +4,15 @@ import unittest
import sys
sys.path.append('../util')
-import iwd
from iwd import IWD
from iwd import PSKAgent
-from iwd import NetworkType
-import testutil
+from hwsim import Hwsim
import os
from configparser import ConfigParser
class Test(unittest.TestCase):
def connect_network(self, wd, device, network):
- ordered_network = device.get_ordered_network(network)
+ ordered_network = device.get_ordered_network(network, full_scan=True)
condition = 'not obj.connected'
wd.wait_for_object_condition(ordered_network.network_object, condition)
@@ -30,7 +28,7 @@ class Test(unittest.TestCase):
wd.wait_for_object_condition(ordered_network.network_object, condition)
def test_connection_success(self):
- wd = IWD(True, '/tmp')
+ wd = self.wd
psk_agent = PSKAgent("secret123")
wd.register_psk_agent(psk_agent)
@@ -38,6 +36,11 @@ class Test(unittest.TestCase):
devices = wd.list_devices(1)
device = devices[0]
+
+ # Set the signals so that the 2.4GHz ranking will be higher
+ self.ssidccmp_2g_rule.signal = -2000
+ self.ssidccmp_5g_rule.signal = -8000
+
#
# Connect to the PSK network, then Hotspot so IWD creates 2 entries in
# the known frequency file.
@@ -75,8 +78,10 @@ class Test(unittest.TestCase):
#
self.assertIsNotNone(psk_freqs)
self.assertIsNotNone(psk_uuid)
- self.assertIn('5180', psk_freqs)
- self.assertIn('2412', psk_freqs)
+
+ # The 2.4GHz frequency should come first, as it was ranked higher
+ self.assertEqual('2412', psk_freqs[0])
+ self.assertEqual('5180', psk_freqs[1])
self.assertIsNotNone(hs20_freqs)
self.assertIsNotNone(hs20_uuid)
@@ -92,6 +97,10 @@ class Test(unittest.TestCase):
psk_agent = PSKAgent("secret123")
wd.register_psk_agent(psk_agent)
+ # Now set the signals so that the 5GHz ranking will be higher
+ self.ssidccmp_2g_rule.signal = -8000
+ self.ssidccmp_5g_rule.signal = -2000
+
#
# Reconnect, this should generate a completely new UUID since we
# previously forgot the network.
@@ -120,8 +129,78 @@ class Test(unittest.TestCase):
self.assertIsNotNone(psk_freqs)
self.assertIsNotNone(psk_uuid2)
self.assertNotEqual(psk_uuid, psk_uuid2)
- self.assertIn('5180', psk_freqs)
- self.assertIn('2412', psk_freqs)
+ # Now the 5GHz frequency should be first
+ self.assertEqual('5180', psk_freqs[0])
+ self.assertEqual('2412', psk_freqs[1])
+
+ def test_maximum_frequencies(self):
+ psk_agent = PSKAgent("secret123")
+ self.wd.register_psk_agent(psk_agent)
+
+ devices = self.wd.list_devices(1)
+ device = devices[0]
+
+ # Connect and generate a known frequencies file
+ self.connect_network(self.wd, device, 'ssidCCMP')
+
+ self.wd.unregister_psk_agent(psk_agent)
+
+ #
+ # Rewrite the known frequencies file to move the valid network
+ # frequencies to the end, past the maximum for a quick scan
+ #
+ config = ConfigParser()
+ config.read('/tmp/iwd/.known_network.freq')
+ for s in config.sections():
+ if os.path.basename(config[s]['name']) == 'ssidCCMP.psk':
+ config.set(s, 'list', "2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467 2472 2484 2412 5180")
+ break
+
+ self.wd.stop()
+
+ with open('/tmp/iwd/.known_network.freq', 'w') as f:
+ config.write(f)
+
+ self.wd = IWD(True)
+
+ devices = self.wd.list_devices(1)
+ device = devices[0]
+
+ device.autoconnect = True
+
+ device.wait_for_event("autoconnect_quick")
+
+ condition = "obj.scanning == True"
+ self.wd.wait_for_object_condition(device, condition)
+
+ condition = "obj.scanning == False"
+ self.wd.wait_for_object_condition(device, condition)
+
+ #
+ # Check that the quick scan didn't return any results
+ #
+ with self.assertRaises(Exception):
+ device.get_ordered_network("ssidCCMP", scan_if_needed=False)
+
+ device.wait_for_event("autoconnect_full")
+
+ condition = "obj.scanning == True"
+ self.wd.wait_for_object_condition(device, condition)
+
+ condition = "obj.scanning == False"
+ self.wd.wait_for_object_condition(device, condition)
+
+ #
+ # The full scan should now see the network
+ #
+ device.get_ordered_network("ssidCCMP", scan_if_needed=False)
+
+ def setUp(self):
+ self.wd = IWD(True)
+
+ def tearDown(self):
+ self.wd.stop()
+ self.wd = None
@classmethod
def setUpClass(cls):
@@ -129,10 +208,23 @@ class Test(unittest.TestCase):
conf = '[General]\nDisableANQP=0\n'
os.system('echo "%s" > /tmp/main.conf' % conf)
+ hwsim = Hwsim()
+
+ cls.ssidccmp_2g_rule = hwsim.rules.create()
+ cls.ssidccmp_2g_rule.source = hwsim.get_radio('rad1').addresses[0]
+ cls.ssidccmp_2g_rule.enabled = True
+
+ cls.ssidccmp_5g_rule = hwsim.rules.create()
+ cls.ssidccmp_5g_rule.source = hwsim.get_radio('rad2').addresses[0]
+ cls.ssidccmp_5g_rule.enabled = True
+
@classmethod
def tearDownClass(cls):
IWD.clear_storage()
os.remove('/tmp/main.conf')
+ cls.ssidccmp_2g_rule.remove()
+ cls.ssidccmp_5g_rule.remove()
+
if __name__ == '__main__':
unittest.main(exit=True)
diff --git a/autotests/testKnownNetworks/hw.conf b/autotests/testKnownNetworks/hw.conf
index 8a7ef73a..f68b63a5 100644
--- a/autotests/testKnownNetworks/hw.conf
+++ b/autotests/testKnownNetworks/hw.conf
@@ -2,6 +2,7 @@
num_radios=5
start_iwd=0
reg_domain=US
+hwsim_medium=yes
[HOSTAPD]
rad0=ssidNew.conf
--
2.34.1
next prev parent reply other threads:[~2024-01-24 13:40 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-24 13:39 [PATCH v2 1/4] knownnetworks: pass scan_bss to known_network_add_frequency James Prestwood
2024-01-24 13:39 ` [PATCH v2 2/4] knownnetworks: sort known frequencies by BSS rank James Prestwood
2024-01-24 18:10 ` Denis Kenzior
2024-01-24 18:33 ` James Prestwood
2024-01-24 18:44 ` Denis Kenzior
2024-01-24 18:55 ` James Prestwood
2024-01-24 19:06 ` Denis Kenzior
2024-01-25 13:21 ` James Prestwood
2024-01-25 15:39 ` Denis Kenzior
2024-01-24 13:40 ` [PATCH v2 3/4] station: knownnetworks: limit quick scans to 5 freqs per network James Prestwood
2024-01-24 18:21 ` Denis Kenzior
2024-01-24 13:40 ` James Prestwood [this message]
2024-01-24 18:16 ` [PATCH v2 1/4] knownnetworks: pass scan_bss to known_network_add_frequency Denis Kenzior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240124134001.20453-4-prestwoj@gmail.com \
--to=prestwoj@gmail.com \
--cc=iwd@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox