author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 31 Aug 2010 16:34:26 +0300 | |
branch | RCL_3 |
changeset 43 | c1f20ce4abcf |
parent 0 | a41df078684a |
child 44 | 3e88ff8f41d5 |
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\thread\t_thread.cpp |
|
15 |
// Overview: |
|
16 |
// Tests the RThread class |
|
17 |
// API Information: |
|
18 |
// RThread, RUndertaker |
|
19 |
// Details: |
|
20 |
// - Create a thread, verify its priority, change the priority and verify results. |
|
21 |
// - Verify naming and renaming threads works as expected. |
|
22 |
// - Test logging on, resuming and closing a thread. Verify results are as expected. |
|
23 |
// - Test creating threads with a variety of invalid parameters. Verify results. |
|
24 |
// - Test the RUndertaker methods: create some threads, logon to the undertaker, |
|
25 |
// verify results upon killing a thread and setting the thread handle. |
|
26 |
// - Check kernel allocation when creating threads and undertakers. Verify the |
|
27 |
// heap has not been corrupted. |
|
28 |
// - Run a thread multiple times, panic within the thread, panic external to the |
|
29 |
// thread and exit a thread in a variety of ways. Verify results are as expected. |
|
30 |
// - Create a semaphore and some threads, verify the threads can wait on and signal |
|
31 |
// the semaphore. |
|
32 |
// - Test unclosed but completed threads. |
|
33 |
// - Suspend and resume some threads in a variety of ways, verify results are as |
|
34 |
// expected. |
|
35 |
// - Test thread duplication. |
|
36 |
// - Test opening a thread using an full name, perform various tests by finding, |
|
37 |
// killing, closing, recreating etc. Verify the results are as expected. |
|
38 |
// - Test creating a thread using a duplicate name then reuse the thread with a |
|
39 |
// valid name. Verify results are as expected. |
|
40 |
// - Verify that a panicked thread releases an existing mutex. |
|
41 |
// - Test thread ID: attempt to open a nonexistent thread by ID, verify different |
|
42 |
// threads have different IDs, verify open by ID works as expected. |
|
43 |
// - Test RThread::StackInfo(), print results and verify results are as expected. |
|
44 |
// Platforms/Drives/Compatibility: |
|
45 |
// All. |
|
46 |
// Assumptions/Requirement/Pre-requisites: |
|
47 |
// Failures and causes: |
|
48 |
// Base Port information: |
|
49 |
// |
|
50 |
// |
|
51 |
||
52 |
#define __E32TEST_EXTENSION__ |
|
53 |
#include <e32test.h> |
|
54 |
#include <e32panic.h> |
|
55 |
#include <e32svr.h> |
|
56 |
#include <u32hal.h> |
|
57 |
#include <e32atomics.h> |
|
58 |
#include <e32def.h> |
|
59 |
#include <e32def_private.h> |
|
60 |
#include "../misc/prbs.h" |
|
61 |
||
62 |
const TInt KNumThreads=20; |
|
63 |
||
64 |
const TInt KExitPanicNum=999; |
|
65 |
const TInt KHeapSize=0x200; |
|
66 |
const TInt KThreadReturnValue=9999; |
|
67 |
const TInt KTerminationReason=1234; |
|
68 |
const TInt KKillReason=4321; |
|
69 |
enum TInstruction {ENormal,EInstrPanic,EWait}; |
|
70 |
||
71 |
const TInt KWaitTime=800000; |
|
72 |
||
73 |
class TReadInfo |
|
74 |
{ |
|
75 |
public: |
|
76 |
TDesC* tdesc; |
|
77 |
TPtrC* tptrc; |
|
78 |
TDes* tdes; |
|
79 |
TPtr* tptr; |
|
80 |
HBufC* hbufc; |
|
81 |
TBufC<0x20>* tbufc; |
|
82 |
TBuf<0x20>* tbuf; |
|
83 |
TPtr* tptrdes; |
|
84 |
TAny* anAddress; |
|
85 |
}; |
|
86 |
||
87 |
LOCAL_D RTest test(_L("T_THREAD")); |
|
88 |
LOCAL_D RTest rtest(_L("Read thread tests")); |
|
89 |
LOCAL_D RTest wtest(_L("Write thread tests")); |
|
90 |
||
91 |
#define rtest(x) rtest(x,__LINE__) |
|
92 |
#define wtest(x) wtest(x,__LINE__) |
|
93 |
||
94 |
LOCAL_C TInt LoopyThread(TAny*) |
|
95 |
{ |
|
96 |
||
97 |
FOREVER |
|
98 |
User::AfterHighRes(1000); |
|
99 |
} |
|
100 |
||
101 |
LOCAL_D void testUndertaker(TOwnerType anOwnerType) |
|
102 |
// |
|
103 |
// Test RThreadWatcher |
|
104 |
// |
|
105 |
{ |
|
106 |
||
107 |
RThread thread1; |
|
108 |
TInt r; |
|
109 |
test.Start(_L("Test the RUndertaker class")); |
|
110 |
test.Next(_L("Create a thread")); |
|
111 |
// if (anOwnerType==EOwnerThread) |
|
112 |
// User::SetDebugMask(0x8000867c); |
|
113 |
r=thread1.Create(_L("Loopy1"),LoopyThread,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)NULL,anOwnerType); |
|
114 |
test(r==KErrNone); |
|
115 |
thread1.Resume(); |
|
116 |
||
117 |
TRequestStatus stat1; |
|
118 |
TInt threadHandle1; |
|
119 |
RThread w1; |
|
120 |
RUndertaker u1; |
|
121 |
test.Next(_L("Create an RUndertaker")); |
|
122 |
r=u1.Create(); |
|
123 |
test(r==KErrNone); |
|
124 |
test.Next(_L("Logon to RUndertaker")); |
|
125 |
r=u1.Logon(stat1,threadHandle1); |
|
126 |
test(r==KErrNone); |
|
127 |
test.Next(_L("Logon again & check we're rejected")); |
|
128 |
r=u1.Logon(stat1,threadHandle1); |
|
129 |
test(r==KErrInUse); |
|
130 |
test.Next(_L("Cancel logon to RUndertaker")); |
|
131 |
r=u1.LogonCancel(); |
|
132 |
test(r==KErrNone); |
|
133 |
test(stat1==KErrCancel); |
|
134 |
||
135 |
test.Next(_L("Logon to RUndertaker again")); |
|
136 |
u1.Logon(stat1,threadHandle1); |
|
137 |
||
138 |
test.Next(_L("Create another thread")); |
|
139 |
RThread thread2; |
|
140 |
r=thread2.Create(_L("Loopy2"),LoopyThread,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)NULL,anOwnerType); |
|
141 |
test(r==KErrNone); |
|
142 |
thread2.Resume(); |
|
143 |
||
144 |
TRequestStatus stat2; |
|
145 |
TInt threadHandle2; |
|
146 |
RThread w2; |
|
147 |
RUndertaker u2; |
|
148 |
test.Next(_L("Create another RUndertaker")); |
|
149 |
r=u2.Create(); |
|
150 |
test(r==KErrNone); |
|
151 |
test.Next(_L("Logon to RUndertaker")); |
|
152 |
r=u2.Logon(stat2,threadHandle2); |
|
153 |
test(r==KErrNone); |
|
154 |
||
155 |
test.Next(_L("Create yet another thread")); |
|
156 |
RThread thread3; |
|
157 |
r=thread3.Create(_L("Loopy3"),LoopyThread,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)NULL,anOwnerType); |
|
158 |
test(r==KErrNone); |
|
159 |
thread3.Resume(); |
|
160 |
||
161 |
test.Next(_L("Kill the first thread & check the undertakers")); |
|
162 |
thread1.Kill(0x489); |
|
163 |
thread1.Close(); |
|
164 |
||
165 |
User::WaitForRequest(stat1); |
|
166 |
User::WaitForRequest(stat2); |
|
167 |
test(stat1==KErrDied); |
|
168 |
test(stat2==KErrDied); |
|
169 |
||
170 |
RThread keep1; |
|
171 |
RThread keep2; |
|
172 |
test.Next(_L("Set the RThread handles")); |
|
173 |
keep1.SetHandle(threadHandle1); |
|
174 |
keep2.SetHandle(threadHandle2); |
|
175 |
||
176 |
test.Next(_L("Test the exit reasons")); |
|
177 |
test(keep1.ExitReason()==0x489); |
|
178 |
test(keep2.ExitReason()==0x489); |
|
179 |
// test.Printf(_L("Thread name %S\n"),&(w1.Name())); |
|
180 |
||
181 |
test.Next(_L("Logon again with both watchers")); |
|
182 |
r=u1.Logon(stat1,threadHandle1); |
|
183 |
test(r==KErrNone); |
|
184 |
r=u2.Logon(stat2,threadHandle2); |
|
185 |
test(r==KErrNone); |
|
186 |
||
187 |
test.Next(_L("Kill the 3rd thread & check the undertakers")); |
|
188 |
thread3.Kill(0x999); |
|
189 |
thread3.Close(); |
|
190 |
||
191 |
User::WaitForRequest(stat1); |
|
192 |
User::WaitForRequest(stat2); |
|
193 |
test(stat1==KErrDied); |
|
194 |
test(stat2==KErrDied); |
|
195 |
||
196 |
test.Next(_L("Set the RThread handles")); |
|
197 |
w1.SetHandle(threadHandle1); |
|
198 |
w2.SetHandle(threadHandle2); |
|
199 |
||
200 |
test.Next(_L("Test the exit reasons")); |
|
201 |
test(w1.ExitReason()==0x999); |
|
202 |
test(w2.ExitReason()==0x999); |
|
203 |
// test.Printf(_L("Thread name %S\n"),&(w1.Name())); |
|
204 |
w1.Close(); |
|
205 |
CLOSE_AND_WAIT(w2); |
|
206 |
||
207 |
test.Next(_L("Logon again with both undertakers")); |
|
208 |
r=u1.Logon(stat1,threadHandle1); |
|
209 |
test(r==KErrNone); |
|
210 |
r=u2.Logon(stat2,threadHandle2); |
|
211 |
test(r==KErrNone); |
|
212 |
||
213 |
test.Next(_L("Kill the 2nd thread & check the undertakers")); |
|
214 |
thread2.Kill(0x707); |
|
215 |
thread2.Close(); |
|
216 |
||
217 |
User::WaitForRequest(stat1); |
|
218 |
User::WaitForRequest(stat2); |
|
219 |
test(stat1==KErrDied); |
|
220 |
test(stat2==KErrDied); |
|
221 |
||
222 |
test.Next(_L("Set the RThread handles")); |
|
223 |
w1.SetHandle(threadHandle1); |
|
224 |
w2.SetHandle(threadHandle2); |
|
225 |
||
226 |
test.Next(_L("Test the exit reasons")); |
|
227 |
test(w1.ExitReason()==0x707); |
|
228 |
test(w2.ExitReason()==0x707); |
|
229 |
// test.Printf(_L("Thread name %S\n"),&(w1.Name())); |
|
230 |
||
231 |
test.Next(_L("Check kernel allocation")); |
|
232 |
test.Next(_L("Please wait while I create & close masses of threads")); |
|
233 |
RThread t[KNumThreads]; |
|
234 |
TInt j; |
|
235 |
for (j=0; j<KNumThreads; j++) |
|
236 |
{ |
|
237 |
TBuf<0x10> name; |
|
238 |
name.Format(_L("LoopyThread%d"),j); |
|
239 |
test(t[j].Create(name, LoopyThread, KDefaultStackSize, KHeapSize, KHeapSize, (TAny*)NULL,anOwnerType)==KErrNone); |
|
240 |
} |
|
241 |
for (j=0; j<KNumThreads-1; j++) |
|
242 |
{ |
|
243 |
t[j].Kill(666); |
|
244 |
CLOSE_AND_WAIT(t[j]); |
|
245 |
} |
|
246 |
||
247 |
test.Next(_L("Please wait while I close & create some undertakers")); |
|
248 |
u1.Close(); |
|
249 |
u2.Close(); |
|
250 |
r=u1.Create(); |
|
251 |
test(r==KErrNone); |
|
252 |
r=u2.Create(); |
|
253 |
test(r==KErrNone); |
|
254 |
||
255 |
test.Next(_L("Mark kernel heap")); |
|
256 |
__KHEAP_MARK; |
|
257 |
||
258 |
test.Next(_L("Create thread")); |
|
259 |
RThread threadx; |
|
260 |
r=threadx.Create(_L("Loopyx"),LoopyThread,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)NULL,anOwnerType); |
|
261 |
test(r==KErrNone); |
|
262 |
test.Next(_L("Resume thread")); |
|
263 |
threadx.Resume(); |
|
264 |
||
265 |
test.Next(_L("Create undertaker")); |
|
266 |
TRequestStatus statx; |
|
267 |
TInt threadHandlex; |
|
268 |
RUndertaker ux; |
|
269 |
r=ux.Create(); |
|
270 |
test(r==KErrNone); |
|
271 |
test.Next(_L("Logon to undertaker")); |
|
272 |
r=ux.Logon(statx,threadHandlex); |
|
273 |
test(r==KErrNone); |
|
274 |
test.Next(_L("Kill thread")); |
|
275 |
threadx.Kill(0x666); |
|
276 |
threadx.Close(); |
|
277 |
User::WaitForRequest(statx); |
|
278 |
test(statx==KErrDied); |
|
279 |
test.Next(_L("Close thread")); |
|
280 |
RThread wx; |
|
281 |
wx.SetHandle(threadHandlex); |
|
282 |
CLOSE_AND_WAIT(wx); |
|
283 |
||
284 |
test.Next(_L("Close undertaker")); |
|
285 |
ux.Close(); |
|
286 |
||
287 |
test.Next(_L("Check kernel heap")); |
|
288 |
__KHEAP_MARKEND; |
|
289 |
w1.Close(); |
|
290 |
CLOSE_AND_WAIT(w2); |
|
291 |
keep1.Close(); |
|
292 |
CLOSE_AND_WAIT(keep2); |
|
293 |
t[KNumThreads-1].Kill(666); |
|
294 |
CLOSE_AND_WAIT(t[KNumThreads-1]); |
|
295 |
||
296 |
test.Next(_L("Close RUndertakers")); |
|
297 |
u1.Close(); |
|
298 |
u2.Close(); |
|
299 |
test.End(); |
|
300 |
} |
|
301 |
||
302 |
volatile TInt IFLAG; |
|
303 |
||
304 |
TInt InstructionThread(TAny* anInstruction) |
|
305 |
{ |
|
306 |
__e32_atomic_store_ord32(&IFLAG, 1); |
|
307 |
RThread::Rendezvous(KErrNone); |
|
308 |
TInstruction what=(TInstruction)(TInt)anInstruction; |
|
309 |
if (what==EInstrPanic) |
|
310 |
User::Panic(_L("Hello"), KExitPanicNum); |
|
311 |
if (what==ENormal) |
|
312 |
return(KThreadReturnValue); |
|
313 |
User::After(500000); |
|
314 |
return(KErrNone); |
|
315 |
} |
|
316 |
||
317 |
TInt StartInstructionThread(RThread& aT, const TDesC& aName, TInt aInstruction, TOwnerType aOwnerType, TRequestStatus* aL, TRequestStatus* aR) |
|
318 |
{ |
|
319 |
TInt r = aT.Create(aName, &InstructionThread, KDefaultStackSize, KHeapSize, KHeapSize, (TAny*)aInstruction, aOwnerType); |
|
320 |
if (r!=KErrNone) |
|
321 |
return r; |
|
322 |
if (aL) |
|
323 |
{ |
|
324 |
aT.Logon(*aL); |
|
325 |
TInt s = aL->Int(); |
|
326 |
test_Equal(s, KRequestPending); |
|
327 |
} |
|
328 |
if (aR) |
|
329 |
{ |
|
330 |
aT.Rendezvous(*aR); |
|
331 |
TInt s = aR->Int(); |
|
332 |
test_Equal(s, KRequestPending); |
|
333 |
aT.Resume(); |
|
334 |
User::WaitForRequest(*aR); |
|
335 |
s = aR->Int(); |
|
336 |
test_KErrNone(s); |
|
337 |
} |
|
338 |
return r; |
|
339 |
} |
|
340 |
||
341 |
||
342 |
LOCAL_D TInt test4Thread(TAny *aSem) |
|
343 |
// |
|
344 |
// Wait to be released on the semaphore. |
|
345 |
// Then release the semaphore. |
|
346 |
// |
|
347 |
{ |
|
348 |
||
349 |
RSemaphore& sem=(*(RSemaphore*)aSem); |
|
350 |
sem.Wait(); |
|
351 |
sem.Signal(); |
|
352 |
return(KErrNone); |
|
353 |
} |
|
354 |
||
355 |
TInt BadPriority(TAny* aThread) |
|
356 |
{ |
|
357 |
((RThread*)aThread)->SetPriority(EPriorityNull); |
|
358 |
return KErrNone; |
|
359 |
} |
|
360 |
||
361 |
_LIT(KLitRomString,"RomStringRomStringRomStringRomStringRomStringRomStringRomString"); |
|
362 |
||
363 |
LOCAL_C TInt BadFullNameThread(TAny* aPar) |
|
364 |
{ |
|
365 |
RThread thread; |
|
366 |
||
367 |
switch ((TInt)aPar) |
|
368 |
{ |
|
369 |
case 0: |
|
370 |
{ |
|
371 |
HBufC* hBuf = HBufC::New(5);//Size 5 is not sufficient. thread.FullName should panic. |
|
372 |
test(NULL != hBuf); |
|
373 |
RBuf rBuf(hBuf); |
|
374 |
thread.FullName(rBuf); |
|
375 |
rBuf.Close(); |
|
376 |
} |
|
377 |
return(KErrNone); |
|
378 |
||
379 |
case 1: |
|
380 |
{ |
|
381 |
TPtr ptr((TText*)(KLitRomString.iBuf), KLitRomString.iTypeLength); |
|
382 |
// Passing descriptor whose data is in ROM. This may behave in different ways |
|
383 |
// on differrent platforms. Here, we just check that Kernel is safe. |
|
384 |
thread.FullName(ptr); |
|
385 |
} |
|
386 |
return(KErrNone); |
|
387 |
} |
|
388 |
return(KErrArgument); |
|
389 |
} |
|
390 |
||
391 |
||
392 |
LOCAL_D void test1() |
|
393 |
// |
|
394 |
// Test 1 |
|
395 |
// |
|
396 |
{ |
|
397 |
||
398 |
__UHEAP_MARK; |
|
399 |
RThread thread; |
|
400 |
TRequestStatus stat; |
|
401 |
TInt r; |
|
402 |
||
403 |
test.Start(_L("Close without create")); |
|
404 |
thread.Close(); |
|
405 |
||
406 |
test.Next(_L("Create ENormal")); |
|
407 |
r = StartInstructionThread(thread, _L("Thread"), ENormal, EOwnerProcess, 0, 0); |
|
408 |
test_KErrNone(r); |
|
409 |
||
410 |
test.Next(_L("Test priorities")); |
|
411 |
test(thread.Priority()==EPriorityNormal); |
|
412 |
thread.SetPriority(EPriorityRealTime); // WINS will commute this to EPriorityMuchMore |
|
413 |
#if defined(__EPOC32__) |
|
414 |
test(thread.Priority()==EPriorityRealTime); |
|
415 |
#endif |
|
416 |
thread.SetPriority(EPriorityMuchMore); |
|
417 |
test(thread.Priority()==EPriorityMuchMore); |
|
418 |
// thread.SetPriority(EPriorityNull); |
|
419 |
RThread badThread; |
|
420 |
r = badThread.Create(_L("Bad Priority"),BadPriority,KDefaultStackSize,KHeapSize,KHeapSize,&thread); |
|
421 |
test(r==KErrNone); |
|
422 |
badThread.Logon(stat); |
|
423 |
test(stat==KRequestPending); |
|
424 |
badThread.Resume(); |
|
425 |
User::WaitForRequest(stat); |
|
426 |
test(stat==EBadPriority); |
|
427 |
test(badThread.ExitCategory()==_L("KERN-EXEC")); |
|
428 |
test(badThread.ExitReason()==EBadPriority); |
|
429 |
test(badThread.ExitType()==EExitPanic); |
|
430 |
CLOSE_AND_WAIT(badThread); |
|
431 |
test(thread.Priority()==EPriorityMuchMore); |
|
432 |
||
433 |
#if defined(__EPOC32__) |
|
434 |
test.Next(_L("Test setting process priority from thread")); |
|
435 |
test(thread.ProcessPriority()==EPriorityForeground); |
|
436 |
thread.SetProcessPriority(EPriorityHigh); |
|
437 |
test(thread.ProcessPriority()==EPriorityHigh); |
|
438 |
test(RProcess().Priority()==EPriorityHigh); |
|
439 |
thread.SetProcessPriority(EPriorityForeground); |
|
440 |
test(thread.ProcessPriority()==EPriorityForeground); |
|
441 |
test(RProcess().Priority()==EPriorityForeground); |
|
442 |
#endif |
|
443 |
||
444 |
TBuf<0x100> name; |
|
445 |
test.Next(_L("Test thread name")); |
|
446 |
test(thread.Name()==_L("Thread")); |
|
447 |
test.Next(_L("Get owning process name")); |
|
448 |
RProcess p; |
|
449 |
test(thread.Process(p)==KErrNone); |
|
450 |
name=p.Name(); |
|
451 |
name.Append(_L("::")); |
|
452 |
name.Append(thread.Name()); |
|
453 |
test.Next(_L("Test fullname - via TFullName RHandleBase::FullName")); |
|
454 |
test(thread.FullName().CompareF(name)==0); |
|
455 |
||
456 |
test.Next(_L("Test fullname - via void RHandleBase::FullName(TDes& aName)")); |
|
457 |
HBufC* hBuf = HBufC::New(100); |
|
458 |
test(NULL != hBuf); |
|
459 |
TPtr ptr = hBuf->Des(); |
|
460 |
thread.FullName(ptr); |
|
461 |
test(ptr.CompareF(name)==0); |
|
462 |
RBuf rBuf(hBuf); |
|
463 |
thread.FullName(rBuf); |
|
464 |
test(rBuf.CompareF(name)==0); |
|
465 |
rBuf.Close(); |
|
466 |
||
467 |
test.Next(_L("Test void RHandleBase::FullName(TDes& aName) when aName is too short")); |
|
468 |
TInt aaa=badThread.Create(_L("BadFullNameThread1"),BadFullNameThread,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)0); |
|
469 |
test(aaa==KErrNone); |
|
470 |
badThread.Logon(stat); |
|
471 |
test(badThread.ExitType()==EExitPending); |
|
472 |
badThread.Resume(); |
|
473 |
User::WaitForRequest(stat); |
|
474 |
test(badThread.ExitCategory()==_L("KERN-EXEC")); |
|
475 |
test(badThread.ExitReason()==EKUDesSetLengthOverflow); |
|
476 |
test(badThread.ExitType()==EExitPanic); |
|
477 |
CLOSE_AND_WAIT(badThread); |
|
478 |
||
479 |
test.Next(_L("Test void RHandleBase::FullName(TDes& aName) where aName has data in ROM ")); |
|
480 |
aaa=badThread.Create(_L("BadFullNameThread2"),BadFullNameThread,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)1); |
|
481 |
test(aaa==KErrNone); |
|
482 |
badThread.Logon(stat); |
|
483 |
test(badThread.ExitType()==EExitPending); |
|
484 |
badThread.Resume(); |
|
485 |
User::WaitForRequest(stat); |
|
486 |
test.Printf(_L("BadFullNameThread2 exited with ExitReason=%d and ExitType=%d\n"),badThread.ExitReason(),badThread.ExitType()); |
|
487 |
CLOSE_AND_WAIT(badThread); |
|
488 |
||
489 |
test.Next(_L("Rename current thread")); |
|
490 |
test(User::RenameThread(_L("renamed"))==KErrNone); |
|
491 |
name=p.Name(); |
|
492 |
name.Append(_L("::")); |
|
493 |
RThread me; |
|
494 |
name.Append(me.Name()); |
|
495 |
test(me.Name()==_L("renamed")); |
|
496 |
test(me.FullName().CompareF(name)==0); |
|
497 |
||
498 |
test.Next(_L("Test running exit types")); |
|
499 |
test(thread.ExitType()==EExitPending); |
|
500 |
test(thread.ExitReason()==0); |
|
501 |
// no getters for iUserHeap and iFrame |
|
502 |
test(thread.ExitCategory()==KNullDesC); |
|
503 |
||
504 |
test.Next(_L("Test logging on")); |
|
505 |
thread.Logon(stat); |
|
506 |
RThread t; |
|
507 |
test(t.RequestCount()==0); |
|
508 |
test(stat==KRequestPending); |
|
509 |
r=thread.LogonCancel(stat); // this generates a signal |
|
510 |
test(r==KErrNone); |
|
511 |
test(stat==KErrNone); |
|
512 |
test(t.RequestCount()==1); // the request count is 1 due to the signal generated by LogonCancel |
|
513 |
test(thread.RequestCount()==0); |
|
514 |
||
515 |
test.Next(_L("Resuming thread")); |
|
516 |
thread.Resume(); |
|
517 |
test.Next(_L("Absorb cancel")); |
|
518 |
User::WaitForRequest(stat); |
|
519 |
test.Next(_L("Test LogonCancel on dead thread is ok")); |
|
520 |
r=thread.LogonCancel(stat); |
|
521 |
test(r==KErrGeneral); |
|
522 |
test.Next(_L("Close thread")); |
|
523 |
CLOSE_AND_WAIT(thread); |
|
524 |
test.Next(_L("Close again")); |
|
525 |
thread.Close(); |
|
526 |
thread.Close(); |
|
527 |
thread.Close(); |
|
528 |
thread.Close(); |
|
529 |
__UHEAP_MARKEND; |
|
530 |
test.End(); |
|
531 |
} |
|
532 |
||
533 |
||
534 |
LOCAL_D void test2(TOwnerType anOwnerType) |
|
535 |
// |
|
536 |
// Test 2 |
|
537 |
// |
|
538 |
{ |
|
539 |
||
540 |
__UHEAP_MARK; |
|
541 |
RThread thread; |
|
542 |
TRequestStatus stat; |
|
543 |
TRequestStatus rstat; |
|
544 |
TInt r; |
|
545 |
||
546 |
test.Start(_L("Run thread 10 times")); |
|
547 |
for (TInt xx=0;xx<10;xx++) |
|
548 |
{ |
|
549 |
test.Printf(_L("\r%02d"),xx); |
|
550 |
r = StartInstructionThread(thread, _L("Thread1"), ENormal, anOwnerType, &stat, 0); |
|
551 |
test_KErrNone(r); |
|
552 |
thread.Resume(); |
|
553 |
User::WaitForRequest(stat); |
|
554 |
CLOSE_AND_WAIT(thread); |
|
555 |
} |
|
556 |
test.Printf(_L("\n")); |
|
557 |
||
558 |
test.Next(_L("Panic within thread")); |
|
559 |
r = StartInstructionThread(thread, _L("Thread2"), EInstrPanic, anOwnerType, &stat, 0); |
|
560 |
test_KErrNone(r); |
|
561 |
test(thread.ExitType()==EExitPending); |
|
562 |
thread.Resume(); |
|
563 |
User::WaitForRequest(stat); |
|
564 |
test(thread.ExitCategory()==_L("Hello")); |
|
565 |
test(thread.ExitReason()==KExitPanicNum); |
|
566 |
test(thread.ExitType()==EExitPanic); |
|
567 |
CLOSE_AND_WAIT(thread); |
|
568 |
||
569 |
test.Next(_L("Panic external to thread")); |
|
570 |
TInt ijk; |
|
571 |
TUint seed[2] = { 0xadf85458, 0 }; |
|
572 |
TUint maxcount = 0; |
|
573 |
for (ijk=0; ijk<8192; ++ijk) |
|
574 |
{ |
|
575 |
if (!(ijk&255)) |
|
576 |
test.Printf(_L("%d\n"), ijk); |
|
577 |
r = StartInstructionThread(thread, _L("Thread3"), EWait, anOwnerType, &stat, 0); |
|
578 |
test_KErrNone(r); |
|
579 |
__e32_atomic_store_ord32(&IFLAG, 0); |
|
580 |
thread.Resume(); |
|
581 |
thread.SetPriority(EPriorityMore); |
|
582 |
if (maxcount==0) |
|
583 |
{ |
|
584 |
while (__e32_atomic_load_acq32(&IFLAG)==0 && --maxcount!=0) |
|
585 |
{ |
|
586 |
} |
|
587 |
maxcount = 0u - maxcount; |
|
588 |
test.Printf(_L("maxcount=%u\n"), maxcount); |
|
589 |
} |
|
590 |
else |
|
591 |
{ |
|
592 |
TUint random = Random(seed); |
|
593 |
random %= maxcount; |
|
594 |
++random; |
|
595 |
while (__e32_atomic_load_acq32(&IFLAG)==0 && --random!=0) |
|
596 |
{ |
|
597 |
} |
|
598 |
} |
|
599 |
thread.Panic(_L("panic"), 123); |
|
600 |
User::WaitForRequest(stat); |
|
601 |
test(thread.ExitCategory()==_L("panic")); |
|
602 |
test(thread.ExitReason()==123); |
|
603 |
test(thread.ExitType()==EExitPanic); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
604 |
r = RTest::CloseHandleAndWaitForDestruction(thread); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
605 |
test_KErrNone(r); |
0 | 606 |
} |
607 |
||
608 |
test.Next(_L("Internal exit")); |
|
609 |
r = StartInstructionThread(thread, _L("Thread4"), ENormal, anOwnerType, &stat, 0); |
|
610 |
test_KErrNone(r); |
|
611 |
test(thread.ExitType()==EExitPending); |
|
612 |
thread.Resume(); |
|
613 |
User::WaitForRequest(stat); |
|
614 |
test(thread.ExitCategory()==_L("Kill")); |
|
615 |
test(thread.ExitReason()==KThreadReturnValue); |
|
616 |
test(thread.ExitType()==EExitKill); |
|
617 |
CLOSE_AND_WAIT(thread); |
|
618 |
||
619 |
test.Next(_L("External terminate")); |
|
620 |
r = StartInstructionThread(thread, _L("Thread5"), EWait, anOwnerType, &stat, &rstat); |
|
621 |
test_KErrNone(r); |
|
622 |
test.Next(_L("Terminate")); |
|
623 |
thread.Terminate(KTerminationReason); |
|
624 |
test.Next(_L("Wait")); |
|
625 |
User::WaitForRequest(stat); |
|
626 |
test(thread.ExitCategory()==_L("Terminate")); |
|
627 |
test(thread.ExitReason()==KTerminationReason); |
|
628 |
test(thread.ExitType()==EExitTerminate); |
|
629 |
test.Next(_L("Close")); |
|
630 |
CLOSE_AND_WAIT(thread); |
|
631 |
||
632 |
test.Next(_L("External kill")); |
|
633 |
r = StartInstructionThread(thread, _L("Thread6"), EWait, anOwnerType, &stat, &rstat); |
|
634 |
test_KErrNone(r); |
|
635 |
thread.Suspend(); |
|
636 |
thread.Resume(); |
|
637 |
thread.Kill(KKillReason); |
|
638 |
User::WaitForRequest(stat); |
|
639 |
test(thread.ExitCategory()==_L("Kill")); |
|
640 |
test(thread.ExitReason()==KKillReason); |
|
641 |
test(thread.ExitType()==EExitKill); |
|
642 |
test.Next(_L("Kill again")); |
|
643 |
thread.Kill(KErrNone); |
|
644 |
thread.Kill(KErrNone); |
|
645 |
thread.Kill(KErrNone); |
|
646 |
CLOSE_AND_WAIT(thread); |
|
647 |
test.End(); |
|
648 |
__UHEAP_MARKEND; |
|
649 |
} |
|
650 |
||
651 |
LOCAL_D void test3() |
|
652 |
// |
|
653 |
// Test 3. |
|
654 |
// |
|
655 |
{ |
|
656 |
||
657 |
test.Start(_L("Read across thread")); |
|
658 |
TReadInfo info; |
|
659 |
TPtrC des1=_L("tdesc"); |
|
660 |
info.tdesc=(&des1); |
|
661 |
TPtrC ptr1=_L("tptrc"); |
|
662 |
info.tptrc=&ptr1; |
|
663 |
TBuf<0x20> tdes(_L("tdes")); |
|
664 |
info.tdes=&tdes; |
|
665 |
TBuf<0x20> tptrbuf(_L("tptr")); |
|
666 |
TPtr tptr((TText*)tptrbuf.Ptr(),tptrbuf.Length(),tptrbuf.MaxLength()); |
|
667 |
info.tptr=&tptr; |
|
668 |
TBuf<0x20> hbufc(_L("hbufc")); |
|
669 |
HBufC *pH=hbufc.Alloc(); |
|
670 |
test(pH!=NULL); |
|
671 |
info.hbufc=pH; |
|
672 |
TBufC<0x20> tbufc(_L("tbufc")); |
|
673 |
info.tbufc=&tbufc; |
|
674 |
TBuf<0x20> tbuf(_L("tbuf")); |
|
675 |
info.tbuf=&tbuf; |
|
676 |
TBufC<0x20> tptrdes(_L("tptrdes")); |
|
677 |
TPtr des=tptrdes.Des(); |
|
678 |
info.tptrdes=&des; |
|
679 |
TBuf<0x10> b(_L("Hello")); |
|
680 |
info.anAddress=(&b); |
|
681 |
info.anAddress= info.anAddress; //prevents warning (var set but never used) |
|
682 |
delete pH; |
|
683 |
test.End(); |
|
684 |
} |
|
685 |
||
686 |
LOCAL_D void test4() |
|
687 |
// |
|
688 |
// Test 4. |
|
689 |
// |
|
690 |
{ |
|
691 |
||
692 |
test.Start(_L("Create sempahore")); |
|
693 |
RSemaphore sem; |
|
694 |
TInt r=sem.CreateLocal(0); |
|
695 |
test(r==KErrNone); |
|
696 |
// |
|
697 |
test.Next(_L("Create thread 1")); |
|
698 |
RThread t; |
|
699 |
r=t.Create(_L("Thread1"),test4Thread,KDefaultStackSize,KHeapSize,KHeapSize,&sem); |
|
700 |
test(r==KErrNone); |
|
701 |
t.Resume(); |
|
702 |
t.Close(); |
|
703 |
// |
|
704 |
test.Next(_L("Create thread 2")); |
|
705 |
r=t.Create(_L("Thread2"),test4Thread,KDefaultStackSize,KHeapSize,KHeapSize,&sem); |
|
706 |
test(r==KErrNone); |
|
707 |
t.Resume(); |
|
708 |
t.Close(); |
|
709 |
// |
|
710 |
test.Next(_L("Create thread 3")); |
|
711 |
r=t.Create(_L("Thread3"),test4Thread,KDefaultStackSize,KHeapSize,KHeapSize,&sem); |
|
712 |
test(r==KErrNone); |
|
713 |
t.Resume(); |
|
714 |
t.Close(); |
|
715 |
// |
|
716 |
test.Next(_L("Release threads")); |
|
717 |
sem.Signal(3); |
|
718 |
// |
|
719 |
test.Next(_L("Wait 1")); |
|
720 |
sem.Wait(); |
|
721 |
// |
|
722 |
test.Next(_L("Wait 2")); |
|
723 |
sem.Wait(); |
|
724 |
// |
|
725 |
test.Next(_L("Wait 2")); |
|
726 |
sem.Wait(); |
|
727 |
sem.Close(); |
|
728 |
// |
|
729 |
test.End(); |
|
730 |
} |
|
731 |
||
732 |
TInt MinimalThread(TAny*) |
|
733 |
// |
|
734 |
// Minimal thread, used in test 5 |
|
735 |
// |
|
736 |
{ |
|
737 |
return(KErrNone); |
|
738 |
} |
|
739 |
||
740 |
LOCAL_D void test5() |
|
741 |
// |
|
742 |
// Test 5 - tests unclosed but completed threads |
|
743 |
// |
|
744 |
{ |
|
745 |
||
746 |
test.Start(_L("Start thread")); |
|
747 |
RThread thread1; |
|
748 |
test(thread1.Create(_L("Test Thread1"),MinimalThread,KDefaultStackSize,KHeapSize,KHeapSize,NULL)==KErrNone); |
|
749 |
TRequestStatus stat1; |
|
750 |
thread1.Logon(stat1); |
|
751 |
thread1.Resume(); |
|
752 |
User::WaitForRequest(stat1); |
|
753 |
test(thread1.ExitType()==EExitKill); |
|
754 |
// 'missing' thread1.Close(); |
|
755 |
||
756 |
test.Next(_L("Start another thread")); |
|
757 |
RThread thread2; |
|
758 |
test(thread2.Create(_L("Test Thread2"),MinimalThread,KDefaultStackSize,KHeapSize,KHeapSize,NULL)==KErrNone); |
|
759 |
TRequestStatus stat2; |
|
760 |
thread2.Logon(stat2); |
|
761 |
thread2.Resume(); |
|
762 |
User::WaitForRequest(stat2); //Goes wrong here in build 48 |
|
763 |
test(thread2.ExitType()==EExitKill); |
|
764 |
||
765 |
test.Next(_L("Close both threads")); |
|
766 |
CLOSE_AND_WAIT(thread2); |
|
767 |
CLOSE_AND_WAIT(thread1); |
|
768 |
||
769 |
test.End(); |
|
770 |
} |
|
771 |
||
772 |
LOCAL_D TInt test6Thread(TAny *anArg) |
|
773 |
// |
|
774 |
// |
|
775 |
// |
|
776 |
{ |
|
777 |
((RSemaphore*)anArg)->Wait(); |
|
778 |
RThread t; |
|
779 |
RThread dup; |
|
780 |
dup.Duplicate(t); |
|
781 |
dup.Panic(_L("Test"),0); |
|
782 |
||
783 |
return KErrNone; |
|
784 |
} |
|
785 |
||
786 |
void test6() |
|
787 |
// |
|
788 |
// Test thread duplication |
|
789 |
// |
|
790 |
{ |
|
791 |
||
792 |
test.Start(_L("Create thread")); |
|
793 |
RSemaphore sem; |
|
794 |
TInt r=sem.CreateLocal(0); |
|
795 |
test(r==KErrNone); |
|
796 |
||
797 |
RThread t; |
|
798 |
t.Create(_L("test6thread"),test6Thread,KDefaultStackSize,KHeapSize,KHeapSize,&sem); |
|
799 |
test.Next(_L("Resume thread")); |
|
800 |
TRequestStatus stat; |
|
801 |
t.Logon(stat); |
|
802 |
t.Resume(); |
|
803 |
sem.Signal(); |
|
804 |
User::WaitForRequest(stat); |
|
805 |
test.Next(_L("Close thread")); |
|
806 |
t.Close(); |
|
807 |
sem.Close(); |
|
808 |
test.End(); |
|
809 |
} |
|
810 |
||
811 |
RSemaphore gsem; |
|
812 |
enum TThreadProgress { EBeforeStart, EStarted, EWaiting, EDoneWaiting, EFinished }; |
|
813 |
TThreadProgress progress=EBeforeStart; |
|
814 |
LOCAL_D TInt test7thread(TAny * /*anArg*/) |
|
815 |
// |
|
816 |
// |
|
817 |
// |
|
818 |
{ |
|
819 |
||
820 |
progress=EStarted; |
|
821 |
progress=EWaiting; |
|
822 |
gsem.Wait(); |
|
823 |
progress=EDoneWaiting; |
|
824 |
gsem.Wait(); |
|
825 |
progress=EFinished; |
|
826 |
return KErrNone; |
|
827 |
} |
|
828 |
||
829 |
void test7() |
|
830 |
// |
|
831 |
// Suspend/ Resume tests |
|
832 |
// |
|
833 |
{ |
|
834 |
||
835 |
TInt r=gsem.CreateLocal(0); |
|
836 |
test(r==KErrNone); |
|
837 |
test.Start(_L("Create thread")); |
|
838 |
RThread t; |
|
839 |
r=t.Create(_L("test7thread"), test7thread, KDefaultStackSize,KHeapSize,KHeapSize,NULL); |
|
840 |
test(r==KErrNone); |
|
841 |
TRequestStatus stat; |
|
842 |
t.Logon(stat); |
|
843 |
test.Next(_L("Resume thread")); |
|
844 |
t.Resume(); |
|
845 |
User::After(KWaitTime); // wait a bit; |
|
846 |
test.Next(_L("Make thread wait on a semaphore")); |
|
847 |
test(progress==EWaiting); |
|
848 |
test.Next(_L("Suspend waiting thread")); |
|
849 |
t.Suspend(); |
|
850 |
test.Next(_L("Signal the semaphore")); |
|
851 |
gsem.Signal(); |
|
852 |
User::After(KWaitTime); |
|
853 |
test.Next(_L("Test thread still suspended")); |
|
854 |
test(progress==EWaiting); |
|
855 |
test.Next(_L("resume thread")); |
|
856 |
t.Resume(); |
|
857 |
test.Next(_L("Test the thread no longer waiting on the semaphore")); |
|
858 |
User::After(KWaitTime); |
|
859 |
test(progress==EDoneWaiting); |
|
860 |
test.Next(_L("Wait for thread to finish")); |
|
861 |
gsem.Signal(); |
|
862 |
User::WaitForRequest(stat); |
|
863 |
test(stat==KErrNone); |
|
864 |
test(progress==EFinished); |
|
865 |
CLOSE_AND_WAIT(t); |
|
866 |
||
867 |
RThread tt; |
|
868 |
progress=EBeforeStart; |
|
869 |
test.Next(_L("Create Thread")); |
|
870 |
r=tt.Create(_L("test7thread"), test7thread, KDefaultStackSize,KHeapSize,KHeapSize,NULL); |
|
871 |
test(r==KErrNone); |
|
872 |
tt.Logon(stat); |
|
873 |
test.Next(_L("Suspend thread without starting it")); |
|
874 |
tt.Suspend(); |
|
875 |
tt.Suspend(); |
|
876 |
test.Next(_L("Resume and test suspend/resume balance")); |
|
877 |
tt.Resume(); |
|
878 |
tt.Resume(); |
|
879 |
User::After(KWaitTime); |
|
880 |
test(progress==EBeforeStart); |
|
881 |
tt.Resume(); |
|
882 |
test.Next(_L("test thread is suspended on semaphore")); |
|
883 |
User::After(KWaitTime); |
|
884 |
test(progress==EWaiting); |
|
885 |
test.Next(_L("suspend thread")); |
|
886 |
tt.Suspend(); |
|
887 |
tt.Suspend(); |
|
888 |
test.Next(_L("resume thread")); |
|
889 |
tt.Resume(); |
|
890 |
tt.Resume(); |
|
891 |
test.Next(_L("test thread still suspended on semaphore")); |
|
892 |
User::After(KWaitTime); |
|
893 |
test(progress==EWaiting); |
|
894 |
test.Next(_L("Suspend, Suspend, Signal semaphore, Suspend")); |
|
895 |
tt.Suspend(); |
|
896 |
tt.Suspend(); |
|
897 |
gsem.Signal(); |
|
898 |
tt.Suspend(); |
|
899 |
test.Next(_L("test thread still suspended on semaphore")); |
|
900 |
User::After(KWaitTime); |
|
901 |
test(progress==EWaiting); |
|
902 |
test.Next(_L("Resume thread, checking suspend/resume balance")); |
|
903 |
tt.Resume(); |
|
904 |
User::After(KWaitTime); |
|
905 |
test(progress==EWaiting); |
|
906 |
tt.Resume(); |
|
907 |
User::After(KWaitTime); |
|
908 |
test(progress==EWaiting); |
|
909 |
tt.Resume(); |
|
910 |
User::After(KWaitTime); |
|
911 |
test(progress==EDoneWaiting); |
|
912 |
test.Next(_L("Resume an executing thread")); |
|
913 |
tt.Resume(); |
|
914 |
tt.Resume(); |
|
915 |
// test.Next(_L("Suspend and check balance")); |
|
916 |
// tt.Suspend(); |
|
917 |
// tt.Suspend(); |
|
918 |
test.Next(_L("Wait for thread to finish")); |
|
919 |
gsem.Signal(); |
|
920 |
User::After(KWaitTime); |
|
921 |
test(progress==EFinished); |
|
922 |
User::WaitForRequest(stat); |
|
923 |
CLOSE_AND_WAIT(tt); |
|
924 |
||
925 |
// |
|
926 |
test.Next(_L("Create Thread")); |
|
927 |
r=tt.Create(_L("test7thread"), test7thread, KDefaultStackSize,KHeapSize,KHeapSize,NULL); |
|
928 |
test(r==KErrNone); |
|
929 |
tt.Logon(stat); |
|
930 |
test.Next(_L("Resume")); |
|
931 |
tt.Resume(); |
|
932 |
test.Next(_L("Hang thread on semaphore")); |
|
933 |
User::After(KWaitTime); |
|
934 |
test(progress==EWaiting); |
|
935 |
test.Next(_L("Suspend then Resume thread")); |
|
936 |
tt.Suspend(); |
|
937 |
tt.Suspend(); |
|
938 |
tt.Resume(); |
|
939 |
User::After(KWaitTime); |
|
940 |
test(progress==EWaiting); |
|
941 |
tt.Resume(); |
|
942 |
test.Next(_L("Check still hanging on semaphore")); |
|
943 |
User::After(KWaitTime); |
|
944 |
test(progress==EWaiting); |
|
945 |
test.Next(_L("Signal Semaphore")); |
|
946 |
gsem.Signal(); |
|
947 |
test.Next(_L("Test thread executing again")); |
|
948 |
User::After(KWaitTime); |
|
949 |
test(progress==EDoneWaiting); |
|
950 |
test.Next(_L("Hang thread on another semaphore, and suspend")); |
|
951 |
tt.Suspend(); |
|
952 |
test.Next(_L("Signal semaphore, and suspend again")); |
|
953 |
gsem.Signal(); |
|
954 |
User::After(KWaitTime); |
|
955 |
test(progress==EDoneWaiting); |
|
956 |
tt.Suspend(); |
|
957 |
test.Next(_L("Resume the thread")); |
|
958 |
tt.Resume(); |
|
959 |
User::After(KWaitTime); |
|
960 |
test(progress==EDoneWaiting); |
|
961 |
tt.Resume(); |
|
962 |
test.Next(_L("Wait for thread to finish")); |
|
963 |
User::After(KWaitTime); |
|
964 |
test(progress==EFinished); |
|
965 |
User::WaitForRequest(stat); |
|
966 |
CLOSE_AND_WAIT(tt); |
|
967 |
test.End(); |
|
968 |
} |
|
969 |
||
970 |
#if 0 |
|
971 |
RSemaphore Sem; |
|
972 |
LOCAL_D TInt test8thread(TAny* aPtr) |
|
973 |
// |
|
974 |
// |
|
975 |
// |
|
976 |
{ |
|
977 |
||
978 |
typedef TBuf<0x20> TTestBuf; |
|
979 |
typedef volatile TTestBuf* TTestBufPtr; |
|
980 |
volatile TTestBufPtr& pB=*(volatile TTestBufPtr*)aPtr; |
|
981 |
if ((TUint)pB != 0xc90fdaa2) |
|
982 |
return KErrGeneral; |
|
983 |
Sem.Wait(); |
|
984 |
TDesC* pD=(TDesC*)pB; |
|
985 |
test(*pD==_L("Everything's just hunky-dory")); |
|
986 |
delete (TTestBufPtr*)pB; |
|
987 |
__UHEAP_MARKEND; |
|
988 |
return KErrNone; |
|
989 |
} |
|
990 |
#endif |
|
991 |
||
992 |
void test8() |
|
993 |
// |
|
994 |
// Get Heap |
|
995 |
// |
|
996 |
{ |
|
997 |
// !!! RThread::SetInitialParameter no longer exists |
|
998 |
||
999 |
/* |
|
1000 |
typedef TBuf<0x20> TTestBuf; |
|
1001 |
TTestBuf* buf=(TTestBuf*)0xc90fdaa2; |
|
1002 |
||
1003 |
test.Start(_L("Create thread")); |
|
1004 |
RThread thread; |
|
1005 |
TInt r=thread.Create(_L("test8thread"),test8thread,KDefaultStackSize,KHeapSize,KHeapSize,NULL); |
|
1006 |
test(r==KErrNone); |
|
1007 |
r=Sem.CreateLocal(0); |
|
1008 |
test(r==KErrNone); |
|
1009 |
test.Next(_L("Set parameter")); |
|
1010 |
r=thread.SetInitialParameter(&buf); |
|
1011 |
test(r==KErrNone); |
|
1012 |
TRequestStatus stat; |
|
1013 |
thread.Logon(stat); |
|
1014 |
thread.SetPriority(EPriorityMore); |
|
1015 |
test.Next(_L("Resume thread")); |
|
1016 |
thread.Resume(); |
|
1017 |
test.Next(_L("Set initial parameter NULL")); |
|
1018 |
r=thread.SetInitialParameter(NULL); |
|
1019 |
test(thread.ExitType()==EExitPending); |
|
1020 |
||
1021 |
test.Next(_L("Get heap")); |
|
1022 |
RHeap* heap; |
|
1023 |
heap=thread.Heap(); |
|
1024 |
test.Next(_L("Alloc inside heap")); |
|
1025 |
__RHEAP_MARK(heap); |
|
1026 |
buf=(TTestBuf*)heap->Alloc(sizeof(TTestBuf)); |
|
1027 |
test(buf!=NULL); |
|
1028 |
new(buf) TTestBuf; |
|
1029 |
*buf=(_L("Everything's just hunky-dory")); |
|
1030 |
||
1031 |
Sem.Signal(); |
|
1032 |
User::WaitForRequest(stat); |
|
1033 |
test(stat==KErrNone); |
|
1034 |
test(thread.ExitType()==EExitKill); |
|
1035 |
test(thread.ExitReason()==KErrNone); |
|
1036 |
||
1037 |
test.Next(_L("Close")); |
|
1038 |
thread.Close(); |
|
1039 |
Sem.Close(); |
|
1040 |
test.End(); |
|
1041 |
*/ |
|
1042 |
} |
|
1043 |
||
1044 |
TInt Thread(TAny* /*aAny*/) |
|
1045 |
{ |
|
1046 |
||
1047 |
RTest test(_L("Any old thread")); |
|
1048 |
test.Next(_L("Find remote thread")); |
|
1049 |
// find the main thread |
|
1050 |
TFullName name; |
|
1051 |
name=RProcess().Name(); |
|
1052 |
name.Append(_L("::*")); |
|
1053 |
TFindThread ft; |
|
1054 |
ft.Find(name); |
|
1055 |
TInt r=ft.Next(name); |
|
1056 |
test(r==KErrNone); |
|
1057 |
RThread t; |
|
1058 |
t.Open(ft); |
|
1059 |
||
1060 |
t.Close(); |
|
1061 |
return KErrNone; |
|
1062 |
} |
|
1063 |
||
1064 |
void test9() |
|
1065 |
{ |
|
1066 |
||
1067 |
test.Start(_L("Test create a NULL TPtr")); |
|
1068 |
TPtr p(NULL, 10, 10); |
|
1069 |
test.Next(_L("Create and run remote thread")); |
|
1070 |
RThread t; |
|
1071 |
TInt r; |
|
1072 |
r=t.Create(_L("Any Old Thread"), Thread, 0x2000, 0x2000, 0x2000, (TAny *)&p); |
|
1073 |
test(KErrNone==r); |
|
1074 |
TRequestStatus stat; |
|
1075 |
t.Logon(stat); |
|
1076 |
t.Resume(); |
|
1077 |
test.Next(_L("Wait for thread to complete")); |
|
1078 |
User::WaitForRequest(stat); |
|
1079 |
test(stat==KErrNone); |
|
1080 |
test(t.ExitCategory()==_L("Kill")); |
|
1081 |
test(t.ExitReason()==KErrNone); |
|
1082 |
test(t.ExitType()==EExitKill); |
|
1083 |
CLOSE_AND_WAIT(t); |
|
1084 |
test.End(); |
|
1085 |
} |
|
1086 |
||
1087 |
||
1088 |
||
1089 |
TInt FoghornLeghorn(TAny* aMutex) |
|
1090 |
// |
|
1091 |
// Thread function |
|
1092 |
// |
|
1093 |
{ |
|
1094 |
||
1095 |
((RSemaphore*)aMutex)->Wait(); |
|
1096 |
RThread thread; |
|
1097 |
TInt r=thread.Create(_L("I say * boy"),FoghornLeghorn,KDefaultStackSize,NULL,aMutex); |
|
1098 |
test(r==KErrBadName); |
|
1099 |
return KErrNone; |
|
1100 |
} |
|
1101 |
||
1102 |
void testOpen() |
|
1103 |
{ |
|
1104 |
||
1105 |
test.Start(_L("Create Foghorn Leghorn")); |
|
1106 |
RSemaphore fogMut; |
|
1107 |
fogMut.CreateLocal(0); |
|
1108 |
RThread foghorn; |
|
1109 |
TInt r=foghorn.Create(_L("Foghorn Leghorn"),FoghornLeghorn,KDefaultStackSize,KHeapSize,KHeapSize,&fogMut); |
|
1110 |
test(r==KErrNone); |
|
1111 |
test.Next(_L("Logon")); |
|
1112 |
TRequestStatus stat; |
|
1113 |
foghorn.Logon(stat); |
|
1114 |
test(stat==KRequestPending); |
|
1115 |
test.Next(_L("Resume Foghorn Leghorn")); |
|
1116 |
foghorn.Resume(); |
|
1117 |
test.Next(_L("Get full name")); |
|
1118 |
TFindThread find(_L("*Foghorn Leghorn")); |
|
1119 |
TFullName name; |
|
1120 |
r=find.Next(name); |
|
1121 |
test(r==KErrNone); |
|
1122 |
test.Next(_L("Open another handle using full name")); |
|
1123 |
RThread leghorn; |
|
1124 |
r=leghorn.Open(name); |
|
1125 |
test(r==KErrNone); |
|
1126 |
test.Next(_L("Kill using second handle")); |
|
1127 |
leghorn.Kill(34523); |
|
1128 |
User::WaitForRequest(stat); |
|
1129 |
test(stat==34523); |
|
1130 |
test.Next(_L("Close handles")); |
|
1131 |
foghorn.Close(); |
|
1132 |
CLOSE_AND_WAIT(leghorn); |
|
1133 |
||
1134 |
test.Next(_L("Again! - Create Foghorn Leghorn")); |
|
1135 |
r=foghorn.Create(_L("Foghorn Leghorn"),FoghornLeghorn,KDefaultStackSize,KHeapSize,KHeapSize,&fogMut); |
|
1136 |
test(r==KErrNone); |
|
1137 |
test.Next(_L("Logon")); |
|
1138 |
foghorn.Logon(stat); |
|
1139 |
test(stat==KRequestPending); |
|
1140 |
test.Next(_L("Resume Foghorn Leghorn")); |
|
1141 |
foghorn.Resume(); |
|
1142 |
test.Next(_L("Get full name")); |
|
1143 |
find.Find(_L("*Foghorn Leghorn")); |
|
1144 |
r=find.Next(name); |
|
1145 |
test(r==KErrNone); |
|
1146 |
test.Next(_L("Open another handle using full name")); |
|
1147 |
r=leghorn.Open(name); |
|
1148 |
test(r==KErrNone); |
|
1149 |
test.Next(_L("Kill using second handle")); |
|
1150 |
leghorn.Kill(67857); |
|
1151 |
User::WaitForRequest(stat); |
|
1152 |
test(stat==67857); |
|
1153 |
test.Next(_L("Close handles")); |
|
1154 |
foghorn.Close(); |
|
1155 |
CLOSE_AND_WAIT(leghorn); |
|
1156 |
||
1157 |
test.Next(_L("Create Foghorn Leghorn")); |
|
1158 |
r=foghorn.Create(_L("Foghorn Leghorn"),FoghornLeghorn,KDefaultStackSize,KHeapSize,KHeapSize,&fogMut); |
|
1159 |
test(r==KErrNone); |
|
1160 |
test.Next(_L("Logon")); |
|
1161 |
foghorn.Logon(stat); |
|
1162 |
test(stat==KRequestPending); |
|
1163 |
test.Next(_L("Resume Foghorn Leghorn")); |
|
1164 |
foghorn.Resume(); |
|
1165 |
test.Next(_L("Now close it")); |
|
1166 |
foghorn.Close(); |
|
1167 |
||
1168 |
test.Next(_L("Get full name")); |
|
1169 |
find.Find(_L("*Foghorn Leghorn")); |
|
1170 |
r=find.Next(name); |
|
1171 |
test(r==KErrNone); |
|
1172 |
test.Next(_L("Open using full name")); |
|
1173 |
r=leghorn.Open(name); |
|
1174 |
test(r==KErrNone); |
|
1175 |
test.Next(_L("Kill")); |
|
1176 |
leghorn.Kill(67857); |
|
1177 |
User::WaitForRequest(stat); |
|
1178 |
test(stat==67857); |
|
1179 |
test.Next(_L("Close")); |
|
1180 |
CLOSE_AND_WAIT(leghorn); |
|
1181 |
||
1182 |
test.Next(_L("Start and get it to try to start a new thread")); |
|
1183 |
r=foghorn.Create(_L("Foghorn Leghorn"),FoghornLeghorn,KDefaultStackSize,KHeapSize,KHeapSize,&fogMut); |
|
1184 |
test(r==KErrNone); |
|
1185 |
foghorn.Logon(stat); |
|
1186 |
test(stat==KRequestPending); |
|
1187 |
foghorn.Resume(); |
|
1188 |
fogMut.Signal(); |
|
1189 |
User::WaitForRequest(stat); |
|
1190 |
test(stat==KErrNone); |
|
1191 |
test(foghorn.ExitCategory()==_L("Kill")); |
|
1192 |
test(foghorn.ExitReason()==KErrNone); |
|
1193 |
test(foghorn.ExitType()==EExitKill); |
|
1194 |
test.Next(_L("Close")); |
|
1195 |
CLOSE_AND_WAIT(foghorn); |
|
1196 |
fogMut.Close(); |
|
1197 |
||
1198 |
test.End(); |
|
1199 |
} |
|
1200 |
||
1201 |
TInt Bunny(TAny*) |
|
1202 |
// |
|
1203 |
// Thread function |
|
1204 |
// |
|
1205 |
{ |
|
1206 |
||
1207 |
FOREVER |
|
1208 |
; |
|
1209 |
} |
|
1210 |
||
1211 |
void testReuse() |
|
1212 |
{ |
|
1213 |
||
1214 |
test.Start(_L("Create thread with duplicate name")); |
|
1215 |
RThread thread; |
|
1216 |
TFullName name=thread.Name(); |
|
1217 |
TInt r=thread.Create(name,Bunny,KDefaultStackSize,KHeapSize,KHeapSize,NULL); |
|
1218 |
test(r==KErrAlreadyExists); |
|
1219 |
// thread.Resume(); handle will be invalid since create failed |
|
1220 |
test.Next(_L("Create with a good name")); |
|
1221 |
r=thread.Create(_L("Bugs Bunny"),Bunny,KDefaultStackSize,KHeapSize,KHeapSize,NULL); |
|
1222 |
test(r==KErrNone); |
|
1223 |
TRequestStatus stat; |
|
1224 |
thread.Logon(stat); |
|
1225 |
test.Next(_L("Resume")); |
|
1226 |
thread.Resume(); |
|
1227 |
test.Next(_L("Kill")); |
|
1228 |
thread.Kill(15); |
|
1229 |
User::WaitForRequest(stat); |
|
1230 |
test(stat==15); |
|
1231 |
CLOSE_AND_WAIT(thread); |
|
1232 |
||
1233 |
test.End(); |
|
1234 |
} |
|
1235 |
||
1236 |
||
1237 |
TInt HongKongPhooey(TAny * /*aAny*/) |
|
1238 |
{ |
|
1239 |
||
1240 |
RMutex m; |
|
1241 |
m.OpenGlobal(_L("Test Mutex")); |
|
1242 |
m.Wait(); |
|
1243 |
User::Panic(_L("Hello"),900); |
|
1244 |
return KErrNone; |
|
1245 |
} |
|
1246 |
||
1247 |
void testReleaseMutex() |
|
1248 |
// |
|
1249 |
// Bug HA-187 |
|
1250 |
// |
|
1251 |
{ |
|
1252 |
TInt r; |
|
1253 |
test.Start(_L("Create a global Mutex")); |
|
1254 |
RMutex m; |
|
1255 |
r=m.CreateGlobal(_L("Test Mutex")); |
|
1256 |
test.Next(_L("Create a thread")); |
|
1257 |
RThread number1SuperGuy; |
|
1258 |
r=number1SuperGuy.Create(_L("Hong Kong Phooey"), HongKongPhooey, KDefaultStackSize,KHeapSize,KHeapSize,NULL); |
|
1259 |
test(r==KErrNone); |
|
1260 |
TRequestStatus s; |
|
1261 |
number1SuperGuy.Logon(s); |
|
1262 |
test.Next(_L("Resume Thread")); |
|
1263 |
number1SuperGuy.Resume(); |
|
1264 |
test.Next(_L("Wait on Mutex and Panic")); |
|
1265 |
User::WaitForRequest(s); |
|
1266 |
test(number1SuperGuy.ExitType()==EExitPanic); |
|
1267 |
test(number1SuperGuy.ExitCategory()==_L("Hello")); |
|
1268 |
test(number1SuperGuy.ExitReason()==900); |
|
1269 |
User::After(100000); // wait a bit for everything to be cleaned up |
|
1270 |
m.Wait(); |
|
1271 |
test.Next(_L("Close everything")); |
|
1272 |
m.Close(); |
|
1273 |
CLOSE_AND_WAIT(number1SuperGuy); |
|
1274 |
test.End(); |
|
1275 |
} |
|
1276 |
||
1277 |
void testId() |
|
1278 |
{ |
|
1279 |
||
1280 |
test.Start(_L("Try to open nonexistant thread by ID")); |
|
1281 |
RThread thread; |
|
1282 |
TInt r=thread.Open(*(TThreadId*)&KMaxTUint); |
|
1283 |
test(r==KErrNotFound); |
|
1284 |
test.Next(_L("Get thread ID")); |
|
1285 |
r=thread.Create(_L("Buster Bunny"),Bunny,KDefaultStackSize,KHeapSize,KHeapSize,NULL); |
|
1286 |
test(r==KErrNone); |
|
1287 |
TThreadId id=thread.Id(); |
|
1288 |
TThreadId id2=thread.Id(); |
|
1289 |
test(id==id2); |
|
1290 |
RThread thread2; |
|
1291 |
r=thread2.Create(_L("Babs Bunny"),Bunny,KDefaultStackSize,KHeapSize,KHeapSize,NULL); |
|
1292 |
test(r==KErrNone); |
|
1293 |
id2=thread2.Id(); |
|
1294 |
test(id!=id2); |
|
1295 |
test(*(TUint*)&id+1==*(TUint*)&id2); |
|
1296 |
test.Next(_L("Open by ID")); |
|
1297 |
TRequestStatus stat; |
|
1298 |
thread.Logon(stat); |
|
1299 |
thread.Kill(54624); |
|
1300 |
User::WaitForRequest(stat); |
|
1301 |
test(stat==54624); |
|
1302 |
thread.Close(); |
|
1303 |
r=thread.Open(id2); |
|
1304 |
test(r==KErrNone); |
|
1305 |
test(thread.Name()==_L("Babs Bunny")); |
|
1306 |
test(thread.FullName()==thread2.FullName()); |
|
1307 |
thread2.Close(); |
|
1308 |
id=thread.Id(); |
|
1309 |
test(id==id2); |
|
1310 |
thread.Logon(stat); |
|
1311 |
thread.Kill(88863); |
|
1312 |
User::WaitForRequest(stat); |
|
1313 |
test(stat==88863); |
|
1314 |
CLOSE_AND_WAIT(thread); |
|
1315 |
||
1316 |
test.End(); |
|
1317 |
} |
|
1318 |
||
1319 |
struct SCreateInfo |
|
1320 |
{ |
|
1321 |
TInt iStackSize; |
|
1322 |
TInt iMinHeapSize; |
|
1323 |
TInt iMaxHeapSize; |
|
1324 |
}; |
|
1325 |
||
1326 |
TInt BadCreation(TAny* aCreateInfo) |
|
1327 |
{ |
|
1328 |
SCreateInfo& info=*((SCreateInfo*)aCreateInfo); |
|
1329 |
RThread thread; |
|
1330 |
thread.Create(_L("Won't work"),Bunny,info.iStackSize,info.iMinHeapSize,info.iMaxHeapSize,NULL); |
|
1331 |
return KErrNone; |
|
1332 |
} |
|
1333 |
||
1334 |
void testCreate() |
|
1335 |
{ |
|
1336 |
test.Start(_L("Negative stack size")); |
|
1337 |
RThread thread; |
|
1338 |
TRequestStatus stat; |
|
1339 |
TInt r; |
|
1340 |
{ |
|
1341 |
SCreateInfo info={-1,0x1000,0x1000}; |
|
1342 |
r=thread.Create(_L("Test Create"),BadCreation,KDefaultStackSize,KHeapSize,KHeapSize,&info); |
|
1343 |
test(KErrNone==r); |
|
1344 |
thread.Logon(stat); |
|
1345 |
thread.Resume(); |
|
1346 |
User::WaitForRequest(stat); |
|
1347 |
test(stat==EThrdStackSizeNegative); |
|
1348 |
test(thread.ExitType()==EExitPanic); |
|
1349 |
test(thread.ExitReason()==EThrdStackSizeNegative); |
|
1350 |
test(thread.ExitCategory()==_L("USER")); |
|
1351 |
CLOSE_AND_WAIT(thread); |
|
1352 |
} |
|
1353 |
// |
|
1354 |
test.Next(_L("Negative heap min size")); |
|
1355 |
{ |
|
1356 |
SCreateInfo info={0x1000,-1,0x1000}; |
|
1357 |
r=thread.Create(_L("Test Create"),BadCreation,KDefaultStackSize,KHeapSize,KHeapSize,&info); |
|
1358 |
test(KErrNone==r); |
|
1359 |
thread.Logon(stat); |
|
1360 |
thread.Resume(); |
|
1361 |
User::WaitForRequest(stat); |
|
1362 |
test(stat==EThrdHeapMinTooSmall); |
|
1363 |
test(thread.ExitType()==EExitPanic); |
|
1364 |
test(thread.ExitReason()==EThrdHeapMinTooSmall); |
|
1365 |
test(thread.ExitCategory()==_L("USER")); |
|
1366 |
CLOSE_AND_WAIT(thread); |
|
1367 |
} |
|
1368 |
test.Next(_L("Negative heap max size")); |
|
1369 |
{ |
|
1370 |
SCreateInfo info={0x1000,0x1000,-1}; |
|
1371 |
r=thread.Create(_L("Test Create"),BadCreation,KDefaultStackSize,KHeapSize,KHeapSize,&info); |
|
1372 |
test(KErrNone==r); |
|
1373 |
thread.Logon(stat); |
|
1374 |
thread.Resume(); |
|
1375 |
User::WaitForRequest(stat); |
|
1376 |
test(stat==EThrdHeapMaxLessThanMin); |
|
1377 |
test(thread.ExitType()==EExitPanic); |
|
1378 |
test(thread.ExitReason()==EThrdHeapMaxLessThanMin); |
|
1379 |
test(thread.ExitCategory()==_L("USER")); |
|
1380 |
CLOSE_AND_WAIT(thread); |
|
1381 |
} |
|
1382 |
test.Next(_L("heap max size < heap min size")); |
|
1383 |
{ |
|
1384 |
SCreateInfo info={0x1000,0x2001,0x1000}; |
|
1385 |
r=thread.Create(_L("Test Create"),BadCreation,KDefaultStackSize,KHeapSize,KHeapSize,&info); |
|
1386 |
test(KErrNone==r); |
|
1387 |
thread.Logon(stat); |
|
1388 |
thread.Resume(); |
|
1389 |
User::WaitForRequest(stat); |
|
1390 |
test(stat==EThrdHeapMaxLessThanMin); |
|
1391 |
test(thread.ExitType()==EExitPanic); |
|
1392 |
test(thread.ExitReason()==EThrdHeapMaxLessThanMin); |
|
1393 |
test(thread.ExitCategory()==_L("USER")); |
|
1394 |
CLOSE_AND_WAIT(thread); |
|
1395 |
} |
|
1396 |
test.Next(_L("Little min heap size")); |
|
1397 |
{ |
|
1398 |
SCreateInfo info={0x1000,KMinHeapSize-1,0x1000}; |
|
1399 |
r=thread.Create(_L("Test Create"),BadCreation,KDefaultStackSize,KHeapSize,KHeapSize,&info); |
|
1400 |
test(KErrNone==r); |
|
1401 |
thread.Logon(stat); |
|
1402 |
thread.Resume(); |
|
1403 |
User::WaitForRequest(stat); |
|
1404 |
test(stat==EThrdHeapMinTooSmall); |
|
1405 |
test(thread.ExitType()==EExitPanic); |
|
1406 |
test(thread.ExitReason()==EThrdHeapMinTooSmall); |
|
1407 |
test(thread.ExitCategory()==_L("USER")); |
|
1408 |
CLOSE_AND_WAIT(thread); |
|
1409 |
} |
|
1410 |
test.End(); |
|
1411 |
} |
|
1412 |
||
1413 |
TInt StackInfoThread(TAny*) |
|
1414 |
{ |
|
1415 |
TInt a; |
|
1416 |
RThread::Rendezvous((TInt)&a); // Complete rendezvous using address of 'a' which is on the stack |
|
1417 |
return 0; |
|
1418 |
} |
|
1419 |
||
1420 |
void testThreadStackInfo() |
|
1421 |
{ |
|
1422 |
// Check the info about the current thread's stack |
|
1423 |
RThread thread; |
|
1424 |
TThreadStackInfo info; |
|
1425 |
TInt r = thread.StackInfo(info); |
|
1426 |
test(r==KErrNone); |
|
1427 |
TLinAddr a = (TLinAddr)&info; |
|
1428 |
test.Printf(_L("address on stack=%x iBase=%x iLimit=%x iExpandLimit=%x"),a,info.iBase,info.iLimit,info.iExpandLimit); |
|
1429 |
test(a<=info.iBase); |
|
1430 |
test(a>=info.iLimit); |
|
1431 |
test(info.iExpandLimit<=info.iLimit); |
|
1432 |
||
1433 |
// Create another thread |
|
1434 |
r=thread.Create(_L("StackInfoThread"),StackInfoThread,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)NULL); |
|
1435 |
test(r==KErrNone); |
|
1436 |
thread.SetPriority(EPriorityLess); |
|
1437 |
||
1438 |
// Resume thread and wait for it to run |
|
1439 |
TRequestStatus stat; |
|
1440 |
thread.Rendezvous(stat); |
|
1441 |
thread.Resume(); |
|
1442 |
User::WaitForRequest(stat); |
|
1443 |
||
1444 |
// Test getting stack info of another thread |
|
1445 |
r = thread.StackInfo(info); |
|
1446 |
test(r==KErrNone); |
|
1447 |
a = stat.Int(); // a = an address on the threads stack |
|
1448 |
test.Printf(_L("address on stack=%x iBase=%x iLimit=%x iExpandLimit=%x"),a,info.iBase,info.iLimit,info.iExpandLimit); |
|
1449 |
test(a<=info.iBase); |
|
1450 |
test(a>=info.iLimit); |
|
1451 |
test(info.iExpandLimit<=info.iLimit); |
|
1452 |
||
1453 |
// Let thread run to end |
|
1454 |
thread.Logon(stat); |
|
1455 |
User::WaitForRequest(stat); |
|
1456 |
test(stat.Int()==0); |
|
1457 |
} |
|
1458 |
||
1459 |
GLDEF_C TInt E32Main() |
|
1460 |
// |
|
1461 |
// Main |
|
1462 |
// |
|
1463 |
{ |
|
1464 |
||
1465 |
// don't want just in time debugging as we trap panics |
|
1466 |
TBool justInTime=User::JustInTime(); |
|
1467 |
User::SetJustInTime(EFalse); |
|
1468 |
||
1469 |
test.Title(); |
|
1470 |
__UHEAP_MARK; |
|
1471 |
||
1472 |
||
1473 |
TFullName name; |
|
1474 |
name=RThread().Name(); |
|
1475 |
||
1476 |
test.Start(_L("Test threads")); |
|
1477 |
||
1478 |
test.Next(_L("Test 1")); |
|
1479 |
test1(); |
|
1480 |
||
1481 |
test.Next(_L("Test create")); |
|
1482 |
testCreate(); |
|
1483 |
||
1484 |
test.Next(_L("Test RUndertaker")); |
|
1485 |
testUndertaker(EOwnerProcess); |
|
1486 |
||
1487 |
test.Next(_L("Test2")); |
|
1488 |
test2(EOwnerProcess); |
|
1489 |
User::SetJustInTime(justInTime); |
|
1490 |
test.Next(_L("Test3")); |
|
1491 |
test3(); |
|
1492 |
test.Next(_L("Test4")); |
|
1493 |
test4(); |
|
1494 |
test.Next(_L("Completed but unclosed thread")); |
|
1495 |
User::SetJustInTime(EFalse); |
|
1496 |
test5(); |
|
1497 |
User::SetJustInTime(justInTime); |
|
1498 |
test.Next(_L("Suspend/Resume")); |
|
1499 |
test7(); |
|
1500 |
test.Next(_L("Testing thread duplication")); |
|
1501 |
User::SetJustInTime(EFalse); |
|
1502 |
test6(); |
|
1503 |
User::SetJustInTime(justInTime); |
|
1504 |
test.Next(_L("Get thread's heap")); |
|
1505 |
test8(); |
|
1506 |
test.Next(_L("Test read NULL remotely (HA-178)")); |
|
1507 |
test9(); |
|
1508 |
test.Next(_L("Test Open(aFullName)")); |
|
1509 |
testOpen(); |
|
1510 |
test.Next(_L("Test Reuse after a failed create")); |
|
1511 |
testReuse(); |
|
1512 |
test.Next(_L("Test thread releases Mutex (HA-178)")); |
|
1513 |
User::SetJustInTime(EFalse); |
|
1514 |
testReleaseMutex(); |
|
1515 |
User::SetJustInTime(justInTime); |
|
1516 |
test.Next(_L("Test Thread ID")); |
|
1517 |
testId(); |
|
1518 |
test.Next(_L("Test RThread::StackInfo")); |
|
1519 |
testThreadStackInfo(); |
|
1520 |
test.End(); |
|
1521 |
__UHEAP_MARKEND; |
|
1522 |
return(KErrNone); |
|
1523 |
} |
|
1524 |
||
1525 |
||
1526 |