diff options
-rw-r--r-- | Makefile.am | 36 | ||||
-rw-r--r-- | Makefile.am.coverage | 41 | ||||
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | m4/gcov.m4 | 23 |
4 files changed, 58 insertions, 45 deletions
diff --git a/Makefile.am b/Makefile.am index e31937a..45c511a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -32,38 +32,4 @@ dist-hook: echo Failed to generate AUTHORS: not a branch >&2; \ fi - -# Coverage targets - -.PHONY: clean-gcda -clean-gcda: - @echo Removing old coverage results - -find -name '*.gcda' -print | xargs -r rm - -.PHONY: coverage-html generate-coverage-html clean-coverage-html -coverage-html: 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 - -.PHONY: coverage-xml generate-coverage-xml clean-coverage-xml -coverage-xml: clean-gcda - -$(MAKE) $(AM_MAKEFLAGS) -k check - $(MAKE) $(AM_MAKEFLAGS) generate-coverage-xml - -generate-coverage-xml: - @echo Generating coverage XML report - $(GCOVR) -x -r $(top_builddir) -o $(top_builddir)/coverage.xml - -clean-coverage-xml: clean-gcda - -rm -rf $(top_builddir)/coverage.xml - -clean-local: clean-coverage-html clean-coverage-xml +include $(top_srcdir)/Makefile.am.coverage diff --git a/Makefile.am.coverage b/Makefile.am.coverage new file mode 100644 index 0000000..b0a2f8c --- /dev/null +++ b/Makefile.am.coverage @@ -0,0 +1,41 @@ + +# Coverage targets + +if HAVE_GCOV + + .PHONY: clean-gcda + clean-gcda: + @echo Removing old coverage results + -find -name '*.gcda' -print | xargs -r rm + + .PHONY: coverage-html generate-coverage-html clean-coverage-html + coverage-html: 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 + +if HAVE_GCOVR + + .PHONY: coverage-gcovr generate-coverage-gcovr clean-coverage-gcovr + coverage-gcovr: clean-gcda + -$(MAKE) $(AM_MAKEFLAGS) -k check + $(MAKE) $(AM_MAKEFLAGS) generate-coverage-gcovr + + generate-coverage-gcovr: + @echo Generating coverage GCOVR report + $(GCOVR) -x -r $(top_builddir) -o $(top_builddir)/coverage.gcovr + + clean-coverage-gcovr: clean-gcda + -rm -rf $(top_builddir)/coverage.gcovr + +endif # HAVE_GCOVR + +endif # HAVE_GCOV diff --git a/configure.ac b/configure.ac index 28f9091..159c740 100644 --- a/configure.ac +++ b/configure.ac @@ -96,6 +96,9 @@ AC_SUBST(STATUS_PROVIDER_EMESENE_LIBS) m4_include([m4/gcov.m4]) AC_TDD_GCOV +AM_CONDITIONAL([HAVE_GCOV], [test "x$ac_cv_check_gcov" = xyes]) +AM_CONDITIONAL([HAVE_LCOV], [test "x$ac_cv_check_lcov" = xyes]) +AM_CONDITIONAL([HAVE_GCOVR], [test "x$ac_cv_check_gcovr" = xyes]) AC_SUBST(COVERAGE_CFLAGS) AC_SUBST(COVERAGE_CXXFLAGS) AC_SUBST(COVERAGE_LDFLAGS) @@ -5,11 +5,10 @@ # * gcovr # # Sets ac_cv_check_gcov to yes if tooling is present -# and reports the executables to the variables LCOV, GCOVR and GENHTML. +# and reports the executables to the variables LCOV, GCOVR and GENHTML. AC_DEFUN([AC_TDD_GCOV], -[AC_CACHE_CHECK([whether code coverage tools are available], ac_cv_check_gcov, [ -AC_ARG_ENABLE(gcov, + AC_ARG_ENABLE(gcov, AS_HELP_STRING([--enable-gcov], [enable coverage testing with gcov]), [use_gcov=$enableval], [use_gcov=no]) @@ -34,7 +33,6 @@ AC_ARG_ENABLE(gcov, lcov_version_list="1.6 1.7 1.8 1.9" AC_CHECK_PROG(LCOV, lcov, lcov) AC_CHECK_PROG(GENHTML, genhtml, genhtml) - AC_CHECK_PROG(GCOVR, gcovr, gcovr) if test "$LCOV"; then AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [ @@ -63,10 +61,8 @@ AC_ARG_ENABLE(gcov, AC_MSG_ERROR([Could not find genhtml from the lcov package]) fi - if test -z "$GCOVR"; then - AC_MSG_ERROR([Could not find gcovr; easy_install (or pip) gcovr]) - fi - + ac_cv_check_gcov=yes + ac_cv_check_lcov=yes # Remove all optimization flags from CFLAGS changequote({,}) @@ -78,6 +74,13 @@ AC_ARG_ENABLE(gcov, COVERAGE_CXXFLAGS="-O0 -fprofile-arcs -ftest-coverage" COVERAGE_LDFLAGS="-lgcov" -fi -])]) # AC_TDD_GCOV + # Check availability of gcovr + AC_CHECK_PROG(GCOVR, gcovr, gcovr) + if test -z "$GCOVR"; then + ac_cv_check_gcovr=no + else + ac_cv_check_gcovr=yes + fi +fi +]) # AC_TDD_GCOV |