forked from github/verilator
Internal code coverage: Better support fastcov [still not default].
This commit is contained in:
parent
f1afa667d7
commit
abc3c216f8
@ -16,6 +16,7 @@ use strict;
|
||||
use vars qw($Debug);
|
||||
|
||||
our $Opt_Stop = 1;
|
||||
our $Opt_Fastcov = 0;
|
||||
our $Exclude_Line_Regexp;
|
||||
our $Remove_Gcda_Regexp;
|
||||
|
||||
@ -30,7 +31,6 @@ $SIG{TERM} = sub { $Fork->kill_tree_all('TERM') if $Fork && $Fork->in_parent; di
|
||||
#======================================================================
|
||||
# main
|
||||
|
||||
our $Opt_Fastcov = 0; # out of memory
|
||||
our $Opt_Hashset;
|
||||
our $opt_stages = '';
|
||||
our $Opt_Scenarios;
|
||||
@ -43,6 +43,7 @@ if (! GetOptions(
|
||||
"debug" => sub { $Debug = 1; },
|
||||
"hashset=s" => \$Opt_Hashset, # driver.pl hashset
|
||||
"<>" => sub { die "%Error: Unknown parameter: $_[0]\n"; },
|
||||
"fastcov!" => \$Opt_Fastcov, # use fastcov, not documented, for debug
|
||||
"scenarios=s" => \$Opt_Scenarios, # driver.pl scenarios
|
||||
"stages=s" => \$opt_stages, # starting stage number
|
||||
"stop!" => \$Opt_Stop, # stop/do not stop on error in tests
|
||||
@ -109,8 +110,8 @@ sub test {
|
||||
|
||||
my $cc_dir = "nodist/obj_dir/coverage";
|
||||
if ($Opt_Stages{4}) {
|
||||
travis_fold_start("info");
|
||||
print "Stage 4: Create info files under $cc_dir\n";
|
||||
travis_fold_start("gcno");
|
||||
print "Stage 4: Create gcno files under $cc_dir\n";
|
||||
mkpath($cc_dir);
|
||||
mkpath("$cc_dir/info");
|
||||
my $dats = `find . -print | grep .gcda`;
|
||||
@ -149,31 +150,11 @@ sub test {
|
||||
travis_fold_end();
|
||||
}
|
||||
|
||||
my $Opt_Fastcov = 0;
|
||||
if ($Opt_Stages{5} && $Opt_Fastcov) {
|
||||
travis_fold_start("fastcov");
|
||||
#Runs out of memory:
|
||||
#run("${RealBin}/fastcov.py -o $cc_dir/app_total.info");
|
||||
#Drops a lot of coverage:
|
||||
my $dats = `find . -print | grep .gcda`;
|
||||
my %dirs;
|
||||
my @dats = sort(split '\n', $dats);
|
||||
foreach my $dat (@dats) {
|
||||
(my $dir = $dat) =~ s!/[^/]+$!!;
|
||||
$dirs{$dir} = 1;
|
||||
}
|
||||
my $chunk = 0;
|
||||
my $comb = "";
|
||||
foreach my $dat (@dats) {
|
||||
$comb .= " -f ../../../../$dat";
|
||||
# Need to batch to avoid memory limit
|
||||
if (length($comb) > 20000 || $dat eq $dats[$#dats]) {
|
||||
run("cd $cc_dir/info ; ${RealBin}/fastcov.py ${comb} --exclude /usr -o app_chunk_${chunk}.info");
|
||||
$comb = "";
|
||||
++$chunk;
|
||||
}
|
||||
}
|
||||
|
||||
# Must run in root directory to find all files
|
||||
mkpath($cc_dir);
|
||||
run("${RealBin}/fastcov.py -X --lcov --exclude /usr -o ${cc_dir}/app_fastcov.info");
|
||||
travis_fold_end();
|
||||
}
|
||||
|
||||
@ -224,21 +205,32 @@ sub test {
|
||||
print "Stage 10: Combine data files\n";
|
||||
run("cd $cc_dir ; lcov -c -i -d src/obj_dbg -o app_base.info");
|
||||
run("cd $cc_dir ; lcov -a app_base.info -o app_total.info");
|
||||
my $infos = `cd $cc_dir ; find info -print | grep .info`;
|
||||
my $comb = "";
|
||||
my @infos = (sort (split /\n/, $infos));
|
||||
foreach my $info (@infos) {
|
||||
$comb .= " -a $info";
|
||||
# Need to batch them to avoid overrunning shell command length limit
|
||||
if (length($comb) > 10000 || $info eq $infos[$#infos]) {
|
||||
# .info may be empty, so ignore errors (unfortunately)
|
||||
run("cd $cc_dir ; lcov -a app_total.info $comb -o app_total.info || true");
|
||||
$comb = "";
|
||||
if ($Opt_Fastcov) {
|
||||
run("cd $cc_dir ; lcov -a app_base.info -a app_fastcov.info -o app_total.info");
|
||||
} else {
|
||||
my $infos = `cd $cc_dir ; find info -print | grep .info`;
|
||||
my $comb = "";
|
||||
my @infos = (sort (split /\n/, $infos));
|
||||
foreach my $info (@infos) {
|
||||
$comb .= " -a $info";
|
||||
# Need to batch them to avoid overrunning shell command length limit
|
||||
if (length($comb) > 10000 || $info eq $infos[$#infos]) {
|
||||
# .info may be empty, so ignore errors (unfortunately)
|
||||
run("cd $cc_dir ; lcov -a app_total.info $comb -o app_total.info || true");
|
||||
$comb = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
travis_fold_end();
|
||||
}
|
||||
|
||||
if ($Opt_Stages{11}) {
|
||||
travis_fold_start("dirs");
|
||||
print "Stage 11: Cleanup paths\n";
|
||||
cleanup_abs_paths($cc_dir, "$cc_dir/app_total.info", "$cc_dir/app_total.info");
|
||||
travis_fold_end();
|
||||
}
|
||||
|
||||
if ($Opt_Stages{12}) {
|
||||
travis_fold_start("filter");
|
||||
print "Stage 12: Filter processed source files\n";
|
||||
@ -253,7 +245,6 @@ sub test {
|
||||
if ($Opt_Stages{17}) {
|
||||
travis_fold_start("report");
|
||||
print "Stage 17: Create HTML\n";
|
||||
cleanup_abs_paths($cc_dir, "$cc_dir/app_total.info", "$cc_dir/app_total.info");
|
||||
run("cd $cc_dir ; genhtml app_total.info --demangle-cpp"
|
||||
." --rc lcov_branch_coverage=1 --rc genhtml_hi_limit=100 --output-directory html");
|
||||
travis_fold_end();
|
||||
|
@ -12,7 +12,7 @@ scenarios(dist => 1);
|
||||
|
||||
my $root = "..";
|
||||
|
||||
my $Tabs_Exempt_Re = qr!(\.out$)|(/gtkwave)|(Makefile)|(\.mk$)!;
|
||||
my $Tabs_Exempt_Re = qr!(\.out$)|(/gtkwave)|(Makefile)|(\.mk$)|(nodist/fastcov.py)!;
|
||||
|
||||
if (!-r "$root/.git") {
|
||||
skip("Not in a git repository");
|
||||
@ -68,7 +68,7 @@ if (!-r "$root/.git") {
|
||||
}
|
||||
my $len = length($1);
|
||||
if ($len >= 100
|
||||
&& $file !~ /\.out$/) {
|
||||
&& $file !~ $Tabs_Exempt_Re) {
|
||||
print" Wide $line\n" if $Self->{verbose};
|
||||
$summary = "File modification adds a new >100 column line:" if !$summary;
|
||||
$warns{$file} = "File modification adds a new >100 column line: $file:$lineno";
|
||||
|
Loading…
Reference in New Issue
Block a user