mirror of
https://git.code.sf.net/p/linux-ima/ima-evm-utils
synced 2025-06-30 21:02:33 +02:00
Pass cleanup function and its arguments to _report_exit_and_cleanup()
If an error occurs before any test is executed, _report_exit_and_cleanup() returns 77 ($SKIP) as exit code, which might not reflect the real exit code at the time the script terminated its execution. If the function registered in the shell trap() is a cleanup function calling _report_exit_and_cleanup() inside, the latter will not have access to the exit code at the time of the trap but instead to the exit code of the cleanup function. To solve this issue, pass the cleanup function and its arguments to _report_exit_and_cleanup(), so that the latter can first get the script exit code and then can execute the cleanup function. Finally, if no test was executed, return the exit code at the time of the trap() instead of 77. Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com> Reviewed-by: Stefan Berger <stefanb@linux.ibm.com> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
This commit is contained in:

committed by
Mimi Zohar

parent
3fadf997a6
commit
03b5d159ca
@ -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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user