NULL =

TEST_SUPPRESSIONS = $(top_builddir)/build/valgrind-suppressions

perform-memcheck: $(TEST_PROGS) $(TEST_SUPPRESSIONS)
	@make -C $(top_builddir)/build all
	@for test in $(TEST_PROGS); do \
		G_SLICE=always-malloc libtool --mode=execute \
			valgrind --trace-children=no --gen-suppressions=all \
			--suppressions=$(TEST_SUPPRESSIONS) \
			--leak-check=full --show-reachable=yes --num-callers=16 \
			--quiet --error-exitcode=33 \
			$(builddir)/$$test; \
	done

if WITH_COVERAGE
coverage:
	mkdir -p $(top_builddir)/build/coverage
	$(LCOV) --directory . --capture --output-file $(top_builddir)/build/coverage.info
	$(GENHTML) --output-directory $(top_builddir)/build/coverage $(top_builddir)/build/coverage.info
	$(LCOV) --directory . --zerocounters
	@echo "file://$(abs_top_builddir)/build/coverage/index.html"

clear-coverage:
	$(LCOV) --directory . --zerocounters

endif
	