From c0730036915b6965846e043613939433dd5f7c1e Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 27 Mar 2014 11:04:24 +1000 Subject: [PATCH] test: automatically run the tests against valgrind for leaks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Peter Hutterer Reviewed-by: Jonas Ã…dahl --- Makefile.am | 3 +++ configure.ac | 9 +++++++-- test/Makefile.am | 13 +++++++++++++ test/valgrind.suppressions | 9 +++++++++ 4 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 test/valgrind.suppressions diff --git a/Makefile.am b/Makefile.am index 08bf7ce8..05698ba5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,3 +1,6 @@ SUBDIRS = src doc test tools ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} + +valgrind: + (cd test; $(MAKE) valgrind) diff --git a/configure.ac b/configure.ac index faae1481..4cb08685 100644 --- a/configure.ac +++ b/configure.ac @@ -73,10 +73,15 @@ if test "x$build_tests" = "xauto"; then build_tests="yes" fi fi -if test "x$build_tests" = "xyes" -a "x$HAVE_CHECK" = "xno"; then - AC_MSG_ERROR([Cannot build tests, check is missing]) +if test "x$build_tests" = "xyes"; then + if test "x$HAVE_CHECK" = "xno"; then + AC_MSG_ERROR([Cannot build tests, check is missing]) + fi + + AC_PATH_PROG(VALGRIND, [valgrind]) fi +AM_CONDITIONAL(HAVE_VALGRIND, [test "x$VALGRIND" != "x"]) AM_CONDITIONAL(BUILD_TESTS, [test "x$build_tests" = "xyes"]) AC_CONFIG_FILES([Makefile diff --git a/test/Makefile.am b/test/Makefile.am index 1a628dea..49fe5f0f 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -74,4 +74,17 @@ test_build_linker_LDADD = $(top_builddir)/src/libinput.la test_build_cxx_SOURCES = build-cxx.cc test_build_cxx_CXXFLAGS = -Wall -Wextra -Wno-unused-parameter $(AM_CXXFLAGS) +if HAVE_VALGRIND +VALGRIND_FLAGS=--leak-check=full \ + --quiet \ + --error-exitcode=3 \ + --suppressions=$(srcdir)/valgrind.suppressions + +valgrind: + $(MAKE) check-TESTS LOG_COMPILER="$(VALGRIND)" LOG_FLAGS="$(VALGRIND_FLAGS)" + +check: valgrind + endif +endif +EXTRA_DIST=valgrind.suppressions diff --git a/test/valgrind.suppressions b/test/valgrind.suppressions new file mode 100644 index 00000000..3ba7f292 --- /dev/null +++ b/test/valgrind.suppressions @@ -0,0 +1,9 @@ +{ + srunner_run::timer_create-uninitialized-bytes + Memcheck:Param + timer_create(evp) + fun:timer_create@@GLIBC_2.3.3 + fun:srunner_run + fun:litest_run + fun:main +}