Merge lp:~allanlesage/indicator-bluetooth/add-coverage-tooling into lp:indicator-bluetooth/13.10

Proposed by Allan LeSage
Status: Work in progress
Proposed branch: lp:~allanlesage/indicator-bluetooth/add-coverage-tooling
Merge into: lp:indicator-bluetooth/13.10
Diff against target: 217 lines (+158/-3)
5 files modified
Makefile.am (+2/-0)
Makefile.am.coverage (+48/-0)
configure.ac (+13/-0)
m4/gcov.m4 (+86/-0)
src/Makefile.am (+9/-3)
To merge this branch: bzr merge lp:~allanlesage/indicator-bluetooth/add-coverage-tooling
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Charles Kerr (community) Needs Fixing
Review via email: mp+179299@code.launchpad.net

Commit message

Add gcov coverage tooling.

Description of the change

Here comes alesage brandishing the familiar hammer! Add gcov tooling; do ./autogen.sh --enable-gcov and then make coverage-html to see test coverage, more rationale in this old blog post: http://qualityhour.wordpress.com/2012/01/29/test-coverage-tutorial-for-cc-autotools-projects/ .

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote :

alesage, the familiar hammer looks fine but it's hitting the wrong anvil. Could you apply this on top of lp:~charlesk/indicator-bluetooth/gmenuify and have this depend on that merge? Otherwise we're going to get conflicts in configure.ac and src/Makefile.am.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Unmerged revisions

53. By Allan LeSage

