1
0
Fork 0
mirror of https://github.com/albfan/miraclecast.git synced 2025-03-09 23:38:56 +00:00

test: add valgrind memory checks

Copy over the "make memcheck" target from libshl. It runs the test-suite
again via valgrind and fails on any valgrind warnings. This is very useful
to find memory-leaks and invalid memory-accesses via the test-suite.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
This commit is contained in:
David Herrmann 2014-03-28 12:48:10 +01:00
parent 729acb64ca
commit 9cb0a092c2
4 changed files with 92 additions and 2 deletions

View file

@ -27,6 +27,7 @@ pkgconfig_DATA =
TPHONY =
TESTS =
MEMTESTS =
bin_PROGRAMS =
check_PROGRAMS =
lib_LTLIBRARIES =
@ -180,8 +181,9 @@ tests = \
test_wpas
if BUILD_HAVE_CHECK
check_PROGRAMS += $(tests)
TESTS += $(tests)
check_PROGRAMS += $(tests) test_valgrind
TESTS += $(tests) test_valgrind
MEMTESTS += $(tests)
endif
test_sources = \
@ -197,11 +199,40 @@ test_cflags = \
test_lflags = \
$(AM_LDFLAGS)
test_rtsp_SOURCES = test/test_rtsp.c $(test_sources)
test_rtsp_CPPFLAGS = $(test_cflags)
test_rtsp_LDADD = $(test_libs)
test_rtsp_LDFLAGS = $(test_lflags)
test_valgrind_SOURCES = test/test_valgrind.c $(test_sources)
test_valgrind_CPPFLAGS = $(test_cflags)
test_valgrind_LDADD = $(test_libs)
test_valgrind_LDFLAGS = $(test_lflags)
test_wpas_SOURCES = test/test_wpas.c $(test_sources)
test_wpas_CPPFLAGS = $(test_cflags)
test_wpas_LDADD = $(test_libs)
test_wpas_LDFLAGS = $(test_lflags)
VALGRIND = CK_FORK=no valgrind --tool=memcheck --leak-check=yes --show-reachable=yes --leak-resolution=high --error-exitcode=1 --suppressions=$(top_builddir)/test.supp
# verify that test_valgrind actually leaks data
memcheck-verify: check
$(AM_V_GEN)$(VALGRIND) --log-file=/dev/null ./test_valgrind >/dev/null ; test 1 = $$?
TPHONY += memcheck-verify
# run memcheck tests via valgrind
memcheck: memcheck-verify
$(AM_V_GEN)for i in $(MEMTESTS) ; do \
$(VALGRIND) --log-file=$(top_builddir)/$$i.memlog \
$(top_builddir)/$$i >/dev/null || (echo "memcheck failed on: $$i" ; exit 1) ; \
done
TPHONY += memcheck
distcheck-hook: memcheck
#
# Phony targets
#