tests: ap_scan=2 AP mode operation and scan failure

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2015-08-11 21:48:55 +03:00
parent 0a34b62be9
commit 708ec753bc
3 changed files with 103 additions and 2 deletions

View file

@ -221,6 +221,9 @@ int wpa_driver_nl80211_scan(struct i802_bss *bss,
wpa_dbg(drv->ctx, MSG_DEBUG, "nl80211: scan request"); wpa_dbg(drv->ctx, MSG_DEBUG, "nl80211: scan request");
drv->scan_for_auth = 0; drv->scan_for_auth = 0;
if (TEST_FAIL())
return -1;
msg = nl80211_scan_common(bss, NL80211_CMD_TRIGGER_SCAN, params); msg = nl80211_scan_common(bss, NL80211_CMD_TRIGGER_SCAN, params);
if (!msg) if (!msg)
return -1; return -1;

View file

@ -19,7 +19,7 @@ except ImportError:
import hostapd import hostapd
from wpasupplicant import WpaSupplicant from wpasupplicant import WpaSupplicant
from utils import HwsimSkip, alloc_fail from utils import HwsimSkip, alloc_fail, fail_test
from test_ap_tdls import connect_2sta_open from test_ap_tdls import connect_2sta_open
WPAS_DBUS_SERVICE = "fi.w1.wpa_supplicant1" WPAS_DBUS_SERVICE = "fi.w1.wpa_supplicant1"
@ -4813,3 +4813,54 @@ def test_dbus_connect_wpa_eap(dev, apdev):
with TestDbusConnect(bus) as t: with TestDbusConnect(bus) as t:
if not t.success(): if not t.success():
raise Exception("Expected signals not seen") raise Exception("Expected signals not seen")
def test_dbus_ap_scan_2_ap_mode_scan(dev, apdev):
"""AP_SCAN 2 AP mode and D-Bus Scan()"""
try:
_test_dbus_ap_scan_2_ap_mode_scan(dev, apdev)
finally:
dev[0].request("AP_SCAN 1")
def _test_dbus_ap_scan_2_ap_mode_scan(dev, apdev):
(bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0])
iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE)
if "OK" not in dev[0].request("AP_SCAN 2"):
raise Exception("Failed to set AP_SCAN 2")
id = dev[0].add_network()
dev[0].set_network(id, "mode", "2")
dev[0].set_network_quoted(id, "ssid", "wpas-ap-open")
dev[0].set_network(id, "key_mgmt", "NONE")
dev[0].set_network(id, "frequency", "2412")
dev[0].set_network(id, "scan_freq", "2412")
dev[0].set_network(id, "disabled", "0")
dev[0].select_network(id)
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=5)
if ev is None:
raise Exception("AP failed to start")
with fail_test(dev[0], 1, "wpa_driver_nl80211_scan"):
iface.Scan({'Type': 'active',
'AllowRoam': True,
'Channels': [(dbus.UInt32(2412), dbus.UInt32(20))]})
ev = dev[0].wait_event(["CTRL-EVENT-SCAN-FAILED",
"AP-DISABLED"], timeout=5)
if ev is None:
raise Exception("CTRL-EVENT-SCAN-FAILED not seen")
if "AP-DISABLED" in ev:
raise Exception("Unexpected AP-DISABLED event")
if "retry=1" in ev:
# Wait for the retry to scan happen
ev = dev[0].wait_event(["CTRL-EVENT-SCAN-FAILED",
"AP-DISABLED"], timeout=5)
if ev is None:
raise Exception("CTRL-EVENT-SCAN-FAILED not seen - retry")
if "AP-DISABLED" in ev:
raise Exception("Unexpected AP-DISABLED event - retry")
dev[1].connect("wpas-ap-open", key_mgmt="NONE", scan_freq="2412")
dev[1].request("DISCONNECT")
dev[1].wait_disconnected()
dev[0].request("DISCONNECT")
dev[0].wait_disconnected()

View file

@ -12,7 +12,7 @@ import subprocess
import hostapd import hostapd
from wpasupplicant import WpaSupplicant from wpasupplicant import WpaSupplicant
from utils import HwsimSkip from utils import HwsimSkip, fail_test
from tshark import run_tshark from tshark import run_tshark
def check_scan(dev, params, other_started=False, test_busy=False): def check_scan(dev, params, other_started=False, test_busy=False):
@ -805,3 +805,50 @@ def test_scan_specify_ssid(dev, apdev):
if "FAIL" not in dev[0].request("SCAN ssid foo"): if "FAIL" not in dev[0].request("SCAN ssid foo"):
raise Exception("Invalid SCAN command accepted") raise Exception("Invalid SCAN command accepted")
def test_scan_ap_scan_2_ap_mode(dev, apdev):
"""AP_SCAN 2 AP mode and scan()"""
try:
_test_scan_ap_scan_2_ap_mode(dev, apdev)
finally:
dev[0].request("AP_SCAN 1")
def _test_scan_ap_scan_2_ap_mode(dev, apdev):
if "OK" not in dev[0].request("AP_SCAN 2"):
raise Exception("Failed to set AP_SCAN 2")
id = dev[0].add_network()
dev[0].set_network(id, "mode", "2")
dev[0].set_network_quoted(id, "ssid", "wpas-ap-open")
dev[0].set_network(id, "key_mgmt", "NONE")
dev[0].set_network(id, "frequency", "2412")
dev[0].set_network(id, "scan_freq", "2412")
dev[0].set_network(id, "disabled", "0")
dev[0].select_network(id)
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=5)
if ev is None:
raise Exception("AP failed to start")
with fail_test(dev[0], 1, "wpa_driver_nl80211_scan"):
if "OK" not in dev[0].request("SCAN freq=2412"):
raise Exception("SCAN command failed unexpectedly")
ev = dev[0].wait_event(["CTRL-EVENT-SCAN-FAILED",
"AP-DISABLED"], timeout=5)
if ev is None:
raise Exception("CTRL-EVENT-SCAN-FAILED not seen")
if "AP-DISABLED" in ev:
raise Exception("Unexpected AP-DISABLED event")
if "retry=1" in ev:
# Wait for the retry to scan happen
ev = dev[0].wait_event(["CTRL-EVENT-SCAN-FAILED",
"AP-DISABLED"], timeout=5)
if ev is None:
raise Exception("CTRL-EVENT-SCAN-FAILED not seen - retry")
if "AP-DISABLED" in ev:
raise Exception("Unexpected AP-DISABLED event - retry")
dev[1].connect("wpas-ap-open", key_mgmt="NONE", scan_freq="2412")
dev[1].request("DISCONNECT")
dev[1].wait_disconnected()
dev[0].request("DISCONNECT")
dev[0].wait_disconnected()