Nux

Merge lp:~fginther/nux/add-code-coverage into lp:nux

Proposed by Francis Ginther
Status: Merged
Approved by: Brandon Schaefer
Approved revision: 732
Merged at revision: 732
Proposed branch: lp:~fginther/nux/add-code-coverage
Merge into: lp:nux
Diff against target: 259 lines (+163/-6)
7 files modified
Makefile.am (+1/-0)
Makefile.am.coverage (+49/-0)
Nux/Makefile.am (+4/-2)
NuxCore/Makefile.am (+4/-2)
NuxGraphics/Makefile.am (+4/-2)
configure.ac (+12/-0)
m4/gcov.m4 (+89/-0)
To merge this branch: bzr merge lp:~fginther/nux/add-code-coverage
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Brandon Schaefer (community) Approve
Allan LeSage (community) Approve
Review via email: mp+138007@code.launchpad.net

Commit message

Add code coverage reporting with coverage-html and coverage-xml targets.

Coverage reporting can be enabled with --enable-gcov.

Description of the change

Add code coverage reporting with coverage-html and coverage-xml targets.

Coverage reporting can be enabled with --enable-gcov.

Testing:
 - Built coverage targets and verified results.
 - Built in pbuilder chroot with hooks to enable gcovr report.

To post a comment you must log in.
Revision history for this message
Allan LeSage (allanlesage) wrote :

* Teensy correction restores coverage for the NuxGraphics dir:

=== modified file 'NuxGraphics/Makefile.am'
--- NuxGraphics/Makefile.am 2012-12-04 19:36:00 +0000
+++ NuxGraphics/Makefile.am 2012-12-05 15:32:28 +0000
@@ -18,7 +18,7 @@
   $(NUX_GRAPHICS_CFLAGS) \
   $(MAINTAINER_CFLAGS) \
   $(GEIS_CFLAGS) \
- $(COVERAGE_FLAGS)
+ $(COVERAGE_CFLAGS)

 libnux_graphics_@NUX_API_VERSION@_la_LIBADD = \
   $(top_builddir)/NuxCore/libnux-core-@NUX_API_VERSION@.la \

* I'll attach a diff of what was necessary to get tests running FYI.

* We could consider splitting these tests into "small" and "large" but can take that up in another MP :) .

* The choice to make "make coverage-html" et.al. not depend on "make check" is evidently a considered one to which I don't object.

Approval contingent on the small correction above.

review: Approve
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

It looks good to me, but possibly making it easier to know you need to do a make check or make check-headless before running make coverage-html would be nice. Or possibly to check if no *.gcda files are found through an error message saying to run those commands.

Otherwise looks good to me :)

Revision history for this message
Francis Ginther (fginther) wrote :

> It looks good to me, but possibly making it easier to know you need to do a
> make check or make check-headless before running make coverage-html would be
> nice. Or possibly to check if no *.gcda files are found through an error
> message saying to run those commands.
>
> Otherwise looks good to me :)

Brandon, I added make check to the two main coverage targets to make it more intuitive for developers. This still allows our jenkins automation to run make check-headless via hook scripts instead of make check and collect the results with gcovr.

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Awesome, im happy with that :)

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

Sorry, Jenkins failure which should be fixed now -> reapproving.

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

It looks like Brandon did something weird in his branch and hence the conflict. I see some coverage related commits in bzr log --include-merged lp:nux ....

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

