Memcached::Handle::DESTROY needs to kill the memcached process with SIGINT (instead of SIGKILL).
Now the numbers look better:
File 'assoc.c' Lines executed:49.13% of 173
File 'items.c' Lines executed:70.61% of 228
File 'memcached.c' Lines executed:65.32% of 1485
File 'slabs.c' Lines executed:84.43% of 122
File 'stats.c' Lines executed:90.00% of 70

-Victor

Victor Kirkebo wrote:

You're right - something is very wrong with the numbers.
It only seems to report coverage for the tests in 00-startup.t. If I try to run only the tests in any of the other *.t files there's no output. I'm not sure why this happens but will look into it.

-Victor

dormando wrote:

The test coverage is exceptionally low.

Is this only accounting the coverage of the last executed test?

On Tue, 9 Sep 2008, Victor Kirkebo wrote:

Hi,
I've attached a new version of this patch that excludes printing of coverage on non-source-tree files.
The printout looks like this:

with gcov:
File `assoc.c' Lines executed:1.66% of 181
File `items.c' Lines executed:2.82% of 248
File `memcached.c' Lines executed:9.40% of 1554
File `slabs.c' Lines executed:14.84% of 128
File `stats.c' Lines executed:2.60% of 77

with tcov:
assoc.c : 1.02 Percent of the file executed
items.c : 2.39 Percent of the file executed
memcached.c : 8.15 Percent of the file executed
slabs.c : 15.65 Percent of the file executed
stats.c : 1.72 Percent of the file executed

-Victor

dormando wrote:
Hey,

Think this could be modified to not spit coverage on files not in the
source tree?

File '/usr/include/gentoo-multilib/amd64/sys/stat.h'
Lines executed:0.00% of 1
/usr/include/gentoo-multilib/amd64/sys/stat.h:creating 'stat.h.gcov'

File '/usr/include/gentoo-multilib/amd64/stdlib.h'
Lines executed:27.27% of 11
/usr/include/gentoo-multilib/amd64/stdlib.h:creating 'stdlib.h.gcov'

File 'slabs.c'
Lines executed:16.39% of 122
slabs.c:creating 'slabs.c.gcov'

File '/usr/include/gentoo-multilib/amd64/stdlib.h'
Lines executed:0.00% of 3
/usr/include/gentoo-multilib/amd64/stdlib.h:creating 'stdlib.h.gcov'

Anyone else have comments?
-Dormando

On Thu, 4 Sep 2008, Victor Kirkebo wrote:


This patch adds test coverage to the 'make test' target.
gcov is used for gcc and tcov is used for Sun studio compiler.

Victor




--
Victor Kirkebo
Database Technology Group
TRO01, x43408/(+47)73842108





diff --git a/Makefile.am b/Makefile.am
index 29085ec..1c86e83 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -7,6 +7,7 @@ memcached_LDADD = @DTRACE_OBJ@ @DAEMON_OBJ@
 memcached_debug_LDADD = @DTRACE_DEBUG_OBJ@ @DAEMON_OBJ@
 memcached_DEPENDENCIES = @DTRACE_OBJ@ @DAEMON_OBJ@
 memcached_debug_DEPENDENCIES = @DTRACE_DEBUG_OBJ@ @DAEMON_OBJ@
+memcached_debug_CFLAGS = @PROFILER_FLAGS@
 
 memcached_dtrace.h:
        ${DTRACE} -h -s memcached_dtrace.d 
@@ -26,6 +27,26 @@ EXTRA_DIST = doc scripts TODO t memcached.spec daemon.c 
memcached_dtrace.d
 
 test:  memcached-debug
        prove $(srcdir)/t
+       @if test `basename $(PROFILER)` = "gcov"; then \
+         for file in memcached_debug-*.gc??; do \
+           mv -f $$file `echo $$file | sed 's/memcached_debug-//'`; \
+         done && \
+         for file in *.gcda; do \
+           srcfile=`echo $$file | sed 's/.gcda/.c/'`; \
+           if test -n "`echo $(memcached_debug_SOURCES) | grep $$srcfile`"; 
then \
+             echo `$(PROFILER) $$srcfile` | sed 's/'$$srcfile':.*//'; \
+           fi \
+         done \
+       elif test `basename $(PROFILER)` = "tcov"; then \
+         files=`grep SRCFILE memcached-debug.profile/tcovd | sed 
's/SRCFILE://' | sort | uniq` && \
+         $(PROFILER) -x memcached-debug.profile $$files 2>&1; \
+         for file in *.tcov; do \
+           srcfile=`echo $$file | sed 's/.tcov//'`; \
+           if test -n "`echo $(memcached_debug_SOURCES) | grep $$srcfile`"; 
then \
+             echo $$srcfile : `grep 'Percent of the file executed' $$file`; \
+           fi \
+         done \
+       else :; fi
 
 dist-hook:
        rm -rf $(distdir)/doc/.svn/
diff --git a/configure.ac b/configure.ac
index 01c51cf..1a8afe3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,6 +28,32 @@ AC_SUBST(DTRACE_OBJ)
 AC_SUBST(DTRACE_DEBUG_OBJ)
 AC_SUBST(DTRACEFLAGS)
 
+if test "$GCC" = "yes"
+then
+   AC_PATH_PROG([PROFILER], [gcov], "no", [$PATH])
+   if test "x$PROFILER" != "xno"; then
+      PROFILER_FLAGS="-fprofile-arcs -ftest-coverage"    
+   fi
+else
+   AC_RUN_IFELSE(
+      [AC_LANG_PROGRAM([], [dnl
+#ifdef __SUNPRO_C
+   return 0;
+#else
+   return 1;
+#endif
+      ])
+    ],[
+       AC_PATH_PROG([PROFILER], [tcov], "no", [$PATH])
+       if test "x$PROFILER" != "xno"; then
+          PROFILER_FLAGS=-xprofile=tcov
+       fi
+    ])
+fi
+
+AC_SUBST(PROFILER_FLAGS)
+
+
 AC_ARG_ENABLE(64bit,
   [AS_HELP_STRING([--enable-64bit],[build 64bit verison])])
 if test "x$enable_64bit" == "xyes"
diff --git a/t/lib/MemcachedTest.pm b/t/lib/MemcachedTest.pm
index c58abe9..fc65892 100644
--- a/t/lib/MemcachedTest.pm
+++ b/t/lib/MemcachedTest.pm
@@ -201,7 +201,7 @@ sub new {
 
 sub DESTROY {
     my $self = shift;
-    kill 9, $self->{pid};
+    kill 2, $self->{pid};
 }
 
 sub port { $_[0]{port} }

Reply via email to