sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
/**
|
sl@0
|
20 |
Overview:
|
sl@0
|
21 |
Test DLL Writeable Static Data support
|
sl@0
|
22 |
|
sl@0
|
23 |
API Information:
|
sl@0
|
24 |
|
sl@0
|
25 |
|
sl@0
|
26 |
Details:
|
sl@0
|
27 |
- Each process has independent DLL WSD
|
sl@0
|
28 |
- Whether DLL linked directly or indirectly
|
sl@0
|
29 |
- Whether DLL loaded dynamically or statically
|
sl@0
|
30 |
- DLL WSD is consistent under heavy usage by multiple processes
|
sl@0
|
31 |
- IPC works to/from DLL WSD descriptors & TRequestStatus
|
sl@0
|
32 |
This source file builds in 4 configurations, with each of
|
sl@0
|
33 |
direct and indirect linking either used or not used.
|
sl@0
|
34 |
These configurations are set by 4 MM files, t_dllwsd[d][i].mmp
|
sl@0
|
35 |
Any of the exe created from the MMP files can be started
|
sl@0
|
36 |
to run the tests, it does not matter which is used.
|
sl@0
|
37 |
All exe configurations will be used during the tests.
|
sl@0
|
38 |
|
sl@0
|
39 |
Platforms/Drives/Compatibility:
|
sl@0
|
40 |
All.
|
sl@0
|
41 |
|
sl@0
|
42 |
Assumptions/Requirement/Pre-requisites:
|
sl@0
|
43 |
|
sl@0
|
44 |
|
sl@0
|
45 |
Failures and causes:
|
sl@0
|
46 |
|
sl@0
|
47 |
|
sl@0
|
48 |
Base Port information:
|
sl@0
|
49 |
|
sl@0
|
50 |
*/
|
sl@0
|
51 |
|
sl@0
|
52 |
#define __E32TEST_EXTENSION__
|
sl@0
|
53 |
|
sl@0
|
54 |
#include <e32test.h>
|
sl@0
|
55 |
#include <e32svr.h>
|
sl@0
|
56 |
#include <f32dbg.h>
|
sl@0
|
57 |
#include <u32std.h>
|
sl@0
|
58 |
#include "t_dllwsd_dll.h"
|
sl@0
|
59 |
#include "t_dllwsd_dlli.h"
|
sl@0
|
60 |
|
sl@0
|
61 |
|
sl@0
|
62 |
LOCAL_D RTest test(_L("T_DLLWSD"));
|
sl@0
|
63 |
|
sl@0
|
64 |
enum TTestFunc
|
sl@0
|
65 |
{
|
sl@0
|
66 |
ETestFuncTestCons=1,
|
sl@0
|
67 |
ETestFuncThrash1,
|
sl@0
|
68 |
ETestFuncIpcTest,
|
sl@0
|
69 |
ETestFuncIpcGet,
|
sl@0
|
70 |
ETestFuncIpcReverse,
|
sl@0
|
71 |
ETestFuncIpcSet,
|
sl@0
|
72 |
ETestFuncPanic,
|
sl@0
|
73 |
};
|
sl@0
|
74 |
|
sl@0
|
75 |
// Test session for IPC use of WSD, talks to the same server as RDllWsd
|
sl@0
|
76 |
class RIpcTestSession : public RSessionBase
|
sl@0
|
77 |
{
|
sl@0
|
78 |
public:
|
sl@0
|
79 |
TInt Connect()
|
sl@0
|
80 |
{
|
sl@0
|
81 |
return CreateSession(_L("IpcTestServer"), TVersion());
|
sl@0
|
82 |
}
|
sl@0
|
83 |
void Get(TBuf<60000>& buf, TRequestStatus& req)
|
sl@0
|
84 |
{
|
sl@0
|
85 |
SendReceive(ETestFuncIpcGet, TIpcArgs(&buf), req);
|
sl@0
|
86 |
}
|
sl@0
|
87 |
void Reverse(TRequestStatus& req)
|
sl@0
|
88 |
{
|
sl@0
|
89 |
SendReceive(ETestFuncIpcReverse, req);
|
sl@0
|
90 |
}
|
sl@0
|
91 |
void Set(const TBuf<60000>& buf, TRequestStatus& req)
|
sl@0
|
92 |
{
|
sl@0
|
93 |
SendReceive(ETestFuncIpcSet, TIpcArgs(&buf), req);
|
sl@0
|
94 |
}
|
sl@0
|
95 |
};
|
sl@0
|
96 |
|
sl@0
|
97 |
#ifdef T_DLLWSD_DIRECT
|
sl@0
|
98 |
void FillBuf(TInt start, TInt inc)
|
sl@0
|
99 |
{
|
sl@0
|
100 |
for (int ii=0; ii<WsdBuf().Length(); ii++)
|
sl@0
|
101 |
{
|
sl@0
|
102 |
WsdBuf()[ii] = (unsigned short)start;
|
sl@0
|
103 |
start += inc;
|
sl@0
|
104 |
}
|
sl@0
|
105 |
}
|
sl@0
|
106 |
|
sl@0
|
107 |
TInt CheckBuf(TInt start, TInt inc)
|
sl@0
|
108 |
{
|
sl@0
|
109 |
for (int ii=0; ii<WsdBuf().Length(); ii++)
|
sl@0
|
110 |
{
|
sl@0
|
111 |
if (WsdBuf()[ii] != start)
|
sl@0
|
112 |
return KErrGeneral;
|
sl@0
|
113 |
start += inc;
|
sl@0
|
114 |
}
|
sl@0
|
115 |
return KErrNone;
|
sl@0
|
116 |
}
|
sl@0
|
117 |
#endif
|
sl@0
|
118 |
|
sl@0
|
119 |
class CDllWsdServer : public CServer2
|
sl@0
|
120 |
{
|
sl@0
|
121 |
public:
|
sl@0
|
122 |
CDllWsdServer() : CServer2(EPriorityStandard)
|
sl@0
|
123 |
{
|
sl@0
|
124 |
}
|
sl@0
|
125 |
CSession2* NewSessionL(const TVersion& /*aVersion*/,const RMessage2& /*aMessage*/) const;
|
sl@0
|
126 |
mutable TInt iCount;
|
sl@0
|
127 |
};
|
sl@0
|
128 |
|
sl@0
|
129 |
class CDllWsdSession : public CSession2
|
sl@0
|
130 |
{
|
sl@0
|
131 |
public:
|
sl@0
|
132 |
CDllWsdSession()
|
sl@0
|
133 |
{
|
sl@0
|
134 |
ResetConsistencyCheck();
|
sl@0
|
135 |
}
|
sl@0
|
136 |
|
sl@0
|
137 |
~CDllWsdSession()
|
sl@0
|
138 |
{
|
sl@0
|
139 |
// transient server immediate shutdown when last client disconnects
|
sl@0
|
140 |
if (--((CDllWsdServer*)Server())->iCount == 0)
|
sl@0
|
141 |
CActiveScheduler::Stop();
|
sl@0
|
142 |
}
|
sl@0
|
143 |
|
sl@0
|
144 |
void ResetConsistencyCheck()
|
sl@0
|
145 |
{
|
sl@0
|
146 |
iX=42;
|
sl@0
|
147 |
iY=0;
|
sl@0
|
148 |
}
|
sl@0
|
149 |
|
sl@0
|
150 |
void OptResetConsistencyCheck()
|
sl@0
|
151 |
{
|
sl@0
|
152 |
#if !defined(T_DLLWSD_DIRECT) && !defined(T_DLLWSD_INDIRECT)
|
sl@0
|
153 |
// if DLL has been unloaded (dynamic library closed, no static link)
|
sl@0
|
154 |
// WSD will be reset
|
sl@0
|
155 |
ResetConsistencyCheck();
|
sl@0
|
156 |
#endif
|
sl@0
|
157 |
}
|
sl@0
|
158 |
|
sl@0
|
159 |
TInt TestConsistency()
|
sl@0
|
160 |
{
|
sl@0
|
161 |
#ifdef T_DLLWSD_DIRECT
|
sl@0
|
162 |
// static direct
|
sl@0
|
163 |
if (WsdFuncX() != iX++)
|
sl@0
|
164 |
return KErrGeneral;
|
sl@0
|
165 |
if (WsdFuncY() != iY++)
|
sl@0
|
166 |
return KErrGeneral;
|
sl@0
|
167 |
#endif
|
sl@0
|
168 |
|
sl@0
|
169 |
#ifdef T_DLLWSD_INDIRECT
|
sl@0
|
170 |
// static indirect
|
sl@0
|
171 |
if (IndWsdFuncX() != iX++)
|
sl@0
|
172 |
return KErrGeneral;
|
sl@0
|
173 |
if (IndWsdFuncY() != iY++)
|
sl@0
|
174 |
return KErrGeneral;
|
sl@0
|
175 |
#endif
|
sl@0
|
176 |
|
sl@0
|
177 |
// dynamic direct
|
sl@0
|
178 |
OptResetConsistencyCheck();
|
sl@0
|
179 |
RLibrary lib;
|
sl@0
|
180 |
TInt err = lib.Load(_L("t_dllwsd_dll"));
|
sl@0
|
181 |
if (err) return err;
|
sl@0
|
182 |
if ((*lib.Lookup(1))/*WsdFuncX*/() != iX++)
|
sl@0
|
183 |
return KErrGeneral;
|
sl@0
|
184 |
if ((*lib.Lookup(2))/*WsdFuncX*/() != iY++)
|
sl@0
|
185 |
return KErrGeneral;
|
sl@0
|
186 |
lib.Close();
|
sl@0
|
187 |
|
sl@0
|
188 |
// dynamic indirect
|
sl@0
|
189 |
OptResetConsistencyCheck();
|
sl@0
|
190 |
err = lib.Load(_L("t_dllwsd_dlli"));
|
sl@0
|
191 |
if (err) return err;
|
sl@0
|
192 |
if ((*lib.Lookup(1))/*IndWsdFuncX*/() != iX++)
|
sl@0
|
193 |
return KErrGeneral;
|
sl@0
|
194 |
if ((*lib.Lookup(2))/*IndWsdFuncX*/() != iY++)
|
sl@0
|
195 |
return KErrGeneral;
|
sl@0
|
196 |
lib.Close();
|
sl@0
|
197 |
|
sl@0
|
198 |
return KErrNone;
|
sl@0
|
199 |
}
|
sl@0
|
200 |
|
sl@0
|
201 |
TInt Thrash1()
|
sl@0
|
202 |
{
|
sl@0
|
203 |
TTime start;
|
sl@0
|
204 |
start.HomeTime();
|
sl@0
|
205 |
TInt count = 0;
|
sl@0
|
206 |
const TTimeIntervalMicroSeconds limit(10000000); // 10 seconds
|
sl@0
|
207 |
for (;; count++)
|
sl@0
|
208 |
{
|
sl@0
|
209 |
TInt err = TestConsistency();
|
sl@0
|
210 |
if (err) return err;
|
sl@0
|
211 |
TTime now;
|
sl@0
|
212 |
now.HomeTime();
|
sl@0
|
213 |
if (now.MicroSecondsFrom(start) > limit)
|
sl@0
|
214 |
break;
|
sl@0
|
215 |
}
|
sl@0
|
216 |
return count > 0 ? count : -count;
|
sl@0
|
217 |
}
|
sl@0
|
218 |
|
sl@0
|
219 |
TInt IpcTest()
|
sl@0
|
220 |
{
|
sl@0
|
221 |
#ifdef T_DLLWSD_DIRECT
|
sl@0
|
222 |
RIpcTestSession s;
|
sl@0
|
223 |
TInt err = s.Connect();
|
sl@0
|
224 |
if (!err) return err;
|
sl@0
|
225 |
WsdBuf().SetLength(WsdBuf().MaxLength());
|
sl@0
|
226 |
for (int i=0; i<10; i++)
|
sl@0
|
227 |
{
|
sl@0
|
228 |
// 0..n -> buf
|
sl@0
|
229 |
FillBuf(0,1);
|
sl@0
|
230 |
err = CheckBuf(0,1);
|
sl@0
|
231 |
if (!err) return err;
|
sl@0
|
232 |
|
sl@0
|
233 |
// buf -> server
|
sl@0
|
234 |
s.Set(WsdBuf(), WsdReq());
|
sl@0
|
235 |
err = CheckBuf(0,1);
|
sl@0
|
236 |
if (!err) return err;
|
sl@0
|
237 |
|
sl@0
|
238 |
// use TReqestStatus in WSD
|
sl@0
|
239 |
User::WaitForRequest(WsdReq());
|
sl@0
|
240 |
if (!WsdReq().Int()) return WsdReq().Int();
|
sl@0
|
241 |
|
sl@0
|
242 |
// 0..0 -> buf
|
sl@0
|
243 |
FillBuf(0,0);
|
sl@0
|
244 |
err = CheckBuf(0,0);
|
sl@0
|
245 |
if (!err) return err;
|
sl@0
|
246 |
WsdReq() = KRequestPending;
|
sl@0
|
247 |
|
sl@0
|
248 |
// reverse buf on server
|
sl@0
|
249 |
s.Reverse(WsdReq());
|
sl@0
|
250 |
|
sl@0
|
251 |
// local buf is still 0..0
|
sl@0
|
252 |
err = CheckBuf(0,0);
|
sl@0
|
253 |
if (!err) return err;
|
sl@0
|
254 |
|
sl@0
|
255 |
// use TReqestStatus in WSD
|
sl@0
|
256 |
User::WaitForRequest(WsdReq());
|
sl@0
|
257 |
if (!WsdReq().Int()) return WsdReq().Int();
|
sl@0
|
258 |
|
sl@0
|
259 |
// local buf is still 0..0
|
sl@0
|
260 |
err = CheckBuf(0,0);
|
sl@0
|
261 |
if (!err) return err;
|
sl@0
|
262 |
|
sl@0
|
263 |
// get buf from server
|
sl@0
|
264 |
s.Get(WsdBuf(), WsdReq());
|
sl@0
|
265 |
User::WaitForRequest(WsdReq());
|
sl@0
|
266 |
|
sl@0
|
267 |
// buf is n..0
|
sl@0
|
268 |
err = CheckBuf(59999,-1);
|
sl@0
|
269 |
if (!err) return err;
|
sl@0
|
270 |
}
|
sl@0
|
271 |
s.Close();
|
sl@0
|
272 |
return KErrNone;
|
sl@0
|
273 |
#else
|
sl@0
|
274 |
return KErrNotSupported;
|
sl@0
|
275 |
#endif
|
sl@0
|
276 |
}
|
sl@0
|
277 |
|
sl@0
|
278 |
void ServiceL(const RMessage2& aMessage)
|
sl@0
|
279 |
{
|
sl@0
|
280 |
#ifdef T_DLLWSD_DIRECT
|
sl@0
|
281 |
TInt ii=0;
|
sl@0
|
282 |
#endif
|
sl@0
|
283 |
switch (aMessage.Function())
|
sl@0
|
284 |
{
|
sl@0
|
285 |
case ETestFuncTestCons:
|
sl@0
|
286 |
aMessage.Complete(TestConsistency());
|
sl@0
|
287 |
break;
|
sl@0
|
288 |
case ETestFuncThrash1:
|
sl@0
|
289 |
aMessage.Complete(Thrash1());
|
sl@0
|
290 |
break;
|
sl@0
|
291 |
case ETestFuncIpcTest:
|
sl@0
|
292 |
aMessage.Complete(IpcTest());
|
sl@0
|
293 |
break;
|
sl@0
|
294 |
case ETestFuncIpcGet:
|
sl@0
|
295 |
#ifdef T_DLLWSD_DIRECT
|
sl@0
|
296 |
aMessage.WriteL(0, WsdBuf());
|
sl@0
|
297 |
aMessage.Complete(KErrNone);
|
sl@0
|
298 |
#else
|
sl@0
|
299 |
aMessage.Complete(KErrNotSupported);
|
sl@0
|
300 |
#endif
|
sl@0
|
301 |
break;
|
sl@0
|
302 |
case ETestFuncIpcReverse:
|
sl@0
|
303 |
#ifdef T_DLLWSD_DIRECT
|
sl@0
|
304 |
for (ii=0; ii<WsdBuf().Length()/2; ii++)
|
sl@0
|
305 |
{
|
sl@0
|
306 |
TInt o = WsdBuf().Length() - 1 - ii;
|
sl@0
|
307 |
TInt t = WsdBuf()[ii];
|
sl@0
|
308 |
WsdBuf()[ii] = WsdBuf()[o];
|
sl@0
|
309 |
WsdBuf()[o] = (unsigned short)t;
|
sl@0
|
310 |
}
|
sl@0
|
311 |
aMessage.Complete(KErrNone);
|
sl@0
|
312 |
#else
|
sl@0
|
313 |
aMessage.Complete(KErrNotSupported);
|
sl@0
|
314 |
#endif
|
sl@0
|
315 |
break;
|
sl@0
|
316 |
case ETestFuncIpcSet:
|
sl@0
|
317 |
#ifdef T_DLLWSD_DIRECT
|
sl@0
|
318 |
aMessage.ReadL(0, WsdBuf());
|
sl@0
|
319 |
aMessage.Complete(KErrNone);
|
sl@0
|
320 |
#else
|
sl@0
|
321 |
aMessage.Complete(KErrNotSupported);
|
sl@0
|
322 |
#endif
|
sl@0
|
323 |
break;
|
sl@0
|
324 |
case ETestFuncPanic:
|
sl@0
|
325 |
User::Panic(_L("As requested..."), 0);
|
sl@0
|
326 |
break;
|
sl@0
|
327 |
default:
|
sl@0
|
328 |
aMessage.Panic(_L("Unrecognised"), aMessage.Function());
|
sl@0
|
329 |
break;
|
sl@0
|
330 |
}
|
sl@0
|
331 |
}
|
sl@0
|
332 |
|
sl@0
|
333 |
int iX;
|
sl@0
|
334 |
int iY;
|
sl@0
|
335 |
};
|
sl@0
|
336 |
|
sl@0
|
337 |
CSession2* CDllWsdServer::NewSessionL(const TVersion& /*aVersion*/,const RMessage2& /*aMessage*/) const
|
sl@0
|
338 |
{
|
sl@0
|
339 |
iCount++;
|
sl@0
|
340 |
return new(ELeave) CDllWsdSession;
|
sl@0
|
341 |
}
|
sl@0
|
342 |
|
sl@0
|
343 |
TInt SlaveMain()
|
sl@0
|
344 |
{
|
sl@0
|
345 |
TName name;
|
sl@0
|
346 |
User::CommandLine(name);
|
sl@0
|
347 |
|
sl@0
|
348 |
CTrapCleanup* cleanup = CTrapCleanup::New();
|
sl@0
|
349 |
if (!cleanup)
|
sl@0
|
350 |
return KErrNoMemory;
|
sl@0
|
351 |
|
sl@0
|
352 |
TRAPD(err,
|
sl@0
|
353 |
{
|
sl@0
|
354 |
CActiveScheduler* sched=new(ELeave) CActiveScheduler;
|
sl@0
|
355 |
CActiveScheduler::Install(sched);
|
sl@0
|
356 |
|
sl@0
|
357 |
CDllWsdServer* server = new(ELeave) CDllWsdServer;
|
sl@0
|
358 |
server->StartL(name);
|
sl@0
|
359 |
|
sl@0
|
360 |
RProcess::Rendezvous(KErrNone);
|
sl@0
|
361 |
CActiveScheduler::Start();
|
sl@0
|
362 |
|
sl@0
|
363 |
delete server;
|
sl@0
|
364 |
delete sched;
|
sl@0
|
365 |
});
|
sl@0
|
366 |
delete cleanup;
|
sl@0
|
367 |
|
sl@0
|
368 |
return err;
|
sl@0
|
369 |
}
|
sl@0
|
370 |
|
sl@0
|
371 |
//
|
sl@0
|
372 |
// Master test controller
|
sl@0
|
373 |
//
|
sl@0
|
374 |
|
sl@0
|
375 |
class RDllWsd : public RSessionBase
|
sl@0
|
376 |
{
|
sl@0
|
377 |
public:
|
sl@0
|
378 |
RDllWsd(const TDesC& aServerName, const TDesC& aExeName = _L("t_dllwsddi"))
|
sl@0
|
379 |
{
|
sl@0
|
380 |
test.Start(_L("RDllWsd create"));
|
sl@0
|
381 |
RProcess proc;
|
sl@0
|
382 |
test_KErrNone(proc.Create(aExeName, aServerName));
|
sl@0
|
383 |
TRequestStatus req;
|
sl@0
|
384 |
proc.Rendezvous(req);
|
sl@0
|
385 |
proc.Resume();
|
sl@0
|
386 |
User::WaitForRequest(req);
|
sl@0
|
387 |
test_KErrNone(req.Int());
|
sl@0
|
388 |
test_KErrNone(CreateSession(aServerName, TVersion()));
|
sl@0
|
389 |
proc.Close();
|
sl@0
|
390 |
test.End();
|
sl@0
|
391 |
}
|
sl@0
|
392 |
TInt ConsistencyTest()
|
sl@0
|
393 |
{
|
sl@0
|
394 |
return SendReceive(ETestFuncTestCons);
|
sl@0
|
395 |
}
|
sl@0
|
396 |
void ThrashTest1(TRequestStatus& aStatus)
|
sl@0
|
397 |
{
|
sl@0
|
398 |
SendReceive(ETestFuncThrash1, aStatus);
|
sl@0
|
399 |
}
|
sl@0
|
400 |
TInt IpcTest()
|
sl@0
|
401 |
{
|
sl@0
|
402 |
return SendReceive(ETestFuncIpcTest);
|
sl@0
|
403 |
}
|
sl@0
|
404 |
TInt Panic()
|
sl@0
|
405 |
{
|
sl@0
|
406 |
return SendReceive(ETestFuncPanic);
|
sl@0
|
407 |
}
|
sl@0
|
408 |
};
|
sl@0
|
409 |
|
sl@0
|
410 |
void BasicTest()
|
sl@0
|
411 |
{
|
sl@0
|
412 |
test.Start(_L("BasicConsistency"));
|
sl@0
|
413 |
|
sl@0
|
414 |
// create a test server/process for each link variant
|
sl@0
|
415 |
RDllWsd slaves[] =
|
sl@0
|
416 |
{
|
sl@0
|
417 |
RDllWsd(_L("slave1"), _L("t_dllwsd")),
|
sl@0
|
418 |
RDllWsd(_L("slave2"), _L("t_dllwsdd")),
|
sl@0
|
419 |
RDllWsd(_L("slave3"), _L("t_dllwsdi")),
|
sl@0
|
420 |
RDllWsd(_L("slave4"), _L("t_dllwsddi")),
|
sl@0
|
421 |
RDllWsd(_L("slave5"), _L("t_dllwsd")),
|
sl@0
|
422 |
RDllWsd(_L("slave6"), _L("t_dllwsdd")),
|
sl@0
|
423 |
RDllWsd(_L("slave7"), _L("t_dllwsdi")),
|
sl@0
|
424 |
RDllWsd(_L("slave8"), _L("t_dllwsddi"))
|
sl@0
|
425 |
};
|
sl@0
|
426 |
TInt nSlaves = sizeof(slaves)/sizeof(slaves[0]);
|
sl@0
|
427 |
TInt ii;
|
sl@0
|
428 |
// do this a few times
|
sl@0
|
429 |
for (TInt jj=0; jj<10; jj++)
|
sl@0
|
430 |
{
|
sl@0
|
431 |
// all four test variants
|
sl@0
|
432 |
for (ii=0; ii<nSlaves; ii++)
|
sl@0
|
433 |
{
|
sl@0
|
434 |
// repeat the test different numbers of times, to ensure WSD values diverge
|
sl@0
|
435 |
for (TInt kk=0; kk<ii+2; kk++)
|
sl@0
|
436 |
{
|
sl@0
|
437 |
// change order in which processes run the tests
|
sl@0
|
438 |
int idx = (ii + jj) % nSlaves;
|
sl@0
|
439 |
test_KErrNone(slaves[idx].ConsistencyTest());
|
sl@0
|
440 |
}
|
sl@0
|
441 |
}
|
sl@0
|
442 |
// start and stop an extra process
|
sl@0
|
443 |
RDllWsd extra(_L("slave9"), _L("t_dllwsddi"));
|
sl@0
|
444 |
test_KErrNone(extra.ConsistencyTest());
|
sl@0
|
445 |
extra.Close();
|
sl@0
|
446 |
}
|
sl@0
|
447 |
|
sl@0
|
448 |
for (ii=nSlaves-1; ii>=0; ii--)
|
sl@0
|
449 |
slaves[ii].Close();
|
sl@0
|
450 |
|
sl@0
|
451 |
test.End();
|
sl@0
|
452 |
}
|
sl@0
|
453 |
|
sl@0
|
454 |
void ThrashTest1()
|
sl@0
|
455 |
{
|
sl@0
|
456 |
test.Start(_L("ThrashTest1"));
|
sl@0
|
457 |
|
sl@0
|
458 |
// create a test server/process for each link variant
|
sl@0
|
459 |
RDllWsd slaves[4] =
|
sl@0
|
460 |
{
|
sl@0
|
461 |
RDllWsd(_L("slaveA"), _L("t_dllwsd")),
|
sl@0
|
462 |
RDllWsd(_L("slaveB"), _L("t_dllwsdd")),
|
sl@0
|
463 |
RDllWsd(_L("slaveC"), _L("t_dllwsdi")),
|
sl@0
|
464 |
RDllWsd(_L("slaveD"), _L("t_dllwsddi"))
|
sl@0
|
465 |
};
|
sl@0
|
466 |
|
sl@0
|
467 |
TRequestStatus req[4];
|
sl@0
|
468 |
TInt ii;
|
sl@0
|
469 |
// start the thrash tests
|
sl@0
|
470 |
for (ii=0; ii<4; ii++)
|
sl@0
|
471 |
{
|
sl@0
|
472 |
slaves[ii].ThrashTest1(req[ii]);
|
sl@0
|
473 |
test.Printf(_L("slave %d thrash started\n"), ii);
|
sl@0
|
474 |
}
|
sl@0
|
475 |
|
sl@0
|
476 |
// show some progress to indicate that things are running
|
sl@0
|
477 |
for (ii=0; ii<8; ii++)
|
sl@0
|
478 |
{
|
sl@0
|
479 |
test.Printf(_L("Waiting %d\n"), ii);
|
sl@0
|
480 |
User::After(1000000);
|
sl@0
|
481 |
}
|
sl@0
|
482 |
// demonstrate that test processes are still doing their stuff
|
sl@0
|
483 |
test.Printf(_L("Still a couple of seconds to wait...\n"));
|
sl@0
|
484 |
|
sl@0
|
485 |
// wait till the test process are done
|
sl@0
|
486 |
for (ii=0; ii<4; ii++)
|
sl@0
|
487 |
{
|
sl@0
|
488 |
User::WaitForRequest(req[ii]);
|
sl@0
|
489 |
// show how much each process did
|
sl@0
|
490 |
test.Printf(_L("Slave %d count = %d\n"), ii, req[ii].Int());
|
sl@0
|
491 |
test_NotNegative(req[ii].Int());
|
sl@0
|
492 |
}
|
sl@0
|
493 |
|
sl@0
|
494 |
for (ii=3; ii>=0; ii--)
|
sl@0
|
495 |
slaves[ii].Close();
|
sl@0
|
496 |
|
sl@0
|
497 |
test.End();
|
sl@0
|
498 |
}
|
sl@0
|
499 |
|
sl@0
|
500 |
void PanicTest()
|
sl@0
|
501 |
{
|
sl@0
|
502 |
test.Start(_L("PanicTest1"));
|
sl@0
|
503 |
|
sl@0
|
504 |
// create a test server/process for each link variant
|
sl@0
|
505 |
RDllWsd slaves[4] =
|
sl@0
|
506 |
{
|
sl@0
|
507 |
RDllWsd(_L("slaveP1"), _L("t_dllwsd")),
|
sl@0
|
508 |
RDllWsd(_L("slaveP2"), _L("t_dllwsdd")),
|
sl@0
|
509 |
RDllWsd(_L("slaveP3"), _L("t_dllwsdi")),
|
sl@0
|
510 |
RDllWsd(_L("slaveP4"), _L("t_dllwsddi"))
|
sl@0
|
511 |
};
|
sl@0
|
512 |
TInt ii;
|
sl@0
|
513 |
for (ii=0; ii<4; ii++)
|
sl@0
|
514 |
slaves[ii].Panic();
|
sl@0
|
515 |
|
sl@0
|
516 |
for (ii=0; ii<4; ii++)
|
sl@0
|
517 |
slaves[ii].Close();
|
sl@0
|
518 |
}
|
sl@0
|
519 |
|
sl@0
|
520 |
void IpcTest()
|
sl@0
|
521 |
{
|
sl@0
|
522 |
test.Start(_L("IPC test"));
|
sl@0
|
523 |
// these two processes will use t_dllwsddi, static link variant
|
sl@0
|
524 |
RDllWsd server(_L("IpcTestServer"));
|
sl@0
|
525 |
RDllWsd client(_L("IpcTestClient"));
|
sl@0
|
526 |
// client will talk to IpcTestServer, ie the server
|
sl@0
|
527 |
test_KErrNone(client.IpcTest());
|
sl@0
|
528 |
client.Close();
|
sl@0
|
529 |
server.Close();
|
sl@0
|
530 |
test.End();
|
sl@0
|
531 |
}
|
sl@0
|
532 |
|
sl@0
|
533 |
TInt MasterMain()
|
sl@0
|
534 |
{
|
sl@0
|
535 |
test.Title();
|
sl@0
|
536 |
test.Start(_L("Test"));
|
sl@0
|
537 |
|
sl@0
|
538 |
BasicTest();
|
sl@0
|
539 |
ThrashTest1();
|
sl@0
|
540 |
IpcTest();
|
sl@0
|
541 |
// PanicTest();
|
sl@0
|
542 |
|
sl@0
|
543 |
test.End();
|
sl@0
|
544 |
return KErrNone;
|
sl@0
|
545 |
}
|
sl@0
|
546 |
|
sl@0
|
547 |
TInt E32Main()
|
sl@0
|
548 |
{
|
sl@0
|
549 |
if (User::CommandLineLength() > 0) // command line contains server name
|
sl@0
|
550 |
return SlaveMain();
|
sl@0
|
551 |
else
|
sl@0
|
552 |
return MasterMain();
|
sl@0
|
553 |
}
|
sl@0
|
554 |
|