From d7965d19e72e6ba63fa807b2ea27adaedc9da109 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 21 Mar 2011 21:22:54 -0700 Subject: [PATCH] Add valgrind support to testsuite. --- tests/automake.mk | 27 ++++++++++++++++++++++++++- tests/valgrind-wrapper.in | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100755 tests/valgrind-wrapper.in diff --git a/tests/automake.mk b/tests/automake.mk index 484ef0e1..a6d8de3a 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -384,6 +384,7 @@ TESTSUITE_AT = \ TESTSUITE = $(srcdir)/tests/testsuite DISTCLEANFILES += tests/atconfig tests/atlocal $(TESTSUITE) +AUTOTEST_PATH = tests/data:tests/language/lexer:tests/libpspp:tests/output:src/ui/terminal $(srcdir)/tests/testsuite.at: tests/testsuite.in tests/automake.mk cp $< $@ @@ -394,7 +395,7 @@ EXTRA_DIST += tests/testsuite.at CHECK_LOCAL += tests_check tests_check: tests/atconfig tests/atlocal $(TESTSUITE) $(check_PROGRAMS) - $(SHELL) '$(TESTSUITE)' -C tests AUTOTEST_PATH=tests/data:tests/language/lexer:tests/libpspp:tests/output:src/ui/terminal $(TESTSUITEFLAGS) + $(SHELL) '$(TESTSUITE)' -C tests AUTOTEST_PATH=$(AUTOTEST_PATH) $(TESTSUITEFLAGS) CLEAN_LOCAL += tests_clean tests_clean: @@ -417,3 +418,27 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac echo 'm4_define([AT_PACKAGE_BUGREPORT], [$(PACKAGE_BUGREPORT)])' && \ echo 'm4_define([AT_PACKAGE_URL], [$(PACKAGE_URL)])'; \ } >'$(srcdir)/package.m4' + +# valgrind support for Autotest testsuite + +valgrind_wrappers = \ + tests/valgrind/pspp \ + tests/valgrind/render-test + +$(valgrind_wrappers): tests/valgrind-wrapper.in + @test -d tests/valgrind || mkdir tests/valgrind + sed -e 's,[@]wrap_program[@],$@,' \ + $(top_srcdir)/tests/valgrind-wrapper.in > $@.tmp + chmod +x $@.tmp + mv $@.tmp $@ +CLEANFILES += $(valgrind_wrappers) +EXTRA_DIST += tests/valgrind-wrapper.in + +VALGRIND = $(SHELL) $(abs_top_builddir)/libtool --mode=execute valgrind --log-file=valgrind.%p --leak-check=full --num-callers=20 +check-valgrind: all tests/atconfig tests/atlocal $(TESTSUITE) $(valgrind_wrappers) + $(SHELL) '$(TESTSUITE)' -C tests VALGRIND='$(VALGRIND)' AUTOTEST_PATH='tests/valgrind:$(AUTOTEST_PATH)' -d $(TESTSUITEFLAGS) + @echo + @echo '--------------------------------' + @echo 'Valgrind output is in:' + @echo 'tests/testsuite.dir/*/valgrind.*' + @echo '--------------------------------' diff --git a/tests/valgrind-wrapper.in b/tests/valgrind-wrapper.in new file mode 100755 index 00000000..a60cd9e0 --- /dev/null +++ b/tests/valgrind-wrapper.in @@ -0,0 +1,38 @@ +#! /bin/sh + +program=`basename "$0"` + +new_PATH= +save_IFS=$IFS +IFS=: +found=no +for dir in $PATH; do + IFS=$save_IFS + if test "X$dir" = X; then + dir=. + fi + if test -x "$dir/$program"; then + if test $found = no; then + found=yes + continue + else + if test "X$next_program" = X; then + next_program=$dir/$program + fi + fi + fi +done +IFS=$save_IFS + +if test $found = no; then + echo "$0: $program not found in PATH ($PATH)" >&2 + exit 1 +elif test "X$next_program" = X; then + echo "$0: $program found only once in PATH ($PATH)" >&2 + exit 1 +fi + +: ${VALGRIND:=libtool --mode=execute valgrind --log-file=valgrind.%p --leak-check=full --num-callers=20} +exec $VALGRIND $next_program "$@" +echo "$0: $VALGRIND $wrap_program $* failed" >&2 +exit 1 -- 2.30.2