tests: Avoid exception string matching for failures
Future commits change the related code and exception string. Avoiding using the context is easy here and actually avoids two layers of nesting. Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
This commit is contained in:
parent
2c89ca9223
commit
6f2289b6b4
1 changed files with 25 additions and 19 deletions
|
@ -3469,26 +3469,32 @@ def test_ap_wpa2_eap_eke_server_oom(dev, apdev):
|
||||||
dev[0].request("REMOVE_NETWORK all")
|
dev[0].request("REMOVE_NETWORK all")
|
||||||
|
|
||||||
for count in range(1, 1000):
|
for count in range(1, 1000):
|
||||||
try:
|
# Fail on allocation number "count"
|
||||||
with alloc_fail(hapd, count, "eap_server_sm_step"):
|
hapd.request("TEST_ALLOC_FAIL %d:eap_server_sm_step" % count)
|
||||||
dev[0].connect("test-wpa2-eap",
|
|
||||||
key_mgmt="WPA-EAP WPA-EAP-SHA256",
|
dev[0].connect("test-wpa2-eap",
|
||||||
eap="EKE", identity="eke user", password=pw,
|
key_mgmt="WPA-EAP WPA-EAP-SHA256",
|
||||||
wait_connect=False, scan_freq="2412")
|
eap="EKE", identity="eke user", password=pw,
|
||||||
# This would eventually time out, but we can stop after having
|
wait_connect=False, scan_freq="2412")
|
||||||
# reached the allocation failure.
|
# This would eventually time out, but we can stop after having
|
||||||
for i in range(10):
|
# reached the allocation failure.
|
||||||
time.sleep(0.1)
|
for i in range(10):
|
||||||
if hapd.request("GET_ALLOC_FAIL").startswith('0'):
|
time.sleep(0.1)
|
||||||
break
|
if hapd.request("GET_ALLOC_FAIL").startswith('0'):
|
||||||
dev[0].request("REMOVE_NETWORK all")
|
|
||||||
except Exception as e:
|
|
||||||
if str(e) == "Allocation failure did not trigger":
|
|
||||||
if count < 30:
|
|
||||||
raise Exception("Too few allocation failures")
|
|
||||||
logger.info("%d allocation failures tested" % (count - 1))
|
|
||||||
break
|
break
|
||||||
raise e
|
else:
|
||||||
|
# Last iteration had no failure
|
||||||
|
# i.e. we exceeded the number of allocations
|
||||||
|
dev[0].request("REMOVE_NETWORK all")
|
||||||
|
logger.info("%d allocation failures tested" % (count - 1))
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
# All iterations had an allocation failure
|
||||||
|
hapd.request("TEST_ALLOC_FAIL 0:")
|
||||||
|
raise Exception("More than %d allocations, test aborted" % (count - 1))
|
||||||
|
|
||||||
|
if count < 30:
|
||||||
|
raise Exception("Too few allocation failures")
|
||||||
|
|
||||||
def test_ap_wpa2_eap_ikev2(dev, apdev):
|
def test_ap_wpa2_eap_ikev2(dev, apdev):
|
||||||
"""WPA2-Enterprise connection using EAP-IKEv2"""
|
"""WPA2-Enterprise connection using EAP-IKEv2"""
|
||||||
|
|
Loading…
Reference in a new issue