From eb88a5ba74b01a2a6460481f021a30d5b03c6f65 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 10 Feb 2015 18:20:54 +0200 Subject: [PATCH] tests: hostapd and external ifconfig down + up Signed-off-by: Jouni Malinen --- tests/hwsim/test_ap_open.py | 31 +++++++++++++++++++++++++++++++ tests/hwsim/test_ap_psk.py | 22 ++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/tests/hwsim/test_ap_open.py b/tests/hwsim/test_ap_open.py index 0807d7b3e..ae400577a 100644 --- a/tests/hwsim/test_ap_open.py +++ b/tests/hwsim/test_ap_open.py @@ -315,3 +315,34 @@ def test_ap_open_start_disabled2(dev, apdev): dev[0].wait_disconnected() dev[0].request("RECONNECT") dev[0].wait_connected() + +def test_ap_open_ifdown(dev, apdev): + """AP with open mode and external ifconfig down""" + params = { "ssid": "open", + "ap_max_inactivity": "1" } + hapd = hostapd.add_ap(apdev[0]['ifname'], params) + bssid = apdev[0]['bssid'] + + dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") + dev[1].connect("open", key_mgmt="NONE", scan_freq="2412") + subprocess.call(['ip', 'link', 'set', 'dev', apdev[0]['ifname'], 'down']) + ev = hapd.wait_event(["AP-STA-DISCONNECTED"], timeout=10) + if ev is None: + raise Exception("Timeout on AP-STA-DISCONNECTED (1)") + ev = hapd.wait_event(["AP-STA-DISCONNECTED"], timeout=5) + if ev is None: + raise Exception("Timeout on AP-STA-DISCONNECTED (2)") + ev = hapd.wait_event(["INTERFACE-DISABLED"], timeout=5) + if ev is None: + raise Exception("No INTERFACE-DISABLED event") + # The following wait tests beacon loss detection in mac80211 on dev0. + # dev1 is used to test stopping of AP side functionality on client polling. + dev[1].request("REMOVE_NETWORK all") + subprocess.call(['ip', 'link', 'set', 'dev', apdev[0]['ifname'], 'up']) + dev[0].wait_disconnected() + dev[1].wait_disconnected() + ev = hapd.wait_event(["INTERFACE-ENABLED"], timeout=10) + if ev is None: + raise Exception("No INTERFACE-ENABLED event") + dev[0].wait_connected() + hwsim_utils.test_connectivity(dev[0], hapd) diff --git a/tests/hwsim/test_ap_psk.py b/tests/hwsim/test_ap_psk.py index df0d7b272..19aa42703 100644 --- a/tests/hwsim/test_ap_psk.py +++ b/tests/hwsim/test_ap_psk.py @@ -1018,3 +1018,25 @@ def _test_ap_wpa2_psk_wpas_in_bridge(dev, apdev): wpas.interface_add(ifname, br_ifname=br_ifname) wpas.connect(ssid, psk=passphrase, scan_freq="2412") + +def test_ap_wpa2_psk_ifdown(dev, apdev): + """AP with open mode and external ifconfig down""" + ssid = "test-wpa2-psk" + passphrase = 'qwertyuiop' + params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) + hapd = hostapd.add_ap(apdev[0]['ifname'], params) + bssid = apdev[0]['bssid'] + + dev[0].connect(ssid, psk=passphrase, scan_freq="2412") + subprocess.call(['ip', 'link', 'set', 'dev', apdev[0]['ifname'], 'down']) + ev = hapd.wait_event(["INTERFACE-DISABLED"], timeout=10) + if ev is None: + raise Exception("No INTERFACE-DISABLED event") + # this wait tests beacon loss detection in mac80211 + dev[0].wait_disconnected() + subprocess.call(['ip', 'link', 'set', 'dev', apdev[0]['ifname'], 'up']) + ev = hapd.wait_event(["INTERFACE-ENABLED"], timeout=10) + if ev is None: + raise Exception("No INTERFACE-ENABLED event") + dev[0].wait_connected() + hwsim_utils.test_connectivity(dev[0], hapd)