|
1 // Copyright (c) 2007-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 #include <e32test.h> |
|
17 #include <f32file.h> |
|
18 #include "featregcmn.h" |
|
19 #include <featreg.h> |
|
20 |
|
21 LOCAL_D RFs TheFs; |
|
22 |
|
23 LOCAL_D RTest TheTest(_L("featregsetup OOM Test")); |
|
24 |
|
25 //Test macros and functions |
|
26 |
|
27 LOCAL_C void Check(TInt aValue, TInt aLine) |
|
28 { |
|
29 if(!aValue) |
|
30 { |
|
31 TheTest(EFalse, aLine); |
|
32 } |
|
33 } |
|
34 |
|
35 LOCAL_C void Check(TInt aValue, TInt aExpected, TInt aLine) |
|
36 { |
|
37 if(aValue != aExpected) |
|
38 { |
|
39 RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue); |
|
40 TheTest(EFalse, aLine); |
|
41 } |
|
42 } |
|
43 |
|
44 #define TEST(arg) ::Check((arg), __LINE__) |
|
45 #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__) |
|
46 |
|
47 /** |
|
48 @SYMTestCaseID SYSLIB-FEATREG-CT-3373 |
|
49 @SYMTestCaseDesc OOM Test for the function ReadMultipleFeatureFileToBuf |
|
50 @SYMTestPriority High |
|
51 @SYMTestActions OOM Testing the function ReadMultipleFeatureFileToBuf |
|
52 when processing multiple featreg files from different rom section |
|
53 Test relies on the additional ROFS2 and ROFS3 section |
|
54 during buildrom time |
|
55 @SYMTestExpectedResults The test must not fail. |
|
56 @SYMDEF DEF101195 |
|
57 */ |
|
58 static void CompositeOOMTesting() |
|
59 { |
|
60 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-FEATREG-CT-3373 Composite OOM Testing ")); |
|
61 TInt failAt=0; |
|
62 TInt err=KErrNone; |
|
63 do |
|
64 { |
|
65 __UHEAP_MARK; |
|
66 |
|
67 // find out the number of open handles |
|
68 TInt pHCountStart; |
|
69 TInt tHCountStart; |
|
70 RThread().HandleCount(pHCountStart,tHCountStart); |
|
71 |
|
72 RBuf8 buffer; |
|
73 |
|
74 __UHEAP_SETFAIL(RHeap::EDeterministic, failAt++); |
|
75 |
|
76 err=ReadMultipleFeatureFileToBuf(TheFs,KFeatregRomPrivatePath,buffer); |
|
77 |
|
78 __UHEAP_SETFAIL(RHeap::ENone, 0); |
|
79 |
|
80 buffer.Close(); |
|
81 |
|
82 // check that no handles have leaked |
|
83 TInt pHCountEnd; |
|
84 TInt tHCountEnd; |
|
85 RThread().HandleCount(pHCountEnd,tHCountEnd); |
|
86 |
|
87 TEST2(pHCountStart,pHCountEnd); |
|
88 TEST2(tHCountStart,tHCountEnd); |
|
89 __UHEAP_MARKEND; |
|
90 } |
|
91 while (err == KErrNoMemory); |
|
92 RDebug::Print(_L("Allocation successful at count=%d"),failAt); |
|
93 TEST2(err,KErrNone); |
|
94 } |
|
95 |
|
96 /** |
|
97 @SYMTestCaseID SYSLIB-FEATREG-CT-3374 |
|
98 @SYMTestCaseDesc Tests the correct list of features are published by featregsetup |
|
99 in a composite rom with multiple featreg files |
|
100 @SYMTestPriority High |
|
101 @SYMTestActions This will be completely testing the functionality from the client side point of view |
|
102 whether the correct feature content is published.by featregsetup when |
|
103 reading and processing multiple files. |
|
104 @SYMTestExpectedResults The test must not fail. |
|
105 @SYMDEF DEF101195 |
|
106 PDEF113655 |
|
107 */ |
|
108 static void CompositeROMTestingL() |
|
109 { |
|
110 /** |
|
111 ------------------------------------------------------------------ |
|
112 COMPOSITE ROM CONFIGURATION |
|
113 MOUNTING CORE-ROFS1-ROFS2-ROFS3 |
|
114 F=FEATURE; XF=EXCLUDE_FEATURE DSR=DEFAULT SUPPORTED RANGE |
|
115 ------------------------------------------------------------------ |
|
116 CORE F: Fax(0x10279806) Usb(0x1027980B)(already included in DSR),OmaDsHostServers(0x10282663) |
|
117 XF: - |
|
118 DSR: 0x10279806 - 0x10281805 (Default techview) |
|
119 ------------------------------------------------------------------ |
|
120 ROFS2 F: TestAA |
|
121 XF: TestBB, Fax, TestCC |
|
122 DSR: 0x10279806 - 0x10281805 (Default techview) |
|
123 0x10288888 - 0x10299999 |
|
124 0x102AAAAA - 0x102BBBBB |
|
125 ------------------------------------------------------------------ |
|
126 ROFS3 F: TestBB, Usb, TestCC (TestCC is in DSR range) |
|
127 XF: TestAA, Usb |
|
128 DSR: 0x10279806 - 0x10281805 (Default techview) |
|
129 0x102CCCCC - 0x102DDDDD |
|
130 0x1CCCCCCA - 0x1CCCCCCF |
|
131 ------------------------------------------------------------------ |
|
132 */ |
|
133 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-FEATREG-CT-3374 Composite ROM Testing ")); |
|
134 __UHEAP_MARK; |
|
135 RFeatureRegistry featreg; |
|
136 User::LeaveIfError(featreg.Open()); |
|
137 CleanupClosePushL(featreg); |
|
138 |
|
139 //SINGLE ENTRY TEST |
|
140 //first test that the overriding feature are behaving as expected |
|
141 TUid TestAA={0x1AAAAAAA}; |
|
142 TUid TestBB={0x1BBBBBBB}; |
|
143 TUid Usb={0x1027980B}; |
|
144 TUid Fax={0x10279806}; |
|
145 TUid OmaDHS={0x10282663}; |
|
146 TUid TestCC={0x1CCCCCCC}; |
|
147 |
|
148 //as a result of the overriding ROFS3 will disable ROFS2 TestAA |
|
149 //and ROFS3 will enable ROFS2 TestBB |
|
150 //and ROFS2 will disable Fax from CORE |
|
151 // |
|
152 //PDEF113655: TestCC is in DSR. It is explicitly excluded in ROFS2 and is explicitly |
|
153 //included in ROFS3. This tests that TestCC has not been optimised out of the config |
|
154 //because it is in the DSR |
|
155 |
|
156 TUint32 info=0; |
|
157 TEST2(featreg.QuerySupport(TestAA),0); |
|
158 TEST2(featreg.QuerySupport(TestAA,info),0); |
|
159 TEST2(info,0); |
|
160 TEST(featreg.QuerySupport(TestBB)>0); |
|
161 TEST(featreg.QuerySupport(TestBB,info)>0); |
|
162 TEST2(info,1); |
|
163 TEST2(featreg.QuerySupport(Fax),0); |
|
164 TEST2(featreg.QuerySupport(Fax,info),0); |
|
165 TEST2(info,0); |
|
166 TEST(featreg.QuerySupport(Usb)>0); |
|
167 TEST(featreg.QuerySupport(Usb,info)>0); |
|
168 TEST2(info,1); |
|
169 TEST(featreg.QuerySupport(OmaDHS)>0); |
|
170 TEST(featreg.QuerySupport(OmaDHS,info)>0); |
|
171 TEST2(info,1); |
|
172 TEST(featreg.QuerySupport(TestCC)>0); |
|
173 TEST(featreg.QuerySupport(TestCC,info)>0); |
|
174 TEST2(info,1); |
|
175 |
|
176 //DEFAULT SUPPORTED RANGE TEST |
|
177 //now check the default CORE range(Exclude the fax as this is disabled) |
|
178 for (TInt i=0x10279807;i<=0x10281805;i++) |
|
179 { |
|
180 TUid featUid={i}; |
|
181 TEST(featreg.QuerySupport(featUid)>0); |
|
182 TEST(featreg.QuerySupport(featUid,info)>0); |
|
183 TEST2(info,1); |
|
184 } |
|
185 //now check the range in ROFS2 and ROFS3 |
|
186 for (TInt j=0x10288888;j<=0x10299999;j++) |
|
187 { |
|
188 TUid featUid={j}; |
|
189 TEST(featreg.QuerySupport(featUid)>0); |
|
190 TEST(featreg.QuerySupport(featUid,info)>0); |
|
191 TEST2(info,1); |
|
192 } |
|
193 for (TInt k=0x102AAAAA;k<=0x102BBBBB;k++) |
|
194 { |
|
195 TUid featUid={k}; |
|
196 TEST(featreg.QuerySupport(featUid)>0); |
|
197 TEST(featreg.QuerySupport(featUid,info)>0); |
|
198 TEST2(info,1); |
|
199 } |
|
200 for (TInt l=0x102CCCCC;l<=0x102DDDDD;l++) |
|
201 { |
|
202 TUid featUid={l}; |
|
203 TEST(featreg.QuerySupport(featUid)>0); |
|
204 TEST(featreg.QuerySupport(featUid,info)>0); |
|
205 TEST2(info,1); |
|
206 } |
|
207 for (TInt m=0x1CCCCCCA;m<=0x1CCCCCCF;m++) |
|
208 { |
|
209 TUid featUid={m}; |
|
210 TEST(featreg.QuerySupport(featUid)>0); |
|
211 TEST(featreg.QuerySupport(featUid,info)>0); |
|
212 TEST2(info,1); |
|
213 } |
|
214 CleanupStack::PopAndDestroy(); |
|
215 __UHEAP_MARKEND; |
|
216 } |
|
217 |
|
218 /** |
|
219 @SYMTestCaseID SYSLIB-FEATREG-CT-3375 |
|
220 @SYMTestCaseDesc Tests Corrupt file handling of ReadMultipleFeatureFileToBuf |
|
221 @SYMTestPriority High |
|
222 @SYMTestActions This test will test that if one of the configuration files is corrupt, the |
|
223 ReadMultipleFeatureFileToBuf function will always return KErrCorrupt, also |
|
224 ensure there is no memory leak when it returned KErrCorrupt. |
|
225 @SYMTestExpectedResults The test must not fail. |
|
226 @SYMDEF DEF101195 |
|
227 */ |
|
228 static void CompositeCorruptFileTesting() |
|
229 { |
|
230 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-FEATREG-CT-3375 Composite Corrupt Testing ")); |
|
231 __UHEAP_MARK; |
|
232 |
|
233 //both test files will be stored in z:\featregcomposite |
|
234 //the featreg.cfg is ok but featreg.cfg[1-0] is a corrupt file |
|
235 _LIT(KTestDirectory,"z:\\featregcomposite\\"); |
|
236 RBuf8 buffer; |
|
237 TInt err=ReadMultipleFeatureFileToBuf(TheFs,KTestDirectory,buffer); |
|
238 TEST2(err,KErrCorrupt); |
|
239 |
|
240 __UHEAP_MARKEND; |
|
241 } |
|
242 |
|
243 |
|
244 /** |
|
245 @SYMTestCaseID SYSLIB-FEATREG-CT-3471 |
|
246 @SYMTestCaseDesc List Config Files Names Under Featreg Data cage |
|
247 @SYMTestPriority High |
|
248 @SYMTestActions This test returns in a list format the names of all the featreg config files in its data cage. |
|
249 In order to validate EC114 Changes for FeatReg |
|
250 @SYMTestExpectedResults Names of featreg config files is returned. |
|
251 @SYMDEF DEF104374 |
|
252 */ |
|
253 static void OutputFileNameL() |
|
254 { |
|
255 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-FEATREG-CT-3471 ")); |
|
256 _LIT(KFeatRegDir,"z:\\private\\102744CA\\*"); |
|
257 |
|
258 CDir* dirList; |
|
259 |
|
260 User::LeaveIfError(TheFs.GetDir(KFeatRegDir, KEntryAttMaskSupported,ESortByName,dirList)); |
|
261 |
|
262 RDebug::Print(_L("These are the files under z:\\private\\102744CA\\ ")); |
|
263 |
|
264 for (TInt i=0;i<dirList->Count();i++) |
|
265 { |
|
266 RDebug::Print(_L(" %S "), &(*dirList)[i].iName); |
|
267 } |
|
268 |
|
269 delete dirList; |
|
270 } |
|
271 |
|
272 |
|
273 //Note that tests can be run in both emulator(automatic) and hardware(manual) however with some difference: |
|
274 //Emulator: Test relies on pre-generated cfg files which is copied and removed using a batch file |
|
275 //Hardware: Test will rely on the buildrom to generate the cfg files for each rom section, as this involes |
|
276 // flashing additional rom sections to Techviwe NAND2 rom, this test is manual |
|
277 LOCAL_C void RunTestL() |
|
278 { |
|
279 User::LeaveIfError(TheFs.Connect()); |
|
280 |
|
281 CompositeCorruptFileTesting(); |
|
282 CompositeOOMTesting(); |
|
283 CompositeROMTestingL(); |
|
284 |
|
285 OutputFileNameL(); |
|
286 |
|
287 TheFs.Close(); |
|
288 } |
|
289 |
|
290 LOCAL_C TInt MainL() |
|
291 { |
|
292 CActiveScheduler* scheduler = new(ELeave)CActiveScheduler; |
|
293 CActiveScheduler::Install(scheduler); |
|
294 |
|
295 TRAPD(err,RunTestL()); |
|
296 TEST2(err, KErrNone); |
|
297 |
|
298 delete scheduler; |
|
299 } |
|
300 |
|
301 GLDEF_C TInt E32Main() |
|
302 { |
|
303 __UHEAP_MARK; |
|
304 |
|
305 TheTest.Title(); |
|
306 TheTest.Start(_L("Featregsetup Composite Testing")); |
|
307 |
|
308 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
309 |
|
310 TRAPD(err,MainL()); |
|
311 TEST2(err, KErrNone); |
|
312 |
|
313 delete cleanup; |
|
314 |
|
315 TheTest.End(); |
|
316 TheTest.Close(); |
|
317 |
|
318 __UHEAP_MARKEND; |
|
319 return(0); |
|
320 } |