]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Add ap_config_reload_on_sighup_config_id
authorRaphaël Mélotte <raphael.melotte@mind.be>
Mon, 1 Aug 2022 11:08:25 +0000 (13:08 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 27 Nov 2022 13:44:58 +0000 (15:44 +0200)
The test checks that when reloading the configuration with SIGHUP,
stations that are connected to BSSes whose config_id did not change are
not disconnected. It also checks that for the BSSes that have a
different config_id and SSID, the new SSID is applied correctly.

Signed-off-by: Raphaël Mélotte <raphael.melotte@mind.be>
tests/hwsim/test_ap_config.py

index a1e068203365988906141b9c991cd5bf4ab5f065..9dd3dceda258200d427488bd7be346480467ea88 100644 (file)
@@ -270,6 +270,43 @@ def test_ap_config_reload_on_sighup_bss_changes(dev, apdev, params):
 
     os.kill(pid, signal.SIGTERM)
 
+def test_ap_config_reload_on_sighup_config_id(dev, apdev, params):
+    """hostapd configuration reload when a config_id is provided"""
+    pidfile = params['prefix'] + ".hostapd.pid"
+    logfile = params['prefix'] + ".hostapd.log"
+    conffile = os.path.abspath(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", bss2=False,
+                         iface_params=["config_id=if1"],
+                         bss_params=[f"bss={apdev[0]['ifname']}_2",
+                                     "ssid=test-2", "config_id=bss2"])
+    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))
+    dev[0].connect("test-2", key_mgmt="NONE", scan_freq="2412")
+
+    write_hostapd_config(conffile, apdev[0]['ifname'], "test-a", bss2=False,
+                         iface_params=["config_id=if1-new"],
+                         bss_params=[f"bss={apdev[0]['ifname']}_2",
+                                     "ssid=test-2", "config_id=bss2"])
+
+    with open(pidfile, "r") as f:
+        pid = int(f.read())
+    os.kill(pid, signal.SIGHUP)
+    ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=1)
+    if ev is not None:
+        raise Exception("Unexpected disconnection when config_id was not changed")
+
+    dev[0].request("REMOVE_NETWORK all")
+    dev[0].wait_disconnected()
+    dev[0].dump_monitor()
+    dev[0].connect("test-a", key_mgmt="NONE", scan_freq="2412")
+
+    os.kill(pid, signal.SIGTERM)
+
 def test_ap_config_reload_before_enable(dev, apdev, params):
     """hostapd configuration reload before enable"""
     hapd = hostapd.add_iface(apdev[0], "bss-1.conf")