diff options
author | Rob Bradford <rob@linux.intel.com> | 2010-09-02 10:18:09 +0100 |
---|---|---|
committer | Rob Bradford <rob@linux.intel.com> | 2010-09-02 10:25:00 +0100 |
commit | 4e7ae7faadaa9039511f21eb2431f5c9dcee0668 (patch) | |
tree | 94fb65c8055e43ed8f3633b005ed107a336d3dae | |
parent | 661d0cfc5efc340086072c9d94626fda46fc471a (diff) |
build: Enable test code coverage analysis
-rw-r--r-- | Makefile.am | 21 | ||||
-rw-r--r-- | configure.ac | 29 | ||||
-rw-r--r-- | rest-extras/Makefile.am | 7 | ||||
-rw-r--r-- | rest/Makefile.am | 9 | ||||
-rw-r--r-- | tests/Makefile.am | 5 |
5 files changed, 62 insertions, 9 deletions
diff --git a/Makefile.am b/Makefile.am index b0ca214..928587e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -11,3 +11,24 @@ CLEANFILES = $(pkgconfig_DATA) DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc ACLOCAL_AMFLAGS = -I build + +if GCOV_ENABLED +cov-reset: + @rm -fr coverage + @find . -name "*.gcda" -exec rm {} \; + @lcov --directory . --zerocounters + +cov-report: + @mkdir -p coverage + @lcov --compat-libtool --directory . --capture --output-file coverage/app.info + @genhtml -o coverage/ coverage/app.info + +cov: + @make cov-report + +clean-local: + @make cov-reset + +check: + @make cov +endif diff --git a/configure.ac b/configure.ac index af6ced2..3396a28 100644 --- a/configure.ac +++ b/configure.ac @@ -65,6 +65,35 @@ GOBJECT_INTROSPECTION_CHECK([0.6.7]) localedir=${datadir}/locale AC_SUBST(localedir) +dnl === Coverage report ======================================================= +AC_PATH_PROG([GCOV], [lcov], [enable_gcov=no]) + +AC_MSG_CHECKING([whether to build with gcov testing]) + +AC_ARG_ENABLE([gcov], + [AS_HELP_STRING([--enable-gcov], + [Whether to enable coverage testing (requires gcc +and lcov)])], + [], + [enable_gcov=no]) + +AS_IF([test "x$enable_gcov" = "xyes" && test "x$GCC" = "xyes"], + [ + AS_IF([test "x$enable_gtk_doc" = "xyes"], + [AC_MSG_WARN([gtk-doc is enabled, this may go horribly wrong])], + [AC_MSG_RESULT([yes])] + ) + + GCOV_CFLAGS="-g -O0 -fprofile-arcs -ftest-coverage" + GCOV_LDFLAGS="-lgcov" + ], + [AC_MSG_RESULT([no])] +) + +AM_CONDITIONAL([GCOV_ENABLED], [test "x$enable_gcov" = "xyes"]) +AC_SUBST([GCOV_CFLAGS]) +AC_SUBST([GCOV_LDFLAGS]) + AC_OUTPUT([ Makefile rest/Makefile diff --git a/rest-extras/Makefile.am b/rest-extras/Makefile.am index 9f69e95..e6a25b9 100644 --- a/rest-extras/Makefile.am +++ b/rest-extras/Makefile.am @@ -17,10 +17,11 @@ lib_headers = \ lib_LTLIBRARIES = librest-extras-@API_VERSION@.la librest_extras_@API_VERSION@_la_CFLAGS = $(GLIB_CFLAGS) $(GTHREAD_CFLAGS) \ $(SOUP_CFLAGS) $(SOUP_GNOME_CFLAGS) \ - $(XML_CFLAGS) \ + $(XML_CFLAGS) $(GCOV_CFLAGS) \ -I$(top_srcdir) -Wall -DG_LOG_DOMAIN=\"Rest\" librest_extras_@API_VERSION@_la_LIBADD = $(GLIB_LIBS) $(GTHREAD_LIBS) \ $(SOUP_LIBS) $(SOUP_GNOME_LIBS) $(XML_LIBS) \ + $(GCOV_LDFLAGS) \ $(top_builddir)/rest/librest-@API_VERSION@.la librest_extras_@API_VERSION@_la_SOURCES = $(lib_sources) $(lib_headers) librest_extras_@API_VERSION@_la_HEADERS = $(lib_headers) @@ -32,8 +33,8 @@ TESTS = test-runner check_PROGRAMS = test-runner test_runner_SOURCES = test-runner.c $(lib_sources) $(lib_headers) -test_runner_CFLAGS = -DBUILD_TESTS $(librest_extras_@API_VERSION@_la_CFLAGS) -test_runner_LDFLAGS = $(librest_extras_@API_VERSION@_la_LIBADD) +test_runner_CFLAGS = -DBUILD_TESTS $(librest_extras_@API_VERSION@_la_CFLAGS) $(GCOV_CFLAGS) +test_runner_LDFLAGS = $(librest_extras_@API_VERSION@_la_LIBADD) $(GCOV_LIBS) # TODO: use gtester diff --git a/rest/Makefile.am b/rest/Makefile.am index e0ca664..4455410 100644 --- a/rest/Makefile.am +++ b/rest/Makefile.am @@ -33,10 +33,11 @@ lib_headers = \ lib_LTLIBRARIES = librest-@API_VERSION@.la librest_@API_VERSION@_la_CFLAGS = $(GLIB_CFLAGS) $(GTHREAD_CFLAGS) \ $(SOUP_CFLAGS) $(SOUP_GNOME_CFLAGS) \ - $(XML_CFLAGS) \ + $(XML_CFLAGS) $(GCOV_CFLAGS) \ -I$(top_srcdir) -Wall -DG_LOG_DOMAIN=\"Rest\" librest_@API_VERSION@_la_LIBADD = $(GLIB_LIBS) $(GTHREAD_LIBS) \ - $(SOUP_LIBS) $(SOUP_GNOME_LIBS) $(XML_LIBS) + $(SOUP_LIBS) $(SOUP_GNOME_LIBS) $(XML_LIBS) \ + $(GCOV_LDFLAGS) librest_@API_VERSION@_la_SOURCES = $(lib_sources) $(lib_headers) librest_@API_VERSION@_la_HEADERS = $(lib_headers) librest_@API_VERSION@_ladir = $(includedir)/rest-@API_VERSION@/rest @@ -47,8 +48,8 @@ TESTS = test-runner check_PROGRAMS = test-runner test_runner_SOURCES = test-runner.c $(lib_sources) $(lib_headers) -test_runner_CFLAGS = -DBUILD_TESTS $(librest_@API_VERSION@_la_CFLAGS) -test_runner_LDFLAGS = $(librest_@API_VERSION@_la_LIBADD) +test_runner_CFLAGS = -DBUILD_TESTS $(librest_@API_VERSION@_la_CFLAGS) $(GCOV_CFLAGS) +test_runner_LDFLAGS = $(librest_@API_VERSION@_la_LIBADD) $(GCOV_LDFLAGS) # TODO: use gtester diff --git a/tests/Makefile.am b/tests/Makefile.am index 8a02588..0093264 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,7 +1,8 @@ TESTS = proxy threaded oauth oauth-async oauth2 flickr lastfm -AM_CPPFLAGS = $(SOUP_CFLAGS) -I$(top_srcdir) -AM_LDFLAGS = $(SOUP_LIBS) ../rest/librest-@API_VERSION@.la ../rest-extras/librest-extras-@API_VERSION@.la +AM_CPPFLAGS = $(SOUP_CFLAGS) -I$(top_srcdir) $(GCOV_CFLAGS) +AM_LDFLAGS = $(SOUP_LIBS) $(GCOV_LDFLAGS) \ + ../rest/librest-@API_VERSION@.la ../rest-extras/librest-extras-@API_VERSION@.la check_PROGRAMS = $(TESTS) |