[PATCH 2/2] tests: Add test_ap_config_reload_on_sighup_ssid_changes

Michal Kazior kazikcz at gmail.com
Thu Oct 22 03:34:02 PDT 2026


From: Michal Kazior <michal at plume.com>

The test validates if the nl80211 AP is stopped
and started upon SSID changes.

Signed-off-by: Michal Kazior <michal at plume.com>
---
 tests/hwsim/test_ap_config.py | 43 +++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/tests/hwsim/test_ap_config.py b/tests/hwsim/test_ap_config.py
index 2d3493199..a9cd1f343 100644
--- a/tests/hwsim/test_ap_config.py
+++ b/tests/hwsim/test_ap_config.py
@@ -15,6 +15,23 @@ from remotehost import remote_compatible
 import hostapd
 from utils import alloc_fail, fail_test
 
+def get_kernel_ssid(ifname):
+    cmd = subprocess.Popen(["iw", "dev", ifname, "info"], stdout=subprocess.PIPE)
+    out, err = cmd.communicate()
+    for entry in out.splitlines():
+        entry = entry.decode()
+        words = entry.strip().split(' ')
+        if words[0] == "ssid":
+            return words[1]
+    return None
+
+def wait_for_kernel_ssid(ifname, ssid, timeout_sec=5):
+    for i in range(timeout_sec * 10):
+        if get_kernel_ssid(ifname) == ssid:
+            return True
+        time.sleep(0.1)
+    return False
+
 @remote_compatible
 def test_ap_config_errors(dev, apdev):
     """Various hostapd configuration errors"""
@@ -215,6 +232,32 @@ def run_ap_config_reload_on_sighup(dev, apdev, params, ht=True):
     if not ht and "dd180050f202" in bss['ie']:
             raise Exception("Unexpected WMM IE after reload")
 
+def test_ap_config_reload_on_sighup_ssid_changes(dev, apdev, params):
+    """hostapd configuration reload modification from file on SIGHUP with bss remove/add"""
+    pidfile = params['prefix'] + ".hostapd.pid"
+    logfile = params['prefix'] + ".hostapd-log"
+    conffile = params['prefix'] + ".hostapd.conf"
+    prg = os.path.join(params['logdir'], 'alt-hostapd/hostapd/hostapd')
+    if not os.path.exists(prg):
+        prg = '../../hostapd/hostapd'
+    write_hostapd_config(conffile, apdev[0]['ifname'], "test")
+    cmd = [prg, '-B', '-dddt', '-P', pidfile, '-f', logfile, conffile]
+    res = subprocess.check_call(cmd)
+    if res != 0:
+        raise Exception("Could not start hostapd: %s" % str(res))
+
+    time.sleep(0.5)
+
+    write_hostapd_config(conffile, apdev[0]['ifname'], "test-a")
+    with open(pidfile, "r") as f:
+        pid = int(f.read())
+
+    assert wait_for_kernel_ssid(apdev[0]['ifname'], "test")
+    os.kill(pid, signal.SIGHUP)
+    assert wait_for_kernel_ssid(apdev[0]['ifname'], "test-a")
+
+    term_hostapd_pid(pid, pidfile)
+
 def test_ap_config_reload_on_sighup_bss_changes(dev, apdev, params):
     """hostapd configuration reload modification from file on SIGHUP with bss remove/add"""
     pidfile = params['prefix'] + ".hostapd.pid"
-- 
2.55.0




More information about the Hostap mailing list