diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2023-05-29 01:06:09 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2023-05-29 01:06:09 +0200 |
| commit | f987f5af492f2ac9d5aeebd351bcb49175556af2 (patch) | |
| tree | e4a6a242996f83c2110dcf46dc2b7a3f271f2b44 /test/test.sh | |
| download | nissy-core-f987f5af492f2ac9d5aeebd351bcb49175556af2.tar.gz nissy-core-f987f5af492f2ac9d5aeebd351bcb49175556af2.zip | |
Initial commit
Diffstat (limited to 'test/test.sh')
| -rwxr-xr-x | test/test.sh | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/test.sh b/test/test.sh new file mode 100755 index 0000000..d59270b --- /dev/null +++ b/test/test.sh | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | CC="cc -DDEBUG -std=c99 -pthread -pedantic -Wall -Wextra \ | ||
| 4 | -Wno-unused-parameter -Wno-unused-function -g3" | ||
| 5 | if [ $(uname) != "OpenBSD" ]; then | ||
| 6 | CC="$CC -fsanitize=address -fsanitize=undefined" | ||
| 7 | fi | ||
| 8 | SRC="src/cube.c" | ||
| 9 | TESTBIN="test/run" | ||
| 10 | TESTOUT="test/last.out" | ||
| 11 | TESTERR="test/last.err" | ||
| 12 | |||
| 13 | for t in test/*; do | ||
| 14 | if [ ! -d $t ]; then continue; fi | ||
| 15 | $CC -o $TESTBIN $t/*.c $SRC || exit 1; | ||
| 16 | for cin in $t/*.in; do | ||
| 17 | c=$(echo "$cin" | sed 's/\.in//') | ||
| 18 | cout=$c.out | ||
| 19 | printf "$c: " | ||
| 20 | $TESTBIN < "$cin" > $TESTOUT 2> $TESTERR | ||
| 21 | if diff $cout $TESTOUT; then | ||
| 22 | printf "OK\n" | ||
| 23 | else | ||
| 24 | printf "Test failed! stderr:\n" | ||
| 25 | cat $TESTERR | ||
| 26 | exit 1 | ||
| 27 | fi | ||
| 28 | done | ||
| 29 | done | ||
| 30 | |||
| 31 | echo "All tests passed!" | ||
| 32 | rm -rf $TESTBIN $TESTOUT $TESTERR | ||
