[PATCH 3/4] build: add code coverage support
Jakub Sitnicki
jsitnicki at gmail.com
Sun Jan 11 06:07:22 PST 2015
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.
---
.gitignore | 5 +++++
Makefile.am | 7 +++++++
configure.ac | 9 +++++++++
libmm-glib/Makefile.am | 6 +++++-
libmm-glib/generated/Makefile.am | 3 +++
libmm-glib/generated/tests/Makefile.am | 3 ++-
libmm-glib/tests/Makefile.am | 3 +++
libqcdm/src/Makefile.am | 4 +++-
libqcdm/tests/Makefile.am | 3 +++
libwmc/src/Makefile.am | 4 +++-
libwmc/tests/Makefile.am | 3 +++
plugins/Makefile.am | 9 +++++++--
src/Makefile.am | 3 +++
src/tests/Makefile.am | 3 +++
14 files changed, 59 insertions(+), 6 deletions(-)
diff --git a/.gitignore b/.gitignore
index 5888e9d..2ce4de0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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/
diff --git a/Makefile.am b/Makefile.am
index f6bea8e..762306f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -24,3 +24,10 @@ EXTRA_DIST = \
COPYING.LIB
ACLOCAL_AMFLAGS = -I m4
+
+ at CODE_COVERAGE_RULES@
+
+if CODE_COVERAGE_ENABLED
+clean-local:
+ -find $(top_builddir) -name "*.gcno" -delete
+endif
diff --git a/configure.ac b/configure.ac
index c0064d2..8fd6c11 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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}
diff --git a/libmm-glib/Makefile.am b/libmm-glib/Makefile.am
index 54e79fc..da1f5d4 100644
--- a/libmm-glib/Makefile.am
+++ b/libmm-glib/Makefile.am
@@ -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 = \
diff --git a/libmm-glib/generated/Makefile.am b/libmm-glib/generated/Makefile.am
index 2a608fc..5a90b90 100644
--- a/libmm-glib/generated/Makefile.am
+++ b/libmm-glib/generated/Makefile.am
@@ -1,6 +1,9 @@
SUBDIRS = . tests
+AM_CFLAGS = $(CODE_COVERAGE_CFLAGS)
+AM_LDFLAGS = $(CODE_COVERAGE_LDFLAGS)
+
noinst_LTLIBRARIES = libmm-generated.la
GENERATED_H = \
diff --git a/libmm-glib/generated/tests/Makefile.am b/libmm-glib/generated/tests/Makefile.am
index a4bed42..0cebb72 100644
--- a/libmm-glib/generated/tests/Makefile.am
+++ b/libmm-glib/generated/tests/Makefile.am
@@ -1,4 +1,5 @@
-
+AM_CFLAGS = $(CODE_COVERAGE_CFLAGS)
+AM_LDFLAGS = $(CODE_COVERAGE_LDFLAGS)
noinst_LTLIBRARIES = libmm-test-generated.la
diff --git a/libmm-glib/tests/Makefile.am b/libmm-glib/tests/Makefile.am
index be93d4c..f98f9d7 100644
--- a/libmm-glib/tests/Makefile.am
+++ b/libmm-glib/tests/Makefile.am
@@ -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)
diff --git a/libqcdm/src/Makefile.am b/libqcdm/src/Makefile.am
index 9aa9500..2caaf00 100644
--- a/libqcdm/src/Makefile.am
+++ b/libqcdm/src/Makefile.am
@@ -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)
diff --git a/libqcdm/tests/Makefile.am b/libqcdm/tests/Makefile.am
index 3259906..c00f1b0 100644
--- a/libqcdm/tests/Makefile.am
+++ b/libqcdm/tests/Makefile.am
@@ -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
diff --git a/libwmc/src/Makefile.am b/libwmc/src/Makefile.am
index 4620501..b662f89 100644
--- a/libwmc/src/Makefile.am
+++ b/libwmc/src/Makefile.am
@@ -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)
diff --git a/libwmc/tests/Makefile.am b/libwmc/tests/Makefile.am
index 33eaf3d..4622fbc 100644
--- a/libwmc/tests/Makefile.am
+++ b/libwmc/tests/Makefile.am
@@ -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)
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index d2cbcb1..c29364d 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -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)
diff --git a/src/Makefile.am b/src/Makefile.am
index 6912b00..3b545ee 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -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 = \
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
index c52e4d1..0804b14 100644
--- a/src/tests/Makefile.am
+++ b/src/tests/Makefile.am
@@ -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 \
--
1.9.3
More information about the ModemManager-devel
mailing list