177
|
1 |
# Copyright (c) 2009 Symbian Foundation Ltd
|
|
2 |
# This component and the accompanying materials are made available
|
|
3 |
# under the terms of the License "Eclipse Public License v1.0"
|
|
4 |
# which accompanies this distribution, and is available
|
|
5 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
6 |
#
|
|
7 |
# Initial Contributors:
|
|
8 |
# Symbian Foundation Ltd - initial contribution.
|
|
9 |
#
|
|
10 |
# Contributors:
|
|
11 |
#
|
|
12 |
# Description:
|
|
13 |
# Raptor parser module.
|
|
14 |
# Extract, analyzes and dumps raptor errors i.e. content of <error> tags from a raptor log file
|
|
15 |
|
|
16 |
package RaptorError;
|
|
17 |
|
|
18 |
use strict;
|
|
19 |
use RaptorCommon;
|
|
20 |
|
|
21 |
our $reset_status = {};
|
|
22 |
my $buildlog_status = {};
|
|
23 |
my $buildlog_error_status = {};
|
|
24 |
|
|
25 |
$reset_status->{name} = 'reset_status';
|
|
26 |
$reset_status->{next_status} = {buildlog=>$buildlog_status};
|
|
27 |
|
|
28 |
$buildlog_status->{name} = 'buildlog_status';
|
|
29 |
$buildlog_status->{next_status} = {error=>$buildlog_error_status};
|
|
30 |
$buildlog_status->{on_start} = 'RaptorError::on_start_buildlog';
|
|
31 |
|
|
32 |
$buildlog_error_status->{name} = 'buildlog_error_status';
|
|
33 |
$buildlog_error_status->{next_status} = {};
|
|
34 |
$buildlog_error_status->{on_start} = 'RaptorError::on_start_buildlog_error';
|
|
35 |
$buildlog_error_status->{on_end} = 'RaptorError::on_end_buildlog_error';
|
|
36 |
$buildlog_error_status->{on_chars} = 'RaptorError::on_chars_buildlog_error';
|
|
37 |
|
|
38 |
my $filename = '';
|
|
39 |
my $failure_item = 0;
|
|
40 |
|
|
41 |
my $characters = '';
|
|
42 |
|
|
43 |
my $CATEGORY_RAPTORERROR = 'raptor_error';
|
|
44 |
my $CATEGORY_RAPTORERROR_CANNOTPROCESSSCHEMAVERSION = 'cannot_process_schema_version';
|
|
45 |
my $CATEGORY_RAPTORERROR_NOBLDINFFOUND = 'no_bld_inf_found';
|
|
46 |
my $CATEGORY_RAPTORERROR_CANTFINDMMPFILE = 'cant_find_mmp_file';
|
|
47 |
my $CATEGORY_RAPTORERROR_MAKEEXITEDWITHERRORS = 'make_exited_with_errors';
|
|
48 |
my $CATEGORY_RAPTORERROR_TOOLDIDNOTRETURNVERSION = 'tool_didnot_return_version';
|
|
49 |
my $CATEGORY_RAPTORERROR_UNKNOWNBUILDCONFIG = 'unknown_build_config';
|
|
50 |
my $CATEGORY_RAPTORERROR_NOBUILDCONFIGSGIVEN = 'no_build_configs_given';
|
|
51 |
|
|
52 |
sub process
|
|
53 |
{
|
|
54 |
my ($text, $logfile, $component, $mmp, $phase, $recipe, $file, $line) = @_;
|
|
55 |
|
|
56 |
my $category = $CATEGORY_RAPTORERROR;
|
|
57 |
my $severity = '';
|
|
58 |
my $subcategory = '';
|
|
59 |
|
|
60 |
if ($text =~ m,Cannot process schema version .* of file,)
|
|
61 |
{
|
|
62 |
$severity = $RaptorCommon::SEVERITY_CRITICAL;
|
|
63 |
$subcategory = $CATEGORY_RAPTORERROR_CANNOTPROCESSSCHEMAVERSION;
|
|
64 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line);
|
|
65 |
}
|
|
66 |
elsif ($text =~ m,No bld\.inf found at,)
|
|
67 |
{
|
|
68 |
$severity = $RaptorCommon::SEVERITY_MAJOR;
|
|
69 |
$subcategory = $CATEGORY_RAPTORERROR_NOBLDINFFOUND;
|
|
70 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line);
|
|
71 |
}
|
|
72 |
elsif ($text =~ m,Can't find mmp file,)
|
|
73 |
{
|
|
74 |
$severity = $RaptorCommon::SEVERITY_MINOR;
|
|
75 |
$subcategory = $CATEGORY_RAPTORERROR_CANTFINDMMPFILE;
|
|
76 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line);
|
|
77 |
}
|
|
78 |
elsif ($text =~ m,The make-engine exited with errors,)
|
|
79 |
{
|
|
80 |
$severity = $RaptorCommon::SEVERITY_CRITICAL;
|
|
81 |
$subcategory = $CATEGORY_RAPTORERROR_MAKEEXITEDWITHERRORS;
|
|
82 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line);
|
|
83 |
}
|
|
84 |
elsif ($text =~ m,tool .* from config .* did not return version .* as required,)
|
|
85 |
{
|
|
86 |
$severity = $RaptorCommon::SEVERITY_CRITICAL;
|
|
87 |
$subcategory = $CATEGORY_RAPTORERROR_TOOLDIDNOTRETURNVERSION;
|
|
88 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line);
|
|
89 |
}
|
|
90 |
elsif ($text =~ m,Unknown build configuration '.*',)
|
|
91 |
{
|
|
92 |
$severity = $RaptorCommon::SEVERITY_CRITICAL;
|
|
93 |
$subcategory = $CATEGORY_RAPTORERROR_UNKNOWNBUILDCONFIG;
|
|
94 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line);
|
|
95 |
}
|
|
96 |
elsif ($text =~ m,No build configurations given,)
|
|
97 |
{
|
|
98 |
$severity = $RaptorCommon::SEVERITY_CRITICAL;
|
|
99 |
$subcategory = $CATEGORY_RAPTORERROR_NOBUILDCONFIGSGIVEN;
|
|
100 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line);
|
|
101 |
}
|
|
102 |
else # log everything by default
|
|
103 |
{
|
|
104 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line);
|
|
105 |
}
|
|
106 |
}
|
|
107 |
|
|
108 |
sub on_start_buildlog
|
|
109 |
{
|
|
110 |
RaptorCommon::init();
|
|
111 |
|
|
112 |
$filename = "$::raptorbitsdir/raptor_error.txt";
|
|
113 |
if (!-f$filename)
|
|
114 |
{
|
|
115 |
print "Writing errors file $filename\n";
|
|
116 |
open(FILE, ">$filename");
|
|
117 |
close(FILE);
|
|
118 |
}
|
|
119 |
}
|
|
120 |
|
|
121 |
sub on_start_buildlog_error
|
|
122 |
{
|
|
123 |
}
|
|
124 |
|
|
125 |
sub on_chars_buildlog_error
|
|
126 |
{
|
|
127 |
my ($ch) = @_;
|
|
128 |
|
|
129 |
#print "on_chars_buildlog_error\n";
|
|
130 |
|
|
131 |
$characters .= $ch->{Data};
|
|
132 |
|
|
133 |
#print "characters is now -->$characters<--\n";
|
|
134 |
}
|
|
135 |
|
|
136 |
sub on_end_buildlog_error
|
|
137 |
{
|
|
138 |
#print "on_end_buildlog_error\n";
|
|
139 |
|
|
140 |
$characters =~ s,^[\r\n]*,,;
|
|
141 |
$characters =~ s,[\r\n]*$,,;
|
|
142 |
|
|
143 |
if ($characters =~ m,[^\s^\r^\n],)
|
|
144 |
{
|
|
145 |
if ($failure_item == 0 and -f "$filename")
|
|
146 |
{
|
|
147 |
open(FILE, "$filename");
|
|
148 |
{
|
|
149 |
local $/ = undef;
|
|
150 |
my $filecontent = <FILE>;
|
|
151 |
$failure_item = $1 if ($filecontent =~ m/.*---failure_item_(\d+)/s);
|
|
152 |
}
|
|
153 |
close(FILE);
|
|
154 |
}
|
|
155 |
|
|
156 |
$failure_item++;
|
|
157 |
|
|
158 |
open(FILE, ">>$filename");
|
|
159 |
print FILE "---failure_item_$failure_item\---\n";
|
|
160 |
print FILE "$characters\n\n";
|
|
161 |
close(FILE);
|
|
162 |
|
|
163 |
process($characters, $::current_log_file, '', '', '', '', "raptor_error.txt", $failure_item);
|
|
164 |
}
|
|
165 |
|
|
166 |
$characters = '';
|
|
167 |
}
|
|
168 |
|
|
169 |
|
|
170 |
1; |