uh_parser/RaptorWarning.pm
changeset 176 6d3c3db11e72
child 182 20288e22722e
equal deleted inserted replaced
175:266a7e9b9237 176:6d3c3db11e72
       
     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 warnings i.e. content of <warning> tags from a raptor log file
       
    15 
       
    16 package RaptorWarning;
       
    17 
       
    18 use strict;
       
    19 use RaptorCommon;
       
    20 
       
    21 our $reset_status = {};
       
    22 my $buildlog_status = {};
       
    23 my $buildlog_warning_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} = {warning=>$buildlog_warning_status};
       
    30 $buildlog_status->{on_start} = 'RaptorWarning::on_start_buildlog';
       
    31 
       
    32 $buildlog_warning_status->{name} = 'buildlog_warning_status';
       
    33 $buildlog_warning_status->{next_status} = {};
       
    34 $buildlog_warning_status->{on_start} = 'RaptorWarning::on_start_buildlog_warning';
       
    35 $buildlog_warning_status->{on_end} = 'RaptorWarning::on_end_buildlog_warning';
       
    36 $buildlog_warning_status->{on_chars} = 'RaptorWarning::on_chars_buildlog_warning';
       
    37 
       
    38 my $filename = '';
       
    39 my $failure_item = 0;
       
    40 
       
    41 my $characters = '';
       
    42 
       
    43 my $CATEGORY_RAPTORWARNING = 'raptor_warning';
       
    44 my $CATEGORY_RAPTORWARNING_MISSINGFLAGABIV2 = 'missing_enable_abiv2_mode';
       
    45 
       
    46 sub process
       
    47 {
       
    48 	my ($text, $logfile, $component, $mmp, $phase, $recipe, $file, $line) = @_;
       
    49 	
       
    50 	my $category = $CATEGORY_RAPTORWARNING;
       
    51 	my $severity = '';
       
    52 	my $subcategory = '';
       
    53 	
       
    54 	if ($text =~ m,missing flag ENABLE_ABIV2_MODE,)
       
    55 	{
       
    56 		$severity = $RaptorCommon::SEVERITY_MINOR;
       
    57 		my $subcategory = $CATEGORY_RAPTORWARNING_MISSINGFLAGABIV2;
       
    58 		RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line);
       
    59 	}
       
    60 	else # log everything by default
       
    61 	{
       
    62 		RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line);
       
    63 	}
       
    64 }
       
    65 
       
    66 sub on_start_buildlog
       
    67 {
       
    68 	RaptorCommon::init();
       
    69 	
       
    70 	$filename = "$::raptorbitsdir/raptor_warning.txt";
       
    71 	if (!-f$filename)
       
    72 	{
       
    73 		print "Writing warnings file $filename\n";
       
    74 		open(FILE, ">$filename");
       
    75 		close(FILE);
       
    76 	}
       
    77 }
       
    78 sub on_start_buildlog_warning
       
    79 {
       
    80 	open(FILE, ">>$filename");
       
    81 }
       
    82 
       
    83 sub on_chars_buildlog_warning
       
    84 {
       
    85 	my ($ch) = @_;
       
    86 	
       
    87 	#print "on_chars_buildlog_warning\n";
       
    88 	
       
    89 	$characters .= $ch->{Data};
       
    90 	
       
    91 	#print "characters is now -->$characters<--\n";
       
    92 }
       
    93 
       
    94 sub on_end_buildlog_warning
       
    95 {
       
    96 	#print "on_end_buildlog_warning\n";
       
    97 	
       
    98 	$characters =~ s,^[\r\n]*,,;
       
    99 	$characters =~ s,[\r\n]*$,,;
       
   100 	
       
   101 	if ($characters =~ m,[^\s^\r^\n],)
       
   102 	{
       
   103 		if ($failure_item == 0 and -f "$filename")
       
   104 		{
       
   105 			open(FILE, "$filename");
       
   106 			{
       
   107 				local $/ = undef;
       
   108 				my $filecontent = <FILE>;
       
   109 				$failure_item = $1 if ($filecontent =~ m/.*---failure_item_(\d+)/s);
       
   110 			}
       
   111 			close(FILE);
       
   112 		}
       
   113 		
       
   114 		$failure_item++;
       
   115 	
       
   116 		open(FILE, ">>$filename");
       
   117 		print FILE "---failure_item_$failure_item\---\n";
       
   118 		print FILE "$characters\n\n";
       
   119 		close(FILE);
       
   120 		
       
   121 		process($characters, $::current_log_file, '', '', '', '', "raptor_warning.txt", $failure_item);
       
   122 	}
       
   123 	
       
   124 	$characters = '';
       
   125 }
       
   126 
       
   127 
       
   128 1;