common/tools/raptor/RaptorError.pm
author Dario Sestito <darios@symbian.org>
Tue, 18 Aug 2009 15:32:29 +0100
changeset 364 4dc3b5b1577c
parent 339 7297abc8565b
child 383 52675b624b66
permissions -rw-r--r--
Enable analysis of Raptor warnings. Publish to Diamonds
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};
324
f1baeb3f075f Generate error and summary file even if build reports no error
Dario Sestito <darios@symbian.org>
parents: 244
diff changeset
    30
$buildlog_status->{on_start} = 'RaptorError::on_start_buildlog';
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    31
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    32
$buildlog_error_status->{name} = 'buildlog_error_status';
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    33
$buildlog_error_status->{next_status} = {};
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    34
$buildlog_error_status->{on_start} = 'RaptorError::on_start_buildlog_error';
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    35
$buildlog_error_status->{on_end} = 'RaptorError::on_end_buildlog_error';
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    36
$buildlog_error_status->{on_chars} = 'RaptorError::on_chars_buildlog_error';
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    37
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
    38
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
    39
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    40
my $characters = '';
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    41
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    42
my $category = $RaptorCommon::CATEGORY_RAPTORERROR;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    43
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    44
sub process
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    45
{
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
    46
	my ($text, $component, $phase, $recipe, $file, $line) = @_;
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    47
	
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    48
	my $severity = $RaptorCommon::SEVERITY_UNKNOWN;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    49
	
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    50
	if ($text =~ m,Cannot process schema version .* of file,)
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    51
	{
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    52
		$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
    53
		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
    54
		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
    55
	}
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
	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
    57
	{
327
61f2add750f0 Added 3 raptor error categories, adjusted severity of all categories
Dario Sestito <darios@symbian.org>
parents: 324
diff changeset
    58
		$severity = $RaptorCommon::SEVERITY_MAJOR;
61f2add750f0 Added 3 raptor error categories, adjusted severity of all categories
Dario Sestito <darios@symbian.org>
parents: 324
diff changeset
    59
		my $subcategory = $RaptorCommon::CATEGORY_RAPTORERROR_NOBLDINFFOUND;
61f2add750f0 Added 3 raptor error categories, adjusted severity of all categories
Dario Sestito <darios@symbian.org>
parents: 324
diff changeset
    60
		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
61f2add750f0 Added 3 raptor error categories, adjusted severity of all categories
Dario Sestito <darios@symbian.org>
parents: 324
diff changeset
    61
	}
61f2add750f0 Added 3 raptor error categories, adjusted severity of all categories
Dario Sestito <darios@symbian.org>
parents: 324
diff changeset
    62
	elsif ($text =~ m,Can't find mmp file,)
61f2add750f0 Added 3 raptor error categories, adjusted severity of all categories
Dario Sestito <darios@symbian.org>
parents: 324
diff changeset
    63
	{
61f2add750f0 Added 3 raptor error categories, adjusted severity of all categories
Dario Sestito <darios@symbian.org>
parents: 324
diff changeset
    64
		$severity = $RaptorCommon::SEVERITY_NORMAL;
61f2add750f0 Added 3 raptor error categories, adjusted severity of all categories
Dario Sestito <darios@symbian.org>
parents: 324
diff changeset
    65
		my $subcategory = $RaptorCommon::CATEGORY_RAPTORERROR_CANTFINDMMPFILE;
61f2add750f0 Added 3 raptor error categories, adjusted severity of all categories
Dario Sestito <darios@symbian.org>
parents: 324
diff changeset
    66
		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
61f2add750f0 Added 3 raptor error categories, adjusted severity of all categories
Dario Sestito <darios@symbian.org>
parents: 324
diff changeset
    67
	}
61f2add750f0 Added 3 raptor error categories, adjusted severity of all categories
Dario Sestito <darios@symbian.org>
parents: 324
diff changeset
    68
	elsif ($text =~ m,The make-engine exited with errors,)
61f2add750f0 Added 3 raptor error categories, adjusted severity of all categories
Dario Sestito <darios@symbian.org>
parents: 324
diff changeset
    69
	{
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
    70
		$severity = $RaptorCommon::SEVERITY_CRITICAL;
327
61f2add750f0 Added 3 raptor error categories, adjusted severity of all categories
Dario Sestito <darios@symbian.org>
parents: 324
diff changeset
    71
		my $subcategory = $RaptorCommon::CATEGORY_RAPTORERROR_MAKEEXITEDWITHERRORS;
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
    72
		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
    73
	}
339
7297abc8565b Add new raptor error category to raptor parser (tool_didnt_return_version)
Dario Sestito <darios@symbian.org>
parents: 327
diff changeset
    74
	elsif ($text =~ m,tool .* from config .* did not return version .* as required,)
7297abc8565b Add new raptor error category to raptor parser (tool_didnt_return_version)
Dario Sestito <darios@symbian.org>
parents: 327
diff changeset
    75
	{
7297abc8565b Add new raptor error category to raptor parser (tool_didnt_return_version)
Dario Sestito <darios@symbian.org>
parents: 327
diff changeset
    76
		$severity = $RaptorCommon::SEVERITY_CRITICAL;
7297abc8565b Add new raptor error category to raptor parser (tool_didnt_return_version)
Dario Sestito <darios@symbian.org>
parents: 327
diff changeset
    77
		my $subcategory = $RaptorCommon::CATEGORY_RAPTORERROR_TOOLDIDNOTRETURNVERSION;
7297abc8565b Add new raptor error category to raptor parser (tool_didnt_return_version)
Dario Sestito <darios@symbian.org>
parents: 327
diff changeset
    78
		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
7297abc8565b Add new raptor error category to raptor parser (tool_didnt_return_version)
Dario Sestito <darios@symbian.org>
parents: 327
diff changeset
    79
	}
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
    80
	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
    81
	{
327
61f2add750f0 Added 3 raptor error categories, adjusted severity of all categories
Dario Sestito <darios@symbian.org>
parents: 324
diff changeset
    82
		$severity = $RaptorCommon::SEVERITY_NORMAL;
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
    83
		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
    84
		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
    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
324
f1baeb3f075f Generate error and summary file even if build reports no error
Dario Sestito <darios@symbian.org>
parents: 244
diff changeset
    88
sub on_start_buildlog
f1baeb3f075f Generate error and summary file even if build reports no error
Dario Sestito <darios@symbian.org>
parents: 244
diff changeset
    89
{
f1baeb3f075f Generate error and summary file even if build reports no error
Dario Sestito <darios@symbian.org>
parents: 244
diff changeset
    90
	RaptorCommon::init();
f1baeb3f075f Generate error and summary file even if build reports no error
Dario Sestito <darios@symbian.org>
parents: 244
diff changeset
    91
	
f1baeb3f075f Generate error and summary file even if build reports no error
Dario Sestito <darios@symbian.org>
parents: 244
diff changeset
    92
	$filename = "$::basedir/errors.txt";
f1baeb3f075f Generate error and summary file even if build reports no error
Dario Sestito <darios@symbian.org>
parents: 244
diff changeset
    93
	if (!-f$filename)
f1baeb3f075f Generate error and summary file even if build reports no error
Dario Sestito <darios@symbian.org>
parents: 244
diff changeset
    94
	{
364
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 339
diff changeset
    95
		print "Writing errors file $filename\n";
324
f1baeb3f075f Generate error and summary file even if build reports no error
Dario Sestito <darios@symbian.org>
parents: 244
diff changeset
    96
		open(FILE, ">$filename");
f1baeb3f075f Generate error and summary file even if build reports no error
Dario Sestito <darios@symbian.org>
parents: 244
diff changeset
    97
		close(FILE);
f1baeb3f075f Generate error and summary file even if build reports no error
Dario Sestito <darios@symbian.org>
parents: 244
diff changeset
    98
	}
f1baeb3f075f Generate error and summary file even if build reports no error
Dario Sestito <darios@symbian.org>
parents: 244
diff changeset
    99
}
f1baeb3f075f Generate error and summary file even if build reports no error
Dario Sestito <darios@symbian.org>
parents: 244
diff changeset
   100
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   101
sub on_start_buildlog_error
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
	open(FILE, ">>$filename");
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
sub on_chars_buildlog_error
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   107
{
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   108
	my ($ch) = @_;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   109
	
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   110
	#print "on_chars_buildlog_error\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   111
	
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   112
	$characters .= $ch->{Data};
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   113
	
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   114
	#print "characters is now -->$characters<--\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   115
}
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   116
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   117
sub on_end_buildlog_error
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   118
{
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   119
	#print "on_end_buildlog_error\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   120
	
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   121
	print FILE $characters if ($characters =~ m,[^\s^\r^\n],);
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   122
	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
   123
	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
   124
	
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
   125
	# 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
   126
	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
   127
	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
   128
	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
   129
	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
   130
	
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
   131
	process($characters, '', '', '', "errors.txt", $linecount);
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   132
	
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   133
	$characters = '';
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   134
}
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   135
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   136
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   137
1;