LCOV 1.8.

svn path=/nixpkgs/trunk/; revision=21149
This commit is contained in:
Ludovic Courtès 2010-04-18 21:51:33 +00:00
parent 502f979532
commit aa0902047e
2 changed files with 103 additions and 151 deletions

View File

@ -1,11 +1,11 @@
{stdenv, fetchurl, perl}: {stdenv, fetchurl, perl}:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "lcov-1.7"; name = "lcov-1.8";
src = fetchurl { src = fetchurl {
url = "mirror://sourceforge/ltp/${name}.tar.gz"; url = "mirror://sourceforge/ltp/${name}.tar.gz";
sha256 = "1cx3haizs0rw6wjsn486qcn50f3qpybflkkb1780cg6s8jzcwdin"; sha256 = "1xrd9abh1gyki9ln9v772dq7jinvyrvx39s3kxbpiila68mbpa7j";
}; };
patches = [ ./find-source.patch ]; patches = [ ./find-source.patch ];
@ -19,13 +19,26 @@ stdenv.mkDerivation rec {
''; '';
postInstall = '' postInstall = ''
for i in $out/bin/*; do for i in "$out/bin/"*; do
substituteInPlace $i --replace /usr/bin/perl ${perl}/bin/perl substituteInPlace $i --replace /usr/bin/perl ${perl}/bin/perl
done done
''; # */ '';
meta = { meta = {
description = "A code coverage tool for Linux"; description = "LCOV, a code coverage tool that enhances GNU gcov";
longDescription =
'' LCOV is an extension of GCOV, a GNU tool which provides information
about what parts of a program are actually executed (i.e.,
"covered") while running a particular test case. The extension
consists of a set of PERL scripts which build on the textual GCOV
output to implement the following enhanced functionality such as
HTML output.
'';
homepage = http://ltp.sourceforge.net/coverage/lcov.php; homepage = http://ltp.sourceforge.net/coverage/lcov.php;
license = "GPLv2+";
maintainers = [ stdenv.lib.maintainers.ludo ];
}; };
} }

View File

