From e4ac747c5f5b4bb01c86c0a5c17bf73d57818464 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 12 Apr 2014 16:51:15 +0300 Subject: [PATCH] tests: ENABLE/DISABLE_NETWORK Signed-off-by: Jouni Malinen --- tests/hwsim/test_wpas_ctrl.py | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/hwsim/test_wpas_ctrl.py b/tests/hwsim/test_wpas_ctrl.py index 0b1156bb4..ebd370254 100644 --- a/tests/hwsim/test_wpas_ctrl.py +++ b/tests/hwsim/test_wpas_ctrl.py @@ -4,6 +4,8 @@ # This software may be distributed under the terms of the BSD license. # See README for more details. +import time + import hostapd def test_wpas_ctrl_network(dev): @@ -699,3 +701,39 @@ def test_wpas_ctrl_log_level(dev): raise Exception("Unexpected debug level(3): " + level) if "Timestamp: 1" not in level: raise Exception("Unexpected timestamp(3): " + level) + +def test_wpas_ctrl_enable_disable_network(dev, apdev): + """wpa_supplicant ctrl_iface ENABLE/DISABLE_NETWORK""" + params = { "ssid": "test" } + hostapd.add_ap(apdev[0]['ifname'], params) + + id = dev[0].connect("test", key_mgmt="NONE", scan_freq="2412", + only_add_network=True) + if "OK" not in dev[0].request("DISABLE_NETWORK " + str(id)): + raise Exception("Failed to disable network") + if "OK" not in dev[0].request("ENABLE_NETWORK " + str(id) + " no-connect"): + raise Exception("Failed to enable network") + if "OK" not in dev[0].request("DISABLE_NETWORK all"): + raise Exception("Failed to disable networks") + if "OK" not in dev[0].request("ENABLE_NETWORK " + str(id)): + raise Exception("Failed to enable network") + ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10) + if ev is None: + raise Exception("Association with the AP timed out") + if "OK" not in dev[0].request("DISABLE_NETWORK " + str(id)): + raise Exception("Failed to disable network") + ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=10) + if ev is None: + raise Exception("Disconnection with the AP timed out") + time.sleep(0.1) + + if "OK" not in dev[0].request("ENABLE_NETWORK all"): + raise Exception("Failed to enable network") + ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10) + if ev is None: + raise Exception("Association with the AP timed out") + if "OK" not in dev[0].request("DISABLE_NETWORK all"): + raise Exception("Failed to disable network") + ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=10) + if ev is None: + raise Exception("Disconnection with the AP timed out")