1 [@--# Copyright (c) 2003-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 the License "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 # Template processed by GenDiamondsXml.pm |
|
15 # |
|
16 #--@] |
|
17 <?xml version="1.0" encoding="utf-8"?> |
|
18 <diamonds-build> |
|
19 <schema>[@--$ENV{DiamondsSchemaNum}--@]</schema> |
|
20 [@-- |
|
21 use myutils; |
|
22 use GenAutoSmokeTestResult; |
|
23 our $Gtotal = 0; |
|
24 our $Gexecuted = 0 ; |
|
25 our $Gsuccessful =0; |
|
26 our $Gnot_tested = 0 ; |
|
27 our $Gfailed = 0 ; |
|
28 our $Gtestcases; |
|
29 our $Gtitle = ""; |
|
30 |
|
31 my $iDir = &myutils::getiDir(); |
|
32 my $iSnapshot = &myutils::getiSnapshot(); |
|
33 my $iProduct = &myutils::getiProduct(); |
|
34 my $iLinkPath = &myutils::getiLinkPath(); |
|
35 |
|
36 |
|
37 { |
|
38 #my $str = PlanTxtAutoSmokeTestResult('.\\', "MSF00290", "tb92sf", '.\\'); |
|
39 my $str = PlanTxtAutoSmokeTestResult($iDir, $iSnapshot, $iProduct, $iLinkPath); |
|
40 |
|
41 if ($str ne undef) #not empty |
|
42 { |
|
43 $Gtestcases = resultTestCasesXMLbody($str); |
|
44 $Gtotal = $Gsuccessful+ $Gnot_tested+ $Gfailed; # total number of testcases |
|
45 } |
|
46 } |
|
47 $OUT = '';#return value |
|
48 |
|
49 # _html2text HTML formate convert to plan text string. |
|
50 # input a html string |
|
51 # ouput smiplified text |
|
52 sub _html2text { |
|
53 my ($str) = shift(@_); |
|
54 |
|
55 $str =~ s/\n//sg; # Remove all obsolete newlines. |
|
56 |
|
57 # Link: |
|
58 $str =~ s/<a[ ]+.*?>(.+)<\/a>/$1/ig; |
|
59 |
|
60 # Table: |
|
61 $str =~ s/<\/?table[ ]*.*?>/\n/ig; |
|
62 $str =~ s/<td[ ]*.*?>/\t/ig; |
|
63 $str =~ s/<tr[ ]*.*?>/\n/ig; |
|
64 $str =~ s/<th[ ]*.*?>/\t/ig; |
|
65 |
|
66 # Cleaning up: |
|
67 $str =~ s/<.*?>//sg; # Remove all tags. |
|
68 $str =~ s/\n[ ]+\n/\n\n/sg; # Remove all obsolete spaces. |
|
69 $str =~ s/\n[ ]+/\n/sg; |
|
70 $str =~ s/\n{2,}/\n\n/sg; # Remove all obsolete newlines. |
|
71 $str =~ s/^[ ]*//g; # Remove all leading spaces (again). |
|
72 $str =~ s/[ ]+/ /g; # Remove all duplicate spaces (again). |
|
73 |
|
74 $str =~ s/[\t\t]+/\t/g; |
|
75 return $str; |
|
76 } |
|
77 |
|
78 sub PlanTxtAutoSmokeTestResult |
|
79 { |
|
80 my ($iLogsPublishLocation, $iSnapshot, $iProduct, $iLinkPathLocation) = @_; |
|
81 my $str; |
|
82 $str = GenAutoSmokeTestResult::generateSTHTMLSummary($iLogsPublishLocation."AutoSmokeTest", $iSnapshot, $iProduct, $iLinkPathLocation."AutoSmokeTest"); |
|
83 $str =~ s/[\t]+//g; # Remove extra \t. the \t was gen by GenSmokeTestResult.pm |
|
84 |
|
85 $str = _html2text($str); |
|
86 |
|
87 $str =~ s/ //g; #remove   |
|
88 $str =~ s/\n\t/\n/g;#remove \t at head |
|
89 $str =~ s/\n\n/\n/g; |
|
90 $str=~ s/^\n//g;#remove first empy line |
|
91 return $str; |
|
92 } |
|
93 |
|
94 sub resultTestCasesXMLbody |
|
95 { |
|
96 my ($str) = shift (@_); |
|
97 my @lines = split(/\n/,$str); |
|
98 #print Dumper(\@lines); |
|
99 $Gtitle = $lines[0];#Auto Smoke Test |
|
100 @results = @lines[2..$#lines]; |
|
101 #print Dumper(\@results); |
|
102 |
|
103 my $ret ="<testcases>\n"; |
|
104 my @testTitle = split (/\t/, $lines[1]); |
|
105 foreach my $APlatform (@results) |
|
106 { |
|
107 my @result = split (/\t/, $APlatform); |
|
108 $plat = $result[0];# platform name; |
|
109 $result[1];# Summary |
|
110 $result[2];# Time World |
|
111 $result[3];# Contacts |
|
112 $result[4];# Messaging |
|
113 $result[5];# Agenda |
|
114 $result[6];# Defects |
|
115 for (my $i =2;$i<6;++$i) |
|
116 { |
|
117 $ret .= "<testcase>\n<name>".$plat.$testTitle[$i]."</name>\n"; |
|
118 $ret .= "<status>".$result[$i]."</status>\n"; |
|
119 $ret .= "</testcase>\n"; |
|
120 if ($result[$i] =~/FAILURES/) |
|
121 {$Gexecuted++; |
|
122 $Gfailed++;} #FAILURES |
|
123 elsif( $result[$i] =~/Unexecuted/) |
|
124 {$Gnot_tested++;}#Unexecuted |
|
125 elsif ( $result[$i] =~/OK/) |
|
126 {$Gexecuted++; |
|
127 $Gsuccessful++;}#OK |
|
128 |
|
129 } |
|
130 } |
|
131 $ret .="</testcases>\n"; |
|
132 return $ret; |
|
133 } |
|
134 |
|
135 --@] |
|
136 <tests> |
|
137 <test_results> |
|
138 <test type="[@--$Gtitle--@]"> |
|
139 <total>[@--$Gtotal--@]</total> |
|
140 <executed>[@--$Gexecuted--@]</executed> |
|
141 <successful>[@--$Gsuccessful--@]</successful> |
|
142 <failed>[@--$Gfailed--@]</failed> |
|
143 <not_tested>[@--$Gnot_tested--@]</not_tested> |
|
144 [@--$Gtestcases--@] |
|
145 </test> |
|
146 </test_results> |
|
147 </tests> |
|
148 </diamonds-build> |
|
149 |
|