bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Generating code coverage reports


From: Simon Josefsson
Subject: Re: Generating code coverage reports
Date: Tue, 28 Oct 2008 22:56:14 +0100
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/22.2 (gnu/linux)

jemarch-mXXj517/address@hidden writes:

> Hi Simon.
>
>    I was inspired by gnupdf's code coverage reports:
>
>    http://www.gnupdf.org/prmgt/coverage/
>
>    So I looked into how to integrate a script to generate them for some of
>    my projects.  I couldn't think of how to implement this as a gnulib
>    module, but I wrote rules for maintainer-makefile's 'cfg.mk'.
>
> Nice. Would be good to create standard rules to compile with code
> coverage in maint.mk.

Hi!  I have pushed the following.  Maybe some parameters should be made
more easy to configure, but that can be changed on demand later on.

/Simon

>From cdccece5811c28f3ac95e1ae226967de25a8c387 Mon Sep 17 00:00:00 2001
From: Simon Josefsson <address@hidden>
Date: Tue, 28 Oct 2008 22:53:47 +0100
Subject: [PATCH] top/maint.mk: Add coverage rules, inspired by scripts in 
gnupdf.

---
 ChangeLog    |    4 ++++
 top/maint.mk |   24 ++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a35a54b..55e7f7e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2008-10-28  Simon Josefsson  <address@hidden>
 
+       * top/maint.mk: Add coverage rules, inspired by scripts in gnupdf.
+
+2008-10-28  Simon Josefsson  <address@hidden>
+
        * MODULES.html.sh (Support for systems lacking POSIX:2001):
        Mention times and sys_times.
        * modules/sys_times, modules/sys_times-tests: New modules.
diff --git a/top/maint.mk b/top/maint.mk
index 24b7650..2eea98d 100644
--- a/top/maint.mk
+++ b/top/maint.mk
@@ -105,6 +105,30 @@ syntax-check-rules := $(shell sed -n 
's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p' $(ME))
 
 syntax-check: $(syntax-check-rules)
 
+# Code Coverage
+
+init-coverage:
+       make clean
+       lcov --directory . --zerocounters
+
+COVERAGE_CCOPTS ?= "-g -fprofile-arcs -ftest-coverage"
+COVERAGE_OUT ?= doc/coverage
+
+build-coverage:
+       make CFLAGS=$(COVERAGE_CCOPTS) CXXFLAGS=$(COVERAGE_CCOPTS)
+       make CFLAGS=$(COVERAGE_CCOPTS) CXXFLAGS=$(COVERAGE_CCOPTS) check
+       mkdir -p $(COVERAGE_OUT)
+       lcov --directory . --output-file $(COVERAGE_OUT)/$(PACKAGE).info \
+               --capture
+
+gen-coverage:
+       genhtml --output-directory $(COVERAGE_OUT) \
+               $(COVERAGE_OUT)/$(PACKAGE).info \
+               --highlight --frames --legend \
+               --title "$(PACKAGE_NAME)"
+
+coverage: init-coverage build-coverage gen-coverage
+
 # Update gettext files.
 PACKAGE ?= $(shell basename $(PWD))
 POURL = http://translationproject.org/latest/$(PACKAGE)/
-- 
1.5.6.5





reply via email to

[Prev in Thread] Current Thread [Next in Thread]