|
1 // Copyright (c) 2004-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 <e32panic.h> |
|
18 #include <f32file.h> |
|
19 #include <bautils.h> |
|
20 #include "LoadManager.h" |
|
21 #include <ecom/ecom.h> |
|
22 #include "EComUidCodes.h" |
|
23 #include "Interface.h" // interface to Plugins |
|
24 //Test utils for copying the resolver to C |
|
25 #include "../EcomTestUtils/EcomTestUtils.h" |
|
26 |
|
27 LOCAL_D RTest TEST(_L("Ecom Defect Test")); |
|
28 |
|
29 _LIT(KEComExDllOnZ, "Z:\\RAMOnly\\T_PlatSecResolverC.dll"); |
|
30 |
|
31 _LIT(KEComExDllOnC, "C:\\sys\\bin\\T_PlatSecResolverC.dll"); |
|
32 _LIT(KEComRscFileOnC, "C:\\resource\\plugins\\T_PlatSecResolverC.rsc"); |
|
33 _LIT(KEComRscFileOnZ, "Z:\\RAMOnly\\T_PlatSecResolverC.rsc"); |
|
34 |
|
35 #define UNUSED_VAR(a) a = a |
|
36 inline LOCAL_C void DeleteTestPlugin() |
|
37 { |
|
38 TRAPD(ignoreErr, EComTestUtils::FileManDeleteFileL(KEComExDllOnC)); |
|
39 TRAP(ignoreErr, EComTestUtils::FileManDeleteFileL(KEComRscFileOnC)); |
|
40 } |
|
41 |
|
42 class REcomDefectTest |
|
43 { |
|
44 public: |
|
45 static void DEF049285_TestCaseL(); |
|
46 static void DEF049979_TestCaseL(); |
|
47 static void INC057514_TestCaseL(); |
|
48 static void DEF065025_TestCase(); |
|
49 }; |
|
50 |
|
51 /** |
|
52 Test case for Defect DEF048053 LoadManager Leaks Memory even when FinalClose is called. |
|
53 |
|
54 @SYMTestCaseID SYSLIB-ECOM-CT-0770 |
|
55 @SYMTestCaseDesc Test case for defect number DEF048053 LoadManager Leaks Memory even when FinalClose is called |
|
56 @SYMTestPriority High |
|
57 @SYMTestActions Create two simple implementation with different UID and check for memory leak when FinalClose is called. |
|
58 Create two complex implementations in Two different DLL check for memory leak when FinalClose is called. |
|
59 Create two simple implementation with same UID and check for memory leak when FinalClose is called. |
|
60 Create two complex implementations in different DLL check for memory leak when FinalClose is called. |
|
61 Test for invalid implementationUid to ensure no leak and proper cleanup |
|
62 @SYMTestExpectedResults The test must not fail. |
|
63 @SYMREQ REQ0000 |
|
64 */ |
|
65 void REcomDefectTest::DEF049285_TestCaseL() |
|
66 { |
|
67 TEST.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0770 ")); |
|
68 _LIT(KDummyText,"Dummy params"); |
|
69 |
|
70 TInt err=KErrNone; |
|
71 TInt failAt = 1; |
|
72 //TO clear warnings in urel armv5 as failAt++ is only used in __UHEAP_SETFAIL in udeb |
|
73 failAt+=0; |
|
74 //Dummy instantiation parameters |
|
75 CExampleInterface::TExampleInterfaceInitParams iInitParams; |
|
76 iInitParams.integer = 5; |
|
77 iInitParams.descriptor = &KDummyText; |
|
78 |
|
79 /** |
|
80 -------------Part 1: Two Simple Implementations in Two different DLL---------------- |
|
81 Plugins used: T_PlatSecEcom1.dll with implUid1=0x102026AA |
|
82 T_PlatSecEcom2.dll with implUid2=0x102026AC |
|
83 */ |
|
84 TEST.Next(_L("DEF048053 Part 1\n")); |
|
85 __UHEAP_MARK; |
|
86 TUid implUid1={0x102026AA}; |
|
87 TUid implUid2={0x102026AC}; |
|
88 TUid returnedUid1; |
|
89 TUid returnedUid2; |
|
90 |
|
91 //Create the first implementation |
|
92 TAny* imp1=REComSession::CreateImplementationL(implUid1,returnedUid1); |
|
93 CInstanceInfoSimple* instanceInfo = reinterpret_cast <CInstanceInfoSimple*> (returnedUid1.iUid); |
|
94 TEST(implUid1==instanceInfo->ImplementationUid(), __LINE__); |
|
95 //Now start the OOM test when creating the second implementation |
|
96 __UHEAP_MARK; |
|
97 do |
|
98 { |
|
99 // Setting Heap failure for OOM test |
|
100 __UHEAP_SETFAIL(RHeap::EDeterministic, failAt++); |
|
101 TAny* imp2=NULL; |
|
102 //Create the second implementation |
|
103 TRAP(err,imp2=REComSession::CreateImplementationL(implUid2,returnedUid2)); |
|
104 if (err==KErrNone) |
|
105 { |
|
106 instanceInfo = reinterpret_cast <CInstanceInfoSimple*> (returnedUid2.iUid); |
|
107 TEST(implUid2==instanceInfo->ImplementationUid(), __LINE__); |
|
108 REComSession::DestroyedImplementation(returnedUid2); |
|
109 delete imp2; |
|
110 imp2=NULL; |
|
111 } |
|
112 __UHEAP_SETFAIL(RHeap::ENone, 0); |
|
113 } |
|
114 while (err == KErrNoMemory); |
|
115 //CALL FinalClose() HERE, do not want to leak memory |
|
116 REComSession::FinalClose(); |
|
117 __UHEAP_MARKEND; |
|
118 |
|
119 REComSession::DestroyedImplementation(returnedUid1); |
|
120 delete imp1; |
|
121 imp1=NULL; |
|
122 //call FinalClose() here, do not want to leak memory |
|
123 REComSession::FinalClose(); |
|
124 __UHEAP_MARKEND; |
|
125 |
|
126 |
|
127 /** |
|
128 ---------------Part 2: Two Complex Implementations in Two different DLL----------------------- |
|
129 Plugins used: EComExample2.dll with implUid1=0x10009DC4 |
|
130 EComExample3.dll with implUid2=0x101F8478 |
|
131 */ |
|
132 TEST.Next(_L("DEF048053 Part 2\n")); |
|
133 __UHEAP_MARK; |
|
134 implUid1=TUid::Uid(0x10009DC4); |
|
135 implUid2=TUid::Uid(0x101F8478); |
|
136 failAt=1; |
|
137 //Set up initialisation parameters |
|
138 //This initialisation parameters are required for testing the |
|
139 //failure point in a more complex plugin where it is possible |
|
140 //to fail in the ConstructL stage of the plugin NewL |
|
141 //Create the first plugin |
|
142 CExampleInterface* impl1 = REINTERPRET_CAST(CExampleInterface*, |
|
143 REComSession::CreateImplementationL(implUid1, |
|
144 returnedUid1, |
|
145 &iInitParams |
|
146 )); |
|
147 //Now start the OOM test when creating the second implementation |
|
148 do |
|
149 { |
|
150 __UHEAP_MARK; |
|
151 // Setting Heap failure for OOM test |
|
152 __UHEAP_SETFAIL(RHeap::EDeterministic, failAt++); |
|
153 CExampleInterface* impl2=NULL; |
|
154 //Create the second implementation |
|
155 TRAP(err,impl2 = REINTERPRET_CAST(CExampleInterface*, |
|
156 REComSession::CreateImplementationL(implUid2, |
|
157 returnedUid2, |
|
158 &iInitParams |
|
159 ))); |
|
160 if (err==KErrNone) |
|
161 { |
|
162 instanceInfo = reinterpret_cast <CInstanceInfoSimple*> (returnedUid2.iUid); |
|
163 TEST(implUid2==instanceInfo->ImplementationUid(), __LINE__); |
|
164 REComSession::DestroyedImplementation(returnedUid2); |
|
165 delete impl2; |
|
166 impl2=NULL; |
|
167 } |
|
168 //CALL FinalClose() HERE!, do not want to leak memory |
|
169 REComSession::FinalClose(); |
|
170 __UHEAP_MARKEND; |
|
171 __UHEAP_SETFAIL(RHeap::ENone, 0); |
|
172 } |
|
173 while (err == KErrNoMemory); |
|
174 |
|
175 REComSession::DestroyedImplementation(returnedUid1); |
|
176 delete impl1; |
|
177 impl1=NULL; |
|
178 //call FinalClose() here, do not want to leak memory |
|
179 REComSession::FinalClose(); |
|
180 __UHEAP_MARKEND; |
|
181 |
|
182 /* |
|
183 -----------Part 3, Two Simple Implementations in the Same DLL------- |
|
184 Plugins used: EComExample2.dll with implUid1=0x10009DC3 |
|
185 with implUid2=0x10009DC4 |
|
186 */ |
|
187 TEST.Next(_L("DEF048053 Part 3\n")); |
|
188 __UHEAP_MARK; |
|
189 implUid1=TUid::Uid(0x10009DC3); |
|
190 implUid2=TUid::Uid(0x10009DC4); |
|
191 failAt=1; |
|
192 //Set up initialisation parameters |
|
193 //This initialisation parameters are required for testing the |
|
194 //failure point in a more complex plugin where it is possible |
|
195 //to fail in the ConstructL stage of the plugin NewL |
|
196 //Create the first plugin |
|
197 impl1 = REINTERPRET_CAST(CExampleInterface*, |
|
198 REComSession::CreateImplementationL(implUid1, |
|
199 returnedUid1, |
|
200 &iInitParams |
|
201 )); |
|
202 //Now start the OOM test when creating the second implementation |
|
203 do |
|
204 { |
|
205 __UHEAP_MARK; |
|
206 // Setting Heap failure for OOM test |
|
207 __UHEAP_SETFAIL(RHeap::EDeterministic, failAt++); |
|
208 CExampleInterface* impl2=NULL; |
|
209 //Create the second implementation |
|
210 TRAP(err,impl2 = REINTERPRET_CAST(CExampleInterface*, |
|
211 REComSession::CreateImplementationL(implUid2, |
|
212 returnedUid2, |
|
213 &iInitParams |
|
214 ))); |
|
215 if (err==KErrNone) |
|
216 { |
|
217 instanceInfo = reinterpret_cast <CInstanceInfoSimple*> (returnedUid2.iUid); |
|
218 TEST(implUid2==instanceInfo->ImplementationUid(), __LINE__); |
|
219 REComSession::DestroyedImplementation(returnedUid2); |
|
220 delete impl2; |
|
221 impl2=NULL; |
|
222 } |
|
223 //CALL FinalClose() HERE!, do not want to leak memory |
|
224 REComSession::FinalClose(); |
|
225 __UHEAP_MARKEND; |
|
226 __UHEAP_SETFAIL(RHeap::ENone, 0); |
|
227 } |
|
228 while (err == KErrNoMemory); |
|
229 |
|
230 REComSession::DestroyedImplementation(returnedUid1); |
|
231 delete impl1; |
|
232 impl1=NULL; |
|
233 //call FinalClose() here, do not want to leak memory |
|
234 REComSession::FinalClose(); |
|
235 __UHEAP_MARKEND; |
|
236 |
|
237 |
|
238 /* |
|
239 ------------Part 4. Two complex implementations in different DLL-------- |
|
240 Plugins used: EComExample2.dll with implUid1=0x10009DC4 |
|
241 EcomRomRslvrExampleOnZ.dll with implUid2=0x10009DC7 |
|
242 //Special case |
|
243 //Implementation with uid 10009DC7 is registered as the implementation in |
|
244 //plugin EComRomRslvrExampleOnZ.DLL however there is no mapping in the |
|
245 //implementaton proxy table that matches this implementation to its NewL |
|
246 //with KErrNotFound(-1) |
|
247 */ |
|
248 TEST.Next(_L("DEF048053 Part 4\n")); |
|
249 __UHEAP_MARK; |
|
250 implUid1=TUid::Uid(0x10009DC4); |
|
251 implUid2=TUid::Uid(0x10009DC7); |
|
252 failAt=1; |
|
253 //Set up initialisation parameters |
|
254 //This initialisation parameters are required for testing the |
|
255 //failure point in a more complex plugin where it is possible |
|
256 //to fail in the ConstructL stage of the plugin NewL |
|
257 //Create the first plugin |
|
258 impl1 = REINTERPRET_CAST(CExampleInterface*, |
|
259 REComSession::CreateImplementationL(implUid1, |
|
260 returnedUid1 |
|
261 )); |
|
262 //Now start the OOM test when creating the second implementation |
|
263 do |
|
264 { |
|
265 __UHEAP_MARK; |
|
266 // Setting Heap failure for OOM test |
|
267 __UHEAP_SETFAIL(RHeap::EDeterministic, failAt++); |
|
268 CExampleInterface* impl2=NULL; |
|
269 //Create the second implementation |
|
270 TRAP(err,impl2 = REINTERPRET_CAST(CExampleInterface*, |
|
271 REComSession::CreateImplementationL(implUid2, |
|
272 returnedUid2, |
|
273 &iInitParams |
|
274 ))); |
|
275 if (err==KErrNone) |
|
276 { |
|
277 instanceInfo = reinterpret_cast <CInstanceInfoSimple*> (returnedUid2.iUid); |
|
278 TEST(implUid2==instanceInfo->ImplementationUid(), __LINE__); |
|
279 REComSession::DestroyedImplementation(returnedUid2); |
|
280 delete impl2; |
|
281 impl2=NULL; |
|
282 } |
|
283 //CALL FinalClose() HERE!, do not want to leak memory |
|
284 REComSession::FinalClose(); |
|
285 __UHEAP_MARKEND; |
|
286 __UHEAP_SETFAIL(RHeap::ENone, 0); |
|
287 } |
|
288 while (err == KErrNoMemory); |
|
289 |
|
290 REComSession::DestroyedImplementation(returnedUid1); |
|
291 delete impl1; |
|
292 impl1=NULL; |
|
293 //call FinalClose() here, do not want to leak memory |
|
294 REComSession::FinalClose(); |
|
295 __UHEAP_MARKEND; |
|
296 |
|
297 /* |
|
298 ------------Part 5. Invalid argument testing in CreateImplementation |
|
299 Test for invalid implementationUid to ensure no leak and proper cleanup |
|
300 */ |
|
301 __UHEAP_MARK; |
|
302 |
|
303 TUid invalidImplUid={0x1111111}; |
|
304 TUid returnedUid; |
|
305 TAny* invalidimpl=NULL; |
|
306 TRAP(err,invalidimpl=REComSession::CreateImplementationL(invalidImplUid,returnedUid)); |
|
307 TEST(err==KErrNotFound, __LINE__); |
|
308 TEST(invalidimpl==NULL, __LINE__); |
|
309 TEST(returnedUid==KNullUid, __LINE__); |
|
310 REComSession::FinalClose(); |
|
311 |
|
312 __UHEAP_MARKEND; |
|
313 |
|
314 } |
|
315 |
|
316 /** |
|
317 Test case for Defect ECom Server only loads Resolvers from Z: Drive |
|
318 |
|
319 @SYMTestCaseID SYSLIB-ECOM-CT-0769 |
|
320 @SYMTestCaseDesc Test case for defect number DEF049979 LoadManager Leaks Memory even when FinalClose is called |
|
321 @SYMTestPriority High |
|
322 @SYMTestActions List all the implemetations once using a UID which reside on C: drive and another on Z: drive |
|
323 @SYMTestExpectedResults The test must not fail. |
|
324 @SYMREQ REQ0000 |
|
325 */ |
|
326 void REcomDefectTest::DEF049979_TestCaseL() |
|
327 { |
|
328 RImplInfoPtrArray ifArray; |
|
329 TEST.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0769 DEF049979_TestCaseL\n ")); |
|
330 |
|
331 _LIT8(KImplementationTest,"text/wml"); |
|
332 // Set up the interface find for the default resolver. |
|
333 TEComResolverParams ResolverParams; |
|
334 ResolverParams.SetDataType(KImplementationTest()); |
|
335 ResolverParams.SetGenericMatch(ETrue); // Allow wildcard matching |
|
336 TUid ifUid = {0x10009DC0}; |
|
337 |
|
338 /* |
|
339 -----Test case 1 ListImplementation using a C resolver---------- |
|
340 */ |
|
341 __UHEAP_MARK; |
|
342 |
|
343 //A resolver uid that only resides in C T_PlatSecResolverC.dll |
|
344 TUid resolverUidC={0x10244444}; |
|
345 |
|
346 |
|
347 REComSession::ListImplementationsL( |
|
348 ifUid, |
|
349 ResolverParams, |
|
350 resolverUidC, |
|
351 ifArray); |
|
352 |
|
353 // There should be 6 implementations found but only 2 returned. |
|
354 // These 2, are the only two that match the datatype supplied. |
|
355 // These 2, are also 2 of a posible 4, i.e. version 2. |
|
356 // The version 1 implementations are not part of the reported 6 |
|
357 // they are superseeded. |
|
358 // So the 2 that match are implementation uids 0x10009DC3 & 0x10009DC4 |
|
359 TInt availCount = ifArray.Count(); |
|
360 TEST(availCount == 2, __LINE__); |
|
361 |
|
362 ifArray.ResetAndDestroy(); |
|
363 |
|
364 /* |
|
365 -----Test case 2 List Implementation using a Z resolver--------- |
|
366 */ |
|
367 //A resolver uid that resides in Z T_PlatSecResolverZ.dll |
|
368 TUid resolverUidZ={0x10999999}; |
|
369 |
|
370 REComSession::ListImplementationsL( |
|
371 ifUid, |
|
372 ResolverParams, |
|
373 resolverUidZ, |
|
374 ifArray); |
|
375 |
|
376 // There should be 6 implementations found but only 2 returned. |
|
377 // These 2, are the only two that match the datatype supplied. |
|
378 // These 2, are also 2 of a posible 4, i.e. version 2. |
|
379 // The version 1 implementations are not part of the reported 6 |
|
380 // they are superseeded. |
|
381 // So the 2 that match are implementation uids 0x10009DC3 & 0x10009DC4 |
|
382 availCount = ifArray.Count(); |
|
383 TEST(availCount == 2, __LINE__); |
|
384 |
|
385 ifArray.ResetAndDestroy(); |
|
386 |
|
387 REComSession::FinalClose(); |
|
388 __UHEAP_MARKEND; |
|
389 |
|
390 } |
|
391 |
|
392 |
|
393 // This class is used for INC057514_TestCaseL. |
|
394 // Checks the reference count when constructing and destructing REComSessions. |
|
395 // |
|
396 class CStuff : public CBase |
|
397 { |
|
398 public: |
|
399 static CStuff* NewL() { |
|
400 CStuff* self = new (ELeave) CStuff; |
|
401 CleanupStack::PushL (self); |
|
402 self->ConstructL(); |
|
403 CleanupStack::Pop (self); |
|
404 return self; |
|
405 } |
|
406 void ConstructL (); |
|
407 ~CStuff(); |
|
408 |
|
409 REComSession iEcomSession; |
|
410 |
|
411 private: |
|
412 CStuff() {/*do nothing*/}; |
|
413 }; |
|
414 |
|
415 void CStuff::ConstructL () |
|
416 { |
|
417 iEcomSession = REComSession::OpenL(); |
|
418 } |
|
419 |
|
420 CStuff::~CStuff() |
|
421 { |
|
422 iEcomSession.Close(); |
|
423 } |
|
424 |
|
425 /** |
|
426 Test case for Defect ECOM can't (reference) count |
|
427 |
|
428 @SYMTestCaseID SYSLIB-ECOM-CT-01364 |
|
429 @SYMTestCaseDesc Test case for defect number INC057514 ECOM can't (reference) count |
|
430 @SYMTestPriority High |
|
431 @SYMTestActions Create 2 implementations |
|
432 Open session with REComSession |
|
433 Close session with REComSession |
|
434 When out of scope destructor for REComSession is called. |
|
435 @SYMTestExpectedResults The test must not fail. |
|
436 @SYMDEF INC057514 |
|
437 */ |
|
438 void REcomDefectTest::INC057514_TestCaseL() |
|
439 { |
|
440 TEST.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-1364 INC057514_TestCaseL ")); |
|
441 |
|
442 // Set up for heap leak checking |
|
443 __UHEAP_MARK; |
|
444 |
|
445 //Check Thread handles leak |
|
446 TInt startProcessHandleCount = 0; |
|
447 TInt startThreadHandleCount = 0; |
|
448 TInt endProcessHandleCount = 0; |
|
449 TInt endThreadHandleCount = 0; |
|
450 |
|
451 RThread rThread; |
|
452 rThread.HandleCount(startProcessHandleCount, startThreadHandleCount); |
|
453 |
|
454 // START TEST // |
|
455 |
|
456 |
|
457 __UHEAP_MARK; |
|
458 |
|
459 CStuff* stuff1 = CStuff::NewL(); |
|
460 CleanupStack::PushL(stuff1); |
|
461 |
|
462 TUid implUid1={0x102026AA}; |
|
463 TUid returnedUid1; |
|
464 TUid returnedUid2; |
|
465 |
|
466 //Create the first implementation |
|
467 TAny* imp1=stuff1->iEcomSession.CreateImplementationL(implUid1,returnedUid1); |
|
468 CInstanceInfoSimple* instanceInfo = reinterpret_cast <CInstanceInfoSimple*> (returnedUid1.iUid); |
|
469 CleanupStack::PushL(imp1); |
|
470 TEST(implUid1==instanceInfo->ImplementationUid(), __LINE__); |
|
471 |
|
472 CStuff* stuff2 = CStuff::NewL(); |
|
473 CleanupStack::PushL(stuff2); |
|
474 |
|
475 //Create the first implementation |
|
476 TAny* imp2=stuff2->iEcomSession.CreateImplementationL(implUid1,returnedUid2); |
|
477 instanceInfo = reinterpret_cast <CInstanceInfoSimple*> (returnedUid2.iUid); |
|
478 CleanupStack::PushL(imp2); |
|
479 TEST(implUid1==instanceInfo->ImplementationUid(), __LINE__); |
|
480 |
|
481 { |
|
482 REComSession session = stuff1->iEcomSession.OpenL(); |
|
483 session.Close(); |
|
484 // When we go out of scope we cause the destructor |
|
485 // to be called for REComSession. |
|
486 } |
|
487 |
|
488 REComSession::DestroyedImplementation(returnedUid1); |
|
489 |
|
490 CleanupStack::PopAndDestroy(imp2); |
|
491 CleanupStack::PopAndDestroy(stuff2); |
|
492 |
|
493 REComSession::FinalClose(); |
|
494 |
|
495 REComSession::DestroyedImplementation(returnedUid2); |
|
496 |
|
497 CleanupStack::PopAndDestroy(imp1); |
|
498 CleanupStack::PopAndDestroy(stuff1); |
|
499 |
|
500 REComSession::FinalClose(); |
|
501 |
|
502 |
|
503 __UHEAP_MARKEND; |
|
504 |
|
505 |
|
506 |
|
507 // END TEST // |
|
508 |
|
509 // Check for open handles |
|
510 rThread.HandleCount(endProcessHandleCount, endThreadHandleCount); |
|
511 TEST(startThreadHandleCount == endThreadHandleCount, __LINE__); |
|
512 |
|
513 //Test ends |
|
514 __UHEAP_MARKEND; |
|
515 } |
|
516 |
|
517 static RSemaphore TheLoadEcomServerSemaphore; |
|
518 |
|
519 static TInt LoadEcomServer(void*) |
|
520 { |
|
521 RThread currThread; |
|
522 const TName& threadName = currThread.Name(); |
|
523 RDebug::Print(_L("Thread %S running\n"), &threadName); |
|
524 |
|
525 //Wait until get a notification from the creating thread that the ECOM server can be loaded. |
|
526 TheLoadEcomServerSemaphore.Wait(); |
|
527 |
|
528 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
529 TEST(cleanup != NULL); |
|
530 |
|
531 //Create ECOM session. This call will try to load the ECOM server. |
|
532 REComSession ecomSession; |
|
533 TRAPD(err, ecomSession.OpenL()); |
|
534 TEST(err==KErrNone); |
|
535 |
|
536 //Wait some time. During that time the ECOM server will try to process the ECOM registry. |
|
537 User::After(3000000); |
|
538 ecomSession.Close(); |
|
539 |
|
540 delete cleanup; |
|
541 RDebug::Print(_L("Thread %S exits\n"), &threadName); |
|
542 return KErrNone; |
|
543 } |
|
544 |
|
545 /** |
|
546 Test case for Defect Multi-threaded client start-up of ECOM server can causeKErrInUse errors |
|
547 |
|
548 @SYMTestCaseID SYSLIB-ECOM-CT-01365 |
|
549 @SYMTestCaseDesc Test case for defect number DEF065025 Multi-threaded client |
|
550 start-up of ECOM server can causeKErrInUse errors |
|
551 @SYMTestPriority High |
|
552 @SYMTestActions Create 16 threads and block. |
|
553 Unblock each thread causing them all to run simultaneously. |
|
554 Each thread opens a session to ECOM Server. |
|
555 Close each session to ECOM Server. |
|
556 Close each thread. |
|
557 @SYMTestExpectedResults The test must not fail. |
|
558 @SYMDEF DEF065025 |
|
559 */ |
|
560 void REcomDefectTest::DEF065025_TestCase() |
|
561 { |
|
562 TEST.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-1365 ")); |
|
563 TInt err=KErrNone; |
|
564 _LIT(KEComServerProcessName,"ecomserver"); |
|
565 TRAP(err, EComTestUtils::KillProcessL(KEComServerProcessName)); |
|
566 UNUSED_VAR(err); |
|
567 |
|
568 const TInt KThreadCnt = 16; |
|
569 err = TheLoadEcomServerSemaphore.CreateLocal(0); |
|
570 TEST(err==KErrNone); |
|
571 |
|
572 RThread loadEcomThread[KThreadCnt]; |
|
573 TRequestStatus threadStatus[KThreadCnt]; |
|
574 TInt i; |
|
575 |
|
576 //Create KThreadCnt threads. They will be blocked on TheLoadEcomServerSemaphore after |
|
577 //their creation. |
|
578 for(i=0;i<KThreadCnt;++i) |
|
579 { |
|
580 TBuf<32> threadName; |
|
581 threadName.Format(_L("Th-%02d"), i + 1); |
|
582 TInt err = loadEcomThread[i].Create(threadName, (TThreadFunction)LoadEcomServer, |
|
583 KDefaultStackSize, KMinHeapSize, 0x00100000, NULL); |
|
584 TEST(err==KErrNone); |
|
585 loadEcomThread[i].Logon(threadStatus[i]); |
|
586 loadEcomThread[i].Resume(); |
|
587 } |
|
588 User::After(3000000); |
|
589 |
|
590 //Unblock the threads. The threads will run simultaneously and will try to load multiple |
|
591 //instances of the ECOM server, which will try to open and process Registry files at the |
|
592 //same time. |
|
593 TheLoadEcomServerSemaphore.Signal(KThreadCnt); |
|
594 |
|
595 //Wait until all threads die. |
|
596 for(i=0;i<KThreadCnt;++i) |
|
597 { |
|
598 User::WaitForRequest(threadStatus[i]); |
|
599 } |
|
600 |
|
601 //Close all threads. |
|
602 for(i=0;i<KThreadCnt;++i) |
|
603 { |
|
604 loadEcomThread[i].Close(); |
|
605 } |
|
606 |
|
607 TheLoadEcomServerSemaphore.Close(); |
|
608 //Put a break point there and kill the test |
|
609 //Check EPOCWIND.OUT file. |
|
610 } |
|
611 /** |
|
612 Copies the Resolver Plugins to C:\ drive |
|
613 */ |
|
614 LOCAL_C void CopyPluginsL() |
|
615 { |
|
616 // Copy the dlls and .rsc files on to RAM |
|
617 TRAPD(err, EComTestUtils::FileManCopyFileL(KEComExDllOnZ, KEComExDllOnC)); |
|
618 TEST(err==KErrNone, __LINE__); |
|
619 TRAP(err, EComTestUtils::FileManCopyFileL(KEComRscFileOnZ, KEComRscFileOnC)); |
|
620 TEST(err==KErrNone, __LINE__); |
|
621 // Wait, so that ECom server looks for plugins copied from Z: to C drive |
|
622 // ECOM server could be already started. It means that when we copy some |
|
623 // ECOM plugins from Z: to C: drive - ECOM server should look for and |
|
624 // find the new ECOM plugins. The ECOM server uses for that CDiscoverer::CIdleScanningTimer |
|
625 // which is an active object. So the discovering service is asynchronous. We have to |
|
626 // wait some time until it finishes. Otherwise ListImplementationsL could fail to find |
|
627 // requested implementations. |
|
628 User::After(5000000); |
|
629 } |
|
630 |
|
631 |
|
632 LOCAL_C void RunTestL() |
|
633 { |
|
634 __UHEAP_MARK; |
|
635 |
|
636 CopyPluginsL(); |
|
637 |
|
638 REcomDefectTest::DEF049285_TestCaseL(); |
|
639 |
|
640 REcomDefectTest::DEF049979_TestCaseL(); |
|
641 |
|
642 REcomDefectTest::INC057514_TestCaseL(); |
|
643 |
|
644 REcomDefectTest::DEF065025_TestCase(); |
|
645 DeleteTestPlugin(); |
|
646 |
|
647 __UHEAP_MARKEND; |
|
648 } |
|
649 |
|
650 GLDEF_C TInt E32Main() |
|
651 { |
|
652 __UHEAP_MARK; |
|
653 |
|
654 TEST.Title(); |
|
655 TEST.Start(_L("Ecom Defect tests.")); |
|
656 |
|
657 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
658 CActiveScheduler* scheduler = new(ELeave)CActiveScheduler; |
|
659 CActiveScheduler::Install(scheduler); |
|
660 |
|
661 TRAPD(err,RunTestL()); |
|
662 TEST(err==KErrNone, __LINE__); |
|
663 |
|
664 delete scheduler; |
|
665 delete cleanup; |
|
666 |
|
667 TEST.End(); |
|
668 TEST.Close(); |
|
669 |
|
670 __UHEAP_MARKEND; |
|
671 return(0); |
|
672 } |