@ -1,94 +1,57 @@
diff --exclude '*~' -rc lcov-1.7-orig/bin/geninfo lcov-1.7/bin/geninfo --- lcov-1.8/bin/geninfo 2010-01-29 11:14:46.000000000 +0100
*** lcov-1.7-orig/bin/geninfo 2008-11-17 14:50:26.000000000 +0100 +++ lcov-1.8/bin/geninfo 2010-04-18 23:33:43.000000000 +0200
--- lcov-1.7/bin/geninfo 2009-09-02 10:55:25.000000000 +0200 @@ -51,6 +51,7 @@
***************
*** 51,56 ****
--- 51,57 ----
use strict; use strict;
use File::Basename; use File::Basename;
+ use Cwd qw(abs_path); +use Cwd qw(abs_path);
use File::Spec::Functions qw /abs2rel catdir file_name_is_absolute splitdir
splitpath rel2abs/;
use Getopt::Long; use Getopt::Long;
use Digest::MD5 qw(md5_base64); @@ -95,6 +96,7 @@ sub match_filename($@);
***************
*** 81,86 ****
--- 82,88 ----
sub solve_ambiguous_match($$$); sub solve_ambiguous_match($$$);
sub split_filename($); sub split_filename($);
sub solve_relative_path($$); sub solve_relative_path($$);
+ sub find_source_file($$); +sub find_source_file($$);
sub get_dir($);
sub read_gcov_header($); sub read_gcov_header($);
sub read_gcov_file($); sub read_gcov_file($);
*************** sub info(@);
*** 724,730 **** @@ -964,7 +966,7 @@ sub process_dafile($$)
if (defined($source)) if (defined($source))
{ {
! $source = solve_relative_path($base_dir, $source); - $source = solve_relative_path($base_dir, $source);
+ $source = find_source_file($base_dir, $source);
} }
# gcov will happily create output even if there's no source code # gcov will happily create output even if there's no source code
--- 726,732 ---- @@ -981,18 +983,9 @@ sub process_dafile($$)
if (defined($source))
{
! $source = find_source_file($base_dir, $source);
}
# gcov will happily create output even if there's no source code
***************
*** 741,758 ****
die("ERROR: could not read source file $source\n"); die("ERROR: could not read source file $source\n");
} }
! @matches = match_filename(defined($source) ? $source : - @matches = match_filename(defined($source) ? $source :
! $gcov_file, keys(%bb_content)); - $gcov_file, keys(%{$instr}));
+ next if ! -r $source;
# Skip files that are not mentioned in the graph file - # Skip files that are not mentioned in the graph file
! if (!@matches) - if (!@matches)
! { - {
! warn("WARNING: cannot find an entry for ".$gcov_file. - warn("WARNING: cannot find an entry for ".$gcov_file.
! " in $graph_file_extension file, skipping ". - " in $graph_file_extension file, skipping ".
! "file!\n"); - "file!\n");
! unlink($gcov_file); - unlink($gcov_file);
! next; - next;
! } - }
+ @matches = ($source);
# Read in contents of gcov file # Read in contents of gcov file
@result = read_gcov_file($gcov_file); @result = read_gcov_file($gcov_file);
--- 743,764 ---- @@ -1242,6 +1235,25 @@ sub solve_relative_path($$)
die("ERROR: could not read source file $source\n");
}
! next if ! -r $source;
!
! #@matches = match_filename(defined($source) ? $source :
! # $gcov_file, keys(%bb_content));
# Skip files that are not mentioned in the graph file
! #if (!@matches)
! #{
! # warn("WARNING: cannot find an entry for ".$gcov_file.
! # " in $graph_file_extension file, skipping ".
! # "file!\n");
! # unlink($gcov_file);
! # next;
! #}
!
! @matches = ($source);
# Read in contents of gcov file
@result = read_gcov_file($gcov_file);
***************
*** 949,954 ****
--- 955,979 ----
} }
+ sub find_source_file($$) +sub find_source_file($$)
+ { +{
+ my ($base_dir, $source) = @_; + my ($base_dir, $source) = @_;
+ my $dir = $base_dir; + my $dir = $base_dir;
+ +
@ -103,43 +66,19 @@ diff --exclude '*~' -rc lcov-1.7-orig/bin/geninfo lcov-1.7/bin/geninfo
+ } + }
+ } + }
+ return abs_path("$dir/$source"); + return abs_path("$dir/$source");
+ } +}
+ +
+ +
# #
# match_filename(gcov_filename, list) # match_filename(gcov_filename, list)
# #
*************** @@ -1918,7 +1930,7 @@ sub process_graphfile($$)
*** 1478,1484 ****
$function_name =~ s/\W/_/g;
(undef, $filename) =
read_gcno_string(*INPUT, $endianness);
! $filename = solve_relative_path($base_dir, $filename);
read(INPUT, $packed_word, 4); # Get path to data file in absolute and normalized form (begins with /,
$lineno = unpack_int32($packed_word, $endianness); # contains no more ../ or ./)
--- 1503,1509 ---- - $graph_filename = solve_relative_path($cwd, $graph_filename);
$function_name =~ s/\W/_/g; + $graph_filename = find_source_file($cwd, $graph_filename);
(undef, $filename) =
read_gcno_string(*INPUT, $endianness); # Get directory and basename of data file
! $filename = find_source_file($base_dir, $filename); ($graph_dir, $graph_basename) = split_filename($graph_filename);
read(INPUT, $packed_word, 4);
$lineno = unpack_int32($packed_word, $endianness);
***************
*** 1530,1536 ****
}
if ($blocks > 1)
{
! $filename = solve_relative_path(
$base_dir, $filename);
if (!defined($result{$filename}))
{
--- 1555,1561 ----
}
if ($blocks > 1)
{
! $filename = find_source_file(
$base_dir, $filename);
if (!defined($result{$filename}))
{