|
1 # Copyright (c) 2010 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 # |
|
15 |
|
16 package TestScriptResults; |
|
17 use strict; |
|
18 use Exporter; |
|
19 use base 'Exporter'; |
|
20 |
|
21 # Crashing enums |
|
22 my $KTestDidNotCrash = 0; |
|
23 my $KTestCrashed = 1; |
|
24 |
|
25 # Test Harness enums |
|
26 our $KCoreConfTest = "CoreConf"; |
|
27 our $KTEFTest = "TEF"; |
|
28 our $KTEFNoTestcasesTest = "TEFNoTestcases"; # Some of the older MM TEF tests were implemented without using testcases, in these cases we use the test steps in their place |
|
29 our $KTestFrameworkTest = "TF"; |
|
30 |
|
31 our @EXPORT = qw($KCoreConfTest, $KTEFTest, $KTEFNoTestcasesTest, $KTestFrameworkTest); |
|
32 |
|
33 # Constructor |
|
34 sub TestScriptResults |
|
35 { |
|
36 my $this = {}; |
|
37 $this->{ScriptName} = undef; |
|
38 $this->{FilePath} = undef; |
|
39 $this->{DidItCrash} = $KTestDidNotCrash; |
|
40 $this->{TotalNumberTestCases} = undef; |
|
41 $this->{Inconclusives} = [1]; # First entry gives the next free index |
|
42 $this->{Fails} = [1]; # First entry gives the next free index |
|
43 $this->{TestHarness} = undef; |
|
44 bless($this); |
|
45 return $this; |
|
46 } |
|
47 |
|
48 sub SetScriptName |
|
49 { |
|
50 my $this = shift; |
|
51 $this->{ScriptName} = shift; |
|
52 } |
|
53 |
|
54 sub ScriptName |
|
55 { |
|
56 my $this = shift; |
|
57 return $this->{ScriptName}; |
|
58 } |
|
59 |
|
60 sub SetFilePath |
|
61 { |
|
62 my $this = shift; |
|
63 $this->{FilePath} = shift; |
|
64 } |
|
65 |
|
66 sub FilePath |
|
67 { |
|
68 my $this = shift; |
|
69 return $this->{FilePath}; |
|
70 } |
|
71 |
|
72 sub CoreConfTest |
|
73 { |
|
74 my $this = shift; |
|
75 $this->{TestHarness} = $KCoreConfTest; |
|
76 } |
|
77 |
|
78 sub TEFTest |
|
79 { |
|
80 my $this = shift; |
|
81 $this->{TestHarness} = $KTEFTest; |
|
82 } |
|
83 |
|
84 sub TEFNoTestcasesTest |
|
85 { |
|
86 my $this = shift; |
|
87 $this->{TestHarness} = $KTEFNoTestcasesTest; |
|
88 } |
|
89 |
|
90 sub TestFrameworkTest |
|
91 { |
|
92 my $this = shift; |
|
93 $this->{TestHarness} = $KTestFrameworkTest; |
|
94 } |
|
95 |
|
96 sub TestHarness |
|
97 { |
|
98 my $this = shift; |
|
99 return $this->{TestHarness}; |
|
100 } |
|
101 |
|
102 sub AddInconclusiveResult |
|
103 { |
|
104 my $this = shift; |
|
105 my $currentFreeIndex = $this->{Inconclusives}[0]; |
|
106 $this->{Inconclusives}[$currentFreeIndex] = shift; |
|
107 $currentFreeIndex++; |
|
108 $this->{Inconclusives}[0] = $currentFreeIndex; |
|
109 } |
|
110 |
|
111 sub ResetInconclusives |
|
112 { |
|
113 my $this = shift; |
|
114 $this->{Inconclusives}[0] = 1; |
|
115 } |
|
116 |
|
117 sub Inconclusives |
|
118 { |
|
119 my $this = shift; |
|
120 my @inconList = @{$this->{Inconclusives}}; |
|
121 my $finalIndex = $inconList[0] - 1; |
|
122 return @inconList[1 .. $finalIndex]; |
|
123 } |
|
124 |
|
125 sub AddFailureResult |
|
126 { |
|
127 my $this = shift; |
|
128 my $currentFreeIndex = $this->{Fails}[0]; |
|
129 $this->{Fails}[$currentFreeIndex] = shift; |
|
130 $currentFreeIndex++; |
|
131 $this->{Fails}[0] = $currentFreeIndex; |
|
132 } |
|
133 |
|
134 sub ResetFailures |
|
135 { |
|
136 my $this = shift; |
|
137 $this->{Fails}[0] = 1; |
|
138 } |
|
139 |
|
140 sub Failures |
|
141 { |
|
142 my $this = shift; |
|
143 my @failureList = @{$this->{Fails}}; |
|
144 my $finalIndex = $failureList[0] - 1; |
|
145 return @failureList[1 .. $finalIndex]; |
|
146 } |
|
147 |
|
148 sub SetTotalTestCount |
|
149 { |
|
150 my $this = shift; |
|
151 $this->{TotalNumberTestCases} = shift; |
|
152 } |
|
153 |
|
154 sub TotalTestCount |
|
155 { |
|
156 my $this = shift; |
|
157 return $this->{TotalNumberTestCases}; |
|
158 } |
|
159 |
|
160 sub TestCrashed |
|
161 { |
|
162 my $this = shift; |
|
163 $this->{DidItCrash} = $KTestCrashed; |
|
164 } |
|
165 |
|
166 sub ResetCrashed |
|
167 { |
|
168 my $this = shift; |
|
169 $this->{DidItCrash} = $KTestDidNotCrash; |
|
170 } |
|
171 |
|
172 sub DidItCrash |
|
173 { |
|
174 my $this = shift; |
|
175 return $this->{DidItCrash}; |
|
176 } |
|
177 |
|
178 sub AnyFailures |
|
179 { |
|
180 my $this = shift; |
|
181 if (($this->{Fails}[0] > 1) || ($this->{Inconclusives}[0] > 1) || ($this->DidItCrash())) |
|
182 { |
|
183 return 1; |
|
184 } |
|
185 return 0; |
|
186 } |
|
187 |
|
188 sub DebugPrint |
|
189 { |
|
190 my $this = shift; |
|
191 print "\nTest script: $this->{ScriptName}\n$this->{FilePath}\n"; |
|
192 if ($this->{DidItCrash} == $KTestCrashed) |
|
193 { |
|
194 print "It CRASHED\n"; |
|
195 } |
|
196 print "Test cases run: $this->{TotalNumberTestCases}\n"; |
|
197 |
|
198 my $lastIndex = $this->{Inconclusives}[0] - 1; |
|
199 if ($lastIndex > 0) |
|
200 { |
|
201 print "INCONCLUSIVES:\n"; |
|
202 foreach my $inconclusiveResult (@{$this->{Inconclusives}}[1 .. $lastIndex]) |
|
203 { |
|
204 print "$inconclusiveResult\n"; |
|
205 } |
|
206 } |
|
207 |
|
208 $lastIndex = $this->{Fails}[0] - 1; |
|
209 if ($lastIndex > 0) |
|
210 { |
|
211 print "FAILS:\n"; |
|
212 foreach my $failResult (@{$this->{Fails}}[1 .. $lastIndex]) |
|
213 { |
|
214 print "$failResult\n"; |
|
215 } |
|
216 } |
|
217 } |