test: Log output of individual tests
This commit is contained in:
parent
5138d88b12
commit
c57c79fa36
30
test.sh
30
test.sh
@ -31,14 +31,21 @@ function runtest_success()
|
||||
|
||||
function runtest()
|
||||
{
|
||||
must_exit_zero=$2
|
||||
testname="$1"
|
||||
must_exit_zero="$2"
|
||||
test_log_file="$3"
|
||||
|
||||
echo "Running: $testname. Date: $(date)" > "${test_log_file}"
|
||||
|
||||
echo -n "Running $1... "
|
||||
#exit 1 to suppress shell message like "./test.sh: line 18: pid Bad system call"
|
||||
(./test $1 || exit 1) 2> /dev/null
|
||||
(./test $1 || exit 1) &>> "${test_log_file}"
|
||||
ret=$?
|
||||
SUCCESS=0
|
||||
if [ $must_exit_zero -eq 1 ] ; then
|
||||
if [ $ret -eq 0 ] ; then
|
||||
runtest_success
|
||||
SUCCESS=1
|
||||
else
|
||||
runtest_fail
|
||||
fi
|
||||
@ -47,20 +54,35 @@ function runtest()
|
||||
runtest_fail
|
||||
else
|
||||
runtest_success
|
||||
SUCCESS=1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Finished: ${testname}. Date: $(date). Success: $SUCCESS" >> "${test_log_file}"
|
||||
|
||||
}
|
||||
|
||||
GIT_ID=$( git log --pretty="format:%h" -n1 )
|
||||
TIMESTAMP=$(date +%s)
|
||||
LOG_OUTPUT_DIR=$1
|
||||
if [ -z "$LOG_OUTPUT_DIR" ] ; then
|
||||
LOG_OUTPUT_DIR="./logs/"
|
||||
fi
|
||||
|
||||
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
|
||||
runtest "$testname" $must_exit_zero "${LOG_OUTPUT_DIR_PATH}/log.${testname}"
|
||||
done
|
||||
echo
|
||||
echo "Tests finished:"
|
||||
echo "Tests finished. Logs in $(realpath ${LOG_OUTPUT_DIR_PATH})"
|
||||
echo "Succeeded: $COUNT_SUCCEEDED"
|
||||
echo "Failed: $COUNT_FAILED"
|
||||
|
||||
|
||||
if [ $COUNT_FAILED -gt 0 ] ; then
|
||||
exit 1
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user