deprecated/buildtools/buildsystemtools/scanlog/compare_summary.pl
changeset 663 8e27d440923e
parent 662 60be34e1b006
child 665 2068325a5906
equal deleted inserted replaced
662:60be34e1b006 663:8e27d440923e
     1 #
       
     2 # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 # All rights reserved.
       
     4 # This component and the accompanying materials are made available
       
     5 # under the terms of "Eclipse Public License v1.0"
       
     6 # which accompanies this distribution, and is available
       
     7 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 #
       
     9 # Initial Contributors:
       
    10 # Nokia Corporation - initial contribution.
       
    11 #
       
    12 # Contributors:
       
    13 #
       
    14 # Description: 
       
    15 #
       
    16 # usage:
       
    17 # perl compare_summary.pl new_build.summary last_build.summary > summary.summary
       
    18 #
       
    19 
       
    20 sub usage
       
    21 	{
       
    22 	print "syntax: perl compare_summary.pl new_build.summary last_build.summary\n";
       
    23 	exit 1;
       
    24 	}
       
    25 
       
    26 sub showtable
       
    27 	{
       
    28 	my $f=$_[0];
       
    29 	my $s=$_[1];
       
    30 	my %first=%$f;
       
    31 	my %second=%$s;
       
    32 
       
    33 	my %comps;
       
    34 	my $key,$n,$n2,$temp;
       
    35 
       
    36 	while ($key = each %first) {
       
    37 		$comps{$key}++;}
       
    38 	while ($key = each %second){
       
    39 		$comps{$key}++;}
       
    40 
       
    41 	foreach $key (sort keys %comps)
       
    42 		{
       
    43 		$n=$first{$key}; if ($n==0) {$n="0";}
       
    44 		$n2=$second{$key}; if ($n2==0) {$n2="0";}
       
    45 		$d=$n-$n2;
       
    46 		if ($d==0) {$d="";}
       
    47 		if ($d > 0) { $d="+$d";}
       
    48 
       
    49 		$temp=sprintf "(%s)",$n2;
       
    50 		printf "%-24.24s   %-5.5s%-7.7s\t\t%s\n", $key, $n, $temp, $d;
       
    51 		}
       
    52 	}
       
    53 
       
    54 
       
    55 
       
    56 $summaryfile1=$ARGV[0];
       
    57 $summaryfile2=$ARGV[1];
       
    58 
       
    59 if (($summaryfile1 eq "") or ($summaryfile2 eq "")) { usage() };
       
    60 
       
    61 open(FILE1, "< $summaryfile1") || die ("can't open summary file: $!");
       
    62 open(FILE2, "< $summaryfile2") || die ("can't open summary file: $!");
       
    63 
       
    64 # find the start of the error summary in file 1
       
    65 while (<FILE1>)
       
    66 	{
       
    67 	if (/Total+\s+(\S+)+\s+(\d+)+\s+(\d+)/)
       
    68 		{
       
    69 		$build1time=$1;
       
    70 		$build1errors=$2;
       
    71 		$build1warnings=$3;
       
    72 		last;
       
    73 		}
       
    74 	}
       
    75 # find the start of the error summary in file 2
       
    76 while (<FILE2>)
       
    77 	{
       
    78 	if (/Total+\s+(\S+)+\s+(\d+)+\s+(\d+)/)
       
    79 		{
       
    80 		$build2time=$1;
       
    81 		$build2errors=$2;
       
    82 		$build2warnings=$3;
       
    83 		last;
       
    84 		}
       
    85 	}
       
    86 
       
    87 print "Total\t\t$build1time($build2time)\t$build1errors($build2errors)\t$build1warnings($build2warnings)\n\n";
       
    88 
       
    89 # compare builds
       
    90 $build1haserrors=0;
       
    91 $build2haserrors=0;
       
    92 
       
    93 # find the "Fatal errors" line
       
    94 $dummy=<FILE1>;$dummy=<FILE1>;
       
    95 if ($dummy =~ /Fatal Errors by Component/) { $build1haserrors=1;}
       
    96 $dummy=<FILE2>;$dummy=<FILE2>;
       
    97 if ($dummy =~ /Fatal Errors by Component/) { $build2haserrors=1;}
       
    98 
       
    99 if ($build1haserrors)
       
   100 	{
       
   101 	while (<FILE1>)
       
   102 		{
       
   103 		if (/^(\S+)+\s+(\d+)/)
       
   104 			{
       
   105 			$theerrors1{$1}="$2";
       
   106 			}
       
   107 		else
       
   108 			{
       
   109 			last;
       
   110 			}
       
   111 		}
       
   112 	}
       
   113 if ($build2haserrors)
       
   114 	{
       
   115 	while (<FILE2>)
       
   116 		{
       
   117 		if (/^(\S+)+\s+(\d+)/)
       
   118 			{
       
   119 			$theerrors2{$1}="$2";
       
   120 			}
       
   121 		else
       
   122 			{
       
   123 			last;
       
   124 			}
       
   125 		}
       
   126 	}
       
   127 
       
   128 if ($build1haserrors || $build2haserrors)
       
   129 	{
       
   130 	print "Fatal Errors by Component\n";
       
   131 	showtable(\%theerrors1, \%theerrors2);
       
   132 	print;
       
   133 	}
       
   134 
       
   135 
       
   136 # do the warnings now
       
   137 $build1haswarnings=0;
       
   138 $build2haswarnings=0;
       
   139 seek FILE1,0,0;
       
   140 seek FILE2,0,0;
       
   141 while (<FILE1>)
       
   142 	{
       
   143 	if (/Warnings by Component/)
       
   144 		{
       
   145 		$build1haswarnings=1;
       
   146 		last;
       
   147 		}
       
   148 	}
       
   149 
       
   150 while (<FILE2>)
       
   151 	{
       
   152 	if (/Warnings by Component/)
       
   153 		{
       
   154 		$build2haswarnings=1;
       
   155 		last;
       
   156 		}
       
   157 	}
       
   158 
       
   159 # compare builds
       
   160 if ($build1haswarnings || $build2haswarnings)
       
   161 	{
       
   162 
       
   163 
       
   164 if ($build1haswarnings)
       
   165 	{
       
   166 	while (<FILE1>)
       
   167 		{
       
   168 		if (/^(\S+)\s+(\d+)/)
       
   169 			{
       
   170 			$thewarnings1{$1}=$2;
       
   171 			}
       
   172 		else
       
   173 			{
       
   174 			last;
       
   175 			}
       
   176 		}
       
   177 	}
       
   178 if ($build2haswarnings)
       
   179 	{
       
   180 	while (<FILE2>)
       
   181 		{
       
   182 		if (/^(\S+)\s+(\d+)/)
       
   183 			{
       
   184 			$thewarnings2{$1}=$2;
       
   185 			}
       
   186 		else
       
   187 			{
       
   188 			last;
       
   189 			}
       
   190 		}
       
   191 	}
       
   192 
       
   193 	print "Warnings by Component\n";
       
   194 	print "                          this (last)\n";
       
   195 	showtable(\%thewarnings1, \%thewarnings2);
       
   196 	}
       
   197 
       
   198 
       
   199 
       
   200 
       
   201 close FILE1;
       
   202 close FILE2;
       
   203