tests: Helper function for DISCONNECT + ABORT_SCAN + wait
Use a helper function to perform this common sequence to disconnect and stop any possibly started reconnection attempt. Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
2b4263d06f
commit
e01a492caa
12 changed files with 38 additions and 101 deletions
|
@ -447,9 +447,7 @@ def main():
|
|||
dev[0].connect("country98", key_mgmt="NONE", scan_freq="2412")
|
||||
dev[1].request("DISCONNECT")
|
||||
dev[0].wait_disconnected()
|
||||
dev[0].request("DISCONNECT")
|
||||
dev[0].request("ABORT_SCAN")
|
||||
time.sleep(1)
|
||||
dev[0].disconnect_and_stop_scan()
|
||||
dev[0].reset()
|
||||
dev[1].reset()
|
||||
dev[0].dump_monitor()
|
||||
|
|
|
@ -162,9 +162,7 @@ def test_ap_acs_5ghz(dev, apdev):
|
|||
finally:
|
||||
if hapd:
|
||||
hapd.request("DISABLE")
|
||||
dev[0].request("DISCONNECT")
|
||||
dev[0].request("ABORT_SCAN")
|
||||
dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
|
||||
dev[0].disconnect_and_stop_scan()
|
||||
hostapd.cmd_execute(apdev[0], ['iw', 'reg', 'set', '00'])
|
||||
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
|
||||
dev[0].flush_scan_cache()
|
||||
|
@ -194,9 +192,7 @@ def test_ap_acs_5ghz_40mhz(dev, apdev):
|
|||
finally:
|
||||
if hapd:
|
||||
hapd.request("DISABLE")
|
||||
dev[0].request("DISCONNECT")
|
||||
dev[0].request("ABORT_SCAN")
|
||||
dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
|
||||
dev[0].disconnect_and_stop_scan()
|
||||
hostapd.cmd_execute(apdev[0], ['iw', 'reg', 'set', '00'])
|
||||
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
|
||||
dev[0].flush_scan_cache()
|
||||
|
@ -228,9 +224,7 @@ def test_ap_acs_vht(dev, apdev):
|
|||
finally:
|
||||
if hapd:
|
||||
hapd.request("DISABLE")
|
||||
dev[0].request("DISCONNECT")
|
||||
dev[0].request("ABORT_SCAN")
|
||||
dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
|
||||
dev[0].disconnect_and_stop_scan()
|
||||
hostapd.cmd_execute(apdev[0], ['iw', 'reg', 'set', '00'])
|
||||
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
|
||||
dev[0].flush_scan_cache()
|
||||
|
@ -264,9 +258,7 @@ def test_ap_acs_vht40(dev, apdev):
|
|||
finally:
|
||||
if hapd:
|
||||
hapd.request("DISABLE")
|
||||
dev[0].request("DISCONNECT")
|
||||
dev[0].request("ABORT_SCAN")
|
||||
dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
|
||||
dev[0].disconnect_and_stop_scan()
|
||||
hostapd.cmd_execute(apdev[0], ['iw', 'reg', 'set', '00'])
|
||||
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
|
||||
dev[0].flush_scan_cache()
|
||||
|
@ -302,9 +294,7 @@ def test_ap_acs_vht160(dev, apdev):
|
|||
finally:
|
||||
if hapd:
|
||||
hapd.request("DISABLE")
|
||||
dev[0].request("DISCONNECT")
|
||||
dev[0].request("ABORT_SCAN")
|
||||
dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
|
||||
dev[0].disconnect_and_stop_scan()
|
||||
hostapd.cmd_execute(apdev[0], ['iw', 'reg', 'set', '00'])
|
||||
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
|
||||
dev[0].flush_scan_cache()
|
||||
|
@ -432,9 +422,7 @@ def test_ap_acs_dfs(dev, apdev, params):
|
|||
finally:
|
||||
if hapd:
|
||||
hapd.request("DISABLE")
|
||||
dev[0].request("DISCONNECT")
|
||||
dev[0].request("ABORT_SCAN")
|
||||
dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
|
||||
dev[0].disconnect_and_stop_scan()
|
||||
hostapd.cmd_execute(apdev[0], ['iw', 'reg', 'set', '00'])
|
||||
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
|
||||
dev[0].flush_scan_cache()
|
||||
|
@ -481,9 +469,7 @@ def test_ap_acs_vht160_dfs(dev, apdev, params):
|
|||
finally:
|
||||
if hapd:
|
||||
hapd.request("DISABLE")
|
||||
dev[0].request("DISCONNECT")
|
||||
dev[0].request("ABORT_SCAN")
|
||||
dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
|
||||
dev[0].disconnect_and_stop_scan()
|
||||
hostapd.cmd_execute(apdev[0], ['iw', 'reg', 'set', '00'])
|
||||
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
|
||||
dev[0].flush_scan_cache()
|
||||
|
|
|
@ -2034,7 +2034,7 @@ def test_ap_wpa2_eap_peap_params(dev, apdev):
|
|||
if ev and "CTRL-EVENT-CONNECTED" in ev:
|
||||
raise Exception("Unexpected connection")
|
||||
dev[0].request("REMOVE_NETWORK all")
|
||||
dev[0].request("ABORT_SCAN")
|
||||
dev[0].disconnect_and_stop_scan()
|
||||
|
||||
tests = [("peap-ver0", ""),
|
||||
("peap-ver1", ""),
|
||||
|
|
|
@ -131,12 +131,7 @@ def test_ap_country(dev, apdev):
|
|||
finally:
|
||||
if hapd:
|
||||
hapd.request("DISABLE")
|
||||
dev[0].request("DISCONNECT")
|
||||
res = dev[0].request("ABORT_SCAN")
|
||||
for i in range(2 if "OK" in res else 1):
|
||||
dev[0].wait_event(["CTRL-EVENT-DISCONNECTED",
|
||||
"CTRL-EVENT-SCAN-RESULTS"], timeout=0.5)
|
||||
dev[0].dump_monitor()
|
||||
dev[0].disconnect_and_stop_scan()
|
||||
hostapd.cmd_execute(apdev[0], ['iw', 'reg', 'set', '00'])
|
||||
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
|
||||
dev[0].flush_scan_cache()
|
||||
|
@ -438,9 +433,7 @@ def test_ap_spectrum_management_required(dev, apdev):
|
|||
finally:
|
||||
if hapd:
|
||||
hapd.request("DISABLE")
|
||||
dev[0].request("DISCONNECT")
|
||||
dev[0].request("ABORT_SCAN")
|
||||
dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
|
||||
dev[0].disconnect_and_stop_scan()
|
||||
hostapd.cmd_execute(apdev[0], ['iw', 'reg', 'set', '00'])
|
||||
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
|
||||
dev[0].flush_scan_cache()
|
||||
|
|
|
@ -362,18 +362,9 @@ def test_ap_wpa2_tdls_responder_teardown(dev, apdev):
|
|||
def tdls_clear_reg(hapd, dev):
|
||||
if hapd:
|
||||
hapd.request("DISABLE")
|
||||
dev[0].request("DISCONNECT")
|
||||
res0 = dev[0].request("ABORT_SCAN")
|
||||
dev[1].request("DISCONNECT")
|
||||
res1 = dev[1].request("ABORT_SCAN")
|
||||
for i in range(2 if "OK" in res0 else 1):
|
||||
dev[0].wait_event(["CTRL-EVENT-DISCONNECTED",
|
||||
"CTRL-EVENT-SCAN-RESULTS"], timeout=0.5)
|
||||
dev[0].dump_monitor()
|
||||
for i in range(2 if "OK" in res1 else 1):
|
||||
dev[1].wait_event(["CTRL-EVENT-DISCONNECTED",
|
||||
"CTRL-EVENT-SCAN-RESULTS"], timeout=0.5)
|
||||
dev[1].dump_monitor()
|
||||
dev[0].disconnect_and_stop_scan()
|
||||
dev[1].disconnect_and_stop_scan()
|
||||
subprocess.call(['iw', 'reg', 'set', '00'])
|
||||
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
|
||||
dev[0].flush_scan_cache()
|
||||
|
|
|
@ -425,9 +425,7 @@ def test_ap_vht160(dev, apdev):
|
|||
finally:
|
||||
if hapd:
|
||||
hapd.request("DISABLE")
|
||||
dev[0].request("DISCONNECT")
|
||||
dev[0].request("ABORT_SCAN")
|
||||
dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
|
||||
dev[0].disconnect_and_stop_scan()
|
||||
subprocess.call(['iw', 'reg', 'set', '00'])
|
||||
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
|
||||
dev[0].flush_scan_cache()
|
||||
|
@ -499,9 +497,7 @@ def test_ap_vht160b(dev, apdev):
|
|||
finally:
|
||||
if hapd:
|
||||
hapd.request("DISABLE")
|
||||
dev[0].request("DISCONNECT")
|
||||
dev[0].request("ABORT_SCAN")
|
||||
dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
|
||||
dev[0].disconnect_and_stop_scan()
|
||||
subprocess.call(['iw', 'reg', 'set', '00'])
|
||||
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
|
||||
dev[0].flush_scan_cache()
|
||||
|
@ -579,9 +575,7 @@ def run_ap_vht160_no_dfs(dev, apdev, channel, ht_capab):
|
|||
finally:
|
||||
if hapd:
|
||||
hapd.request("DISABLE")
|
||||
dev[0].request("DISCONNECT")
|
||||
dev[0].request("ABORT_SCAN")
|
||||
dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
|
||||
dev[0].disconnect_and_stop_scan()
|
||||
subprocess.call(['iw', 'reg', 'set', '00'])
|
||||
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
|
||||
dev[0].flush_scan_cache()
|
||||
|
@ -1021,9 +1015,7 @@ def test_ap_vht80_pwr_constraint(dev, apdev):
|
|||
finally:
|
||||
if hapd:
|
||||
hapd.request("DISABLE")
|
||||
dev[0].request("DISCONNECT")
|
||||
dev[0].request("ABORT_SCAN")
|
||||
dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
|
||||
dev[0].disconnect_and_stop_scan()
|
||||
subprocess.call(['iw', 'reg', 'set', '00'])
|
||||
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
|
||||
dev[0].flush_scan_cache()
|
||||
|
@ -1132,9 +1124,7 @@ def test_ap_vht_40_fallback_to_20(devs, apdevs):
|
|||
finally:
|
||||
if hapd:
|
||||
hapd.request("DISABLE")
|
||||
dev.request("DISCONNECT")
|
||||
dev.request("ABORT_SCAN")
|
||||
dev.wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
|
||||
dev.disconnect_and_stop_scan()
|
||||
subprocess.call(['iw', 'reg', 'set', '00'])
|
||||
dev.wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
|
||||
dev.flush_scan_cache()
|
||||
|
|
|
@ -334,9 +334,8 @@ def run_wpa2_ocv_vht80plus80(dev, apdev):
|
|||
hapd.disable()
|
||||
for i in range(3):
|
||||
dev[i].request("DISCONNECT")
|
||||
dev[i].request("ABORT_SCAN")
|
||||
for i in range(3):
|
||||
dev[i].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
|
||||
dev[i].disconnect_and_stop_scan()
|
||||
|
||||
class APConnection:
|
||||
def init_params(self):
|
||||
|
@ -520,9 +519,7 @@ def run_wpa2_ocv_ap_vht160_mismatch(dev, apdev):
|
|||
dev[0].dump_monitor()
|
||||
if conn.hapd:
|
||||
conn.hapd.request("DISABLE")
|
||||
dev[0].request("DISCONNECT")
|
||||
dev[0].request("ABORT_SCAN")
|
||||
dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
|
||||
dev[0].disconnect_and_stop_scan()
|
||||
|
||||
@remote_compatible
|
||||
def test_wpa2_ocv_ap_vht80plus80_mismatch(dev, apdev):
|
||||
|
@ -556,9 +553,7 @@ def run_wpa2_ocv_ap_vht80plus80_mismatch(dev, apdev):
|
|||
dev[0].dump_monitor()
|
||||
if conn.hapd:
|
||||
conn.hapd.request("DISABLE")
|
||||
dev[0].request("DISCONNECT")
|
||||
dev[0].request("ABORT_SCAN")
|
||||
dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
|
||||
dev[0].disconnect_and_stop_scan()
|
||||
|
||||
@remote_compatible
|
||||
def test_wpa2_ocv_ap_unexpected1(dev, apdev):
|
||||
|
@ -857,9 +852,7 @@ def run_wpa2_ocv_vht160_mismatch_client(dev, apdev):
|
|||
dev[0].dump_monitor()
|
||||
if conn.hapd:
|
||||
conn.hapd.request("DISABLE")
|
||||
dev[0].request("DISCONNECT")
|
||||
dev[0].request("ABORT_SCAN")
|
||||
dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
|
||||
dev[0].disconnect_and_stop_scan()
|
||||
|
||||
def test_wpa2_ocv_sta_group_hs(dev, apdev):
|
||||
"""OCV group handshake (STA)"""
|
||||
|
|
|
@ -1670,9 +1670,7 @@ def test_rrm_beacon_req_passive_scan_vht(dev, apdev):
|
|||
finally:
|
||||
if hapd:
|
||||
hapd.request("DISABLE")
|
||||
dev[0].request("DISCONNECT")
|
||||
dev[0].request("ABORT_SCAN")
|
||||
dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
|
||||
dev[0].disconnect_and_stop_scan()
|
||||
subprocess.call(['iw', 'reg', 'set', '00'])
|
||||
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
|
||||
dev[0].flush_scan_cache()
|
||||
|
@ -1719,9 +1717,7 @@ def test_rrm_beacon_req_passive_scan_vht160(dev, apdev):
|
|||
finally:
|
||||
if hapd:
|
||||
hapd.request("DISABLE")
|
||||
dev[0].request("DISCONNECT")
|
||||
dev[0].request("ABORT_SCAN")
|
||||
dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
|
||||
dev[0].disconnect_and_stop_scan()
|
||||
subprocess.call(['iw', 'reg', 'set', '00'])
|
||||
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
|
||||
dev[0].flush_scan_cache()
|
||||
|
|
|
@ -27,12 +27,7 @@ def clear_regdom_state(dev, hapd, hapd2):
|
|||
hapd.request("DISABLE")
|
||||
if hapd2:
|
||||
hapd2.request("DISABLE")
|
||||
dev[0].request("DISCONNECT")
|
||||
res = dev[0].request("ABORT_SCAN")
|
||||
for i in range(2 if "OK" in res else 1):
|
||||
dev[0].wait_event(["CTRL-EVENT-DISCONNECTED",
|
||||
"CTRL-EVENT-SCAN-RESULTS"], timeout=0.5)
|
||||
dev[0].dump_monitor()
|
||||
dev[0].disconnect_and_stop_scan()
|
||||
subprocess.call(['iw', 'reg', 'set', '00'])
|
||||
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
|
||||
dev[0].flush_scan_cache()
|
||||
|
@ -1137,14 +1132,7 @@ def stop_wnm_tm(hapd, dev):
|
|||
if hapd:
|
||||
hapd.request("DISABLE")
|
||||
time.sleep(0.1)
|
||||
dev[0].request("DISCONNECT")
|
||||
res = dev[0].request("ABORT_SCAN")
|
||||
try:
|
||||
dev[0].wait_disconnected()
|
||||
except:
|
||||
pass
|
||||
if "OK" in res:
|
||||
dev[0].wait_event(["CTRL-EVENT-SCAN-RESULTS"], timeout=0.5)
|
||||
dev[0].disconnect_and_stop_scan()
|
||||
subprocess.call(['iw', 'reg', 'set', '00'])
|
||||
wait_regdom_changes(dev[0])
|
||||
country = dev[0].get_driver_status_field("country")
|
||||
|
@ -1884,11 +1872,7 @@ def test_wnm_bss_tm_reject(dev, apdev):
|
|||
finally:
|
||||
if hapd:
|
||||
hapd.request("DISABLE")
|
||||
dev[0].request("DISCONNECT")
|
||||
res = dev[0].request("ABORT_SCAN")
|
||||
for i in range(2 if "OK" in res else 1):
|
||||
dev[0].wait_event(["CTRL-EVENT-DISCONNECTED",
|
||||
"CTRL-EVENT-SCAN-RESULTS"], timeout=0.5)
|
||||
dev[0].disconnect_and_stop_scan()
|
||||
subprocess.call(['iw', 'reg', 'set', '00'])
|
||||
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
|
||||
dev[0].flush_scan_cache()
|
||||
|
|
|
@ -384,9 +384,7 @@ def _test_wpas_ap_dfs(dev):
|
|||
dev[1].connect("wpas-ap-dfs", key_mgmt="NONE")
|
||||
dev[1].wait_regdom(country_ie=True)
|
||||
dev[0].request("DISCONNECT")
|
||||
dev[1].request("DISCONNECT")
|
||||
dev[1].request("ABORT_SCAN")
|
||||
dev[1].wait_disconnected()
|
||||
dev[1].disconnect_and_stop_scan()
|
||||
|
||||
@remote_compatible
|
||||
def test_wpas_ap_disable(dev):
|
||||
|
|
|
@ -152,8 +152,8 @@ def clear_regdom(hapd, dev, count=1):
|
|||
time.sleep(0.1)
|
||||
for i in range(count):
|
||||
dev[i].request("DISCONNECT")
|
||||
dev[i].request("ABORT_SCAN")
|
||||
dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
|
||||
for i in range(count):
|
||||
dev[i].disconnect_and_stop_scan()
|
||||
subprocess.call(['iw', 'reg', 'set', '00'])
|
||||
wait_regdom_changes(dev[0])
|
||||
country = dev[0].get_driver_status_field("country")
|
||||
|
|
|
@ -1152,6 +1152,14 @@ class WpaSupplicant:
|
|||
if len(res.splitlines()) > 1:
|
||||
logger.info("flush_scan_cache: Could not clear all BSS entries. These remain:\n" + res)
|
||||
|
||||
def disconnect_and_stop_scan(self):
|
||||
self.request("DISCONNECT")
|
||||
res = self.request("ABORT_SCAN")
|
||||
for i in range(2 if "OK" in res else 1):
|
||||
self.wait_event(["CTRL-EVENT-DISCONNECTED",
|
||||
"CTRL-EVENT-SCAN-RESULTS"], timeout=0.5)
|
||||
self.dump_monitor()
|
||||
|
||||
def roam(self, bssid, fail_test=False, assoc_reject_ok=False):
|
||||
self.dump_monitor()
|
||||
if "OK" not in self.request("ROAM " + bssid):
|
||||
|
|
Loading…
Reference in a new issue