]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
tests/tpm2_key_protector_test: Reset "ret" on fail
authorGary Lin <glin@suse.com>
Mon, 7 Apr 2025 08:29:23 +0000 (16:29 +0800)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 10 Apr 2025 17:25:41 +0000 (19:25 +0200)
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 <glin@suse.com>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
tests/tpm2_key_protector_test.in

index 07477ba2a25346f096f23eae1a1a9d1a16990ee5..409696a29a811382dc02f0a12389f97165c423c3 100644 (file)
@@ -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}