]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
Use AX_CODE_COVERAGE for test-coverage statistics
authorThomas Zimmermann <tdz@users.sourceforge.net>
Fri, 12 Aug 2016 08:50:53 +0000 (10:50 +0200)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Mon, 15 Aug 2016 13:30:51 +0000 (14:30 +0100)
DBus uses custom rules in its Makefiles to implement test-coverage
statistics.

This patch implements test-coverage statistics with the autoconf macro
AX_CODE_COVERAGE. The script automatically tests for tools (e.g., gcov,
lcov), sets build variables and creates Makefile rules.

Run 'configure' with '--enable-code-coverage' to enable support for
test-coverage statistics. Run 'make check-code-coverage' to run the
tests and generate the statistics.

Signed-off-by: Thomas Zimmermann <tdz@users.sourceforge.net>
[smcv: do not alter compiler.m4; move AM_CXXFLAGS to the one place we
compile C++]
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88922

Makefile.am
bus/Makefile.am
configure.ac
dbus/Makefile.am
test/Makefile.am
tools/lcov.am [deleted file]

index 756ab8b9a26ca53e0136afc928ae3b3ed6e72ff9..db0d5228992e6ae930250916946a64d39608ecd0 100644 (file)
@@ -33,4 +33,5 @@ DISTCHECK_CONFIGURE_FLAGS = \
 
 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
 
-include tools/lcov.am
+# Add rules for code-coverage testing, as defined by AX_CODE_COVERAGE
+@CODE_COVERAGE_RULES@
index 90092b14227cf3b7159bc232ce5ac092b00eaee2..268c6f040071c02b437d04eff405170f528aa604 100644 (file)
@@ -3,6 +3,7 @@ legacydbusdatadir=$(sysconfdir)/dbus-1
 dbus_daemon_execdir = $(DBUS_DAEMONDIR)
 
 DBUS_BUS_LIBS = \
+       $(CODE_COVERAGE_LDFLAGS) \
        $(XML_LIBS) \
        $(SELINUX_LIBS) \
        $(APPARMOR_LIBS) \
@@ -12,12 +13,14 @@ DBUS_BUS_LIBS = \
        $(NULL)
 
 DBUS_LAUNCHER_LIBS = \
+       $(CODE_COVERAGE_LDFLAGS) \
        $(XML_LIBS) \
        $(THREAD_LIBS) \
        $(NETWORK_libs) \
        $(NULL)
 
 AM_CPPFLAGS = \
+       $(CODE_COVERAGE_CPPFLAGS) \
        -I$(top_srcdir) \
        $(DBUS_STATIC_BUILD_CPPFLAGS) \
        $(XML_CFLAGS) \
@@ -29,6 +32,10 @@ AM_CPPFLAGS = \
 # if assertions are enabled, improve backtraces
 AM_LDFLAGS = @R_DYNAMIC_LDFLAG@
 
+AM_CFLAGS = \
+       $(CODE_COVERAGE_CFLAGS) \
+       $(NULL)
+
 EFENCE=
 
 CONFIG_IN_FILES=                               \
@@ -233,10 +240,6 @@ test_bus_LDADD = \
        $(DBUS_BUS_LIBS) \
        $(NULL)
 
-## mop up the gcov files
-clean-local:
-       /bin/rm *.bb *.bbg *.da *.gcov || true
-
 install-data-hook:
        $(mkinstalldirs) $(DESTDIR)$(dbusdatadir)/session.d
        $(mkinstalldirs) $(DESTDIR)$(dbusdatadir)/services
@@ -327,6 +330,9 @@ systemduserunit_DATA = \
        $(NULL)
 endif
 
+# Add rules for code-coverage testing, as defined by AX_CODE_COVERAGE
+@CODE_COVERAGE_RULES@
+
 #### Extra dist
 
 EXTRA_DIST=$(CONFIG_IN_FILES) $(SCRIPT_IN_FILES)
