author | Mike Kinghan <mikek@symbian.org> |
Thu, 25 Nov 2010 14:35:45 +0000 | |
branch | GCC_SURGE |
changeset 305 | 1ba12ef4ef89 |
parent 109 | b3a1d9898418 |
child 257 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 2002-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 "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 |
// e32test\secure\t_sobject.cpp |
|
15 |
// Overview: |
|
16 |
// Test the security aspects of the TFind??? (TFindChunk etc.) classes. |
|
17 |
// API Information: |
|
18 |
// TFind??? (TFindChunk, TFindThread etc.) |
|
19 |
// Details: |
|
20 |
// - Test TFindPhysicalDevices and attempt to open the found device. |
|
21 |
// Verify results are as expected. |
|
22 |
// - Test TFindLogicalDevices and attempt to open the found device. |
|
23 |
// Duplicate the object in another thread. Verify results are as expected. |
|
24 |
// - Test TFindLibrary and attempt to open the found device. Verify results |
|
25 |
// are as expected. |
|
26 |
// - Test TFindServer and attempt to open the found server. Test duplication |
|
27 |
// of a named or unnamed server. Verify results are as expected. |
|
28 |
// - Test TFindProcess and attempt to open the found process. Test duplication |
|
29 |
// of the object. Attempt to open the process by name and by id. Verify |
|
30 |
// results are as expected. |
|
31 |
// - Test TFindThread and attempt to open the found thread. Test duplication |
|
32 |
// of the object. Attempt to open the thread in various ways. Verify |
|
33 |
// results are as expected. |
|
34 |
// - Test TFindChunk and attempt to open the found object. Test duplication |
|
35 |
// of the object. Attempt to open the object in various ways. Verify |
|
36 |
// results are as expected. |
|
37 |
// - Test TFindSemaphore and attempt to open the found object. Attempt to |
|
38 |
// open the object in various ways. Test duplication of the object. Verify |
|
39 |
// results are as expected. |
|
40 |
// - Test TFindMutex and attempt to open the found object. Attempt to |
|
41 |
// open the object in various ways. Test duplication of the object. Verify |
|
42 |
// results are as expected. |
|
43 |
// - Create some RMsgQueue objects. Attempt to open the objects in various ways. |
|
44 |
// Test duplication of the objects. Verify results are as expected. |
|
45 |
// - Create some RCondVar objects. Attempt to open the objects in various ways. |
|
46 |
// Test duplication of the objects. Verify results are as expected. |
|
47 |
// - Test passing a handle via IPC: test sending LogicalChannel, Chunk, |
|
48 |
// Semaphore, Mutex, MsgQueue, CondVar and Session handles. Verify results |
|
49 |
// are as expected. |
|
50 |
// Platforms/Drives/Compatibility: |
|
51 |
// All. |
|
52 |
// Assumptions/Requirement/Pre-requisites: |
|
53 |
// Failures and causes: |
|
54 |
// Base Port information: |
|
55 |
// |
|
56 |
// |
|
57 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
58 |
#define __E32TEST_EXTENSION__ |
0 | 59 |
#include <e32test.h> |
60 |
#include <e32msgqueue.h> |
|
61 |
#include <f32file.h> |
|
62 |
#include "d_sldd.h" |
|
63 |
||
64 |
LOCAL_D RTest test(_L("T_SOBJECT")); |
|
65 |
||
66 |
TInt PlatSecProcessIsolationError = 1; |
|
67 |
TInt PlatSecFindError = 1; |
|
68 |
||
69 |
_LIT(KTestMutexName,"T_SOBJECT-test-mutex"); |
|
70 |
_LIT(KTestSemaphoreName,"T_SOBJECT-test-semaphore"); |
|
71 |
_LIT(KTestChunkName,"T_SOBJECT-test-chunk"); |
|
72 |
_LIT(KTestMsgQueueName,"T_SOBJECT-test-msgqueue"); |
|
73 |
_LIT(KTestCondVarName,"T_SOBJECT-test-condvar"); |
|
74 |
||
75 |
TFullName Name; |
|
76 |
TFullName Name2; |
|
77 |
||
78 |
void SetName(RHandleBase a) |
|
79 |
{ |
|
80 |
Name = a.FullName(); |
|
81 |
} |
|
82 |
||
83 |
TBool CheckName(RHandleBase a) |
|
84 |
{ |
|
85 |
Name2 = a.FullName(); |
|
86 |
return Name==Name2; |
|
87 |
} |
|
88 |
||
89 |
class RTestHandle : public RHandleBase |
|
90 |
{ |
|
91 |
public: |
|
92 |
inline TInt Open(const TFindHandleBase& aHandle,TOwnerType aType=EOwnerThread) |
|
93 |
{ return RHandleBase::Open(aHandle,aType); } |
|
94 |
}; |
|
95 |
||
96 |
||
97 |
||
98 |
enum TTestProcessFunctions |
|
99 |
{ |
|
100 |
ETestProcessServer, |
|
101 |
ETestProcessDuplicate, |
|
102 |
ETestProcessOpenThreadById, |
|
103 |
}; |
|
104 |
||
105 |
#include "testprocess.h" |
|
106 |
||
107 |
||
108 |
TThreadId MainThreadId; |
|
109 |
||
110 |
TInt TestThreadDuplicate(TAny* aArg) |
|
111 |
{ |
|
112 |
RHandleBase handle; |
|
113 |
handle.SetHandle((TInt)aArg); |
|
114 |
RThread thread; |
|
115 |
TInt r = thread.Open(MainThreadId); |
|
116 |
if(r!=KErrNone) |
|
117 |
r = 999; |
|
118 |
else |
|
119 |
r = handle.Duplicate(thread); |
|
120 |
thread.Close(); |
|
121 |
return r; |
|
122 |
} |
|
123 |
||
124 |
TInt DuplicateInOtherThread(RHandleBase aHandle) |
|
125 |
{ |
|
126 |
RThread thread; |
|
127 |
TRequestStatus logonStatus; |
|
128 |
thread.Create(_L(""),TestThreadDuplicate,KDefaultStackSize,KDefaultStackSize,KDefaultStackSize,(TAny*)aHandle.Handle()); |
|
129 |
MainThreadId = RThread().Id(); |
|
130 |
thread.Logon(logonStatus); |
|
131 |
thread.Resume(); |
|
132 |
User::WaitForRequest(logonStatus); |
|
133 |
test(thread.ExitType()==EExitKill); |
|
134 |
CLOSE_AND_WAIT(thread); |
|
135 |
return logonStatus.Int(); |
|
136 |
} |
|
137 |
||
138 |
TInt DuplicateInOtherProcess(RHandleBase aHandle) |
|
139 |
{ |
|
140 |
RTestProcess process; |
|
141 |
TRequestStatus logonStatus; |
|
142 |
process.Create(ETestProcessDuplicate,RThread().Id(),aHandle.Handle()); |
|
143 |
process.Logon(logonStatus); |
|
144 |
process.Resume(); |
|
145 |
User::WaitForRequest(logonStatus); |
|
146 |
test(process.ExitType()==EExitKill); |
|
147 |
CLOSE_AND_WAIT(process); |
|
148 |
return logonStatus.Int(); |
|
149 |
} |
|
150 |
||
151 |
TInt OpenThreadByIdInOtherProcess(TThreadId aId) |
|
152 |
{ |
|
153 |
RTestProcess process; |
|
154 |
TRequestStatus logonStatus; |
|
155 |
process.Create(ETestProcessOpenThreadById,aId); |
|
156 |
process.Logon(logonStatus); |
|
157 |
process.Resume(); |
|
158 |
User::WaitForRequest(logonStatus); |
|
159 |
test(process.ExitType()==EExitKill); |
|
160 |
CLOSE_AND_WAIT(process); |
|
161 |
return logonStatus.Int(); |
|
162 |
} |
|
163 |
||
164 |
||
165 |
||
166 |
// |
|
167 |
// RTestSession |
|
168 |
// |
|
169 |
||
170 |
enum TServerName |
|
171 |
{ |
|
172 |
EMainServer,EGlobalSharableServer,EAnonymousServer,ENumServerTypes |
|
173 |
}; |
|
174 |
||
175 |
_LIT(KServerName,"T_SOBJECT-MainServer"); |
|
176 |
_LIT(KServerName2,"T_SOBJECT-GlobalSharableServer"); |
|
177 |
||
178 |
inline const TDesC& ServerName(TServerName aName) |
|
179 |
{ |
|
180 |
switch(aName) |
|
181 |
{ |
|
182 |
case EMainServer: |
|
183 |
return KServerName; |
|
184 |
case EGlobalSharableServer: |
|
185 |
return KServerName2; |
|
186 |
default: |
|
187 |
return KNullDesC; |
|
188 |
} |
|
189 |
} |
|
190 |
||
191 |
class RTestSession : public RSessionBase |
|
192 |
{ |
|
193 |
public: |
|
194 |
inline TInt Connect(TServerName aName=EMainServer) |
|
195 |
{ |
|
196 |
TInt r=CreateSession(ServerName(aName),TVersion()); |
|
197 |
if(r) return r; |
|
198 |
return ShareAuto(); |
|
199 |
} |
|
200 |
inline TInt ConnectProtected(TServerName aName=EMainServer) |
|
201 |
{ |
|
202 |
TInt r=CreateSession(ServerName(aName),TVersion()); |
|
203 |
if(r) return r; |
|
204 |
return ShareProtected(); |
|
205 |
} |
|
206 |
inline TInt Open(RMessagePtr2 aMessage,TInt aParam,TOwnerType aType=EOwnerProcess) |
|
207 |
{ return RSessionBase::Open(aMessage,aParam,aType); } |
|
208 |
inline TInt Open(RMessagePtr2 aMessage,TInt aParam,const TSecurityPolicy& aServerPolicy,TOwnerType aType=EOwnerProcess) |
|
209 |
{ return RSessionBase::Open(aMessage,aParam,aServerPolicy,aType); } |
|
210 |
inline TInt Send(TInt aFunction) |
|
211 |
{ return RSessionBase::SendReceive(aFunction); } |
|
212 |
inline TInt Send(TInt aFunction,const TIpcArgs& aArgs) |
|
213 |
{ return RSessionBase::SendReceive(aFunction,aArgs); } |
|
214 |
inline void Send(TInt aFunction,TRequestStatus& aStatus) |
|
215 |
{ RSessionBase::SendReceive(aFunction,aStatus); } |
|
216 |
inline void Send(TInt aFunction,const TIpcArgs& aArgs,TRequestStatus& aStatus) |
|
217 |
{ RSessionBase::SendReceive(aFunction,aArgs,aStatus); } |
|
218 |
}; |
|
219 |
||
220 |
||
221 |
||
222 |
// |
|
223 |
// CTestSession |
|
224 |
// |
|
225 |
||
226 |
class CTestSession : public CSession2 |
|
227 |
{ |
|
228 |
public: |
|
229 |
enum {EShutdown,EPing,ETestMutex,ETestSemaphore,ETestMsgQueue,ETestCondVar,ETestChunk,ETestChunkAdjust,ETestLdd, |
|
230 |
ETestSession,ETestSession2,ETestSession3,ETestServerDuplicateInThread,ETestServerDuplicateInProcess}; |
|
231 |
public: |
|
232 |
CTestSession(); |
|
233 |
virtual void ServiceL(const RMessage2& aMessage); |
|
234 |
public: |
|
235 |
}; |
|
236 |
||
237 |
CTestSession::CTestSession() |
|
238 |
: CSession2() |
|
239 |
{ |
|
240 |
} |
|
241 |
||
242 |
||
243 |
void CTestSession::ServiceL(const RMessage2& aMessage) |
|
244 |
{ |
|
245 |
RMessagePtr2 m(aMessage); |
|
246 |
TFullName name; |
|
247 |
TInt r = KErrGeneral; |
|
248 |
||
249 |
switch (aMessage.Function()) |
|
250 |
{ |
|
251 |
case CTestSession::EShutdown: |
|
252 |
CActiveScheduler::Stop(); |
|
253 |
break; |
|
254 |
||
255 |
case CTestSession::EPing: |
|
256 |
r=aMessage.Int0(); |
|
257 |
break; |
|
258 |
||
259 |
case CTestSession::ETestMutex: |
|
260 |
{ |
|
261 |
RMutex object; |
|
262 |
||
263 |
r = object.Open(m,0,EOwnerThread); |
|
264 |
if(r!=KErrBadHandle || object.Handle()) |
|
265 |
goto fail; |
|
266 |
||
267 |
r = object.Open(m,1,EOwnerProcess); |
|
268 |
if(r!=KErrNone) |
|
269 |
break; |
|
270 |
name = object.FullName(); |
|
271 |
object.Close(); |
|
272 |
if(name!=KTestMutexName) |
|
273 |
goto fail; |
|
274 |
||
275 |
r = object.Open(m,2,EOwnerThread); |
|
276 |
if(r!=KErrNone) |
|
277 |
break; |
|
278 |
SetName(object); |
|
279 |
m.Read(3,Name2); |
|
280 |
if(Name!=Name2) |
|
281 |
goto fail; |
|
282 |
||
283 |
m.Complete(object); |
|
284 |
object.Close(); |
|
285 |
return; |
|
286 |
} |
|
287 |
||
288 |
case CTestSession::ETestSemaphore: |
|
289 |
{ |
|
290 |
RSemaphore object; |
|
291 |
||
292 |
r = object.Open(m,0,EOwnerThread); |
|
293 |
if(r!=KErrBadHandle || object.Handle()) |
|
294 |
goto fail; |
|
295 |
||
296 |
r = object.Open(m,1,EOwnerProcess); |
|
297 |
if(r!=KErrNone) |
|
298 |
break; |
|
299 |
name = object.FullName(); |
|
300 |
object.Close(); |
|
301 |
if(name!=KTestSemaphoreName) |
|
302 |
goto fail; |
|
303 |
||
304 |
r = object.Open(m,2,EOwnerThread); |
|
305 |
if(r!=KErrNone) |
|
306 |
break; |
|
307 |
SetName(object); |
|
308 |
m.Read(3,Name2); |
|
309 |
if(Name!=Name2) |
|
310 |
goto fail; |
|
311 |
||
312 |
m.Complete(object); |
|
313 |
object.Close(); |
|
314 |
return; |
|
315 |
} |
|
316 |
||
317 |
case CTestSession::ETestMsgQueue: |
|
318 |
{ |
|
319 |
RMsgQueue<TInt> object; |
|
320 |
||
321 |
r = object.Open(m,0,EOwnerThread); |
|
322 |
if(r!=KErrBadHandle || object.Handle()) |
|
323 |
goto fail; |
|
324 |
||
325 |
r = object.Open(m,1,EOwnerProcess); |
|
326 |
if(r!=KErrNone) |
|
327 |
break; |
|
328 |
name = object.FullName(); |
|
329 |
object.Close(); |
|
330 |
if(name!=KTestMsgQueueName) |
|
331 |
goto fail; |
|
332 |
||
333 |
r = object.Open(m,2,EOwnerThread); |
|
334 |
if(r!=KErrNone) |
|
335 |
break; |
|
336 |
SetName(object); |
|
337 |
m.Read(3,Name2); |
|
338 |
if(Name!=Name2) |
|
339 |
goto fail; |
|
340 |
||
341 |
m.Complete(object); |
|
342 |
object.Close(); |
|
343 |
return; |
|
344 |
} |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
345 |
|
0 | 346 |
|
347 |
case CTestSession::ETestCondVar: |
|
348 |
{ |
|
349 |
RCondVar object; |
|
350 |
||
351 |
r = object.Open(m,0,EOwnerThread); |
|
352 |
if(r!=KErrBadHandle || object.Handle()) |
|
353 |
goto fail; |
|
354 |
||
355 |
r = object.Open(m,1,EOwnerProcess); |
|
356 |
if(r!=KErrNone) |
|
357 |
break; |
|
358 |
name = object.FullName(); |
|
359 |
object.Close(); |
|
360 |
if(name!=KTestCondVarName) |
|
361 |
goto fail; |
|
362 |
||
363 |
r = object.Open(m,2,EOwnerThread); |
|
364 |
if(r!=KErrNone) |
|
365 |
break; |
|
366 |
SetName(object); |
|
367 |
m.Read(3,Name2); |
|
368 |
if(Name!=Name2) |
|
369 |
goto fail; |
|
370 |
||
371 |
m.Complete(object); |
|
372 |
object.Close(); |
|
373 |
return; |
|
374 |
} |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
375 |
|
0 | 376 |
|
377 |
case CTestSession::ETestChunk: |
|
378 |
{ |
|
379 |
RChunk object; |
|
380 |
||
381 |
r = object.Open(m,0,EOwnerThread); |
|
382 |
if(r!=KErrBadHandle || object.Handle()) |
|
383 |
goto fail; |
|
384 |
||
385 |
r = object.Open(m,1,EOwnerProcess); |
|
386 |
if(r!=KErrNone) |
|
387 |
break; |
|
388 |
name = object.FullName(); |
|
389 |
object.Close(); |
|
390 |
if(name!=KTestChunkName) |
|
391 |
goto fail; |
|
392 |
||
393 |
r = object.Open(m,2,EOwnerThread); |
|
394 |
if(r!=KErrNone) |
|
395 |
break; |
|
396 |
SetName(object); |
|
397 |
m.Read(3,Name2); |
|
398 |
if(Name!=Name2) |
|
399 |
goto fail; |
|
400 |
||
401 |
m.Complete(object); |
|
402 |
object.Close(); |
|
403 |
return; |
|
404 |
} |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
405 |
|
0 | 406 |
|
407 |
case CTestSession::ETestChunkAdjust: |
|
408 |
{ |
|
409 |
RChunk object; |
|
410 |
r = object.Open(m,0,EOwnerThread); |
|
411 |
if(r==KErrNone) |
|
412 |
r = object.Adjust(0x1000); |
|
413 |
object.Close(); |
|
414 |
} |
|
415 |
break; |
|
416 |
||
417 |
case CTestSession::ETestLdd: |
|
418 |
{ |
|
419 |
RLddTest object; |
|
420 |
r = object.Open(m,0); |
|
421 |
if(r!=KErrBadHandle || object.Handle()) |
|
422 |
goto fail; |
|
423 |
r = object.Open(m,1); |
|
424 |
if(r!=KErrNone) |
|
425 |
break; |
|
426 |
SetName(object); |
|
427 |
m.Read(3,Name2); |
|
428 |
if(Name!=Name2) |
|
429 |
goto fail; |
|
430 |
r = object.Test1(); |
|
431 |
if(r!=aMessage.Int2()) |
|
432 |
goto fail; |
|
433 |
m.Complete(object); |
|
434 |
object.Close(); |
|
435 |
return; |
|
436 |
} |
|
437 |
||
438 |
case CTestSession::ETestSession: |
|
439 |
{ |
|
440 |
RTestSession object; |
|
441 |
r = object.Open(m,0); |
|
442 |
if(r!=KErrBadHandle || object.Handle()) |
|
443 |
goto fail; |
|
444 |
r = object.Open(m,1,TSecurityPolicy(ECapabilityTCB)); |
|
445 |
if(r!=KErrPermissionDenied || object.Handle()) |
|
446 |
goto fail; |
|
447 |
r = object.Open(m,1); |
|
448 |
if(r!=KErrNone) |
|
449 |
break; |
|
450 |
SetName(object); |
|
451 |
m.Read(3,Name2); |
|
452 |
if(Name!=Name2) |
|
453 |
goto fail; |
|
454 |
||
455 |
RFs fs; |
|
456 |
r = fs.Open(m,2,TSecurityPolicy(ECapabilityTCB)); |
|
457 |
if(r!=KErrNone) |
|
458 |
goto fail; |
|
459 |
fs.Close(); |
|
460 |
||
461 |
r=object.Send(CTestSession::EPing,TIpcArgs(234)); |
|
462 |
if(r!=234) |
|
463 |
goto fail; |
|
464 |
||
465 |
m.Complete(object); |
|
466 |
object.Close(); |
|
467 |
return; |
|
468 |
} |
|
469 |
||
470 |
case CTestSession::ETestSession2: |
|
471 |
{ |
|
472 |
RTestSession object; |
|
473 |
object.Connect(EGlobalSharableServer); |
|
474 |
m.Complete(object); |
|
475 |
object.Close(); |
|
476 |
return; |
|
477 |
} |
|
478 |
||
479 |
case CTestSession::ETestSession3: |
|
480 |
{ |
|
481 |
RFs object; |
|
482 |
object.Connect(); |
|
483 |
object.ShareProtected(); |
|
484 |
m.Complete(object); |
|
485 |
object.Close(); |
|
486 |
return; |
|
487 |
} |
|
488 |
||
489 |
case CTestSession::ETestServerDuplicateInThread: |
|
490 |
r = DuplicateInOtherThread(Server()->Server()); |
|
491 |
break; |
|
492 |
||
493 |
case CTestSession::ETestServerDuplicateInProcess: |
|
494 |
r = DuplicateInOtherProcess(Server()->Server()); |
|
495 |
break; |
|
496 |
||
497 |
default: |
|
498 |
m.Complete(KErrNotSupported); |
|
499 |
break; |
|
500 |
} |
|
501 |
m.Complete(r); |
|
502 |
return; |
|
503 |
fail: |
|
504 |
m.Complete(KErrGeneral); |
|
505 |
return; |
|
506 |
} |
|
507 |
||
508 |
RTestSession Session; |
|
509 |
||
510 |
||
511 |
||
512 |
// |
|
513 |
// CTestServer |
|
514 |
// |
|
515 |
||
516 |
class CTestServer : public CServer2 |
|
517 |
{ |
|
518 |
public: |
|
519 |
CTestServer(TInt aPriority,TInt aType=ESharableSessions); |
|
520 |
virtual CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const; |
|
521 |
}; |
|
522 |
||
523 |
CTestServer::CTestServer(TInt aPriority,TInt aType) |
|
524 |
: CServer2(aPriority,(TServerType)aType) |
|
525 |
{ |
|
526 |
} |
|
527 |
||
528 |
CSession2* CTestServer::NewSessionL(const TVersion& /*aVersion*/,const RMessage2& /*aMessage*/) const |
|
529 |
{ |
|
530 |
return new (ELeave) CTestSession(); |
|
531 |
} |
|
532 |
||
533 |
||
534 |
||
535 |
// |
|
536 |
// CTestActiveScheduler |
|
537 |
// |
|
538 |
||
539 |
class CTestActiveScheduler : public CActiveScheduler |
|
540 |
{ |
|
541 |
public: |
|
542 |
virtual void Error(TInt anError) const; |
|
543 |
}; |
|
544 |
||
545 |
void CTestActiveScheduler::Error(TInt anError) const |
|
546 |
{ |
|
547 |
User::Panic(_L("TestServer Error"),anError); |
|
548 |
} |
|
549 |
||
550 |
||
551 |
||
552 |
// |
|
553 |
// Server thread |
|
554 |
// |
|
555 |
||
556 |
const TInt KServerRendezvous = KRequestPending+1; |
|
557 |
||
558 |
RServer2 Servers[ENumServerTypes]; |
|
559 |
||
560 |
void DoStartServer(TServerName aName) |
|
561 |
{ |
|
562 |
CTestActiveScheduler* activeScheduler = new (ELeave) CTestActiveScheduler; |
|
563 |
CActiveScheduler::Install(activeScheduler); |
|
564 |
CleanupStack::PushL(activeScheduler); |
|
565 |
||
566 |
TInt type = 1; // ESharableSessions |
|
567 |
if(aName==EGlobalSharableServer) |
|
568 |
type = 2; // EGlobalSharableSessions; |
|
569 |
CTestServer* server = new (ELeave) CTestServer(0,type); |
|
570 |
CleanupStack::PushL(server); |
|
571 |
||
572 |
User::LeaveIfError(server->Start(ServerName(aName))); |
|
573 |
||
574 |
Servers[aName] = server->Server(); |
|
575 |
RProcess::Rendezvous(KServerRendezvous); |
|
576 |
RThread::Rendezvous(KServerRendezvous); |
|
577 |
||
578 |
CActiveScheduler::Start(); |
|
579 |
||
580 |
Servers[aName].SetHandle(0); |
|
581 |
CleanupStack::PopAndDestroy(2); |
|
582 |
} |
|
583 |
||
584 |
TInt StartServer(TServerName aName) |
|
585 |
{ |
|
586 |
CTrapCleanup* cleanupStack = CTrapCleanup::New(); |
|
587 |
if(!cleanupStack) |
|
588 |
return KErrNoMemory; |
|
589 |
TRAPD(leaveError,DoStartServer(aName)) |
|
590 |
delete cleanupStack; |
|
591 |
return leaveError; |
|
592 |
} |
|
593 |
||
594 |
TInt DoThreadStartServer(TAny* aArg) |
|
595 |
{ |
|
596 |
return StartServer((TServerName)(TInt)aArg); |
|
597 |
} |
|
598 |
||
599 |
TRequestStatus ThrdSvrStat; |
|
600 |
||
601 |
TInt StartServerInThread(TServerName aName) |
|
602 |
{ |
|
603 |
RThread thread; |
|
604 |
TRequestStatus rendezvousStatus; |
|
605 |
thread.Create(_L(""),DoThreadStartServer,KDefaultStackSize,KDefaultStackSize,KDefaultStackSize,(TAny*)aName); |
|
606 |
thread.NotifyDestruction(ThrdSvrStat); |
|
607 |
thread.Rendezvous(rendezvousStatus); |
|
608 |
thread.Resume(); |
|
609 |
User::WaitForRequest(rendezvousStatus); |
|
610 |
thread.Close(); |
|
611 |
if(rendezvousStatus.Int()!=KServerRendezvous) |
|
612 |
return KErrGeneral; |
|
613 |
return KErrNone; |
|
614 |
} |
|
615 |
||
616 |
||
617 |
||
618 |
void TestPhysicalDevices() |
|
619 |
{ |
|
620 |
TFullName name; |
|
621 |
test.Start(_L("Test find named object")); |
|
622 |
TFindPhysicalDevice find(_L("*")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
623 |
test((find.Next(name))==KErrNone); |
0 | 624 |
|
625 |
test.Next(_L("Try open found object")); |
|
626 |
RTestHandle testObject; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
627 |
test((testObject.Open(find))==PlatSecProcessIsolationError); |
0 | 628 |
testObject.Close(); |
629 |
||
630 |
test.End(); |
|
631 |
} |
|
632 |
||
633 |
||
634 |
||
635 |
void TestLogicalDevices() |
|
636 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
637 |
TFullName name; |
0 | 638 |
RDevice device; |
639 |
||
640 |
test.Start(_L("Test find named object")); |
|
641 |
TFindLogicalDevice find(_L("*")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
642 |
test((find.Next(name))==KErrNone); |
0 | 643 |
|
644 |
test.Next(_L("Test open found object")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
645 |
test((device.Open(find))==KErrNone); |
0 | 646 |
|
647 |
test.Next(_L("Test duplicate object in other thread")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
648 |
test((DuplicateInOtherThread(device))==KErrNone); |
0 | 649 |
|
650 |
test.Next(_L("Test duplicate object in other process")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
651 |
test((DuplicateInOtherProcess(device))==KErrNone); |
0 | 652 |
|
653 |
device.Close(); |
|
654 |
||
655 |
test.Next(_L("Test open device by name")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
656 |
test((device.Open(name))==KErrNone); |
0 | 657 |
device.Close(); |
658 |
||
659 |
test.End(); |
|
660 |
} |
|
661 |
||
662 |
||
663 |
||
664 |
void TestLibraries() |
|
665 |
{ |
|
666 |
TFullName name; |
|
667 |
test.Start(_L("Test find named object")); |
|
668 |
TFindLibrary find(_L("*")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
669 |
test((find.Next(name))==KErrNone); |
0 | 670 |
|
671 |
test.Next(_L("Try open found object")); |
|
672 |
RTestHandle testObject; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
673 |
test((testObject.Open(find))==PlatSecProcessIsolationError); |
0 | 674 |
testObject.Close(); |
675 |
||
676 |
test.End(); |
|
677 |
} |
|
678 |
||
679 |
||
680 |
||
681 |
void TestServers() |
|
682 |
{ |
|
683 |
TFullName name; |
|
684 |
RServer2 localObject(Servers[EAnonymousServer]); |
|
685 |
||
686 |
test.Start(_L("Test find named object")); |
|
687 |
TFindServer find(ServerName(EMainServer)); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
688 |
test((find.Next(name))==KErrNone); |
0 | 689 |
|
690 |
test.Next(_L("Try open found object")); |
|
691 |
RTestHandle testObject; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
692 |
test((testObject.Open(find))==KErrPermissionDenied); |
0 | 693 |
|
694 |
test.Next(_L("Test duplicate named server in other thread")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
695 |
test((Session.Send(CTestSession::ETestServerDuplicateInThread))==KErrNone); |
0 | 696 |
|
697 |
test.Next(_L("Try duplicate named server in other process")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
698 |
test((Session.Send(CTestSession::ETestServerDuplicateInProcess))==KErrPermissionDenied); |
0 | 699 |
|
700 |
test.Next(_L("Test duplicate unnamed server in other thread")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
701 |
test((DuplicateInOtherThread(localObject))==KErrNone); |
0 | 702 |
|
703 |
test.Next(_L("Try duplicate unnamed server in other process")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
704 |
test((DuplicateInOtherProcess(localObject))==KErrPermissionDenied); |
0 | 705 |
|
706 |
test.End(); |
|
707 |
} |
|
708 |
||
709 |
||
710 |
||
711 |
void TestProcesses() |
|
712 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
713 |
TFullName name; |
0 | 714 |
RProcess process; |
715 |
||
716 |
test.Start(_L("Test find named object")); |
|
717 |
TFindProcess find(_L("EKern*")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
718 |
test((find.Next(name))==KErrNone); |
0 | 719 |
|
720 |
test.Next(_L("Test open found object")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
721 |
test((process.Open(find))==KErrNone); |
0 | 722 |
|
723 |
test.Next(_L("Test duplicate object in other thread")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
724 |
test((DuplicateInOtherThread(process))==KErrNone); |
0 | 725 |
|
726 |
test.Next(_L("Test duplicate object in other process")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
727 |
test((DuplicateInOtherProcess(process))==KErrNone); |
0 | 728 |
|
729 |
process.Close(); |
|
730 |
||
731 |
test.Next(_L("Test open process by name")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
732 |
test((process.Open(name))==KErrNone); |
0 | 733 |
TProcessId id=process.Id(); |
734 |
process.Close(); |
|
735 |
||
736 |
test.Next(_L("Test open process by id")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
737 |
test((process.Open(id))==KErrNone); |
0 | 738 |
test(name==process.FullName()); |
739 |
process.Close(); |
|
740 |
||
741 |
test.End(); |
|
742 |
} |
|
743 |
||
744 |
||
745 |
||
746 |
void TestThreads() |
|
747 |
{ |
|
748 |
TFullName name; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
749 |
|
0 | 750 |
test.Start(_L("Creating threads")); |
751 |
RThread globalObject; |
|
752 |
RThread localObject; |
|
753 |
RThread testObject; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
754 |
test((globalObject.Create(_L("T_SOBJECT-test-global-thread"),TestThreadDuplicate,KDefaultStackSize,KDefaultStackSize,KDefaultStackSize,NULL))==KErrNone); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
755 |
test((localObject.Create(_L(""),TestThreadDuplicate,KDefaultStackSize,KDefaultStackSize,KDefaultStackSize,NULL))==KErrNone); |
0 | 756 |
|
757 |
test.Next(_L("Test find named thread")); |
|
758 |
TFindThread find(globalObject.FullName()); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
759 |
test((find.Next(name))==KErrNone); |
0 | 760 |
|
761 |
test.Next(_L("Test open found object")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
762 |
test((testObject.Open(find))==KErrNone); |
0 | 763 |
testObject.Close(); |
764 |
||
765 |
test.Next(_L("Check can't find unnamed thread")); |
|
766 |
TName objectName(localObject.FullName()); |
|
767 |
find.Find(objectName); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
768 |
test((find.Next(name))==PlatSecFindError); |
0 | 769 |
|
770 |
test.Next(_L("Test open named thread by name")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
771 |
test((testObject.Open(globalObject.FullName()))==KErrNone); |
0 | 772 |
testObject.Close(); |
773 |
||
774 |
test.Next(_L("Check can't open unnamed thread by name")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
775 |
test((testObject.Open(localObject.FullName()))==PlatSecFindError); |
0 | 776 |
testObject.Close(); |
777 |
||
778 |
test.Next(_L("Check can't open with no name")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
779 |
test((testObject.Open(KNullDesC))==KErrNotFound); |
0 | 780 |
testObject.Close(); |
781 |
||
782 |
test.Next(_L("Test open named thread by id (in same process)")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
783 |
test((testObject.Open(globalObject.Id()))==KErrNone); |
0 | 784 |
testObject.Close(); |
785 |
||
786 |
test.Next(_L("Test open named thread by id (in other process)")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
787 |
test((OpenThreadByIdInOtherProcess(globalObject.Id()))==KErrNone); |
0 | 788 |
|
789 |
test.Next(_L("Test open unnamed thread by id (in same process)")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
790 |
test((testObject.Open(localObject.Id()))==KErrNone); |
0 | 791 |
|
792 |
test.Next(_L("Check can't open unnamed thread by id (in other process)")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
793 |
test((OpenThreadByIdInOtherProcess(localObject.Id()))==PlatSecProcessIsolationError); |
0 | 794 |
|
795 |
test.Next(_L("Test duplicate named thread in other process")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
796 |
test((DuplicateInOtherProcess(globalObject))==KErrNone); |
0 | 797 |
|
798 |
test.Next(_L("Check can't duplicate unnamed thread in other process")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
799 |
test((DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError); |
0 | 800 |
|
801 |
test.Next(_L("Test duplicate named thread in other thread")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
802 |
test((DuplicateInOtherThread(globalObject))==KErrNone); |
0 | 803 |
|
804 |
test.Next(_L("Test duplicate unnamed thread in other thead")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
805 |
test((DuplicateInOtherThread(localObject))==KErrNone); |
0 | 806 |
|
807 |
test.Next(_L("Closing threads")); |
|
808 |
globalObject.Close(); |
|
809 |
localObject.Close(); |
|
810 |
||
811 |
test.End(); |
|
812 |
} |
|
813 |
||
814 |
||
815 |
||
816 |
void TestChunks() |
|
817 |
{ |
|
818 |
TFullName name; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
819 |
|
0 | 820 |
test.Start(_L("Creating chunks")); |
821 |
RChunk globalObject; |
|
822 |
RChunk localObject; |
|
823 |
RChunk testObject; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
824 |
test((globalObject.CreateGlobal(_L("T_SOBJECT-test-global-chunk"),4096,1024*1024))==KErrNone); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
825 |
test((localObject.CreateLocal(4096,1024*1024))==KErrNone); |
0 | 826 |
|
827 |
test.Next(_L("Test find global object")); |
|
828 |
TFindChunk find(globalObject.FullName()); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
829 |
test((find.Next(name))==KErrNone); |
0 | 830 |
|
831 |
test.Next(_L("Test open found object")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
832 |
test((testObject.Open(find))==KErrNone); |
0 | 833 |
testObject.Close(); |
834 |
||
835 |
test.Next(_L("Check can't find local object")); |
|
836 |
TName objectName(localObject.FullName()); |
|
837 |
find.Find(objectName); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
838 |
test((find.Next(name))==PlatSecFindError); |
0 | 839 |
|
840 |
test.Next(_L("Test open with null name")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
841 |
test((testObject.OpenGlobal(KNullDesC,ETrue))==KErrNotFound); |
0 | 842 |
testObject.Close(); |
843 |
||
844 |
test.Next(_L("Test open global object by name")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
845 |
test((testObject.OpenGlobal(globalObject.FullName(),ETrue))==KErrNone); |
0 | 846 |
testObject.Close(); |
847 |
||
848 |
test.Next(_L("Check can't open local object by name")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
849 |
test((testObject.OpenGlobal(localObject.FullName(),ETrue))==PlatSecFindError); |
0 | 850 |
testObject.Close(); |
851 |
||
852 |
test.Next(_L("Test duplicate global object in other process")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
853 |
test((DuplicateInOtherProcess(globalObject))==KErrNone); |
0 | 854 |
|
855 |
test.Next(_L("Check can't duplicate local object in other process")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
856 |
test((DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError); |
0 | 857 |
|
858 |
test.Next(_L("Test duplicate global object in other thread")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
859 |
test((DuplicateInOtherThread(globalObject))==KErrNone); |
0 | 860 |
|
861 |
test.Next(_L("Test duplicate local object in other thead")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
862 |
test((DuplicateInOtherThread(localObject))==KErrNone); |
0 | 863 |
|
864 |
test.Next(_L("Test Chunk protection")); |
|
865 |
{ |
|
866 |
RChunk protectedChunk; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
867 |
test((protectedChunk.CreateGlobal(KNullDesC,0x1000,0x100000,EOwnerProcess))==KErrNone); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
868 |
test((Session.Send(CTestSession::ETestChunkAdjust,TIpcArgs(protectedChunk)))==KErrNone); |
0 | 869 |
protectedChunk.SetRestrictions(RChunk::EPreventAdjust); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
870 |
test((Session.Send(CTestSession::ETestChunkAdjust,TIpcArgs(protectedChunk)))==KErrAccessDenied); |
0 | 871 |
protectedChunk.Close(); |
872 |
} |
|
873 |
||
874 |
test.Next(_L("Closing chunks")); |
|
875 |
globalObject.Close(); |
|
876 |
localObject.Close(); |
|
877 |
||
878 |
test.End(); |
|
879 |
} |
|
880 |
||
881 |
||
882 |
||
883 |
void TestSemaphores() |
|
884 |
{ |
|
885 |
TFullName name; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
886 |
|
0 | 887 |
test.Start(_L("Creating semaphores")); |
888 |
RSemaphore globalObject; |
|
889 |
RSemaphore localObject; |
|
890 |
RSemaphore testObject; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
891 |
test((globalObject.CreateGlobal(_L("T_SOBJECT-test-global-semaphore"),1))==KErrNone); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
892 |
test((localObject.CreateLocal(1))==KErrNone); |
0 | 893 |
|
894 |
test.Next(_L("Test find global object")); |
|
895 |
TFindSemaphore find(globalObject.FullName()); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
896 |
test((find.Next(name))==KErrNone); |
0 | 897 |
|
898 |
test.Next(_L("Test open found object")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
899 |
test((testObject.Open(find))==KErrNone); |
0 | 900 |
testObject.Close(); |
901 |
||
902 |
test.Next(_L("Check can't find local object")); |
|
903 |
TName objectName(localObject.FullName()); |
|
904 |
find.Find(objectName); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
905 |
test((find.Next(name))==PlatSecFindError); |
0 | 906 |
|
907 |
test.Next(_L("Test open with null name")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
908 |
test((testObject.OpenGlobal(KNullDesC))==KErrNotFound); |
0 | 909 |
testObject.Close(); |
910 |
||
911 |
test.Next(_L("Test open global object by name")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
912 |
test((testObject.OpenGlobal(globalObject.FullName()))==KErrNone); |
0 | 913 |
testObject.Close(); |
914 |
||
915 |
test.Next(_L("Check can't open local object by name")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
916 |
test((testObject.OpenGlobal(localObject.FullName()))==PlatSecFindError); |
0 | 917 |
testObject.Close(); |
918 |
||
919 |
test.Next(_L("Test duplicate global object in other process")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
920 |
test((DuplicateInOtherProcess(globalObject))==KErrNone); |
0 | 921 |
|
922 |
test.Next(_L("Check can't duplicate local object in other process")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
923 |
test((DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError); |
0 | 924 |
|
925 |
test.Next(_L("Test duplicate global object in other thread")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
926 |
test((DuplicateInOtherThread(globalObject))==KErrNone); |
0 | 927 |
|
928 |
test.Next(_L("Test duplicate local object in other thead")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
929 |
test((DuplicateInOtherThread(localObject))==KErrNone); |
0 | 930 |
|
931 |
test.Next(_L("Closing Semaphores")); |
|
932 |
globalObject.Close(); |
|
933 |
localObject.Close(); |
|
934 |
||
935 |
test.End(); |
|
936 |
} |
|
937 |
||
938 |
||
939 |
||
940 |
void TestMutexes() |
|
941 |
{ |
|
942 |
TFullName name; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
943 |
|
0 | 944 |
test.Start(_L("Creating mutexes")); |
945 |
RMutex globalObject; |
|
946 |
RMutex localObject; |
|
947 |
RMutex testObject; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
948 |
test((globalObject.CreateGlobal(_L("T_SOBJECT-test-global-mutex")))==KErrNone); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
949 |
test((localObject.CreateLocal())==KErrNone); |
0 | 950 |
|
951 |
test.Next(_L("Test find global object")); |
|
952 |
TFindMutex find(globalObject.FullName()); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
953 |
test((find.Next(name))==KErrNone); |
0 | 954 |
|
955 |
test.Next(_L("Test open found object")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
956 |
test((testObject.Open(find))==KErrNone); |
0 | 957 |
testObject.Close(); |
958 |
||
959 |
test.Next(_L("Check can't find local object")); |
|
960 |
TName objectName(localObject.FullName()); |
|
961 |
find.Find(objectName); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
962 |
test((find.Next(name))==PlatSecFindError); |
0 | 963 |
|
964 |
test.Next(_L("Test open with null name")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
965 |
test((testObject.OpenGlobal(KNullDesC))==KErrNotFound); |
0 | 966 |
testObject.Close(); |
967 |
||
968 |
test.Next(_L("Test open global object by name")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
969 |
test((testObject.OpenGlobal(globalObject.FullName()))==KErrNone); |
0 | 970 |
testObject.Close(); |
971 |
||
972 |
test.Next(_L("Check can't open local object by name")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
973 |
test((testObject.OpenGlobal(localObject.FullName()))==PlatSecFindError); |
0 | 974 |
testObject.Close(); |
975 |
||
976 |
test.Next(_L("Test duplicate global object in other process")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
977 |
test((DuplicateInOtherProcess(globalObject))==KErrNone); |
0 | 978 |
|
979 |
test.Next(_L("Check can't duplicate local object in other process")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
980 |
test((DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError); |
0 | 981 |
|
982 |
test.Next(_L("Test duplicate global object in other thread")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
983 |
test((DuplicateInOtherThread(globalObject))==KErrNone); |
0 | 984 |
|
985 |
test.Next(_L("Test duplicate local object in other thead")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
986 |
test((DuplicateInOtherThread(localObject))==KErrNone); |
0 | 987 |
|
988 |
test.Next(_L("Closing mutexes")); |
|
989 |
globalObject.Close(); |
|
990 |
localObject.Close(); |
|
991 |
||
992 |
test.End(); |
|
993 |
} |
|
994 |
||
995 |
||
996 |
||
997 |
void TestMessageQueues() |
|
998 |
{ |
|
999 |
test.Start(_L("Creating message queues")); |
|
1000 |
RMsgQueue<TInt> globalObject; |
|
1001 |
RMsgQueue<TInt> localObject; |
|
1002 |
RMsgQueue<TInt> testObject; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1003 |
test((globalObject.CreateGlobal(_L("T_SOBJECT-test-global-msgqueue"),1))==KErrNone); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1004 |
test((localObject.CreateLocal(1))==KErrNone); |
0 | 1005 |
|
1006 |
test.Next(_L("Test open with null name")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1007 |
test((testObject.OpenGlobal(KNullDesC))==KErrNotFound); |
0 | 1008 |
testObject.Close(); |
1009 |
||
1010 |
test.Next(_L("Test open global object by name")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1011 |
test((testObject.OpenGlobal(globalObject.FullName()))==KErrNone); |
0 | 1012 |
testObject.Close(); |
1013 |
||
1014 |
test.Next(_L("Check can't open local object by name")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1015 |
test((testObject.OpenGlobal(localObject.FullName()))==PlatSecFindError); |
0 | 1016 |
testObject.Close(); |
1017 |
||
1018 |
test.Next(_L("Test duplicate global object in other process")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1019 |
test((DuplicateInOtherProcess(globalObject))==KErrNone); |
0 | 1020 |
|
1021 |
test.Next(_L("Check can't duplicate local object in other process")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1022 |
test((DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError); |
0 | 1023 |
|
1024 |
test.Next(_L("Test duplicate global object in other thread")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1025 |
test((DuplicateInOtherThread(globalObject))==KErrNone); |
0 | 1026 |
|
1027 |
test.Next(_L("Test duplicate local object in other thead")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1028 |
test((DuplicateInOtherThread(localObject))==KErrNone); |
0 | 1029 |
|
1030 |
test.Next(_L("Closing message queues")); |
|
1031 |
globalObject.Close(); |
|
1032 |
localObject.Close(); |
|
1033 |
||
1034 |
test.End(); |
|
1035 |
} |
|
1036 |
||
1037 |
||
1038 |
||
1039 |
void TestConditionVariables() |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1040 |
{ |
0 | 1041 |
test.Start(_L("Creating condition variables")); |
1042 |
RCondVar globalObject; |
|
1043 |
RCondVar localObject; |
|
1044 |
RCondVar testObject; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1045 |
test((globalObject.CreateGlobal(_L("T_SOBJECT-test-global-condvar")))==KErrNone); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1046 |
test((localObject.CreateLocal())==KErrNone); |
0 | 1047 |
|
1048 |
test.Next(_L("Test open with null name")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1049 |
test((testObject.OpenGlobal(KNullDesC))==KErrNotFound); |
0 | 1050 |
testObject.Close(); |
1051 |
||
1052 |
test.Next(_L("Test open global object by name")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1053 |
test((testObject.OpenGlobal(globalObject.FullName()))==KErrNone); |
0 | 1054 |
testObject.Close(); |
1055 |
||
1056 |
test.Next(_L("Check can't open local object by name")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1057 |
test((testObject.OpenGlobal(localObject.FullName()))==PlatSecFindError); |
0 | 1058 |
testObject.Close(); |
1059 |
||
1060 |
test.Next(_L("Test duplicate global object in other process")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1061 |
test((DuplicateInOtherProcess(globalObject))==KErrNone); |
0 | 1062 |
|
1063 |
test.Next(_L("Check can't duplicate local object in other process")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1064 |
test((DuplicateInOtherProcess(localObject))==PlatSecProcessIsolationError); |
0 | 1065 |
|
1066 |
test.Next(_L("Test duplicate global object in other thread")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1067 |
test((DuplicateInOtherThread(globalObject))==KErrNone); |
0 | 1068 |
|
1069 |
test.Next(_L("Test duplicate local object in other thead")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1070 |
test((DuplicateInOtherThread(localObject))==KErrNone); |
0 | 1071 |
|
1072 |
test.Next(_L("Closing message queues")); |
|
1073 |
globalObject.Close(); |
|
1074 |
localObject.Close(); |
|
1075 |
||
1076 |
test.End(); |
|
1077 |
} |
|
1078 |
||
1079 |
||
1080 |
||
1081 |
void TestIPCHandles() |
|
1082 |
{ |
|
1083 |
RTestProcess server; |
|
1084 |
TRequestStatus rendezvous; |
|
1085 |
TInt r; |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1086 |
|
0 | 1087 |
test.Next(_L("Test sending LogicalChannel handles")); |
1088 |
{ |
|
1089 |
RLddTest localLdd; |
|
1090 |
RLddTest protectedLdd; |
|
1091 |
RLddTest returnLdd; |
|
1092 |
r=User::LoadLogicalDevice(_L("D_SLDD.LDD")); |
|
1093 |
test(r==KErrNone || r==KErrAlreadyExists); |
|
1094 |
r=localLdd.OpenLocal(); |
|
1095 |
test(r==KErrNone); |
|
1096 |
r=protectedLdd.OpenProtected(); |
|
1097 |
test(r==KErrNone); |
|
1098 |
TInt lddValue=protectedLdd.Test1(); |
|
1099 |
test(lddValue==RLddTest::ETest1Value); |
|
1100 |
SetName(protectedLdd); |
|
1101 |
r = Session.Send(CTestSession::ETestLdd,TIpcArgs(localLdd,protectedLdd,lddValue,&Name)); |
|
1102 |
r = returnLdd.SetReturnedHandle(r); |
|
1103 |
test(r==KErrNone); |
|
1104 |
test(CheckName(returnLdd)); |
|
1105 |
protectedLdd.Close(); |
|
1106 |
returnLdd.Close(); |
|
1107 |
localLdd.Close(); |
|
1108 |
} |
|
1109 |
||
1110 |
test.Next(_L("Test sending Chunk handles")); |
|
1111 |
{ |
|
1112 |
RChunk localChunk; |
|
1113 |
RChunk globalChunk; |
|
1114 |
RChunk protectedChunk; |
|
1115 |
RChunk returnChunk; |
|
1116 |
test((r=localChunk.CreateLocal(0x1000,0x100000,EOwnerThread))==KErrNone); |
|
1117 |
test((r=globalChunk.CreateGlobal(KTestChunkName,0x1000,0x100000,EOwnerProcess))==KErrNone); |
|
1118 |
test((r=protectedChunk.CreateGlobal(KNullDesC,0x1000,0x100000,EOwnerProcess))==KErrNone); |
|
1119 |
SetName(protectedChunk); |
|
1120 |
r = Session.Send(CTestSession::ETestChunk,TIpcArgs(localChunk,globalChunk,protectedChunk,&Name)); |
|
1121 |
r = returnChunk.SetReturnedHandle(r); |
|
1122 |
test(r==KErrNone); |
|
1123 |
test(CheckName(returnChunk)); |
|
1124 |
returnChunk.Close(); |
|
1125 |
protectedChunk.Close(); |
|
1126 |
globalChunk.Close(); |
|
1127 |
localChunk.Close(); |
|
1128 |
} |
|
1129 |
||
1130 |
test.Next(_L("Test sending Semaphore handles")); |
|
1131 |
{ |
|
1132 |
RSemaphore localSemaphore; |
|
1133 |
RSemaphore globalSemaphore; |
|
1134 |
RSemaphore protectedSemaphore; |
|
1135 |
RSemaphore returnSemaphore; |
|
1136 |
test((r=localSemaphore.CreateLocal(1,EOwnerThread))==KErrNone); |
|
1137 |
test((r=globalSemaphore.CreateGlobal(KTestSemaphoreName,1,EOwnerProcess))==KErrNone); |
|
1138 |
test((r=protectedSemaphore.CreateGlobal(KNullDesC,1,EOwnerProcess))==KErrNone); |
|
1139 |
SetName(protectedSemaphore); |
|
1140 |
r = Session.Send(CTestSession::ETestSemaphore,TIpcArgs(localSemaphore,globalSemaphore,protectedSemaphore,&Name)); |
|
1141 |
r = returnSemaphore.SetReturnedHandle(r); |
|
1142 |
test(r==KErrNone); |
|
1143 |
test(CheckName(returnSemaphore)); |
|
1144 |
returnSemaphore.Close(); |
|
1145 |
protectedSemaphore.Close(); |
|
1146 |
globalSemaphore.Close(); |
|
1147 |
localSemaphore.Close(); |
|
1148 |
} |
|
1149 |
||
1150 |
test.Next(_L("Test sending Mutex handles")); |
|
1151 |
{ |
|
1152 |
RMutex localMutex; |
|
1153 |
RMutex globalMutex; |
|
1154 |
RMutex protectedMutex; |
|
1155 |
RMutex returnMutex; |
|
1156 |
test((r=localMutex.CreateLocal(EOwnerThread))==KErrNone); |
|
1157 |
test((r=globalMutex.CreateGlobal(KTestMutexName,EOwnerProcess))==KErrNone); |
|
1158 |
test((r=protectedMutex.CreateGlobal(KNullDesC,EOwnerProcess))==KErrNone); |
|
1159 |
SetName(protectedMutex); |
|
1160 |
r = Session.Send(CTestSession::ETestMutex,TIpcArgs(localMutex,globalMutex,protectedMutex,&Name)); |
|
1161 |
r = returnMutex.SetReturnedHandle(r); |
|
1162 |
test(r==KErrNone); |
|
1163 |
test(CheckName(returnMutex)); |
|
1164 |
returnMutex.Close(); |
|
1165 |
protectedMutex.Close(); |
|
1166 |
globalMutex.Close(); |
|
1167 |
localMutex.Close(); |
|
1168 |
} |
|
1169 |
||
1170 |
test.Next(_L("Test sending MsgQueue handles")); |
|
1171 |
{ |
|
1172 |
RMsgQueue<TInt> localMsgQueue; |
|
1173 |
RMsgQueue<TInt> globalMsgQueue; |
|
1174 |
RMsgQueue<TInt> protectedMsgQueue; |
|
1175 |
RMsgQueue<TInt> returnMsgQueue; |
|
1176 |
test((r=localMsgQueue.CreateLocal(1,EOwnerThread))==KErrNone); |
|
1177 |
test((r=globalMsgQueue.CreateGlobal(KTestMsgQueueName,1,EOwnerProcess))==KErrNone); |
|
1178 |
test((r=protectedMsgQueue.CreateGlobal(KNullDesC,1,EOwnerProcess))==KErrNone); |
|
1179 |
SetName(protectedMsgQueue); |
|
1180 |
r = Session.Send(CTestSession::ETestMsgQueue,TIpcArgs(localMsgQueue,globalMsgQueue,protectedMsgQueue,&Name)); |
|
1181 |
r = returnMsgQueue.SetReturnedHandle(r); |
|
1182 |
test(r==KErrNone); |
|
1183 |
test(CheckName(returnMsgQueue)); |
|
1184 |
returnMsgQueue.Close(); |
|
1185 |
protectedMsgQueue.Close(); |
|
1186 |
globalMsgQueue.Close(); |
|
1187 |
localMsgQueue.Close(); |
|
1188 |
} |
|
1189 |
||
1190 |
test.Next(_L("Test sending CondVar handles")); |
|
1191 |
{ |
|
1192 |
RCondVar localCondVar; |
|
1193 |
RCondVar globalCondVar; |
|
1194 |
RCondVar protectedCondVar; |
|
1195 |
RCondVar returnCondVar; |
|
1196 |
test((r=localCondVar.CreateLocal(EOwnerThread))==KErrNone); |
|
1197 |
test((r=globalCondVar.CreateGlobal(KTestCondVarName,EOwnerProcess))==KErrNone); |
|
1198 |
test((r=protectedCondVar.CreateGlobal(KNullDesC,EOwnerProcess))==KErrNone); |
|
1199 |
SetName(protectedCondVar); |
|
1200 |
r = Session.Send(CTestSession::ETestCondVar,TIpcArgs(localCondVar,globalCondVar,protectedCondVar,&Name)); |
|
1201 |
r = returnCondVar.SetReturnedHandle(r); |
|
1202 |
test(r==KErrNone); |
|
1203 |
test(CheckName(returnCondVar)); |
|
1204 |
returnCondVar.Close(); |
|
1205 |
protectedCondVar.Close(); |
|
1206 |
globalCondVar.Close(); |
|
1207 |
localCondVar.Close(); |
|
1208 |
} |
|
1209 |
||
1210 |
test.Start(_L("Starting test server 2")); |
|
1211 |
server.Create(ETestProcessServer,EGlobalSharableServer); |
|
1212 |
server.Rendezvous(rendezvous); |
|
1213 |
server.Resume(); |
|
1214 |
User::WaitForRequest(rendezvous); |
|
1215 |
test(rendezvous==KServerRendezvous); |
|
1216 |
server.Close(); |
|
1217 |
||
1218 |
test.Next(_L("Test sending Session handles")); |
|
1219 |
{ |
|
1220 |
RTestSession localSession; |
|
1221 |
RTestSession protectedSession; |
|
1222 |
RTestSession returnSession; |
|
1223 |
RFs fsSession; |
|
1224 |
test((r=localSession.Connect(EGlobalSharableServer))==KErrNone); |
|
1225 |
test((r=localSession.Send(CTestSession::EPing,TIpcArgs(123)))==123); |
|
1226 |
test((r=protectedSession.ConnectProtected(EGlobalSharableServer))==KErrNone); |
|
1227 |
test((r=protectedSession.Send(CTestSession::EPing,TIpcArgs(123)))==123); |
|
1228 |
test((r=fsSession.Connect())==KErrNone); |
|
1229 |
test((r=fsSession.ShareProtected())==KErrNone); |
|
1230 |
SetName(protectedSession); |
|
1231 |
r = Session.Send(CTestSession::ETestSession,TIpcArgs(localSession,protectedSession,fsSession,&Name)); |
|
1232 |
r = returnSession.SetReturnedHandle(r); |
|
1233 |
test(r==KErrNone); |
|
1234 |
test(CheckName(returnSession)); |
|
1235 |
returnSession.Close(); |
|
1236 |
protectedSession.Close(); |
|
1237 |
localSession.Close(); |
|
1238 |
fsSession.Close(); |
|
1239 |
} |
|
1240 |
||
1241 |
test.Next(_L("Test receiving Session handles")); |
|
1242 |
{ |
|
1243 |
RTestSession returnSession; |
|
1244 |
r = Session.Send(CTestSession::ETestSession2); |
|
1245 |
r = returnSession.SetReturnedHandle(r); |
|
1246 |
test(r==KErrNone); |
|
1247 |
test((r=Session.Send(CTestSession::EPing,TIpcArgs(123)))==123); // So we know server has closed returnedSession |
|
1248 |
test((r=returnSession.Send(CTestSession::EPing,TIpcArgs(123)))==123); |
|
1249 |
returnSession.Close(); |
|
1250 |
RFs returnFsSession; |
|
1251 |
r = Session.Send(CTestSession::ETestSession3); |
|
1252 |
r = returnSession.SetReturnedHandle(r,TSecurityPolicy(TSecureId(0x100039e3))); // f32 sid |
|
1253 |
test(r==KErrNone); |
|
1254 |
returnFsSession.Close(); |
|
1255 |
} |
|
1256 |
||
1257 |
test.Next(_L("Try global sharing of Sessions without server support")); |
|
1258 |
{ |
|
1259 |
RTestSession protectedSession; |
|
1260 |
test((r=protectedSession.ConnectProtected(EMainServer))==KErrPermissionDenied); |
|
1261 |
} |
|
1262 |
||
1263 |
test.Next(_L("Stopping test server 2")); |
|
1264 |
{ |
|
1265 |
RTestSession session; |
|
1266 |
test((r=session.Connect(EGlobalSharableServer))==KErrNone); |
|
1267 |
session.Send(CTestSession::EShutdown); |
|
1268 |
session.Close(); |
|
1269 |
} |
|
1270 |
||
1271 |
test.End(); |
|
1272 |
} |
|
1273 |
||
1274 |
// Test uniqness of object names is enforced by DObjectCon when creating objects |
|
1275 |
void TestObjectNames() |
|
1276 |
{ |
|
1277 |
_LIT(KNameFormat, "TestObject-%d"); |
|
1278 |
const TInt KObjectCount = 10; |
|
1279 |
RMutex objects[KObjectCount]; |
|
1280 |
||
1281 |
test.Start(_L("Test uniqueness of object names")); |
|
1282 |
||
1283 |
// Test creating named and unnamed objects is ok |
|
1284 |
TInt i; |
|
1285 |
for (i = 0 ; i < KObjectCount ; ++i) |
|
1286 |
{ |
|
1287 |
if (i % 2) |
|
1288 |
test(objects[i].CreateLocal() == KErrNone); |
|
1289 |
else |
|
1290 |
{ |
|
1291 |
TBuf<16> name; |
|
1292 |
name.AppendFormat(KNameFormat, i); |
|
1293 |
test(objects[i].CreateGlobal(name) == KErrNone); |
|
1294 |
} |
|
1295 |
} |
|
1296 |
||
1297 |
// Test we cannot create objects with duplicate names |
|
1298 |
for (i = 0 ; i < KObjectCount ; i+=2) |
|
1299 |
{ |
|
1300 |
TBuf<16> name; |
|
1301 |
name.AppendFormat(KNameFormat, i); |
|
1302 |
test(objects[i].CreateGlobal(name) == KErrAlreadyExists); |
|
1303 |
} |
|
1304 |
||
1305 |
// Close all objects |
|
1306 |
for (i = 0 ; i < KObjectCount ; ++i) |
|
1307 |
{ |
|
1308 |
objects[i].Close(); |
|
1309 |
} |
|
1310 |
||
1311 |
test.End(); |
|
1312 |
} |
|
1313 |
||
1314 |
||
1315 |
TInt DoTestProcess(TInt aTestNum,TInt aArg1,TInt aArg2) |
|
1316 |
{ |
|
1317 |
TInt r; |
|
1318 |
||
1319 |
switch(aTestNum) |
|
1320 |
{ |
|
1321 |
||
1322 |
case ETestProcessServer: |
|
1323 |
return StartServer((TServerName)aArg1); |
|
1324 |
||
1325 |
case ETestProcessDuplicate: |
|
1326 |
{ |
|
1327 |
RHandleBase handle; |
|
1328 |
handle.SetHandle(aArg2); |
|
1329 |
RThread thread; |
|
1330 |
r = thread.Open(TThreadId(aArg1)); |
|
1331 |
if(r!=KErrNone) |
|
1332 |
r = 999; |
|
1333 |
else |
|
1334 |
r = handle.Duplicate(thread); |
|
1335 |
thread.Close(); |
|
1336 |
} |
|
1337 |
return r; |
|
1338 |
||
1339 |
case ETestProcessOpenThreadById: |
|
1340 |
{ |
|
1341 |
RThread thread; |
|
1342 |
r = thread.Open(TThreadId(aArg1)); |
|
1343 |
if(r==KErrNone) |
|
1344 |
thread.Close(); |
|
1345 |
} |
|
1346 |
return r; |
|
1347 |
||
1348 |
||
1349 |
default: |
|
1350 |
User::Panic(_L("T_SOBJECT"),1); |
|
1351 |
} |
|
1352 |
||
1353 |
return KErrNone; |
|
1354 |
} |
|
1355 |
||
1356 |
||
1357 |
GLDEF_C TInt E32Main() |
|
1358 |
{ |
|
1359 |
PlatSecProcessIsolationError = PlatSec::ConfigSetting(PlatSec::EPlatSecProcessIsolation)&&PlatSec::ConfigSetting(PlatSec::EPlatSecEnforcement) |
|
1360 |
? KErrPermissionDenied : KErrNone; |
|
1361 |
PlatSecFindError = PlatSec::ConfigSetting(PlatSec::EPlatSecProcessIsolation) |
|
1362 |
? KErrNotFound : KErrNone; |
|
1363 |
||
1364 |
TBuf16<512> cmd; |
|
1365 |
User::CommandLine(cmd); |
|
1366 |
if(cmd.Length() && TChar(cmd[0]).IsDigit()) |
|
1367 |
{ |
|
1368 |
TInt function = -1; |
|
1369 |
TInt arg1 = -1; |
|
1370 |
TInt arg2 = -1; |
|
1371 |
TLex lex(cmd); |
|
1372 |
lex.Val(function); |
|
1373 |
lex.SkipSpace(); |
|
1374 |
lex.Val(arg1); |
|
1375 |
lex.SkipSpace(); |
|
1376 |
lex.Val(arg2); |
|
1377 |
return DoTestProcess(function,arg1,arg2); |
|
1378 |
} |
|
1379 |
||
1380 |
||
1381 |
test.Title(); |
|
1382 |
||
1383 |
test.Start(_L("Starting test servers")); |
|
1384 |
RTestProcess server; |
|
1385 |
TRequestStatus rendezvous; |
|
1386 |
TRequestStatus svrstat; |
|
1387 |
server.Create(ETestProcessServer,EMainServer); |
|
1388 |
server.NotifyDestruction(svrstat); |
|
1389 |
server.Rendezvous(rendezvous); |
|
1390 |
server.Resume(); |
|
1391 |
User::WaitForRequest(rendezvous); |
|
1392 |
test(rendezvous==KServerRendezvous); |
|
1393 |
server.Close(); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1394 |
test((StartServerInThread(EAnonymousServer))==KErrNone); |
0 | 1395 |
|
1396 |
test.Next(_L("Openning server session")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1397 |
test((Session.Connect())==KErrNone); |
0 | 1398 |
|
1399 |
test.Next(_L("Test Find and Open PhysicalDevices")); |
|
1400 |
TestPhysicalDevices(); |
|
1401 |
||
1402 |
test.Next(_L("Test Find and Open LogicalDevices")); |
|
1403 |
TestLogicalDevices(); |
|
1404 |
||
1405 |
test.Next(_L("Test Find and Open Libraries")); |
|
1406 |
TestLibraries(); |
|
1407 |
||
1408 |
test.Next(_L("Test Find and Open Servers")); |
|
1409 |
TestServers(); |
|
1410 |
||
1411 |
test.Next(_L("Test Find and Open Processes")); |
|
1412 |
TestProcesses(); |
|
1413 |
||
1414 |
test.Next(_L("Test Find and Open Threads")); |
|
1415 |
TestThreads(); |
|
1416 |
||
1417 |
test.Next(_L("Test Find and Open Chunks")); |
|
1418 |
TestChunks(); |
|
1419 |
||
1420 |
test.Next(_L("Test Find and Open Semaphores")); |
|
1421 |
TestSemaphores(); |
|
1422 |
||
1423 |
test.Next(_L("Test Find and Open Mutexes")); |
|
1424 |
TestMutexes(); |
|
1425 |
||
1426 |
test.Next(_L("Test Message Queues")); |
|
1427 |
TestMessageQueues(); |
|
1428 |
||
1429 |
test.Next(_L("Test Condition Variables")); |
|
1430 |
TestConditionVariables(); |
|
1431 |
||
1432 |
test.Next(_L("Test passing handle via IPC")); |
|
1433 |
TestIPCHandles(); |
|
1434 |
||
1435 |
test.Next(_L("Test object names")); |
|
1436 |
TestObjectNames(); |
|
1437 |
||
1438 |
test.Next(_L("Stopping test server")); |
|
1439 |
Session.Send(CTestSession::EShutdown); |
|
1440 |
Session.Close(); |
|
1441 |
User::WaitForRequest(svrstat); |
|
1442 |
test(svrstat == KErrNone); |
|
1443 |
||
1444 |
test.End(); |
|
1445 |
||
1446 |
return(0); |
|
1447 |
} |
|
1448 |