diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2022-09-01 18:06:20 +0200 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2022-09-01 18:06:20 +0200 |
| commit | 2ca2717d26843efa1d70507cff18494661b69049 (patch) | |
| tree | 501d08e38449c74c08f4472fa9b507e627e21080 | |
| parent | 2eafcaabbdc673576cbba8b5ab9080a2ce6d4b1e (diff) | |
Add run.sh
| -rwxr-xr-x | tests/run.sh | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/run.sh b/tests/run.sh new file mode 100755 index 0000000..c92187c --- /dev/null +++ b/tests/run.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +pythonexec="/usr/bin/env python" # You can change this variable according to your system +wai=$(dirname $(readlink -f "$0")) # Current script directory +tests=$(ls -d ${wai}/*/) # Find tests +out=$(mktemp) +test_timeout=20 +abort=1 + +for test in ${tests} +do + printf "%-50s%s %s" "- $(basename $test)" "=>" + cd $test + timeout $test_timeout ${pythonexec} simulator.py &> "$out" + + # Ensure timeout + if [ $? -eq 124 ] + then + echo "failed :(" + echo "------------- Test timeout (should not exceed ${test_timeout}s) -------------" + cat "$out"; + rm "$out" + exit 2 + fi + + # Ensure test output + if [ "$(base64 $out)" = "$(base64 ./out)" ] + then + echo "passed" + else + echo "failed :(" + echo "------------- Expected -------------" + cat out + echo "------------- Got -------------" + cat "$out"; + rm "$out" + [ $abort -eq 1 ] && exit 1 + fi + + # Prepare for next test + cd - &>/dev/null +done + +rm "$out" |
