From: Gary Lin Date: Mon, 7 Apr 2025 08:29:23 +0000 (+0800) Subject: tests/tpm2_key_protector_test: Reset "ret" on fail X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9f66a4719b7fed24fe36154d634c16dd9bd528c9;p=thirdparty%2Fgrub.git tests/tpm2_key_protector_test: Reset "ret" on fail Reset "ret" to 0 when a test case fails so that the other test cases could continue. Also set the exit status to 1 when encountering a failure to reflect the test result. Signed-off-by: Gary Lin Reviewed-by: Stefan Berger Reviewed-by: Daniel Kiper --- diff --git a/tests/tpm2_key_protector_test.in b/tests/tpm2_key_protector_test.in index 07477ba2a..409696a29 100644 --- a/tests/tpm2_key_protector_test.in +++ b/tests/tpm2_key_protector_test.in @@ -285,12 +285,16 @@ srktests+=("ECC persistent no_fallback_srk") srktests+=("RSA transient fallback_srk") srktests+=("ECC transient fallback_srk") +exit_status=0 + for i in "${!srktests[@]}"; do tpm2_seal_unseal ${srktests[$i]} || ret=$? if [ "${ret}" -eq 0 ]; then echo "TPM2 [${srktests[$i]}]: PASS" elif [ "${ret}" -eq 1 ]; then echo "TPM2 [${srktests[$i]}]: FAIL" + ret=0 + exit_status=1 else echo "Unexpected failure [${srktests[$i]}]" >&2 exit ${ret} @@ -303,9 +307,11 @@ if [ "${ret}" -eq 0 ]; then echo "TPM2 [NV Index]: PASS" elif [ "${ret}" -eq 1 ]; then echo "TPM2 [NV Index]: FAIL" + ret=0 + exit_status=1 else echo "Unexpected failure [NV index]" >&2 exit ${ret} fi -exit 0 +exit ${exit_status}