Add coverage tooling.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Makefile.am'
--- Makefile.am 2012-12-06 02:58:44 +0000
+++ Makefile.am 2013-08-08 22:48:20 +0000
@@ -3,3 +3,5 @@
3EXTRA_DIST = autogen.sh NEWS3EXTRA_DIST = autogen.sh NEWS
44
5DISTCHECK_CONFIGURE_FLAGS = --enable-localinstall5DISTCHECK_CONFIGURE_FLAGS = --enable-localinstall
6
7include $(top_srcdir)/Makefile.am.coverage
68
=== added file 'Makefile.am.coverage'
--- Makefile.am.coverage 1970-01-01 00:00:00 +0000
+++ Makefile.am.coverage 2013-08-08 22:48:20 +0000
@@ -0,0 +1,48 @@
1
2# Coverage targets
3
4.PHONY: clean-gcno clean-gcda \
5 coverage-html generate-coverage-html clean-coverage-html \
6 coverage-gcovr generate-coverage-gcovr clean-coverage-gcovr
7
8clean-local: clean-gcno clean-coverage-html clean-coverage-gcovr
9
10if HAVE_GCOV
11
12clean-gcno:
13 @echo Removing old coverage instrumentation
14 -find -name '*.gcno' -print | xargs -r rm
15
16clean-gcda:
17 @echo Removing old coverage results
18 -find -name '*.gcda' -print | xargs -r rm
19
20coverage-html: clean-gcda
21 -$(MAKE) $(AM_MAKEFLAGS) -k check
22 $(MAKE) $(AM_MAKEFLAGS) generate-coverage-html
23
24generate-coverage-html:
25 @echo Collecting coverage data
26 $(LCOV) --directory $(top_builddir) --capture --output-file coverage.info --no-checksum --compat-libtool
27 LANG=C $(GENHTML) --prefix $(top_builddir) --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info
28
29clean-coverage-html: clean-gcda
30 -$(LCOV) --directory $(top_builddir) -z
31 -rm -rf coverage.info coveragereport
32
33if HAVE_GCOVR
34
35coverage-gcovr: clean-gcda
36 -$(MAKE) $(AM_MAKEFLAGS) -k check
37 $(MAKE) $(AM_MAKEFLAGS) generate-coverage-gcovr
38
39generate-coverage-gcovr:
40 @echo Generating coverage GCOVR report
41 $(GCOVR) -x -r $(top_builddir) -o $(top_builddir)/coverage.xml
42
43clean-coverage-gcovr: clean-gcda
44 -rm -rf $(top_builddir)/coverage.xml
45
46endif # HAVE_GCOVR
47
48endif # HAVE_GCOV
049
=== modified file 'configure.ac'
--- configure.ac 2013-02-11 21:47:09 +0000
+++ configure.ac 2013-08-08 22:48:20 +0000
@@ -62,6 +62,19 @@
62fi62fi
63AC_SUBST(DBUSSERVICEDIR)63AC_SUBST(DBUSSERVICEDIR)
6464
65dnl #########################
66dnl gcov coverage reporting
67dnl #########################
68
69m4_include([m4/gcov.m4])
70AC_TDD_GCOV
71AM_CONDITIONAL([HAVE_GCOV], [test "x$ac_cv_check_gcov" = xyes])
72AM_CONDITIONAL([HAVE_LCOV], [test "x$ac_cv_check_lcov" = xyes])
73AM_CONDITIONAL([HAVE_GCOVR], [test "x$ac_cv_check_gcovr" = xyes])
74AC_SUBST(COVERAGE_CFLAGS)
75AC_SUBST(COVERAGE_CXXFLAGS)
76AC_SUBST(COVERAGE_LDFLAGS)
77
65dnl ###########################################################################78dnl ###########################################################################
66dnl Files to generate79dnl Files to generate
67dnl ###########################################################################80dnl ###########################################################################
6881
=== added directory 'm4'
=== added file 'm4/gcov.m4'
--- m4/gcov.m4 1970-01-01 00:00:00 +0000
+++ m4/gcov.m4 2013-08-08 22:48:20 +0000
@@ -0,0 +1,86 @@
1# Checks for existence of coverage tools:
2# * gcov
3# * lcov
4# * genhtml
5# * gcovr
6#
7# Sets ac_cv_check_gcov to yes if tooling is present
8# and reports the executables to the variables LCOV, GCOVR and GENHTML.
9AC_DEFUN([AC_TDD_GCOV],
10[
11 AC_ARG_ENABLE(gcov,
12 AS_HELP_STRING([--enable-gcov],
13 [enable coverage testing with gcov]),
14 [use_gcov=$enableval], [use_gcov=no])
15
16 if test "x$use_gcov" = "xyes"; then
17 # we need gcc:
18 if test "$GCC" != "yes"; then
19 AC_MSG_ERROR([GCC is required for --enable-gcov])
20 fi
21
22 # Check if ccache is being used
23 AC_CHECK_PROG(SHTOOL, shtool, shtool)
24 case `$SHTOOL path $CC` in
25 *ccache*[)] gcc_ccache=yes;;
26 *[)] gcc_ccache=no;;
27 esac
28
29 if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then
30 AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.])
31 fi
32
33 lcov_version_list="1.6 1.7 1.8 1.9"
34 AC_CHECK_PROG(LCOV, lcov, lcov)
35 AC_CHECK_PROG(GENHTML, genhtml, genhtml)
36
37 if test "$LCOV"; then
38 AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [
39 glib_cv_lcov_version=invalid
40 lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'`
41 for lcov_check_version in $lcov_version_list; do
42 if test "$lcov_version" = "$lcov_check_version"; then
43 glib_cv_lcov_version="$lcov_check_version (ok)"
44 fi
45 done
46 ])
47 else
48 lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list"
49 AC_MSG_ERROR([$lcov_msg])
50 fi
51
52 case $glib_cv_lcov_version in
53 ""|invalid[)]
54 lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)."
55 AC_MSG_ERROR([$lcov_msg])
56 LCOV="exit 0;"
57 ;;
58 esac
59
60 if test -z "$GENHTML"; then
61 AC_MSG_ERROR([Could not find genhtml from the lcov package])
62 fi
63
64 ac_cv_check_gcov=yes
65 ac_cv_check_lcov=yes
66
67 # Remove all optimization flags from CFLAGS
68 changequote({,})
69 CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'`
70 changequote([,])
71
72 # Add the special gcc flags
73 COVERAGE_CFLAGS="-O0 -fprofile-arcs -ftest-coverage"
74 COVERAGE_CXXFLAGS="-O0 -fprofile-arcs -ftest-coverage"
75 COVERAGE_LDFLAGS="-lgcov"
76
77 # Check availability of gcovr
78 AC_CHECK_PROG(GCOVR, gcovr, gcovr)
79 if test -z "$GCOVR"; then
80 ac_cv_check_gcovr=no
81 else
82 ac_cv_check_gcovr=yes
83 fi
84
85fi
86]) # AC_TDD_GCOV
087
=== modified file 'src/Makefile.am'
--- src/Makefile.am 2013-02-06 03:16:55 +0000
+++ src/Makefile.am 2013-08-08 22:48:20 +0000
@@ -17,11 +17,15 @@
17indicator_bluetooth_service_CFLAGS = \17indicator_bluetooth_service_CFLAGS = \
18 -DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \18 -DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \
19 -DLOCALE_DIR=\"$(datadir)/locale\" \19 -DLOCALE_DIR=\"$(datadir)/locale\" \
20 $(INDICATOR_BLUETOOTH_SERVICE_CFLAGS)20 $(INDICATOR_BLUETOOTH_SERVICE_CFLAGS) \
21 $(COVERAGE_CFLAGS)
2122
22indicator_bluetooth_service_LDADD = \23indicator_bluetooth_service_LDADD = \
23 $(INDICATOR_BLUETOOTH_SERVICE_LIBS)24 $(INDICATOR_BLUETOOTH_SERVICE_LIBS)
2425
26indicator_bluetooth_service_LDFLAGS = \
27 $(COVERAGE_LDFLAGS)
28
25libbluetooth_la_SOURCES = \29libbluetooth_la_SOURCES = \
26 config.vapi \30 config.vapi \
27 indicator3-0.4.vapi \31 indicator3-0.4.vapi \
@@ -37,13 +41,15 @@
3741
38libbluetooth_la_CFLAGS = \42libbluetooth_la_CFLAGS = \
39 -DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \43 -DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \
40 $(INDICATOR_BLUETOOTH_CFLAGS)44 $(INDICATOR_BLUETOOTH_CFLAGS) \
45 $(COVERAGE_CFLAGS)
4146
42libbluetooth_la_LIBADD = \47libbluetooth_la_LIBADD = \
43 $(INDICATOR_BLUETOOTH_LIBS)48 $(INDICATOR_BLUETOOTH_LIBS)
4449
45libbluetooth_la_LDFLAGS = \50libbluetooth_la_LDFLAGS = \
46 -module -avoid-version51 -module -avoid-version \
52 $(COVERAGE_LDFLAGS)
4753
48CLEANFILES = \54CLEANFILES = \
49 $(patsubst %.vala,%.c,$(filter %.vala, $(SOURCES))) \55 $(patsubst %.vala,%.c,$(filter %.vala, $(SOURCES))) \

Subscribers

People subscribed via source and target branches