Commit 8931b5fd 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, the make target coverage can be executed:

- 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 70375c1b
......@@ -5,6 +5,8 @@ Makefile.in
*.o
*.lo
*.la
*.gcda
*.gcno
*~
*.[1-9]
.dirstamp
......@@ -38,3 +40,5 @@ Makefile.in
/src/tests/*.log
/src/tests/*.trs
/src/test-suite.log
/src/coverage
......@@ -4,3 +4,6 @@ SUBDIRS = src
DISTCHECK_CONFIGURE_FLAGS = \
VMOD_DIR='$${libdir}/varnish/vmods'
coverage:
$(MAKE) $(AM_MAKEFLAGS) -C src coverage
......@@ -35,6 +35,22 @@ AC_ARG_WITH([rst2man],
AC_CHECK_PROGS(RST2MAN, [rst2man rst2man.py], []))
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]))
PKG_CHECK_MODULES([LIBCRYPTO], [libcrypto])
......
......@@ -61,6 +61,36 @@ rfc8188_test_CFLAGS = $(AM_CFLAGS)
TESTS += rfc8188_test
gcov: clean
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) CC=gcc \
CFLAGS="${AM_CFLAGS} --coverage -fno-inline -g -O0" check
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 = \
vmod_ece.vcc \
$(VMOD_TESTS)
......@@ -70,4 +100,9 @@ CLEANFILES = \
$(builddir)/vcc_if.h \
$(builddir)/vmod_ece.rst \
$(builddir)/vmod_ece.man.rst \
$(builddir)/vmod_ece.3
$(builddir)/vmod_ece.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