build: Add coverage support
Subsystems (2)
Luiz Augusto von Dentz
maintainerPATCH 1/1 build: Add coverage support
From: Luiz Augusto von Dentz <[email protected]>
--- Makefile.am | 18 ++++++++++++++++++ acinclude.m4 | 9 +++++++++ bootstrap-configure | 1 + configure.ac | 2 ++ 4 files changed, 30 insertions(+)
Makefile.am +18 -0
@@ -331,5 +331,23 @@ lib/bluetooth/%.h: lib/%.h $(AM_V_at)$(MKDIR_P) lib/bluetooth $(AM_V_GEN)$(LN_S) -f "$(abs_top_builddir)"/$< $@ +if COVERAGE +clean-coverage: + $(RM) -r coverage + @find . -name "*.gcda" -exec $(RM) {} \; + $(LCOV) --directory . --zerocounters + +check-coverage: + @make check + $(AM_V_at)$(MKDIR_P) -p coverage + $(LCOV) --compat-libtool --directory . --capture --output-file \ + coverage/check.info + @genhtml -o coverage/ coverage/check.info + clean-local: + @make clean-coverage $(RM) -r lib/bluetooth +else +clean-local: + $(RM) -r lib/bluetooth +endif
acinclude.m4 +9 -0
@@ -51,6 +51,15 @@ AC_DEFUN([MISC_FLAGS], [ misc_ldflags="$misc_ldflags -pie" fi ]) + AC_ARG_ENABLE(coverage, AC_HELP_STRING([--enable-coverage], + [enable coverage flags]), [ + AC_PATH_PROG([LCOV], [lcov]) + if (test "$LCOV" && test "${enableval}" = "yes"); then + misc_cflags="$misc_cflags -ftest-coverage" + misc_cflags="$misc_cflags -fprofile-arcs" + misc_ldflags="$misc_ldflags -gcov" + fi + ]) AC_SUBST([MISC_CFLAGS], $misc_cflags) AC_SUBST([MISC_LDFLAGS], $misc_ldflags) ])
bootstrap-configure +1 -0
@@ -14,4 +14,5 @@ fi --enable-experimental \ --enable-android \ --enable-sixaxis \ + --enable-coverage \ --disable-datafiles $*
configure.ac +2 -0
@@ -252,4 +252,6 @@ AC_ARG_ENABLE(android, AC_HELP_STRING([--enable-android], [enable_android=${enableval}]) AM_CONDITIONAL(ANDROID, test "${enable_android}" = "yes") +AM_CONDITIONAL([COVERAGE], [test "$LCOV"]) + AC_OUTPUT(Makefile src/bluetoothd.8 lib/bluez.pc)
Signature · 1 line
1.8.3.1
Marcel Holtmann
maintainerHi Luiz,
Quoted 14 lines
From: Luiz Augusto von Dentz <[email protected]>
---
Makefile.am | 18 ++++++++++++++++++ acinclude.m4 | 9 +++++++++ bootstrap-configure | 1 + configure.ac | 2 ++ 4 files changed, 30 insertions(+)Makefile.am +0
-0
Makefile.am lib/bluetooth/%.h: lib/%.h · line 334
Quoted 4 lines
Makefile.am +1
-0@@ -331,5 +331,23 @@ lib/bluetooth/%.h: lib/%.h $(AM_V_at)$(MKDIR_P) lib/bluetooth $(AM_V_GEN)$(LN_S) -f "$(abs_top_builddir)"/$< $@ +if COVERAGE
maybe we should just make this depend on maintainer-mode.
Quoted 54 lines
Makefile.am +12
-0+clean-coverage: + $(RM) -r coverage + @find . -name "*.gcda" -exec $(RM) {} \; + $(LCOV) --directory . --zerocounters + +check-coverage: + @make check + $(AM_V_at)$(MKDIR_P) -p coverage + $(LCOV) --compat-libtool --directory . --capture --output-file \ + coverage/check.info + @genhtml -o coverage/ coverage/check.info +clean-local:
Makefile.am +1
-0+ @make clean-coverage$(RM) -r lib/bluetoothMakefile.am +4
-0+else +clean-local: + $(RM) -r lib/bluetooth +endifacinclude.m4 +9
-0@@ -51,6 +51,15 @@ AC_DEFUN([MISC_FLAGS], [ misc_ldflags="$misc_ldflags -pie" fi ]) + AC_ARG_ENABLE(coverage, AC_HELP_STRING([--enable-coverage], + [enable coverage flags]), [ + AC_PATH_PROG([LCOV], [lcov]) + if (test "$LCOV" && test "${enableval}" = "yes"); then + misc_cflags="$misc_cflags -ftest-coverage" + misc_cflags="$misc_cflags -fprofile-arcs" + misc_ldflags="$misc_ldflags -gcov" + fi + ]) AC_SUBST([MISC_CFLAGS], $misc_cflags) AC_SUBST([MISC_LDFLAGS], $misc_ldflags) ])bootstrap-configure +1
-0@@ -14,4 +14,5 @@ fi --enable-experimental \ --enable-android \ --enable-sixaxis \ + --enable-coverage \ --disable-datafiles $*configure.ac +0
-0
configure.ac AC_ARG_ENABLE(android, AC_HELP_STRING([--enable-android], · line 255
Quoted 4 lines
configure.ac +1
-0@@ -252,4 +252,6 @@ AC_ARG_ENABLE(android, AC_HELP_STRING([--enable-android], [enable_android=${enableval}]) AM_CONDITIONAL(ANDROID, test "${enable_android}" = "yes") +AM_CONDITIONAL([COVERAGE], [test "$LCOV”])
I do not like this one. The test should check enable_xxx variables. I rather have configure abort with error if some programs or dependencies are not found.
Regards
Marcel
Luiz Augusto von Dentz
maintainerHi Marcel,
On Wed, Dec 11, 2013 at 2:00 PM, Marcel Holtmann <[email protected]> wrot= e:
Quoted 19 lines
Hi Luiz,
Quoted 17 lines
From: Luiz Augusto von Dentz <[email protected]>
---
Makefile.am | 18 ++++++++++++++++++ acinclude.m4 | 9 +++++++++ bootstrap-configure | 1 + configure.ac | 2 ++ 4 files changed, 30 insertions(+)Makefile.am +0
-0@@ -331,5 +331,23 @@ lib/bluetooth/%.h: lib/%.h $(AM_V_at)$(MKDIR_P) lib/bluetooth $(AM_V_GEN)$(LN_S) -f "$(abs_top_builddir)"/$< $@
Quoted 3 lines
Makefile.am lib/bluetooth/%.h: lib/%.h · line 334
Quoted 1 line
Makefile.am +1
-0+if COVERAGEmaybe we should just make this depend on maintainer-mode.
We could, but I suggest you do a quick run with this version to see if it is acceptable for maintainer-mode since it does increase quite a bit the build time for me so perhaps we should keep it separately.
Quoted 10 lines
Makefile.am lib/bluetooth/%.h: lib/%.h
Quoted 10 lines
Makefile.am +10
-0+clean-coverage: + $(RM) -r coverage + @find . -name "*.gcda" -exec $(RM) {} \; + $(LCOV) --directory . --zerocounters + +check-coverage: + @make check + $(AM_V_at)$(MKDIR_P) -p coverage + $(LCOV) --compat-libtool --directory . --capture --output-file \ + coverage/check.inf=
o
Quoted 36 lines
Quoted 36 lines
Makefile.am +2
-0+ @genhtml -o coverage/ coverage/check.info +clean-local:
Makefile.am +5
-0+ @make clean-coverage $(RM) -r lib/bluetooth +else +clean-local: + $(RM) -r lib/bluetooth +endifacinclude.m4 +9
-0@@ -51,6 +51,15 @@ AC_DEFUN([MISC_FLAGS], [ misc_ldflags=3D"$misc_ldflags -pie" fi ]) + AC_ARG_ENABLE(coverage, AC_HELP_STRING([--enable-coverage], + [enable coverage flags]), [ + AC_PATH_PROG([LCOV], [lcov]) + if (test "$LCOV" && test "${enableval}" =3D "yes"); then + misc_cflags=3D"$misc_cflags -ftest-coverage" + misc_cflags=3D"$misc_cflags -fprofile-arcs" + misc_ldflags=3D"$misc_ldflags -gcov" + fi + ]) AC_SUBST([MISC_CFLAGS], $misc_cflags) AC_SUBST([MISC_LDFLAGS], $misc_ldflags) ])bootstrap-configure +0
-0@@ -14,4 +14,5 @@ fi --enable-experimental \ --enable-android \
Quoted 8 lines
configure.ac AC_ARG_ENABLE(android, AC_HELP_STRING([--enable-andr=
Quoted 8 lines
bootstrap-configure +1
-0--enable-sixaxis \ + --enable-coverage \ --disable-datafiles $*configure.ac +0
-0@@ -252,4 +252,6 @@ AC_ARG_ENABLE(android, AC_HELP_STRING([--enable-andr=
oid],
Quoted 6 lines
configure.ac AC_ARG_ENABLE(android, AC_HELP_STRING([--enable-andr= · line 255
Quoted 4 lines
configure.ac +1
-0[enable_android=3D${enableval}]) AM_CONDITIONAL(ANDROID, test "${enable_android}" =3D "yes") +AM_CONDITIONAL([COVERAGE], [test "$LCOV=94])I do not like this one. The test should check
enable_xxxvariables. I rat=
her have configure abort with error if some programs or dependencies are no= t found.
Okay, Ive named it LCOV because it actually checks for lcov binary and then uses it in Makefile.am at check-coverage and clean-coverage, it comes from AC_PATH_PROG([LCOV], [lcov]). I can do AC_MSG_ERROR if lcov is not found, is that how you want it? I couldn't make AM_CONDITIONAL within MISC_FLAGS that why Ive moved it to configure.ac. --=20
Luiz Augusto von Dentz
Marcel Holtmann
maintainerHi Luiz,
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
From: Luiz Augusto von Dentz <[email protected]>
---
Makefile.am | 18 ++++++++++++++++++ acinclude.m4 | 9 +++++++++ bootstrap-configure | 1 + configure.ac | 2 ++ 4 files changed, 30 insertions(+)Makefile.am +0
-0@@ -331,5 +331,23 @@ lib/bluetooth/%.h: lib/%.h $(AM_V_at)$(MKDIR_P) lib/bluetooth $(AM_V_GEN)$(LN_S) -f "$(abs_top_builddir)"/$< $@
Quoted 7 lines
Quoted 3 lines
Makefile.am lib/bluetooth/%.h: lib/%.h · line 334
Quoted 1 line
Makefile.am +1
-0+if COVERAGEmaybe we should just make this depend on maintainer-mode.
We could, but I suggest you do a quick run with this version to see if it is acceptable for maintainer-mode since it does increase quite a bit the build time for me so perhaps we should keep it separately.
let see how bad it actually is.
Quoted 61 lines
Quoted 57 lines
Quoted 57 lines
Makefile.am +12
-0+clean-coverage: + $(RM) -r coverage + @find . -name "*.gcda" -exec $(RM) {} \; + $(LCOV) --directory . --zerocounters + +check-coverage: + @make check + $(AM_V_at)$(MKDIR_P) -p coverage + $(LCOV) --compat-libtool --directory . --capture --output-file \ + coverage/check.info + @genhtml -o coverage/ coverage/check.info +clean-local:
Makefile.am +5
-0+ @make clean-coverage $(RM) -r lib/bluetooth +else +clean-local: + $(RM) -r lib/bluetooth +endifacinclude.m4 +9
-0@@ -51,6 +51,15 @@ AC_DEFUN([MISC_FLAGS], [ misc_ldflags="$misc_ldflags -pie" fi ]) + AC_ARG_ENABLE(coverage, AC_HELP_STRING([--enable-coverage], + [enable coverage flags]), [ + AC_PATH_PROG([LCOV], [lcov]) + if (test "$LCOV" && test "${enableval}" = "yes"); then + misc_cflags="$misc_cflags -ftest-coverage" + misc_cflags="$misc_cflags -fprofile-arcs" + misc_ldflags="$misc_ldflags -gcov" + fi + ]) AC_SUBST([MISC_CFLAGS], $misc_cflags) AC_SUBST([MISC_LDFLAGS], $misc_ldflags) ])bootstrap-configure +1
-0@@ -14,4 +14,5 @@ fi --enable-experimental \ --enable-android \ --enable-sixaxis \ + --enable-coverage \ --disable-datafiles $*configure.ac +0
-0@@ -252,4 +252,6 @@ AC_ARG_ENABLE(android, AC_HELP_STRING([--enable-android], [enable_android=${enableval}]) AM_CONDITIONAL(ANDROID, test "${enable_android}" = "yes")Quoted 3 lines
configure.ac AC_ARG_ENABLE(android, AC_HELP_STRING([--enable-android], · line 255
Quoted 1 line
configure.ac +1
-0+AM_CONDITIONAL([COVERAGE], [test "$LCOV”])I do not like this one. The test should check
enable_xxxvariables. I rather have configure abort with error if some programs or dependencies are not found.
Quoted 5 lines
Okay, Ive named it LCOV because it actually checks for lcov binary and then uses it in Makefile.am at check-coverage and clean-coverage, it comes from
AC_PATH_PROG([LCOV], [lcov]). I can doAC_MSG_ERRORif lcov is not found, is that how you want it? I couldn't makeAM_CONDITIONALwithinMISC_FLAGSthat why Ive moved it to configure.ac.
Yes. Just error out and abort configure.
Regards
Marcel
Hi Luiz,
Quoted 5 lines · Luiz Augusto von Dentz
acinclude.m4 +0
-0@@ -51,6 +51,15 @@ AC_DEFUN([MISC_FLAGS], [ misc_ldflags="$misc_ldflags -pie" fi
acinclude.m4 AC_DEFUN([MISC_FLAGS], [ · line 62
Quoted 10 lines
acinclude.m4 +9
-0]) + AC_ARG_ENABLE(coverage, AC_HELP_STRING([--enable-coverage], + [enable coverage flags]), [ + AC_PATH_PROG([LCOV], [lcov]) + if (test "$LCOV" && test "${enableval}" = "yes"); then + misc_cflags="$misc_cflags -ftest-coverage" + misc_cflags="$misc_cflags -fprofile-arcs" + misc_ldflags="$misc_ldflags -gcov" + fi + ])
I believe the current recommended (or at least simpler) way to enable coverage is to use "--coverage" option (both as CFLAGS and LDFLAGS), instead of separate -ftest-coverage/-fprofile-arcs/-gcov options. Check "man gcc" for details.
acinclude.m4 AC_DEFUN([MISC_FLAGS], [ · line 65
Quoted 3 lines
acinclude.m4 +0
-0AC_SUBST([MISC_CFLAGS], $misc_cflags) AC_SUBST([MISC_LDFLAGS], $misc_ldflags) ])
Best Regards,
Signature · 3 lines
Anderson Lizardo Instituto Nokia de Tecnologia - INdT Manaus - Brazil