ladanyi@793: #!/bin/sh
ladanyi@793: 
ladanyi@793: # Run in valgrind, with leak checking enabled
ladanyi@793: 
ladanyi@793: valgrind -q --leak-check=full "$@" 2> .valgrind-log
ladanyi@793: 
ladanyi@793: # Save the test result
ladanyi@793: 
ladanyi@793: result="$?"
ladanyi@793: 
ladanyi@793: # Valgrind should generate no error messages
ladanyi@793: 
ladanyi@793: log_contents="`cat .valgrind-log`"
ladanyi@793: 
ladanyi@793: if [ "$log_contents" != "" ]; then
ladanyi@793:         cat .valgrind-log >&2
ladanyi@793:         result=1
ladanyi@793: fi
ladanyi@793: 
ladanyi@793: rm -f .valgrind-log
ladanyi@793: 
ladanyi@793: exit $result