All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 BlueZ] build: Add coverage support
@ 2013-12-18 13:09 Luiz Augusto von Dentz
  2013-12-23  8:05 ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2013-12-18 13:09 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

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(+)

diff --git a/.gitignore b/.gitignore
index c570728..21dbe26 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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
diff --git a/Makefile.am b/Makefile.am
index 15cc149..7380e61 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -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
diff --git a/acinclude.m4 b/acinclude.m4
index 2065852..afc7c6d 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -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)
 ])
diff --git a/configure.ac b/configure.ac
index 18d0b55..4f36355 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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)
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 BlueZ] build: Add coverage support
  2013-12-18 13:09 [PATCH v2 BlueZ] build: Add coverage support Luiz Augusto von Dentz
@ 2013-12-23  8:05 ` Luiz Augusto von Dentz
  2013-12-23 13:57   ` Marcel Holtmann
  0 siblings, 1 reply; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2013-12-23  8:05 UTC (permalink / raw)
  To: linux-bluetooth

Hi Marcel,

On Wed, Dec 18, 2013 at 3:09 PM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> 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(+)
>
> diff --git a/.gitignore b/.gitignore
> index c570728..21dbe26 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -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
> diff --git a/Makefile.am b/Makefile.am
> index 15cc149..7380e61 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -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
> diff --git a/acinclude.m4 b/acinclude.m4
> index 2065852..afc7c6d 100644
> --- a/acinclude.m4
> +++ b/acinclude.m4
> @@ -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)
>  ])
> diff --git a/configure.ac b/configure.ac
> index 18d0b55..4f36355 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -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)
> --
> 1.8.3.1

Any feedback regarding this patch? It is now using maintainer mode as
you suggested.


-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 BlueZ] build: Add coverage support
  2013-12-23  8:05 ` Luiz Augusto von Dentz
@ 2013-12-23 13:57   ` Marcel Holtmann
  2013-12-23 14:20     ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 6+ messages in thread
From: Marcel Holtmann @ 2013-12-23 13:57 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hi Luiz,

>> 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(+)
>> 
>> diff --git a/.gitignore b/.gitignore
>> index c570728..21dbe26 100644
>> --- a/.gitignore
>> +++ b/.gitignore
>> @@ -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
>> diff --git a/Makefile.am b/Makefile.am
>> index 15cc149..7380e61 100644
>> --- a/Makefile.am
>> +++ b/Makefile.am
>> @@ -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
>> diff --git a/acinclude.m4 b/acinclude.m4
>> index 2065852..afc7c6d 100644
>> --- a/acinclude.m4
>> +++ b/acinclude.m4
>> @@ -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)
>> ])
>> diff --git a/configure.ac b/configure.ac
>> index 18d0b55..4f36355 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -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)
>> --
>> 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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 BlueZ] build: Add coverage support
  2013-12-23 13:57   ` Marcel Holtmann
@ 2013-12-23 14:20     ` Luiz Augusto von Dentz
  2014-04-28  8:34       ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2013-12-23 14:20 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: linux-bluetooth

Hi Marcel,

On Mon, Dec 23, 2013 at 3:57 PM, Marcel Holtmann <marcel@holtmann.org> wrote:
> Hi Luiz,
>
>>> 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(+)
>>>
>>> diff --git a/.gitignore b/.gitignore
>>> index c570728..21dbe26 100644
>>> --- a/.gitignore
>>> +++ b/.gitignore
>>> @@ -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
>>> diff --git a/Makefile.am b/Makefile.am
>>> index 15cc149..7380e61 100644
>>> --- a/Makefile.am
>>> +++ b/Makefile.am
>>> @@ -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
>>> diff --git a/acinclude.m4 b/acinclude.m4
>>> index 2065852..afc7c6d 100644
>>> --- a/acinclude.m4
>>> +++ b/acinclude.m4
>>> @@ -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)
>>> ])
>>> diff --git a/configure.ac b/configure.ac
>>> index 18d0b55..4f36355 100644
>>> --- a/configure.ac
>>> +++ b/configure.ac
>>> @@ -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)
>>> --
>>> 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.

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.

