tests: Clean up and optimize gas_concurrent_scan and _connect
No need to run a full scan as the first step since it only needs to find the AP from a known channel for the GAS operation. Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
ad36d27d6a
commit
d7a99700de
2 changed files with 13 additions and 7 deletions
|
@ -2,6 +2,7 @@
|
||||||
#
|
#
|
||||||
# GAS tests
|
# GAS tests
|
||||||
# Copyright (c) 2013, Qualcomm Atheros, Inc.
|
# Copyright (c) 2013, Qualcomm Atheros, Inc.
|
||||||
|
# Copyright (c) 2013-2014, Jouni Malinen <j@w1.fi>
|
||||||
#
|
#
|
||||||
# This software may be distributed under the terms of the BSD license.
|
# This software may be distributed under the terms of the BSD license.
|
||||||
# See README for more details.
|
# See README for more details.
|
||||||
|
@ -103,7 +104,8 @@ def test_gas_concurrent_scan(dev, apdev):
|
||||||
params['hessid'] = bssid
|
params['hessid'] = bssid
|
||||||
hostapd.add_ap(apdev[0]['ifname'], params)
|
hostapd.add_ap(apdev[0]['ifname'], params)
|
||||||
|
|
||||||
dev[0].scan()
|
# get BSS entry available to allow GAS query
|
||||||
|
dev[0].scan(freq="2412")
|
||||||
|
|
||||||
logger.info("Request concurrent operations")
|
logger.info("Request concurrent operations")
|
||||||
req = dev[0].request("GAS_REQUEST " + bssid + " 00 000102000101")
|
req = dev[0].request("GAS_REQUEST " + bssid + " 00 000102000101")
|
||||||
|
@ -112,7 +114,7 @@ def test_gas_concurrent_scan(dev, apdev):
|
||||||
req = dev[0].request("GAS_REQUEST " + bssid + " 00 000102000801")
|
req = dev[0].request("GAS_REQUEST " + bssid + " 00 000102000801")
|
||||||
if "FAIL" in req:
|
if "FAIL" in req:
|
||||||
raise Exception("GAS query request rejected")
|
raise Exception("GAS query request rejected")
|
||||||
dev[0].request("SCAN")
|
dev[0].scan(no_wait=True)
|
||||||
req = dev[0].request("GAS_REQUEST " + bssid + " 00 000102000201")
|
req = dev[0].request("GAS_REQUEST " + bssid + " 00 000102000201")
|
||||||
if "FAIL" in req:
|
if "FAIL" in req:
|
||||||
raise Exception("GAS query request rejected")
|
raise Exception("GAS query request rejected")
|
||||||
|
@ -140,13 +142,14 @@ def test_gas_concurrent_connect(dev, apdev):
|
||||||
params['hessid'] = bssid
|
params['hessid'] = bssid
|
||||||
hostapd.add_ap(apdev[0]['ifname'], params)
|
hostapd.add_ap(apdev[0]['ifname'], params)
|
||||||
|
|
||||||
dev[0].scan()
|
dev[0].scan(freq="2412")
|
||||||
|
|
||||||
logger.debug("Start concurrent connect and GAS request")
|
logger.debug("Start concurrent connect and GAS request")
|
||||||
dev[0].connect("test-gas", key_mgmt="WPA-EAP", eap="TTLS",
|
dev[0].connect("test-gas", key_mgmt="WPA-EAP", eap="TTLS",
|
||||||
identity="DOMAIN\mschapv2 user", anonymous_identity="ttls",
|
identity="DOMAIN\mschapv2 user", anonymous_identity="ttls",
|
||||||
password="password", phase2="auth=MSCHAPV2",
|
password="password", phase2="auth=MSCHAPV2",
|
||||||
ca_cert="auth_serv/ca.pem", wait_connect=False)
|
ca_cert="auth_serv/ca.pem", wait_connect=False,
|
||||||
|
scan_freq="2412")
|
||||||
req = dev[0].request("GAS_REQUEST " + bssid + " 00 000102000101")
|
req = dev[0].request("GAS_REQUEST " + bssid + " 00 000102000101")
|
||||||
if "FAIL" in req:
|
if "FAIL" in req:
|
||||||
raise Exception("GAS query request rejected")
|
raise Exception("GAS query request rejected")
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
#
|
#
|
||||||
# Python class for controlling wpa_supplicant
|
# Python class for controlling wpa_supplicant
|
||||||
# Copyright (c) 2013, Jouni Malinen <j@w1.fi>
|
# Copyright (c) 2013-2014, Jouni Malinen <j@w1.fi>
|
||||||
#
|
#
|
||||||
# This software may be distributed under the terms of the BSD license.
|
# This software may be distributed under the terms of the BSD license.
|
||||||
# See README for more details.
|
# See README for more details.
|
||||||
|
@ -627,16 +627,19 @@ class WpaSupplicant:
|
||||||
self.select_network(id)
|
self.select_network(id)
|
||||||
return id
|
return id
|
||||||
|
|
||||||
def scan(self, type=None, freq=None):
|
def scan(self, type=None, freq=None, no_wait=False):
|
||||||
if type:
|
if type:
|
||||||
cmd = "SCAN TYPE=" + type
|
cmd = "SCAN TYPE=" + type
|
||||||
else:
|
else:
|
||||||
cmd = "SCAN"
|
cmd = "SCAN"
|
||||||
if freq:
|
if freq:
|
||||||
cmd = cmd + " freq=" + freq
|
cmd = cmd + " freq=" + freq
|
||||||
|
if not no_wait:
|
||||||
self.dump_monitor()
|
self.dump_monitor()
|
||||||
if not "OK" in self.request(cmd):
|
if not "OK" in self.request(cmd):
|
||||||
raise Exception("Failed to trigger scan")
|
raise Exception("Failed to trigger scan")
|
||||||
|
if no_wait:
|
||||||
|
return
|
||||||
ev = self.wait_event(["CTRL-EVENT-SCAN-RESULTS"], 15)
|
ev = self.wait_event(["CTRL-EVENT-SCAN-RESULTS"], 15)
|
||||||
if ev is None:
|
if ev is None:
|
||||||
raise Exception("Scan timed out")
|
raise Exception("Scan timed out")
|
||||||
|
|
Loading…
Reference in a new issue