index 2aac82ed1a06e610808aa42ac33d86caf1ebc019..cf08a055eaceb5c13c8ed40427d1e924c216f5f9 100644 (file)
@@ -71,7 +71,6 @@ AC_HEADER_STDC
 AC_C_INLINE
 AM_PROG_LIBTOOL
 AC_PROG_MKDIR_P
-COMPILER_COVERAGE
 COMPILER_OPTIMISATIONS
 PKG_PROG_PKG_CONFIG
 
@@ -333,10 +332,14 @@ AH_BOTTOM([
 #  define DBUS_ENABLE_CHECKS 1
 #endif])
 
-if test x$enable_compiler_coverage = xyes; then
-     ## so that config.h changes when you toggle gcov support
-     AC_DEFINE_UNQUOTED(DBUS_GCOV_ENABLED, 1, [Defined if gcov is enabled to force a rebuild due to config.h changing])
-fi
+# Test for code-coverage tools if --enable-code-coverage
+AX_CODE_COVERAGE
+
+AS_IF([test x$enable_code_coverage = xyes],[
+    AC_DEFINE_UNQUOTED(
+      [DBUS_GCOV_ENABLED], [1],
+      [Defined if gcov is enabled to force a rebuild due to config.h changing])
+  ])
 
 #### Integer sizes
 
@@ -1893,7 +1896,7 @@ echo "
 
 echo "
         Rebuilding generated files: ${USE_MAINTAINER_MODE}
-        gcc coverage profiling:   ${enable_compiler_coverage}
+        gcc coverage profiling:   ${enable_code_coverage}
         Building embedded tests:  ${enable_embedded_tests}
         Building modular tests:   ${enable_modular_tests}
             - with GLib:          ${with_glib}
@@ -1937,9 +1940,9 @@ fi
 if test x$enable_embedded_tests = xyes -a x$enable_asserts = xno; then
         echo "NOTE: building with embedded tests but without assertions means tests may not properly report failures (this configuration is only useful when doing something like profiling the tests)"
 fi
-if test x$enable_compiler_coverage = xyes; then
-        echo "NOTE: building with coverage profiling is definitely for developers only."
-fi
+AS_IF([test x$enable_code_coverage = xyes],[
+    AC_MSG_WARN([Building with coverage profiling is definitely for developers only.])
+  ])
 if test x$enable_verbose_mode = xyes; then
         echo "NOTE: building with verbose mode increases library size, may slightly increase security risk, and decreases performance."
 fi
index 015248654d917ce0a1cfe57123209d0c5fbc214b..e4aa2eeac2bc220368829502e6cc83a1d412e23d 100644 (file)
@@ -2,6 +2,7 @@
 dbusdatadir=$(datadir)/dbus-1
 
 AM_CPPFLAGS = \
+       $(CODE_COVERAGE_CPPFLAGS) \
        -I$(top_builddir) \
        -I$(top_srcdir) \
        $(DBUS_STATIC_BUILD_CPPFLAGS) \
@@ -13,7 +14,9 @@ AM_CPPFLAGS = \
        -DDBUS_SESSION_CONFIG_FILE=\""$(dbusdatadir)/session.conf"\" \
        $(NULL)
 
-AM_CFLAGS =
+AM_CFLAGS = \
+       $(CODE_COVERAGE_CFLAGS) \
+       $(NULL)
 
 if HAVE_VISIBILITY
 if !DBUS_WIN
@@ -306,6 +309,10 @@ libdbus_1_la_LDFLAGS = \
 libdbus_internal_la_LIBADD=$(LIBDBUS_LIBS) libdbus-1.la
 
 if DBUS_WIN
+AM_CXXFLAGS = \
+       $(CODE_COVERAGE_CXXFLAGS) \
+       $(NULL)
+
 # This must be a separate convenience library, otherwise libtool notices
 # that libdbus-1 might contain C++, links it with g++ and links in libstdc++,
 # even on Unix where in fact it doesn't contain any C++. For Windows, where
@@ -327,6 +334,5 @@ test_dbus_SOURCES=                          \
 
 test_dbus_LDADD = libdbus-internal.la
 
-## mop up the gcov files
-clean-local:
-       /bin/rm *.bb *.bbg *.da *.gcov .libs/*.da .libs/*.bbg || true
+# Add rules for code-coverage testing, as defined by AX_CODE_COVERAGE
+@CODE_COVERAGE_RULES@
index 85799fe3ef83b4574600ebb723d5734e0391fb2a..1b6d757c2b25d0f50dcef98d2da4f418bd78ba6f 100644 (file)
@@ -1,13 +1,14 @@
-## the "name-test" subdir in fact contains a bunch of tests now that need a temporary bus 
+## the "name-test" subdir in fact contains a bunch of tests now that need a temporary bus
 ## to be running to do stuff with. The directory should be renamed.
 ## We want to build the current directory first to pick up the testutils lib
-SUBDIRS= . name-test 
+SUBDIRS= . name-test
 DIST_SUBDIRS=name-test
 
 CLEANFILES =
 EXTRA_DIST =
 
 AM_CPPFLAGS = \
+       $(CODE_COVERAGE_CPPFLAGS) \
        -I$(top_srcdir) \
        $(DBUS_STATIC_BUILD_CPPFLAGS) \
        -DDBUS_COMPILATION \
@@ -17,6 +18,10 @@ AM_CPPFLAGS = \
 # improve backtraces from test stuff
 AM_LDFLAGS = @R_DYNAMIC_LDFLAG@
 
+AM_CFLAGS = \
+       $(CODE_COVERAGE_CFLAGS) \
+       $(NULL)
+
 noinst_LTLIBRARIES = libdbus-testutils.la
 
 libdbus_testutils_la_SOURCES = \
@@ -34,6 +39,7 @@ endif
 libdbus_testutils_la_LIBADD = \
        $(top_builddir)/dbus/libdbus-1.la \
        $(top_builddir)/dbus/libdbus-internal.la \
+       $(CODE_COVERAGE_LDFLAGS) \
        $(NULL)
 
 TEST_EXTENSIONS = .sh
@@ -555,3 +561,6 @@ $(installable_test_meta_with_config): %_with_config.test: %$(EXEEXT) Makefile
                echo 'Output=TAP'; \
                echo 'Exec=env DBUS_TEST_DATA=$(testexecdir)/data $(testexecdir)/$* --tap'; \
        ) > $@.tmp && mv $@.tmp $@
+
+# Add rules for code-coverage testing, as defined by AX_CODE_COVERAGE
+@CODE_COVERAGE_RULES@
diff --git a/tools/lcov.am b/tools/lcov.am
deleted file mode 100644 (file)
index ac34867..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-# Copyright © 2008-2011 Collabora Ltd.
-# Copyright © 2008-2011 Nokia Corporation
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-lcov-reset:
-       lcov --directory @abs_top_builddir@ --zerocounters
-
-lcov-report:
-       lcov --directory @abs_top_builddir@ --capture \
-               --output-file @abs_top_builddir@/lcov.info
-       $(mkdir_p) @abs_top_builddir@/lcov.html
-       git_commit=`GIT_DIR=@abs_top_srcdir@/.git git log -1 --pretty=format:%h 2>/dev/null`;\
-       genhtml --title "@PACKAGE_STRING@ $$git_commit" \
-               --output-directory @abs_top_builddir@/lcov.html lcov.info
-       @echo
-       @echo 'lcov report can be found in:'
-       @echo 'file://@abs_top_builddir@/lcov.html/index.html'
-       @echo
-
-lcov-check:
-       $(MAKE) lcov-reset
-       $(MAKE) check $(LCOV_CHECK_ARGS)
-       $(MAKE) lcov-report
-
-## vim:set ft=automake: