build: add code coverage support

Build all targets, except for CLI tools (mmcli, uml290), with special
flags needed for collecting code coverage information when the build has
been configured with --enable-code-coverage.

Three new targets are available in the top build directory:

 - `check-code-coverage' runs the test suite and generates a code
   coverage report,

 - `code-coverage-capture' generates a code coverage report from already
   collected data, which can come in handy when one wants to see code
   paths touched by a particular test,

 - `code-coverage-clean' removes the collected coverage data and the
   generated reports.
This commit is contained in:
Jakub Sitnicki
2015-01-11 15:07:22 +01:00
committed by Aleksander Morgado
parent ffe2106d4e
commit 7552030ef9
14 changed files with 59 additions and 6 deletions

5
.gitignore vendored
View File

@@ -18,6 +18,8 @@ gtk-doc.make
*.lo
*.la
*.loT
*.gcno
*.gcda
libtool
.deps
.libs
@@ -165,3 +167,6 @@ plugins/test-service-*
TAGS
ABOUT-NLS
ModemManager-*-coverage.info
ModemManager-*-coverage/

View File

@@ -24,3 +24,10 @@ EXTRA_DIST = \
COPYING.LIB
ACLOCAL_AMFLAGS = -I m4
@CODE_COVERAGE_RULES@
if CODE_COVERAGE_ENABLED
clean-local:
-find $(top_builddir) -name "*.gcno" -delete
endif

View File

@@ -110,6 +110,9 @@ AC_SUBST(GLIB_MKENUMS)
GDBUS_CODEGEN=`$PKG_CONFIG --variable=gdbus_codegen gio-2.0`
AC_SUBST(GDBUS_CODEGEN)
# Code coverage (disabled by default)
AX_CODE_COVERAGE
# GObject Introspection
GOBJECT_INTROSPECTION_CHECK([0.9.6])
@@ -302,7 +305,13 @@ echo "
compiler: ${CC}
cflags: ${CFLAGS}
Maintainer mode: ${USE_MAINTAINER_MODE}
Code coverage: ${CODE_COVERAGE_ENABLED}"
if test "x${CODE_COVERAGE_ENABLED}" = "xyes"; then
echo " Code coverage cflags: ${CODE_COVERAGE_CFLAGS}"
echo " Code coverage ldflags: ${CODE_COVERAGE_LDFLAGS}"
fi
echo "
D-Bus system directory: ${DBUS_SYS_DIR}
udev base directory: ${UDEV_BASE_DIR}
systemd unit directory: ${with_systemdsystemunitdir}

View File

@@ -1,5 +1,8 @@
SUBDIRS = generated . tests
AM_CFLAGS = $(CODE_COVERAGE_CFLAGS)
AM_LDFLAGS = $(CODE_COVERAGE_LDFLAGS)
lib_LTLIBRARIES = libmm-glib.la
libmm_glib_la_SOURCES = \
@@ -91,7 +94,8 @@ libmm_glib_la_LIBADD = \
$(LIBMM_GLIB_LIBS)
libmm_glib_la_LDFLAGS = \
-version-info $(MM_GLIB_LT_CURRENT):$(MM_GLIB_LT_REVISION):$(MM_GLIB_LT_AGE)
-version-info $(MM_GLIB_LT_CURRENT):$(MM_GLIB_LT_REVISION):$(MM_GLIB_LT_AGE) \
$(AM_LDFLAGS)
includedir = @includedir@/libmm-glib
include_HEADERS = \

View File

@@ -1,6 +1,9 @@
SUBDIRS = . tests
AM_CFLAGS = $(CODE_COVERAGE_CFLAGS)
AM_LDFLAGS = $(CODE_COVERAGE_LDFLAGS)
noinst_LTLIBRARIES = libmm-generated.la
GENERATED_H = \

View File

@@ -1,4 +1,5 @@
AM_CFLAGS = $(CODE_COVERAGE_CFLAGS)
AM_LDFLAGS = $(CODE_COVERAGE_LDFLAGS)
noinst_LTLIBRARIES = libmm-test-generated.la

View File

@@ -1,5 +1,8 @@
include $(top_srcdir)/gtester.make
AM_CFLAGS = $(CODE_COVERAGE_CFLAGS)
AM_LDFLAGS = $(CODE_COVERAGE_LDFLAGS)
noinst_PROGRAMS = test-common-helpers
TEST_PROGS += $(noinst_PROGRAMS)

View File

@@ -1,5 +1,7 @@
noinst_LTLIBRARIES = libqcdm.la libqcdm-test.la
AM_CFLAGS = $(CODE_COVERAGE_CFLAGS)
AM_LDFLAGS = $(CODE_COVERAGE_LDFLAGS)
noinst_LTLIBRARIES = libqcdm.la libqcdm-test.la
libqcdm_la_CPPFLAGS = \
$(MM_CFLAGS)

View File

@@ -1,5 +1,8 @@
include $(top_srcdir)/gtester.make
AM_CFLAGS = $(CODE_COVERAGE_CFLAGS)
AM_LDFLAGS = $(CODE_COVERAGE_LDFLAGS)
noinst_PROGRAMS = test-qcdm modepref ipv6pref reset
TEST_PROGS += test-qcdm

View File

@@ -1,5 +1,7 @@
noinst_LTLIBRARIES = libwmc.la
AM_CFLAGS = $(CODE_COVERAGE_CFLAGS)
AM_LDFLAGS = $(CODE_COVERAGE_LDFLAGS)
noinst_LTLIBRARIES = libwmc.la
libwmc_la_CPPFLAGS = \
$(MM_CFLAGS)

View File

@@ -1,5 +1,8 @@
include $(top_srcdir)/gtester.make
AM_CFLAGS = $(CODE_COVERAGE_CFLAGS)
AM_LDFLAGS = $(CODE_COVERAGE_LDFLAGS)
noinst_PROGRAMS = test-wmc
TEST_PROGS += $(noinst_PROGRAMS)

View File

@@ -3,6 +3,9 @@ include $(top_srcdir)/gtester.make
# Common CPPFLAGS and LDFLAGS
AM_CFLAGS = $(CODE_COVERAGE_CFLAGS)
AM_LDFLAGS = $(CODE_COVERAGE_LDFLAGS)
PLUGIN_COMMON_COMPILER_FLAGS = \
$(MM_CFLAGS) \
$(GUDEV_CFLAGS) \
@@ -13,13 +16,15 @@ PLUGIN_COMMON_COMPILER_FLAGS = \
-I$(top_builddir)/include \
-I$(top_srcdir)/libmm-glib \
-I$(top_srcdir)/libmm-glib/generated \
-I$(top_builddir)/libmm-glib/generated
-I$(top_builddir)/libmm-glib/generated \
$(AM_CFLAGS)
PLUGIN_COMMON_LINKER_FLAGS = \
$(GUDEV_LIBS) \
$(MM_LIBS) \
-module \
-avoid-version
-avoid-version \
$(AM_LDFLAGS)
if WITH_QMI
PLUGIN_COMMON_COMPILER_FLAGS += $(QMI_CFLAGS)

View File

@@ -8,6 +8,9 @@ udevrules_DATA = \
77-mm-usb-serial-adapters-greylist.rules \
80-mm-candidate.rules
AM_CFLAGS = $(CODE_COVERAGE_CFLAGS)
AM_LDFLAGS = $(CODE_COVERAGE_LDFLAGS)
noinst_LTLIBRARIES = libmodem-helpers.la libport.la
libmodem_helpers_la_CPPFLAGS = \

View File

@@ -1,5 +1,8 @@
include $(top_srcdir)/gtester.make
AM_CFLAGS = $(CODE_COVERAGE_CFLAGS)
AM_LDFLAGS = $(CODE_COVERAGE_LDFLAGS)
noinst_PROGRAMS = \
test-modem-helpers \
test-charsets \