File: gcov.patch

package info (click to toggle)
subversion 1.4.2dfsg1-3
  • links: PTS
  • area: main
  • in suites: etch
  • size: 37,284 kB
  • ctags: 32,888
  • sloc: ansic: 406,472; python: 38,378; sh: 15,438; cpp: 9,604; ruby: 8,313; perl: 5,308; java: 4,576; lisp: 3,860; xml: 3,298; makefile: 856
file content (74 lines) | stat: -rw-r--r-- 3,172 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
74
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 8987)
+++ Makefile.in	(working copy)
@@ -326,6 +326,36 @@
 	@$(MAKE) check \
 	  BASE_URL=svn+ssh://localhost`pwd`/subversion/tests/clients/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
+
 check-clean:
 	rm -rf subversion/tests/clients/cmdline/repositories   \
                subversion/tests/clients/cmdline/working_copies \
Index: configure.in
===================================================================
--- configure.in	(revision 8987)
+++ configure.in	(working copy)
@@ -323,6 +323,15 @@
     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,
 AC_HELP_STRING([--with-editor=PATH],
                [Specify a default editor for the subversion client.]),