os/persistentdata/featuremgmt/featureregistry/test/compositeromtesting/src/featregSetupTest.cpp
Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
18 #include "featregcmn.h"
23 LOCAL_D RTest TheTest(_L("featregsetup OOM Test"));
25 //Test macros and functions
27 LOCAL_C void Check(TInt aValue, TInt aLine)
31 TheTest(EFalse, aLine);
35 LOCAL_C void Check(TInt aValue, TInt aExpected, TInt aLine)
37 if(aValue != aExpected)
39 RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
40 TheTest(EFalse, aLine);
44 #define TEST(arg) ::Check((arg), __LINE__)
45 #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
48 @SYMTestCaseID SYSLIB-FEATREG-CT-3373
49 @SYMTestCaseDesc OOM Test for the function ReadMultipleFeatureFileToBuf
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
55 @SYMTestExpectedResults The test must not fail.
58 static void CompositeOOMTesting()
60 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-FEATREG-CT-3373 Composite OOM Testing "));
67 // find out the number of open handles
70 RThread().HandleCount(pHCountStart,tHCountStart);
74 __UHEAP_SETFAIL(RHeap::EDeterministic, failAt++);
76 err=ReadMultipleFeatureFileToBuf(TheFs,KFeatregRomPrivatePath,buffer);
78 __UHEAP_SETFAIL(RHeap::ENone, 0);
82 // check that no handles have leaked
85 RThread().HandleCount(pHCountEnd,tHCountEnd);
87 TEST2(pHCountStart,pHCountEnd);
88 TEST2(tHCountStart,tHCountEnd);
91 while (err == KErrNoMemory);
92 RDebug::Print(_L("Allocation successful at count=%d"),failAt);
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.
108 static void CompositeROMTestingL()
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)
118 DSR: 0x10279806 - 0x10281805 (Default techview)
119 ------------------------------------------------------------------
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)
128 DSR: 0x10279806 - 0x10281805 (Default techview)
129 0x102CCCCC - 0x102DDDDD
130 0x1CCCCCCA - 0x1CCCCCCF
131 ------------------------------------------------------------------
133 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-FEATREG-CT-3374 Composite ROM Testing "));
135 RFeatureRegistry featreg;
136 User::LeaveIfError(featreg.Open());
137 CleanupClosePushL(featreg);
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};
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
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
157 TEST2(featreg.QuerySupport(TestAA),0);
158 TEST2(featreg.QuerySupport(TestAA,info),0);
160 TEST(featreg.QuerySupport(TestBB)>0);
161 TEST(featreg.QuerySupport(TestBB,info)>0);
163 TEST2(featreg.QuerySupport(Fax),0);
164 TEST2(featreg.QuerySupport(Fax,info),0);
166 TEST(featreg.QuerySupport(Usb)>0);
167 TEST(featreg.QuerySupport(Usb,info)>0);
169 TEST(featreg.QuerySupport(OmaDHS)>0);
170 TEST(featreg.QuerySupport(OmaDHS,info)>0);
172 TEST(featreg.QuerySupport(TestCC)>0);
173 TEST(featreg.QuerySupport(TestCC,info)>0);
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++)
181 TEST(featreg.QuerySupport(featUid)>0);
182 TEST(featreg.QuerySupport(featUid,info)>0);
185 //now check the range in ROFS2 and ROFS3
186 for (TInt j=0x10288888;j<=0x10299999;j++)
189 TEST(featreg.QuerySupport(featUid)>0);
190 TEST(featreg.QuerySupport(featUid,info)>0);
193 for (TInt k=0x102AAAAA;k<=0x102BBBBB;k++)
196 TEST(featreg.QuerySupport(featUid)>0);
197 TEST(featreg.QuerySupport(featUid,info)>0);
200 for (TInt l=0x102CCCCC;l<=0x102DDDDD;l++)
203 TEST(featreg.QuerySupport(featUid)>0);
204 TEST(featreg.QuerySupport(featUid,info)>0);
207 for (TInt m=0x1CCCCCCA;m<=0x1CCCCCCF;m++)
210 TEST(featreg.QuerySupport(featUid)>0);
211 TEST(featreg.QuerySupport(featUid,info)>0);
214 CleanupStack::PopAndDestroy();
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.
228 static void CompositeCorruptFileTesting()
230 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-FEATREG-CT-3375 Composite Corrupt Testing "));
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\\");
237 TInt err=ReadMultipleFeatureFileToBuf(TheFs,KTestDirectory,buffer);
238 TEST2(err,KErrCorrupt);
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.
253 static void OutputFileNameL()
255 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-FEATREG-CT-3471 "));
256 _LIT(KFeatRegDir,"z:\\private\\102744CA\\*");
260 User::LeaveIfError(TheFs.GetDir(KFeatRegDir, KEntryAttMaskSupported,ESortByName,dirList));
262 RDebug::Print(_L("These are the files under z:\\private\\102744CA\\ "));
264 for (TInt i=0;i<dirList->Count();i++)
266 RDebug::Print(_L(" %S "), &(*dirList)[i].iName);
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()
279 User::LeaveIfError(TheFs.Connect());
281 CompositeCorruptFileTesting();
282 CompositeOOMTesting();
283 CompositeROMTestingL();
292 CActiveScheduler* scheduler = new(ELeave)CActiveScheduler;
293 CActiveScheduler::Install(scheduler);
295 TRAPD(err,RunTestL());
296 TEST2(err, KErrNone);
301 GLDEF_C TInt E32Main()
306 TheTest.Start(_L("Featregsetup Composite Testing"));
308 CTrapCleanup* cleanup = CTrapCleanup::New();
311 TEST2(err, KErrNone);