esds/tests/run.sh

44 lines
930 B
Bash
Raw Normal View History

2022-06-09 21:48:32 +02:00
#!/usr/bin/env bash
wai=$(dirname $(readlink -f "$0")) # Current script directory
2022-08-31 18:15:17 +02:00
tests=$(ls -d ${wai}/*/) # Find tests
2022-06-09 21:48:32 +02:00
out=$(mktemp)
test_timeout=20
2022-06-29 11:19:36 +02:00
abort=1
2022-06-09 21:48:32 +02:00
for test in ${tests}
do
printf "%-50s%s %s" "- $(basename $test)" "=>"
cd $test
timeout $test_timeout ./simulator.py &> "$out"
# Ensure timeout
if [ $? -eq 124 ]
then
2022-09-01 08:12:18 +02:00
echo "failed :("
2022-06-09 21:48:32 +02:00
echo "------------- Test timeout (should not exceed ${test_timeout}s) -------------"
cat "$out";
rm "$out"
exit 2
fi
# Ensure test output
2022-08-31 20:01:50 +02:00
if [ "$(base64 $out)" = "$(base64 ./out)" ]
2022-06-09 21:48:32 +02:00
then
2022-09-01 08:12:18 +02:00
echo "passed"
2022-06-09 21:48:32 +02:00
else
2022-09-01 08:12:18 +02:00
echo "failed :("
2022-06-09 21:48:32 +02:00
echo "------------- Expected -------------"
cat out
echo "------------- Got -------------"
cat "$out";
rm "$out"
2022-06-29 11:19:36 +02:00
[ $abort -eq 1 ] && exit 1
2022-06-09 21:48:32 +02:00
fi
# Prepare for next test
cd - &>/dev/null
done
rm "$out"