|
1 # Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 # All rights reserved. |
|
3 # This component and the accompanying materials are made available |
|
4 # under the terms of "Eclipse Public License v1.0" |
|
5 # which accompanies this distribution, and is available |
|
6 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 # |
|
8 # Initial Contributors: |
|
9 # Nokia Corporation - initial contribution. |
|
10 # |
|
11 # Contributors: |
|
12 # |
|
13 # Description: |
|
14 # Script summarise and hotlink logfiles by reading |
|
15 # HTMLscanlog generated files |
|
16 # This initial version is phase 1 of 3. |
|
17 # 1. HTML scanlog input --> HTML report output |
|
18 # 2. HTML scanlog input --> XML report output + XSLT to HTML |
|
19 # 3. XML scanlog input --> XML report output + XSLT to HTML |
|
20 # |
|
21 # |
|
22 |
|
23 #!/usr/bin/perl -w |
|
24 package BragStatus; |
|
25 use FindBin; |
|
26 use FileRead; |
|
27 require GenResult; |
|
28 use strict; |
|
29 |
|
30 use constant SINGLE_SMOKETEST_FAILURE => 1; |
|
31 use constant PLATFORM_SMOKETEST_FAILURE => 2; |
|
32 use constant PLATFORM_SMOKETEST_SUCCESS => 0; |
|
33 |
|
34 my $gBragStatus = "Green"; |
|
35 my $iHTMLFileName = "testlog.html"; |
|
36 my $iTraceFileName = "trace.txt"; |
|
37 my $iDevkitFileName = "Devkit\.log"; |
|
38 |
|
39 my $iCfgFileLocation = $FindBin::Bin; |
|
40 #Read in the products from a cfg file |
|
41 my $text = FileRead::file_read("$iCfgFileLocation\\Product_AutoSmokeTest.cfg"); |
|
42 my %iProducts = $text =~ /^\s*(\w+\.?\w+)\s*=\s*(.+)$/mg ; |
|
43 #Read in the smoketest list from a cfg file |
|
44 my $Smoketext = FileRead::file_read ("$iCfgFileLocation\\AutoSmoketests.cfg"); |
|
45 my %iTests = $Smoketext =~ /^\s*(\w+\s*\w*\s*)=\s*(.+)$/mg ; |
|
46 |
|
47 my $iNumberOfTests = scalar(my @iTempArray = values %iTests); |
|
48 my $iLogsPublishLocation = ""; |
|
49 |
|
50 # Entry point into the BragStatus module |
|
51 sub main |
|
52 { |
|
53 my ($iDir, $iSnapshot, $iProduct, $iLinkPath) = @_; |
|
54 # set file names, so that they can be accessed globally |
|
55 ${GenResult::iGTFileName} = "GT.summary.html"; |
|
56 ${GenResult::iTVFileName} = "TV.summary.html"; |
|
57 ${GenResult::iBUILDFileName} = "$iSnapshot"."_Symbian_OS_v"."$iProduct".".summary.html"; |
|
58 ${GenResult::iCBRFileName} = "$iSnapshot"."_Symbian_OS_v"."$iProduct"."_cbr.summary.html"; |
|
59 ${GenResult::iROMFileName} = "techviewroms"."$iSnapshot"."_Symbian_OS_v"."$iProduct". ".log"; |
|
60 |
|
61 my $iLinkPathLocation = ""; |
|
62 $iDir =~ s/[^\\]$/$&\\/; #add trailing backslash, if missing |
|
63 $iLogsPublishLocation = $iDir; |
|
64 if (-e $iLinkPath) { |
|
65 $iLinkPathLocation = $iLinkPath; |
|
66 } else { |
|
67 # if no link path is specified, then use current directory location |
|
68 #print "WARNING:" .$iLinkPath. " does not exist, linking with relative paths\n"; |
|
69 $iLinkPathLocation = $iLogsPublishLocation; |
|
70 } |
|
71 |
|
72 if (-e $iLogsPublishLocation) |
|
73 { |
|
74 #Set the Files for the Smoketest package |
|
75 ${GenResult::iGTLogFileLocation} = $iLogsPublishLocation.${GenResult::iGTFileName}; |
|
76 ${GenResult::iTVLogFileLocation} = $iLogsPublishLocation.${GenResult::iTVFileName}; |
|
77 ${GenResult::iBUILDLogFileLocation} = $iLogsPublishLocation.${GenResult::iBUILDFileName}; |
|
78 ${GenResult::iCBRLogFileLocation} = $iLogsPublishLocation.${GenResult::iCBRFileName}; |
|
79 ${GenResult::iROMLogFileLocation} = $iLogsPublishLocation.${GenResult::iROMFileName}; |
|
80 |
|
81 #################################### |
|
82 #BUILD RESULTS |
|
83 #################################### |
|
84 CheckBuildResults(); |
|
85 } |
|
86 else |
|
87 { |
|
88 #Something is seriously wrong if there is no logs |
|
89 setBragStatus("Black"); |
|
90 } |
|
91 |
|
92 ############################### |
|
93 #SMOKETEST |
|
94 ############################### |
|
95 CheckSmokeTest($iProduct, $iSnapshot."_Symbian_OS_v".$iProduct); |
|
96 ############################### |
|
97 CheckDevkit($iProduct); |
|
98 #CBR EXIST |
|
99 ############################### |
|
100 CheckCBRs($iProduct, $iSnapshot); |
|
101 return $gBragStatus; |
|
102 } |
|
103 |
|
104 ######################################################### |
|
105 # Name:CheckSmokeTest |
|
106 # Input: Product |
|
107 # Outout: None |
|
108 # Description: Checks the smoketest tables for any errors |
|
109 ######################################################### |
|
110 sub CheckSmokeTest |
|
111 { |
|
112 my $iProduct = shift; |
|
113 my $iFileName = shift; |
|
114 my $iResult = 0; |
|
115 my @iProductList = ($iProducts{$iProduct} =~ m/\S+/ig); |
|
116 my $iplatform_counter = 0; |
|
117 |
|
118 |
|
119 # Parse results from dabs/autorom smoketest solution |
|
120 # Passing 1 as the second argument ensures that the function acts for brag status only. |
|
121 $iResult = &GenAutoSmokeTestResult::printSTResultRow(1,($iLogsPublishLocation."AutoSmokeTest\\"),@iProductList); |
|
122 |
|
123 if($iResult == 1) |
|
124 { |
|
125 #Some tests failed for $iPlatform |
|
126 setBragStatus("Amber"); |
|
127 } |
|
128 if($iResult == 2) |
|
129 { |
|
130 #Platform Failure |
|
131 setBragStatus("Red"); |
|
132 } |
|
133 |
|
134 if($iResult == -1) |
|
135 { |
|
136 # BRAG status set to TBA as smoke tests do not appear to have been run |
|
137 setBragStatus("TBA"); |
|
138 } |
|
139 } |
|
140 |
|
141 ########################################### |
|
142 #Name: CheckBuildResults |
|
143 #inputs :None |
|
144 #Outputs:None |
|
145 #Description:Checks the same files as the Build Results table. |
|
146 ########################################### |
|
147 sub CheckBuildResults |
|
148 { |
|
149 my @ListofChecks = qw(GT TV BUILD CBR ROM CDB); |
|
150 my $iCount = "0"; |
|
151 while(@ListofChecks) |
|
152 { |
|
153 my $iFile = shift @ListofChecks; |
|
154 # zero errors, means 'None' is displayed |
|
155 if (!&GenResult::getHandleErrors($iFile)) |
|
156 { |
|
157 setBragStatus("TBA"); |
|
158 #Should jump up to While loop again |
|
159 next; |
|
160 } |
|
161 |
|
162 my $iResultRow; |
|
163 my @iResult = &GenResult::getResults($iFile); |
|
164 foreach (&GenResult::getResults($iFile)) { |
|
165 undef $iResultRow; |
|
166 if (($_->[1] != "0") || ($_->[3] != "0")) |
|
167 { |
|
168 #A Build Results Error |
|
169 setBragStatus("Amber"); |
|
170 } |
|
171 if ($_->[5] != "0") |
|
172 { |
|
173 $GenResult::iBraggflag=1; |
|
174 } |
|
175 |
|
176 }#foreach |
|
177 $iCount++; |
|
178 }#end while |
|
179 } |
|
180 ############################################## |
|
181 # Name: CheckCBRs |
|
182 # Inputs : product and snapshot number |
|
183 # Outputs: None |
|
184 # Description: Checks that the CBRs are created and sets the brag |
|
185 # status to Red if they havent been |
|
186 ############################################### |
|
187 sub CheckCBRs |
|
188 { |
|
189 my $iProduct = shift; |
|
190 my $iSnapshot = shift; |
|
191 |
|
192 my $iCBR_GT_only_Location = "\\\\builds01\\devbuilds\\ComponentisedReleases\\DailyBuildArchive\\Symbian_OS_v$iProduct\\"; |
|
193 my $iCBR_GT_techview_Location = "\\\\builds01\\devbuilds\\ComponentisedReleases\\DailyBuildArchive\\Symbian_OS_v$iProduct\\"; |
|
194 #Check to see if its a test build |
|
195 if(&GenResult::isTestBuild() eq "1") |
|
196 { |
|
197 $iCBR_GT_only_Location = "\\\\builds01\\devbuilds\\Test_Builds\\ComponentisedReleases\\TestArchive\\Symbian_OS_v$iProduct\\"; |
|
198 $iCBR_GT_techview_Location = "\\\\builds01\\devbuilds\\Test_Builds\\ComponentisedReleases\\TestArchive\\Symbian_OS_v$iProduct\\"; |
|
199 } |
|
200 |
|
201 if( -e $iCBR_GT_only_Location) |
|
202 { |
|
203 #Check the GT_ONLY |
|
204 if( -e $iCBR_GT_only_Location."\\GT_only_baseline\\$iSnapshot\_Symbian_OS_v$iProduct\\reldata") |
|
205 { |
|
206 setBragStatus("Green"); |
|
207 } |
|
208 else |
|
209 { |
|
210 setBragStatus("Red"); |
|
211 } |
|
212 #Check the GT_techview_baseline |
|
213 if( -e $iCBR_GT_techview_Location."\\GT_techview_baseline\\$iSnapshot\_Symbian_OS_v$iProduct\\reldata") |
|
214 { |
|
215 setBragStatus("Green"); |
|
216 } |
|
217 else |
|
218 { |
|
219 setBragStatus("Red"); |
|
220 } |
|
221 } |
|
222 else #No CBRs built so BragStatus is Red |
|
223 { |
|
224 setBragStatus("Red"); |
|
225 } |
|
226 } |
|
227 |
|
228 ######################################################### |
|
229 # Name:CheckDevkit |
|
230 # Input: Product |
|
231 # Outout: None |
|
232 # Description: Checks the Devkit log file for any errors |
|
233 ######################################################### |
|
234 sub CheckDevkit |
|
235 { |
|
236 my $iProduct = shift; |
|
237 my $iResult = 0; |
|
238 my @iProductList = ($iProducts{$iProduct} =~ m/\S+/ig); |
|
239 my $iplatform_counter = 0; |
|
240 foreach my $iPlatform (@iProductList) |
|
241 { |
|
242 $iResult = getDEVKITRow($iPlatform); |
|
243 if($iResult == 1) |
|
244 { |
|
245 #Error in $iPlatform |
|
246 setBragStatus("Amber"); |
|
247 } |
|
248 |
|
249 } |
|
250 } |
|
251 |
|
252 sub getDEVKITRow |
|
253 { |
|
254 ############################################### |
|
255 # Name: getDEVKITRow |
|
256 # Input: Platform |
|
257 # Output: 0 - No problems |
|
258 # 1 - error in log file |
|
259 # |
|
260 ############################################## |
|
261 |
|
262 my $iPlatform = $_[0]; |
|
263 my $iDKdir = "\\SmokeTest\\"; |
|
264 |
|
265 open (DevkitLOGFILE, $iLogsPublishLocation.$iDKdir.$iDevkitFileName); |
|
266 my @iDevkitLog = <DevkitLOGFILE>; |
|
267 my $iErrorCount = 0; |
|
268 my $iLineOK = 0; |
|
269 |
|
270 foreach (@iDevkitLog) { |
|
271 if (m/ERROR:/) |
|
272 { |
|
273 $iErrorCount++; |
|
274 } |
|
275 else |
|
276 { |
|
277 $iLineOK++; |
|
278 } |
|
279 } |
|
280 if($iErrorCount > 0) { return 1;}else{return 0;} |
|
281 |
|
282 } |
|
283 |
|
284 ############################################### |
|
285 # Name : setBragStatus |
|
286 # Inputs: Suggested Brag Status "Green","Amber","Red","Black" |
|
287 # Outputs: None |
|
288 # Description: This function sets the brag status |
|
289 # Brag status can only deteriorate, not improve |
|
290 ############################################### |
|
291 sub setBragStatus |
|
292 { |
|
293 my $iBstatus = shift; |
|
294 if($gBragStatus eq "Green") |
|
295 { |
|
296 $gBragStatus = $iBstatus; |
|
297 return 0; |
|
298 } |
|
299 if(($gBragStatus eq "Amber") && (($iBstatus eq "Black") || ($iBstatus eq "Red"))) |
|
300 { |
|
301 $gBragStatus = $iBstatus; |
|
302 return 0; |
|
303 } |
|
304 |
|
305 if(($gBragStatus eq "Red") && ($iBstatus eq "Black")) |
|
306 { |
|
307 $gBragStatus = $iBstatus; |
|
308 return 0; |
|
309 } |
|
310 |
|
311 if($iBstatus eq "TBA") # Set BRAG to "TBA" if the SmokeTests do not appear to have run. |
|
312 { |
|
313 $gBragStatus = $iBstatus; |
|
314 return 0; |
|
315 } |
|
316 |
|
317 #For Everything Else leave gBragStatus as is |
|
318 return 0; |
|
319 } |
|
320 1; |