| OLD | NEW |
| (Empty) |
| 1 #!/bin/bash | |
| 2 | |
| 3 bad= | |
| 4 | |
| 5 # If you encounter the following problem with Valgrind like I did: | |
| 6 # https://bugzilla.redhat.com/show_bug.cgi?id=455644 | |
| 7 # you can pass the environment variable NO_VALGRIND=1 to run the testsuite | |
| 8 # without it. | |
| 9 if [ "$NO_VALGRIND" ]; then | |
| 10 cmd=(./testsuite) | |
| 11 else | |
| 12 cmd=(valgrind --error-exitcode=1 --leak-check=full ./testsuite) | |
| 13 fi | |
| 14 | |
| 15 set -o pipefail | |
| 16 # Stdout goes directly to testsuite.out; stderr goes down the pipe. | |
| 17 if ! "${cmd[@]}" 2>&1 >testsuite.out | tee testsuite.err; then | |
| 18 echo >&2 'Memory errors!' | |
| 19 bad=1 | |
| 20 fi | |
| 21 | |
| 22 if grep 'LEAK SUMMARY' testsuite.err >/dev/null; then | |
| 23 echo >&2 'Memory leaks!' | |
| 24 bad=1 | |
| 25 fi | |
| 26 | |
| 27 if ! diff -u testsuite.expected testsuite.out; then | |
| 28 echo >&2 'Output is incorrect!' | |
| 29 bad=1 | |
| 30 fi | |
| 31 | |
| 32 if [ $bad ]; then | |
| 33 echo >&2 'Test suite failed!' | |
| 34 exit 1 | |
| 35 else | |
| 36 echo 'Test suite passed.' | |
| 37 fi | |
| OLD | NEW |