sl@0
|
1 |
// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// e32test\secure\t_smessage.cpp
|
sl@0
|
15 |
// Overview:
|
sl@0
|
16 |
// Test RMessagePtr2 and server message passing
|
sl@0
|
17 |
// API Information:
|
sl@0
|
18 |
// RMessagePtr2, RMessage2
|
sl@0
|
19 |
// Details:
|
sl@0
|
20 |
// - Start a test server and open a server session. Perform various IPC tests
|
sl@0
|
21 |
// and verify results are as expected.
|
sl@0
|
22 |
// - Start a thread and request the server kill, terminate and panic the client
|
sl@0
|
23 |
// thread. Verify results are as expected.
|
sl@0
|
24 |
// - Perform various tests of setting the process priority via the
|
sl@0
|
25 |
// RMessagePtr2::SetProcessPriority() method. Verify results are as expected.
|
sl@0
|
26 |
// - Verify the ability to open a handle on the client thread using the
|
sl@0
|
27 |
// RMessagePtr2::Client() method.
|
sl@0
|
28 |
// - Verify message passing via an RMessage2 object.
|
sl@0
|
29 |
// - Verify the RMessagePtr2::Handle and RMessagePtr::Session methods work
|
sl@0
|
30 |
// as expected.
|
sl@0
|
31 |
// Platforms/Drives/Compatibility:
|
sl@0
|
32 |
// All.
|
sl@0
|
33 |
// Assumptions/Requirement/Pre-requisites:
|
sl@0
|
34 |
// Failures and causes:
|
sl@0
|
35 |
// Base Port information:
|
sl@0
|
36 |
//
|
sl@0
|
37 |
//
|
sl@0
|
38 |
|
sl@0
|
39 |
#include <e32test.h>
|
sl@0
|
40 |
|
sl@0
|
41 |
LOCAL_D RTest test(_L("T_SMESSAGE"));
|
sl@0
|
42 |
|
sl@0
|
43 |
enum TTestProcessFunctions
|
sl@0
|
44 |
{
|
sl@0
|
45 |
ETestProcessServer,
|
sl@0
|
46 |
};
|
sl@0
|
47 |
|
sl@0
|
48 |
#include "testprocess.h"
|
sl@0
|
49 |
|
sl@0
|
50 |
TInt StartServer();
|
sl@0
|
51 |
|
sl@0
|
52 |
TInt DoTestProcess(TInt aTestNum,TInt aArg1,TInt aArg2)
|
sl@0
|
53 |
{
|
sl@0
|
54 |
(void)aArg1;
|
sl@0
|
55 |
(void)aArg2;
|
sl@0
|
56 |
|
sl@0
|
57 |
switch(aTestNum)
|
sl@0
|
58 |
{
|
sl@0
|
59 |
|
sl@0
|
60 |
case ETestProcessServer:
|
sl@0
|
61 |
return StartServer();
|
sl@0
|
62 |
|
sl@0
|
63 |
default:
|
sl@0
|
64 |
User::Panic(_L("T_SMESSAGE"),1);
|
sl@0
|
65 |
}
|
sl@0
|
66 |
|
sl@0
|
67 |
return KErrNone;
|
sl@0
|
68 |
}
|
sl@0
|
69 |
|
sl@0
|
70 |
|
sl@0
|
71 |
|
sl@0
|
72 |
class RTestThread : public RThread
|
sl@0
|
73 |
{
|
sl@0
|
74 |
public:
|
sl@0
|
75 |
void Create(TThreadFunction aFunction,TAny* aArg=0);
|
sl@0
|
76 |
};
|
sl@0
|
77 |
|
sl@0
|
78 |
void RTestThread::Create(TThreadFunction aFunction,TAny* aArg)
|
sl@0
|
79 |
{
|
sl@0
|
80 |
TInt r=RThread::Create(_L(""),aFunction,KDefaultStackSize,KDefaultStackSize,KDefaultStackSize,aArg);
|
sl@0
|
81 |
test(r==KErrNone);
|
sl@0
|
82 |
}
|
sl@0
|
83 |
|
sl@0
|
84 |
|
sl@0
|
85 |
//
|
sl@0
|
86 |
// CTestSession
|
sl@0
|
87 |
//
|
sl@0
|
88 |
|
sl@0
|
89 |
class CTestSession : public CSession2
|
sl@0
|
90 |
{
|
sl@0
|
91 |
public:
|
sl@0
|
92 |
enum {EShutdown,ETestIpc,ETestKill,ETestTerminate,ETestPanic,
|
sl@0
|
93 |
ETestSetProcessPriority,ETestClient,ETestRMessage,ETestHandle,ETestSession};
|
sl@0
|
94 |
public:
|
sl@0
|
95 |
CTestSession();
|
sl@0
|
96 |
virtual void ServiceL(const RMessage2& aMessage);
|
sl@0
|
97 |
public:
|
sl@0
|
98 |
};
|
sl@0
|
99 |
|
sl@0
|
100 |
CTestSession::CTestSession()
|
sl@0
|
101 |
: CSession2()
|
sl@0
|
102 |
{
|
sl@0
|
103 |
}
|
sl@0
|
104 |
|
sl@0
|
105 |
const TInt KTestDataMaxLength8 = 20;
|
sl@0
|
106 |
const TInt KTestDataMaxLength16 = 40;
|
sl@0
|
107 |
_LIT8(KTestData8,"12345678");
|
sl@0
|
108 |
_LIT16(KTestData16,"1234567890123456");
|
sl@0
|
109 |
_LIT(KTestPanicCategory,"TEST PANIC");
|
sl@0
|
110 |
|
sl@0
|
111 |
void CTestSession::ServiceL(const RMessage2& aMessage)
|
sl@0
|
112 |
{
|
sl@0
|
113 |
RMessagePtr2 m(aMessage);
|
sl@0
|
114 |
switch (aMessage.Function())
|
sl@0
|
115 |
{
|
sl@0
|
116 |
case CTestSession::ETestIpc:
|
sl@0
|
117 |
{
|
sl@0
|
118 |
TInt r,l,ml;
|
sl@0
|
119 |
// 8 bit descriptors
|
sl@0
|
120 |
TBuf8<KTestDataMaxLength8> buf8;
|
sl@0
|
121 |
buf8.FillZ();
|
sl@0
|
122 |
// GetDesLength
|
sl@0
|
123 |
l = m.GetDesLength(0);
|
sl@0
|
124 |
if(l!=KTestData8().Length()) m.Complete(l<0 ? l : KErrGeneral);
|
sl@0
|
125 |
// Read
|
sl@0
|
126 |
r = m.Read(0,buf8,1);
|
sl@0
|
127 |
if(r!=KErrNone) m.Complete(r);
|
sl@0
|
128 |
if(buf8.Compare(KTestData8().Right(l-1))) m.Complete(KErrGeneral);
|
sl@0
|
129 |
// ReadL
|
sl@0
|
130 |
buf8.Zero();
|
sl@0
|
131 |
buf8.FillZ();
|
sl@0
|
132 |
m.ReadL(0,buf8,1);
|
sl@0
|
133 |
if(buf8.Compare(KTestData8().Right(l-1))) m.Complete(KErrGeneral);
|
sl@0
|
134 |
// GetDesMaxLength
|
sl@0
|
135 |
ml = m.GetDesMaxLength(2);
|
sl@0
|
136 |
if(ml!=KTestDataMaxLength8) m.Complete(ml<0 ? ml : KErrGeneral);
|
sl@0
|
137 |
// Write
|
sl@0
|
138 |
r = m.Write(2,KTestData8(),0);
|
sl@0
|
139 |
if(r!=KErrNone) m.Complete(r);
|
sl@0
|
140 |
// WriteL
|
sl@0
|
141 |
m.WriteL(2,KTestData8(),1);
|
sl@0
|
142 |
// 16 bit descriptors
|
sl@0
|
143 |
TBuf16<KTestDataMaxLength16> buf16;
|
sl@0
|
144 |
buf16.FillZ();
|
sl@0
|
145 |
// GetDesLength
|
sl@0
|
146 |
l = m.GetDesLength(1);
|
sl@0
|
147 |
if(l!=KTestData16().Length()) m.Complete(l<0 ? l : KErrGeneral);
|
sl@0
|
148 |
// Read
|
sl@0
|
149 |
r = m.Read(1,buf16,1);
|
sl@0
|
150 |
if(r!=KErrNone) m.Complete(r);
|
sl@0
|
151 |
if(buf16.Compare(KTestData16().Right(l-1))) m.Complete(KErrGeneral);
|
sl@0
|
152 |
// ReadL
|
sl@0
|
153 |
buf16.Zero();
|
sl@0
|
154 |
buf16.FillZ();
|
sl@0
|
155 |
m.ReadL(1,buf16,1);
|
sl@0
|
156 |
if(buf16.Compare(KTestData16().Right(l-1))) m.Complete(KErrGeneral);
|
sl@0
|
157 |
// GetDesMaxLength
|
sl@0
|
158 |
ml = m.GetDesMaxLength(3);
|
sl@0
|
159 |
if(ml!=KTestDataMaxLength16) m.Complete(ml<0 ? ml : KErrGeneral);
|
sl@0
|
160 |
// Write
|
sl@0
|
161 |
r = m.Write(3,KTestData16(),0);
|
sl@0
|
162 |
if(r!=KErrNone) m.Complete(r);
|
sl@0
|
163 |
// WriteL
|
sl@0
|
164 |
m.WriteL(3,KTestData16(),1);
|
sl@0
|
165 |
// done
|
sl@0
|
166 |
aMessage.Complete(KErrNone);
|
sl@0
|
167 |
}
|
sl@0
|
168 |
break;
|
sl@0
|
169 |
|
sl@0
|
170 |
case CTestSession::ETestKill:
|
sl@0
|
171 |
m.Kill(999);
|
sl@0
|
172 |
break;
|
sl@0
|
173 |
|
sl@0
|
174 |
case CTestSession::ETestTerminate:
|
sl@0
|
175 |
m.Terminate(999);
|
sl@0
|
176 |
break;
|
sl@0
|
177 |
|
sl@0
|
178 |
case CTestSession::ETestPanic:
|
sl@0
|
179 |
m.Panic(KTestPanicCategory,999);
|
sl@0
|
180 |
break;
|
sl@0
|
181 |
|
sl@0
|
182 |
case ETestSetProcessPriority:
|
sl@0
|
183 |
m.Complete(m.SetProcessPriority((TProcessPriority)aMessage.Int0()));
|
sl@0
|
184 |
break;
|
sl@0
|
185 |
|
sl@0
|
186 |
case ETestClient:
|
sl@0
|
187 |
{
|
sl@0
|
188 |
RThread client;
|
sl@0
|
189 |
m.Client(client);
|
sl@0
|
190 |
m.Complete(client.Id());
|
sl@0
|
191 |
client.Close();
|
sl@0
|
192 |
}
|
sl@0
|
193 |
break;
|
sl@0
|
194 |
|
sl@0
|
195 |
case ETestRMessage:
|
sl@0
|
196 |
{
|
sl@0
|
197 |
RMessage2 message2(m);
|
sl@0
|
198 |
if (Mem::Compare((TUint8*)&message2,sizeof(message2),(TUint8*)&aMessage,sizeof(aMessage)))
|
sl@0
|
199 |
m.Complete(KErrGeneral);
|
sl@0
|
200 |
else
|
sl@0
|
201 |
m.Complete(KErrNone);
|
sl@0
|
202 |
}
|
sl@0
|
203 |
break;
|
sl@0
|
204 |
|
sl@0
|
205 |
case ETestHandle:
|
sl@0
|
206 |
if (m.Handle()!=aMessage.Handle())
|
sl@0
|
207 |
m.Complete(KErrGeneral);
|
sl@0
|
208 |
else
|
sl@0
|
209 |
m.Complete(KErrNone);
|
sl@0
|
210 |
break;
|
sl@0
|
211 |
|
sl@0
|
212 |
case CTestSession::ETestSession:
|
sl@0
|
213 |
if (aMessage.Session()!=this)
|
sl@0
|
214 |
m.Complete(KErrGeneral);
|
sl@0
|
215 |
else
|
sl@0
|
216 |
m.Complete(KErrNone);
|
sl@0
|
217 |
break;
|
sl@0
|
218 |
|
sl@0
|
219 |
case CTestSession::EShutdown:
|
sl@0
|
220 |
CActiveScheduler::Stop();
|
sl@0
|
221 |
break;
|
sl@0
|
222 |
|
sl@0
|
223 |
default:
|
sl@0
|
224 |
m.Complete(KErrNotSupported);
|
sl@0
|
225 |
break;
|
sl@0
|
226 |
}
|
sl@0
|
227 |
}
|
sl@0
|
228 |
|
sl@0
|
229 |
|
sl@0
|
230 |
|
sl@0
|
231 |
//
|
sl@0
|
232 |
// CTestServer
|
sl@0
|
233 |
//
|
sl@0
|
234 |
|
sl@0
|
235 |
class CTestServer : public CServer2
|
sl@0
|
236 |
{
|
sl@0
|
237 |
public:
|
sl@0
|
238 |
CTestServer(TInt aPriority);
|
sl@0
|
239 |
virtual CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const;
|
sl@0
|
240 |
};
|
sl@0
|
241 |
|
sl@0
|
242 |
CTestServer::CTestServer(TInt aPriority)
|
sl@0
|
243 |
: CServer2(aPriority)
|
sl@0
|
244 |
{
|
sl@0
|
245 |
}
|
sl@0
|
246 |
|
sl@0
|
247 |
CSession2* CTestServer::NewSessionL(const TVersion& /*aVersion*/,const RMessage2& /*aMessage*/) const
|
sl@0
|
248 |
{
|
sl@0
|
249 |
return new (ELeave) CTestSession();
|
sl@0
|
250 |
}
|
sl@0
|
251 |
|
sl@0
|
252 |
|
sl@0
|
253 |
|
sl@0
|
254 |
//
|
sl@0
|
255 |
// CTestActiveScheduler
|
sl@0
|
256 |
//
|
sl@0
|
257 |
|
sl@0
|
258 |
class CTestActiveScheduler : public CActiveScheduler
|
sl@0
|
259 |
{
|
sl@0
|
260 |
public:
|
sl@0
|
261 |
virtual void Error(TInt anError) const;
|
sl@0
|
262 |
};
|
sl@0
|
263 |
|
sl@0
|
264 |
void CTestActiveScheduler::Error(TInt anError) const
|
sl@0
|
265 |
{
|
sl@0
|
266 |
User::Panic(_L("TestServer Error"),anError);
|
sl@0
|
267 |
}
|
sl@0
|
268 |
|
sl@0
|
269 |
|
sl@0
|
270 |
|
sl@0
|
271 |
//
|
sl@0
|
272 |
// Server thread
|
sl@0
|
273 |
//
|
sl@0
|
274 |
|
sl@0
|
275 |
_LIT(KServerName,"T_SMESSAGE-server");
|
sl@0
|
276 |
const TInt KServerRendezvous = KRequestPending+1;
|
sl@0
|
277 |
|
sl@0
|
278 |
void DoStartServer()
|
sl@0
|
279 |
{
|
sl@0
|
280 |
CTestActiveScheduler* activeScheduler = new (ELeave) CTestActiveScheduler;
|
sl@0
|
281 |
CActiveScheduler::Install(activeScheduler);
|
sl@0
|
282 |
CleanupStack::PushL(activeScheduler);
|
sl@0
|
283 |
|
sl@0
|
284 |
CTestServer* server = new (ELeave) CTestServer(0);
|
sl@0
|
285 |
CleanupStack::PushL(server);
|
sl@0
|
286 |
|
sl@0
|
287 |
User::LeaveIfError(server->Start(KServerName));
|
sl@0
|
288 |
|
sl@0
|
289 |
RProcess::Rendezvous(KServerRendezvous);
|
sl@0
|
290 |
|
sl@0
|
291 |
CActiveScheduler::Start();
|
sl@0
|
292 |
|
sl@0
|
293 |
CleanupStack::PopAndDestroy(2);
|
sl@0
|
294 |
}
|
sl@0
|
295 |
|
sl@0
|
296 |
TInt StartServer()
|
sl@0
|
297 |
{
|
sl@0
|
298 |
CTrapCleanup* cleanupStack = CTrapCleanup::New();
|
sl@0
|
299 |
if(!cleanupStack)
|
sl@0
|
300 |
return KErrNoMemory;
|
sl@0
|
301 |
TRAPD(leaveError,DoStartServer())
|
sl@0
|
302 |
delete cleanupStack;
|
sl@0
|
303 |
return leaveError;
|
sl@0
|
304 |
}
|
sl@0
|
305 |
|
sl@0
|
306 |
|
sl@0
|
307 |
|
sl@0
|
308 |
//
|
sl@0
|
309 |
// RTestSession
|
sl@0
|
310 |
//
|
sl@0
|
311 |
|
sl@0
|
312 |
class RTestSession : public RSessionBase
|
sl@0
|
313 |
{
|
sl@0
|
314 |
public:
|
sl@0
|
315 |
inline TInt Connect()
|
sl@0
|
316 |
{ return CreateSession(KServerName,TVersion());}
|
sl@0
|
317 |
inline TInt Send(TInt aFunction)
|
sl@0
|
318 |
{ return RSessionBase::SendReceive(aFunction); }
|
sl@0
|
319 |
inline TInt Send(TInt aFunction,const TIpcArgs& aArgs)
|
sl@0
|
320 |
{ return RSessionBase::SendReceive(aFunction,aArgs); }
|
sl@0
|
321 |
inline void Send(TInt aFunction,TRequestStatus& aStatus)
|
sl@0
|
322 |
{ RSessionBase::SendReceive(aFunction,aStatus); }
|
sl@0
|
323 |
inline void Send(TInt aFunction,const TIpcArgs& aArgs,TRequestStatus& aStatus)
|
sl@0
|
324 |
{ RSessionBase::SendReceive(aFunction,aArgs,aStatus); }
|
sl@0
|
325 |
};
|
sl@0
|
326 |
|
sl@0
|
327 |
|
sl@0
|
328 |
|
sl@0
|
329 |
TInt TestThreadServerKill(TAny* aArg)
|
sl@0
|
330 |
{
|
sl@0
|
331 |
RTestSession Session;
|
sl@0
|
332 |
TInt r = Session.Connect();
|
sl@0
|
333 |
if(r!=KErrNone)
|
sl@0
|
334 |
return KErrGeneral;
|
sl@0
|
335 |
User::SetJustInTime(EFalse);
|
sl@0
|
336 |
r = Session.Send((TInt)aArg);
|
sl@0
|
337 |
Session.Close();
|
sl@0
|
338 |
return KErrGeneral;
|
sl@0
|
339 |
}
|
sl@0
|
340 |
|
sl@0
|
341 |
|
sl@0
|
342 |
RTestSession Session;
|
sl@0
|
343 |
|
sl@0
|
344 |
void TestIPC()
|
sl@0
|
345 |
{
|
sl@0
|
346 |
TBuf8<KTestDataMaxLength8> buf8;
|
sl@0
|
347 |
TBuf16<KTestDataMaxLength16> buf16;
|
sl@0
|
348 |
TInt r = Session.Send(CTestSession::ETestIpc,TIpcArgs(&KTestData8,&KTestData16,&buf8,&buf16));
|
sl@0
|
349 |
test(r==KErrNone);
|
sl@0
|
350 |
TInt l = KTestData8().Length();
|
sl@0
|
351 |
test(buf8.Length()==l+1);
|
sl@0
|
352 |
test(KTestData8().Compare(buf8.Right(l))==0);
|
sl@0
|
353 |
l = KTestData16().Length();
|
sl@0
|
354 |
test(buf16.Length()==l+1);
|
sl@0
|
355 |
test(KTestData16().Compare(buf16.Right(l))==0);
|
sl@0
|
356 |
}
|
sl@0
|
357 |
|
sl@0
|
358 |
|
sl@0
|
359 |
|
sl@0
|
360 |
void TestKill()
|
sl@0
|
361 |
{
|
sl@0
|
362 |
RTestThread thread;
|
sl@0
|
363 |
TRequestStatus logonStatus;
|
sl@0
|
364 |
|
sl@0
|
365 |
test.Start(_L("Test Kill"));
|
sl@0
|
366 |
thread.Create(TestThreadServerKill,(TAny*)CTestSession::ETestKill);
|
sl@0
|
367 |
thread.Logon(logonStatus);
|
sl@0
|
368 |
thread.Resume();
|
sl@0
|
369 |
User::WaitForRequest(logonStatus);
|
sl@0
|
370 |
User::SetJustInTime(ETrue);
|
sl@0
|
371 |
test(thread.ExitType()==EExitKill);
|
sl@0
|
372 |
test(logonStatus==999);
|
sl@0
|
373 |
CLOSE_AND_WAIT(thread);
|
sl@0
|
374 |
|
sl@0
|
375 |
test.Next(_L("Test Terminate"));
|
sl@0
|
376 |
thread.Create(TestThreadServerKill,(TAny*)CTestSession::ETestTerminate);
|
sl@0
|
377 |
thread.Logon(logonStatus);
|
sl@0
|
378 |
thread.Resume();
|
sl@0
|
379 |
User::WaitForRequest(logonStatus);
|
sl@0
|
380 |
User::SetJustInTime(ETrue);
|
sl@0
|
381 |
test(thread.ExitType()==EExitTerminate);
|
sl@0
|
382 |
test(logonStatus==999);
|
sl@0
|
383 |
CLOSE_AND_WAIT(thread);
|
sl@0
|
384 |
|
sl@0
|
385 |
test.Next(_L("Test Panic"));
|
sl@0
|
386 |
thread.Create(TestThreadServerKill,(TAny*)CTestSession::ETestPanic);
|
sl@0
|
387 |
thread.Logon(logonStatus);
|
sl@0
|
388 |
thread.Resume();
|
sl@0
|
389 |
User::WaitForRequest(logonStatus);
|
sl@0
|
390 |
User::SetJustInTime(ETrue);
|
sl@0
|
391 |
test(thread.ExitType()==EExitPanic);
|
sl@0
|
392 |
test(logonStatus==999);
|
sl@0
|
393 |
CLOSE_AND_WAIT(thread);
|
sl@0
|
394 |
|
sl@0
|
395 |
test.End();
|
sl@0
|
396 |
}
|
sl@0
|
397 |
|
sl@0
|
398 |
|
sl@0
|
399 |
|
sl@0
|
400 |
void TestSetProcessPriority()
|
sl@0
|
401 |
{
|
sl@0
|
402 |
RProcess process;
|
sl@0
|
403 |
TProcessPriority priority(process.Priority());
|
sl@0
|
404 |
TInt r;
|
sl@0
|
405 |
|
sl@0
|
406 |
test.Start(_L("Try changing priority when Priority Control disabled"));
|
sl@0
|
407 |
r = Session.Send(CTestSession::ETestSetProcessPriority,TIpcArgs(EPriorityBackground));
|
sl@0
|
408 |
test(r==KErrPermissionDenied);
|
sl@0
|
409 |
test(process.Priority()==priority);
|
sl@0
|
410 |
|
sl@0
|
411 |
r = Session.Send(CTestSession::ETestSetProcessPriority,TIpcArgs(EPriorityForeground));
|
sl@0
|
412 |
test(r==KErrPermissionDenied);
|
sl@0
|
413 |
test(process.Priority()==priority);
|
sl@0
|
414 |
|
sl@0
|
415 |
r = Session.Send(CTestSession::ETestSetProcessPriority,TIpcArgs(EPriorityLow));
|
sl@0
|
416 |
test(r==KErrPermissionDenied);
|
sl@0
|
417 |
test(process.Priority()==priority);
|
sl@0
|
418 |
|
sl@0
|
419 |
r = Session.Send(CTestSession::ETestSetProcessPriority,TIpcArgs(EPriorityHigh));
|
sl@0
|
420 |
test(r==KErrPermissionDenied);
|
sl@0
|
421 |
test(process.Priority()==priority);
|
sl@0
|
422 |
|
sl@0
|
423 |
test.Next(_L("Test changing priority when Priority Control enabled"));
|
sl@0
|
424 |
User::SetPriorityControl(ETrue);
|
sl@0
|
425 |
|
sl@0
|
426 |
r = Session.Send(CTestSession::ETestSetProcessPriority,TIpcArgs(EPriorityBackground));
|
sl@0
|
427 |
test(r==KErrNone);
|
sl@0
|
428 |
test(process.Priority()==EPriorityBackground);
|
sl@0
|
429 |
|
sl@0
|
430 |
r = Session.Send(CTestSession::ETestSetProcessPriority,TIpcArgs(EPriorityForeground));
|
sl@0
|
431 |
test(r==KErrNone);
|
sl@0
|
432 |
test(process.Priority()==EPriorityForeground);
|
sl@0
|
433 |
|
sl@0
|
434 |
r = Session.Send(CTestSession::ETestSetProcessPriority,TIpcArgs(EPriorityLow));
|
sl@0
|
435 |
test(r==KErrPermissionDenied);
|
sl@0
|
436 |
test(process.Priority()==EPriorityForeground);
|
sl@0
|
437 |
|
sl@0
|
438 |
r = Session.Send(CTestSession::ETestSetProcessPriority,TIpcArgs(EPriorityHigh));
|
sl@0
|
439 |
test(r==KErrPermissionDenied);
|
sl@0
|
440 |
test(process.Priority()==EPriorityForeground);
|
sl@0
|
441 |
|
sl@0
|
442 |
User::SetPriorityControl(EFalse);
|
sl@0
|
443 |
|
sl@0
|
444 |
process.SetPriority(priority);
|
sl@0
|
445 |
|
sl@0
|
446 |
test.End();
|
sl@0
|
447 |
}
|
sl@0
|
448 |
|
sl@0
|
449 |
|
sl@0
|
450 |
|
sl@0
|
451 |
GLDEF_C TInt E32Main()
|
sl@0
|
452 |
{
|
sl@0
|
453 |
TBuf16<512> cmd;
|
sl@0
|
454 |
User::CommandLine(cmd);
|
sl@0
|
455 |
if(cmd.Length() && TChar(cmd[0]).IsDigit())
|
sl@0
|
456 |
{
|
sl@0
|
457 |
TInt function = -1;
|
sl@0
|
458 |
TInt arg1 = -1;
|
sl@0
|
459 |
TInt arg2 = -1;
|
sl@0
|
460 |
TLex lex(cmd);
|
sl@0
|
461 |
lex.Val(function);
|
sl@0
|
462 |
lex.SkipSpace();
|
sl@0
|
463 |
lex.Val(arg1);
|
sl@0
|
464 |
lex.SkipSpace();
|
sl@0
|
465 |
lex.Val(arg2);
|
sl@0
|
466 |
return DoTestProcess(function,arg1,arg2);
|
sl@0
|
467 |
}
|
sl@0
|
468 |
|
sl@0
|
469 |
test.Title();
|
sl@0
|
470 |
|
sl@0
|
471 |
test.Start(_L("Starting test server"));
|
sl@0
|
472 |
RTestProcess server;
|
sl@0
|
473 |
TRequestStatus rendezvous;
|
sl@0
|
474 |
TRequestStatus svrstat;
|
sl@0
|
475 |
server.Create(ETestProcessServer);
|
sl@0
|
476 |
server.NotifyDestruction(svrstat);
|
sl@0
|
477 |
server.Rendezvous(rendezvous);
|
sl@0
|
478 |
server.Resume();
|
sl@0
|
479 |
User::WaitForRequest(rendezvous);
|
sl@0
|
480 |
test(rendezvous==KServerRendezvous);
|
sl@0
|
481 |
server.Close();
|
sl@0
|
482 |
|
sl@0
|
483 |
test.Next(_L("Openning server session"));
|
sl@0
|
484 |
TInt r = Session.Connect();
|
sl@0
|
485 |
test(r==KErrNone);
|
sl@0
|
486 |
|
sl@0
|
487 |
test.Next(_L("Test IPC data transfer"));
|
sl@0
|
488 |
TestIPC();
|
sl@0
|
489 |
|
sl@0
|
490 |
test.Next(_L("Test RMessagePtr2::Kill, Panic and Teminate"));
|
sl@0
|
491 |
TestKill();
|
sl@0
|
492 |
|
sl@0
|
493 |
test.Next(_L("Test RMessagePtr2::SetProcessPriority"));
|
sl@0
|
494 |
TestSetProcessPriority();
|
sl@0
|
495 |
|
sl@0
|
496 |
test.Next(_L("Test RMessagePtr2::Client"));
|
sl@0
|
497 |
test(Session.Send(CTestSession::ETestClient)==(TInt)RThread().Id());
|
sl@0
|
498 |
|
sl@0
|
499 |
test.Next(_L("Test RMessagePtr2::RMessage2"));
|
sl@0
|
500 |
test(Session.Send(CTestSession::ETestRMessage,TIpcArgs(111111,222222,333333,444444))==KErrNone);
|
sl@0
|
501 |
|
sl@0
|
502 |
test.Next(_L("Test RMessagePtr2::Handle"));
|
sl@0
|
503 |
test(Session.Send(CTestSession::ETestHandle,TIpcArgs())==KErrNone);
|
sl@0
|
504 |
|
sl@0
|
505 |
test.Next(_L("Test RMessagePtr2::Session"));
|
sl@0
|
506 |
test(Session.Send(CTestSession::ETestSession,TIpcArgs())==KErrNone);
|
sl@0
|
507 |
|
sl@0
|
508 |
test.Next(_L("Stopping test server"));
|
sl@0
|
509 |
Session.Send(CTestSession::EShutdown);
|
sl@0
|
510 |
Session.Close();
|
sl@0
|
511 |
User::WaitForRequest(svrstat);
|
sl@0
|
512 |
test(svrstat == KErrNone);
|
sl@0
|
513 |
|
sl@0
|
514 |
test.End();
|
sl@0
|
515 |
return(0);
|
sl@0
|
516 |
}
|
sl@0
|
517 |
|