diff options
author | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2018-09-24 12:47:51 +0200 |
---|---|---|
committer | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2018-09-24 12:47:51 +0200 |
commit | 383180f13a132e4fc95f2710f2a7deb27fe516c4 (patch) | |
tree | 488e6de29e55dc3c36f4723bee09955230dbf821 | |
parent | d1cfcb3520382cd6c762db829f1ba004b8666286 (diff) | |
download | librb-383180f13a132e4fc95f2710f2a7deb27fe516c4.tar.gz librb-383180f13a132e4fc95f2710f2a7deb27fe516c4.tar.bz2 librb-383180f13a132e4fc95f2710f2a7deb27fe516c4.zip |
add: optional code coverage for tests
-rw-r--r-- | .gitignore | 10 | ||||
-rw-r--r-- | Makefile.am | 4 | ||||
-rw-r--r-- | Makefile.am.coverage | 28 | ||||
-rw-r--r-- | configure.ac | 13 |
4 files changed, 51 insertions, 4 deletions
@@ -1,6 +1,10 @@ +*.gcda +*.gcno +*.la +*.lo *.o -.* *.plist +.* Makefile Makefile.in aclocal.m4 @@ -14,6 +18,8 @@ config.log config.status config.sub configure +coverage.info +coveragereport/ depcomp install-sh librb-*.tar.gz @@ -35,5 +41,3 @@ tests.trs www/downloads.html www/manuals www/out -*.la -*.lo diff --git a/Makefile.am b/Makefile.am index 611684d..fd5f691 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,3 +1,4 @@ +include Makefile.am.coverage ACLOCAL_AMFLAGS=-I m4 # building librb library @@ -13,7 +14,8 @@ librb_la_CFLAGS = -I$(top_srcdir) check_PROGRAMS = tests tests_SOURCES = rb.c tests.c mtest.h -tests_CFLAGS = -I$(top_srcdir) +tests_CFLAGS = -I$(top_srcdir) $(COVERAGE_CFLAGS) +tests_LDFLAGS = $(COVERAGE_LDFLAGS) TESTS = $(check_PROGRAMS) LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \ diff --git a/Makefile.am.coverage b/Makefile.am.coverage new file mode 100644 index 0000000..5cfbf51 --- /dev/null +++ b/Makefile.am.coverage @@ -0,0 +1,28 @@ +# Coverage targets + +.PHONY: clean-gcda coverage generate-coverage-html clean-coverage-html + +if HAVE_GCOV + +clean-gcda: + @echo Removing old coverage results + -find -name '*.gcda' -print | xargs -r rm + -find -name '*.gcno' -print | xargs -r rm + +coverage: clean-gcda + -$(MAKE) $(AM_MAKEFLAGS) -k check + $(MAKE) $(AM_MAKEFLAGS) generate-coverage-html + +generate-coverage-html: + @echo Collecting coverage data + $(LCOV) --directory $(top_builddir) --capture --output-file coverage.info --no-checksum --compat-libtool + LANG=C $(GENHTML) --prefix $(top_builddir) --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info + +clean-coverage-html: clean-gcda + -$(LCOV) --directory $(top_builddir) -z + -rm -rf coverage.info coveragereport + +clean-local: clean-coverage-html + +endif # HAVE_GCOV + diff --git a/configure.ac b/configure.ac index e15a285..5ae1282 100644 --- a/configure.ac +++ b/configure.ac @@ -9,6 +9,19 @@ AC_CONFIG_HEADERS([config.h]) AC_CHECK_HEADERS([assert.h errno.h stddef.h stdlib.h string.h]) + +### +# gcov coverage reporting +# + + +m4_include([m4/gcov.m4]) +AC_TDD_GCOV +AC_SUBST(COVERAGE_CFLAGS) +AC_SUBST(COVERAGE_CXXFLAGS) +AC_SUBST(COVERAGE_LDFLAGS) + + ### # --enable-threads # |