82 $auto_tests_total = $line; |
107 $auto_tests_total = $line; |
83 # Remove td tags. |
108 # Remove td tags. |
84 $auto_tests_total =~ s/^.*\">//; |
109 $auto_tests_total =~ s/^.*\">//; |
85 $auto_tests_total =~ s/<.*//; |
110 $auto_tests_total =~ s/<.*//; |
86 } |
111 } |
|
112 if ($read_flag == 3) { # Get number of Disabled tests. |
|
113 ($auto_tests_disabled) = split /\//,$line; |
|
114 $auto_tests_disabled =~ s/^.*\">//; # Remove opening td tag. |
|
115 } |
87 if ($read_flag == 4) { # Get number of Passed tests. |
116 if ($read_flag == 4) { # Get number of Passed tests. |
88 ($auto_tests_passed) = split /\//,$line; |
117 ($auto_tests_passed) = split /\//,$line; |
89 $auto_tests_passed =~ s/^.*\">//; # Remove opening td tag. |
118 $auto_tests_passed =~ s/^.*\">//; # Remove opening td tag. |
90 } |
119 } |
91 if ($read_flag == 5) { # Get number of Failed tests. |
120 if ($read_flag == 5) { # Get number of Failed tests. |
92 ($auto_tests_failed) = split /\//,$line; |
121 ($auto_tests_failed) = split /\//,$line; |
93 $auto_tests_failed =~ s/^.*\">//; # Remove opening td tag. |
122 $auto_tests_failed =~ s/^.*\">//; # Remove opening td tag. |
94 } |
123 } |
95 if ($read_flag == 7) { # Get number of Not run tests. |
124 if ($read_flag == 6) { # Get number of Skipped tests. |
96 ($auto_tests_notrun) = split /\//,$line; |
125 ($auto_tests_skipped) = split /\//,$line; |
97 $auto_tests_notrun =~ s/^.*\">//; # Remove opening td tag. |
126 $auto_tests_skipped =~ s/^.*\">//; # Remove opening td tag. |
|
127 } |
|
128 if ($read_flag == 7) { # Get number of No result tests. |
|
129 ($auto_tests_noresult) = split /\//,$line; |
|
130 $auto_tests_noresult =~ s/^.*\">//; # Remove opening td tag. |
98 } |
131 } |
99 if ($line eq "<td class=\"tableData\">Nested tests<\/td>") { # Set flag for reading results. |
132 if ($line eq "<td class=\"tableData\">Nested tests<\/td>") { # Set flag for reading results. |
100 $read_flag = 0; |
133 $read_flag = 0; |
101 } |
134 } |
102 if (($line eq "<\/tr>") && ($read_flag >= 0)) { # Exit loop. |
135 if (($line eq "<\/tr>") && ($read_flag >= 0)) { # Exit loop. |
103 last; |
136 last; |
104 }; |
137 }; |
105 } |
138 } |
106 close FILE; |
139 close FILE; |
|
140 # Set number of No run tests. |
|
141 $auto_tests_notrun = $auto_tests_skipped + $auto_tests_noresult; |
|
142 |
|
143 # Get additional info |
|
144 open (FILE, "<$ats3_report") or die ("Couldn't open $ats3_report for reading: $!\n"); |
|
145 while ($line = <FILE>) { |
|
146 chomp $line; |
|
147 if ($line =~ "<b>Test run:") { |
|
148 $name = $line; |
|
149 $name =~ s/^.*<td>//; |
|
150 $name =~ s/<\/td>.*//; |
|
151 } |
|
152 if ($line =~ "<b>Start time:") { |
|
153 $start_time = $line; |
|
154 $start_time =~ s/^.*<td>//; |
|
155 $start_time =~ s/<\/td>.*//; |
|
156 } |
|
157 if ($line =~ "<b>End time:") { |
|
158 $end_time = $line; |
|
159 $end_time =~ s/^.*<td>//; |
|
160 $end_time =~ s/<\/td>.*//; |
|
161 } |
|
162 } |
|
163 close FILE; |
|
164 |
107 } |
165 } |
108 if (defined($ats4_report)) { # Get ATS4 Smoketest results. |
166 if (defined($ats4_report)) { # Get ATS4 Smoketest results. |
109 $auto_tests_total = 0; |
|
110 $auto_tests_passed = 0; |
|
111 $auto_tests_failed = 0; |
|
112 $auto_tests_notrun = 0; |
|
113 open (FILE, "<$ats4_report") or die ("Couldn't open $ats4_report for reading: $!\n"); |
167 open (FILE, "<$ats4_report") or die ("Couldn't open $ats4_report for reading: $!\n"); |
114 my $read_flag = -1; |
168 my $read_flag = -1; |
115 print "Reading $ats4_report... "; |
169 print "Reading $ats4_report... "; |
116 while ($line = <FILE>) { |
170 while ($line = <FILE>) { |
117 chomp $line; |
171 chomp $line; |
118 if ($read_flag >= 0) { $read_flag++ } |
172 if ($read_flag >= 0) { $read_flag++ } |
119 if ($read_flag == 3) { # Get status. |
173 if ($read_flag == 3) { # Get status. |
120 $auto_tests_total++; |
174 $auto_tests_total++; |
121 if ($line =~ "PASSED") { $auto_tests_passed++ } |
175 if ($line =~ "PASSED") { $auto_tests_passed++ } |
122 if ($line =~ "FAILED") { $auto_tests_failed++ } |
176 if ($line =~ "FAILED") { $auto_tests_failed++ } |
123 if (($line =~ "SKIPPED") || ($line =~ "NOT_AVAILABLE")) { $auto_tests_notrun++ } |
177 if ($line =~ "SKIPPED") { $auto_tests_skipped++ } |
|
178 if ($line =~ "NOT_AVAILABLE") { $auto_tests_notrun++ } |
124 # Re-set flag. |
179 # Re-set flag. |
125 $read_flag = -1; |
180 $read_flag = -1; |
126 } |
181 } |
127 if ($line eq "<result type=\"TestCaseResult\">") { # Set flag for reading results. |
182 if ($line eq "<result type=\"TestCaseResult\">") { # Set flag for reading results. |
128 $read_flag = 0; |
183 $read_flag = 0; |
129 } |
184 } |
130 } |
185 } |
131 close FILE; |
186 close FILE; |
|
187 |
|
188 # Get additional info |
|
189 $name = "Smoketest"; # Name not available in ATS4 testreport. |
|
190 open (FILE, "<$ats4_report") or die ("Couldn't open $ats4_report for reading: $!\n"); |
|
191 $start_time = ""; |
|
192 while ($line = <FILE>) { |
|
193 chomp $line; |
|
194 if ($line =~ "timeStamp=\"") { |
|
195 $time_stamp = $line; |
|
196 $time_stamp =~ s/^.*timeStamp=\"//; |
|
197 $time_stamp =~ s/\..*//; |
|
198 ($date,$time) = split /\s/,$time_stamp; |
|
199 ($day, $month, $year) = split /-/,$date; |
|
200 $time_stamp = "$year-$month-$day $time"; |
|
201 if ($start_time eq "") { $start_time = $time_stamp } |
|
202 } |
|
203 } |
|
204 close FILE; |
|
205 $end_time = $time_stamp; # Last entry becomes end_time. |
132 } |
206 } |
133 print "complete\n"; |
207 print "complete\n"; |
134 print "Total number of tests: $auto_tests_total\n"; |
208 #print "Total number of tests: $auto_tests_total\n"; |
135 print "Passed tests: $auto_tests_passed\n"; |
209 #print "Passed tests: $auto_tests_passed\n"; |
136 print "Failed tests: $auto_tests_failed\n"; |
210 #print "Failed tests: $auto_tests_failed\n"; |
137 print "Not run tests: $auto_tests_notrun\n"; |
211 #print "Not run tests: $auto_tests_notrun\n"; |
138 |
212 |
139 # Define detailshref attribute. |
213 # Define detailshref attribute and report_url. |
140 $temp_path = $brag_file; |
214 $temp_path = $brag_file; |
141 $temp_path =~ s/\\/\//g; # Replace \ with / |
215 $temp_path =~ s/\\/\//g; # Replace \ with / |
142 $temp_path =~ s/\/summary\/.*//; |
216 $temp_path =~ s/\/summary\/.*//; |
143 if (defined($ats3_report)) { $detailshref = $ats3_report }; |
217 if (defined($ats3_report)) { $detailshref = $ats3_report }; |
144 if (defined($ats4_report)) { $detailshref = $ats4_report }; |
218 if (defined($ats4_report)) { $detailshref = $ats4_report }; |
145 $detailshref =~ s/\\/\//g; # Replace \ with / |
219 $detailshref =~ s/\\/\//g; # Replace \ with / |
|
220 $report_url = lc($detailshref); |
146 $detailshref =~ s/($temp_path)/../; |
221 $detailshref =~ s/($temp_path)/../; |
|
222 #Replace "//v800020/publish" with "http://cdn.symbian.org" in report_url |
|
223 $report_url =~ s/^.*\/publish\//http:\/\/cdn.symbian.org\//; |
|
224 |
147 if (defined($test_report)) { |
225 if (defined($test_report)) { |
148 $man_detailshref = $test_report; |
226 $man_detailshref = $test_report; |
149 $man_detailshref =~ s/\\/\//g; # Replace \ with / |
227 $man_detailshref =~ s/\\/\//g; # Replace \ with / |
150 $man_detailshref =~ s/($temp_path)/../; |
228 $man_detailshref =~ s/($temp_path)/../; |
151 } |
229 } |
152 |
230 |
153 if (defined($test_report)) { # Get manual Smoketest results. |
231 if (defined($test_report)) { # Get manual Smoketest results. |
154 print "Parsing " . $test_report . "... "; |
232 print "Parsing " . $test_report . "... "; |
155 $xml_report = XMLin("$test_report", keeproot => 1, forcearray => [ 'test-set', 'test-case' ], keyattr => [] ); |
233 $xml_report = XMLin("$test_report", keeproot => 1, forcearray => [ 'test-set', 'test-case' ], keyattr => [] ); |
156 print "complete \n"; |
234 print "complete \n"; |
157 $man_tests_total = 0; |
|
158 $man_tests_passed = 0; |
|
159 $man_tests_failed = 0; |
|
160 $man_tests_notrun = 0; |
|
161 foreach $test_case (@{$xml_report->{'test-report'}->{'test-set'}->[0]->{'test-case'}}) { |
235 foreach $test_case (@{$xml_report->{'test-report'}->{'test-set'}->[0]->{'test-case'}}) { |
162 if (lc($test_case->{'result'}) eq "passed") { $man_tests_passed++ } |
236 if (lc($test_case->{'result'}) eq "passed") { $man_tests_passed++ } |
163 if (lc($test_case->{'result'}) eq "failed") { $man_tests_failed++ } |
237 if (lc($test_case->{'result'}) eq "failed") { $man_tests_failed++ } |
164 if (lc($test_case->{'result'}) eq "not run") { $man_tests_notrun++ } |
238 if (lc($test_case->{'result'}) eq "not run") { $man_tests_notrun++ } |
165 $man_tests_total++; |
239 $man_tests_total++; |
166 } |
240 } |
167 print "Total number of tests: $man_tests_total\n"; |
241 # print "Total number of tests: $man_tests_total\n"; |
168 print "Passed tests: $man_tests_passed\n"; |
242 # print "Passed tests: $man_tests_passed\n"; |
169 print "Failed tests: $man_tests_failed\n"; |
243 # print "Failed tests: $man_tests_failed\n"; |
170 print "Not run tests: $man_tests_notrun\n"; |
244 # print "Not run tests: $man_tests_notrun\n"; |
171 } |
245 } |
172 |
246 |
173 # Check for Smoketest results in BRAG file. |
247 # Check for Smoketest results in BRAG file. |
174 open (FILE, "<$brag_file") or die ("Couldn't open $brag_file for reading: $!\n"); |
248 open (FILE, "<$brag_file") or die ("Couldn't open $brag_file for reading: $!\n"); |
175 $existing_results = 0; |
249 $existing_results = 0; |
251 print FILE "<\/phase>\n"; |
325 print FILE "<\/phase>\n"; |
252 print FILE "</buildStatus>\n"; |
326 print FILE "</buildStatus>\n"; |
253 close FILE; |
327 close FILE; |
254 print "$test_brag_xml saved\n"; |
328 print "$test_brag_xml saved\n"; |
255 |
329 |
|
330 # Calculate Test BRAG Status (based on auto + manual) |
|
331 $cases_total = $man_tests_total + $auto_tests_total; |
|
332 $cases_passed = $man_tests_passed + $auto_tests_passed; |
|
333 $cases_failed = $man_tests_failed + $auto_tests_failed; |
|
334 $cases_not_run = $man_tests_notrun + $auto_tests_notrun; |
|
335 $cases_not_available = $auto_tests_disabled; |
|
336 if ($auto_tests_total > 0) { |
|
337 $auto_pass_rate = ($auto_tests_passed / $auto_tests_total) * 100; |
|
338 } else { |
|
339 $auto_pass_rate = 0; |
|
340 } |
|
341 if ($cases_total > 0) { |
|
342 $fail_rate = ($cases_failed / $cases_total) * 100; |
|
343 } else { |
|
344 $fail_rate = 0; |
|
345 } |
|
346 if ($cases_total == 0) { |
|
347 $test_brag_status = "n/a"; |
|
348 } elsif (($fail_rate > 0) && ($fail_rate <= 50)) { |
|
349 $test_brag_status = "amber"; |
|
350 } elsif ($fail_rate > 50) { |
|
351 $test_brag_status = "red"; |
|
352 } else { |
|
353 $test_brag_status = "green"; |
|
354 } |
|
355 $auto_pass_rate = sprintf("%.1f", $auto_pass_rate); |
|
356 # Generate bit file |
|
357 if (-e $bit_file) { # Delete the file if exists. |
|
358 unlink($bit_file); |
|
359 print "$bit_file deleted\n"; |
|
360 } |
|
361 open (FILE, "> $bit_file") or die ("Couldn't open $bit_file for writing: $!\n"); |
|
362 print FILE "test $name,$type,$test_target,$start_time,$end_time,$auto_tests_total,$auto_tests_passed,$auto_tests_failed,$auto_tests_notrun,$auto_tests_disabled,$auto_pass_rate\n"; |
|
363 if ($test_brag_status ne "n/a") { print FILE "test_brag $test_brag_status\n"; } |
|
364 print FILE "report Smoke Test Report,$report_url,report"; |
|
365 close FILE; |
|
366 print "$bit_file saved\n"; |
|
367 |
|
368 if (defined($build_id)) { |
|
369 print "Updating BIT db... "; |
|
370 my @args = ("perl", $bitops_path, "-u", $build_id, "-a", "-f", $bit_file); |
|
371 system(@args) == 0 or die "system @args failed: $?"; |
|
372 print "complete\n"; |
|
373 } |
|
374 |
256 exit 0; |
375 exit 0; |
257 |
376 |
258 sub usage($) |
377 sub usage($) |
259 { |
378 { |
260 my $error = shift; |
379 my $error = shift; |
261 my $fh = $error == 0 ? *STDOUT : *STDERR; |
380 my $fh = $error == 0 ? *STDOUT : *STDERR; |
262 print $fh "update_brag_status.pl\n" . |
381 print $fh "update_brag_status.pl\n" . |
263 "Specify the BRAG xml file and ATS report\n" . |
382 "Specify the BRAG xml file and ATS report\n" . |
264 "synopsis:\n" . |
383 "synopsis:\n" . |
265 " update_brag_status.pl --help\n" . |
384 " update_brag_status.pl --help\n" . |
266 " update_brag_status.pl [--brag-file=XML_FILE] [--ats3-report=HTML_REPORT] [--ats4-report=SIMPLELOGGER_REPORT] [--test-report=XML_REPORT] \n" . |
385 " update_brag_status.pl [--brag-file=XML_FILE] [--ats3-report=HTML_REPORT] [--ats4-report=SIMPLELOGGER_REPORT] [--test-report=XML_REPORT] [--build-id=ID]\n" . |
267 "options:\n" . |
386 "options:\n" . |
268 " --help Display this help and exit.\n" . |
387 " --help Display this help and exit.\n" . |
269 " --brag-file=XML_FILE XML_FILE is the full path to the file containing BRAG summary.\n" . |
388 " --brag-file=XML_FILE XML_FILE is the full path to the file containing BRAG summary.\n" . |
270 " --ats3-report=HTML_REPORT HTML_REPORT is the full path to the ATS3 report.\n" . |
389 " --ats3-report=HTML_REPORT HTML_REPORT is the full path to the ATS3 report.\n" . |
271 " --ats4-report=SIMPLELOGGER_REPORT SIMPLELOGGER_REPORT is the full path to the ATS4 report.\n" . |
390 " --ats4-report=SIMPLELOGGER_REPORT SIMPLELOGGER_REPORT is the full path to the ATS4 report.\n" . |
272 " --test-report=XML_REPORT XML_REPORT is the name of the test report for manually executed tests.\n" . |
391 " --test-report=XML_REPORT XML_REPORT is the name of the test report for manually executed tests.\n" . |
273 " If not specified only automated tests results will be taken into account.\n"; |
392 " If not specified only automated tests results will be taken into account.\n" . |
|
393 " --build-id=ID ID is the id of the build which will be updated with the test results.\n"; |
274 exit $error; |
394 exit $error; |
275 } |
395 } |
276 |
396 |
277 sub help() |
397 sub help() |
278 { |
398 { |