author | Mike Kinghan <mikek@symbian.org> |
Thu, 25 Nov 2010 14:35:45 +0000 | |
branch | GCC_SURGE |
changeset 305 | 1ba12ef4ef89 |
parent 200 | 73ea206103e6 |
child 271 | dc268b18d709 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1995-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\active\t_messge.cpp |
|
15 |
// Overview: |
|
16 |
// Test the RMessage2 and RMessagePtr2 classes. |
|
17 |
// API Information: |
|
18 |
// RMessage2, RMessagePtr2, RSessionBase, CSession2, CServer2 |
|
19 |
// Details: |
|
20 |
// - Verify copy constructor and assignment operator of Rmessage2 is implemented correctly. |
|
21 |
// - Verify default constructor, copy constructor and assignment operator of RMessagePtr2 |
|
22 |
// is implemented correctly, construct RMessagePtr2 from pointer to RMessage2 and verify |
|
23 |
// that it is constructed successfully. |
|
24 |
// - Create client and server threads, open a session with specified number of message slots |
|
25 |
// - Send integer message arguments from client and test that the server receives the |
|
26 |
// same integers. |
|
27 |
// - Send pointers as message arguments from client and test that the server receives the |
|
28 |
// same pointers. |
|
29 |
// - Test Client() method of RMessage2 and verify it opened a handle to the client thread |
|
30 |
// - Complete several messages using RMessage2::Complete and verify the client gets the |
|
31 |
// error codes back correctly. |
|
32 |
// - Complete several messages using RMessagePtr2::Complete and verify the client gets the |
|
33 |
// error codes back correctly. |
|
34 |
// - Check RMessage construction from RMessagePtr2 is successful. |
|
35 |
// - Check creation of other sessions to the same server is successful. |
|
36 |
// - Check the server return KErrServerBusy when client has more outstanding requests than |
|
37 |
// available message slots. |
|
38 |
// - Send stop signal and check that the server has stopped as expected. |
|
39 |
// - Check the client and server have exited as expected. |
|
40 |
// - Create client and server threads, open a connection to the server and verify that |
|
41 |
// - Server is panicked when completing a message twice. |
|
42 |
// Platforms/Drives/Compatibility: |
|
43 |
// All. |
|
44 |
// Assumptions/Requirement/Pre-requisites: |
|
45 |
// Failures and causes: |
|
46 |
// Base Port information: |
|
47 |
// |
|
48 |
// |
|
49 |
||
50 |
#include <e32std.h> |
|
51 |
#include <e32std_private.h> |
|
52 |
#include <e32test.h> |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
53 |
#include <e32ver.h> |
0 | 54 |
#include <e32panic.h> |
55 |
||
56 |
const TInt KHeapMinSize=0x1000; |
|
57 |
const TInt KHeapMaxSize=0x1000; |
|
58 |
||
59 |
_LIT(KServerName,"CTestServer"); |
|
60 |
||
61 |
class CTestServer : public CServer2 |
|
62 |
{ |
|
63 |
public: |
|
64 |
IMPORT_C CTestServer(TInt aPriority); |
|
65 |
enum TPanicType{ |
|
66 |
EInt0Error=1, EInt1Error, EInt2Error, EInt3Error, |
|
67 |
EPtr0Error, EPtr1Error, EPtr2Error, EPtr3Error, |
|
68 |
ECreateNameError, ENewSessionError, |
|
69 |
EClientError |
|
70 |
}; |
|
71 |
static void Panic(TPanicType aReason); |
|
72 |
protected: |
|
73 |
//override the pure virtual functions: |
|
74 |
IMPORT_C virtual CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const; |
|
75 |
}; |
|
76 |
||
77 |
||
78 |
class CTestSession : public CSession2 |
|
79 |
{ |
|
80 |
public: |
|
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
81 |
enum {EStop,ETestInt,ETestPtr,ETestClient,ETestComplete,ETestPtrComplete,ETestCompletePanic,ETestOtherSession,ETestCompleteAfter,ETestMessageConstruction, |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
82 |
ETestRMessagePtr2LeavingInterface, ETestKillCompletePanic}; |
0 | 83 |
//Override pure virtual |
84 |
IMPORT_C virtual void ServiceL(const RMessage2& aMessage); |
|
85 |
private: |
|
86 |
void TestInt(const RMessage2& aMessage); |
|
87 |
void TestPtr(const RMessage2& aMessage); |
|
88 |
void TestClient(const RMessage2& aMessage); |
|
89 |
void TestComplete(const RMessage2& aMessage); |
|
90 |
void TestPtrComplete(const RMessage2& aMessage); |
|
91 |
void TestCompletePanic(); |
|
92 |
TInt TestMessageConstruction(const RMessage2& aMessage); |
|
93 |
TInt TestRMessagePtr2LeavingInterface(const RMessage2& aMessage); |
|
94 |
// |
|
95 |
TInt count1;//initially ==0 |
|
96 |
RMessage2 messages[5];//Used in TestComplete() |
|
97 |
// |
|
98 |
TInt count2;//initially ==0 |
|
99 |
RMessagePtr2 messagePtrs[5];//User in TestPtrComplete() |
|
100 |
}; |
|
101 |
||
102 |
||
103 |
class CMyActiveScheduler : public CActiveScheduler |
|
104 |
{ |
|
105 |
public: |
|
106 |
virtual void Error(TInt anError) const; //override pure virtual error function |
|
107 |
}; |
|
108 |
||
109 |
||
110 |
class RSession : public RSessionBase |
|
111 |
{ |
|
112 |
public: |
|
113 |
TInt PublicSendReceive(TInt aFunction, const TIpcArgs &aPtr) |
|
114 |
{ |
|
115 |
return (SendReceive(aFunction, aPtr)); |
|
116 |
} |
|
117 |
void PublicSendReceive(TInt aFunction, const TIpcArgs &aPtr, TRequestStatus& aStatus) |
|
118 |
{ |
|
119 |
SendReceive(aFunction, aPtr, aStatus); |
|
120 |
} |
|
121 |
TInt PublicCreateSession(const TDesC& aServer,TInt aMessageSlots) |
|
122 |
{ |
|
123 |
return (CreateSession(aServer,User::Version(),aMessageSlots)); |
|
124 |
} |
|
125 |
}; |
|
126 |
||
127 |
// CTestServer functions |
|
128 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
129 |
EXPORT_C CTestServer::CTestServer(TInt aPriority) |
0 | 130 |
// |
131 |
// Constructor - sets name |
|
132 |
// |
|
133 |
: CServer2(aPriority) |
|
134 |
{} |
|
135 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
136 |
EXPORT_C CSession2* CTestServer::NewSessionL(const TVersion& aVersion,const RMessage2& /*aMessage*/) const |
0 | 137 |
// |
138 |
// Virtual fn - checks version supported and creates a CTestSession |
|
139 |
// |
|
140 |
{ |
|
141 |
TVersion version(KE32MajorVersionNumber,KE32MinorVersionNumber,KE32BuildVersionNumber); |
|
142 |
if (User::QueryVersionSupported(version,aVersion)==EFalse) |
|
143 |
User::Leave(KErrNotSupported); |
|
144 |
CTestSession* newCTestSession = new CTestSession; |
|
145 |
if (newCTestSession==NULL) |
|
146 |
Panic(ENewSessionError); |
|
147 |
return(newCTestSession); |
|
148 |
} |
|
149 |
||
150 |
RThread clientThread, serverThread; |
|
151 |
||
152 |
void CTestServer::Panic(TPanicType aReason) //static function |
|
153 |
{ |
|
154 |
clientThread.Kill(KErrNone); |
|
155 |
User::Panic(_L("CTestServer"),aReason); |
|
156 |
} |
|
157 |
||
158 |
RSession session, otherSession; |
|
159 |
RSemaphore sem; |
|
160 |
||
161 |
const TInt KTestInt[] = {-3866,30566,0,200}; |
|
162 |
||
163 |
void CTestSession::TestInt(const RMessage2& aMessage) |
|
164 |
// |
|
165 |
// Tests to see that the correct Int0/1/2/3 have been received |
|
166 |
// |
|
167 |
{ |
|
168 |
if (aMessage.Int0()!=KTestInt[0]) |
|
169 |
CTestServer::Panic(CTestServer::EInt0Error); |
|
170 |
if (aMessage.Int1()!=KTestInt[1]) |
|
171 |
CTestServer::Panic(CTestServer::EInt1Error); |
|
172 |
if (aMessage.Int2()!=KTestInt[2]) |
|
173 |
CTestServer::Panic(CTestServer::EInt2Error); |
|
174 |
if (aMessage.Int3()!=KTestInt[3]) |
|
175 |
CTestServer::Panic(CTestServer::EInt3Error); |
|
176 |
} |
|
177 |
||
178 |
const TAny* KTestPtr[]={&clientThread, &serverThread, &session, &sem}; |
|
179 |
||
180 |
void CTestSession::TestPtr(const RMessage2& aMessage) |
|
181 |
// |
|
182 |
// Tests to see that the correct Ptr0/1/2/3 have been received |
|
183 |
// |
|
184 |
{ |
|
185 |
if (aMessage.Ptr0()!=KTestPtr[0]) |
|
186 |
CTestServer::Panic(CTestServer::EPtr0Error); |
|
187 |
if (aMessage.Ptr1()!=KTestPtr[1]) |
|
188 |
CTestServer::Panic(CTestServer::EPtr1Error); |
|
189 |
if (aMessage.Ptr2()!=KTestPtr[2]) |
|
190 |
CTestServer::Panic(CTestServer::EPtr2Error); |
|
191 |
if (aMessage.Ptr3()!=KTestPtr[3]) |
|
192 |
CTestServer::Panic(CTestServer::EPtr3Error); |
|
193 |
} |
|
194 |
||
195 |
void CTestSession::TestClient(const RMessage2& aMessage) |
|
196 |
// |
|
197 |
// Tests Client() |
|
198 |
// |
|
199 |
{ |
|
200 |
||
201 |
TFullName n=RProcess().Name(); |
|
202 |
n+=_L("::Client Thread"); |
|
203 |
RThread t; |
|
204 |
TInt r=aMessage.Client(t); |
|
205 |
if (r!=KErrNone) |
|
206 |
User::Invariant(); |
|
207 |
if (t.FullName().CompareF(n)!=0) |
|
208 |
{ |
|
209 |
clientThread.Kill(0); |
|
210 |
CTestServer::Panic(CTestServer::EClientError); |
|
211 |
} |
|
212 |
t.Close(); |
|
213 |
} |
|
214 |
||
215 |
void CTestSession::TestComplete(const RMessage2& aMessage) |
|
216 |
// |
|
217 |
// Stores messages up then Completes in reverse order |
|
218 |
// |
|
219 |
{ |
|
220 |
messages[count1] = aMessage; |
|
221 |
if (++count1==5) |
|
222 |
for(count1=4; count1>=0; count1--) |
|
223 |
messages[count1].Complete(5-count1); //Complete with different 'error messages' |
|
224 |
} |
|
225 |
||
226 |
void CTestSession::TestPtrComplete(const RMessage2& aMessage) |
|
227 |
// |
|
228 |
// Stores messages up as RMessagePtrs then Completes in reverse order |
|
229 |
// Also tests RMessage2::MessagePtr() |
|
230 |
// |
|
231 |
{ |
|
232 |
||
233 |
messagePtrs[count2] = aMessage; |
|
234 |
__ASSERT_ALWAYS(!messagePtrs[count2].IsNull(), User::Invariant()); |
|
235 |
if (++count2==5) |
|
236 |
for(count2=4; count2>=0; count2--) |
|
237 |
{ |
|
238 |
messagePtrs[count2].Complete(10-count2*2); |
|
239 |
__ASSERT_ALWAYS(messagePtrs[count2].IsNull(), User::Invariant()); |
|
240 |
} |
|
241 |
} |
|
242 |
||
243 |
||
244 |
||
245 |
TInt CTestSession::TestMessageConstruction(const RMessage2& aMessage) |
|
246 |
{ |
|
247 |
RMessage2 m2((RMessagePtr2&)aMessage); |
|
248 |
if(m2!=aMessage) |
|
249 |
return KErrGeneral; |
|
250 |
return KErrNone; |
|
251 |
} |
|
252 |
||
253 |
TInt CTestSession::TestRMessagePtr2LeavingInterface(const RMessage2& aMessage) |
|
254 |
{ |
|
255 |
RThread thread1, thread2; |
|
256 |
TProcessPriority priority = EPriorityForeground; |
|
257 |
||
258 |
//Check that both Client and ClientL methods return the same thread and error code. |
|
259 |
if (aMessage.Client(thread1)) |
|
260 |
return KErrGeneral; |
|
261 |
||
262 |
TRAPD(r1, aMessage.ClientL(thread2)) |
|
263 |
if (KErrNone != r1) |
|
264 |
{ |
|
265 |
thread1.Close(); |
|
266 |
return r1; |
|
267 |
} |
|
268 |
if (thread1.Id() != thread2.Id()) |
|
269 |
{ |
|
270 |
thread1.Close(); |
|
271 |
thread2.Close(); |
|
272 |
return KErrBadHandle; |
|
273 |
} |
|
274 |
||
275 |
//Check that both SetPriority & SetPriorityL methods return the same error code |
|
276 |
r1 = aMessage.SetProcessPriority(priority); |
|
277 |
TRAPD(r2, aMessage.SetProcessPriorityL(priority)) |
|
278 |
||
279 |
thread1.Close(); |
|
280 |
thread2.Close(); |
|
281 |
if (r1 != r2) |
|
282 |
return KErrGeneral; |
|
283 |
||
284 |
return KErrNone; |
|
285 |
} |
|
286 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
287 |
EXPORT_C void CTestSession::ServiceL(const RMessage2& aMessage) |
0 | 288 |
// |
289 |
// Virtual message-handler |
|
290 |
// |
|
291 |
{ |
|
292 |
TInt r=KErrNone; |
|
293 |
switch (aMessage.Function()) |
|
294 |
{ |
|
295 |
case EStop: |
|
296 |
CActiveScheduler::Stop(); |
|
297 |
break; |
|
298 |
case ETestInt: |
|
299 |
TestInt(aMessage); |
|
300 |
break; |
|
301 |
case ETestPtr: |
|
302 |
TestPtr(aMessage); |
|
303 |
break; |
|
304 |
case ETestClient: |
|
305 |
TestClient(aMessage); |
|
306 |
break; |
|
307 |
case ETestComplete: |
|
308 |
TestComplete(aMessage); |
|
309 |
return; |
|
310 |
case ETestPtrComplete: |
|
311 |
TestPtrComplete(aMessage); |
|
312 |
return; |
|
313 |
case ETestCompletePanic: |
|
314 |
aMessage.Complete(KErrNone); |
|
315 |
break; |
|
316 |
case ETestOtherSession: |
|
317 |
break; |
|
318 |
case ETestCompleteAfter: |
|
319 |
User::After(7000000); |
|
320 |
break; |
|
321 |
case ETestMessageConstruction: |
|
322 |
r=TestMessageConstruction(aMessage); |
|
323 |
break; |
|
324 |
case ETestRMessagePtr2LeavingInterface: |
|
325 |
r=TestRMessagePtr2LeavingInterface(aMessage); |
|
326 |
break; |
|
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
327 |
case ETestKillCompletePanic: |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
328 |
aMessage.Complete(KErrNone); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
329 |
aMessage.Panic(_L("Testing Panic"),0xFF); //This will panic the server! |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
330 |
break; |
0 | 331 |
default: |
332 |
r=KErrNotSupported; |
|
333 |
||
334 |
} |
|
335 |
aMessage.Complete(r); |
|
336 |
||
337 |
} |
|
338 |
||
339 |
// CTestSession funtions |
|
340 |
||
341 |
void CMyActiveScheduler::Error(TInt anError) const |
|
342 |
// |
|
343 |
// Virtual error handler |
|
344 |
// |
|
345 |
{ |
|
346 |
User::Panic(_L("CMyActiveScheduer::Error"), anError); |
|
347 |
} |
|
348 |
||
349 |
#include <e32svr.h> |
|
350 |
||
351 |
TInt ClientThread(TAny*) |
|
352 |
// |
|
353 |
// Passed as the first client thread - signals the server to do several tests |
|
354 |
// |
|
355 |
{ |
|
356 |
RTest test(_L("T_MESSGE...client")); |
|
357 |
||
358 |
test.Title(); |
|
359 |
test.Start(_L("Wait for server to start")); |
|
360 |
sem.Wait(); |
|
361 |
||
362 |
test.Next(_L("Create Session")); |
|
363 |
TInt r=session.PublicCreateSession(_L("CTestServer"),5); |
|
364 |
if (r!=KErrNone) |
|
365 |
User::Panic(_L("CreateSessn failure"),r); |
|
366 |
||
367 |
test.Next(_L("Signal to test Int0/1/2/3()")); |
|
368 |
r=session.PublicSendReceive(CTestSession::ETestInt,TIpcArgs(-3866,30566,0,200) ); |
|
369 |
test(r==KErrNone); |
|
370 |
||
371 |
test.Next(_L("Signal to test Ptr0/1/2/3()")); |
|
372 |
||
373 |
r=session.PublicSendReceive(CTestSession::ETestPtr, TIpcArgs(&clientThread, &serverThread, &session, &sem)); |
|
374 |
test(r==KErrNone); |
|
375 |
||
376 |
test.Next(_L("Signal to test Client()")); |
|
377 |
r=session.PublicSendReceive(CTestSession::ETestClient, TIpcArgs()); |
|
378 |
test(r==KErrNone); |
|
379 |
||
380 |
test.Next(_L("Test RMessage2::Complete()")); |
|
381 |
TRequestStatus stat[7]; |
|
382 |
for (r=0;r<4;r++) |
|
383 |
{ |
|
384 |
session.PublicSendReceive(CTestSession::ETestComplete, TIpcArgs(), stat[r]); |
|
385 |
test(stat[r]==KRequestPending); |
|
386 |
} |
|
387 |
session.PublicSendReceive(CTestSession::ETestComplete, TIpcArgs(), stat[4]); |
|
388 |
User::WaitForRequest(stat[0]); |
|
389 |
for (r=0;r<5;r++) |
|
390 |
test(stat[r]==5-r); //Test the 'error messages' set by Complete() |
|
391 |
test.Next(_L("Test RMessagePtr2::Complete()")); |
|
392 |
for (r=0;r<4;r++) |
|
393 |
{ |
|
394 |
session.PublicSendReceive(CTestSession::ETestPtrComplete, TIpcArgs(), stat[r]); |
|
395 |
test(stat[r]==KRequestPending); |
|
396 |
} |
|
397 |
session.PublicSendReceive(CTestSession::ETestPtrComplete, TIpcArgs(), stat[4]); |
|
398 |
User::WaitForRequest(stat[0]); |
|
399 |
for (r=0;r<5;r++) |
|
400 |
test(stat[r]==10-r*2); |
|
401 |
||
402 |
test.Next(_L("Test RMessage contruction from Ptr")); |
|
403 |
if(UserSvr::IpcV1Available()) |
|
404 |
{ |
|
405 |
r=session.PublicSendReceive(CTestSession::ETestMessageConstruction, TIpcArgs(111,222,333,444)); |
|
406 |
test(r==KErrNone); |
|
407 |
} |
|
408 |
else |
|
409 |
{ |
|
410 |
test.Printf(_L("NOT TESTED - IPC V1 is not supported by system")); |
|
411 |
} |
|
412 |
||
413 |
test.Next(_L("Test RMessagePtr leaving interface")); |
|
414 |
r=session.PublicSendReceive(CTestSession::ETestRMessagePtr2LeavingInterface, TIpcArgs()); |
|
415 |
test(r==KErrNone); |
|
416 |
||
417 |
test.Next(_L("Try another session")); |
|
418 |
r=otherSession.PublicCreateSession(_L("CTestServer"),5); |
|
419 |
test(r==KErrNone); |
|
420 |
||
421 |
r=otherSession.PublicSendReceive(CTestSession::ETestOtherSession, TIpcArgs()); |
|
422 |
test(r==KErrNone); |
|
423 |
||
424 |
test.Next(_L("Saturate server")); |
|
425 |
for(r=0;r<7;r++) |
|
426 |
{ |
|
427 |
test.Printf(_L("Send %d\r"),r); |
|
428 |
session.PublicSendReceive(CTestSession::ETestCompleteAfter,TIpcArgs(),stat[r]); |
|
429 |
if (r<5) |
|
430 |
test(stat[r]==KRequestPending); |
|
431 |
else |
|
432 |
test(stat[r]==KErrServerBusy); |
|
433 |
} |
|
434 |
test.Printf(_L("\n")); |
|
435 |
for(r=0;r<5;r++) |
|
436 |
{ |
|
437 |
test.Printf(_L("Wait %d\r"),r); |
|
438 |
User::WaitForRequest(stat[r]); |
|
439 |
test(stat[r]==KErrNone); |
|
440 |
} |
|
441 |
test.Printf(_L("\n")); |
|
442 |
||
443 |
test.Next(_L("Signal to stop ActiveScheduler")); |
|
444 |
session.PublicSendReceive(CTestSession::EStop, TIpcArgs()); |
|
445 |
session.Close(); |
|
446 |
otherSession.PublicSendReceive(CTestSession::EStop, TIpcArgs()); |
|
447 |
otherSession.Close(); |
|
448 |
test.Close(); |
|
449 |
||
450 |
return (KErrNone); |
|
451 |
} |
|
452 |
||
453 |
TInt ServerThread(TAny*) |
|
454 |
// |
|
455 |
// Passed as the server thread in 2 tests - sets up and runs CTestServer |
|
456 |
// |
|
457 |
{ |
|
458 |
RTest test(_L("T_MESSGE...server")); |
|
459 |
||
460 |
test.Title(); |
|
461 |
test.Start(_L("Create and install ActiveScheduler")); |
|
462 |
CMyActiveScheduler* pScheduler = new CMyActiveScheduler; |
|
463 |
if (pScheduler==NULL) |
|
464 |
{ |
|
465 |
clientThread.Kill(0); |
|
466 |
User::Panic(_L("CreateSched failure"),KErrNoMemory); |
|
467 |
} |
|
468 |
||
469 |
CActiveScheduler::Install(pScheduler); |
|
470 |
||
471 |
test.Next(_L("Creating and starting Server")); |
|
472 |
CTestServer* pServer = new CTestServer(0); |
|
473 |
if (pServer==NULL) |
|
474 |
{ |
|
475 |
clientThread.Kill(0); |
|
476 |
User::Panic(_L("CreateServr failure"),KErrNoMemory); |
|
477 |
} |
|
478 |
||
479 |
TInt r=pServer->Start(KServerName);//Starting a CServer2 also Adds it to the ActiveScheduler |
|
480 |
if (r!=KErrNone) |
|
481 |
{ |
|
482 |
clientThread.Kill(0); |
|
483 |
User::Panic(_L("StartServr failure"),r); |
|
484 |
} |
|
485 |
||
486 |
||
487 |
test.Next(_L("Start ActiveScheduler and signal to client")); |
|
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
488 |
test.Printf(_L(" There might be something going on beneath this window\n")); |
0 | 489 |
sem.Signal(); |
490 |
CActiveScheduler::Start(); |
|
491 |
test.Next(_L("Destroy ActiveScheduler")); |
|
492 |
delete pScheduler; |
|
493 |
delete pServer; |
|
494 |
||
495 |
test.Close(); |
|
496 |
||
497 |
return (KErrNone); |
|
498 |
} |
|
499 |
||
500 |
const TInt KTestPanic = 14849; |
|
501 |
||
502 |
TInt PanicTestThread (TAny*) |
|
503 |
// |
|
504 |
// Passed as a thread entry - just calls RMessage2::Panic() |
|
505 |
// |
|
506 |
{ |
|
507 |
RMessage2 message; |
|
508 |
message.Panic(_L("Testing Panic"),KTestPanic); |
|
509 |
return(KErrNone); |
|
510 |
} |
|
511 |
||
512 |
RTest test(_L("Main T_MESSGE test")); |
|
513 |
||
514 |
TInt CompletePanicClientThread (TAny*) |
|
515 |
// |
|
516 |
// Passed as the second client thread entry - signals to server to call Complete() twice |
|
517 |
// |
|
518 |
{ |
|
519 |
sem.Wait(); |
|
520 |
||
521 |
TInt r=session.PublicCreateSession(_L("CTestServer"),1); |
|
522 |
test(r==KErrNone); |
|
523 |
||
524 |
r=session.PublicSendReceive(CTestSession::ETestCompletePanic, TIpcArgs()); |
|
525 |
test(r==KErrNone); |
|
526 |
||
527 |
session.PublicSendReceive(CTestSession::EStop, TIpcArgs());//panic should occur before this is serviced |
|
528 |
return(KErrNone); |
|
529 |
} |
|
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
530 |
|
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
531 |
TInt KillCompletePanicClientThread (TAny*) |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
532 |
// |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
533 |
// A client thread entry - signals to server to kill client after completing the message |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
534 |
// |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
535 |
{ |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
536 |
sem.Wait(); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
537 |
|
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
538 |
TInt r=session.PublicCreateSession(_L("CTestServer"),1); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
539 |
test(r==KErrNone); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
540 |
|
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
541 |
r=session.PublicSendReceive(CTestSession::ETestKillCompletePanic, TIpcArgs()); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
542 |
test(r==KErrNone); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
543 |
|
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
544 |
session.PublicSendReceive(CTestSession::EStop, TIpcArgs());//panic should occur before this is serviced |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
545 |
return(KErrNone); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
546 |
} |
0 | 547 |
|
548 |
void SimpleRMessage() |
|
549 |
// |
|
550 |
// Simple RMessage2 Tests - constructors and assignment |
|
551 |
// |
|
552 |
{ |
|
553 |
||
554 |
test.Start(_L("Default constructor")); |
|
555 |
RMessage2 message1; |
|
556 |
||
557 |
test.Next(_L("Copy constructor")); |
|
558 |
RMessage2 message2(message1); |
|
559 |
test(message1.Function()==message2.Function()); |
|
560 |
test(message1.Int0()==message2.Int0()); |
|
561 |
test(message1.Int1()==message2.Int1()); |
|
562 |
test(message1.Int2()==message2.Int2()); |
|
563 |
test(message1.Int3()==message2.Int3()); |
|
564 |
||
565 |
test.Next(_L("Assignment operator")); |
|
566 |
RMessage2 message3; |
|
567 |
Mem::Fill(&message3,sizeof(message3),0xb9); // first fill message 3 with rubbish |
|
568 |
message3=message1; |
|
569 |
test(message1.Function()==message3.Function()); |
|
570 |
test(message1.Int0()==message3.Int0()); |
|
571 |
test(message1.Int1()==message3.Int1()); |
|
572 |
test(message1.Int2()==message3.Int2()); |
|
573 |
test(message1.Int3()==message3.Int3()); |
|
574 |
||
575 |
test.End(); |
|
576 |
} |
|
577 |
||
578 |
void SimpleRMessagePtr() |
|
579 |
// |
|
580 |
// Simple RMessagePtr2 tests - constructors and assignment |
|
581 |
// |
|
582 |
{ |
|
583 |
test.Start(_L("Default constructor")); |
|
584 |
RMessagePtr2 messagePtr1; |
|
585 |
test(messagePtr1.IsNull()); |
|
586 |
||
587 |
test.Next(_L("Copy constructor")); |
|
588 |
RMessagePtr2 messagePtr2(messagePtr1); |
|
589 |
test(messagePtr2.IsNull()); |
|
590 |
||
591 |
test.Next(_L("Constructor from pointer to RMessage2")); |
|
592 |
RMessage2 message; |
|
593 |
messagePtr1= message; |
|
594 |
||
595 |
test.Next(_L("Assignment operator")); |
|
596 |
messagePtr1=messagePtr2; |
|
597 |
||
598 |
test.End(); |
|
599 |
} |
|
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
600 |
|
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
601 |
void TestServerCompleteTwicePanic(void) |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
602 |
{ |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
603 |
TRequestStatus clientStat,serverStat; |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
604 |
|
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
605 |
TBool justInTime=User::JustInTime(); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
606 |
|
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
607 |
test.Next(_L("Check server panics if you try to complete a message twice")); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
608 |
test.Start(_L("Create client and server threads")); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
609 |
clientThread.Create(_L("Client Thread1"),CompletePanicClientThread,KDefaultStackSize,KHeapMinSize,KHeapMaxSize,NULL); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
610 |
serverThread.Create(_L("Server Thread"),ServerThread,KDefaultStackSize,KHeapMinSize,KHeapMaxSize,NULL); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
611 |
|
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
612 |
test.Next(_L("Logon to the threads")); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
613 |
clientThread.Logon(clientStat); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
614 |
serverThread.Logon(serverStat); |
0 | 615 |
|
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
616 |
test.Next(_L("Start the threads")); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
617 |
sem.CreateLocal(0); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
618 |
User::SetJustInTime(EFalse); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
619 |
clientThread.Resume(); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
620 |
serverThread.Resume(); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
621 |
|
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
622 |
test.Next(_L("Wait for the threads to stop")); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
623 |
User::WaitForRequest(clientStat); // |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
624 |
User::WaitForRequest(serverStat); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
625 |
User::SetJustInTime(justInTime); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
626 |
test.Next(_L("Check the exit categories")); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
627 |
test(clientThread.ExitType()==EExitKill); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
628 |
test(clientThread.ExitCategory().Compare(_L("Kill"))==0); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
629 |
test(clientThread.ExitReason()==KErrNone); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
630 |
|
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
631 |
test(serverThread.ExitType()==EExitPanic); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
632 |
test(serverThread.ExitCategory().Compare(_L("USER"))==0); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
633 |
test(serverThread.ExitReason()==ETMesCompletion); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
634 |
|
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
635 |
test.Next(_L("Close the threads")); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
636 |
CLOSE_AND_WAIT(serverThread); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
637 |
CLOSE_AND_WAIT(clientThread); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
638 |
test.End(); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
639 |
} |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
640 |
|
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
641 |
void TestServerKillCompletePanic(void) |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
642 |
{ |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
643 |
TRequestStatus clientStat,serverStat; |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
644 |
|
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
645 |
TBool justInTime=User::JustInTime(); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
646 |
|
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
647 |
test.Next(_L("Check Server panics if you try to panic a client using a completed message")); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
648 |
test.Start(_L("Create client and server threads")); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
649 |
clientThread.Create(_L("Client Thread2"),KillCompletePanicClientThread,KDefaultStackSize,KHeapMinSize,KHeapMaxSize,NULL); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
650 |
serverThread.Create(_L("Server Thread"),ServerThread,KDefaultStackSize,KHeapMinSize,KHeapMaxSize,NULL); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
651 |
|
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
652 |
test.Next(_L("Logon to the threads")); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
653 |
clientThread.Logon(clientStat); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
654 |
serverThread.Logon(serverStat); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
655 |
|
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
656 |
test.Next(_L("Start the threads")); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
657 |
sem.CreateLocal(0); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
658 |
User::SetJustInTime(EFalse); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
659 |
clientThread.Resume(); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
660 |
serverThread.Resume(); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
661 |
|
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
662 |
test.Next(_L("Wait for the threads to stop")); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
663 |
User::WaitForRequest(clientStat); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
664 |
User::WaitForRequest(serverStat); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
665 |
User::SetJustInTime(justInTime); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
666 |
test.Next(_L("Check the exit categories")); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
667 |
test(clientThread.ExitType()==EExitKill); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
668 |
test(clientThread.ExitCategory().Compare(_L("Kill"))==0); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
669 |
test(clientThread.ExitReason()==KErrNone); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
670 |
|
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
671 |
test(serverThread.ExitType()==EExitPanic); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
672 |
test(serverThread.ExitCategory().Compare(_L("KERN-EXEC"))==0); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
673 |
test(serverThread.ExitReason()==EBadMessageHandle); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
674 |
|
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
675 |
test.Next(_L("Close the threads")); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
676 |
CLOSE_AND_WAIT(serverThread); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
677 |
CLOSE_AND_WAIT(clientThread); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
678 |
test.End(); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
679 |
} |
0 | 680 |
|
681 |
GLDEF_C TInt E32Main() |
|
682 |
{ |
|
683 |
test.Title(); |
|
684 |
||
685 |
test.Start(_L("Simple RMessage2 tests")); |
|
686 |
SimpleRMessage(); |
|
687 |
||
688 |
test.Next(_L("Simple RMessagePtr2 tests")); |
|
689 |
SimpleRMessagePtr(); |
|
690 |
||
691 |
test.Next(_L("Sending messages between two threads")); |
|
692 |
test.Start(_L("Create client and server threads")); |
|
693 |
clientThread.Create(_L("Client Thread"),ClientThread,KDefaultStackSize,KHeapMinSize,KHeapMaxSize,NULL); |
|
694 |
serverThread.Create(_L("Server Thread"),ServerThread,KDefaultStackSize,KHeapMinSize,KHeapMaxSize,NULL); |
|
695 |
||
696 |
test.Next(_L("Logon to the threads")); |
|
697 |
TRequestStatus clientStat,serverStat; |
|
698 |
clientThread.Logon(clientStat); |
|
699 |
serverThread.Logon(serverStat); |
|
700 |
||
701 |
test.Next(_L("Start the threads")); |
|
702 |
sem.CreateLocal(0); |
|
703 |
clientThread.Resume(); |
|
704 |
serverThread.Resume(); |
|
705 |
||
706 |
test.Next(_L("Wait for the threads to stop")); |
|
707 |
if(clientStat==KRequestPending) |
|
708 |
User::WaitForRequest(clientStat); |
|
709 |
if(serverStat==KRequestPending) |
|
710 |
User::WaitForRequest(serverStat); |
|
711 |
switch (clientThread.ExitType()) |
|
712 |
{ |
|
713 |
case EExitKill: |
|
714 |
test.Printf(_L(" Client thread killed\n")); |
|
715 |
break; |
|
716 |
case EExitTerminate: |
|
717 |
test.Printf(_L("!!Client thread terminated:")); |
|
718 |
test.Panic(clientThread.ExitCategory(), clientThread.ExitReason()); |
|
719 |
case EExitPanic: |
|
720 |
test.Panic(_L("!!Client thread panicked:")); |
|
721 |
test.Panic(clientThread.ExitCategory(), clientThread.ExitReason()); |
|
722 |
default: |
|
723 |
test.Panic(_L("!!Client thread did something bizarre"), clientThread.ExitReason()); |
|
724 |
} |
|
725 |
switch (serverThread.ExitType()) |
|
726 |
{ |
|
727 |
case EExitKill: |
|
728 |
test.Printf(_L(" Server thread killed\n")); |
|
729 |
break; |
|
730 |
case EExitTerminate: |
|
731 |
test.Printf(_L("!!Server thread terminated:")); |
|
732 |
test.Panic(serverThread.ExitCategory(), serverThread.ExitReason()); |
|
733 |
case EExitPanic: |
|
734 |
test.Printf(_L("!!Server thread panicked:")); |
|
735 |
test.Panic(serverThread.ExitCategory(), serverThread.ExitReason()); |
|
736 |
// |
|
737 |
// To catch a panic put a breakpoint in User::Panic() (in UCDT\UC_UNC.CPP). |
|
738 |
// |
|
739 |
default: |
|
740 |
test.Panic(_L("!!Server thread did something bizarre"), serverThread.ExitReason()); |
|
741 |
} |
|
742 |
||
743 |
test.Next(_L("Close the threads")); |
|
744 |
CLOSE_AND_WAIT(serverThread); |
|
745 |
CLOSE_AND_WAIT(clientThread); |
|
746 |
test.End(); |
|
747 |
||
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
748 |
TestServerCompleteTwicePanic(); |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
749 |
|
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
750 |
TestServerKillCompletePanic(); |
0 | 751 |
|
752 |
test.End(); |
|
753 |
||
754 |
return (KErrNone); |
|
755 |
} |
|
756 |
||
757 |