test.sh (756B)
1 #!/bin/sh 2 3 re="${TEST:-$@}" 4 5 TESTBIN="test/run" 6 TESTOUT="test/last.out" 7 TESTERR="test/last.err" 8 CUBEOBJ="debugcube.o" 9 10 for t in test/*; do 11 if [ -n "$re" ] && [ -z "$(echo "$t" | grep "$re")" ]; then 12 continue 13 fi 14 15 # Verify if $t is a directory and if its name starts with three digits 16 if [ -d "$t" ] && echo "$(basename "$t")" | grep -Eq '^[0-9]{3}'; then 17 $CC -o $TESTBIN $t/*.c $CUBEOBJ || exit 1 18 for cin in $t/*.in; do 19 c=$(echo "$cin" | sed 's/\.in//') 20 cout=$c.out 21 printf "$c: " 22 $TESTBIN < "$cin" > $TESTOUT 2> $TESTERR 23 if diff $cout $TESTOUT; then 24 printf "OK\n" 25 else 26 printf "Test failed! stderr:\n" 27 cat $TESTERR 28 exit 1 29 fi 30 done 31 fi 32 done 33 34 echo "All tests passed!" 35 rm -rf $TESTBIN $TESTOUT $TESTERR $CUBEOBJ