|
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 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalComponent - Internal Symbian test code |
|
19 */ |
|
20 |
|
21 #include <s32file.h> |
|
22 |
|
23 #include "T_SysStartApparcStep.h" |
|
24 #include "tssaac/tssaac.h" |
|
25 |
|
26 _LIT(KApparcPanicFile,"c:\\T_SSAAC_PanicResultFile.txt"); |
|
27 |
|
28 |
|
29 const TChar KDelimChar = '='; |
|
30 |
|
31 /** |
|
32 The expected results are hard coded from the test specification. |
|
33 */ |
|
34 //Test case 1 |
|
35 const TInt KExpectedStartApp1LRes1 = KErrNone; |
|
36 const TInt KExpectedStartApp1LRes2 = KErrNotFound; |
|
37 |
|
38 //Test case 99 |
|
39 const TInt KExpectedLocalisedCaptionLRes1 = 0; |
|
40 const TInt KExpectedLocalisedCaptionLRes2 = 0; |
|
41 |
|
42 /** |
|
43 Read the results of the individual tests. The test number is determined by |
|
44 reading the configuration file z:\\apparctest\\TestCaseConfig.txt and then one |
|
45 of two functions is called, one which handles tests which panic and one which |
|
46 handles tests which don't. |
|
47 |
|
48 Non-paniccing test results are read from file c:\\SysStartApparc_TestStartApp1L.txt |
|
49 The order in which these results are written in CSysStartApparcTestCase::WriteResultFileL() |
|
50 MUST match the order in which they are read and tested in CheckApparcResultsL() |
|
51 The expected results are hard coded from the test specification.(see above) |
|
52 |
|
53 Paniccing test results are read from file c:\\T_SSAAC_PanicResultFile.txt |
|
54 The result is a '1 or 0' to represent a PASS or a FAIL The actual pass critria |
|
55 are found in file sysstart_apparc_checkEpocWind.bat where the test is performed and |
|
56 the T_SSAAC_PanicResultFile file created with the appropriate result |
|
57 |
|
58 */ |
|
59 |
|
60 /** |
|
61 Read the results of the individual tests that do not panic. Currently, there is |
|
62 only one test that does not panic. Results are read in from file SysStartApparc_TestStartApp1L.txt |
|
63 and compared with the expected results |
|
64 |
|
65 */ |
|
66 void CT_SysStartApparcStep::CheckApparcResultsL() |
|
67 { |
|
68 RFs fs; |
|
69 User::LeaveIfError(fs.Connect()); |
|
70 CleanupClosePushL(fs); |
|
71 |
|
72 RFileReadStream reader; |
|
73 User::LeaveIfError(reader.Open(fs, KSsaacResultFile, EFileRead)); |
|
74 CleanupClosePushL(reader); |
|
75 |
|
76 TBuf8<64> myDes; |
|
77 TInt ret = 0; |
|
78 |
|
79 // Read 16 bits - StartApp1LRes1 |
|
80 reader.ReadL(myDes, KDelimChar); |
|
81 ret = reader.ReadInt16L(); |
|
82 |
|
83 if(iTestcase == 1) |
|
84 { |
|
85 INFO_PRINTF3(_L("Test StartApp1LRes1 Count - Expected: %d, Actual: %d"), KExpectedStartApp1LRes1, ret); |
|
86 TEST(ret==KExpectedStartApp1LRes1); |
|
87 } |
|
88 else |
|
89 { // test case is 99 |
|
90 INFO_PRINTF3(_L("Test LocalisedCaptionLRes1 Count - Expected: %d, Actual: %d"), KExpectedLocalisedCaptionLRes1, ret); |
|
91 TEST(ret==KExpectedLocalisedCaptionLRes1); |
|
92 } |
|
93 |
|
94 // Read 16 bits - StartApp1LRes2 |
|
95 reader.ReadL(myDes, KDelimChar); |
|
96 ret = reader.ReadInt16L(); |
|
97 |
|
98 if(iTestcase == 1) |
|
99 { |
|
100 INFO_PRINTF3(_L("Test StartApp1LRes2 Count - Expected: %d, Actual: %d"), KExpectedStartApp1LRes2, ret); |
|
101 TEST(ret==KExpectedStartApp1LRes2); |
|
102 } |
|
103 else // test cass is 99 |
|
104 { |
|
105 INFO_PRINTF3(_L("Test LocalisedCaptionLRes2 Count - Expected: %d, Actual: %d"), KExpectedLocalisedCaptionLRes2, ret); |
|
106 TEST(ret==KExpectedLocalisedCaptionLRes2); |
|
107 } |
|
108 |
|
109 // clean-up |
|
110 CleanupStack::PopAndDestroy(2, &fs); |
|
111 } |
|
112 |
|
113 /** |
|
114 Read the results of the individual tests that panic. After a panic, the |
|
115 batch file sysstartapparc_checkEpocWind.bat searched the EpocWind.out file |
|
116 for lines of text that verify that a panic has occurred with the correct |
|
117 KERN-EXEC number and then writes the result to a text file (pass=1, fail=0) |
|
118 for processing here. |
|
119 |
|
120 */ |
|
121 void CT_SysStartApparcStep::CheckApparcPanicResultsL() |
|
122 { |
|
123 RFs fs; |
|
124 User::LeaveIfError(fs.Connect()); |
|
125 INFO_PRINTF1(_L("File server connected")); |
|
126 |
|
127 CleanupClosePushL(fs); |
|
128 |
|
129 RFileReadStream reader; |
|
130 User::LeaveIfError(reader.Open(fs, KApparcPanicFile, EFileRead)); |
|
131 |
|
132 CleanupClosePushL(reader); |
|
133 |
|
134 TBuf8<64> myDes; |
|
135 |
|
136 TInt expected = 1; //a PASS |
|
137 |
|
138 //File containd a test name and a test result, Move past the test name |
|
139 reader.ReadL(myDes, KDelimChar); |
|
140 |
|
141 //Read the test result |
|
142 reader.ReadL(myDes, KDelimChar); |
|
143 |
|
144 // Read 16 bits - StartApp1LRes1 |
|
145 TChar result(reader.ReadUint8L()); |
|
146 TInt ret = result.GetNumericValue(); |
|
147 INFO_PRINTF3(_L("Test StartApp1LRes1 Count - Expected: %d, Actual: %d"), KTestResultPass, ret); |
|
148 TEST(ret==expected); |
|
149 |
|
150 // clean-up |
|
151 CleanupStack::PopAndDestroy(2, &fs); |
|
152 } |
|
153 |
|
154 |
|
155 /** |
|
156 Destructor |
|
157 */ |
|
158 CT_SysStartApparcStep::~CT_SysStartApparcStep() |
|
159 { |
|
160 } |
|
161 |
|
162 /** |
|
163 Constructor |
|
164 */ |
|
165 CT_SysStartApparcStep::CT_SysStartApparcStep() |
|
166 { |
|
167 // Call base class method to set up the human readable name for logging |
|
168 SetTestStepName(KT_SysStartApparcStep); |
|
169 } |
|
170 |
|
171 /** |
|
172 Override of base class virtual. |
|
173 @return - TVerdict code |
|
174 */ |
|
175 |
|
176 TVerdict CT_SysStartApparcStep::doTestStepL() |
|
177 { |
|
178 INFO_PRINTF1(_L("Test T_SysStartApparcStep: Started")); |
|
179 |
|
180 __UHEAP_MARK; |
|
181 TInt ret=KErrGeneral; |
|
182 iTestcase=ReadConfigFileL(); |
|
183 |
|
184 //Test case 1 and 99 are the only tests that do not panic |
|
185 if( (iTestcase==1) || (iTestcase==29) ) |
|
186 { |
|
187 TRAP(ret, CheckApparcResultsL()); |
|
188 } |
|
189 else |
|
190 { |
|
191 TRAP(ret, CheckApparcPanicResultsL()); |
|
192 } |
|
193 INFO_PRINTF2(_L("CheckApparcResultsL ends with code %d"), ret); |
|
194 TEST(ret==KErrNone); |
|
195 __UHEAP_MARKEND; |
|
196 |
|
197 INFO_PRINTF1(_L("Test T_SysStartApparcStep: Finished")); |
|
198 return TestStepResult(); |
|
199 } |
|
200 |
|
201 /** |
|
202 Reads the input config file and returns the test case number |
|
203 Defined in sysstart_apparc_run.bat |
|
204 @return TInt - the test case number |
|
205 */ |
|
206 TInt CT_SysStartApparcStep::ReadConfigFileL() |
|
207 { |
|
208 RFs fs; |
|
209 User::LeaveIfError(fs.Connect()); |
|
210 CleanupClosePushL(fs); |
|
211 |
|
212 RFileReadStream reader; |
|
213 User::LeaveIfError(reader.Open(fs, KApparcConfigFile, EFileRead)); |
|
214 CleanupClosePushL(reader); |
|
215 |
|
216 TBuf8<255> aDes; |
|
217 reader.ReadL(aDes, KDelimChar); |
|
218 |
|
219 //Read in a two character representation of a number and convert to an integer |
|
220 TChar result1(reader.ReadInt8L()); |
|
221 TChar result0(reader.ReadInt8L()); |
|
222 TInt aTestCase = result1.GetNumericValue()*10 + result0.GetNumericValue(); |
|
223 |
|
224 // clean-up |
|
225 CleanupStack::PopAndDestroy(2, &fs); |
|
226 |
|
227 return aTestCase; |
|
228 |
|
229 } |