diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-04-12 20:22:01 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-04-12 20:22:01 +0200 |
| commit | 72e018b066bd5cc3ce0181b43865a227e8b9b6ec (patch) | |
| tree | 60b2e8dbe7fd2dd7cf58ecd1606e03146329b516 /test/test.sh | |
| download | cubecore-72e018b066bd5cc3ce0181b43865a227e8b9b6ec.tar.gz cubecore-72e018b066bd5cc3ce0181b43865a227e8b9b6ec.zip | |
Initial fork from H48
Diffstat (limited to 'test/test.sh')
| -rwxr-xr-x | test/test.sh | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/test.sh b/test/test.sh new file mode 100755 index 0000000..77bd8ca --- /dev/null +++ b/test/test.sh | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | detectsan() { cc -fsanitize=$1 -dM -E -x c - </dev/null | grep "SANITIZE"; } | ||
| 4 | |||
| 5 | re="${TEST:-$@}" | ||
| 6 | |||
| 7 | CC="cc -DDEBUG -std=c99 -pedantic -Wall -Wextra -g3" | ||
| 8 | |||
| 9 | [ -n "$(detectsan address)" ] && CC="$CC -fsanitize=address" | ||
| 10 | [ -n "$(detectsan undefined)" ] && CC="$CC -fsanitize=undefined" | ||
| 11 | |||
| 12 | TESTBIN="test/run" | ||
| 13 | TESTOUT="test/last.out" | ||
| 14 | TESTERR="test/last.err" | ||
| 15 | CUBEOBJ="debugcube.o" | ||
| 16 | |||
| 17 | for t in test/*; do | ||
| 18 | if [ -n "$re" ] && [ -z "$(echo "$t" | grep "$re")" ]; then | ||
| 19 | continue | ||
| 20 | fi | ||
| 21 | if [ ! -d $t ]; then continue; fi | ||
| 22 | $CC -o $TESTBIN $t/*.c $CUBEOBJ || exit 1; | ||
| 23 | for cin in $t/*.in; do | ||
| 24 | c=$(echo "$cin" | sed 's/\.in//') | ||
| 25 | cout=$c.out | ||
| 26 | printf "$c: " | ||
| 27 | $TESTBIN < "$cin" > $TESTOUT 2> $TESTERR | ||
| 28 | if diff $cout $TESTOUT; then | ||
| 29 | printf "OK\n" | ||
| 30 | else | ||
| 31 | printf "Test failed! stderr:\n" | ||
| 32 | cat $TESTERR | ||
| 33 | exit 1 | ||
| 34 | fi | ||
| 35 | done | ||
| 36 | done | ||
| 37 | |||
| 38 | echo "All tests passed!" | ||
| 39 | rm -rf $TESTBIN $TESTOUT $TESTERR $CUBEOBJ | ||
