[igt-dev] [PATCH i-g-t 03/12] code_cov_parse_info: use numberic sort for line numbers
Kamil Konieczny
kamil.konieczny at linux.intel.com
Wed Jan 25 13:57:10 UTC 2023
On 2023-01-17 at 15:05:58 +0100, Mauro Carvalho Chehab wrote:
> From: Mauro Carvalho Chehab <mchehab at kernel.org>
>
> The DA and BRDA information is originally numerically sorted.
>
> Sort it the same way at the output data.
>
> Signed-off-by: Mauro Carvalho Chehab <mchehab at kernel.org>
Reviewed-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>
> ---
> scripts/code_cov_parse_info | 19 +++++++++++++++++--
> 1 file changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/code_cov_parse_info b/scripts/code_cov_parse_info
> index d3739211b68a..ef44229983b6 100755
> --- a/scripts/code_cov_parse_info
> +++ b/scripts/code_cov_parse_info
> @@ -284,6 +284,21 @@ sub parse_info_data($)
> close IN or die;
> }
>
> +sub sort_where($$)
> +{
> + my @a = split ",", shift;
> + my @b = split ",", shift;
> + my $ret;
> +
> + $ret = $a[0] <=> $b[0];
> + return $ret if ($ret);
> +
> + $ret = $a[1] <=> $b[1];
> + return $ret if ($ret);
> +
> + return $a[2] <=> $b[2];
> +}
> +
> sub write_filtered_file($)
> {
> my $filter = shift;
> @@ -325,10 +340,10 @@ sub write_filtered_file($)
> }
> }
>
> - foreach my $ln(sort keys %{ $record{$source}{$func}{da} }) {
> + foreach my $ln(sort { $a <=> $b } keys %{ $record{$source}{$func}{da} }) {
> $filtered .= "DA:$ln," . $record{$source}{$func}{da}{$ln} . "\n";
> }
> - foreach my $where(sort keys %{ $record{$source}{$func}{brda} }) {
> + foreach my $where(sort sort_where keys %{ $record{$source}{$func}{brda} }) {
> my $taken = $record{$source}{$func}{brda}{$where};
> $taken = "-" if (!$taken);
> $filtered .= "BRDA:$where,$taken\n";
> --
> 2.39.0
>
More information about the igt-dev
mailing list