tests: Optimize scanning in wpa_supplicant-as-AP test case

Wait for the AP to be ready before initiating the scan to avoid
unnecessary five second extra wait. In addition, disconnect the station
to avoid possibility of starting a new scan at the end of the test case.
These remove unnecessary wait time from the test cases.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Jouni Malinen 2014-03-25 15:08:07 +02:00 committed by Jouni Malinen
parent 4d1e38be9e
commit 9905de3129

View file

@ -10,6 +10,11 @@ logger = logging.getLogger()
import hwsim_utils import hwsim_utils
def wait_ap_ready(dev):
ev = dev.wait_event(["CTRL-EVENT-CONNECTED"])
if ev is None:
raise Exception("AP failed to start")
def test_wpas_ap_open(dev): def test_wpas_ap_open(dev):
"""wpa_supplicant AP mode - open network""" """wpa_supplicant AP mode - open network"""
id = dev[0].add_network() id = dev[0].add_network()
@ -19,6 +24,7 @@ def test_wpas_ap_open(dev):
dev[0].set_network(id, "frequency", "2412") dev[0].set_network(id, "frequency", "2412")
dev[0].set_network(id, "scan_freq", "2412") dev[0].set_network(id, "scan_freq", "2412")
dev[0].select_network(id) dev[0].select_network(id)
wait_ap_ready(dev[0])
dev[1].connect("wpas-ap-open", key_mgmt="NONE", scan_freq="2412") dev[1].connect("wpas-ap-open", key_mgmt="NONE", scan_freq="2412")
dev[2].connect("wpas-ap-open", key_mgmt="NONE", scan_freq="2412") dev[2].connect("wpas-ap-open", key_mgmt="NONE", scan_freq="2412")
@ -61,6 +67,8 @@ def test_wpas_ap_open(dev):
ev = dev[2].wait_event(["CTRL-EVENT-CONNECTED"]) ev = dev[2].wait_event(["CTRL-EVENT-CONNECTED"])
if ev is None: if ev is None:
raise Exception("Reconnection timed out") raise Exception("Reconnection timed out")
dev[1].request("DISCONNECT")
dev[2].request("DISCONNECT")
def test_wpas_ap_wep(dev): def test_wpas_ap_wep(dev):
"""wpa_supplicant AP mode - WEP""" """wpa_supplicant AP mode - WEP"""
@ -72,10 +80,12 @@ def test_wpas_ap_wep(dev):
dev[0].set_network(id, "scan_freq", "2412") dev[0].set_network(id, "scan_freq", "2412")
dev[0].set_network_quoted(id, "wep_key0", "hello") dev[0].set_network_quoted(id, "wep_key0", "hello")
dev[0].select_network(id) dev[0].select_network(id)
wait_ap_ready(dev[0])
dev[1].connect("wpas-ap-wep", key_mgmt="NONE", wep_key0='"hello"', dev[1].connect("wpas-ap-wep", key_mgmt="NONE", wep_key0='"hello"',
scan_freq="2412") scan_freq="2412")
hwsim_utils.test_connectivity(dev[0].ifname, dev[1].ifname) hwsim_utils.test_connectivity(dev[0].ifname, dev[1].ifname)
dev[1].request("DISCONNECT")
def test_wpas_ap_no_ssid(dev): def test_wpas_ap_no_ssid(dev):
"""wpa_supplicant AP mode - invalid network configuration""" """wpa_supplicant AP mode - invalid network configuration"""
@ -97,10 +107,9 @@ def test_wpas_ap_default_frequency(dev):
dev[0].set_network(id, "key_mgmt", "NONE") dev[0].set_network(id, "key_mgmt", "NONE")
dev[0].set_network(id, "scan_freq", "2412") dev[0].set_network(id, "scan_freq", "2412")
dev[0].select_network(id) dev[0].select_network(id)
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"]) wait_ap_ready(dev[0])
if ev is None:
raise Exception("AP failed to start")
dev[1].connect("wpas-ap-open", key_mgmt="NONE", scan_freq="2462") dev[1].connect("wpas-ap-open", key_mgmt="NONE", scan_freq="2462")
dev[1].request("DISCONNECT")
def test_wpas_ap_invalid_frequency(dev): def test_wpas_ap_invalid_frequency(dev):
"""wpa_supplicant AP mode - invalid frequency configuration""" """wpa_supplicant AP mode - invalid frequency configuration"""
@ -124,9 +133,7 @@ def test_wpas_ap_wps(dev):
dev[0].set_network(id, "frequency", "2412") dev[0].set_network(id, "frequency", "2412")
dev[0].set_network(id, "scan_freq", "2412") dev[0].set_network(id, "scan_freq", "2412")
dev[0].select_network(id) dev[0].select_network(id)
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"]) wait_ap_ready(dev[0])
if ev is None:
raise Exception("AP start timeout")
bssid = dev[0].p2p_interface_addr() bssid = dev[0].p2p_interface_addr()
logger.info("Test PBC mode start/stop") logger.info("Test PBC mode start/stop")