Commit 8dbfc85c authored by Geoff Simmons's avatar Geoff Simmons

Add autotool support for generating coverage reports.

configure checks if you have lcov & genhtml; these can be specified
with --with-lcov and/or --with-genhtml.

If they are available, then make coverage does the following:

- make clean, then make check with CC=gcc & CXX=g++, and CFLAGS &&
  CXXFLAGS set so that inputs for gcov/lcov are generated.

- lcov creates the src/coverage subdir and generates a targetfile
  there.

- genhtml generates HTML reports in src/coverage.
parent 5c259a91
...@@ -7,6 +7,8 @@ Makefile.in ...@@ -7,6 +7,8 @@ Makefile.in
*.la *.la
*~ *~
*.[1-9] *.[1-9]
*.gcda
*.gcno
.dirstamp .dirstamp
/aclocal.m4 /aclocal.m4
...@@ -36,3 +38,5 @@ Makefile.in ...@@ -36,3 +38,5 @@ Makefile.in
/src/tests/*.log /src/tests/*.log
/src/tests/*.trs /src/tests/*.trs
/src/test-suite.log /src/test-suite.log
/src/coverage
...@@ -13,6 +13,9 @@ README.rst: src/vmod_re2.vcc ...@@ -13,6 +13,9 @@ README.rst: src/vmod_re2.vcc
$(MAKE) -C src vmod_re2.man.rst $(MAKE) -C src vmod_re2.man.rst
cp src/vmod_re2.man.rst README.rst cp src/vmod_re2.man.rst README.rst
coverage:
$(MAKE) $(AM_MAKEFLAGS) -C src coverage
%.1 %.2 %.3 %.4 %.5 %.6 %.7 %.8 %.9: %.1 %.2 %.3 %.4 %.5 %.6 %.7 %.8 %.9:
if HAVE_RST2MAN if HAVE_RST2MAN
${RST2MAN} $< $@ ${RST2MAN} $< $@
......
...@@ -28,6 +28,22 @@ AC_ARG_WITH([rst2man], ...@@ -28,6 +28,22 @@ AC_ARG_WITH([rst2man],
[RST2MAN="$withval"], [RST2MAN="$withval"],
AC_CHECK_PROGS(RST2MAN, [rst2man rst2man.py], [])) AC_CHECK_PROGS(RST2MAN, [rst2man rst2man.py], []))
AC_ARG_WITH([lcov],
AS_HELP_STRING(
[--with-lcov=PATH],
[Location of lcov to generate coverage data (auto)]),
[LCOV="$withval"],
AC_CHECK_PROGS(LCOV, [lcov], []))
AM_CONDITIONAL(HAVE_LCOV, [test -n "$LCOV"])
AC_ARG_WITH([genhtml],
AS_HELP_STRING(
[--with-genhtml=PATH],
[Location of genhtml to generate coverage reports (auto)]),
[GENHTML="$withval"],
AC_CHECK_PROGS(GENHTML, [genhtml], []))
AM_CONDITIONAL(HAVE_GENHTML, [test -n "$GENHTML"])
m4_ifndef([VARNISH_PREREQ], AC_MSG_ERROR([Need varnish.m4 -- see INSTALL.rst])) m4_ifndef([VARNISH_PREREQ], AC_MSG_ERROR([Need varnish.m4 -- see INSTALL.rst]))
PKG_CHECK_MODULES([RE2], [re2]) PKG_CHECK_MODULES([RE2], [re2])
......
...@@ -52,6 +52,38 @@ AM_VTC_LOG_FLAGS = -Dvmod_re2="$(VMOD_RE2)" ...@@ -52,6 +52,38 @@ AM_VTC_LOG_FLAGS = -Dvmod_re2="$(VMOD_RE2)"
TESTS = @VMOD_TESTS@ TESTS = @VMOD_TESTS@
gcov: clean
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) CC=gcc CXX=g++ \
CFLAGS="${AM_CFLAGS} --coverage -fno-inline -g -O0" \
CXXFLAGS="${AM_CXXFLAGS} --coverage -fno-inline -g -O0" check
# Set QUIET=-q for non-verbose builds, otherwise set to empty.
QUIET_0 = -q
QUIET_ = $(QUIET_@AM_DEFAULT_V@)
QUIET = $(QUIET_@AM_V@)
coverage/lcov.info: gcov
if HAVE_LCOV
$(AM_V_at)@mkdir $(builddir)/coverage
$(AM_V_GEN) $(LCOV) $(QUIET) -c -d . -o $(builddir)/coverage/lcov.info
else
@echo "================================================="
@echo "You need lcov installed to generate coverage data"
@echo "================================================="
@false
endif
coverage: coverage/lcov.info
if HAVE_GENHTML
$(AM_V_GEN) $(GENHTML) $(QUIET) $(builddir)/coverage/lcov.info \
-o $(builddir)/coverage
else
@echo "======================================================="
@echo "You need genhtml installed to generate coverage reports"
@echo "======================================================="
@false
endif
EXTRA_DIST = \ EXTRA_DIST = \
vmod_re2.vcc \ vmod_re2.vcc \
$(VMOD_TESTS) $(VMOD_TESTS)
...@@ -61,4 +93,9 @@ CLEANFILES = \ ...@@ -61,4 +93,9 @@ CLEANFILES = \
$(builddir)/vcc_if.h \ $(builddir)/vcc_if.h \
$(builddir)/vmod_re2.rst \ $(builddir)/vmod_re2.rst \
$(builddir)/vmod_re2.man.rst \ $(builddir)/vmod_re2.man.rst \
$(builddir)/vmod_re2.3 $(builddir)/vmod_re2.3 \
$(builddir)/*.gcda \
$(builddir)/*.gcno
clean-local:
@rm -rf $(builddir)/coverage
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment