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