summaryrefslogtreecommitdiff
path: root/tests/valgrind-wrapper.in
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2010-02-01 14:26:07 -0800
committerBen Pfaff <blp@nicira.com>2010-02-02 15:21:09 -0800
commitb6fa444705e2c954798b569da11bb2ac2340e3d9 (patch)
tree58a9da7f73d0081b0d26b43b7b39f6d6b7b00549 /tests/valgrind-wrapper.in
parent28447a186b017471dc00ed41ab832dc566d7bebd (diff)
downloadopenvswitch-b6fa444705e2c954798b569da11bb2ac2340e3d9.tar.gz
Add support for running the testsuite under 'valgrind'.
Diffstat (limited to 'tests/valgrind-wrapper.in')
-rwxr-xr-xtests/valgrind-wrapper.in36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/valgrind-wrapper.in b/tests/valgrind-wrapper.in
new file mode 100755
index 000000000..ed9a053d3
--- /dev/null
+++ b/tests/valgrind-wrapper.in
@@ -0,0 +1,36 @@
+#! /bin/sh
+
+wrap_program=`basename '@wrap_program@'`
+
+# Strip the first directory from $PATH that contains $wrap_program,
+# so that below we run the real $wrap_program, not ourselves.
+not_found=true
+new_path=
+first=true
+save_IFS=$IFS
+IFS=:
+for dir in $PATH; do
+ IFS=$save_IFS
+ if $not_found && test -x "$dir/$wrap_program"; then
+ not_found=false
+ else
+ if $first; then
+ first=false
+ new_path=$dir
+ else
+ new_path=$new_path:$dir
+ fi
+ fi
+done
+IFS=$save_IFS
+if $not_found; then
+ echo "$0: error: cannot find $wrap_program in \$PATH" >&2
+ exit 1
+fi
+PATH=$new_path
+export PATH
+
+: ${VALGRIND:=valgrind -q --log-file=valgrind.%p --leak-check=full}
+exec $VALGRIND $wrap_program "$@"
+echo "$0: failed to execute $VALGRIND $wrap_program" "$@" >&2
+exit 1