public inbox for iwd@lists.linux.dev
 help / color / mirror / Atom feed
From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH v3 2/4] auto-t: refactor testSAE-roam into connect/roam functions
Date: Mon,  9 Mar 2026 09:57:44 -0700	[thread overview]
Message-ID: <20260309165746.2073055-2-prestwoj@gmail.com> (raw)
In-Reply-To: <20260309165746.2073055-1-prestwoj@gmail.com>

This makes adding roaming tests easier if they don't strictly conform
to the existing test structure. By adding connect/roam helpers future
tests will have a bit more control on whats being tested.
---
 autotests/testSAE-roam/connection_test.py | 62 +++++++++--------------
 1 file changed, 25 insertions(+), 37 deletions(-)

diff --git a/autotests/testSAE-roam/connection_test.py b/autotests/testSAE-roam/connection_test.py
index 718bfd77..c813f00f 100644
--- a/autotests/testSAE-roam/connection_test.py
+++ b/autotests/testSAE-roam/connection_test.py
@@ -13,73 +13,61 @@ import testutil
 from config import ctx
 
 class Test(unittest.TestCase):
-    def validate_connection(self, wd, ft=True, check_used_pmksa=False):
-        device = wd.list_devices(1)[0]
-
+    def connect(self, wd, device, hapd):
         # This won't guarantee all BSS's are found, but at least ensures that
         # at least one will be.
         device.get_ordered_network('TestFT', full_scan=True)
 
-        self.assertFalse(self.bss_hostapd[0].list_sta())
-        self.assertFalse(self.bss_hostapd[1].list_sta())
+        self.assertFalse(hapd.list_sta())
 
-        device.connect_bssid(self.bss_hostapd[0].bssid)
+        device.connect_bssid(hapd.bssid)
 
         condition = 'obj.state == DeviceState.connected'
         wd.wait_for_object_condition(device, condition)
 
-        self.bss_hostapd[0].wait_for_event('AP-STA-CONNECTED %s' % device.address)
+        hapd.wait_for_event('AP-STA-CONNECTED %s' % device.address)
 
         self.assertFalse(self.bss_hostapd[1].list_sta())
 
         testutil.test_iface_operstate(device.name)
-        testutil.test_ifaces_connected(self.bss_hostapd[0].ifname, device.name)
-        self.assertRaises(Exception, testutil.test_ifaces_connected,
-                          (self.bss_hostapd[1].ifname, device.name, True, True))
+        testutil.test_ifaces_connected(hapd.ifname, device.name)
 
-        # If PMKSA was used, hostapd should not include the sae_group key in
-        # its status for the station.
-        sta_status = self.bss_hostapd[0].sta_status(device.address)
-        if check_used_pmksa:
-            self.assertNotIn("sae_group", sta_status.keys())
-        else:
-            self.assertIn("sae_group", sta_status.keys())
+    def roam(self, wd, device, hapd_from, hapd_to):
+        device.roam(hapd_to.bssid)
 
-        device.roam(self.bss_hostapd[1].bssid)
-
-        # Check that iwd is on BSS 1 once out of roaming state and doesn't
+        # Check that iwd is on hapd_to once out of roaming state and doesn't
         # go through 'disconnected', 'autoconnect', 'connecting' in between
         from_condition = 'obj.state == DeviceState.roaming'
         to_condition = 'obj.state == DeviceState.connected'
         wd.wait_for_object_change(device, from_condition, to_condition)
 
-        self.bss_hostapd[1].wait_for_event('AP-STA-CONNECTED %s' % device.address)
+        hapd_to.wait_for_event('AP-STA-CONNECTED %s' % device.address)
 
         testutil.test_iface_operstate(device.name)
-        testutil.test_ifaces_connected(self.bss_hostapd[1].ifname, device.name)
+        testutil.test_ifaces_connected(hapd_to.ifname, device.name)
         self.assertRaises(Exception, testutil.test_ifaces_connected,
-                          (self.bss_hostapd[0].ifname, device.name, True, True))
+                          (hapd_from.ifname, device.name, True, True))
 
-        if not ft:
-                return
 
-        device.roam(self.bss_hostapd[2].bssid)
+    def validate_connection(self, wd, ft=True, check_used_pmksa=False):
+        device = wd.list_devices(1)[0]
 
-        condition = 'obj.state == DeviceState.roaming'
-        wd.wait_for_object_condition(device, condition)
+        self.connect(wd, device, self.bss_hostapd[0])
 
-        condition = 'obj.state != DeviceState.roaming'
-        wd.wait_for_object_condition(device, condition)
+        # If PMKSA was used, hostapd should not include the sae_group key in
+        # its status for the station.
+        sta_status = self.bss_hostapd[0].sta_status(device.address)
+        if check_used_pmksa:
+            self.assertNotIn("sae_group", sta_status.keys())
+        else:
+            self.assertIn("sae_group", sta_status.keys())
 
-        condition = 'obj.state == DeviceState.connected'
-        wd.wait_for_object_condition(device, condition)
+        self.roam(wd, device, self.bss_hostapd[0], self.bss_hostapd[1])
 
-        self.bss_hostapd[2].wait_for_event('AP-STA-CONNECTED %s' % device.address)
+        if not ft:
+            return
 
-        testutil.test_iface_operstate(device.name)
-        testutil.test_ifaces_connected(self.bss_hostapd[2].ifname, device.name)
-        self.assertRaises(Exception, testutil.test_ifaces_connected,
-                            (self.bss_hostapd[1].ifname, device.name, True, True))
+        self.roam(wd, device, self.bss_hostapd[1], self.bss_hostapd[2])
 
     def test_ft_roam_success(self):
         wd = IWD(True)
-- 
2.34.1


  reply	other threads:[~2026-03-09 16:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-09 16:57 [PATCH v3 1/4] station: check return of handshake_state_set_pmksa James Prestwood
2026-03-09 16:57 ` James Prestwood [this message]
2026-03-09 16:57 ` [PATCH v3 3/4] auto-t: Add test to roam back to BSS with existing PMKSA James Prestwood
2026-03-09 16:57 ` [PATCH v3 4/4] handshake: clear expiration of pmksa in _steal_pmksa() James Prestwood
2026-03-10 14:33 ` [PATCH v3 1/4] station: check return of handshake_state_set_pmksa 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=20260309165746.2073055-2-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