Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
authorSimon Howkins <simonh@symbian.org>
Mon, 13 Jul 2009 17:43:50 +0100
changeset 228 71d24b4fa162
parent 227 51e429810aba
child 230 2719a5d09e27
Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170. Also re-jigged to use STDIN and STDOUT rather than filename options on the CLI.
common/build.xml
common/tools/raptor/preprocess_log.pl
--- a/common/build.xml	Mon Jul 13 11:38:30 2009 +0100
+++ b/common/build.xml	Mon Jul 13 17:43:50 2009 +0100
@@ -757,69 +757,67 @@
             <arg value="${build.log.dir}/analysis/${build.id}_what_results.csv"/>
         </exec>
         
-    <echo message="Running yarp over *_compile.log files"/>
-    <for param="logfile">
-      <path>
-        <fileset dir="${build.log.dir}">
-          <include name="*_compile.log"/>
-          <exclude name="*build_check_compile.log"/>
-        </fileset>
-      </path>
-      <sequential>
-        <propertyregex override="yes" property="yarpfile"  input="@{logfile}" regexp=".*[\\|\/](.*)_compile\.log" replace="\1_yarp.csv"/>
-        <propertyregex override="yes" property="yarpfile_short"  input="${yarpfile}" regexp="[^_]*_[^_]*_[^_]*_(.+)_[^_]*_yarp\.csv" replace="YARP_\1"/>
-        <echo message="Yarping @{logfile}..."/>
-        <exec executable="perl" dir="${build.drive}" failonerror="false" output="${build.log.dir}/analysis/${build.id}_yarp.log" append="true">
-          <arg value="${sf.common.config.dir}/tools/analysis/yarp.pl"/>
-          <arg value="@{logfile}"/>
-          <arg value="${build.log.dir}/analysis/${yarpfile}"/>
-        </exec>
-        <exec executable="cmd" output="${build.drive}/output/logs/analysis/tmp_yarp_files.csv" append="true">
-          <arg value="/c"/>
-          <arg value="echo"/>
-          <arg value="${yarpfile_short},${sf.spec.publish.networkdrive}\${sf.spec.job.name}\builds\${sf.spec.job.codeline}\${build.id}\logs\analysis\${yarpfile},${build.drive}\output\logs\analysis\${yarpfile}"/>
-        </exec>
-      </sequential>
-    </for>
-    
-    <exec executable="perl" dir="${build.drive}" failonerror="false" outputproperty="sf.job.totalyarperrors">
-      <arg value="${sf.common.config.dir}/tools/analysis/parse_yarp_files.pl"/>
-      <arg value="${build.drive}/output/logs/analysis/tmp_yarp_files.csv"/>
-    </exec>
-    <echo message="Total yarp errors: ${sf.job.totalyarperrors}"/>
-    
-    <fmpp sourceFile="${sf.common.config.dir}/diamonds/sf-run-analysis.xml.ftl" outputFile="${build.drive}/output/logs/sf-run-analysis.xml">
-      <data expandProperties="yes">
-        ant: antProperties()
-        files: csv(${build.drive}/output/logs/analysis/tmp_yarp_files.csv,{separator:',',headers:[name,path,localpath]})
-      </data>
-    </fmpp>
-    
-    <echo message="Extracting whatlog information from *whatlog*_compile.log files"/>
-    <for param="logfile">
-      <path>
-        <fileset dir="${build.log.dir}">
-          <include name="*whatlog*_compile.log"/>
-        </fileset>
-      </path>
-      <sequential>
-        <propertyregex override="yes" property="whatlogfile"  input="@{logfile}" regexp=".*[\\|\/].*\.\d+_+(.*)_compile\.log" replace="\1_preprocessed.log"/>
-        <echo message="Preprocessing @{logfile}..."/>
-        <exec executable="perl" dir="${sf.common.config.dir}/tools/raptor" failonerror="false" output="${build.log.dir}/analysis/${build.id}_whatlog.log" append="true">
-          <arg value="${sf.common.config.dir}/tools/raptor/preprocess_log.pl"/>
-          <arg value="--in=@{logfile}"/>
-          <arg value="--out=${build.log.dir}/analysis/${whatlogfile}"/>
-        </exec>
-        <echo message="Extracting whatlog info from ${whatlogfile}..."/>
-        <exec executable="perl" dir="${sf.common.config.dir}/tools/raptor" failonerror="false" output="${build.log.dir}/analysis/${build.id}_whatlog.log" append="true">
-          <arg value="${sf.common.config.dir}/tools/raptor/parse.pl"/>
-          <arg value="--releaseable"/>
-          <arg value="--log=${build.log.dir}/analysis/${whatlogfile}"/>
-          <arg value="--basedir=${build.log.dir}/releaseables"/>
-          <arg value="--append"/>
-        </exec>
-      </sequential>
-    </for>
+      <echo message="Running yarp over *_compile.log files"/>
+      <for param="logfile">
+        <path>
+          <fileset dir="${build.log.dir}">
+            <include name="*_compile.log"/>
+            <exclude name="*build_check_compile.log"/>
+          </fileset>
+        </path>
+        <sequential>
+          <propertyregex override="yes" property="yarpfile"  input="@{logfile}" regexp=".*[\\|\/](.*)_compile\.log" replace="\1_yarp.csv"/>
+          <propertyregex override="yes" property="yarpfile_short"  input="${yarpfile}" regexp="[^_]*_[^_]*_[^_]*_(.+)_[^_]*_yarp\.csv" replace="YARP_\1"/>
+          <echo message="Yarping @{logfile}..."/>
+          <exec executable="perl" dir="${build.drive}" failonerror="false" output="${build.log.dir}/analysis/${build.id}_yarp.log" append="true">
+            <arg value="${sf.common.config.dir}/tools/analysis/yarp.pl"/>
+            <arg value="@{logfile}"/>
+            <arg value="${build.log.dir}/analysis/${yarpfile}"/>
+          </exec>
+          <exec executable="cmd" output="${build.drive}/output/logs/analysis/tmp_yarp_files.csv" append="true">
+            <arg value="/c"/>
+            <arg value="echo"/>
+            <arg value="${yarpfile_short},${sf.spec.publish.networkdrive}\${sf.spec.job.name}\builds\${sf.spec.job.codeline}\${build.id}\logs\analysis\${yarpfile},${build.drive}\output\logs\analysis\${yarpfile}"/>
+          </exec>
+        </sequential>
+      </for>
+      
+      <exec executable="perl" dir="${build.drive}" failonerror="false" outputproperty="sf.job.totalyarperrors">
+        <arg value="${sf.common.config.dir}/tools/analysis/parse_yarp_files.pl"/>
+        <arg value="${build.drive}/output/logs/analysis/tmp_yarp_files.csv"/>
+      </exec>
+      <echo message="Total yarp errors: ${sf.job.totalyarperrors}"/>
+      
+      <fmpp sourceFile="${sf.common.config.dir}/diamonds/sf-run-analysis.xml.ftl" outputFile="${build.drive}/output/logs/sf-run-analysis.xml">
+        <data expandProperties="yes">
+          ant: antProperties()
+          files: csv(${build.drive}/output/logs/analysis/tmp_yarp_files.csv,{separator:',',headers:[name,path,localpath]})
+        </data>
+      </fmpp>
+      
+      <echo message="Extracting whatlog information from *whatlog*_compile.log files"/>
+      <for param="logfile">
+        <path>
+          <fileset dir="${build.log.dir}">
+            <include name="*whatlog*_compile.log"/>
+          </fileset>
+        </path>
+        <sequential>
+          <propertyregex override="yes" property="whatlogfile" input="@{logfile}" regexp=".*[\\|\/].*\.\d+_+(.*)_compile\.log" replace="\1_preprocessed.log"/>
+	  <echo message="Preprocessing @{logfile}..."/>
+          <exec executable="perl" dir="${sf.common.config.dir}/tools/raptor" failonerror="false" input="@{logfile}" output="${build.log.dir}/analysis/${whatlogfile}" error="${build.log.dir}/analysis/${build.id}_whatlog.log" append="true">
+            <arg value="${sf.common.config.dir}/tools/raptor/preprocess_log.pl"/>
+          </exec>
+          <echo message="Extracting whatlog info from ${whatlogfile}..."/>
+          <exec executable="perl" dir="${sf.common.config.dir}/tools/raptor" failonerror="false" output="${build.log.dir}/analysis/${build.id}_whatlog.log" append="true">
+            <arg value="${sf.common.config.dir}/tools/raptor/parse.pl"/>
+            <arg value="--releaseable"/>
+            <arg value="--log=${build.log.dir}/analysis/${whatlogfile}"/>
+            <arg value="--basedir=${build.log.dir}/releaseables"/>
+            <arg value="--append"/>
+          </exec>
+        </sequential>
+      </for>
 
     </target>
   
