From: Ben Pfaff Date: Mon, 1 Feb 2010 22:26:07 +0000 (-0800) Subject: Add support for running the testsuite under 'valgrind'. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b6fa444705e2c954798b569da11bb2ac2340e3d9;p=openvswitch Add support for running the testsuite under 'valgrind'. --- diff --git a/tests/automake.mk b/tests/automake.mk index 4a48496b..502e8dbd 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -95,6 +95,54 @@ check-lcov: all tests/atconfig tests/atlocal $(TESTSUITE) $(lcov_wrappers) cd tests && genhtml -q -o coverage.html coverage.info; \ exit $$rc +# valgrind support + +valgrind_wrappers = \ + tests/valgrind/ovs-appctl \ + tests/valgrind/ovs-vsctl \ + tests/valgrind/ovsdb-client \ + tests/valgrind/ovsdb-server \ + tests/valgrind/ovsdb-tool \ + tests/valgrind/test-aes128 \ + tests/valgrind/test-classifier \ + tests/valgrind/test-csum \ + tests/valgrind/test-dhcp-client \ + tests/valgrind/test-dir_name \ + tests/valgrind/test-flows \ + tests/valgrind/test-hash \ + tests/valgrind/test-hmap \ + tests/valgrind/test-json \ + tests/valgrind/test-jsonrpc \ + tests/valgrind/test-list \ + tests/valgrind/test-lockfile \ + tests/valgrind/test-ovsdb \ + tests/valgrind/test-reconnect \ + tests/valgrind/test-sha1 \ + tests/valgrind/test-stp \ + tests/valgrind/test-timeval \ + tests/valgrind/test-type-props \ + tests/valgrind/test-uuid \ + tests/valgrind/test-vconn + +$(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 = valgrind --log-file=valgrind.%p --leak-check=full \ + --suppressions=$(abs_top_srcdir)/tests/openssl.supp --num-callers=20 +EXTRA_DIST += tests/openssl.supp +check-valgrind: all tests/atconfig tests/atlocal $(TESTSUITE) $(valgrind_wrappers) + $(SHELL) '$(TESTSUITE)' -C tests CHECK_VALGRIND=true VALGRIND='$(VALGRIND)' AUTOTEST_PATH='tests/valgrind:$(AUTOTEST_PATH)' -d $(TESTSUITEFLAGS) + @echo + @echo '----------------------------------------------------------------------' + @echo 'Valgrind output can be found in tests/testsuite.dir/*/valgrind.*' + @echo '----------------------------------------------------------------------' + clean-local: test ! -f '$(TESTSUITE)' || $(SHELL) '$(TESTSUITE)' -C tests --clean diff --git a/tests/openssl.supp b/tests/openssl.supp new file mode 100644 index 00000000..eb461f81 --- /dev/null +++ b/tests/openssl.supp @@ -0,0 +1,13 @@ +# suppress OpenSSL errors from valgrind + +{ + BN_mod_inverse + Memcheck:Cond + fun:BN_mod_inverse +} + +{ + BN_div + Memcheck:Cond + fun:BN_div +} diff --git a/tests/valgrind-wrapper.in b/tests/valgrind-wrapper.in new file mode 100755 index 00000000..ed9a053d --- /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