aboutsummaryrefslogtreecommitdiff
path: root/test/test.sh
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-04-12 20:22:01 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-04-12 20:22:01 +0200
commit72e018b066bd5cc3ce0181b43865a227e8b9b6ec (patch)
tree60b2e8dbe7fd2dd7cf58ecd1606e03146329b516 /test/test.sh
downloadcubecore-72e018b066bd5cc3ce0181b43865a227e8b9b6ec.tar.gz
cubecore-72e018b066bd5cc3ce0181b43865a227e8b9b6ec.zip
Initial fork from H48
Diffstat (limited to 'test/test.sh')
-rwxr-xr-xtest/test.sh39
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
3detectsan() { cc -fsanitize=$1 -dM -E -x c - </dev/null | grep "SANITIZE"; }
4
5re="${TEST:-$@}"
6
7CC="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
12TESTBIN="test/run"
13TESTOUT="test/last.out"
14TESTERR="test/last.err"
15CUBEOBJ="debugcube.o"
16
17for 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
36done
37
38echo "All tests passed!"
39rm -rf $TESTBIN $TESTOUT $TESTERR $CUBEOBJ

Generated with cgit - Back to sebastiano.tronto.net