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