common/tools/raptor/RaptorError.pm
changeset 374 52675b624b66
parent 364 4dc3b5b1577c
equal deleted inserted replaced
373:cc469b3fe547 374:52675b624b66
    34 $buildlog_error_status->{on_start} = 'RaptorError::on_start_buildlog_error';
    34 $buildlog_error_status->{on_start} = 'RaptorError::on_start_buildlog_error';
    35 $buildlog_error_status->{on_end} = 'RaptorError::on_end_buildlog_error';
    35 $buildlog_error_status->{on_end} = 'RaptorError::on_end_buildlog_error';
    36 $buildlog_error_status->{on_chars} = 'RaptorError::on_chars_buildlog_error';
    36 $buildlog_error_status->{on_chars} = 'RaptorError::on_chars_buildlog_error';
    37 
    37 
    38 my $filename = '';
    38 my $filename = '';
       
    39 my $failure_item = 0;
    39 
    40 
    40 my $characters = '';
    41 my $characters = '';
    41 
    42 
    42 my $category = $RaptorCommon::CATEGORY_RAPTORERROR;
    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';
    43 
    49 
    44 sub process
    50 sub process
    45 {
    51 {
    46 	my ($text, $component, $phase, $recipe, $file, $line) = @_;
    52 	my ($text, $component, $phase, $recipe, $file, $line) = @_;
    47 	
    53 	
    48 	my $severity = $RaptorCommon::SEVERITY_UNKNOWN;
    54 	my $category = $CATEGORY_RAPTORERROR;
       
    55 	my $severity = '';
       
    56 	my $subcategory = '';
    49 	
    57 	
    50 	if ($text =~ m,Cannot process schema version .* of file,)
    58 	if ($text =~ m,Cannot process schema version .* of file,)
    51 	{
    59 	{
    52 		$severity = $RaptorCommon::SEVERITY_CRITICAL;
    60 		$severity = $RaptorCommon::SEVERITY_CRITICAL;
    53 		my $subcategory = $RaptorCommon::CATEGORY_RAPTORERROR_CANNOTPROCESSSCHEMAVERSION;
    61 		$subcategory = $CATEGORY_RAPTORERROR_CANNOTPROCESSSCHEMAVERSION;
    54 		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
    62 		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
    55 	}
    63 	}
    56 	elsif ($text =~ m,No bld\.inf found at,)
    64 	elsif ($text =~ m,No bld\.inf found at,)
    57 	{
    65 	{
    58 		$severity = $RaptorCommon::SEVERITY_MAJOR;
    66 		$severity = $RaptorCommon::SEVERITY_MAJOR;
    59 		my $subcategory = $RaptorCommon::CATEGORY_RAPTORERROR_NOBLDINFFOUND;
    67 		$subcategory = $CATEGORY_RAPTORERROR_NOBLDINFFOUND;
    60 		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
    68 		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
    61 	}
    69 	}
    62 	elsif ($text =~ m,Can't find mmp file,)
    70 	elsif ($text =~ m,Can't find mmp file,)
    63 	{
    71 	{
    64 		$severity = $RaptorCommon::SEVERITY_NORMAL;
    72 		$severity = $RaptorCommon::SEVERITY_MINOR;
    65 		my $subcategory = $RaptorCommon::CATEGORY_RAPTORERROR_CANTFINDMMPFILE;
    73 		$subcategory = $CATEGORY_RAPTORERROR_CANTFINDMMPFILE;
    66 		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
    74 		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
    67 	}
    75 	}
    68 	elsif ($text =~ m,The make-engine exited with errors,)
    76 	elsif ($text =~ m,The make-engine exited with errors,)
    69 	{
    77 	{
    70 		$severity = $RaptorCommon::SEVERITY_CRITICAL;
    78 		$severity = $RaptorCommon::SEVERITY_CRITICAL;
    71 		my $subcategory = $RaptorCommon::CATEGORY_RAPTORERROR_MAKEEXITEDWITHERRORS;
    79 		$subcategory = $CATEGORY_RAPTORERROR_MAKEEXITEDWITHERRORS;
    72 		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
    80 		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
    73 	}
    81 	}
    74 	elsif ($text =~ m,tool .* from config .* did not return version .* as required,)
    82 	elsif ($text =~ m,tool .* from config .* did not return version .* as required,)
    75 	{
    83 	{
    76 		$severity = $RaptorCommon::SEVERITY_CRITICAL;
    84 		$severity = $RaptorCommon::SEVERITY_CRITICAL;
    77 		my $subcategory = $RaptorCommon::CATEGORY_RAPTORERROR_TOOLDIDNOTRETURNVERSION;
    85 		$subcategory = $CATEGORY_RAPTORERROR_TOOLDIDNOTRETURNVERSION;
    78 		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
    86 		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
    79 	}
    87 	}
    80 	else # log everything by default
    88 	else # log everything by default
    81 	{
    89 	{
    82 		$severity = $RaptorCommon::SEVERITY_NORMAL;
       
    83 		my $subcategory = '';
       
    84 		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
    90 		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
    85 	}
    91 	}
    86 }
    92 }
    87 
    93 
    88 sub on_start_buildlog
    94 sub on_start_buildlog
    89 {
    95 {
    90 	RaptorCommon::init();
    96 	RaptorCommon::init();
    91 	
    97 	
    92 	$filename = "$::basedir/errors.txt";
    98 	$filename = "$::basedir/raptor_error.txt";
    93 	if (!-f$filename)
    99 	if (!-f$filename)
    94 	{
   100 	{
    95 		print "Writing errors file $filename\n";
   101 		print "Writing errors file $filename\n";
    96 		open(FILE, ">$filename");
   102 		open(FILE, ">$filename");
    97 		close(FILE);
   103 		close(FILE);
    98 	}
   104 	}
    99 }
   105 }
   100 
   106 
   101 sub on_start_buildlog_error
   107 sub on_start_buildlog_error
   102 {
   108 {
   103 	open(FILE, ">>$filename");
       
   104 }
   109 }
   105 
   110 
   106 sub on_chars_buildlog_error
   111 sub on_chars_buildlog_error
   107 {
   112 {
   108 	my ($ch) = @_;
   113 	my ($ch) = @_;
   116 
   121 
   117 sub on_end_buildlog_error
   122 sub on_end_buildlog_error
   118 {
   123 {
   119 	#print "on_end_buildlog_error\n";
   124 	#print "on_end_buildlog_error\n";
   120 	
   125 	
   121 	print FILE $characters if ($characters =~ m,[^\s^\r^\n],);
   126 	$characters =~ s,^[\r\n]*,,;
   122 	print FILE "\n" if ($characters !~ m,[\r\n]$, );
   127 	$characters =~ s,[\r\n]*$,,;
   123 	close(FILE);
       
   124 	
   128 	
   125 	# get the line number - not really optimized
   129 	if ($characters =~ m,[^\s^\r^\n],)
   126 	my $linecount = 0;
   130 	{	
   127 	open(FILE, "$filename");
   131 		if ($failure_item == 0 and -f "$filename")
   128 	for ($linecount = 0; <FILE>; $linecount++) { }
   132 		{
   129 	close(FILE);
   133 			open(FILE, "$filename");
       
   134 			{
       
   135 				local $/ = undef;
       
   136 				my $filecontent = <FILE>;
       
   137 				$failure_item = $1 if ($filecontent =~ m/.*---failure_item_(\d+)/s);
       
   138 			}
       
   139 			close(FILE);
       
   140 		}
       
   141 		
       
   142 		$failure_item++;
   130 	
   143 	
   131 	process($characters, '', '', '', "errors.txt", $linecount);
   144 		open(FILE, ">>$filename");
       
   145 		print FILE "---failure_item_$failure_item\---\n";
       
   146 		print FILE "$characters\n\n";
       
   147 		close(FILE);
       
   148 		
       
   149 		process($characters, '', '', '', "raptor_error.txt", $failure_item);
       
   150 	}
   132 	
   151 	
   133 	$characters = '';
   152 	$characters = '';
   134 }
   153 }
   135 
   154 
   136 
   155