1 #!/bin/sh 2 3 trap 'rm $test.valgrind-errors; exit 1' INT QUIT 4 5 total=0 6 pass=0 7 clean=0 8 9 echo "====== Testing for correctness ======" 10 for test in *.c; do 11 echo -n "Testing $test..." 12 ../glcpp < $test > $test.out 2>&1 13 total=$((total+1)) 14 if cmp $test.expected $test.out >/dev/null 2>&1; then 15 echo "PASS" 16 pass=$((pass+1)) 17 else 18 echo "FAIL" 19 diff -u $test.expected $test.out 20 fi 21 done 22 23 echo "" 24 echo "$pass/$total tests returned correct results" 25 echo "" 26 27 echo "====== Testing for valgrind cleanliness ======" 28 for test in *.c; do 29 echo -n "Testing $test with valgrind..." 30 valgrind --error-exitcode=31 --log-file=$test.valgrind-errors ../glcpp < $test >/dev/null 2>&1 31 if [ "$?" = "31" ]; then 32 echo "ERRORS" 33 cat $test.valgrind-errors 34 else 35 echo "CLEAN" 36 clean=$((clean+1)) 37 rm $test.valgrind-errors 38 fi 39 done 40 41 echo "" 42 echo "$pass/$total tests returned correct results" 43 echo "$clean/$total tests are valgrind-clean" 44 45 if [ "$pass" = "$total" ] && [ "$clean" = "$total" ]; then 46 exit 0 47 else 48 exit 1 49 fi 50 51