Add a note about the purpose of NO_VALGRIND to run-testsuite.
[bigint/bigint.git] / run-testsuite
CommitLineData
706f6a7e
MM
1#!/bin/bash
2
3bad=
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
9if [ "$NO_VALGRIND" ]; then
10 cmd=(./testsuite)
11else
12 cmd=(valgrind --error-exitcode=1 --leak-check=full ./testsuite)
13fi
14
706f6a7e 15set -o pipefail
d8a8a836
MM
16# Stdout goes directly to testsuite.out; stderr goes down the pipe.
17if ! "${cmd[@]}" 2>&1 >testsuite.out | tee testsuite.err; then
706f6a7e
MM
18 echo >&2 'Memory errors!'
19 bad=1
20fi
21
22if grep 'LEAK SUMMARY' testsuite.err >/dev/null; then
23 echo >&2 'Memory leaks!'
24 bad=1
25fi
26
27if ! diff -u testsuite.expected testsuite.out; then
28 echo >&2 'Output is incorrect!'
29 bad=1
30fi
31
32if [ $bad ]; then
33 echo >&2 'Test suite failed!'
34 exit 1
35else
e39c0ed2 36 echo 'Test suite passed.'
706f6a7e 37fi