diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2022-06-09 21:48:32 +0200 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2022-06-09 21:48:32 +0200 |
| commit | c2e6aad09f893e4c8cb5cb9243c32a0d6d0d1e12 (patch) | |
| tree | bebdb575f200c7ea75f3115a81deecd5b797c4ff /tests/run.sh | |
Init ESDS repository
Diffstat (limited to 'tests/run.sh')
| -rwxr-xr-x | tests/run.sh | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/run.sh b/tests/run.sh new file mode 100755 index 0000000..8720736 --- /dev/null +++ b/tests/run.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[0;33m' +BOLD='\033[1m' +NC='\033[0m' # No Color + +wai=$(dirname $(readlink -f "$0")) # Current script directory +tests=$(find ${wai}/ -maxdepth 1 -mindepth 1 -type d) # Find tests +out=$(mktemp) +test_timeout=20 + +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 + echo -e "${RED}${BOLD}failed${NC}" + echo "------------- Test timeout (should not exceed ${test_timeout}s) -------------" + cat "$out"; + rm "$out" + exit 2 + fi + + # Ensure test output + if $(diff "$out" ./out &>/dev/null) + then + echo -e "${GREEN}${BOLD}passed${NC}" + else + echo -e "${RED}${BOLD}failed${NC}" + echo "------------- Expected -------------" + cat out + echo "------------- Got -------------" + cat "$out"; + rm "$out" + exit 1 + fi + + # Prepare for next test + cd - &>/dev/null +done + +rm "$out" |
