|
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 // t_oomcenrep.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 #include "t_cenrep_helper.h" |
|
19 #include <e32test.h> |
|
20 #include <f32file.h> |
|
21 #include <utf.h> |
|
22 #include "srvsess.h" |
|
23 #include "sessmgr.h" |
|
24 #include "srvres.h" |
|
25 #include "srvreqs.h" |
|
26 #include "cachemgr.h" |
|
27 #include "clientrequest.h" |
|
28 #include "install.h" |
|
29 #include <bautils.h> |
|
30 |
|
31 LOCAL_D RTest TheTest (_L ("t_cenrep_pma_multirofs.exe")); |
|
32 |
|
33 /////////////////////////////////////////////////////////////////////////////////////// |
|
34 //Test macros and functions |
|
35 LOCAL_C void Check(TInt aValue, TInt aExpected, TInt aLine, TBool aIsHexFormat=EFalse) |
|
36 { |
|
37 if(aValue != aExpected) |
|
38 { |
|
39 if(aIsHexFormat) |
|
40 { |
|
41 RDebug::Print(_L("*** Expected error: 0x%x, got: 0x%x\r\n"), aExpected, aValue); |
|
42 } |
|
43 else |
|
44 { |
|
45 RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue); |
|
46 } |
|
47 TRAPD(err, CleanupCDriveL()); |
|
48 if (err != KErrNone) |
|
49 { |
|
50 RDebug::Print( _L( "*** CleanupCDriveL also failed with error %d expecting KErrNone\r\n"), err ); |
|
51 } |
|
52 TheTest(EFalse, aLine); |
|
53 } |
|
54 } |
|
55 |
|
56 #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__) |
|
57 #define TESTHEX2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__, ETrue) |
|
58 |
|
59 ///////////////////////////////////////////////////////////////////////////////////////// |
|
60 static void CloseTServerResources(TAny*) |
|
61 { |
|
62 TServerResources::Close(); |
|
63 } |
|
64 |
|
65 ///////////////////////////////////////////////////////////////////////////////////////// |
|
66 class CenrepSrvPmaMultiRofsTest :public CBase |
|
67 { |
|
68 public: |
|
69 CenrepSrvPmaMultiRofsTest(); |
|
70 ~CenrepSrvPmaMultiRofsTest(); |
|
71 static CenrepSrvPmaMultiRofsTest* NewL(TUid aReposUid); |
|
72 void DoHeapRepositoryContentCheckL(); |
|
73 |
|
74 private: |
|
75 void ConstructL(TUid aReposUid); |
|
76 public: |
|
77 CServerRepository* iServerRepo; |
|
78 CSessionNotifier* iSessionNotif; |
|
79 }; |
|
80 |
|
81 ////////////////////////////////////////////////////////////////////////////////////////////////// |
|
82 |
|
83 CenrepSrvPmaMultiRofsTest::CenrepSrvPmaMultiRofsTest(){} |
|
84 |
|
85 CenrepSrvPmaMultiRofsTest::~CenrepSrvPmaMultiRofsTest() |
|
86 { |
|
87 if (iServerRepo) |
|
88 { |
|
89 if (iSessionNotif) |
|
90 { |
|
91 iServerRepo->Close(); |
|
92 } |
|
93 delete iServerRepo; |
|
94 } |
|
95 if (iSessionNotif) |
|
96 delete iSessionNotif; |
|
97 |
|
98 // Cache must be disabled here. Otherwise, if any idle repositories exists, they will |
|
99 // still be open (have their pointers in the iOpenRepositories list) and the list will leak. |
|
100 TServerResources::iCacheManager->DisableCache(); |
|
101 TServerResources::iObserver->CloseiOpenRepositories(); |
|
102 } |
|
103 |
|
104 CenrepSrvPmaMultiRofsTest* CenrepSrvPmaMultiRofsTest::NewL(TUid aReposUid) |
|
105 { |
|
106 CenrepSrvPmaMultiRofsTest* self=new (ELeave)CenrepSrvPmaMultiRofsTest; |
|
107 CleanupStack::PushL(self); |
|
108 self->ConstructL(aReposUid); |
|
109 CleanupStack::Pop(self); |
|
110 return self; |
|
111 } |
|
112 |
|
113 void CenrepSrvPmaMultiRofsTest::ConstructL(TUid aReposUid) |
|
114 { |
|
115 iServerRepo=new (ELeave)CServerRepository(); |
|
116 iSessionNotif=new (ELeave) CSessionNotifier(); |
|
117 |
|
118 iServerRepo->OpenL(aReposUid,*iSessionNotif); |
|
119 } |
|
120 |
|
121 //Deletes the CServerRepository object properly |
|
122 LOCAL_C void ReleaseRepository(TAny* aServerRepository) |
|
123 { |
|
124 CServerRepository* serverRepository = static_cast<CServerRepository*>(aServerRepository); |
|
125 |
|
126 TServerResources::iCacheManager->DisableCache(); |
|
127 TServerResources::iObserver->CloseiOpenRepositories(); |
|
128 delete serverRepository; |
|
129 TServerResources::iCacheManager->EnableCache(); |
|
130 } |
|
131 |
|
132 //Opening a repository and closing the repository |
|
133 LOCAL_C void OpenCloseL(TUid aReposUid) |
|
134 { |
|
135 CServerRepository* serverRepo=new (ELeave)CServerRepository(); |
|
136 TCleanupItem cleanupItem(&ReleaseRepository, serverRepo); |
|
137 CleanupStack::PushL(cleanupItem); |
|
138 |
|
139 CSessionNotifier* sessNotif=new (ELeave)CSessionNotifier(); |
|
140 CleanupStack::PushL(sessNotif); |
|
141 |
|
142 // test access to a valid repository |
|
143 serverRepo->OpenL(aReposUid,*sessNotif); |
|
144 serverRepo->Close(); |
|
145 |
|
146 CleanupStack::PopAndDestroy(sessNotif); |
|
147 CleanupStack::PopAndDestroy(1); |
|
148 } |
|
149 |
|
150 // Type definition for pointer to function |
|
151 // Used for functions that can't use CenrepSrvPmaMultiRofsTest::ConstructL |
|
152 /** |
|
153 Wrapper function to call all test functions |
|
154 @param testFuncL pointer to test function |
|
155 @param aTestDesc test function name |
|
156 */ |
|
157 LOCAL_C void DoMultiRofsReposTestL( TUid aReposUid, const TDesC& aTestDesc, TInt aExpectedResult) |
|
158 { |
|
159 TheTest.Next(aTestDesc); |
|
160 |
|
161 TInt err; |
|
162 __UHEAP_MARK; |
|
163 |
|
164 //Initializing the server resources |
|
165 TServerResources::InitialiseL (); |
|
166 |
|
167 TRAP(err, OpenCloseL(aReposUid)); |
|
168 TEST2(err, aExpectedResult); |
|
169 |
|
170 //Freeing the server resources |
|
171 TServerResources::Close(); |
|
172 |
|
173 __UHEAP_MARKEND; |
|
174 |
|
175 } |
|
176 |
|
177 void CenrepSrvPmaMultiRofsTest::DoHeapRepositoryContentCheckL() |
|
178 { |
|
179 CServerRepository* srv=iServerRepo; |
|
180 //check setting and its meta |
|
181 TServerSetting* setting=NULL; |
|
182 |
|
183 setting=srv->GetSetting(1); |
|
184 TESTHEX2(setting->iKey,1); |
|
185 TESTHEX2(setting->iMeta,0x80000010); |
|
186 //points to global default policy here |
|
187 TESTHEX2(setting->iAccessPolicy->LowKey(),KUnspecifiedKey); |
|
188 TESTHEX2(setting->iAccessPolicy->HighKey(),1); |
|
189 TESTHEX2(setting->iAccessPolicy->KeyMask(),1); |
|
190 |
|
191 setting=srv->GetSetting(2); |
|
192 TESTHEX2(setting->iKey,2); |
|
193 TESTHEX2(setting->iMeta,0xA0000010); |
|
194 //points to global default policy here |
|
195 TESTHEX2(setting->iAccessPolicy->LowKey(),KUnspecifiedKey); |
|
196 TESTHEX2(setting->iAccessPolicy->HighKey(),1); |
|
197 TESTHEX2(setting->iAccessPolicy->KeyMask(),1); |
|
198 |
|
199 setting=srv->GetSetting(3); |
|
200 TESTHEX2(setting->iKey,3); |
|
201 TESTHEX2(setting->iMeta,0x800000FF); |
|
202 //points to global default policy here |
|
203 TESTHEX2(setting->iAccessPolicy->LowKey(),KUnspecifiedKey); |
|
204 TESTHEX2(setting->iAccessPolicy->HighKey(),1); |
|
205 TESTHEX2(setting->iAccessPolicy->KeyMask(),1); |
|
206 |
|
207 setting=srv->GetSetting(4); |
|
208 TESTHEX2(setting->iKey,4); |
|
209 TESTHEX2(setting->iMeta,0x80000010); |
|
210 TESTHEX2(setting->iAccessPolicy->LowKey(),4); |
|
211 TESTHEX2(setting->iAccessPolicy->HighKey(),1); |
|
212 TESTHEX2(setting->iAccessPolicy->KeyMask(),0); |
|
213 |
|
214 setting=srv->GetSetting(5); |
|
215 TESTHEX2(setting->iKey,5); |
|
216 TESTHEX2(setting->iMeta,0xC0000063); |
|
217 //points to global default policy here |
|
218 TESTHEX2(setting->iAccessPolicy->LowKey(),KUnspecifiedKey); |
|
219 TESTHEX2(setting->iAccessPolicy->HighKey(),1); |
|
220 TESTHEX2(setting->iAccessPolicy->KeyMask(),1); |
|
221 |
|
222 setting=srv->GetSetting(6); |
|
223 TESTHEX2(setting->iKey,6); |
|
224 TESTHEX2(setting->iMeta,0x90000010); |
|
225 TESTHEX2(setting->iAccessPolicy->LowKey(),6); |
|
226 TESTHEX2(setting->iAccessPolicy->HighKey(),1); |
|
227 TESTHEX2(setting->iAccessPolicy->KeyMask(),0); |
|
228 |
|
229 setting=srv->GetSetting(7); |
|
230 TESTHEX2(setting->iKey,7); |
|
231 TESTHEX2(setting->iMeta,0x80000010); |
|
232 TESTHEX2(setting->iAccessPolicy->LowKey(),7); |
|
233 TESTHEX2(setting->iAccessPolicy->HighKey(),1); |
|
234 TESTHEX2(setting->iAccessPolicy->KeyMask(),0); |
|
235 |
|
236 setting=srv->GetSetting(9); |
|
237 TESTHEX2(setting->iKey,9); |
|
238 TESTHEX2(setting->iMeta,0x80000010); |
|
239 TESTHEX2(setting->iAccessPolicy->LowKey(),KUnspecifiedKey); |
|
240 TESTHEX2(setting->iAccessPolicy->HighKey(),1); |
|
241 TESTHEX2(setting->iAccessPolicy->KeyMask(),1); |
|
242 |
|
243 setting=srv->GetSetting(10); |
|
244 TESTHEX2(setting->iKey,10); |
|
245 TESTHEX2(setting->iMeta,0x80000010); |
|
246 TESTHEX2(setting->iAccessPolicy->LowKey(),10); |
|
247 TESTHEX2(setting->iAccessPolicy->HighKey(),1); |
|
248 TESTHEX2(setting->iAccessPolicy->KeyMask(),0); |
|
249 |
|
250 setting=srv->GetSetting(300); |
|
251 TESTHEX2(setting->iKey,300); |
|
252 TESTHEX2(setting->iMeta,0x900003E7); |
|
253 TESTHEX2(setting->iAccessPolicy->LowKey(),KUnspecifiedKey); |
|
254 TESTHEX2(setting->iAccessPolicy->HighKey(),1); |
|
255 TESTHEX2(setting->iAccessPolicy->KeyMask(),1); |
|
256 } |
|
257 |
|
258 LOCAL_C void DoAdditionalCheckingL(TUid aReposUid) |
|
259 { |
|
260 TServerResources::InitialiseL (); |
|
261 CleanupStack::PushL(TCleanupItem(CloseTServerResources, 0)); |
|
262 |
|
263 CenrepSrvPmaMultiRofsTest* test=CenrepSrvPmaMultiRofsTest::NewL(aReposUid); |
|
264 CleanupStack::PushL(test); |
|
265 test->DoHeapRepositoryContentCheckL(); |
|
266 |
|
267 CleanupStack::PopAndDestroy(); //test |
|
268 CleanupStack::Pop(); //CloseTServerResources |
|
269 |
|
270 TServerResources::Close(); |
|
271 } |
|
272 |
|
273 /** |
|
274 @SYMTestCaseID PDS-CENTRALREPOSITORY-UT-4124 |
|
275 @SYMTestCaseDesc Server side loading of a multiple ROFS PMA repository files |
|
276 @SYMTestPriority High |
|
277 @SYMTestActions - Create the server class CServerRepository and used it to load the multi ROFS PMA keyspace. |
|
278 - Test are repeated for the following keyspace combination such as TXT/TXT, CRE/TXT or TXT/CRE and CRE/CRE. |
|
279 - Test will also verify the resulting merged settings which includes checking |
|
280 individual metadata bits and security policy bits |
|
281 - Test will also be repeated for opening PMA keyspace with non-PMA keyspace in different ROFS layers. |
|
282 |
|
283 @SYMTestExpectedResults - Server loading of the multi rofs keyspace should not fail if the type of the keyspace is the same |
|
284 - Server loading of the multi rofs keyspace should fail if the type of the keyspace is not the same |
|
285 @SYMREQ REQ42876 |
|
286 */ |
|
287 LOCAL_C void DoPMAMultiRofsTestL() |
|
288 { |
|
289 TheTest.Next (_L (" @SYMTestCaseID:PDS-CENTRALREPOSITORY-UT-4124 Centrep Server PMA MultiROFS Test")); |
|
290 |
|
291 const TUid KMultiRofsRepositoryUid0={0xF1000900};//TXT1(core) - CRE1(rofs1) - TXT1(rofs2) - CRE1(rofs3) |
|
292 const TUid KMultiRofsRepositoryUid1={0xF1000901};//TXT1(core) - TXT1(rofs1) |
|
293 const TUid KMultiRofsRepositoryUid2={0xF1000902};//CRE1(core) - CRE1(rofs1) |
|
294 const TUid KMultiRofsRepositoryUid3={0xF1000903};//TXT1(core) - CRE1(rofs1) |
|
295 const TUid KMultiRofsRepositoryUid4={0xF1000904};//CRE1(core) - TXT1(rofs1) |
|
296 const TUid KMultiRofsRepositoryUid5={0xF1000905};//TXT1(core) - TXT0(rofs1) |
|
297 const TUid KMultiRofsRepositoryUid6={0xF1000906};//TXT0(core) - TXT1(rofs1) |
|
298 const TUid KMultiRofsRepositoryUid7={0xF1000907};//CRE1(core) - CRE0(rofs1) |
|
299 const TUid KMultiRofsRepositoryUid8={0xF1000908};//CRE0(core) - CRE1(rofs1) |
|
300 const TUid KMultiRofsRepositoryUid9={0xF1000909};//CRE1(core) - TXT0(rofs1) |
|
301 const TUid KMultiRofsRepositoryUid10={0xF100090A};//CRE0(core) - TXT1(rofs1) |
|
302 const TUid KMultiRofsRepositoryUid11={0xF100090B};//TXT1(core) - CRE0(rofs1) |
|
303 const TUid KMultiRofsRepositoryUid12={0xF100090C};//TXT0(core) - CRE1(rofs1) |
|
304 const TUid KMultiRofsRepositoryUid13={0xF100090D};//TXT1(core) - CRE1(rofs1) - TXT1(rofs2) - CRE0(rofs3) |
|
305 // Note: TXT1 means the file is PMA repository with .txt format |
|
306 // TXT0 means the file is non-PMA repository with .txt format |
|
307 // CRE1 means the file is PMA repository with .cre format |
|
308 // CRE0 means the file is non-PMA repository with .cre format |
|
309 |
|
310 //First Testuid=KMultiRofsRepositoryUid |
|
311 //Testing the OOM of multi rofs processing |
|
312 // 0xF1000900 to 0xF1000904 expect KErrNone as they are all PMA keyspaces of the same UID across |
|
313 // multiple ROFS layers. |
|
314 DoMultiRofsReposTestL(KMultiRofsRepositoryUid0, _L("Open Close OOM Multi ROFS Test 0"),KErrNone); |
|
315 DoAdditionalCheckingL(KMultiRofsRepositoryUid0); |
|
316 DoMultiRofsReposTestL(KMultiRofsRepositoryUid1, _L("Open Close OOM Multi ROFS Test 1"),KErrNone); |
|
317 DoAdditionalCheckingL(KMultiRofsRepositoryUid1); |
|
318 DoMultiRofsReposTestL(KMultiRofsRepositoryUid2, _L("Open Close OOM Multi ROFS Test 2"),KErrNone); |
|
319 DoAdditionalCheckingL(KMultiRofsRepositoryUid2); |
|
320 DoMultiRofsReposTestL(KMultiRofsRepositoryUid3, _L("Open Close OOM Multi ROFS Test 3"),KErrNone); |
|
321 DoAdditionalCheckingL(KMultiRofsRepositoryUid3); |
|
322 DoMultiRofsReposTestL(KMultiRofsRepositoryUid4, _L("Open Close OOM Multi ROFS Test 4"),KErrNone); |
|
323 DoAdditionalCheckingL(KMultiRofsRepositoryUid4); |
|
324 |
|
325 // 0xF1000905 to 0xF100090D expect KErrCorrupt as they have at least mixed one PMA keyspace and one |
|
326 // Non-PMA keyspace of the same UID across multiple ROFS layers. |
|
327 // No need for additional checking of merged value because it should be corrupt. |
|
328 DoMultiRofsReposTestL(KMultiRofsRepositoryUid5, _L("Open Close OOM Multi ROFS Test 5"),KErrCorrupt); |
|
329 DoMultiRofsReposTestL(KMultiRofsRepositoryUid6, _L("Open Close OOM Multi ROFS Test 6"),KErrCorrupt); |
|
330 DoMultiRofsReposTestL(KMultiRofsRepositoryUid7, _L("Open Close OOM Multi ROFS Test 7"),KErrCorrupt); |
|
331 DoMultiRofsReposTestL(KMultiRofsRepositoryUid8, _L("Open Close OOM Multi ROFS Test 8"),KErrCorrupt); |
|
332 DoMultiRofsReposTestL(KMultiRofsRepositoryUid9, _L("Open Close OOM Multi ROFS Test 9"),KErrCorrupt); |
|
333 DoMultiRofsReposTestL(KMultiRofsRepositoryUid10, _L("Open Close OOM Multi ROFS Test 10"),KErrCorrupt); |
|
334 DoMultiRofsReposTestL(KMultiRofsRepositoryUid11, _L("Open Close OOM Multi ROFS Test 11"),KErrCorrupt); |
|
335 DoMultiRofsReposTestL(KMultiRofsRepositoryUid12, _L("Open Close OOM Multi ROFS Test 12"),KErrCorrupt); |
|
336 DoMultiRofsReposTestL(KMultiRofsRepositoryUid13, _L("Open Close OOM Multi ROFS Test 13"),KErrCorrupt); |
|
337 } |
|
338 |
|
339 LOCAL_C void MainL() |
|
340 { |
|
341 CActiveScheduler* scheduler = new(ELeave)CActiveScheduler; |
|
342 CActiveScheduler::Install(scheduler); |
|
343 |
|
344 DoPMAMultiRofsTestL(); |
|
345 CleanupCDriveL(); |
|
346 |
|
347 delete scheduler; |
|
348 } |
|
349 |
|
350 TInt E32Main () |
|
351 { |
|
352 TheTest.Title (); |
|
353 TheTest.Start(_L("PMA Multi ROFS CenrepServ Test")); |
|
354 |
|
355 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
356 TheTest(cleanup != NULL); |
|
357 |
|
358 __UHEAP_MARK; |
|
359 |
|
360 TRAPD(err, MainL()); |
|
361 TEST2(err, KErrNone); |
|
362 |
|
363 __UHEAP_MARKEND; |
|
364 |
|
365 TheTest.End (); |
|
366 TheTest.Close (); |
|
367 |
|
368 delete cleanup; |
|
369 |
|
370 User::Heap().Check(); |
|
371 return KErrNone; |
|
372 } |