build: Add coverage support
Subsystems (2)
Luiz Augusto von Dentz
maintainerPATCH v2 1/1 build: Add coverage support
From: Luiz Augusto von Dentz <[email protected]>
Coverage is enabled with --enable-maintainer-mode, 2 new targets are added 'coverage' and 'clean-coverage', the first generate the reports using lcov and depend on the second to cleanup previous generated reports and .gcda files.
--- .gitignore | 4 ++++ Makefile.am | 18 ++++++++++++++++++ acinclude.m4 | 4 ++++ configure.ac | 4 ++++ 4 files changed, 30 insertions(+)
.gitignore +4 -0
@@ -3,6 +3,8 @@ *.lo *.la *.so +*.gcno +*.gcda .deps .libs .dirstamp
@@ -27,7 +29,9 @@ stamp-h1 autom4te.cache test-driver test-suite.log +coverage.info +coverage lib/bluez.pc lib/bluetooth src/builtin.h
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 MAINTAINER_MODE +clean-coverage: + -find $(top_builddir) -name "*.gcda" -delete + @lcov --directory $(top_builddir) --zerocounters + $(RM) -r coverage $(top_builddir)/coverage.info + +coverage: clean-coverage check + @lcov --compat-libtool --directory $(top_builddir) --capture \ + --output-file $(top_builddir)/coverage.info + $(AM_V_at)$(MKDIR_P) coverage + @genhtml -o coverage/ $(top_builddir)/coverage.info + +clean-local: clean-coverage + -find $(top_builddir) -name "*.gcno" -delete + $(RM) -r lib/bluetooth + +else clean-local: $(RM) -r lib/bluetooth +endif
acinclude.m4 +4 -0
@@ -51,6 +51,10 @@ AC_DEFUN([MISC_FLAGS], [ misc_ldflags="$misc_ldflags -pie" fi ]) + if (test "$USE_MAINTAINER_MODE" = "yes"); then + misc_cflags="$misc_cflags --coverage" + misc_ldflags="$misc_ldflags --coverage" + fi AC_SUBST([MISC_CFLAGS], $misc_cflags) AC_SUBST([MISC_LDFLAGS], $misc_ldflags) ])
configure.ac +4 -0
@@ -252,4 +252,8 @@ AC_ARG_ENABLE(android, AC_HELP_STRING([--enable-android], [enable_android=${enableval}]) AM_CONDITIONAL(ANDROID, test "${enable_android}" = "yes") +if (test "$USE_MAINTAINER_MODE" = "yes"); then + AC_CHECK_PROG([LCOV], [lcov], [yes], AC_MSG_ERROR(lcov is required)) +fi + AC_OUTPUT(Makefile src/bluetoothd.8 lib/bluez.pc)
Signature · 1 line
1.8.3.1
Luiz Augusto von Dentz
maintainerHi Marcel,
Quoted 93 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
Coverage is enabled with --enable-maintainer-mode, 2 new targets are added 'coverage' and 'clean-coverage', the first generate the reports using lcov and depend on the second to cleanup previous generated reports and .gcda files.
--- .gitignore | 4 ++++ Makefile.am | 18 ++++++++++++++++++ acinclude.m4 | 4 ++++ configure.ac | 4 ++++ 4 files changed, 30 insertions(+).gitignore +4
-0@@ -3,6 +3,8 @@ *.lo *.la *.so +*.gcno +*.gcda .deps .libs .dirstamp@@ -27,7 +29,9 @@ stamp-h1 autom4te.cache test-driver test-suite.log +coverage.info +coverage lib/bluez.pc lib/bluetooth src/builtin.hMakefile.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 MAINTAINER_MODE +clean-coverage: + -find $(top_builddir) -name "*.gcda" -delete + @lcov --directory $(top_builddir) --zerocounters + $(RM) -r coverage $(top_builddir)/coverage.info + +coverage: clean-coverage check + @lcov --compat-libtool --directory $(top_builddir) --capture \ + --output-file $(top_builddir)/coverage.info + $(AM_V_at)$(MKDIR_P) coverage + @genhtml -o coverage/ $(top_builddir)/coverage.info + +clean-local: clean-coverage + -find $(top_builddir) -name "*.gcno" -delete + $(RM) -r lib/bluetooth + +else clean-local: $(RM) -r lib/bluetooth +endifacinclude.m4 +4
-0@@ -51,6 +51,10 @@ AC_DEFUN([MISC_FLAGS], [ misc_ldflags="$misc_ldflags -pie" fi ]) + if (test "$USE_MAINTAINER_MODE" = "yes"); then + misc_cflags="$misc_cflags --coverage" + misc_ldflags="$misc_ldflags --coverage" + fi AC_SUBST([MISC_CFLAGS], $misc_cflags) AC_SUBST([MISC_LDFLAGS], $misc_ldflags) ])configure.ac +4
-1@@ -252,4 +252,8 @@ AC_ARG_ENABLE(android, AC_HELP_STRING([--enable-android], [enable_android=${enableval}]) AM_CONDITIONAL(ANDROID, test "${enable_android}" = "yes") +if (test "$USE_MAINTAINER_MODE" = "yes"); then + AC_CHECK_PROG([LCOV], [lcov], [yes], AC_MSG_ERROR(lcov is required)) +fi + AC_OUTPUT(Makefile src/bluetoothd.8 lib/bluez.pc) --
Quoted 1 line
1.8.3.1
Any feedback regarding this patch? It is now using maintainer mode as you suggested.
Signature · 1 line
Luiz Augusto von Dentz
Marcel Holtmann
maintainerHi Luiz,
Quoted 85 lines
Quoted 85 lines
Coverage is enabled with --enable-maintainer-mode, 2 new targets are added 'coverage' and 'clean-coverage', the first generate the reports using lcov and depend on the second to cleanup previous generated reports and .gcda files.
---.gitignore | 4 ++++ Makefile.am | 18 ++++++++++++++++++ acinclude.m4 | 4 ++++ configure.ac | 4 ++++ 4 files changed, 30 insertions(+).gitignore +2
-0@@ -3,6 +3,8 @@ *.lo *.la *.so +*.gcno +*.gcda.deps
.libs
.dirstamp.gitignore +0
-0@@ -27,7 +29,9 @@ stamp-h1autom4te.cache
test-driver
test-suite.log.gitignore +2
-0+coverage.info +coverage
lib/bluez.pc
lib/bluetoothsrc/builtin.hMakefile.am +17
-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 MAINTAINER_MODE +clean-coverage: + -find $(top_builddir) -name "*.gcda" -delete + @lcov --directory $(top_builddir) --zerocounters + $(RM) -r coverage $(top_builddir)/coverage.info + +coverage: clean-coverage check + @lcov --compat-libtool --directory $(top_builddir) --capture \ + --output-file $(top_builddir)/coverage.info + $(AM_V_at)$(MKDIR_P) coverage + @genhtml -o coverage/ $(top_builddir)/coverage.info + +clean-local: clean-coverage + -find $(top_builddir) -name "*.gcno" -delete + $(RM) -r lib/bluetooth + +elseclean-local:
$(RM) -r lib/bluetoothMakefile.am +1
-0+endifacinclude.m4 +4
-0@@ -51,6 +51,10 @@ AC_DEFUN([MISC_FLAGS], [ misc_ldflags="$misc_ldflags -pie" fi ]) + if (test "$USE_MAINTAINER_MODE" = "yes"); then + misc_cflags="$misc_cflags --coverage" + misc_ldflags="$misc_ldflags --coverage" + fi AC_SUBST([MISC_CFLAGS], $misc_cflags) AC_SUBST([MISC_LDFLAGS], $misc_ldflags) ])configure.ac +0
-0@@ -252,4 +252,8 @@ AC_ARG_ENABLE(android, AC_HELP_STRING([--enable-android], [enable_android=${enableval}]) AM_CONDITIONAL(ANDROID, test "${enable_android}" = "yes")
Quoted 10 lines
Quoted 7 lines
configure.ac +4
-1+if (test "$USE_MAINTAINER_MODE" = "yes"); then + AC_CHECK_PROG([LCOV], [lcov], [yes], AC_MSG_ERROR(lcov is required)) +fi + AC_OUTPUT(Makefile src/bluetoothd.8 lib/bluez.pc) --1.8.3.1
Any feedback regarding this patch? It is now using maintainer mode as you suggested.
I have not tested it yet. In general this looks just fine. However the if else with clean-local in each branches is still something that I think could be done a bit cleaner.
Regards
Marcel
Luiz Augusto von Dentz
maintainerHi Marcel,
Quoted 98 lines · Marcel Holtmann
Hi Luiz,
Quoted 85 lines
Quoted 85 lines
Coverage is enabled with --enable-maintainer-mode, 2 new targets are added 'coverage' and 'clean-coverage', the first generate the reports using lcov and depend on the second to cleanup previous generated reports and .gcda files.
---.gitignore | 4 ++++ Makefile.am | 18 ++++++++++++++++++ acinclude.m4 | 4 ++++ configure.ac | 4 ++++ 4 files changed, 30 insertions(+).gitignore +2
-0@@ -3,6 +3,8 @@ *.lo *.la *.so +*.gcno +*.gcda.deps
.libs
.dirstamp.gitignore +0
-0@@ -27,7 +29,9 @@ stamp-h1autom4te.cache
test-driver
test-suite.log.gitignore +2
-0+coverage.info +coverage
lib/bluez.pc
lib/bluetoothsrc/builtin.hMakefile.am +17
-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 MAINTAINER_MODE +clean-coverage: + -find $(top_builddir) -name "*.gcda" -delete + @lcov --directory $(top_builddir) --zerocounters + $(RM) -r coverage $(top_builddir)/coverage.info + +coverage: clean-coverage check + @lcov --compat-libtool --directory $(top_builddir) --capture \ + --output-file $(top_builddir)/coverage.info + $(AM_V_at)$(MKDIR_P) coverage + @genhtml -o coverage/ $(top_builddir)/coverage.info + +clean-local: clean-coverage + -find $(top_builddir) -name "*.gcno" -delete + $(RM) -r lib/bluetooth + +elseclean-local:
$(RM) -r lib/bluetoothMakefile.am +1
-0+endifacinclude.m4 +4
-0@@ -51,6 +51,10 @@ AC_DEFUN([MISC_FLAGS], [ misc_ldflags="$misc_ldflags -pie" fi ]) + if (test "$USE_MAINTAINER_MODE" = "yes"); then + misc_cflags="$misc_cflags --coverage" + misc_ldflags="$misc_ldflags --coverage" + fi AC_SUBST([MISC_CFLAGS], $misc_cflags) AC_SUBST([MISC_LDFLAGS], $misc_ldflags) ])configure.ac +0
-0@@ -252,4 +252,8 @@ AC_ARG_ENABLE(android, AC_HELP_STRING([--enable-android], [enable_android=${enableval}]) AM_CONDITIONAL(ANDROID, test "${enable_android}" = "yes")Quoted 10 lines
Quoted 7 lines
configure.ac +4
-1+if (test "$USE_MAINTAINER_MODE" = "yes"); then + AC_CHECK_PROG([LCOV], [lcov], [yes], AC_MSG_ERROR(lcov is required)) +fi + AC_OUTPUT(Makefile src/bluetoothd.8 lib/bluez.pc) --1.8.3.1
Any feedback regarding this patch? It is now using maintainer mode as you suggested.
Quoted 1 line
I have not tested it yet. In general this looks just fine. However the if else with clean-local in each branches is still something that I think could be done a bit cleaner.
Im all for it as well, but note that the .gcna needs to be cleanup manually since they are not created by the build itself but at runtime when the binary is run thus why I made clean-local to depend on clean-coverage , the .gcno files could be cleanup like any .o file but I couldn't figure out how to do it so far.
Signature · 1 line
Luiz Augusto von Dentz
Luiz Augusto von Dentz
maintainerHi Marcel,
Quoted 101 lines · Luiz Augusto von Dentz
Hi Marcel,
Quoted 98 lines · Marcel Holtmann
Hi Luiz,
Quoted 95 lines
Quoted 91 lines
Coverage is enabled with --enable-maintainer-mode, 2 new targets are added 'coverage' and 'clean-coverage', the first generate the reports using lcov and depend on the second to cleanup previous generated reports and .gcda files.
---.gitignore | 4 ++++ Makefile.am | 18 ++++++++++++++++++ acinclude.m4 | 4 ++++ configure.ac | 4 ++++ 4 files changed, 30 insertions(+).gitignore +2
-0@@ -3,6 +3,8 @@ *.lo *.la *.so +*.gcno +*.gcda.deps
.libs
.dirstamp.gitignore +0
-0@@ -27,7 +29,9 @@ stamp-h1autom4te.cache
test-driver
test-suite.log.gitignore +2
-0+coverage.info +coverage
lib/bluez.pc
lib/bluetoothsrc/builtin.hMakefile.am +17
-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 MAINTAINER_MODE +clean-coverage: + -find $(top_builddir) -name "*.gcda" -delete + @lcov --directory $(top_builddir) --zerocounters + $(RM) -r coverage $(top_builddir)/coverage.info + +coverage: clean-coverage check + @lcov --compat-libtool --directory $(top_builddir) --capture \ + --output-file $(top_builddir)/coverage.info + $(AM_V_at)$(MKDIR_P) coverage + @genhtml -o coverage/ $(top_builddir)/coverage.info + +clean-local: clean-coverage + -find $(top_builddir) -name "*.gcno" -delete + $(RM) -r lib/bluetooth + +elseclean-local:
$(RM) -r lib/bluetoothMakefile.am +1
-0+endifacinclude.m4 +4
-0@@ -51,6 +51,10 @@ AC_DEFUN([MISC_FLAGS], [ misc_ldflags="$misc_ldflags -pie" fi ]) + if (test "$USE_MAINTAINER_MODE" = "yes"); then + misc_cflags="$misc_cflags --coverage" + misc_ldflags="$misc_ldflags --coverage" + fi AC_SUBST([MISC_CFLAGS], $misc_cflags) AC_SUBST([MISC_LDFLAGS], $misc_ldflags) ])configure.ac +4
-1@@ -252,4 +252,8 @@ AC_ARG_ENABLE(android, AC_HELP_STRING([--enable-android], [enable_android=${enableval}]) AM_CONDITIONAL(ANDROID, test "${enable_android}" = "yes") +if (test "$USE_MAINTAINER_MODE" = "yes"); then + AC_CHECK_PROG([LCOV], [lcov], [yes], AC_MSG_ERROR(lcov is required)) +fi + AC_OUTPUT(Makefile src/bluetoothd.8 lib/bluez.pc) --Quoted 1 line
1.8.3.1
Any feedback regarding this patch? It is now using maintainer mode as you suggested.
Quoted 7 lines
Quoted 1 line
I have not tested it yet. In general this looks just fine. However the if else with clean-local in each branches is still something that I think could be done a bit cleaner.
Im all for it as well, but note that the .gcna needs to be cleanup manually since they are not created by the build itself but at runtime when the binary is run thus why I made clean-local to depend on clean-coverage , the .gcno files could be cleanup like any .o file but I couldn't figure out how to do it so far.
Revisiting this one, the other way some projects are cleaning .gcno .gcna is adding those to CLEANFILES (e.g. CLEANFILES += *.gcno *.gcda), but in this case we have to every sub-directory so it might be more troublesome to maintain.
Another thing we could check is if this may actually be done automatically by autotools in future since apparently it does cleanup some files generated such as *.o it could cleanup *.gcno.
Signature · 1 line
Luiz Augusto von Dentz