diff options
author | Thomas H.P. Andersen <phomes@gmail.com> | 2013-03-28 14:54:06 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-07-13 21:56:33 -0400 |
commit | 6aea6d10f460853111ca8744201ec8dade97de3c (patch) | |
tree | bc6581816af3727aa404a72b3636e012acfec7e6 /Makefile.am | |
parent | 7aa4fa34f76b0d9b031f0a5ea941c7fa10cebbee (diff) |
Add test coverage and generate report with lcov
Enable coverage with --enable-coverage.
"make coverage" will create the report locally,
"make coverage-sync" will upload the report to
http://www.freedesktop.org/software/systemd/coverage/.
Requires lcov version 1.10 to handle naming in systemd and to
use the --no-external option.
[zj: make the coverage at least generate something with
separate build dir, simplify rules a bit: all errors
are mine. ]
Diffstat (limited to 'Makefile.am')
-rw-r--r-- | Makefile.am | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am index 2283d05789..9105274c0d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1390,6 +1390,44 @@ test_sched_prio_LDADD = \ libsystemd-daemon.la # ------------------------------------------------------------------------------ +## .PHONY so it always rebuilds it +.PHONY: coverage lcov-run lcov-report + +# run lcov from scratch, always +coverage: + $(MAKE) lcov-run + $(MAKE) lcov-report + +coverage_dir = coverage +coverage_opts = --base-directory $(srcdir) --directory $(builddir) --rc 'geninfo_adjust_src_path=$(abspath $(srcdir))=>$(abspath $(builddir))' + +if ENABLE_COVERAGE +# reset run coverage tests +lcov-run: + @rm -rf $(coverage_dir) + lcov $(coverage_opts) --zerocounters + -$(MAKE) check + +# generate report based on current coverage data +lcov-report: + $(MKDIR_P) $(coverage_dir) + lcov $(coverage_opts) --compat-libtool --capture --no-external \ + | sed 's|$(abspath $(builddir))|$(abspath $(srcdir))|' > $(coverage_dir)/.lcov.info + genhtml -t "systemd test coverage" -o $(coverage_dir) $(coverage_dir)/.lcov.info + @echo "Coverage report generated in $(abs_builddir)/$(coverage_dir)/index.html" + +# lcov doesn't work properly with vpath builds, make sure that bad +# output is not uploaded by mistake. +coverage-sync: coverage + test "$(builddir)" = "$(srcdir)" + rsync -rlv --delete --omit-dir-times coverage/ $(www_target)/coverage + +else +lcov-run lcov-report: + echo "Need to reconfigure with --enable-coverage" +endif + +# ------------------------------------------------------------------------------ systemd_initctl_SOURCES = \ src/initctl/initctl.c |