Commit b5303dfa 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 and CFLAGS 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 13b3b902
...@@ -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
......
...@@ -13,6 +13,9 @@ README.rst: src/vmod_selector.vcc ...@@ -13,6 +13,9 @@ README.rst: src/vmod_selector.vcc
$(MAKE) $(AM_MAKEFLAGS) -C src vmod_selector.man.rst $(MAKE) $(AM_MAKEFLAGS) -C src vmod_selector.man.rst
cp src/vmod_selector.man.rst README.rst cp src/vmod_selector.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} $< $@
......
...@@ -35,6 +35,22 @@ AC_ARG_WITH([rst2man], ...@@ -35,6 +35,22 @@ AC_ARG_WITH([rst2man],
AC_CHECK_PROGS(RST2MAN, [rst2man rst2man.py], [])) AC_CHECK_PROGS(RST2MAN, [rst2man rst2man.py], []))
AM_CONDITIONAL(HAVE_RST2MAN, [test "x$RST2MAN" != "xno"]) AM_CONDITIONAL(HAVE_RST2MAN, [test "x$RST2MAN" != "xno"])
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 README.rst])) m4_ifndef([VARNISH_PREREQ], AC_MSG_ERROR([Need varnish.m4 -- see README.rst]))
VARNISH_PREREQ([6.0.0]) VARNISH_PREREQ([6.0.0])
......
...@@ -45,6 +45,37 @@ AM_VTC_LOG_FLAGS = -Dvmod_selector="$(VMOD_SELECTOR)" ...@@ -45,6 +45,37 @@ AM_VTC_LOG_FLAGS = -Dvmod_selector="$(VMOD_SELECTOR)"
TESTS = @VMOD_TESTS@ TESTS = @VMOD_TESTS@
gcov: clean
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) CC=gcc \
CFLAGS="${AM_CFLAGS} --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_selector.vcc \ vmod_selector.vcc \
selector.vsc \ selector.vsc \
...@@ -57,4 +88,9 @@ CLEANFILES = \ ...@@ -57,4 +88,9 @@ CLEANFILES = \
$(builddir)/vmod_selector.man.rst \ $(builddir)/vmod_selector.man.rst \
$(builddir)/vmod_selector.3 \ $(builddir)/vmod_selector.3 \
$(builddir)/VSC_selector.c \ $(builddir)/VSC_selector.c \
$(builddir)/VSC_selector.h $(builddir)/VSC_selector.h \
$(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