dotest.sh (762B)
1 #!/bin/sh 2 3 # Exit, with error message (hard failure) 4 exit_fail() { 5 echo " FAIL: " "$@" >&2 6 exit 1 7 } 8 9 if ! valgrind --version > /dev/null 2>&1 10 then 11 [ "$VALGRIND" = 1 ] && exit_fail "no valgrind" 12 NOVALGRIND=1 13 fi 14 mustach="${mustach:-../mustach}" 15 echo "starting test" 16 if [ "$NOVALGRIND" = 1 ] 17 then 18 $mustach "$@" > resu.last || exit_fail "ERROR! mustach command failed ($?)!" 19 else 20 valgrind $mustach "$@" > resu.last 2> vg.last || exit_fail "ERROR! valgrind + mustach command failed ($?)!" 21 sed -i 's:^==[0-9]*== ::' vg.last 22 awk '/^ *total heap usage: .* allocs, .* frees,.*/{if($$4-$$6)exit(1)}' vg.last || exit_fail "ERROR! Alloc/Free issue" 23 fi 24 if diff -w resu.ref resu.last 25 then 26 echo "result ok" 27 else 28 exit_fail "ERROR! Result differs" 29 fi 30 echo 31 exit 0