summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@kernel.org>2022-12-05 15:13:25 +0100
committerMauro Carvalho Chehab <mchehab@kernel.org>2024-02-15 21:04:46 +0100
commit0d1f9770b615dca40f2277e27e3135c10e0b3ee1 (patch)
treeb6166b7e547629c759bd2988ee9b02331f4146e6 /scripts
parentcfca731679906fb2defaeb1587f57bb1161a6885 (diff)
scripts/code_cov_parse_info: fix files statistics
With fields rename at %record, the number of filtered files is not reflecting what it was actually there. Also, the was_used logic for json format was not parsing the same way as it used to be with info format. Fix those. Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org> Reviewed-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/code_cov_parse_info17
1 files changed, 10 insertions, 7 deletions
diff --git a/scripts/code_cov_parse_info b/scripts/code_cov_parse_info
index a33bcad29..a5c28a5c0 100755
--- a/scripts/code_cov_parse_info
+++ b/scripts/code_cov_parse_info
@@ -126,7 +126,6 @@ sub parse_json_gcov_v1($$)
my $file = shift;
my $json = shift;
- my $was_used = 0;
my $has_func = 0;
my $ignore = 0;
@@ -149,6 +148,7 @@ sub parse_json_gcov_v1($$)
my %cached;
for my $file_ref (@{$json->{'files'}}) {
my $source = $file_ref->{'file'};
+ my $was_used = 0;
$files{$source} = 1;
next if is_file_excluded($source);
@@ -181,8 +181,6 @@ sub parse_json_gcov_v1($$)
$was_used = 1;
}
}
- next if ($ignore_unused && !$was_used);
- $used_source{$source} = 1;
# Parse lines and branches
for my $line_ref (@{$file_ref->{'lines'}}) {
@@ -267,6 +265,7 @@ sub parse_json_gcov_v1($$)
}
$all_branch{$source}{$where}{count} += $branch_ref->{'count'};
+ $was_used = 1 if ($branch_ref->{'count'} > 0);
$i++;
}
@@ -274,6 +273,8 @@ sub parse_json_gcov_v1($$)
@{$record{files}{$source}{line}{$ln}{branches}} = ();
}
}
+ next if ($ignore_unused && !$was_used);
+ $used_source{$source} = 1;
}
# As the record was changed, we need to use a different format name
@@ -285,7 +286,6 @@ sub parse_json_internal_format_v1($$)
my $file = shift;
my $json = shift;
- my $was_used = 0;
my $has_func = 0;
my $ignore = 0;
my %cached;
@@ -305,6 +305,8 @@ sub parse_json_internal_format_v1($$)
for my $source (keys %{$json->{'files'}}) {
$files{$source} = 1;
+ my $was_used = 0;
+
next if is_file_excluded($source);
my $file_ref = \%{$json->{'files'}{$source}};
@@ -332,8 +334,6 @@ sub parse_json_internal_format_v1($$)
$was_used = 1;
}
}
- next if ($ignore_unused && !$was_used);
- $used_source{$source} = 1;
# Parse lines and branches
for my $ln (keys %{$file_ref->{line}}) {
@@ -400,12 +400,15 @@ sub parse_json_internal_format_v1($$)
}
$all_branch{$source}{$where}{count} += $taken;
+ $was_used = 1 if ($taken > 0);
$i++;
}
if (!defined($record{files}{$source}{line}{$ln}{branches})) {
@{$record{files}{$source}{line}{$ln}{branches}} = ();
}
}
+ next if ($ignore_unused && !$was_used);
+ $used_source{$source} = 1;
}
}
@@ -876,7 +879,7 @@ sub gen_stats()
# per-file coverage stats
$stats{"all_files"} = scalar keys(%files);
- $stats{"filtered_files"} = scalar keys(%record);
+ $stats{"filtered_files"} = scalar keys(%{$record{files}});
$stats{"used_files"} = scalar keys(%used_source);
}