What the heck...all I did was a bzr merge...check it out, then a bzr revert...then did my own thing and pushed the other branch. I don't see how this should carry any info with it...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Makefile.am'
--- Makefile.am 2012-05-25 20:36:09 +0000
+++ Makefile.am 2012-12-06 01:28:22 +0000
@@ -2,6 +2,7 @@
22
3CXXFLAGS += -fno-permissive3CXXFLAGS += -fno-permissive
44
5include $(top_srcdir)/Makefile.am.coverage
5include doxygen-include.am6include doxygen-include.am
67
7if BUILD_DOCUMENTATION8if BUILD_DOCUMENTATION
89
=== added file 'Makefile.am.coverage'
--- Makefile.am.coverage 1970-01-01 00:00:00 +0000
+++ Makefile.am.coverage 2012-12-06 01:28:22 +0000
@@ -0,0 +1,49 @@
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:
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 $(LCOV) --extract coverage.info "$(abs_top_srcdir)/*" -o coverage.info
28 LANG=C $(GENHTML) --prefix $(top_builddir) --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info
29
30clean-coverage-html: clean-gcda
31 -$(LCOV) --directory $(top_builddir) -z
32 -rm -rf coverage.info coveragereport
33
34if HAVE_GCOVR
35
36coverage-gcovr:
37 -$(MAKE) $(AM_MAKEFLAGS) -k check
38 $(MAKE) $(AM_MAKEFLAGS) generate-coverage-gcovr
39
40generate-coverage-gcovr:
41 @echo Generating coverage GCOVR report
42 $(GCOVR) --xml -r $(top_builddir) -o $(top_builddir)/coverage.xml
43
44clean-coverage-gcovr: clean-gcda
45 -rm -rf $(top_builddir)/coverage.xml
46
47endif # HAVE_GCOVR
48
49endif # HAVE_GCOV
050
=== modified file 'Nux/Makefile.am'
--- Nux/Makefile.am 2012-11-20 22:13:38 +0000
+++ Nux/Makefile.am 2012-12-06 01:28:22 +0000
@@ -17,7 +17,8 @@
17 $(NUX_CFLAGS) \17 $(NUX_CFLAGS) \
18 $(IBUS_CFLAGS) \18 $(IBUS_CFLAGS) \
19 $(GEIS_CFLAGS) \19 $(GEIS_CFLAGS) \
20 $(MAINTAINER_CFLAGS)20 $(MAINTAINER_CFLAGS) \
21 $(COVERAGE_CFLAGS)
2122
22libnux_@NUX_API_VERSION@_la_LIBADD = \23libnux_@NUX_API_VERSION@_la_LIBADD = \
23 $(top_builddir)/NuxCore/libnux-core-@NUX_API_VERSION@.la \24 $(top_builddir)/NuxCore/libnux-core-@NUX_API_VERSION@.la \
@@ -27,7 +28,8 @@
27 $(GEIS_LIBS)28 $(GEIS_LIBS)
2829
29libnux_@NUX_API_VERSION@_la_LDFLAGS = \30libnux_@NUX_API_VERSION@_la_LDFLAGS = \
30 $(NUX_LT_LDFLAGS)31 $(NUX_LT_LDFLAGS) \
32 $(COVERAGE_LDFLAGS)
3133
32source_cpp = \34source_cpp = \
33 $(srcdir)/AbstractButton.cpp \35 $(srcdir)/AbstractButton.cpp \
3436
=== modified file 'NuxCore/Makefile.am'
--- NuxCore/Makefile.am 2012-09-12 00:52:05 +0000
+++ NuxCore/Makefile.am 2012-12-06 01:28:22 +0000
@@ -16,13 +16,15 @@
16libnux_core_@NUX_API_VERSION@_la_CPPFLAGS= \16libnux_core_@NUX_API_VERSION@_la_CPPFLAGS= \
17 $(GCC_FLAGS) \17 $(GCC_FLAGS) \
18 $(NUX_CORE_CFLAGS) \18 $(NUX_CORE_CFLAGS) \
19 $(MAINTAINER_CFLAGS)19 $(MAINTAINER_CFLAGS) \
20 $(COVERAGE_CFLAGS)
2021
21libnux_core_@NUX_API_VERSION@_la_LIBADD = \22libnux_core_@NUX_API_VERSION@_la_LIBADD = \
22 $(NUX_CORE_LIBS) -lpthread23 $(NUX_CORE_LIBS) -lpthread
2324
24libnux_core_@NUX_API_VERSION@_la_LDFLAGS = \25libnux_core_@NUX_API_VERSION@_la_LDFLAGS = \
25 $(NUX_LT_LDFLAGS)26 $(NUX_LT_LDFLAGS) \
27 $(COVERAGE_LDFLAGS)
2628
27source_cpp = \29source_cpp = \
28 $(srcdir)/Animation.cpp \30 $(srcdir)/Animation.cpp \
2931
=== modified file 'NuxGraphics/Makefile.am'
--- NuxGraphics/Makefile.am 2012-11-05 17:47:31 +0000
+++ NuxGraphics/Makefile.am 2012-12-06 01:28:22 +0000
@@ -17,7 +17,8 @@
17 $(GCC_FLAGS) \17 $(GCC_FLAGS) \
18 $(NUX_GRAPHICS_CFLAGS) \18 $(NUX_GRAPHICS_CFLAGS) \
19 $(MAINTAINER_CFLAGS) \19 $(MAINTAINER_CFLAGS) \
20 $(GEIS_CFLAGS)20 $(GEIS_CFLAGS) \
21 $(COVERAGE_CFLAGS)
2122
22libnux_graphics_@NUX_API_VERSION@_la_LIBADD = \23libnux_graphics_@NUX_API_VERSION@_la_LIBADD = \
23 $(top_builddir)/NuxCore/libnux-core-@NUX_API_VERSION@.la \24 $(top_builddir)/NuxCore/libnux-core-@NUX_API_VERSION@.la \
@@ -25,7 +26,8 @@
25 $(GEIS_LIBS)26 $(GEIS_LIBS)
2627
27libnux_graphics_@NUX_API_VERSION@_la_LDFLAGS = \28libnux_graphics_@NUX_API_VERSION@_la_LDFLAGS = \
28 $(NUX_LT_LDFLAGS)29 $(NUX_LT_LDFLAGS) \
30 $(COVERAGE_LDFLAGS)
2931
30source_h = \32source_h = \
31 $(srcdir)/BitmapFormats.h \33 $(srcdir)/BitmapFormats.h \
3234
=== modified file 'configure.ac'
--- configure.ac 2012-11-27 15:12:37 +0000
+++ configure.ac 2012-12-06 01:28:22 +0000
@@ -342,6 +342,17 @@
342342
343AM_CONDITIONAL(BUILD_TESTS, [test "x$enable_tests" = "xyes"])343AM_CONDITIONAL(BUILD_TESTS, [test "x$enable_tests" = "xyes"])
344344
345###########################
346# gcov coverage reporting
347###########################
348m4_include([m4/gcov.m4])
349AC_TDD_GCOV
350AM_CONDITIONAL([HAVE_GCOV], [test "x$ac_cv_check_gcov" = xyes])
351AM_CONDITIONAL([HAVE_LCOV], [test "x$ac_cv_check_lcov" = xyes])
352AM_CONDITIONAL([HAVE_GCOVR], [test "x$ac_cv_check_gcovr" = xyes])
353AC_SUBST(COVERAGE_CFLAGS)
354AC_SUBST(COVERAGE_LDFLAGS)
355
345dnl ===========================================================================356dnl ===========================================================================
346357
347# sets up doxygen358# sets up doxygen
@@ -485,6 +496,7 @@
485echo -e " Build Examples : ${BOLD_WHITE}${enable_examples}${RESET}"496echo -e " Build Examples : ${BOLD_WHITE}${enable_examples}${RESET}"
486echo -e " Build Gpu Tests : ${BOLD_WHITE}${enable_gputests}${RESET}"497echo -e " Build Gpu Tests : ${BOLD_WHITE}${enable_gputests}${RESET}"
487echo -e " Build Nux Tests : ${BOLD_WHITE}${enable_tests}${RESET}"498echo -e " Build Nux Tests : ${BOLD_WHITE}${enable_tests}${RESET}"
499echo -e " Coverage Reporting : ${BOLD_WHITE}${use_gcov}${RESET}"
488echo -e " Gestures support : ${BOLD_WHITE}${have_geis}${RESET}"500echo -e " Gestures support : ${BOLD_WHITE}${have_geis}${RESET}"
489echo -e " X11 build support : ${BOLD_WHITE}${enable_x_support}${RESET}"501echo -e " X11 build support : ${BOLD_WHITE}${enable_x_support}${RESET}"
490echo -e " Minimal build : ${BOLD_WHITE}${enable_minimal_build}${RESET}"502echo -e " Minimal build : ${BOLD_WHITE}${enable_minimal_build}${RESET}"
491503
=== added file 'm4/gcov.m4'
--- m4/gcov.m4 1970-01-01 00:00:00 +0000
+++ m4/gcov.m4 2012-12-06 01:28:22 +0000
@@ -0,0 +1,89 @@
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 AM_CONDITIONAL(HAVE_GCOV, test "x$use_gcov" = "xyes")
17
18 if test "x$use_gcov" = "xyes"; then
19 # we need gcc:
20 if test "$GCC" != "yes"; then
21 AC_MSG_ERROR([GCC is required for --enable-gcov])
22 fi
23
24 # Check if ccache is being used
25 AC_CHECK_PROG(SHTOOL, shtool, shtool)
26 if test "$SHTOOL"; then
27 AS_CASE([`$SHTOOL path $CC`],
28 [*ccache*], [gcc_ccache=yes],
29 [gcc_ccache=no])
30 fi
31
32 if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then
33 AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.])
34 fi
35
36 lcov_version_list="1.6 1.7 1.8 1.9"
37 AC_CHECK_PROG(LCOV, lcov, lcov)
38 AC_CHECK_PROG(GENHTML, genhtml, genhtml)
39
40 if test "$LCOV"; then
41 AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [
42 glib_cv_lcov_version=invalid
43 lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'`
44 for lcov_check_version in $lcov_version_list; do
45 if test "$lcov_version" = "$lcov_check_version"; then
46 glib_cv_lcov_version="$lcov_check_version (ok)"
47 fi
48 done
49 ])
50 else
51 lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list"
52 AC_MSG_ERROR([$lcov_msg])
53 fi
54
55 case $glib_cv_lcov_version in
56 ""|invalid[)]
57 lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)."
58 AC_MSG_ERROR([$lcov_msg])
59 LCOV="exit 0;"
60 ;;
61 esac
62
63 if test -z "$GENHTML"; then
64 AC_MSG_ERROR([Could not find genhtml from the lcov package])
65 fi
66
67 ac_cv_check_gcov=yes
68 ac_cv_check_lcov=yes
69
70 # Remove all optimization flags from CFLAGS
71 changequote({,})
72 CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'`
73 changequote([,])
74
75 # Add the special gcc flags
76 COVERAGE_CFLAGS="-O0 --coverage"
77 COVERAGE_CXXFLAGS="-O0 --coverage"
78 COVERAGE_LDFLAGS="-lgcov"
79
80 # Check availability of gcovr
81 AC_CHECK_PROG(GCOVR, gcovr, gcovr)
82 if test -z "$GCOVR"; then
83 ac_cv_check_gcovr=no
84 else
85 ac_cv_check_gcovr=yes
86 fi
87fi
88]) # AC_TDD_GCOV
89

Subscribers

People subscribed via source and target branches