[igt-dev] [PATCH 6/6] scripts/code_cov_parse_info: print common coverage and extra per function

Kamil Konieczny kamil.konieczny at linux.intel.com
Thu Oct 6 11:25:26 UTC 2022


On 2022-09-22 at 10:46:18 +0200, Mauro Carvalho Chehab wrote:
> From: Mauro Carvalho Chehab <mchehab at kernel.org>
> 
> While analyzing the data, it is nice to have a quick summary about
> how much each set of the analyzed data contributes to the total.
> 
> So, generate a function summary report with the interception of
> all the sets ("common function coverage"), plus the difference
> that an individual test group contributes.
> 
> This is useful to provide a quick feedback on several situations:
> 
> - When comparing FULL with BAT:
> 	- how many functions are added on FULL?
> 	- are there functions that are only on BAT?
> 
> - When comparing different machines:
> 	- How many functions each individual machine has over
> 	  the common group?
> 
> - When comparing a group of tests:
> 	- How many functions an individual test adds for the
> 	  coverage that weren't covered at the common group yet?
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab at kernel.org>

Acked-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>

> ---
> 
> To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover.
> See [PATCH 0/6] at: https://lore.kernel.org/all/cover.1663836123.git.mchehab@kernel.org/
> 
>  scripts/code_cov_parse_info | 81 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 81 insertions(+)
> 
> diff --git a/scripts/code_cov_parse_info b/scripts/code_cov_parse_info
> index 7f3e1f9ef116..72a1e8c2b0ad 100755
> --- a/scripts/code_cov_parse_info
> +++ b/scripts/code_cov_parse_info
> @@ -574,6 +574,8 @@ sub generate_report($)
>  	%used_source = ();
>  	%files = ();
>  	%test_names = ();
> +	my @all_func_keys;
> +	my %info_files_with_func;
>  
>  	foreach my $f (@info_files) {
>  		foreach my $source (keys(%{$report{$f}{"all_line"}})) {
> @@ -586,6 +588,14 @@ sub generate_report($)
>  			foreach my $file (keys(%{$report{$f}{"all_func"}{$func}})) {
>  				$all_func{$func}{$file}->{ln} = $report{$f}{"all_func"}{$func}{$file}->{ln};
>  				$used_func{$func}->{$file} = 1 if ($report{$f}{"used_func"}{$func}->{$file});
> +				if ($report{$f}{"used_func"}{$func}->{$file}) {
> +					$used_func{$func}->{$file} = 1;
> +					if (!$info_files_with_func{"$file $func"}) {
> +						$info_files_with_func{"$file $func"} = 1;
> +					} else {
> +						$info_files_with_func{"$file $func"}++;
> +					}
> +				}
>  			}
>  		}
>  		foreach my $source (keys(%{$report{$f}{"all_branch"}})) {
> @@ -603,6 +613,25 @@ sub generate_report($)
>  	}
>  	gen_stats();
>  
> +	# Gen code coverage set comparision counters
> +	my $common_func_count = 0;
> +	foreach my $k (keys %info_files_with_func) {
> +		$common_func_count++ if ($info_files_with_func{$k} == scalar (@info_files));
> +	}
> +	foreach my $f (@info_files) {
> +		$report{$f}{"more_func"} = 0;
> +		$report{$f}{"uniq_func"} = 0;
> +		foreach my $func (keys(%{$report{$f}{"all_func"}})) {
> +			foreach my $file (keys(%{$report{$f}{"all_func"}{$func}})) {
> +				next if (!$report{$f}{"used_func"}{$func}->{$file});
> +				next if ($info_files_with_func{"$file $func"} == scalar (@info_files));
> +
> +				$report{$f}{"more_func"}++;
> +				$report{$f}{"uniq_func"}++ if ($info_files_with_func{"$file $func"} == 1);
> +			}
> +		}
> +	}
> +
>  	# Colors for the html output
>  
>  	my $red    = "style=\"background-color:#ffb3b3\"";
> @@ -720,6 +749,58 @@ sub generate_report($)
>  	}
>  	print OUT "  </tr>\n</table><p/>\n\n";
>  
> +	# Print function diff
> +	print OUT "  <h2>Differences on function coverage</h2>\n";
> +	print OUT "<table width=\"100%\" border=1 cellspacing=0 cellpadding=0>\n  <tr>\n";
> +	print OUT "    <th></th>\n";
> +	print OUT "    <th>Common to all</th>\n";
> +	foreach my $f (@info_files) {
> +		print OUT "    <th>$f</th>\n";
> +	}
> +	print OUT "    <th>TOTAL</th>\n";
> +
> +	print OUT "  </tr><tr>\n";
> +	print OUT "    <td>#Functions per category</td>\n";
> +
> +	printf OUT "    <td>%d</td>\n", $common_func_count;
> +
> +	foreach my $f (@info_files) {
> +		my %st = %{$report{$f}{"stats"}};
> +		if ($st{"func_count"}) {
> +			printf OUT "    <td>%d</td>\n", $st{"func_used"};
> +
> +		}
> +	}
> +	print OUT "    <td>" . $stats{"func_count"} . "</td>\n";
> +
> +	print OUT "  </tr><tr>\n";
> +	print OUT "    <td>#functions not in common</td>\n";
> +	print OUT "    <td></td>\n";
> +	foreach my $f (@info_files) {
> +		my %st = %{$report{$f}{"stats"}};
> +		if ($st{"func_count"}) {
> +			printf OUT "    <td>%d</td>\n", $report{$f}{"more_func"};
> +
> +		}
> +	}
> +	print OUT "    <td></td>\n";
> +
> +	print OUT "  </tr><tr>\n";
> +	print OUT "    <td>Unique functions</td>\n";
> +	print OUT "    <td></td>\n";
> +	foreach my $f (@info_files) {
> +		my %st = %{$report{$f}{"stats"}};
> +		if ($st{"func_count"}) {
> +			printf OUT "    <td>%d</td>\n", $report{$f}{"uniq_func"};
> +
> +		}
> +	}
> +	print OUT "    <td></td>\n";
> +
> +	print OUT "  </tr>\n</table><p/>\n\n";
> +
> +	# Print the filters applied when generating the report
> +
>  	if ($filter_str ne "") {
>  		printf OUT "<p>Filters: %s.</p>\n", $filter_str;
>  	} else {
> -- 
> 2.37.2
> 


More information about the igt-dev mailing list