common/tools/raptor/RaptorError.pm
author MattD <mattd@symbian.org>
Wed, 12 Aug 2009 10:30:24 +0100
changeset 313 52d855dfda13
parent 244 9544c55a7fd0
child 324 f1baeb3f075f
permissions -rw-r--r--
Changed 'publish' to 'sf-publish' to only publish the zips, not all logs. Changed behaviour so that 'sf.spec.package.src.enable'=false stops the source repos from getting packaged, but not the RnD ones (which are extracted again in platform builds)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     1
# Copyright (c) 2009 Symbian Foundation Ltd
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     2
# This component and the accompanying materials are made available
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     3
# under the terms of the License "Eclipse Public License v1.0"
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     4
# which accompanies this distribution, and is available
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     5
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     6
#
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     7
# Initial Contributors:
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     8
# Symbian Foundation Ltd - initial contribution.
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     9
#
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    10
# Contributors:
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    11
#
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    12
# Description:
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    13
# Raptor parser module.
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    14
# Extract, analyzes and dumps raptor errors i.e. content of <error> tags from a raptor log file
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    15
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    16
package RaptorError;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    17
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    18
use strict;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    19
use RaptorCommon;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    20
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    21
our $reset_status = {};
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    22
my $buildlog_status = {};
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    23
my $buildlog_error_status = {};
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    24
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    25
$reset_status->{name} = 'reset_status';
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    26
$reset_status->{next_status} = {buildlog=>$buildlog_status};
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    27
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    28
$buildlog_status->{name} = 'buildlog_status';
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    29
$buildlog_status->{next_status} = {error=>$buildlog_error_status};
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    30
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    31
$buildlog_error_status->{name} = 'buildlog_error_status';
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    32
$buildlog_error_status->{next_status} = {};
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    33
$buildlog_error_status->{on_start} = 'RaptorError::on_start_buildlog_error';
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    34
$buildlog_error_status->{on_end} = 'RaptorError::on_end_buildlog_error';
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    35
$buildlog_error_status->{on_chars} = 'RaptorError::on_chars_buildlog_error';
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    36
244
9544c55a7fd0 Raptor parser to provide summary csv file so that faults can be readily put into db
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    37
my $filename = '';
9544c55a7fd0 Raptor parser to provide summary csv file so that faults can be readily put into db
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    38
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    39
my $characters = '';
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    40
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    41
my $category = $RaptorCommon::CATEGORY_RAPTORERROR;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    42
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    43
sub process
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    44
{
244
9544c55a7fd0 Raptor parser to provide summary csv file so that faults can be readily put into db
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    45
	my ($text, $component, $phase, $recipe, $file, $line) = @_;
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    46
	
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    47
	my $severity = $RaptorCommon::SEVERITY_UNKNOWN;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    48
	
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    49
	if ($text =~ m,Cannot process schema version .* of file,)
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    50
	{
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    51
		$severity = $RaptorCommon::SEVERITY_CRITICAL;
244
9544c55a7fd0 Raptor parser to provide summary csv file so that faults can be readily put into db
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    52
		my $subcategory = $RaptorCommon::CATEGORY_RAPTORERROR_CANNOTPROCESSSCHEMAVERSION;
9544c55a7fd0 Raptor parser to provide summary csv file so that faults can be readily put into db
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    53
		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
9544c55a7fd0 Raptor parser to provide summary csv file so that faults can be readily put into db
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    54
	}
9544c55a7fd0 Raptor parser to provide summary csv file so that faults can be readily put into db
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    55
	elsif ($text =~ m,No bld\.inf found at,)
9544c55a7fd0 Raptor parser to provide summary csv file so that faults can be readily put into db
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    56
	{
9544c55a7fd0 Raptor parser to provide summary csv file so that faults can be readily put into db
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    57
		$severity = $RaptorCommon::SEVERITY_CRITICAL;
9544c55a7fd0 Raptor parser to provide summary csv file so that faults can be readily put into db
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    58
		my $subcategory = $RaptorCommon::CATEGORY_RAPTORERROR_NOBLDINFFOUND;
9544c55a7fd0 Raptor parser to provide summary csv file so that faults can be readily put into db
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    59
		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
9544c55a7fd0 Raptor parser to provide summary csv file so that faults can be readily put into db
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    60
	}
9544c55a7fd0 Raptor parser to provide summary csv file so that faults can be readily put into db
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    61
	else # log everything by default
9544c55a7fd0 Raptor parser to provide summary csv file so that faults can be readily put into db
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    62
	{
9544c55a7fd0 Raptor parser to provide summary csv file so that faults can be readily put into db
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    63
		$severity = $RaptorCommon::SEVERITY_UNKNOWN;
9544c55a7fd0 Raptor parser to provide summary csv file so that faults can be readily put into db
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    64
		my $subcategory = '';
9544c55a7fd0 Raptor parser to provide summary csv file so that faults can be readily put into db
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    65
		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    66
	}
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    67
}
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    68
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    69
sub on_start_buildlog_error
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    70
{
244
9544c55a7fd0 Raptor parser to provide summary csv file so that faults can be readily put into db
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    71
	$filename = "$::basedir/errors.txt";
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    72
	print "Writing error file $filename\n" if (!-f$filename);
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    73
	open(FILE, ">>$filename");
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    74
}
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    75
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    76
sub on_chars_buildlog_error
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    77
{
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    78
	my ($ch) = @_;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    79
	
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    80
	#print "on_chars_buildlog_error\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    81
	
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    82
	$characters .= $ch->{Data};
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    83
	
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    84
	#print "characters is now -->$characters<--\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    85
}
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    86
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    87
sub on_end_buildlog_error
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    88
{
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    89
	#print "on_end_buildlog_error\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    90
	
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    91
	print FILE $characters if ($characters =~ m,[^\s^\r^\n],);
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    92
	print FILE "\n" if ($characters !~ m,[\r\n]$, );
244
9544c55a7fd0 Raptor parser to provide summary csv file so that faults can be readily put into db
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    93
	close(FILE);
9544c55a7fd0 Raptor parser to provide summary csv file so that faults can be readily put into db
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    94
	
9544c55a7fd0 Raptor parser to provide summary csv file so that faults can be readily put into db
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    95
	# get the line number - not really optimized
9544c55a7fd0 Raptor parser to provide summary csv file so that faults can be readily put into db
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    96
	my $linecount = 0;
9544c55a7fd0 Raptor parser to provide summary csv file so that faults can be readily put into db
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    97
	open(FILE, "$filename");
9544c55a7fd0 Raptor parser to provide summary csv file so that faults can be readily put into db
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    98
	for ($linecount = 0; <FILE>; $linecount++) { }
9544c55a7fd0 Raptor parser to provide summary csv file so that faults can be readily put into db
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    99
	close(FILE);
9544c55a7fd0 Raptor parser to provide summary csv file so that faults can be readily put into db
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
   100
	
9544c55a7fd0 Raptor parser to provide summary csv file so that faults can be readily put into db
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
   101
	process($characters, '', '', '', "errors.txt", $linecount);
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   102
	
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   103
	$characters = '';
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   104
}
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   105
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   106
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   107
1;