From 9cf89e4b43e5e018bb3103be1873a3993769ce4a Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Wed, 20 Mar 2013 20:58:49 +0100 Subject: Add a bit of infrastructure for running valgrind * make memcheck: Runs basic memory checking * make leakcheck: Also runs leak checking --- Makefile.am | 2 ++ build/Makefile.am | 4 ++++ build/Makefile.decl | 11 +++++++++++ build/Makefile.tests | 11 +++++++++++ common/Makefile.am | 3 ++- common/tests/Makefile.am | 2 -- doc/Makefile.am | 4 ++++ doc/manual/p11-kit-devel.xml | 4 ++++ p11-kit/Makefile.am | 3 ++- tools/Makefile.am | 3 ++- tools/tests/Makefile.am | 4 ++-- trust/Makefile.am | 3 ++- trust/tests/Makefile.am | 2 -- 13 files changed, 46 insertions(+), 10 deletions(-) create mode 100644 build/Makefile.decl diff --git a/Makefile.am b/Makefile.am index 863bc02..13de2bb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,6 @@ +include $(top_srcdir)/build/Makefile.decl + WEBHOST = anarchy.freedesktop.org WEBBASE = /srv/p11-glue.freedesktop.org/www diff --git a/build/Makefile.am b/build/Makefile.am index de76c58..6f80eab 100644 --- a/build/Makefile.am +++ b/build/Makefile.am @@ -11,3 +11,7 @@ noinst_LTLIBRARIES = \ libcutest_la_SOURCES = \ cutest/CuTest.c \ cutest/CuTest.h + +memcheck: + +leakcheck: diff --git a/build/Makefile.decl b/build/Makefile.decl new file mode 100644 index 0000000..c90c22b --- /dev/null +++ b/build/Makefile.decl @@ -0,0 +1,11 @@ +NULL = + +memcheck: + @for dir in $(SUBDIRS); do \ + test "$$dir" = "." || $(MAKE) -C $$dir memcheck; \ + done + +leakcheck: + @for dir in $(SUBDIRS); do \ + test "$$dir" = "." || $(MAKE) -C $$dir leakcheck; \ + done diff --git a/build/Makefile.tests b/build/Makefile.tests index 9f41045..3faa7f3 100644 --- a/build/Makefile.tests +++ b/build/Makefile.tests @@ -1,3 +1,4 @@ +NULL = CUTEST_CFLAGS = \ -I$(top_srcdir)/build/cutest \ @@ -6,3 +7,13 @@ CUTEST_CFLAGS = \ -DP11_KIT_FUTURE_UNSTABLE_API CUTEST_LIBS = $(top_builddir)/build/libcutest.la + +MEMCHECK_ENV = $(TEST_RUNNER) valgrind --error-exitcode=80 --quiet --trace-children=yes + +LEAKCHECK_ENV = $(TEST_RUNNER) valgrind --error-exitcode=81 --quiet --leak-check=yes + +memcheck: all + make $(AM_MAKEFLAGS) TESTS_ENVIRONMENT="$(MEMCHECK_ENV)" check-TESTS + +leakcheck: all + make $(AM_MAKEFLAGS) TESTS_ENVIRONMENT="$(LEAKCHECK_ENV)" check-TESTS diff --git a/common/Makefile.am b/common/Makefile.am index 14432fc..bfed1d7 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -1,4 +1,5 @@ -NULL = + +include $(top_srcdir)/build/Makefile.decl SUBDIRS = . tests diff --git a/common/tests/Makefile.am b/common/tests/Makefile.am index 70f369c..adc06cb 100644 --- a/common/tests/Makefile.am +++ b/common/tests/Makefile.am @@ -1,8 +1,6 @@ include $(top_srcdir)/build/Makefile.tests -NULL = - COMMON = $(top_srcdir)/common INCLUDES = \ diff --git a/doc/Makefile.am b/doc/Makefile.am index 27b5b47..de840c0 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,2 +1,6 @@ SUBDIRS = manual + +memcheck: + +leakcheck: diff --git a/doc/manual/p11-kit-devel.xml b/doc/manual/p11-kit-devel.xml index 52535d3..12beb5d 100644 --- a/doc/manual/p11-kit-devel.xml +++ b/doc/manual/p11-kit-devel.xml @@ -266,6 +266,10 @@ $ make install the tests. If you run it from a subdirectory only the tests in that directory will be run. + To check for memory errors or memory leaks, run make memcheck + or make leakcheck respectively. This requires valgrind + be installed. + Build p11-kit with the configure option to build code coverage support. diff --git a/p11-kit/Makefile.am b/p11-kit/Makefile.am index 0afa084..1967403 100644 --- a/p11-kit/Makefile.am +++ b/p11-kit/Makefile.am @@ -1,4 +1,5 @@ -NULL = + +include $(top_srcdir)/build/Makefile.decl SUBDIRS = . tests diff --git a/tools/Makefile.am b/tools/Makefile.am index 4977221..aaf7e99 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -1,4 +1,5 @@ -NULL = + +include $(top_srcdir)/build/Makefile.decl SUBDIRS = . tests diff --git a/tools/tests/Makefile.am b/tools/tests/Makefile.am index a74c981..feffcc9 100644 --- a/tools/tests/Makefile.am +++ b/tools/tests/Makefile.am @@ -1,8 +1,6 @@ include $(top_srcdir)/build/Makefile.tests -NULL = - EXTRA_DIST = files if WITH_ASN1 @@ -10,6 +8,8 @@ if WITH_ASN1 COMMON = $(top_srcdir)/common TOOLS = $(top_srcdir)/tools +TEST_RUNNER = libtool --mode=execute + INCLUDES = \ -I$(top_srcdir) \ -I$(top_srcdir)/p11-kit \ diff --git a/trust/Makefile.am b/trust/Makefile.am index 38c6b98..60323a8 100644 --- a/trust/Makefile.am +++ b/trust/Makefile.am @@ -1,4 +1,5 @@ -NULL = + +include $(top_srcdir)/build/Makefile.decl SUBDIRS = . tests diff --git a/trust/tests/Makefile.am b/trust/tests/Makefile.am index 4617546..243b45c 100644 --- a/trust/tests/Makefile.am +++ b/trust/tests/Makefile.am @@ -1,8 +1,6 @@ include $(top_srcdir)/build/Makefile.tests -NULL = - INCLUDES = \ -I$(top_srcdir) \ -I$(srcdir)/.. \ -- cgit v1.1