[Spice-devel] gcov code coverage integration to build system

Submitted by David Jaša on Dec. 17, 2012, 10:47 a.m.

Details

Message ID 1355741261.3499.1196.camel@dhcp-29-7.brq.redhat.com
State New
Headers show

Not browsing as part of any series.

Commit Message

David Jaša Dec. 17, 2012, 10:47 a.m.
Hi,

I'm trying to integrate gcov directly into (spice-common & spice-server)
according to the tutorial at:
https://qualityhour.wordpress.com/2012/01/29/test-coverage-tutorial-for-cc-autotools-projects/

and it sort of works, if I add the gcov.m4 file to m4/ subdirectories
and patch configure.ac files of spice/server and spice-common, the
code-coverage-related files do get built.

The problem is that these files do get generated also when --enable-gcov
is not specified or when --disable-gcov is specified - and I have no
idea if other flags have been overriden (-O2 -> -O0 mainly) as well in
that case.

When I tried to put AC_SUBST(COVERAGE_*FLAGS) to conditional, configure
then failed on empty if, putting all the lines to conditional made
configure fail in other ways...

What am I missing in order to make --(enable|disable)-gcov work as
expected?

FWIW, the pathes to configure.ac and *Makefile.am look like this:

spice-server:

Patch hide | download patch | download mbox

diff --git a/configure.ac b/configure.ac
index fc0216f..bcb7ebf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -429,6 +429,12 @@  if test "x$enable_automated_tests" = "xyes"; then
     AC_MSG_RESULT([found])
 fi
 
+# conditionals should be handled inside of the included macro
+m4_include([m4/gcov.m4])
+AC_TDD_GCOV
+AC_SUBST(COVERAGE_CFLAGS)
+AC_SUBST(COVERAGE_LDFLAGS)
+
 dnl ===========================================================================
 dnl check compiler flags
 
diff --git a/server/Makefile.am b/server/Makefile.am
index 4e5f18a..b52fb8d 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -3,6 +3,7 @@  SUBDIRS = . tests
 
 AM_CPPFLAGS =                                  \
        -DRED_STATISTICS                        \
+       $(COVERAGE_CFLAGS)                      \
        $(CELT051_CFLAGS)                       \
        $(COMMON_CFLAGS)                        \
        $(GLIB2_CFLAGS)                         \
@@ -18,6 +19,7 @@  AM_CPPFLAGS =                                 \
 lib_LTLIBRARIES = libspice-server.la
 
 libspice_server_la_LDFLAGS =                   \
+       $(COVERAGE_LDFLAGS)                     \
        -version-info $(SPICE_LT_VERSION)       \
        -no-undefined                           \
        $(NULL)




spice-common:

diff --git a/common/Makefile.am b/common/Makefile.am
index 91a7d48..be4329f 100644
--- a/common/Makefile.am
+++ b/common/Makefile.am
@@ -65,7 +65,10 @@  libspice_common_server_la_SOURCES =          \
        $(SERVER_MARSHALLERS)                   \
        $(NULL)
 
-libspice_common_server_la_CFLAGS = -DFIXME_SERVER_SMARTCARD
+libspice_common_server_la_CFLAGS =     \
+       -DFIXME_SERVER_SMARTCARD        \
+       $(COVERAGE_CFLAGS)              \
+       $(NULL)
 
 if SUPPORT_GL
 libspice_common_la_SOURCES +=          \
diff --git a/configure.ac b/configure.ac
index c4b0f08..84dc009 100644
--- a/configure.ac
+++ b/configure.ac
@@ -67,6 +67,12 @@  fi
 AC_SUBST(GL_CFLAGS)
 AC_SUBST(GL_LIBS)
 
+# conditionals are handled inside of the included macro
+m4_include([m4/gcov.m4])
+AC_TDD_GCOV
+AC_SUBST(COVERAGE_CFLAGS)
+AC_SUBST(COVERAGE_LDFLAGS)
+
 # Checks for header files
 AC_PATH_X
 AC_FUNC_ALLOCA