--- a/common/tools/raptor/preprocess_log.pl	Mon Jul 13 11:38:30 2009 +0100
+++ b/common/tools/raptor/preprocess_log.pl	Mon Jul 13 17:43:50 2009 +0100
@@ -1,3 +1,4 @@
+#!perl -w
 # Copyright (c) 2009 Symbian Foundation Ltd
 # This component and the accompanying materials are made available
 # under the terms of the License "Eclipse Public License v1.0"
@@ -16,56 +17,49 @@
 
 use Getopt::Long;
 
-my $infile = '';
-my $outfile = '';
-my $basedir = '';
 my $help = 0;
-GetOptions((
-	'in:s' => \$infile,
-	'out:s' => \$outfile,
-	'help!' => \$help
-));
-
-$help = 1 if (!$infile);
+GetOptions(
+	'help!' => \$help,
+);
 
 if ($help)
 {
-	print "Preprocess a raptor log, trying to countermeasure a list of known anomalies\n";
-	print "Usage: perl preprocess_log.pl --in=INFILE --out=OUTFILE\n";
+	warn <<"EOF";
+Preprocess a raptor log, trying to countermeasure a list of known anomalies
+
+Usage: perl preprocess_log.pl < INFILE > OUTFILE
+EOF
 	exit(0);
 }
 
