tests: Call stop_sigma_dut() in more failure cases
Some of the sigma_dut test cases were not yet using try/finally to ensure stop_sigma_dut() gets called. That could result in not logging all failure reasons in the log and getting stuck with being unable to start new sigma_dut processes after failed test cases. Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
This commit is contained in:
parent
f0b6b23fe3
commit
991e6b9e79
1 changed files with 327 additions and 308 deletions
|
@ -162,20 +162,21 @@ def test_sigma_dut_basic(dev, apdev):
|
|||
"""sigma_dut basic functionality"""
|
||||
sigma = start_sigma_dut(dev[0].ifname)
|
||||
|
||||
res = sigma_dut_cmd("UNKNOWN")
|
||||
if "status,INVALID,errorCode,Unknown command" not in res:
|
||||
raise Exception("Unexpected sigma_dut response to unknown command")
|
||||
|
||||
tests = [("ca_get_version", "status,COMPLETE,version,1.0"),
|
||||
("device_get_info", "status,COMPLETE,vendor"),
|
||||
("device_list_interfaces,interfaceType,foo", "status,ERROR"),
|
||||
("device_list_interfaces,interfaceType,802.11",
|
||||
"status,COMPLETE,interfaceType,802.11,interfaceID," + dev[0].ifname)]
|
||||
try:
|
||||
res = sigma_dut_cmd("UNKNOWN")
|
||||
if "status,INVALID,errorCode,Unknown command" not in res:
|
||||
raise Exception("Unexpected sigma_dut response to unknown command")
|
||||
|
||||
for cmd, response in tests:
|
||||
res = sigma_dut_cmd(cmd)
|
||||
if response not in res:
|
||||
raise Exception("Unexpected %s response: %s" % (cmd, res))
|
||||
|
||||
finally:
|
||||
stop_sigma_dut(sigma)
|
||||
|
||||
def test_sigma_dut_open(dev, apdev):
|
||||
|
@ -189,6 +190,7 @@ def run_sigma_dut_open(dev, apdev):
|
|||
ifname = dev[0].ifname
|
||||
sigma = start_sigma_dut(ifname)
|
||||
|
||||
try:
|
||||
hapd = hostapd.add_ap(apdev[0], {"ssid": "open"})
|
||||
|
||||
sigma_dut_cmd_check("sta_set_ip_config,interface,%s,dhcp,0,ip,127.0.0.11,mask,255.255.255.0" % ifname)
|
||||
|
@ -198,7 +200,7 @@ def run_sigma_dut_open(dev, apdev):
|
|||
sigma_dut_cmd_check("sta_get_ip_config,interface," + ifname)
|
||||
sigma_dut_cmd_check("sta_disconnect,interface," + ifname)
|
||||
sigma_dut_cmd_check("sta_reset_default,interface," + ifname)
|
||||
|
||||
finally:
|
||||
stop_sigma_dut(sigma)
|
||||
|
||||
def test_sigma_dut_psk_pmf(dev, apdev):
|
||||
|
@ -212,6 +214,7 @@ def run_sigma_dut_psk_pmf(dev, apdev):
|
|||
ifname = dev[0].ifname
|
||||
sigma = start_sigma_dut(ifname)
|
||||
|
||||
try:
|
||||
ssid = "test-pmf-required"
|
||||
params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678")
|
||||
params["wpa_key_mgmt"] = "WPA-PSK-SHA256"
|
||||
|
@ -226,7 +229,7 @@ def run_sigma_dut_psk_pmf(dev, apdev):
|
|||
sigma_dut_cmd_check("sta_get_ip_config,interface," + ifname)
|
||||
sigma_dut_cmd_check("sta_disconnect,interface," + ifname)
|
||||
sigma_dut_cmd_check("sta_reset_default,interface," + ifname)
|
||||
|
||||
finally:
|
||||
stop_sigma_dut(sigma)
|
||||
|
||||
def test_sigma_dut_psk_pmf_bip_cmac_128(dev, apdev):
|
||||
|
@ -270,6 +273,7 @@ def run_sigma_dut_psk_pmf_cipher(dev, apdev, sigma_cipher, hostapd_cipher,
|
|||
ifname = dev[0].ifname
|
||||
sigma = start_sigma_dut(ifname)
|
||||
|
||||
try:
|
||||
ssid = "test-pmf-required"
|
||||
params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678")
|
||||
params["wpa_key_mgmt"] = "WPA-PSK-SHA256"
|
||||
|
@ -297,7 +301,7 @@ def run_sigma_dut_psk_pmf_cipher(dev, apdev, sigma_cipher, hostapd_cipher,
|
|||
|
||||
sigma_dut_cmd_check("sta_disconnect,interface," + ifname)
|
||||
sigma_dut_cmd_check("sta_reset_default,interface," + ifname)
|
||||
|
||||
finally:
|
||||
stop_sigma_dut(sigma)
|
||||
|
||||
def test_sigma_dut_sae(dev, apdev):
|
||||
|
@ -308,6 +312,7 @@ def test_sigma_dut_sae(dev, apdev):
|
|||
ifname = dev[0].ifname
|
||||
sigma = start_sigma_dut(ifname)
|
||||
|
||||
try:
|
||||
ssid = "test-sae"
|
||||
params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678")
|
||||
params['wpa_key_mgmt'] = 'SAE'
|
||||
|
@ -336,7 +341,7 @@ def test_sigma_dut_sae(dev, apdev):
|
|||
raise Exception("Expected SAE group not used")
|
||||
sigma_dut_cmd_check("sta_disconnect,interface," + ifname)
|
||||
sigma_dut_cmd_check("sta_reset_default,interface," + ifname)
|
||||
|
||||
finally:
|
||||
stop_sigma_dut(sigma)
|
||||
|
||||
def test_sigma_dut_sae_groups(dev, apdev):
|
||||
|
@ -347,6 +352,7 @@ def test_sigma_dut_sae_groups(dev, apdev):
|
|||
ifname = dev[0].ifname
|
||||
sigma = start_sigma_dut(ifname)
|
||||
|
||||
try:
|
||||
ssid = "test-sae"
|
||||
params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678")
|
||||
params['wpa_key_mgmt'] = 'SAE'
|
||||
|
@ -365,7 +371,7 @@ def test_sigma_dut_sae_groups(dev, apdev):
|
|||
sigma_dut_cmd_check("sta_disconnect,interface," + ifname)
|
||||
|
||||
sigma_dut_cmd_check("sta_reset_default,interface," + ifname)
|
||||
|
||||
finally:
|
||||
stop_sigma_dut(sigma)
|
||||
|
||||
def test_sigma_dut_sae_pmkid_include(dev, apdev):
|
||||
|
@ -376,6 +382,7 @@ def test_sigma_dut_sae_pmkid_include(dev, apdev):
|
|||
ifname = dev[0].ifname
|
||||
sigma = start_sigma_dut(ifname)
|
||||
|
||||
try:
|
||||
ssid = "test-sae"
|
||||
params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678")
|
||||
params['wpa_key_mgmt'] = 'SAE'
|
||||
|
@ -389,6 +396,7 @@ def test_sigma_dut_sae_pmkid_include(dev, apdev):
|
|||
sigma_dut_cmd_check("sta_associate,interface,%s,ssid,%s,channel,1" % (ifname, "test-sae"))
|
||||
sigma_dut_wait_connected(ifname)
|
||||
sigma_dut_cmd_check("sta_reset_default,interface," + ifname)
|
||||
finally:
|
||||
stop_sigma_dut(sigma)
|
||||
|
||||
def test_sigma_dut_sae_password(dev, apdev):
|
||||
|
@ -426,6 +434,7 @@ def test_sigma_dut_sae_pw_id(dev, apdev):
|
|||
ifname = dev[0].ifname
|
||||
sigma = start_sigma_dut(ifname)
|
||||
|
||||
try:
|
||||
ssid = "test-sae"
|
||||
params = hostapd.wpa2_params(ssid=ssid)
|
||||
params['wpa_key_mgmt'] = 'SAE'
|
||||
|
@ -441,7 +450,7 @@ def test_sigma_dut_sae_pw_id(dev, apdev):
|
|||
sigma_dut_wait_connected(ifname)
|
||||
sigma_dut_cmd_check("sta_disconnect,interface," + ifname)
|
||||
sigma_dut_cmd_check("sta_reset_default,interface," + ifname)
|
||||
|
||||
finally:
|
||||
stop_sigma_dut(sigma)
|
||||
|
||||
def test_sigma_dut_sae_pw_id_ft(dev, apdev):
|
||||
|
@ -459,6 +468,7 @@ def run_sigma_dut_sae_pw_id_ft(dev, apdev, over_ds=False):
|
|||
ifname = dev[0].ifname
|
||||
sigma = start_sigma_dut(ifname)
|
||||
|
||||
try:
|
||||
ssid = "test-sae"
|
||||
params = hostapd.wpa2_params(ssid=ssid)
|
||||
params['wpa_key_mgmt'] = 'SAE FT-SAE'
|
||||
|
@ -492,7 +502,7 @@ def run_sigma_dut_sae_pw_id_ft(dev, apdev, over_ds=False):
|
|||
|
||||
sigma_dut_cmd_check("sta_disconnect,interface," + ifname)
|
||||
sigma_dut_cmd_check("sta_reset_default,interface," + ifname)
|
||||
|
||||
finally:
|
||||
stop_sigma_dut(sigma)
|
||||
|
||||
def test_sigma_dut_sta_override_rsne(dev, apdev):
|
||||
|
@ -506,6 +516,7 @@ def run_sigma_dut_sta_override_rsne(dev, apdev):
|
|||
ifname = dev[0].ifname
|
||||
sigma = start_sigma_dut(ifname)
|
||||
|
||||
try:
|
||||
ssid = "test-psk"
|
||||
params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678")
|
||||
hapd = hostapd.add_ap(apdev[0], params)
|
||||
|
@ -533,7 +544,7 @@ def run_sigma_dut_sta_override_rsne(dev, apdev):
|
|||
raise Exception("Unexpected status code: " + ev)
|
||||
|
||||
sigma_dut_cmd_check("sta_reset_default,interface," + ifname)
|
||||
|
||||
finally:
|
||||
stop_sigma_dut(sigma)
|
||||
|
||||
def test_sigma_dut_ap_psk(dev, apdev):
|
||||
|
@ -657,6 +668,7 @@ def test_sigma_dut_eap_ttls(dev, apdev, params):
|
|||
|
||||
cmd = "sta_set_security,type,eapttls,interface,%s,ssid,%s,keymgmttype,wpa2,encType,AES-CCMP,PairwiseCipher,AES-CCMP-128,trustedRootCA,sigma_dut_eap_ttls.ca.pem,username,DOMAIN\mschapv2 user,password,password" % (ifname, ssid)
|
||||
|
||||
try:
|
||||
tests = ["",
|
||||
",Domain,server.w1.fi",
|
||||
",DomainSuffix,w1.fi",
|
||||
|
@ -690,7 +702,7 @@ def test_sigma_dut_eap_ttls(dev, apdev, params):
|
|||
sigma_dut_cmd_check("sta_disconnect,interface," + ifname)
|
||||
sigma_dut_cmd_check("sta_reset_default,interface," + ifname)
|
||||
dev[0].dump_monitor()
|
||||
|
||||
finally:
|
||||
stop_sigma_dut(sigma)
|
||||
|
||||
def test_sigma_dut_suite_b(dev, apdev, params):
|
||||
|
@ -732,6 +744,7 @@ def test_sigma_dut_suite_b(dev, apdev, params):
|
|||
ifname = dev[0].ifname
|
||||
sigma = start_sigma_dut(ifname, cert_path=logdir)
|
||||
|
||||
try:
|
||||
sigma_dut_cmd_check("sta_reset_default,interface,%s,prog,PMF" % ifname)
|
||||
sigma_dut_cmd_check("sta_set_ip_config,interface,%s,dhcp,0,ip,127.0.0.11,mask,255.255.255.0" % ifname)
|
||||
sigma_dut_cmd_check("sta_set_security,type,eaptls,interface,%s,ssid,%s,PairwiseCipher,AES-GCMP-256,GroupCipher,AES-GCMP-256,GroupMgntCipher,BIP-GMAC-256,keymgmttype,SuiteB,clientCertificate,suite_b.pem,trustedRootCA,suite_b_ca.pem,CertType,ECC" % (ifname, "test-suite-b"))
|
||||
|
@ -740,7 +753,7 @@ def test_sigma_dut_suite_b(dev, apdev, params):
|
|||
sigma_dut_cmd_check("sta_get_ip_config,interface," + ifname)
|
||||
sigma_dut_cmd_check("sta_disconnect,interface," + ifname)
|
||||
sigma_dut_cmd_check("sta_reset_default,interface," + ifname)
|
||||
|
||||
finally:
|
||||
stop_sigma_dut(sigma)
|
||||
|
||||
def test_sigma_dut_suite_b_rsa(dev, apdev, params):
|
||||
|
@ -767,6 +780,7 @@ def test_sigma_dut_suite_b_rsa(dev, apdev, params):
|
|||
|
||||
cmd = "sta_set_security,type,eaptls,interface,%s,ssid,%s,PairwiseCipher,AES-GCMP-256,GroupCipher,AES-GCMP-256,GroupMgntCipher,BIP-GMAC-256,keymgmttype,SuiteB,clientCertificate,suite_b_rsa.pem,trustedRootCA,suite_b_ca_rsa.pem,CertType,RSA" % (ifname, "test-suite-b")
|
||||
|
||||
try:
|
||||
tests = ["",
|
||||
",TLSCipher,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
|
||||
",TLSCipher,TLS_DHE_RSA_WITH_AES_256_GCM_SHA384"]
|
||||
|
@ -779,7 +793,7 @@ def test_sigma_dut_suite_b_rsa(dev, apdev, params):
|
|||
sigma_dut_cmd_check("sta_get_ip_config,interface," + ifname)
|
||||
sigma_dut_cmd_check("sta_disconnect,interface," + ifname)
|
||||
sigma_dut_cmd_check("sta_reset_default,interface," + ifname)
|
||||
|
||||
finally:
|
||||
stop_sigma_dut(sigma)
|
||||
|
||||
def test_sigma_dut_ap_suite_b(dev, apdev, params):
|
||||
|
@ -2705,6 +2719,7 @@ def run_sigma_dut_preconfigured_profile(dev, apdev):
|
|||
ifname = dev[0].ifname
|
||||
sigma = start_sigma_dut(ifname)
|
||||
|
||||
try:
|
||||
params = hostapd.wpa2_params(ssid="test-psk", passphrase="12345678")
|
||||
hapd = hostapd.add_ap(apdev[0], params)
|
||||
dev[0].connect("test-psk", psk="12345678", scan_freq="2412",
|
||||
|
@ -2716,7 +2731,7 @@ def run_sigma_dut_preconfigured_profile(dev, apdev):
|
|||
sigma_dut_cmd_check("sta_get_ip_config,interface," + ifname)
|
||||
sigma_dut_cmd_check("sta_disconnect,interface," + ifname)
|
||||
sigma_dut_cmd_check("sta_reset_default,interface," + ifname)
|
||||
|
||||
finally:
|
||||
stop_sigma_dut(sigma)
|
||||
|
||||
def test_sigma_dut_wps_pbc(dev, apdev):
|
||||
|
@ -2737,6 +2752,7 @@ def run_sigma_dut_wps_pbc(dev, apdev):
|
|||
ifname = dev[0].ifname
|
||||
sigma = start_sigma_dut(ifname)
|
||||
|
||||
try:
|
||||
cmd = "start_wps_registration,interface,%s" % ifname
|
||||
cmd += ",WpsRole,Enrollee"
|
||||
cmd += ",WpsConfigMethod,PBC"
|
||||
|
@ -2745,6 +2761,7 @@ def run_sigma_dut_wps_pbc(dev, apdev):
|
|||
sigma_dut_cmd_check("sta_disconnect,interface," + ifname)
|
||||
hapd.disable()
|
||||
sigma_dut_cmd_check("sta_reset_default,interface," + ifname)
|
||||
finally:
|
||||
stop_sigma_dut(sigma)
|
||||
dev[0].flush_scan_cache()
|
||||
|
||||
|
@ -2980,6 +2997,7 @@ def run_sigma_dut_venue_url(dev, apdev):
|
|||
ifname = dev[0].ifname
|
||||
sigma = start_sigma_dut(ifname)
|
||||
|
||||
try:
|
||||
ssid = "venue"
|
||||
params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678")
|
||||
params["wpa_key_mgmt"] = "WPA-PSK-SHA256"
|
||||
|
@ -3014,7 +3032,7 @@ def run_sigma_dut_venue_url(dev, apdev):
|
|||
sigma_dut_cmd_check("sta_hs2_venue_info,interface," + ifname + ",Display,Yes")
|
||||
sigma_dut_cmd_check("sta_disconnect,interface," + ifname)
|
||||
sigma_dut_cmd_check("sta_reset_default,interface," + ifname)
|
||||
|
||||
finally:
|
||||
stop_sigma_dut(sigma)
|
||||
|
||||
def test_sigma_dut_hs20_assoc_24(dev, apdev):
|
||||
|
@ -3061,6 +3079,7 @@ def run_sigma_dut_hs20_assoc_2(dev, apdev, band, expect_bssid):
|
|||
ifname = dev[0].ifname
|
||||
sigma = start_sigma_dut(ifname)
|
||||
|
||||
try:
|
||||
sigma_dut_cmd_check("sta_reset_default,interface,%s,prog,HS2-R3" % ifname)
|
||||
sigma_dut_cmd_check("sta_set_ip_config,interface,%s,dhcp,0,ip,127.0.0.11,mask,255.255.255.0" % ifname)
|
||||
sigma_dut_cmd_check("sta_add_credential,interface,%s,type,uname_pwd,realm,example.com,username,hs20-test,password,password" % ifname)
|
||||
|
@ -3070,7 +3089,7 @@ def run_sigma_dut_hs20_assoc_2(dev, apdev, band, expect_bssid):
|
|||
sigma_dut_cmd_check("sta_get_ip_config,interface," + ifname)
|
||||
sigma_dut_cmd_check("sta_disconnect,interface," + ifname)
|
||||
sigma_dut_cmd_check("sta_reset_default,interface," + ifname)
|
||||
|
||||
finally:
|
||||
stop_sigma_dut(sigma)
|
||||
|
||||
if "BSSID," + expect_bssid not in res:
|
||||
|
|
Loading…
Reference in a new issue