Merge lp:~allanlesage/indicator-session/TDD into lp:indicator-session/0.4

Proposed by Allan LeSage
Status: Merged
Approved by: Charles Kerr
Approved revision: 248
Merged at revision: 252
Proposed branch: lp:~allanlesage/indicator-session/TDD
Merge into: lp:indicator-session/0.4
Diff against target: 270 lines (+168/-7)
7 files modified
Makefile.am (+2/-0)
Makefile.am.coverage (+48/-0)
configure.ac (+18/-5)
m4/gcov.m4 (+86/-0)
src/Makefile.am (+12/-2)
src/gtk-logout-helper.c (+1/-0)
src/session-service.c (+1/-0)
To merge this branch: bzr merge lp:~allanlesage/indicator-session/TDD
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
Review via email: mp+99774@code.launchpad.net

Commit message

Added gcov coverage tooling.

Description of the change

Added gcov to build for coverage metrics.

To post a comment you must log in.
247. By Allan LeSage

Merged from trunk.

248. By Allan LeSage

Advised changes to fix implicit declarations.

Revision history for this message
Charles Kerr (charlesk) wrote :

Looks good, thanks for fixing the locale issue

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile.am'
2--- Makefile.am 2011-08-23 21:30:22 +0000
3+++ Makefile.am 2012-03-29 17:11:19 +0000
4@@ -72,3 +72,5 @@
5 @chmod +x $@
6
7 CLEANFILES = $(TESTS)
8+
9+include $(top_srcdir)/Makefile.am.coverage
10
11=== added file 'Makefile.am.coverage'
12--- Makefile.am.coverage 1970-01-01 00:00:00 +0000
13+++ Makefile.am.coverage 2012-03-29 17:11:19 +0000
14@@ -0,0 +1,48 @@
15+
16+# Coverage targets
17+
18+.PHONY: clean-gcno clean-gcda \
19+ coverage-html generate-coverage-html clean-coverage-html \
20+ coverage-gcovr generate-coverage-gcovr clean-coverage-gcovr
21+
22+clean-local: clean-gcno clean-coverage-html clean-coverage-gcovr
23+
24+if HAVE_GCOV
25+
26+clean-gcno:
27+ @echo Removing old coverage instrumentation
28+ -find -name '*.gcno' -print | xargs -r rm
29+
30+clean-gcda:
31+ @echo Removing old coverage results
32+ -find -name '*.gcda' -print | xargs -r rm
33+
34+coverage-html: clean-gcda
35+ -$(MAKE) $(AM_MAKEFLAGS) -k check
36+ $(MAKE) $(AM_MAKEFLAGS) generate-coverage-html
37+
38+generate-coverage-html:
39+ @echo Collecting coverage data
40+ $(LCOV) --directory $(top_builddir) --capture --output-file coverage.info --no-checksum --compat-libtool
41+ LANG=C $(GENHTML) --prefix $(top_builddir) --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info
42+
43+clean-coverage-html: clean-gcda
44+ -$(LCOV) --directory $(top_builddir) -z
45+ -rm -rf coverage.info coveragereport
46+
47+if HAVE_GCOVR
48+
49+coverage-gcovr: clean-gcda
50+ -$(MAKE) $(AM_MAKEFLAGS) -k check
51+ $(MAKE) $(AM_MAKEFLAGS) generate-coverage-gcovr
52+
53+generate-coverage-gcovr:
54+ @echo Generating coverage GCOVR report
55+ $(GCOVR) -x -r $(top_builddir) -o $(top_builddir)/coverage.xml
56+
57+clean-coverage-gcovr: clean-gcda
58+ -rm -rf $(top_builddir)/coverage.xml
59+
60+endif # HAVE_GCOVR
61+
62+endif # HAVE_GCOV
63
64=== modified file 'configure.ac'
65--- configure.ac 2012-03-21 16:58:29 +0000
66+++ configure.ac 2012-03-29 17:11:19 +0000
67@@ -198,6 +198,18 @@
68 AM_GLIB_GNU_GETTEXT
69
70 ###########################
71+# gcov coverage reporting
72+###########################
73+
74+m4_include([m4/gcov.m4])
75+AC_TDD_GCOV
76+AM_CONDITIONAL([HAVE_GCOV], [test "x$ac_cv_check_gcov" = xyes])
77+AM_CONDITIONAL([HAVE_LCOV], [test "x$ac_cv_check_lcov" = xyes])
78+AM_CONDITIONAL([HAVE_GCOVR], [test "x$ac_cv_check_gcovr" = xyes])
79+AC_SUBST(COVERAGE_CFLAGS)
80+AC_SUBST(COVERAGE_LDFLAGS)
81+
82+###########################
83 # Files
84 ###########################
85
86@@ -237,9 +249,10 @@
87
88 SUS Indicator Configuration:
89
90- Prefix: $prefix
91- Indicator Dir: $INDICATORDIR
92- Indicator GTK: $with_gtk
93- Logout Helper: $have_gtklogouthelper
94- APT support: $enable_apt
95+ Prefix: $prefix
96+ Indicator Dir: $INDICATORDIR
97+ Indicator GTK: $with_gtk
98+ Logout Helper: $have_gtklogouthelper
99+ APT support: $enable_apt
100+ Coverage reporting: $use_gcov
101 ])
102
103=== added directory 'm4'
104=== added file 'm4/gcov.m4'
105--- m4/gcov.m4 1970-01-01 00:00:00 +0000
106+++ m4/gcov.m4 2012-03-29 17:11:19 +0000
107@@ -0,0 +1,86 @@
108+# Checks for existence of coverage tools:
109+# * gcov
110+# * lcov
111+# * genhtml
112+# * gcovr
113+#
114+# Sets ac_cv_check_gcov to yes if tooling is present
115+# and reports the executables to the variables LCOV, GCOVR and GENHTML.
116+AC_DEFUN([AC_TDD_GCOV],
117+[
118+ AC_ARG_ENABLE(gcov,
119+ AS_HELP_STRING([--enable-gcov],
120+ [enable coverage testing with gcov]),
121+ [use_gcov=$enableval], [use_gcov=no])
122+
123+ if test "x$use_gcov" = "xyes"; then
124+ # we need gcc:
125+ if test "$GCC" != "yes"; then
126+ AC_MSG_ERROR([GCC is required for --enable-gcov])
127+ fi
128+
129+ # Check if ccache is being used
130+ AC_CHECK_PROG(SHTOOL, shtool, shtool)
131+ case `$SHTOOL path $CC` in
132+ *ccache*[)] gcc_ccache=yes;;
133+ *[)] gcc_ccache=no;;
134+ esac
135+
136+ if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then
137+ AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.])
138+ fi
139+
140+ lcov_version_list="1.6 1.7 1.8 1.9"
141+ AC_CHECK_PROG(LCOV, lcov, lcov)
142+ AC_CHECK_PROG(GENHTML, genhtml, genhtml)
143+
144+ if test "$LCOV"; then
145+ AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [
146+ glib_cv_lcov_version=invalid
147+ lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'`
148+ for lcov_check_version in $lcov_version_list; do
149+ if test "$lcov_version" = "$lcov_check_version"; then
150+ glib_cv_lcov_version="$lcov_check_version (ok)"
151+ fi
152+ done
153+ ])
154+ else
155+ lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list"
156+ AC_MSG_ERROR([$lcov_msg])
157+ fi
158+
159+ case $glib_cv_lcov_version in
160+ ""|invalid[)]
161+ lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)."
162+ AC_MSG_ERROR([$lcov_msg])
163+ LCOV="exit 0;"
164+ ;;
165+ esac
166+
167+ if test -z "$GENHTML"; then
168+ AC_MSG_ERROR([Could not find genhtml from the lcov package])
169+ fi
170+
171+ ac_cv_check_gcov=yes
172+ ac_cv_check_lcov=yes
173+
174+ # Remove all optimization flags from CFLAGS
175+ changequote({,})
176+ CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'`
177+ changequote([,])
178+
179+ # Add the special gcc flags
180+ COVERAGE_CFLAGS="-O0 -fprofile-arcs -ftest-coverage"
181+ COVERAGE_CXXFLAGS="-O0 -fprofile-arcs -ftest-coverage"
182+ COVERAGE_LDFLAGS="-lgcov"
183+
184+ # Check availability of gcovr
185+ AC_CHECK_PROG(GCOVR, gcovr, gcovr)
186+ if test -z "$GCOVR"; then
187+ ac_cv_check_gcovr=no
188+ else
189+ ac_cv_check_gcovr=yes
190+ fi
191+
192+fi
193+]) # AC_TDD_GCOV
194
195=== modified file 'src/Makefile.am'
196--- src/Makefile.am 2012-02-23 14:39:11 +0000
197+++ src/Makefile.am 2012-03-29 17:11:19 +0000
198@@ -26,10 +26,13 @@
199 accounts-service-user-client.h
200 libsession_la_CFLAGS = \
201 $(APPLET_CFLAGS) \
202+ $(COVERAGE_CFLAGS) \
203 -Wall -Werror \
204 -DG_LOG_DOMAIN=\"Indicator-Session\"
205 libsession_la_LIBADD = $(APPLET_LIBS)
206-libsession_la_LDFLAGS = -module -avoid-version
207+libsession_la_LDFLAGS = \
208+ $(COVERAGE_LDFLAGS) \
209+ -module -avoid-version
210
211 consolekit-manager-client.h: $(srcdir)/org.freedesktop.ConsoleKit.Manager.xml
212 dbus-binding-tool \
213@@ -137,11 +140,14 @@
214 -DLIBEXECDIR=\"$(libexecdir)\" \
215 -Wall -Werror \
216 -DG_LOG_DOMAIN=\"Indicator-Session\" \
217- $(GUDEV_CFLAGS)
218+ $(GUDEV_CFLAGS) \
219+ $(COVERAGE_CFLAGS)
220 indicator_session_service_LDADD = \
221 $(SESSIONSERVICE_LIBS) \
222 $(GCONF_LIBS) \
223 $(GUDEV_LIBS)
224+indicator_session_service_LDFLAGS = \
225+ $(COVERAGE_LDFLAGS)
226
227 #################
228 # GTK Logout Stuff
229@@ -159,6 +165,7 @@
230 $(SESSIONSERVICE_CFLAGS) \
231 $(GTKLOGOUTHELPER_CFLAGS) \
232 $(GCONF_CFLAGS) \
233+ $(COVERAGE_CFLAGS) \
234 -Wall -Werror \
235 -DINDICATOR_ICONS_DIR="\"$(INDICATORICONSDIR)\""
236
237@@ -166,6 +173,9 @@
238 $(SESSIONSERVICE_LIBS) \
239 $(GTKLOGOUTHELPER_LIBS) \
240 $(GCONF_LIBS)
241+
242+gtk_logout_helper_LDFLAGS = \
243+ $(COVERAGE_LDFLAGS)
244 endif
245
246
247
248=== modified file 'src/gtk-logout-helper.c'
249--- src/gtk-logout-helper.c 2011-09-27 14:52:56 +0000
250+++ src/gtk-logout-helper.c 2012-03-29 17:11:19 +0000
251@@ -22,6 +22,7 @@
252 */
253
254 #include <config.h>
255+#include <locale.h>
256 #include <glib.h>
257 #include <gtk/gtk.h>
258 #include <dbus/dbus-glib.h>
259
260=== modified file 'src/session-service.c'
261--- src/session-service.c 2012-02-01 03:21:26 +0000
262+++ src/session-service.c 2012-03-29 17:11:19 +0000
263@@ -26,6 +26,7 @@
264 #include <config.h>
265
266 #include <unistd.h>
267+#include <locale.h>
268
269 #include <glib/gi18n.h>
270 #include <gio/gio.h>

Subscribers

People subscribed via source and target branches