diff --git a/tests/boot_aggregate.test b/tests/boot_aggregate.test index d711566..ca5faf9 100755 --- a/tests/boot_aggregate.test +++ b/tests/boot_aggregate.test @@ -12,7 +12,7 @@ # for verifying the calculated boot_aggregate is included in this # directory as well. -trap cleanup SIGINT SIGTERM EXIT +trap '_report_exit_and_cleanup cleanup' SIGINT SIGTERM EXIT # Base VERBOSE on the environment variable, if set. VERBOSE="${VERBOSE:-0}" diff --git a/tests/fsverity.test b/tests/fsverity.test index 549c42a..be95940 100755 --- a/tests/fsverity.test +++ b/tests/fsverity.test @@ -47,7 +47,7 @@ FSVERITY="$(which fsverity)" _require dd mkfs blkid e2fsck tune2fs evmctl setfattr ./gen-keys.sh >/dev/null 2>&1 -trap cleanup SIGINT SIGTERM EXIT +trap '_report_exit_and_cleanup cleanup' SIGINT SIGTERM EXIT cleanup() { if [ -e $TST_MNT ]; then @@ -58,7 +58,6 @@ cleanup() { rm "$TST_IMG" fi fi - _report_exit_and_cleanup } # Loopback mount a file diff --git a/tests/functions.sh b/tests/functions.sh index 8f6f02d..d0a9e8e 100755 --- a/tests/functions.sh +++ b/tests/functions.sh @@ -250,10 +250,14 @@ _enable_gost_engine() { # Show test stats and exit into automake test system # with proper exit code (same as ours). Do cleanups. _report_exit_and_cleanup() { + local exit_code=$? + if [ -n "${WORKDIR}" ]; then rm -rf "${WORKDIR}" fi + "$@" + if [ $testsfail -gt 0 ]; then echo "=================================" echo " Run with FAILEARLY=1 $0 $*" @@ -271,8 +275,10 @@ _report_exit_and_cleanup() { exit "$FAIL" elif [ $testspass -gt 0 ]; then exit "$OK" - else + elif [ $testsskip -gt 0 ]; then exit "$SKIP" + else + exit "$exit_code" fi } @@ -312,4 +318,4 @@ _softhsm_teardown() { rm -rf "${SOFTHSM_SETUP_CONFIGDIR}" unset SOFTHSM_SETUP_CONFIGDIR SOFTHSM2_CONF PKCS11_KEYURI \ EVMCTL_ENGINE OPENSSL_ENGINE OPENSSL_KEYFORM -} \ No newline at end of file +}