test: Refactor: Put seccomp tests into child processes ; Simplfy .sh

Refactor the test logic. Seccomp tests that can be
killed run in their own subprocess now.

All test functions now return 0 on success. Therefore,
the shell script can be simplified.
This commit is contained in:
2021-09-05 16:48:27 +02:00
parent 26f391f736
commit b2b501d97e
2 changed files with 121 additions and 49 deletions

28
test.sh
View File

@ -32,8 +32,7 @@ function runtest_success()
function runtest()
{
testname="$1"
must_exit_zero="$2"
test_log_file="$3"
test_log_file="$2"
echo "Running: $testname. Date: $(date)" > "${test_log_file}"
@ -42,24 +41,14 @@ function runtest()
(./test $1 || exit $?) &>> "${test_log_file}"
ret=$?
SUCCESS="no"
if [ $must_exit_zero -eq 1 ] ; then
if [ $ret -eq 0 ] ; then
runtest_success
SUCCESS="yes"
else
runtest_fail
fi
if [ $ret -eq 0 ] ; then
runtest_success
SUCCESS="yes"
else
if [ $ret -eq 0 ] ; then
runtest_fail
else
runtest_success
SUCCESS="yes"
fi
runtest_fail
fi
echo "Finished: ${testname}. Date: $(date). Return code: $ret. Success: $SUCCESS" >> "${test_log_file}"
echo "Finished: ${testname}. Date: $(date). Success: $SUCCESS" >> "${test_log_file}"
}
GIT_ID=$( git log --pretty="format:%h" -n1 )
@ -73,9 +62,8 @@ LOG_OUTPUT_DIR_PATH="${LOG_OUTPUT_DIR}/qssb_test_${GIT_ID}_${TIMESTAMP}"
[ -d "$LOG_OUTPUT_DIR_PATH" ] || mkdir -p "$LOG_OUTPUT_DIR_PATH"
for test in $( ./test --dumptests ) ; do
testname=$( echo $test | cut -d":" -f1 )
must_exit_zero=$( echo "$test" | cut -d":" -f2 )
runtest "$testname" $must_exit_zero "${LOG_OUTPUT_DIR_PATH}/log.${testname}"
testname=$( echo $test )
runtest "$testname" "${LOG_OUTPUT_DIR_PATH}/log.${testname}"
done
echo
echo "Tests finished. Logs in $(realpath ${LOG_OUTPUT_DIR_PATH})"