Commit | Line | Data |
---|---|---|
706f6a7e MM |
1 | #!/bin/bash |
2 | ||
3 | bad= | |
4 | ||
7fda25bd MM |
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. | |
d8a8a836 MM |
9 | if [ "$NO_VALGRIND" ]; then |
10 | cmd=(./testsuite) | |
11 | else | |
12 | cmd=(valgrind --error-exitcode=1 --leak-check=full ./testsuite) | |
13 | fi | |
14 | ||
706f6a7e | 15 | set -o pipefail |
d8a8a836 MM |
16 | # Stdout goes directly to testsuite.out; stderr goes down the pipe. |
17 | if ! "${cmd[@]}" 2>&1 >testsuite.out | tee testsuite.err; then | |
706f6a7e MM |
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 | |
e39c0ed2 | 36 | echo 'Test suite passed.' |
706f6a7e | 37 | fi |