-open(INFILE, $infile);
-open(OUTFILE, ">$outfile");
-
-for my $line (<INFILE>)
+while (my $line = <>)
 {
-	if ($line =~ m,<[^<^>]+>.*&.*</[^<^>]+>,)
+	if ($line =~ m{<[^<^>]+>.*&.*</[^<^>]+>})
 	{
 		$line = escape_ampersand($line);
 	}
-	elsif ($line =~ m,<\?xml\s.*encoding=.*\".*\?>,)
+	elsif ($line =~ m{<\?xml\s.*encoding=.*\".*\?>})
 	{
 		$line = set_encoding_utf8($line);
 	}
+	elsif ($line =~ m{<archive.*?[^/]>})
+	{
+		$line = unterminated_archive_tag($line, scalar <>, $.)
+	}
 	
-	print OUTFILE $line;
+	print $line;
 }
 
-close(OUTFILE);
-close(INFILE);
-
-
 sub escape_ampersand
 {
 	my ($line) = @_;
 	
-	print "escape_ampersand\n";
-	print "in: $line";
+	warn "escape_ampersand\n";
+	warn "in: $line";
 	
 	$line =~ s,&,&amp;,g;
 	
-	print "out: $line";
+	warn "out: $line";
 	return $line;
 }
 
@@ -73,11 +67,28 @@
 {
 	my ($line) = @_;
 	
-	print "set_encoding_utf8\n";
-	print "in: $line";
+	warn "set_encoding_utf8\n";
+	warn "in: $line";
 	
 	$line =~ s,encoding=".*",encoding="utf-8",;
 	
-	print "out: $line";
+	warn "out: $line";
 	return $line;
-}
\ No newline at end of file
+}
+
+sub unterminated_archive_tag
+{
+	my $line = shift;
+	my $nextLine = shift;
+	my $lineNum = shift;
+	
+	if ($nextLine !~ m{(<member>)|(</archive>)})
+	{
+		warn "unterminated_archive_tag\n";
+		warn "in: $line";
+		$line =~ s{>}{/>};
+		warn "out: $line";
+	}
+	
+	return $line . $nextLine;
+}