diff --git a/ChangeLog b/ChangeLog index b36217f9fc..530af890ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Thu May 29 15:25:00 EST 2008 Daniel P. Berrange + + * configure.in, scripts/*: Remove all coverage helper scripts + in favour of using lcov + * src/Makefile.am, Makefile.am: Switch to use lcov for pretty + code coverage reports + Thu May 29 15:17:00 EST 2008 Daniel P. Berrange * src/libvirt.c: Don't register storage API if daemon is diff --git a/Makefile.am b/Makefile.am index 73552a4875..e0aba2daa7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,10 @@ ## Process this file with automake to produce Makefile.in +LCOV = lcov +GENHTML = genhtml + SUBDIRS = gnulib/lib include src qemud proxy docs gnulib/tests \ - python tests po scripts + python tests po ACLOCAL_AMFLAGS = -I m4 -I gnulib/m4 @@ -28,24 +31,15 @@ tests: @(if [ "$(pythondir)" != "" ] ; then cd python ; \ $(MAKE) MAKEFLAGS+=--silent tests ; fi) -cov: cov-recursive cov-am +cov: clean-cov + mkdir $(top_builddir)/coverage + $(LCOV) -c -o $(top_builddir)/coverage/libvirt.info.tmp -d $(top_srcdir)/src -d $(top_srcdir)/qemud -d $(top_srcdir)/tests + $(LCOV) -r $(top_builddir)/coverage/libvirt.info.tmp -o $(top_builddir)/coverage/libvirt.info *usr* + rm $(top_builddir)/coverage/libvirt.info.tmp + $(GENHTML) -s -t "libvirt" -o $(top_builddir)/coverage --legend $(top_builddir)/coverage/libvirt.info clean-cov: rm -rf $(top_builddir)/coverage - cd src && $(MAKE) $(AM_MAKEFLAGS) clean-cov - -cov-recursive: - cd src && $(MAKE) $(AM_MAKEFLAGS) cov - -cov-am: - rm -rf $(top_builddir)/coverage - mkdir $(top_builddir)/coverage - perl $(srcdir)/scripts/coverage-report.pl src/*.cov > $(top_builddir)/coverage/index.xml - xsltproc $(srcdir)/scripts/coverage-report.xsl \ - $(top_builddir)/coverage/index.xml \ - > $(top_builddir)/coverage/index.html - for i in $(top_builddir)/src/*.gcov ; do o=`echo $$i | sed -e 's,$(top_builddir)/src,coverage,'` ; \ - perl $(srcdir)/scripts/coverage-report-entry.pl $$i > $$o.html ; done # disable this check distuninstallcheck: diff --git a/configure.in b/configure.in index 24d8d8629d..6023355707 100644 --- a/configure.in +++ b/configure.in @@ -1001,7 +1001,7 @@ AC_OUTPUT(Makefile src/Makefile include/Makefile docs/Makefile \ gnulib/lib/Makefile \ gnulib/tests/Makefile \ libvirt.pc libvirt.spec \ - po/Makefile.in scripts/Makefile \ + po/Makefile.in \ include/libvirt/Makefile include/libvirt/libvirt.h \ python/Makefile python/tests/Makefile \ qemud/Makefile \ diff --git a/scripts/.cvsignore b/scripts/.cvsignore deleted file mode 100644 index 282522db03..0000000000 --- a/scripts/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile -Makefile.in diff --git a/scripts/Makefile.am b/scripts/Makefile.am deleted file mode 100644 index 7078fe8302..0000000000 --- a/scripts/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ - -EXTRA_DIST = coverage-report.pl \ - coverage-report-entry.pl \ - coverage-report.xsl diff --git a/scripts/README b/scripts/README deleted file mode 100644 index fdbf9574e3..0000000000 --- a/scripts/README +++ /dev/null @@ -1,3 +0,0 @@ -This directory provides a collection of tools used in the -build / test process. They are not installed / used after -deployment. diff --git a/scripts/coverage-report-entry.pl b/scripts/coverage-report-entry.pl deleted file mode 100644 index c3f02558f7..0000000000 --- a/scripts/coverage-report-entry.pl +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/perl -# -# Copyright (C) 2006-2007 Daniel P. Berrange -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# Author: Daniel P. Berrange -# -# coverage-report-entry.pl: convert gcov annotated source into HTML -# -# This script takes a gcov annotated source code files on STDIN -# converts it to HTML, coloured according to coverage, and sends -# it to STDOUT - -print < - -Coverage report for $ARGV[0] - - - -

Coverage report for $ARGV[0]

- -
-EOF
-
-
-while (<>) {
-    s/&/&/g;
-    s//>/g;
-
-    if (/^\s*function (\S+) called (\d+) returned \d+% blocks executed \d+%/) {
-	my $class = $2 > 0 ? "perfect" : "terrible";
-	$_ = "$_";
-    } elsif (/^\s*branch\s+\d+\s+taken\s+(\d+)%\s+.*$/) {
-	my $class = $1 > 0 ? "perfect" : "terrible";
-	$_ = "$_";
-    } elsif (/^\s*branch\s+\d+\s+never executed.*$/) {
-	my $class = "terrible";
-	$_ = "$_";
-    } elsif (/^\s*call\s+\d+\s+never executed.*$/) {
-	my $class = "terrible";
-	$_ = "$_";
-    } elsif (/^\s*call\s+\d+\s+returned\s+(\d+)%.*$/) {
-	my $class = $1 > 0 ? "perfect" : "terrible";
-	$_ = "$_";
-    }
-
-
-    print;
-}
-
-print <
-
-
-EOF
diff --git a/scripts/coverage-report.pl b/scripts/coverage-report.pl
deleted file mode 100644
index 1001aa4ad5..0000000000
--- a/scripts/coverage-report.pl
+++ /dev/null
@@ -1,164 +0,0 @@
-#!/usr/bin/perl
-#
-# Copyright (C) 2006-2007 Daniel P. Berrange
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
-#
-# Author: Daniel P. Berrange 
-#
-# coverage-report.pl: generate XML coverage summary report
-#
-# This script takes a listof gcov .cov files as args, and generates
-# an XML document summarizing the coverage per function and per
-# source file.
-
-use warnings;
-use strict;
-
-my %coverage = ( function => {}, file => {} );
-
-my @functionBlackList = (
-			 "__memcpy",
-			 "__memmove",
-			 "__memset",
-			 "__strcat",
-			 "__strcpy",
-			 "__strncpy",
-			 "__strsep",
-			 "__strtok"
-		      );
-
-my %filemap;
-
-my $type;
-my $name;
-
-my @functions;
-
-while (<>) {
-    if (/^Function '(.*)'\s*$/) {
-	$type = "function";
-	$name = $1;
-	$coverage{$type}->{$name} = {};
-	push @functions, $name;
-    } elsif (/^File '(.*?)'\s*$/) {
-	$type = "file";
-	$name = $1;
-	$coverage{$type}->{$name} = {};
-
-	foreach my $func (@functions) {
-	    $coverage{"function"}->{$func}->{file} = $name;
-	}
-	@functions = ();
-    } elsif (/^Lines executed:(.*)%\s*of\s*(\d+)\s*$/) {
-	$coverage{$type}->{$name}->{lines} = $2;
-	$coverage{$type}->{$name}->{linesCoverage} = $1;
-    } elsif (/^Branches executed:(.*)%\s*of\s*(\d+)\s*$/) {
-	$coverage{$type}->{$name}->{branches} = $2;
-	$coverage{$type}->{$name}->{branchesCoverage} = $1;
-    } elsif (/^Taken at least once:(.*)%\s*of\s*(\d+)\s*$/) {
-	$coverage{$type}->{$name}->{conds} = $2;
-	$coverage{$type}->{$name}->{condsCoverage} = $1;
-    } elsif (/^Calls executed:(.*)%\s*of\s*(\d+)\s*$/) {
-	$coverage{$type}->{$name}->{calls} = $2;
-	$coverage{$type}->{$name}->{callsCoverage} = $1;
-    } elsif (/^No branches$/) {
-	$coverage{$type}->{$name}->{branches} = 0;
-	$coverage{$type}->{$name}->{branchesCoverage} = "100.00";
-	$coverage{$type}->{$name}->{conds} = 0;
-	$coverage{$type}->{$name}->{condsCoverage} = "100.00";
-    } elsif (/^No calls$/) {
-	$coverage{$type}->{$name}->{calls} = 0;
-	$coverage{$type}->{$name}->{callsCoverage} = "100.00";
-    } elsif (/^\s*(.*):creating '(.*)'\s*$/) {
-	$filemap{$1} = $2;
-    } elsif (/^\s*$/) {
-	# nada
-    } else {
-	warn "unexpected input [$_]\n";
-    }
-}
-
-my %summary;
-foreach my $type ("function", "file") {
-    $summary{$type} = {};
-    foreach my $m ("lines", "branches", "conds", "calls") {
-	my $totalGot = 0;
-	my $totalMiss = 0;
-	my $count = 0;
-	foreach my $func (keys %{$coverage{function}}) {
-	    my $blacklisted = 0;
-	    foreach my $blackName (@functionBlackList) {
-		$blacklisted = 1 if $func =~ /^$blackName/;
-	    }
-	    next if $blacklisted;
-
-	    $count++;
-	    my $got = $coverage{function}->{$func}->{$m};
-	    $totalGot += $got;
-	    my $miss = $got * $coverage{function}->{$func}->{$m ."Coverage"} / 100;
-	    $totalMiss += $miss;
-	}
-	$summary{$type}->{$m} = sprintf("%d", $totalGot);
-	if ($totalGot == 0) {
-	    $summary{$type}->{$m . "Coverage"} = "100.00";
-	} else {
-	    $summary{$type}->{$m . "Coverage"} = sprintf("%.2f", $totalMiss / $totalGot * 100);
-	}
-    }
-}
-
-
-
-print "\n";
-
-foreach my $type ("function", "file") {
-    printf "<%ss>\n", $type;
-    foreach my $name (sort { $a cmp $b } keys %{$coverage{$type}}) {
-	if ($type eq "file") {
-	    next if $name =~ m,^/usr,;
-	} else {
-	    my $blacklisted = 0;
-	    foreach my $blackName (@functionBlackList) {
-		$blacklisted = 1 if $name =~ /^$blackName/;
-	    }
-	    next if $blacklisted;
-	}
-
-	my $rec = $coverage{$type}->{$name};
-	printf "  \n", $name, ($type eq "file" ? $filemap{$name} : $filemap{$rec->{file}});
-	printf "    \n", $rec->{lines}, $rec->{linesCoverage};
-	if (exists $rec->{branches}) {
-	    printf "    \n", $rec->{branches}, $rec->{branchesCoverage};
-	}
-	if (exists $rec->{conds}) {
-	    printf "    \n", $rec->{conds}, $rec->{condsCoverage};
-	}
-	if (exists $rec->{calls}) {
-	    printf "    \n", $rec->{calls}, $rec->{callsCoverage};
-	}
-	print  "  \n";
-    }
-
-    printf "  \n";
-    printf "    \n", $summary{$type}->{lines}, $summary{$type}->{linesCoverage};
-    printf "    \n", $summary{$type}->{branches}, $summary{$type}->{branchesCoverage};
-    printf "    \n", $summary{$type}->{conds}, $summary{$type}->{condsCoverage};
-    printf "    \n", $summary{$type}->{calls}, $summary{$type}->{callsCoverage};
-    printf  "  \n";
-    printf "\n", $type;
-}
-
-print "\n";
diff --git a/scripts/coverage-report.xsl b/scripts/coverage-report.xsl
deleted file mode 100644
index 6775035714..0000000000
--- a/scripts/coverage-report.xsl
+++ /dev/null
@@ -1,217 +0,0 @@
-
-
-
-  
-
-  
-    
-      
-        Coverage report
-        
-      
-      
-        

Coverage report

- - - -
- - -

Function coverage

- - - -
- - - -

File coverage

- - - -
- - - - - - - - - - - - - - - - - - - - - odd - - - even - - - - - - - - - - - - - - odd - - - even - - - - - - -
NameLinesBranchesConditionsCalls
-
- - - - - - - - - - - - - - Summary - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - perfect - - - excellant - - - good - - - poor - - - bad - - - terrible - - - - - % of - - -
diff --git a/src/Makefile.am b/src/Makefile.am index 286e10ed0b..0549bfda97 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -149,22 +149,4 @@ else EXTRA_DIST += parthelper.c endif -cov: clean-cov - for i in $(CLIENT_SOURCES); do \ - case $$i in *.c) ;; *) continue;; esac; \ - b=$$(basename $$i .c); \ - o_files=; \ - for i in '' _test; do \ - g="$(LV_LIBTOOL_OBJDIR)/libvirt$${i}_la-$$b.gcda"; \ - o="$(LV_LIBTOOL_OBJDIR)/libvirt$${i}_la-$$b.o"; \ - test -f "$$o" -a -f "$$g" \ - && o_files="$$o_files $$o"; \ - done; \ - test -n "$$o_files" \ - && gcov -o $(LV_LIBTOOL_OBJDIR) -b -f $$o_files > $$b.cov; \ - done - -clean-cov: - rm -f *.cov *.gcov - -CLEANFILES = *.cov *.gcov .libs/*.gcda .libs/*.gcno *.gcno *.gcda +CLEANFILES = *.gcov .libs/*.gcda .libs/*.gcno *.gcno *.gcda