summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile.am38
-rw-r--r--configure.ac24
-rw-r--r--src/.gitignore2
4 files changed, 65 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 5f9ba906a4..f4f1e45926 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,7 @@
/busctl
/cdrom_id
/collect
+/coverage/
/gtk-doc.make
/hostnamectl
/install-tree
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
diff --git a/configure.ac b/configure.ac
index 1e196f7307..afbe8e9048 100644
--- a/configure.ac
+++ b/configure.ac
@@ -215,6 +215,29 @@ m4_pattern_forbid([^_?PKG_[A-Z_]+$],[*** pkg.m4 missing, please install pkg-conf
PKG_CHECK_MODULES(DBUS, [dbus-1 >= 1.3.2])
# ------------------------------------------------------------------------------
+have_coverage=no
+AC_ARG_ENABLE(coverage, AS_HELP_STRING([--enable-coverage], [enable test coverage]))
+if test "x$enable_coverage" = "xyes" ; then
+ AC_CHECK_PROG(lcov_found, [lcov], [yes], [no])
+ if test "x$lcov_found" = xno ; then
+ AC_MSG_ERROR([*** lcov support requested but the program was not found])
+ else
+ lcov_version_major="`lcov --version | cut -d ' ' -f 4 | cut -d '.' -f 1`"
+ lcov_version_minor="`lcov --version | cut -d ' ' -f 4 | cut -d '.' -f 2`"
+ if test "$lcov_version_major" -eq 1 -a "$lcov_version_minor" -lt 10; then
+ AC_MSG_ERROR([*** lcov version is too old. 1.10 required])
+ else
+ have_coverage=yes
+ CC_CHECK_FLAGS_APPEND([with_coverage_cflags], [CFLAGS], [\
+ -fprofile-arcs \
+ -ftest-coverage])
+ AC_SUBST([OUR_CFLAGS], "$with_cflags $with_coverage_cflags")
+ fi
+ fi
+fi
+AM_CONDITIONAL(ENABLE_COVERAGE, [test "$have_coverage" = "yes"])
+
+# ------------------------------------------------------------------------------
have_kmod=no
AC_ARG_ENABLE(kmod, AS_HELP_STRING([--disable-kmod], [disable loadable modules support]))
if test "x$enable_kmod" != "xno"; then
@@ -1000,6 +1023,7 @@ AC_MSG_RESULT([
Python Headers: ${have_python_devel}
man pages: ${have_manpages}
gtk-doc: ${enable_gtk_doc}
+ test coverage: ${have_coverage}
Split /usr: ${enable_split_usr}
SysV compatibility: ${SYSTEM_SYSV_COMPAT}
diff --git a/src/.gitignore b/src/.gitignore
index afabb6a5d2..e6ac2d7b8a 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -4,3 +4,5 @@ load-fragment-gperf.gperf
org.freedesktop.systemd1.policy.in
org.freedesktop.systemd1.policy
99-systemd.rules
+*.gcno
+*.gcda