161 // |
162 // |
162 { |
163 { |
163 |
164 |
164 RThread clientThread; |
165 RThread clientThread; |
165 TInt r=clientThread.Create(_L("TALERT_Thread0"),FileAccess,0x4000,KHeapSize,KHeapSize,(TAny*)&gPathThread0,EOwnerThread); |
166 TInt r=clientThread.Create(_L("TALERT_Thread0"),FileAccess,0x4000,KHeapSize,KHeapSize,(TAny*)&gPathThread0,EOwnerThread); |
166 test(r==KErrNone); |
167 test_KErrNone(r); |
167 clientThread.Resume(); |
168 clientThread.Resume(); |
168 clientThread.Close(); |
169 clientThread.Close(); |
169 } |
170 } |
170 |
171 |
171 LOCAL_C void StartThread1() |
172 LOCAL_C void StartThread1() |
174 // |
175 // |
175 { |
176 { |
176 |
177 |
177 RThread clientThread; |
178 RThread clientThread; |
178 TInt r=clientThread.Create(_L("TALERT_Thread1"),FileAccess,0x4000,KHeapSize,KHeapSize,(TAny*)&gPathThread1,EOwnerThread); |
179 TInt r=clientThread.Create(_L("TALERT_Thread1"),FileAccess,0x4000,KHeapSize,KHeapSize,(TAny*)&gPathThread1,EOwnerThread); |
179 test(r==KErrNone); |
180 test_KErrNone(r); |
180 clientThread.Resume(); |
181 clientThread.Resume(); |
181 clientThread.Close(); |
182 clientThread.Close(); |
182 } |
183 } |
183 |
184 |
184 LOCAL_C void StartThread2() |
185 LOCAL_C void StartThread2() |
187 // |
188 // |
188 { |
189 { |
189 |
190 |
190 RThread clientThread; |
191 RThread clientThread; |
191 TInt r=clientThread.Create(_L("TALERT_Thread2"),FileAccess,0x4000,KHeapSize,KHeapSize,(TAny*)&gPathThread2,EOwnerThread); |
192 TInt r=clientThread.Create(_L("TALERT_Thread2"),FileAccess,0x4000,KHeapSize,KHeapSize,(TAny*)&gPathThread2,EOwnerThread); |
192 test(r==KErrNone); |
193 test_KErrNone(r); |
193 clientThread.Resume(); |
194 clientThread.Resume(); |
194 clientThread.Close(); |
195 clientThread.Close(); |
195 } |
196 } |
196 |
197 |
197 |
198 |
245 // |
246 // |
246 { |
247 { |
247 |
248 |
248 RThread clientThread; |
249 RThread clientThread; |
249 TInt r=clientThread.Create(_L("TALERT_Thread3"),NotifyAccess,0x4000,KHeapSize,KHeapSize,NULL,EOwnerThread); |
250 TInt r=clientThread.Create(_L("TALERT_Thread3"),NotifyAccess,0x4000,KHeapSize,KHeapSize,NULL,EOwnerThread); |
250 test(r==KErrNone); |
251 test_KErrNone(r); |
251 clientThread.Resume(); |
252 clientThread.Resume(); |
252 clientThread.Close(); |
253 clientThread.Close(); |
253 } |
254 } |
254 |
255 |
255 LOCAL_C TInt MediaChange(TAny*) |
256 LOCAL_C TInt MediaChange(TAny*) |
275 // |
276 // |
276 { |
277 { |
277 |
278 |
278 RThread clientThread; |
279 RThread clientThread; |
279 TInt r=clientThread.Create(_L("TALERT_Thread4"),MediaChange,0x4000,KHeapSize,KHeapSize,NULL,EOwnerThread); |
280 TInt r=clientThread.Create(_L("TALERT_Thread4"),MediaChange,0x4000,KHeapSize,KHeapSize,NULL,EOwnerThread); |
280 test(r==KErrNone); |
281 test_KErrNone(r); |
281 clientThread.SetPriority(EPriorityMore); |
282 clientThread.SetPriority(EPriorityMore); |
282 clientThread.Resume(); |
283 clientThread.Resume(); |
283 clientThread.Close(); |
284 clientThread.Close(); |
284 } |
285 } |
285 |
286 |
322 { |
323 { |
323 t.Kill(KErrCancel); |
324 t.Kill(KErrCancel); |
324 t.Close(); |
325 t.Close(); |
325 } |
326 } |
326 else |
327 else |
327 test(r==KErrNotFound); |
328 test_Value(r, r == KErrNotFound); |
328 |
329 |
329 r=t.Open(_L("TALERT_Thread1"),EOwnerThread); |
330 r=t.Open(_L("TALERT_Thread1"),EOwnerThread); |
330 if(r==KErrNone) |
331 if(r==KErrNone) |
331 { |
332 { |
332 t.Kill(KErrCancel); |
333 t.Kill(KErrCancel); |
333 t.Close(); |
334 t.Close(); |
334 } |
335 } |
335 else |
336 else |
336 test(r==KErrNotFound); |
337 test_Value(r, r == KErrNotFound); |
337 |
338 |
338 r=t.Open(_L("TALERT_Thread2"),EOwnerThread); |
339 r=t.Open(_L("TALERT_Thread2"),EOwnerThread); |
339 if(r==KErrNone) |
340 if(r==KErrNone) |
340 { |
341 { |
341 t.Kill(KErrCancel); |
342 t.Kill(KErrCancel); |
342 t.Close(); |
343 t.Close(); |
343 } |
344 } |
344 else |
345 else |
345 test(r==KErrNotFound); |
346 test_Value(r, r == KErrNotFound); |
346 |
347 |
347 r=t.Open(_L("TALERT_Thread3"),EOwnerThread); |
348 r=t.Open(_L("TALERT_Thread3"),EOwnerThread); |
348 if(r==KErrNone) |
349 if(r==KErrNone) |
349 { |
350 { |
350 t.Kill(KErrCancel); |
351 t.Kill(KErrCancel); |
351 t.Close(); |
352 t.Close(); |
352 } |
353 } |
353 else |
354 else |
354 test(r==KErrNotFound); |
355 test_Value(r, r == KErrNotFound); |
355 |
356 |
356 r=t.Open(_L("TALERT_Thread4"),EOwnerThread); |
357 r=t.Open(_L("TALERT_Thread4"),EOwnerThread); |
357 if(r==KErrNone) |
358 if(r==KErrNone) |
358 { |
359 { |
359 t.Kill(KErrCancel); |
360 t.Kill(KErrCancel); |
360 t.Close(); |
361 t.Close(); |
361 } |
362 } |
362 else |
363 else |
363 test(r==KErrNotFound); |
364 test_Value(r, r == KErrNotFound); |
364 |
365 |
365 /* TFindThread threadFinder(_L("TALERT_*")); |
366 /* TFindThread threadFinder(_L("TALERT_*")); |
366 FOREVER |
367 FOREVER |
367 { |
368 { |
368 TFullName threadName; |
369 TFullName threadName; |
369 TInt r=threadFinder.Next(threadName); |
370 TInt r=threadFinder.Next(threadName); |
370 test.Printf(_L("r=%d"),r); |
371 test.Printf(_L("r=%d"),r); |
371 if (r==KErrNotFound) |
372 if (r==KErrNotFound) |
372 break; |
373 break; |
373 test(r==KErrNone); |
374 test_KErrNone(r); |
374 test.Printf(_L("Killing Thread %S\n"),&threadName); |
375 test.Printf(_L("Killing Thread %S\n"),&threadName); |
375 RThread t; |
376 RThread t; |
376 r=t.Open(threadName,EOwnerThread); |
377 r=t.Open(threadName,EOwnerThread); |
377 test(r==KErrNone); |
378 test_KErrNone(r); |
378 t.Kill(KErrCancel); |
379 t.Kill(KErrCancel); |
379 t.Close(); |
380 t.Close(); |
380 } */ |
381 } */ |
381 test.Printf(_L("-Kill threads")); |
382 test.Printf(_L("-Kill threads")); |
382 } |
383 } |
386 // Create lots of threads and change notifiers |
387 // Create lots of threads and change notifiers |
387 // |
388 // |
388 { |
389 { |
389 test.Next(_L("Create lots of threads and change notifiers")); |
390 test.Next(_L("Create lots of threads and change notifiers")); |
390 TInt r=TheFs.MkDirAll(gPathThread1); |
391 TInt r=TheFs.MkDirAll(gPathThread1); |
391 test(r==KErrNone || r==KErrAlreadyExists); |
392 test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
392 r=TheFs.MkDir(gPathThread2); |
393 r=TheFs.MkDir(gPathThread2); |
393 test(r==KErrNone || r==KErrAlreadyExists); |
394 test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
394 |
395 |
395 StartThread0(); // Read and write to D: |
396 StartThread0(); // Read and write to D: |
396 StartThread1(); // Read and write to C: |
397 StartThread1(); // Read and write to C: |
397 StartThread2(); // Read and write to D: (again) |
398 StartThread2(); // Read and write to D: (again) |
398 StartThread3(); // Set RFs::Notifiers |
399 StartThread3(); // Set RFs::Notifiers |
435 // |
436 // |
436 { |
437 { |
437 |
438 |
438 test.Next(_L("Create a hung server and kill the thread it is writing to")); |
439 test.Next(_L("Create a hung server and kill the thread it is writing to")); |
439 TInt r=TheFs.MkDir(gPathThread0); |
440 TInt r=TheFs.MkDir(gPathThread0); |
440 test(r==KErrNone || r==KErrAlreadyExists); |
441 test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
441 StartThread4(); // Generate media changes |
442 StartThread4(); // Generate media changes |
442 |
443 |
443 RThread clientThread; |
444 RThread clientThread; |
444 r=clientThread.Create(_L("TALERT_ThreadHangTest"),ThreadHangTest,0x4000,KHeapSize,KHeapSize,NULL,EOwnerThread); |
445 r=clientThread.Create(_L("TALERT_ThreadHangTest"),ThreadHangTest,0x4000,KHeapSize,KHeapSize,NULL,EOwnerThread); |
445 test(r==KErrNone); |
446 test_KErrNone(r); |
446 TRequestStatus status; |
447 TRequestStatus status; |
447 clientThread.Logon(status); |
448 clientThread.Logon(status); |
448 clientThread.Resume(); |
449 clientThread.Resume(); |
449 gThreadTick=ETrue; |
450 gThreadTick=ETrue; |
450 test.Next(_L("ThreadHangTest is running")); |
451 test.Next(_L("ThreadHangTest is running")); |
474 test.Next(_L("Test fileserver is still alive after thread is killed")); |
475 test.Next(_L("Test fileserver is still alive after thread is killed")); |
475 WaitForMedia(); |
476 WaitForMedia(); |
476 r=TheFs.MkDir(gPathThread0); // Check fileserver ok |
477 r=TheFs.MkDir(gPathThread0); // Check fileserver ok |
477 if(r!=KErrNone && r!=KErrAlreadyExists) |
478 if(r!=KErrNone && r!=KErrAlreadyExists) |
478 test.Printf(_L("r=%d"),r); |
479 test.Printf(_L("r=%d"),r); |
479 test(r==KErrNone || r==KErrAlreadyExists); |
480 test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
480 |
481 |
481 } |
482 } |
482 |
483 |
483 GLDEF_C void CallTestsL() |
484 GLDEF_C void CallTestsL() |
484 // |
485 // |
511 //clean up the talert directory after the test completes |
512 //clean up the talert directory after the test completes |
512 /* CFileMan* FileMan=NULL; |
513 /* CFileMan* FileMan=NULL; |
513 FileMan=CFileMan::NewL(TheFs); |
514 FileMan=CFileMan::NewL(TheFs); |
514 TInt r=FileMan->RmDir(_L("\\F32-TST\\TALERT\\")); |
515 TInt r=FileMan->RmDir(_L("\\F32-TST\\TALERT\\")); |
515 test.Printf(_L("r=%d"),r); |
516 test.Printf(_L("r=%d"),r); |
516 test(r==KErrNone || r==KErrPathNotFound); |
517 test_Value(r, r == KErrNone || r==KErrPathNotFound); |
517 delete FileMan; |
518 delete FileMan; |
518 */ |
519 */ |
519 } |
520 } |