2021-06-05 14:07:11 +02:00
|
|
|
#!/bin/sh
|
|
|
|
GREEN='\033[0;32m'
|
|
|
|
RED='\033[0;31m'
|
2021-11-20 17:03:04 +01:00
|
|
|
YELLOW='\033[1;33m'
|
2021-06-05 14:07:11 +02:00
|
|
|
NC='\033[0m'
|
|
|
|
|
2021-06-06 09:02:30 +02:00
|
|
|
COUNT_SUCCEEDED=0
|
|
|
|
COUNT_FAILED=0
|
2021-11-20 17:03:04 +01:00
|
|
|
COUNT_SKIPPED=0
|
2021-06-06 09:02:30 +02:00
|
|
|
|
2021-06-06 08:57:24 +02:00
|
|
|
function print_fail()
|
2021-06-05 14:07:11 +02:00
|
|
|
{
|
|
|
|
echo -e "${RED}$@${NC}" 1>&2
|
|
|
|
}
|
|
|
|
|
2021-06-06 08:57:24 +02:00
|
|
|
function print_success()
|
2021-06-05 14:07:11 +02:00
|
|
|
{
|
|
|
|
echo -e "${GREEN}$@${NC}"
|
|
|
|
}
|
|
|
|
|
2021-11-20 17:03:04 +01:00
|
|
|
function print_skipped()
|
|
|
|
{
|
|
|
|
echo -e "${YELLOW}$@${NC}"
|
|
|
|
}
|
|
|
|
|
2021-06-06 09:02:30 +02:00
|
|
|
function runtest_fail()
|
|
|
|
{
|
|
|
|
print_fail "failed"
|
|
|
|
COUNT_FAILED=$(($COUNT_FAILED+1))
|
|
|
|
}
|
|
|
|
|
|
|
|
function runtest_success()
|
|
|
|
{
|
|
|
|
print_success "ok"
|
|
|
|
COUNT_SUCCEEDED=$((COUNT_SUCCEEDED+1))
|
|
|
|
}
|
|
|
|
|
2021-11-20 17:03:04 +01:00
|
|
|
function runtest_skipped()
|
|
|
|
{
|
|
|
|
print_skipped "skipped"
|
|
|
|
COUNT_SKIPPED=$((COUNT_SKIPPED+1))
|
|
|
|
}
|
|
|
|
|
2021-06-06 09:02:30 +02:00
|
|
|
|
2021-06-05 14:07:11 +02:00
|
|
|
function runtest()
|
|
|
|
{
|
2021-06-06 09:27:45 +02:00
|
|
|
testname="$1"
|
2021-09-05 16:48:27 +02:00
|
|
|
test_log_file="$2"
|
2021-06-06 09:27:45 +02:00
|
|
|
|
|
|
|
echo "Running: $testname. Date: $(date)" > "${test_log_file}"
|
|
|
|
|
2021-06-05 14:07:11 +02:00
|
|
|
echo -n "Running $1... "
|
2021-08-16 23:08:16 +02:00
|
|
|
#exit $? to suppress shell message like "./test.sh: line 18: pid Bad system call"
|
|
|
|
(./test $1 || exit $?) &>> "${test_log_file}"
|
2021-06-05 14:07:11 +02:00
|
|
|
ret=$?
|
2021-08-16 23:08:16 +02:00
|
|
|
SUCCESS="no"
|
2021-09-05 16:48:27 +02:00
|
|
|
if [ $ret -eq 0 ] ; then
|
|
|
|
runtest_success
|
|
|
|
SUCCESS="yes"
|
2021-11-20 17:03:04 +01:00
|
|
|
elif [ $ret -eq 2 ] ; then
|
|
|
|
runtest_skipped
|
|
|
|
SUCCESS="skipped"
|
2021-06-05 14:07:11 +02:00
|
|
|
else
|
2021-09-05 16:48:27 +02:00
|
|
|
runtest_fail
|
2021-06-05 14:07:11 +02:00
|
|
|
fi
|
2021-06-06 09:27:45 +02:00
|
|
|
|
2021-09-05 16:48:27 +02:00
|
|
|
echo "Finished: ${testname}. Date: $(date). Success: $SUCCESS" >> "${test_log_file}"
|
2021-06-05 14:07:11 +02:00
|
|
|
}
|
|
|
|
|
2021-06-06 09:27:45 +02:00
|
|
|
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
|
|
|
|
|
2021-11-30 17:57:48 +01:00
|
|
|
LOG_OUTPUT_DIR_PATH="${LOG_OUTPUT_DIR}/exile_test_${GIT_ID}_${TIMESTAMP}"
|
2021-06-06 09:27:45 +02:00
|
|
|
[ -d "$LOG_OUTPUT_DIR_PATH" ] || mkdir -p "$LOG_OUTPUT_DIR_PATH"
|
|
|
|
|
2021-06-05 14:07:11 +02:00
|
|
|
for test in $( ./test --dumptests ) ; do
|
2021-09-05 16:48:27 +02:00
|
|
|
testname=$( echo $test )
|
|
|
|
runtest "$testname" "${LOG_OUTPUT_DIR_PATH}/log.${testname}"
|
2021-06-05 14:07:11 +02:00
|
|
|
done
|
2021-06-06 09:02:30 +02:00
|
|
|
echo
|
2021-06-06 09:27:45 +02:00
|
|
|
echo "Tests finished. Logs in $(realpath ${LOG_OUTPUT_DIR_PATH})"
|
2021-06-06 09:02:30 +02:00
|
|
|
echo "Succeeded: $COUNT_SUCCEEDED"
|
|
|
|
echo "Failed: $COUNT_FAILED"
|
2021-11-20 17:03:04 +01:00
|
|
|
echo "Skipped: $COUNT_SKIPPED"
|
2021-06-06 09:27:45 +02:00
|
|
|
|
2021-06-06 09:02:30 +02:00
|
|
|
if [ $COUNT_FAILED -gt 0 ] ; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
exit 0
|