Commit 43173ef2 authored by Anel Husakovic's avatar Anel Husakovic Committed by Sergei Golubchik

MDEV-26102 dgcov: add support for *.gcda.gcov.json.gz files of gcov 9.1+

- Script covers situation for gcov (gcc) < 9 with non-json format of
generated files as well as for gcov (gcc) >=8 with json generated format

Reviewed by: serg@mariadb.com
parent 1547e554
......@@ -62,13 +62,16 @@ my $res;
my $cmd;
if ($opt_purge)
{
$cmd= "find . -name '*.da' -o -name '*.gcda' -o -name '*.gcov' -o ".
$cmd= "find . -name '*.da' -o -name '*.gcda*' -o -name '*.gcov' -o ".
"-name '*.dgcov' | grep -v 'README\.gcov' | xargs rm -f ''";
logv "Running: $cmd";
system($cmd)==0 or die "system($cmd): $? $!";
exit 0;
}
my $gcc_version= `gcc -dumpversion`;
$gcc_version=~ s/(\d).*$/$1/;
find(\&gcov_one_file, $root);
find(\&write_coverage, $root) if $opt_generate;
exit 0 if $opt_only_gcov;
......@@ -162,6 +165,7 @@ sub gcov_one_file {
}
# now, read the generated file
if ($gcc_version <9){
for my $gcov_file (<$_*.gcov>) {
open FH, '<', "$gcov_file" or die "open(<$gcov_file): $!";
my $fname;
......@@ -183,6 +187,20 @@ sub gcov_one_file {
}
close(FH);
}
} else {
use IO::Uncompress::Gunzip qw(gunzip $GunzipError);
use JSON::PP;
my $gcov_file_json;
my $fname;
gunzip "$_.gcov.json.gz" => \$gcov_file_json or die "gunzip($_.gcov.json.gz): $GunzipError";
my $obj= decode_json $gcov_file_json;
for my $file (@{$obj->{files}}) {
$fname= $file->{file};
for my $line (@{$file->{lines}}){
$cov{$fname}->{$line->{line_number}}+= $line->{count};
}
}
}
}
sub write_coverage {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment