@@ -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}"
@@ -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
@@ -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
+}