common/tools/raptor/summarize.pl
author MattD <mattd@symbian.org>
Mon, 19 Oct 2009 11:49:45 +0100
changeset 691 a7fa60f12ba2
parent 383 52675b624b66
permissions -rw-r--r--
Catchup merge of tags
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
383
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     1
# Copyright (c) 2009 Symbian Foundation Ltd
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     2
# This component and the accompanying materials are made available
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     3
# under the terms of the License "Eclipse Public License v1.0"
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     4
# which accompanies this distribution, and is available
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     5
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     6
#
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     7
# Initial Contributors:
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     8
# Symbian Foundation Ltd - initial contribution.
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     9
#
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    10
# Contributors:
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    11
#
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    12
# Description:
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    13
# Generate an HTML summary of the Raptor build from the output of the raptor parser
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    14
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    15
use strict;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    16
use FindBin;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    17
use lib $FindBin::Bin;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    18
use Getopt::Long;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    19
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    20
my $raptorbitsdir = 0;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    21
my $outputdir = '.';
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    22
my $help = 0;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    23
GetOptions((
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    24
	'raptorbitsdir=s' => \$raptorbitsdir,
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    25
	'outputdir=s' => \$outputdir,
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    26
	'help!' => \$help
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    27
));
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    28
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    29
$help = 1 if (!$raptorbitsdir);
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    30
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    31
if ($help)
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    32
{
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    33
	print "Generate an HTML summary of the Raptor build from a summary.csv file\n";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    34
	print "Usage: perl summarize.pl --raptorbitsdir=DIR [--outputdir=DIR]\n";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    35
	exit(0);
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    36
}
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    37
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    38
$outputdir = "$outputdir/html";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    39
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    40
system("rd /S /Q $outputdir") if (-d $outputdir);
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    41
mkdir ($outputdir);
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    42
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    43
my $raptor_errors = {};
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    44
my $raptor_warnings = {};
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    45
my $raptor_unreciped = {};
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    46
my $general_failures_num_by_severity = {};
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    47
my $general_failures_by_category_severity = {};
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    48
my $recipe_failures_num_by_severity = {};
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    49
my $recipe_failures_by_package_severity = {};
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    50
#my $severities = {};
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    51
my @severities = ('critical', 'major', 'minor', 'unknown');
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    52
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    53
# READ SUMMARY.CSV FILE
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    54
my $csv_file = "$raptorbitsdir/summary.csv";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    55
my $csv_linenum = 0;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    56
open(CSV, $csv_file);
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    57
while(<CSV>)
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    58
{
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    59
	$csv_linenum ++;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    60
	my $line = $_;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    61
	
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    62
	if ($line =~ /([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*)/)
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    63
	{
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    64
		my $failure = {};
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    65
		$failure->{category} = $1;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    66
		$failure->{subcategory} = $2;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    67
		$failure->{severity} = $3;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    68
		$failure->{config} = $4;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    69
		$failure->{component} = $5;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    70
		$failure->{phase} = $6;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    71
		$failure->{recipe} = $7;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    72
		$failure->{file} = $8;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    73
		$failure->{linenum} = $9;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    74
		
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    75
		my $failure_package = '';
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    76
		
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    77
		if (!$failure->{category})
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    78
		{
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    79
			print "WARNING: summary line without a category at $csv_file line $csv_linenum. Skipping\n";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    80
			next;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    81
		}
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    82
		
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    83
		if ($failure->{category} =~ m,^recipe_failure$,i and !$failure->{component})
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    84
		{
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    85
			print "WARNING: recipe_failure with component field empty at $csv_file line $csv_linenum. Skipping\n";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    86
			next;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    87
		}
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    88
		if ($failure->{component})
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    89
		{
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    90
			if ($failure->{component} =~ m,/((os|mw|app|tools|ostools|adaptation)/[^/]*),)
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    91
			{
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    92
				$failure_package = $1;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    93
			}
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    94
			else
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    95
			{
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    96
				print "WARNING: summary line with wrong component path at $csv_file line $csv_linenum. Skipping\n";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    97
				next;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    98
			}
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    99
		}
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   100
		
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   101
		$failure->{subcategory} = 'uncategorized' if (!$failure->{subcategory});
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   102
		$failure->{severity} = 'unknown' if (!$failure->{severity});
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   103
		
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   104
		# populate severities dynamically.
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   105
		#$severities->{$failure->{severity}} = 1;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   106
		
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   107
		# put failure items into their category container
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   108
		if ($failure->{category} =~ /^raptor_(error|warning|unreciped)$/i)
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   109
		{
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   110
			$general_failures_num_by_severity->{$failure->{category}} = {} if (!defined $general_failures_num_by_severity->{$failure->{category}});
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   111
			my $general_failure = $general_failures_num_by_severity->{$failure->{category}};
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   112
			
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   113
			if (!defined $general_failure->{$failure->{severity}})
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   114
			{
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   115
				$general_failure->{$failure->{severity}} = 1;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   116
			}
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   117
			else
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   118
			{
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   119
				$general_failure->{$failure->{severity}} ++;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   120
			}
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   121
			
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   122
			$general_failures_by_category_severity->{$failure->{category}} = {} if (!defined $general_failures_by_category_severity->{$failure->{category}});
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   123
			$general_failures_by_category_severity->{$failure->{category}}->{$failure->{severity}} = [] if (!defined $general_failures_by_category_severity->{$failure->{category}}->{$failure->{severity}});
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   124
			push(@{$general_failures_by_category_severity->{$failure->{category}}->{$failure->{severity}}}, $failure);
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   125
		}
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   126
		elsif ($failure->{category} =~ /^recipe_failure$/i)
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   127
		{
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   128
			$recipe_failures_num_by_severity->{$failure_package} = {} if (!defined $recipe_failures_num_by_severity->{$failure_package});
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   129
			my $package_failure = $recipe_failures_num_by_severity->{$failure_package};
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   130
			
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   131
			if (!defined $package_failure->{$failure->{severity}})
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   132
			{
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   133
				$package_failure->{$failure->{severity}} = 1;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   134
			}
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   135
			else
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   136
			{
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   137
				$package_failure->{$failure->{severity}} ++;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   138
			}
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   139
			
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   140
			$recipe_failures_by_package_severity->{$failure_package} = {} if (!defined $recipe_failures_by_package_severity->{$failure_package});
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   141
			$recipe_failures_by_package_severity->{$failure_package}->{$failure->{severity}} = [] if (!defined $recipe_failures_by_package_severity->{$failure_package}->{$failure->{severity}});
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   142
			push(@{$recipe_failures_by_package_severity->{$failure_package}->{$failure->{severity}}}, $failure);
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   143
		}
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   144
	}
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   145
	else
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   146
	{
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   147
		print "WARNING: line does not match expected format at $csv_file line $csv_linenum. Skipping\n";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   148
	}
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   149
}
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   150
close(CSV);
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   151
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   152
# PRINT HTML SUMMARY
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   153
my $aggregated_html = "$outputdir/index.html";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   154
open(AGGREGATED, ">$aggregated_html");
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   155
print AGGREGATED "RAPTOR BUILD SUMMARY<br/>\n";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   156
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   157
print AGGREGATED "<br/>GENERAL FAILURES<br/>\n";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   158
print AGGREGATED "<table border='1'>\n";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   159
my $tableheader = "<tr><th>category</th>";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   160
for (@severities) { $tableheader .= "<th>$_</th>"; }
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   161
$tableheader .= "</tr>";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   162
print AGGREGATED "$tableheader\n";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   163
for my $category (keys %{$general_failures_num_by_severity})
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   164
{
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   165
	print_category_specific_summary($category, $general_failures_by_category_severity->{$category});
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   166
	my $categoryline = "<tr><td><a href='$category.html'>$category</a></td>";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   167
	for (@severities)
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   168
	{
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   169
		my $failuresbyseverity = 0;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   170
		$failuresbyseverity = $general_failures_num_by_severity->{$category}->{$_} if (defined $general_failures_num_by_severity->{$category}->{$_});
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   171
		$categoryline .= "<td>$failuresbyseverity</td>";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   172
	}
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   173
	$categoryline .= "</tr>";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   174
	print AGGREGATED "$categoryline\n";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   175
}
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   176
print AGGREGATED "</table>\n";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   177
print AGGREGATED "<br/>\n";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   178
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   179
print AGGREGATED "<br/>PACKGE-SPECIFIC FAILURES<br/>\n";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   180
print AGGREGATED "<table border='1'>\n";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   181
$tableheader = "<tr><th>package</th>";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   182
for (@severities) { $tableheader .= "<th>$_</th>"; }
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   183
$tableheader .= "</tr>";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   184
print AGGREGATED "$tableheader\n";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   185
for my $package (keys %{$recipe_failures_num_by_severity})
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   186
{
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   187
	print_package_specific_summary($package, $recipe_failures_by_package_severity->{$package});
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   188
	my $packagesummaryhtml = $package;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   189
	$packagesummaryhtml =~ s,/,_,;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   190
	$packagesummaryhtml .= ".html";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   191
	my $packageline = "<tr><td><a href='$packagesummaryhtml'>$package</a></td>";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   192
	for (@severities)
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   193
	{
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   194
		my $failuresbyseverity = 0;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   195
		$failuresbyseverity = $recipe_failures_num_by_severity->{$package}->{$_} if (defined $recipe_failures_num_by_severity->{$package}->{$_});
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   196
		$packageline .= "<td>$failuresbyseverity</td>";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   197
	}
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   198
	$packageline .= "</tr>";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   199
	print AGGREGATED "$packageline\n";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   200
}
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   201
print AGGREGATED "</table>\n";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   202
close(AGGREGATED);
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   203
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   204
translate_detail_files_to_html();
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   205
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   206
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   207
sub print_category_specific_summary
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   208
{
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   209
	my ($category, $failures_by_severity) = @_;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   210
	
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   211
	my $filenamebase = $category;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   212
	$filenamebase =~ s,/,_,;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   213
	
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   214
	open(SPECIFIC, ">$outputdir/$filenamebase.html");
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   215
	print SPECIFIC "FAILURES FOR CATEGORY $category<br/>\n";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   216
		
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   217
	for my $severity (@severities)
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   218
	{
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   219
		if (defined $failures_by_severity->{$severity})
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   220
		{
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   221
			print SPECIFIC "<br/>".uc($severity)."<br/>\n";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   222
			print SPECIFIC "<table border='1'>\n";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   223
			# $subcategory, $severity, $component, $phase, $recipe, $file, $line
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   224
			my $tableheader = "<tr><th>category</th><th>configuration</th><th>log snippet</th></tr>";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   225
			print SPECIFIC "$tableheader\n";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   226
			
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   227
			for my $failure (@{$failures_by_severity->{$severity}})
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   228
			{
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   229
				my $failureline = "<tr><td>$failure->{subcategory}</td>";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   230
				$failureline .= "<td>$failure->{config}</td>";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   231
				$failureline .= "<td><a href='$filenamebase\_failures.html#failure_item_$failure->{linenum}'>item $failure->{linenum}</a></td>";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   232
				$failureline .= "</tr>";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   233
				print SPECIFIC "$failureline\n";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   234
			}
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   235
			
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   236
			print SPECIFIC "</table>\n";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   237
			print SPECIFIC "<br/>\n";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   238
		}
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   239
	}
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   240
	
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   241
	close(SPECIFIC);
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   242
}
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   243
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   244
sub print_package_specific_summary
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   245
{
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   246
	my ($package, $failures_by_severity) = @_;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   247
	
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   248
	my $filenamebase = $package;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   249
	$filenamebase =~ s,/,_,;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   250
	
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   251
	open(SPECIFIC, ">$outputdir/$filenamebase.html");
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   252
	print SPECIFIC "FAILURES FOR PACKAGE $package<br/>\n";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   253
		
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   254
	for my $severity (@severities)
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   255
	{
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   256
		if (defined $failures_by_severity->{$severity})
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   257
		{
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   258
			print SPECIFIC "<br/>".uc($severity)."<br/>\n";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   259
			print SPECIFIC "<table border='1'>\n";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   260
			# $subcategory, $severity, $component, $phase, $recipe, $file, $line
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   261
			my $tableheader = "<tr><th>category</th><th>configuration</th><th>component</th><th>phase</th><th>recipe</th><th>log snippet</th></tr>";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   262
			print SPECIFIC "$tableheader\n";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   263
			
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   264
			for my $failure (@{$failures_by_severity->{$severity}})
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   265
			{
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   266
				my $failureline = "<tr><td>$failure->{subcategory}</td>";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   267
				$failureline .= "<td>$failure->{config}</td>";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   268
				$failureline .= "<td>$failure->{component}</td>";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   269
				$failureline .= "<td>$failure->{phase}</td>";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   270
				$failureline .= "<td>$failure->{recipe}</td>";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   271
				$failureline .= "<td><a href='$filenamebase\_failures.html#failure_item_$failure->{linenum}'>item $failure->{linenum}</a></td>";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   272
				$failureline .= "</tr>";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   273
				print SPECIFIC "$failureline\n";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   274
			}
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   275
			
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   276
			print SPECIFIC "</table>\n";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   277
			print SPECIFIC "<br/>\n";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   278
		}
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   279
	}
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   280
	
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   281
	close(SPECIFIC);
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   282
}
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   283
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   284
sub translate_detail_files_to_html
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   285
{
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   286
	opendir(DIR, $raptorbitsdir);
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   287
	my @failurefiles = readdir(DIR);
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   288
	closedir(DIR);	
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   289
	@failurefiles = grep(/\.txt$/, @failurefiles);
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   290
	
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   291
	for my $file (@failurefiles)
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   292
	{
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   293
		$file =~ /(.*)\.txt$/;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   294
		my $filenamebase = $1;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   295
		
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   296
		my $filecontent = '';
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   297
		open(FILE, "$raptorbitsdir/$file");
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   298
		{
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   299
			local $/=undef;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   300
			$filecontent = <FILE>;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   301
		}
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   302
		close(FILE);
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   303
		
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   304
		$filecontent =~ s,---(failure_item_\d+)---,<a name="$1">---$1---</a>,g;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   305
		$filecontent = "<pre>$filecontent</pre>";
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   306
		
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   307
		open(FILE, ">$outputdir/$filenamebase\_failures.html");
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   308
		print FILE $filecontent;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   309
		close(FILE);
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   310
	}
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   311
}