summaryrefslogtreecommitdiff
path: root/qpid/cpp/src/tests/test_env
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2007-04-02 20:27:21 +0000
committerAlan Conway <aconway@apache.org>2007-04-02 20:27:21 +0000
commitc7de0c94a03478ca5ef7dc6085407bd464ad2214 (patch)
treecb79ed61f7fd83aabba4322864bb83ccc16b616e /qpid/cpp/src/tests/test_env
parentfea1cde4749b111bf14bf503fa945a994b469808 (diff)
downloadqpid-python-c7de0c94a03478ca5ef7dc6085407bd464ad2214.tar.gz
* src/tests/examples.README,examples.Makefile: out of date, removed.
* src/tests/README: details on running tests. * cpp/README: Point to src/tests/README * src/tests/ .valgrind.supp, .valgrindrc-default: moved valgrind options to file, easier to modify locally updated suppressions (see README) * src/tests/test_env, run-unit-tests: more flexible test running (see README) git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@524913 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/tests/test_env')
-rw-r--r--qpid/cpp/src/tests/test_env43
1 files changed, 43 insertions, 0 deletions
diff --git a/qpid/cpp/src/tests/test_env b/qpid/cpp/src/tests/test_env
new file mode 100644
index 0000000000..fdfc5f0369
--- /dev/null
+++ b/qpid/cpp/src/tests/test_env
@@ -0,0 +1,43 @@
+#!/bin/sh
+#
+# Run a test under valgrind.
+#
+
+# Use VALGRIND if set, else look on path.
+test -z "$VALGRIND" && VALGRIND=`which valgrind 2>/dev/null`
+# No valgrind, just run the command
+test -z "$VALGRIND" && exec libtool --mode=execute "$@"
+
+test "$VERBOSE" = yes && set -x
+test -z "$vg_log" && vg_log=valgrind.out
+rm -f $vg_log
+
+# Dump log file, print a message and exit non-0.
+vg_failed() {
+ cat $vg_log 1>&2
+ echo $1 1>&2
+ exit 1
+}
+
+# Check for errors in valgrind output.
+vg_check()
+{
+ # Ensure there is an ERROR SUMMARY line.
+ grep -E '^==[0-9]+== ERROR SUMMARY:' $vg_log > /dev/null || \
+ vg_failed "No valgrind ERROR SUMMARY line in $$vg_failed."
+ # Ensure that the number of errors is 0.
+ grep -E '^==[0-9]+== ERROR SUMMARY: [^0] ' $vg_log > /dev/null && \
+ vg_failed "Valgrind reported errors in $vg_out; see above."
+ # Check for leaks.
+ grep -E '^==[0-9]+== +.* lost: [^0]' $vg_log && \
+ vg_failed "Found memory leaks (see log file, $vg_log); see above."
+ true
+}
+
+# libdlclose_noop prevents unloading symbols needed for valgrind output.
+preload=.libs/libdlclose_noop.so
+# Output to file, only display if there is an error.
+opts=--log-file-exactly=$vg_log
+
+LD_PRELOAD=$preload libtool --mode=execute $VALGRIND $opts -- "$@" || fail=1
+vg_check && test -z "$fail"