Add --enable-coverage configure option

This configure flag enables lcov [1] coverage generation and is intended
to be used with unit tests (--enable-unit-tests is implied).

A html coverage report can be generated by issuing the following command
in the toplevel build directory:

make coverage

[1] - http://ltp.sourceforge.net/coverage/lcov.php

Based on a patch by Adrian-Ken Rueegsegger.
This commit is contained in:
Tobias Brunner
2013-06-11 11:03:11 +02:00
parent 952073b8a7
commit 1f14b4a1f9
4 changed files with 61 additions and 1 deletions
+28
View File
@@ -37,5 +37,33 @@ Doxyfile : Doxyfile.in
apidoc : Doxyfile
doxygen
if COVERAGE
cov-reset:
@rm -rf $(top_builddir)/coverage
@find $(top_builddir) -name "*.gcda" -delete
@lcov --zerocounters --directory $(top_builddir)
cov-report:
@mkdir $(top_builddir)/coverage
lcov -c -o $(top_builddir)/coverage/coverage.info -d $(top_builddir)
genhtml --num-spaces 4 --legend \
-t "$(PACKAGE_STRING)" \
-o $(top_builddir)/coverage/html \
-p `readlink -m $(abs_top_srcdir)`/src \
$(top_builddir)/coverage/coverage.info
@echo "Coverage Report at $(top_builddir)/coverage/html" >&2
coverage:
@$(MAKE) cov-reset
@$(MAKE) check
@$(MAKE) cov-report
else
cov-reset:
coverage:
@echo "reconfigure with --enable-coverage"
endif
clean-local:
@$(MAKE) cov-reset
rm -rf apidoc