-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 BlueZ] build: Add coverage support
  2013-12-23 14:20     ` Luiz Augusto von Dentz
@ 2014-04-28  8:34       ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2014-04-28  8:34 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: linux-bluetooth

Hi Marcel,

On Mon, Dec 23, 2013 at 4:20 PM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> Hi Marcel,
>
> On Mon, Dec 23, 2013 at 3:57 PM, Marcel Holtmann <marcel@holtmann.org> wrote:
>> Hi Luiz,
>>
>>>> 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(+)
>>>>
>>>> diff --git a/.gitignore b/.gitignore
>>>> index c570728..21dbe26 100644
>>>> --- a/.gitignore
>>>> +++ b/.gitignore
>>>> @@ -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
>>>> diff --git a/Makefile.am b/Makefile.am
>>>> index 15cc149..7380e61 100644
>>>> --- a/Makefile.am
>>>> +++ b/Makefile.am
>>>> @@ -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
>>>> diff --git a/acinclude.m4 b/acinclude.m4
>>>> index 2065852..afc7c6d 100644
>>>> --- a/acinclude.m4
>>>> +++ b/acinclude.m4
>>>> @@ -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)
>>>> ])
>>>> diff --git a/configure.ac b/configure.ac
>>>> index 18d0b55..4f36355 100644
>>>> --- a/configure.ac
>>>> +++ b/configure.ac
>>>> @@ -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)
>>>> --
>>>> 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.
>
> 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.


-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 BlueZ] build: Add coverage support
@ 2014-09-22 12:41 Luiz Augusto von Dentz
  0 siblings, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2014-09-22 12:41 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

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.
---
v2: Fix lcov check to be optional and only enable coverage target if
lcov is found.

 .gitignore   |  4 ++++
 Makefile.am  | 17 +++++++++++++++++
 acinclude.m4 |  4 ++++
 configure.ac |  5 +++++
 4 files changed, 30 insertions(+)

diff --git a/.gitignore b/.gitignore
index e22274f..ecd4a3b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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
diff --git a/Makefile.am b/Makefile.am
index 14b4f55..61788ff 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -409,5 +409,22 @@ 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:
+	-find $(top_builddir) -name "*.gcno" -delete
+	-find $(top_builddir) -name "*.gcda" -delete
+	@lcov --directory $(top_builddir) --zerocounters
+	$(RM) -r coverage $(top_builddir)/coverage.info
+
+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
+	$(RM) -r lib/bluetooth
+else
 clean-local:
 	$(RM) -r lib/bluetooth
+endif
diff --git a/acinclude.m4 b/acinclude.m4
index 2065852..7efc382 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -51,6 +51,10 @@ AC_DEFUN([MISC_FLAGS], [
 			misc_ldflags="$misc_ldflags -pie"
 		fi
 	])
+	if (test "$LCOV" = "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)
 ])
diff --git a/configure.ac b/configure.ac
index 9bdd239..bc1de01 100644
--- a/configure.ac
+++ b/configure.ac
@@ -32,6 +32,11 @@ m4_ifdef([AC_LIBTOOL_TAGS], [AC_LIBTOOL_TAGS([])])
 AC_DISABLE_STATIC
 AC_PROG_LIBTOOL
 
+if (test "$USE_MAINTAINER_MODE" = "yes"); then
+	AC_CHECK_PROG([LCOV], [lcov], [yes], [no])
+	AM_CONDITIONAL(COVERAGE, test "${LCOV}" = "yes")
+fi
+
 MISC_FLAGS
 
 AC_ARG_ENABLE(threads, AC_HELP_STRING([--enable-threads],
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-09-22 12:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-18 13:09 [PATCH v2 BlueZ] build: Add coverage support Luiz Augusto von Dentz
2013-12-23  8:05 ` Luiz Augusto von Dentz
2013-12-23 13:57   ` Marcel Holtmann
2013-12-23 14:20     ` Luiz Augusto von Dentz
2014-04-28  8:34       ` Luiz Augusto von Dentz
2014-09-22 12:41 Luiz Augusto von Dentz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.