From eb89361bdeede9082887d9ce200343cb9a219621 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 27 Dec 2016 00:56:46 +0200 Subject: [PATCH] tests: hostapd configuration reload Signed-off-by: Jouni Malinen --- tests/hwsim/start.sh | 2 ++ tests/hwsim/test_ap_config.py | 41 +++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/tests/hwsim/start.sh b/tests/hwsim/start.sh index 1d2d50771..6db4a5555 100755 --- a/tests/hwsim/start.sh +++ b/tests/hwsim/start.sh @@ -117,6 +117,8 @@ done sudo $(printf -- "$VALGRIND_WPAS" 5) $WPAS -g /tmp/wpas-wlan5 -G$GROUP \ -ddKt$TRACE -f $LOGDIR/log5 & sudo $VALGRIND_HAPD $HAPD -ddKt$TRACE -g /var/run/hostapd-global -G $GROUP -f $LOGDIR/hostapd & +HPID=$! +echo $HPID > $LOGDIR/hostapd-test.pid if [ -x $HLR_AUC_GW ]; then cp $DIR/auth_serv/hlr_auc_gw.milenage_db $LOGDIR/hlr_auc_gw.milenage_db diff --git a/tests/hwsim/test_ap_config.py b/tests/hwsim/test_ap_config.py index 7fb3bf6db..a4c01d9cd 100644 --- a/tests/hwsim/test_ap_config.py +++ b/tests/hwsim/test_ap_config.py @@ -4,6 +4,10 @@ # This software may be distributed under the terms of the BSD license. # See README for more details. +import os +import signal +import time + from remotehost import remote_compatible import hostapd @@ -78,3 +82,40 @@ def test_ap_config_errors(dev, apdev): if "FAIL" not in hapd.request("ENABLE"): raise Exception("Unexpected ENABLE success (HS 2.0 without WPA2/CCMP)") hostapd.remove_bss(apdev[0]) + +def test_ap_config_reload(dev, apdev, params): + """hostapd configuration reload""" + hapd = hostapd.add_ap(apdev[0], { "ssid": "foo" }) + hapd.set("ssid", "foobar") + with open(os.path.join(params['logdir'], 'hostapd-test.pid'), "r") as f: + pid = int(f.read()) + os.kill(pid, signal.SIGHUP) + time.sleep(0.1) + dev[0].connect("foobar", key_mgmt="NONE", scan_freq="2412") + hapd.set("ssid", "foo") + os.kill(pid, signal.SIGHUP) + dev[0].wait_disconnected() + dev[0].request("DISCONNECT") + +def test_ap_config_reload_file(dev, apdev, params): + """hostapd configuration reload from file""" + hapd = hostapd.add_iface(apdev[0], "bss-1.conf") + hapd.enable() + hapd.set("ssid", "foobar") + with open(os.path.join(params['logdir'], 'hostapd-test.pid'), "r") as f: + pid = int(f.read()) + os.kill(pid, signal.SIGHUP) + time.sleep(0.1) + dev[0].connect("foobar", key_mgmt="NONE", scan_freq="2412") + hapd.set("ssid", "foo") + os.kill(pid, signal.SIGHUP) + dev[0].wait_disconnected() + dev[0].request("DISCONNECT") + +def test_ap_config_reload_before_enable(dev, apdev, params): + """hostapd configuration reload before enable""" + hapd = hostapd.add_iface(apdev[0], "bss-1.conf") + with open(os.path.join(params['logdir'], 'hostapd-test.pid'), "r") as f: + pid = int(f.read()) + os.kill(pid, signal.SIGHUP) + hapd.ping()