tests: Unify ignore_old_scan_res resetting
Add a decorator that clears ignore_old_scan_res parameter value instead of doing this with try/finally in large number of test cases. Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
570ae3ef54
commit
49d1f9c98e
3 changed files with 49 additions and 84 deletions
|
@ -1273,13 +1273,9 @@ def test_scan_chan_switch(dev, apdev):
|
||||||
run_scan(dev[0], bssid, 2412)
|
run_scan(dev[0], bssid, 2412)
|
||||||
dev[0].dump_monitor()
|
dev[0].dump_monitor()
|
||||||
|
|
||||||
|
@reset_ignore_old_scan_res
|
||||||
def test_scan_new_only(dev, apdev):
|
def test_scan_new_only(dev, apdev):
|
||||||
"""Scan and only_new=1 multiple times"""
|
"""Scan and only_new=1 multiple times"""
|
||||||
try:
|
|
||||||
_test_scan_new_only(dev, apdev)
|
|
||||||
finally:
|
|
||||||
dev[0].set("ignore_old_scan_res", "0")
|
|
||||||
def _test_scan_new_only(dev, apdev):
|
|
||||||
dev[0].flush_scan_cache()
|
dev[0].flush_scan_cache()
|
||||||
hapd = hostapd.add_ap(apdev[0], {"ssid": "test-scan"})
|
hapd = hostapd.add_ap(apdev[0], {"ssid": "test-scan"})
|
||||||
dev[0].set("ignore_old_scan_res", "1")
|
dev[0].set("ignore_old_scan_res", "1")
|
||||||
|
|
|
@ -183,14 +183,9 @@ def test_sigma_dut_basic(dev, apdev):
|
||||||
finally:
|
finally:
|
||||||
stop_sigma_dut(sigma)
|
stop_sigma_dut(sigma)
|
||||||
|
|
||||||
|
@reset_ignore_old_scan_res
|
||||||
def test_sigma_dut_open(dev, apdev):
|
def test_sigma_dut_open(dev, apdev):
|
||||||
"""sigma_dut controlled open network association"""
|
"""sigma_dut controlled open network association"""
|
||||||
try:
|
|
||||||
run_sigma_dut_open(dev, apdev)
|
|
||||||
finally:
|
|
||||||
dev[0].set("ignore_old_scan_res", "0")
|
|
||||||
|
|
||||||
def run_sigma_dut_open(dev, apdev):
|
|
||||||
ifname = dev[0].ifname
|
ifname = dev[0].ifname
|
||||||
sigma = start_sigma_dut(ifname)
|
sigma = start_sigma_dut(ifname)
|
||||||
|
|
||||||
|
@ -208,14 +203,9 @@ def run_sigma_dut_open(dev, apdev):
|
||||||
finally:
|
finally:
|
||||||
stop_sigma_dut(sigma)
|
stop_sigma_dut(sigma)
|
||||||
|
|
||||||
|
@reset_ignore_old_scan_res
|
||||||
def test_sigma_dut_psk_pmf(dev, apdev):
|
def test_sigma_dut_psk_pmf(dev, apdev):
|
||||||
"""sigma_dut controlled PSK+PMF association"""
|
"""sigma_dut controlled PSK+PMF association"""
|
||||||
try:
|
|
||||||
run_sigma_dut_psk_pmf(dev, apdev)
|
|
||||||
finally:
|
|
||||||
dev[0].set("ignore_old_scan_res", "0")
|
|
||||||
|
|
||||||
def run_sigma_dut_psk_pmf(dev, apdev):
|
|
||||||
ifname = dev[0].ifname
|
ifname = dev[0].ifname
|
||||||
sigma = start_sigma_dut(ifname)
|
sigma = start_sigma_dut(ifname)
|
||||||
|
|
||||||
|
@ -238,41 +228,31 @@ def run_sigma_dut_psk_pmf(dev, apdev):
|
||||||
finally:
|
finally:
|
||||||
stop_sigma_dut(sigma)
|
stop_sigma_dut(sigma)
|
||||||
|
|
||||||
|
@reset_ignore_old_scan_res
|
||||||
def test_sigma_dut_psk_pmf_bip_cmac_128(dev, apdev):
|
def test_sigma_dut_psk_pmf_bip_cmac_128(dev, apdev):
|
||||||
"""sigma_dut controlled PSK+PMF association with BIP-CMAC-128"""
|
"""sigma_dut controlled PSK+PMF association with BIP-CMAC-128"""
|
||||||
try:
|
|
||||||
run_sigma_dut_psk_pmf_cipher(dev, apdev, "BIP-CMAC-128", "AES-128-CMAC")
|
run_sigma_dut_psk_pmf_cipher(dev, apdev, "BIP-CMAC-128", "AES-128-CMAC")
|
||||||
finally:
|
|
||||||
dev[0].set("ignore_old_scan_res", "0")
|
|
||||||
|
|
||||||
|
@reset_ignore_old_scan_res
|
||||||
def test_sigma_dut_psk_pmf_bip_cmac_256(dev, apdev):
|
def test_sigma_dut_psk_pmf_bip_cmac_256(dev, apdev):
|
||||||
"""sigma_dut controlled PSK+PMF association with BIP-CMAC-256"""
|
"""sigma_dut controlled PSK+PMF association with BIP-CMAC-256"""
|
||||||
try:
|
|
||||||
run_sigma_dut_psk_pmf_cipher(dev, apdev, "BIP-CMAC-256", "BIP-CMAC-256")
|
run_sigma_dut_psk_pmf_cipher(dev, apdev, "BIP-CMAC-256", "BIP-CMAC-256")
|
||||||
finally:
|
|
||||||
dev[0].set("ignore_old_scan_res", "0")
|
|
||||||
|
|
||||||
|
@reset_ignore_old_scan_res
|
||||||
def test_sigma_dut_psk_pmf_bip_gmac_128(dev, apdev):
|
def test_sigma_dut_psk_pmf_bip_gmac_128(dev, apdev):
|
||||||
"""sigma_dut controlled PSK+PMF association with BIP-GMAC-128"""
|
"""sigma_dut controlled PSK+PMF association with BIP-GMAC-128"""
|
||||||
try:
|
|
||||||
run_sigma_dut_psk_pmf_cipher(dev, apdev, "BIP-GMAC-128", "BIP-GMAC-128")
|
run_sigma_dut_psk_pmf_cipher(dev, apdev, "BIP-GMAC-128", "BIP-GMAC-128")
|
||||||
finally:
|
|
||||||
dev[0].set("ignore_old_scan_res", "0")
|
|
||||||
|
|
||||||
|
@reset_ignore_old_scan_res
|
||||||
def test_sigma_dut_psk_pmf_bip_gmac_256(dev, apdev):
|
def test_sigma_dut_psk_pmf_bip_gmac_256(dev, apdev):
|
||||||
"""sigma_dut controlled PSK+PMF association with BIP-GMAC-256"""
|
"""sigma_dut controlled PSK+PMF association with BIP-GMAC-256"""
|
||||||
try:
|
|
||||||
run_sigma_dut_psk_pmf_cipher(dev, apdev, "BIP-GMAC-256", "BIP-GMAC-256")
|
run_sigma_dut_psk_pmf_cipher(dev, apdev, "BIP-GMAC-256", "BIP-GMAC-256")
|
||||||
finally:
|
|
||||||
dev[0].set("ignore_old_scan_res", "0")
|
|
||||||
|
|
||||||
|
@reset_ignore_old_scan_res
|
||||||
def test_sigma_dut_psk_pmf_bip_gmac_256_mismatch(dev, apdev):
|
def test_sigma_dut_psk_pmf_bip_gmac_256_mismatch(dev, apdev):
|
||||||
"""sigma_dut controlled PSK+PMF association with BIP-GMAC-256 mismatch"""
|
"""sigma_dut controlled PSK+PMF association with BIP-GMAC-256 mismatch"""
|
||||||
try:
|
|
||||||
run_sigma_dut_psk_pmf_cipher(dev, apdev, "BIP-GMAC-256", "AES-128-CMAC",
|
run_sigma_dut_psk_pmf_cipher(dev, apdev, "BIP-GMAC-256", "AES-128-CMAC",
|
||||||
failure=True)
|
failure=True)
|
||||||
finally:
|
|
||||||
dev[0].set("ignore_old_scan_res", "0")
|
|
||||||
|
|
||||||
def run_sigma_dut_psk_pmf_cipher(dev, apdev, sigma_cipher, hostapd_cipher,
|
def run_sigma_dut_psk_pmf_cipher(dev, apdev, sigma_cipher, hostapd_cipher,
|
||||||
failure=False):
|
failure=False):
|
||||||
|
@ -562,14 +542,9 @@ def run_sigma_dut_sae_pw_id_ft(dev, apdev, over_ds=False):
|
||||||
finally:
|
finally:
|
||||||
stop_sigma_dut(sigma)
|
stop_sigma_dut(sigma)
|
||||||
|
|
||||||
|
@reset_ignore_old_scan_res
|
||||||
def test_sigma_dut_sta_override_rsne(dev, apdev):
|
def test_sigma_dut_sta_override_rsne(dev, apdev):
|
||||||
"""sigma_dut and RSNE override on STA"""
|
"""sigma_dut and RSNE override on STA"""
|
||||||
try:
|
|
||||||
run_sigma_dut_sta_override_rsne(dev, apdev)
|
|
||||||
finally:
|
|
||||||
dev[0].set("ignore_old_scan_res", "0")
|
|
||||||
|
|
||||||
def run_sigma_dut_sta_override_rsne(dev, apdev):
|
|
||||||
ifname = dev[0].ifname
|
ifname = dev[0].ifname
|
||||||
sigma = start_sigma_dut(ifname)
|
sigma = start_sigma_dut(ifname)
|
||||||
|
|
||||||
|
@ -1261,14 +1236,9 @@ def test_sigma_dut_ap_psk_sae_ft(dev, apdev, params):
|
||||||
finally:
|
finally:
|
||||||
stop_sigma_dut(sigma)
|
stop_sigma_dut(sigma)
|
||||||
|
|
||||||
|
@reset_ignore_old_scan_res
|
||||||
def test_sigma_dut_owe(dev, apdev):
|
def test_sigma_dut_owe(dev, apdev):
|
||||||
"""sigma_dut controlled OWE station"""
|
"""sigma_dut controlled OWE station"""
|
||||||
try:
|
|
||||||
run_sigma_dut_owe(dev, apdev)
|
|
||||||
finally:
|
|
||||||
dev[0].set("ignore_old_scan_res", "0")
|
|
||||||
|
|
||||||
def run_sigma_dut_owe(dev, apdev):
|
|
||||||
if "OWE" not in dev[0].get_capability("key_mgmt"):
|
if "OWE" not in dev[0].get_capability("key_mgmt"):
|
||||||
raise HwsimSkip("OWE not supported")
|
raise HwsimSkip("OWE not supported")
|
||||||
|
|
||||||
|
@ -1332,6 +1302,7 @@ def run_sigma_dut_owe(dev, apdev):
|
||||||
finally:
|
finally:
|
||||||
stop_sigma_dut(sigma)
|
stop_sigma_dut(sigma)
|
||||||
|
|
||||||
|
@reset_ignore_old_scan_res
|
||||||
def test_sigma_dut_owe_ptk_workaround(dev, apdev):
|
def test_sigma_dut_owe_ptk_workaround(dev, apdev):
|
||||||
"""sigma_dut controlled OWE station with PTK workaround"""
|
"""sigma_dut controlled OWE station with PTK workaround"""
|
||||||
if "OWE" not in dev[0].get_capability("key_mgmt"):
|
if "OWE" not in dev[0].get_capability("key_mgmt"):
|
||||||
|
@ -1359,7 +1330,6 @@ def test_sigma_dut_owe_ptk_workaround(dev, apdev):
|
||||||
sigma_dut_cmd_check("sta_reset_default,interface," + ifname)
|
sigma_dut_cmd_check("sta_reset_default,interface," + ifname)
|
||||||
finally:
|
finally:
|
||||||
stop_sigma_dut(sigma)
|
stop_sigma_dut(sigma)
|
||||||
dev[0].set("ignore_old_scan_res", "0")
|
|
||||||
|
|
||||||
def test_sigma_dut_ap_owe(dev, apdev, params):
|
def test_sigma_dut_ap_owe(dev, apdev, params):
|
||||||
"""sigma_dut controlled AP with OWE"""
|
"""sigma_dut controlled AP with OWE"""
|
||||||
|
@ -3305,14 +3275,9 @@ def test_sigma_dut_dpp_nfc_static_write_enrollee(dev, apdev):
|
||||||
dev[0].set("dpp_config_processing", "0")
|
dev[0].set("dpp_config_processing", "0")
|
||||||
stop_sigma_dut(sigma)
|
stop_sigma_dut(sigma)
|
||||||
|
|
||||||
|
@reset_ignore_old_scan_res
|
||||||
def test_sigma_dut_preconfigured_profile(dev, apdev):
|
def test_sigma_dut_preconfigured_profile(dev, apdev):
|
||||||
"""sigma_dut controlled connection using preconfigured profile"""
|
"""sigma_dut controlled connection using preconfigured profile"""
|
||||||
try:
|
|
||||||
run_sigma_dut_preconfigured_profile(dev, apdev)
|
|
||||||
finally:
|
|
||||||
dev[0].set("ignore_old_scan_res", "0")
|
|
||||||
|
|
||||||
def run_sigma_dut_preconfigured_profile(dev, apdev):
|
|
||||||
ifname = dev[0].ifname
|
ifname = dev[0].ifname
|
||||||
sigma = start_sigma_dut(ifname)
|
sigma = start_sigma_dut(ifname)
|
||||||
|
|
||||||
|
@ -3332,14 +3297,9 @@ def run_sigma_dut_preconfigured_profile(dev, apdev):
|
||||||
finally:
|
finally:
|
||||||
stop_sigma_dut(sigma)
|
stop_sigma_dut(sigma)
|
||||||
|
|
||||||
|
@reset_ignore_old_scan_res
|
||||||
def test_sigma_dut_wps_pbc(dev, apdev):
|
def test_sigma_dut_wps_pbc(dev, apdev):
|
||||||
"""sigma_dut and WPS PBC Enrollee"""
|
"""sigma_dut and WPS PBC Enrollee"""
|
||||||
try:
|
|
||||||
run_sigma_dut_wps_pbc(dev, apdev)
|
|
||||||
finally:
|
|
||||||
dev[0].set("ignore_old_scan_res", "0")
|
|
||||||
|
|
||||||
def run_sigma_dut_wps_pbc(dev, apdev):
|
|
||||||
ssid = "test-wps-conf"
|
ssid = "test-wps-conf"
|
||||||
hapd = hostapd.add_ap(apdev[0],
|
hapd = hostapd.add_ap(apdev[0],
|
||||||
{"ssid": "wps", "eap_server": "1", "wps_state": "2",
|
{"ssid": "wps", "eap_server": "1", "wps_state": "2",
|
||||||
|
@ -3612,14 +3572,9 @@ def test_sigma_dut_ap_ent_ft_eap(dev, apdev, params):
|
||||||
finally:
|
finally:
|
||||||
stop_sigma_dut(sigma)
|
stop_sigma_dut(sigma)
|
||||||
|
|
||||||
|
@reset_ignore_old_scan_res
|
||||||
def test_sigma_dut_venue_url(dev, apdev):
|
def test_sigma_dut_venue_url(dev, apdev):
|
||||||
"""sigma_dut controlled Venue URL fetch"""
|
"""sigma_dut controlled Venue URL fetch"""
|
||||||
try:
|
|
||||||
run_sigma_dut_venue_url(dev, apdev)
|
|
||||||
finally:
|
|
||||||
dev[0].set("ignore_old_scan_res", "0")
|
|
||||||
|
|
||||||
def run_sigma_dut_venue_url(dev, apdev):
|
|
||||||
ifname = dev[0].ifname
|
ifname = dev[0].ifname
|
||||||
sigma = start_sigma_dut(ifname)
|
sigma = start_sigma_dut(ifname)
|
||||||
|
|
||||||
|
@ -4436,6 +4391,7 @@ def run_sigma_dut_ap_channel(dev, apdev, params, channel, mode, scan_freq,
|
||||||
subprocess.call(['iw', 'reg', 'set', '00'])
|
subprocess.call(['iw', 'reg', 'set', '00'])
|
||||||
dev[0].flush_scan_cache()
|
dev[0].flush_scan_cache()
|
||||||
|
|
||||||
|
@reset_ignore_old_scan_res
|
||||||
def test_sigma_dut_beacon_prot(dev, apdev):
|
def test_sigma_dut_beacon_prot(dev, apdev):
|
||||||
"""sigma_dut controlled STA and beacon protection"""
|
"""sigma_dut controlled STA and beacon protection"""
|
||||||
ssid = "test-pmf-required"
|
ssid = "test-pmf-required"
|
||||||
|
@ -4467,7 +4423,6 @@ def test_sigma_dut_beacon_prot(dev, apdev):
|
||||||
sigma_dut_cmd_check("sta_reset_default,interface," + ifname)
|
sigma_dut_cmd_check("sta_reset_default,interface," + ifname)
|
||||||
finally:
|
finally:
|
||||||
stop_sigma_dut(sigma)
|
stop_sigma_dut(sigma)
|
||||||
dev[0].set("ignore_old_scan_res", "0")
|
|
||||||
|
|
||||||
def test_sigma_dut_ap_beacon_prot(dev, apdev, params):
|
def test_sigma_dut_ap_beacon_prot(dev, apdev, params):
|
||||||
"""sigma_dut controlled AP and beacon protection"""
|
"""sigma_dut controlled AP and beacon protection"""
|
||||||
|
|
|
@ -258,23 +258,37 @@ def set_world_reg(apdev0=None, apdev1=None, dev0=None):
|
||||||
def sysctl_write(val):
|
def sysctl_write(val):
|
||||||
subprocess.call(['sysctl', '-w', val], stdout=open('/dev/null', 'w'))
|
subprocess.call(['sysctl', '-w', val], stdout=open('/dev/null', 'w'))
|
||||||
|
|
||||||
def disable_ipv6(fn):
|
def var_arg_call(fn, dev, apdev, params):
|
||||||
def wrapper(dev, apdev, params):
|
|
||||||
require_under_vm()
|
|
||||||
try:
|
|
||||||
sysctl_write('net.ipv6.conf.all.disable_ipv6=1')
|
|
||||||
sysctl_write('net.ipv6.conf.default.disable_ipv6=1')
|
|
||||||
if fn.__code__.co_argcount > 2:
|
if fn.__code__.co_argcount > 2:
|
||||||
return fn(dev, apdev, params)
|
return fn(dev, apdev, params)
|
||||||
elif fn.__code__.co_argcount > 1:
|
elif fn.__code__.co_argcount > 1:
|
||||||
return fn(dev, apdev)
|
return fn(dev, apdev)
|
||||||
return fn(dev)
|
return fn(dev)
|
||||||
finally:
|
|
||||||
sysctl_write('net.ipv6.conf.all.disable_ipv6=0')
|
def cloned_wrapper(wrapper, fn):
|
||||||
sysctl_write('net.ipv6.conf.default.disable_ipv6=0')
|
|
||||||
# we need the name set right for selecting / printing etc.
|
# we need the name set right for selecting / printing etc.
|
||||||
wrapper.__name__ = fn.__name__
|
wrapper.__name__ = fn.__name__
|
||||||
wrapper.__doc__ = fn.__doc__
|
wrapper.__doc__ = fn.__doc__
|
||||||
# reparent to the right module for module filtering
|
# reparent to the right module for module filtering
|
||||||
wrapper.__module__ = fn.__module__
|
wrapper.__module__ = fn.__module__
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
def disable_ipv6(fn):
|
||||||
|
def wrapper(dev, apdev, params):
|
||||||
|
require_under_vm()
|
||||||
|
try:
|
||||||
|
sysctl_write('net.ipv6.conf.all.disable_ipv6=1')
|
||||||
|
sysctl_write('net.ipv6.conf.default.disable_ipv6=1')
|
||||||
|
var_arg_call(fn, dev, apdev, params)
|
||||||
|
finally:
|
||||||
|
sysctl_write('net.ipv6.conf.all.disable_ipv6=0')
|
||||||
|
sysctl_write('net.ipv6.conf.default.disable_ipv6=0')
|
||||||
|
return cloned_wrapper(wrapper, fn)
|
||||||
|
|
||||||
|
def reset_ignore_old_scan_res(fn):
|
||||||
|
def wrapper(dev, apdev, params):
|
||||||
|
try:
|
||||||
|
var_arg_call(fn, dev, apdev, params)
|
||||||
|
finally:
|
||||||
|
dev[0].set("ignore_old_scan_res", "0")
|
||||||
|
return cloned_wrapper(wrapper, fn)
|
||||||
|
|
Loading…
Reference in a new issue