author | Simon Howkins <simonh@symbian.org> |
Thu, 28 Jan 2010 13:59:40 +0000 | |
changeset 861 | caa0601f50c5 |
parent 812 | c8a16c56ada8 |
permissions | -rw-r--r-- |
547
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
1 |
#!perl -w |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
2 |
# |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
3 |
# Copyright (c) 2009 Symbian Foundation Ltd |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
4 |
# This component and the accompanying materials are made available |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
5 |
# under the terms of the License "Eclipse Public License v1.0" |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
6 |
# which accompanies this distribution, and is available |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html". |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
8 |
# |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
9 |
# Initial Contributors: |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
10 |
# Symbian Foundation Ltd - initial contribution. |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
11 |
# |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
12 |
# Contributors: |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
13 |
# |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
14 |
# Description: |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
15 |
# Generate the BRAG-compatible XML summary of the Raptor log from the CSV output of the raptor parser |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
16 |
|
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
17 |
use strict; |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
18 |
|
665
ddca63d8e13c
Add use lib statement to look for Text-CSV in local lib folder
Dario Sestito <darios@symbian.org>
parents:
605
diff
changeset
|
19 |
use FindBin; |
ddca63d8e13c
Add use lib statement to look for Text-CSV in local lib folder
Dario Sestito <darios@symbian.org>
parents:
605
diff
changeset
|
20 |
use lib "$FindBin::Bin/../lib"; |
752
1f07674ec99f
Moved common code to shared module.
Simon Howkins <simonh@symbian.org>
parents:
665
diff
changeset
|
21 |
use lib "$FindBin::Bin"; |
665
ddca63d8e13c
Add use lib statement to look for Text-CSV in local lib folder
Dario Sestito <darios@symbian.org>
parents:
605
diff
changeset
|
22 |
|
547
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
23 |
use Getopt::Long; |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
24 |
use Text::CSV; |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
25 |
|
752
1f07674ec99f
Moved common code to shared module.
Simon Howkins <simonh@symbian.org>
parents:
665
diff
changeset
|
26 |
use ToBrag; |
547
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
27 |
|
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
28 |
my $raptorSummary; |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
29 |
my $help = 0; |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
30 |
GetOptions(( |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
31 |
'raptorsummary=s' => \$raptorSummary, |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
32 |
'help!' => \$help |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
33 |
)); |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
34 |
|
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
35 |
$help = 1 if (!$raptorSummary); |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
36 |
if ($help) |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
37 |
{ |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
38 |
print "Generate an XML summary of the Raptor build from a summary.csv file\n"; |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
39 |
print "Usage: perl summarize.pl --raptorsummary=CSV\n"; |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
40 |
exit(0); |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
41 |
} |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
42 |
|
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
43 |
# Start to build structure to be output as XML (same format as XML::Parser would create for us) |
752
1f07674ec99f
Moved common code to shared module.
Simon Howkins <simonh@symbian.org>
parents:
665
diff
changeset
|
44 |
my $buildStatus = ToBrag::createBuildStatus(); |
1f07674ec99f
Moved common code to shared module.
Simon Howkins <simonh@symbian.org>
parents:
665
diff
changeset
|
45 |
# Obtain a phase object |
1f07674ec99f
Moved common code to shared module.
Simon Howkins <simonh@symbian.org>
parents:
665
diff
changeset
|
46 |
my $buildPhase = ToBrag::ensurePhase($buildStatus, "Build"); |
547
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
47 |
|
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
48 |
# READ SUMMARY.CSV FILE |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
49 |
open(CSV, $raptorSummary); |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
50 |
my $csv = Text::CSV->new(); |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
51 |
while (my $line = <CSV>) |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
52 |
{ |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
53 |
chomp $line; |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
54 |
|
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
55 |
unless ($csv->parse($line)) |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
56 |
{ |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
57 |
my $err = $csv->error_input(); |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
58 |
warn "Failed to parse $raptorSummary line line $. as CSV '$line': $err Skipping\n"; |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
59 |
next; |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
60 |
} |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
61 |
|
812
c8a16c56ada8
Fixed format checking of summary.csv to deal with new field.
Simon Howkins <simonh@symbian.org>
parents:
807
diff
changeset
|
62 |
my @keys = qw{category subcategory severity config component mmp phase recipe file linenum}; |
547
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
63 |
my @values = $csv->fields(); |
807
194ddb729c09
Fixed format checking of summary file so that it actually checks something!
Simon Howkins <simonh@symbian.org>
parents:
753
diff
changeset
|
64 |
unless (scalar @values == scalar @keys) |
547
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
65 |
{ |
812
c8a16c56ada8
Fixed format checking of summary.csv to deal with new field.
Simon Howkins <simonh@symbian.org>
parents:
807
diff
changeset
|
66 |
warn "WARNING: (raptorToBRAG.pl) line does not match expected format at $raptorSummary line $.. Skipping\n"; |
547
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
67 |
next; |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
68 |
} |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
69 |
|
556
fa2414b24dc4
Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents:
547
diff
changeset
|
70 |
# Populate the hash using a hash slice |
547
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
71 |
my $failure = {}; |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
72 |
@{$failure}{@keys} = @values; |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
73 |
|
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
74 |
if (!$failure->{category}) |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
75 |
{ |
812
c8a16c56ada8
Fixed format checking of summary.csv to deal with new field.
Simon Howkins <simonh@symbian.org>
parents:
807
diff
changeset
|
76 |
warn "WARNING: (raptorToBRAG.pl) summary line without a category at $raptorSummary line $.. Skipping\n"; |
547
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
77 |
next; |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
78 |
} |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
79 |
|
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
80 |
if ($failure->{category} =~ m{^recipe_failure$}i and !$failure->{component}) |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
81 |
{ |
812
c8a16c56ada8
Fixed format checking of summary.csv to deal with new field.
Simon Howkins <simonh@symbian.org>
parents:
807
diff
changeset
|
82 |
warn "WARNING: (raptorToBRAG.pl) recipe_failure with component field empty at $raptorSummary line $.. Skipping\n"; |
547
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
83 |
next; |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
84 |
} |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
85 |
$failure->{subcategory} ||= 'uncategorized'; |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
86 |
$failure->{severity} ||= 'unknown'; |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
87 |
|
752
1f07674ec99f
Moved common code to shared module.
Simon Howkins <simonh@symbian.org>
parents:
665
diff
changeset
|
88 |
# Obtain a matching step |
1f07674ec99f
Moved common code to shared module.
Simon Howkins <simonh@symbian.org>
parents:
665
diff
changeset
|
89 |
my $step = ToBrag::ensureStep($buildPhase, $failure->{config}); |
1f07674ec99f
Moved common code to shared module.
Simon Howkins <simonh@symbian.org>
parents:
665
diff
changeset
|
90 |
# Also create empty <failures> tags with severities in a sensible order |
1f07674ec99f
Moved common code to shared module.
Simon Howkins <simonh@symbian.org>
parents:
665
diff
changeset
|
91 |
ToBrag::ensureFailureSet($step, "critical"); |
1f07674ec99f
Moved common code to shared module.
Simon Howkins <simonh@symbian.org>
parents:
665
diff
changeset
|
92 |
ToBrag::ensureFailureSet($step, "major"); |
1f07674ec99f
Moved common code to shared module.
Simon Howkins <simonh@symbian.org>
parents:
665
diff
changeset
|
93 |
ToBrag::ensureFailureSet($step, "minor"); |
547
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
94 |
|
752
1f07674ec99f
Moved common code to shared module.
Simon Howkins <simonh@symbian.org>
parents:
665
diff
changeset
|
95 |
# Obtain a set of failures which matches this severity |
1f07674ec99f
Moved common code to shared module.
Simon Howkins <simonh@symbian.org>
parents:
665
diff
changeset
|
96 |
my $failureSet = ToBrag::ensureFailureSet($step, $failure->{severity}); |
547
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
97 |
|
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
98 |
# Now create the failure itself, and add it to this failure set |
556
fa2414b24dc4
Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents:
547
diff
changeset
|
99 |
my $failureItem = bless { |
753
5069de517698
New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
752
diff
changeset
|
100 |
Kids => [ bless { Kids => [ bless { Text => $failure->{subcategory} }, "Characters" ]}, "effect" ], |
556
fa2414b24dc4
Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents:
547
diff
changeset
|
101 |
}, "failure"; |
fa2414b24dc4
Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents:
547
diff
changeset
|
102 |
if ($failure->{component}) |
fa2414b24dc4
Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents:
547
diff
changeset
|
103 |
{ |
fa2414b24dc4
Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents:
547
diff
changeset
|
104 |
$failure->{component} =~ s{^(/sf/.*?/.*?)/.*$}{$1}; |
fa2414b24dc4
Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents:
547
diff
changeset
|
105 |
$failureItem->{package} = $failure->{component}; |
fa2414b24dc4
Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents:
547
diff
changeset
|
106 |
} |
752
1f07674ec99f
Moved common code to shared module.
Simon Howkins <simonh@symbian.org>
parents:
665
diff
changeset
|
107 |
push @{$failureSet->{Kids}}, $failureItem, $ToBrag::xmlNewline; |
547
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
108 |
} |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
109 |
close(CSV); |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
110 |
|
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
111 |
# Print XML |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
112 |
print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
113 |
print "<?xml-stylesheet type='text/xsl' href='brag.xsl'?>\n"; |
752
1f07674ec99f
Moved common code to shared module.
Simon Howkins <simonh@symbian.org>
parents:
665
diff
changeset
|
114 |
ToBrag::printTree($buildStatus->[0]); |
547
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
115 |
print "\n"; |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
116 |
|
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
117 |
exit(0); |
19f9d5fc6406
Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff
changeset
|
118 |