runtests.sh (667B)
1 #!/bin/sh 2 3 file=${1?' empty input file'} 4 5 trap 'rm -f *.o $tmp1 $tmp2' EXIT 6 trap 'exit $?' INT QUIT TERM 7 8 rm -f test.log 9 10 tmp1=tmp1.$$ 11 tmp2=tmp2.$$ 12 13 while read i state 14 do 15 rm -f *.o $i $tmp1 $tmp2 16 17 (echo $i 18 $CC $CFLAGS $LDFLAGS -o $i $i.c 19 echo '/^output:$/+;/^end:$/-'w $tmp1 | ed -s $i.c 20 21 $EXEC ./$i >$tmp2 2>&1 & 22 pid=$! 23 sleep 10 && echo timeout >> $tmp2 && kill $pid 2>/dev/null& 24 timer=$! 25 wait $pid 26 kill $timer 27 wait $timer 28 29 if grep '^RESULT: SKIP$' $tmp2 30 then 31 printf '\tSKIP\t%s\n' $i $state 32 continue 33 fi 34 diff -u $tmp1 $tmp2) >> test.log 2>&1 && 35 36 printf '[PASS]' || printf '[FAIL]' 37 printf '\t%s\t%s\n' $i $state 38 done < $file