File: gcov.patch

package info (click to toggle)
subversion 1.6.12dfsg-7
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 48,292 kB
  • ctags: 47,714
  • sloc: ansic: 578,414; python: 77,551; sh: 13,100; ruby: 12,194; cpp: 10,097; java: 8,428; lisp: 7,702; perl: 7,320; makefile: 1,035; xml: 759; sql: 62
file content (73 lines) | stat: -rw-r--r-- 3,008 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
This patch can be used to generate a report showing what C source
lines are executed when the testsuite is run.  gcc is required.  After
applying this patch do:

$ ./configure --enable-gcov
$ make check
$ make gcov

Now look at gcov-report.html and the annotated source files it links
to.

See also gcov(1), gcc(1).

Index: Makefile.in
===================================================================
--- Makefile.in	(revision 32484)
+++ Makefile.in	(working copy)
@@ -443,6 +443,36 @@
 	@$(MAKE) check \
 	  BASE_URL=svn+ssh://localhost`pwd`/subversion/tests/cmdline
 
+gcov:
+	@echo -n "Collecting source files ..." ;                         \
+	FILES=`find subversion/ -path '*/tests/*' -prune -o              \
+	    -name '*.c' -print`;                                         \
+	echo "Done." ;                                                   \
+	echo "Coverage report Subversion r`svnversion .`<br>"            \
+	echo "`date`<br>"                                                \
+	    > gcov-report.html;                                          \
+	echo `uname -o -r -m`  "<br>"                                    \
+	    >> gcov-report.html;                                         \
+	(for file in $$FILES; do                                         \
+	    echo $$file 1>&2 ;                                           \
+	    base=`echo $$file | sed -e 's/.c$$//' `;                     \
+	    if [ -f "$$base.da" ] ; then                                 \
+	        obj=$$base.o;                                            \
+	    else                                                         \
+	        obj=`dirname $$base`/.libs/`basename $$base`.o;          \
+	    fi;                                                          \
+	    stats=`gcov --preserve-paths                                 \
+	        --object-directory=$$obj                                 \
+	        $$file | sed -e "s/Creating.*//"  |                      \
+                sed -s "s|$$PWD/||"`                                     \
+	    mangled=`echo $$base | tr '/' '#'`;                          \
+	    fixed=`echo $$base | tr '/' '_'`;                            \
+	    mv *$$mangled.c.gcov $$fixed.c.gcov;                         \
+	    echo -n $$stats |                                            \
+	        sed -e "s/in file/in file <a href=\"$$fixed.c.gcov\">/"; \
+	    echo "</a><br>";                                             \
+	done) | sort -g >> gcov-report.html
+
 bdbcheck:
 	@$(MAKE) check FS_TYPE=bdb
 
Index: configure.ac
===================================================================
--- configure.ac	(revision 32484)
+++ configure.ac	(working copy)
@@ -684,6 +684,14 @@
 #   # do nothing
 fi
 
+AC_ARG_ENABLE(gcov,
+AC_HELP_STRING([--enable-gcov],
+         [Turn on coverage testing (GCC only).]),
+[
+    if test "$enableval" = "yes" ; then
+      CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
+    fi
+])
 
 AC_ARG_WITH(editor,
 AS_HELP_STRING([--with-editor=PATH],