sl@0
|
1 |
// Copyright (c) 1997-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 |
// f32test\server\t_alert.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <f32file.h>
|
sl@0
|
19 |
#include <e32test.h>
|
sl@0
|
20 |
#include <e32math.h>
|
sl@0
|
21 |
#include <e32svr.h>
|
sl@0
|
22 |
#include "t_server.h"
|
sl@0
|
23 |
|
sl@0
|
24 |
GLDEF_D RTest test(_L("T_ALERT"));
|
sl@0
|
25 |
|
sl@0
|
26 |
LOCAL_D TInt gFileWrites;
|
sl@0
|
27 |
LOCAL_D TInt gFileReads;
|
sl@0
|
28 |
LOCAL_D TInt gFileCreates;
|
sl@0
|
29 |
LOCAL_D TInt gFileDeletes;
|
sl@0
|
30 |
LOCAL_D TInt gNotifies;
|
sl@0
|
31 |
LOCAL_D TInt gNotifyCancels;
|
sl@0
|
32 |
LOCAL_D TInt gMediaChanges;
|
sl@0
|
33 |
|
sl@0
|
34 |
LOCAL_D const TInt gMaxIteration=100;
|
sl@0
|
35 |
LOCAL_D const TInt KHeapSize=0x4000;
|
sl@0
|
36 |
LOCAL_D const TInt gMaxDelay=100;
|
sl@0
|
37 |
LOCAL_D const TInt gMaxMediaChangeInterval=1000;
|
sl@0
|
38 |
LOCAL_D const TInt gUpdateInterval=10000;
|
sl@0
|
39 |
LOCAL_D const TInt gMaxFiles=4;
|
sl@0
|
40 |
LOCAL_D const TInt gMaxTempSize=1024;
|
sl@0
|
41 |
LOCAL_D const TFileName gPathThread1=_L("C:\\F32-TST\\TALERT\\");
|
sl@0
|
42 |
|
sl@0
|
43 |
// Test2
|
sl@0
|
44 |
LOCAL_D const TInt gHeartBeatInterval=10000000;
|
sl@0
|
45 |
LOCAL_D TInt gThreadTick;
|
sl@0
|
46 |
LOCAL_D TInt gFileCreateFail;
|
sl@0
|
47 |
|
sl@0
|
48 |
#if defined(__WINS__)
|
sl@0
|
49 |
LOCAL_D const TFileName gPathThread0=_L("X:\\F32-TST\\TALERT\\");
|
sl@0
|
50 |
LOCAL_D const TFileName gPathThread2=_L("X:\\F32-TST\\TALERT\\");
|
sl@0
|
51 |
#else
|
sl@0
|
52 |
LOCAL_D TFileName gPathThread0=_L("?:\\F32-TST\\TALERT\\");
|
sl@0
|
53 |
LOCAL_D TFileName gPathThread2=_L("?:\\F32-TST\\TALERT\\");
|
sl@0
|
54 |
#endif
|
sl@0
|
55 |
|
sl@0
|
56 |
LOCAL_C void WaitForMedia()
|
sl@0
|
57 |
//
|
sl@0
|
58 |
// Wait until the media change is serviced
|
sl@0
|
59 |
//
|
sl@0
|
60 |
{
|
sl@0
|
61 |
FOREVER
|
sl@0
|
62 |
{
|
sl@0
|
63 |
TInt r=TheFs.MkDir(gPathThread0);
|
sl@0
|
64 |
if (r==KErrNone || r==KErrAlreadyExists)
|
sl@0
|
65 |
break;
|
sl@0
|
66 |
}
|
sl@0
|
67 |
}
|
sl@0
|
68 |
|
sl@0
|
69 |
LOCAL_C TInt FileAccess(TAny* aPathPtr)
|
sl@0
|
70 |
//
|
sl@0
|
71 |
// Do lots of file access - ignore all errors
|
sl@0
|
72 |
//
|
sl@0
|
73 |
{
|
sl@0
|
74 |
|
sl@0
|
75 |
TFileName file[gMaxFiles];
|
sl@0
|
76 |
TFileName sessionPath=*(TDesC*)aPathPtr;
|
sl@0
|
77 |
HBufC8* tempPtr=HBufC8::New(gMaxTempSize);
|
sl@0
|
78 |
HBufC* tempPtrx=HBufC::New(gMaxTempSize);
|
sl@0
|
79 |
TPtr8 temp(tempPtr->Des());
|
sl@0
|
80 |
TPtr tempx(tempPtrx->Des());
|
sl@0
|
81 |
|
sl@0
|
82 |
RFs fs;
|
sl@0
|
83 |
fs.Connect();
|
sl@0
|
84 |
fs.SetSessionPath(sessionPath);
|
sl@0
|
85 |
|
sl@0
|
86 |
FOREVER
|
sl@0
|
87 |
{
|
sl@0
|
88 |
switch(Math::Rand(gSeed)%4)
|
sl@0
|
89 |
{
|
sl@0
|
90 |
case 0:
|
sl@0
|
91 |
{
|
sl@0
|
92 |
TInt fileNum=Math::Rand(gSeed)%gMaxFiles;
|
sl@0
|
93 |
if (file[fileNum].Length()==0)
|
sl@0
|
94 |
break;
|
sl@0
|
95 |
RFile f;
|
sl@0
|
96 |
TInt r=f.Open(fs,file[fileNum],EFileRead|EFileWrite);
|
sl@0
|
97 |
if (r!=KErrNone)
|
sl@0
|
98 |
break;
|
sl@0
|
99 |
CreateLongName(tempx,gSeed,Math::Rand(gSeed)%gMaxTempSize);
|
sl@0
|
100 |
temp.Copy(tempx);
|
sl@0
|
101 |
r=f.Write(temp);
|
sl@0
|
102 |
if (r==KErrNone)
|
sl@0
|
103 |
gFileWrites++;
|
sl@0
|
104 |
f.Close();
|
sl@0
|
105 |
break;
|
sl@0
|
106 |
}
|
sl@0
|
107 |
case 1:
|
sl@0
|
108 |
{
|
sl@0
|
109 |
TInt fileNum=Math::Rand(gSeed)%gMaxFiles;
|
sl@0
|
110 |
if (file[fileNum].Length()==0)
|
sl@0
|
111 |
break;
|
sl@0
|
112 |
RFile f;
|
sl@0
|
113 |
TInt r=f.Open(fs,file[fileNum],EFileRead|EFileWrite);
|
sl@0
|
114 |
if (r!=KErrNone)
|
sl@0
|
115 |
break;
|
sl@0
|
116 |
r=f.Read(temp);
|
sl@0
|
117 |
if (r==KErrNone)
|
sl@0
|
118 |
gFileReads++;
|
sl@0
|
119 |
f.Close();
|
sl@0
|
120 |
break;
|
sl@0
|
121 |
}
|
sl@0
|
122 |
case 2:
|
sl@0
|
123 |
{
|
sl@0
|
124 |
TInt fileNum=Math::Rand(gSeed)%gMaxFiles;
|
sl@0
|
125 |
if (file[fileNum].Length()!=0)
|
sl@0
|
126 |
break;
|
sl@0
|
127 |
RFile f;
|
sl@0
|
128 |
TInt r=f.Temp(fs,sessionPath,file[fileNum],EFileRead|EFileWrite);
|
sl@0
|
129 |
if (r==KErrNone)
|
sl@0
|
130 |
gFileCreates++;
|
sl@0
|
131 |
f.Close();
|
sl@0
|
132 |
break;
|
sl@0
|
133 |
}
|
sl@0
|
134 |
case 3:
|
sl@0
|
135 |
{
|
sl@0
|
136 |
TInt fileNum=Math::Rand(gSeed)%gMaxFiles;
|
sl@0
|
137 |
if (file[fileNum].Length()==0)
|
sl@0
|
138 |
break;
|
sl@0
|
139 |
TInt r=fs.Delete(file[fileNum]);
|
sl@0
|
140 |
if (r==KErrNone)
|
sl@0
|
141 |
{
|
sl@0
|
142 |
file[fileNum].SetLength(0);
|
sl@0
|
143 |
gFileDeletes++;
|
sl@0
|
144 |
}
|
sl@0
|
145 |
break;
|
sl@0
|
146 |
}
|
sl@0
|
147 |
default:
|
sl@0
|
148 |
break;
|
sl@0
|
149 |
}
|
sl@0
|
150 |
}
|
sl@0
|
151 |
|
sl@0
|
152 |
//delete tempPtr;
|
sl@0
|
153 |
//delete tempPtrx;
|
sl@0
|
154 |
//return(KErrNone);
|
sl@0
|
155 |
}
|
sl@0
|
156 |
|
sl@0
|
157 |
|
sl@0
|
158 |
LOCAL_C void StartThread0()
|
sl@0
|
159 |
//
|
sl@0
|
160 |
// Start a thread that reads and writes to D:
|
sl@0
|
161 |
//
|
sl@0
|
162 |
{
|
sl@0
|
163 |
|
sl@0
|
164 |
RThread clientThread;
|
sl@0
|
165 |
TInt r=clientThread.Create(_L("TALERT_Thread0"),FileAccess,0x4000,KHeapSize,KHeapSize,(TAny*)&gPathThread0,EOwnerThread);
|
sl@0
|
166 |
test(r==KErrNone);
|
sl@0
|
167 |
clientThread.Resume();
|
sl@0
|
168 |
clientThread.Close();
|
sl@0
|
169 |
}
|
sl@0
|
170 |
|
sl@0
|
171 |
LOCAL_C void StartThread1()
|
sl@0
|
172 |
//
|
sl@0
|
173 |
// Start a thread that reads and writes to C:
|
sl@0
|
174 |
//
|
sl@0
|
175 |
{
|
sl@0
|
176 |
|
sl@0
|
177 |
RThread clientThread;
|
sl@0
|
178 |
TInt r=clientThread.Create(_L("TALERT_Thread1"),FileAccess,0x4000,KHeapSize,KHeapSize,(TAny*)&gPathThread1,EOwnerThread);
|
sl@0
|
179 |
test(r==KErrNone);
|
sl@0
|
180 |
clientThread.Resume();
|
sl@0
|
181 |
clientThread.Close();
|
sl@0
|
182 |
}
|
sl@0
|
183 |
|
sl@0
|
184 |
LOCAL_C void StartThread2()
|
sl@0
|
185 |
//
|
sl@0
|
186 |
// Start a thread that reads and writes to D:
|
sl@0
|
187 |
//
|
sl@0
|
188 |
{
|
sl@0
|
189 |
|
sl@0
|
190 |
RThread clientThread;
|
sl@0
|
191 |
TInt r=clientThread.Create(_L("TALERT_Thread2"),FileAccess,0x4000,KHeapSize,KHeapSize,(TAny*)&gPathThread2,EOwnerThread);
|
sl@0
|
192 |
test(r==KErrNone);
|
sl@0
|
193 |
clientThread.Resume();
|
sl@0
|
194 |
clientThread.Close();
|
sl@0
|
195 |
}
|
sl@0
|
196 |
|
sl@0
|
197 |
|
sl@0
|
198 |
LOCAL_C TInt NotifyAccess(TAny*)
|
sl@0
|
199 |
//
|
sl@0
|
200 |
// Create, wait for and cancel notifiers.
|
sl@0
|
201 |
//
|
sl@0
|
202 |
{
|
sl@0
|
203 |
|
sl@0
|
204 |
RFs fs;
|
sl@0
|
205 |
fs.Connect();
|
sl@0
|
206 |
TRequestStatus status;
|
sl@0
|
207 |
|
sl@0
|
208 |
FOREVER
|
sl@0
|
209 |
{
|
sl@0
|
210 |
switch(Math::Rand(gSeed)%4)
|
sl@0
|
211 |
{
|
sl@0
|
212 |
case 0:
|
sl@0
|
213 |
gNotifies++;
|
sl@0
|
214 |
fs.NotifyChange(ENotifyAll,status);
|
sl@0
|
215 |
User::WaitForRequest(status);
|
sl@0
|
216 |
break;
|
sl@0
|
217 |
case 1:
|
sl@0
|
218 |
gNotifies++;
|
sl@0
|
219 |
fs.NotifyChange(ENotifyEntry,status);
|
sl@0
|
220 |
User::WaitForRequest(status);
|
sl@0
|
221 |
break;
|
sl@0
|
222 |
case 2:
|
sl@0
|
223 |
gNotifyCancels++;
|
sl@0
|
224 |
fs.NotifyChange(ENotifyAll,status);
|
sl@0
|
225 |
User::After(Math::Rand(gSeed)%gMaxDelay);
|
sl@0
|
226 |
fs.NotifyChangeCancel();
|
sl@0
|
227 |
User::WaitForRequest(status);
|
sl@0
|
228 |
break;
|
sl@0
|
229 |
case 3:
|
sl@0
|
230 |
gNotifyCancels++;
|
sl@0
|
231 |
fs.NotifyChange(ENotifyEntry,status);
|
sl@0
|
232 |
User::After(Math::Rand(gSeed)%gMaxDelay);
|
sl@0
|
233 |
fs.NotifyChangeCancel();
|
sl@0
|
234 |
User::WaitForRequest(status);
|
sl@0
|
235 |
break;
|
sl@0
|
236 |
}
|
sl@0
|
237 |
}
|
sl@0
|
238 |
|
sl@0
|
239 |
//return(KErrNone);
|
sl@0
|
240 |
}
|
sl@0
|
241 |
|
sl@0
|
242 |
LOCAL_C void StartThread3()
|
sl@0
|
243 |
//
|
sl@0
|
244 |
// Start a thread that creates and waits/cancel RFs::Notifiers
|
sl@0
|
245 |
//
|
sl@0
|
246 |
{
|
sl@0
|
247 |
|
sl@0
|
248 |
RThread clientThread;
|
sl@0
|
249 |
TInt r=clientThread.Create(_L("TALERT_Thread3"),NotifyAccess,0x4000,KHeapSize,KHeapSize,NULL,EOwnerThread);
|
sl@0
|
250 |
test(r==KErrNone);
|
sl@0
|
251 |
clientThread.Resume();
|
sl@0
|
252 |
clientThread.Close();
|
sl@0
|
253 |
}
|
sl@0
|
254 |
|
sl@0
|
255 |
LOCAL_C TInt MediaChange(TAny*)
|
sl@0
|
256 |
//
|
sl@0
|
257 |
// Cause media changes a random intervals
|
sl@0
|
258 |
//
|
sl@0
|
259 |
{
|
sl@0
|
260 |
gMediaChanges=0;
|
sl@0
|
261 |
FOREVER
|
sl@0
|
262 |
{
|
sl@0
|
263 |
TInt interval=Math::Rand(gSeed)%gMaxMediaChangeInterval;
|
sl@0
|
264 |
User::After(interval);
|
sl@0
|
265 |
// UserSvr::ForceRemountMedia(ERemovableMedia0); // Generate media change
|
sl@0
|
266 |
++gMediaChanges;
|
sl@0
|
267 |
}
|
sl@0
|
268 |
|
sl@0
|
269 |
//return(KErrNone);
|
sl@0
|
270 |
}
|
sl@0
|
271 |
|
sl@0
|
272 |
LOCAL_C void StartThread4()
|
sl@0
|
273 |
//
|
sl@0
|
274 |
// Start a thread that creates media changes
|
sl@0
|
275 |
//
|
sl@0
|
276 |
{
|
sl@0
|
277 |
|
sl@0
|
278 |
RThread clientThread;
|
sl@0
|
279 |
TInt r=clientThread.Create(_L("TALERT_Thread4"),MediaChange,0x4000,KHeapSize,KHeapSize,NULL,EOwnerThread);
|
sl@0
|
280 |
test(r==KErrNone);
|
sl@0
|
281 |
clientThread.SetPriority(EPriorityMore);
|
sl@0
|
282 |
clientThread.Resume();
|
sl@0
|
283 |
clientThread.Close();
|
sl@0
|
284 |
}
|
sl@0
|
285 |
|
sl@0
|
286 |
LOCAL_C void StartClock()
|
sl@0
|
287 |
//
|
sl@0
|
288 |
// Display ongoing reads/writes. Getch to exit
|
sl@0
|
289 |
//
|
sl@0
|
290 |
{
|
sl@0
|
291 |
|
sl@0
|
292 |
test.Console()->ClearScreen();
|
sl@0
|
293 |
FOREVER
|
sl@0
|
294 |
{
|
sl@0
|
295 |
User::After(gUpdateInterval);
|
sl@0
|
296 |
test.Console()->SetPos(0,5);
|
sl@0
|
297 |
test.Printf(_L("File writes = %d \n"),gFileWrites);
|
sl@0
|
298 |
test.Printf(_L("File reads = %d \n"),gFileReads);
|
sl@0
|
299 |
test.Printf(_L("File creates = %d \n"),gFileCreates);
|
sl@0
|
300 |
test.Printf(_L("File deletes = %d \n"),gFileDeletes);
|
sl@0
|
301 |
test.Printf(_L("File notifies = %d \n"),gNotifies);
|
sl@0
|
302 |
test.Printf(_L("File notifies cancelled = %d \n"),gNotifyCancels);
|
sl@0
|
303 |
// test.Printf(_L("Press any key to exit\n"));
|
sl@0
|
304 |
// TKeyCode keycode=test.Console()->KeyCode();
|
sl@0
|
305 |
// if (keycode!=EKeyNull)
|
sl@0
|
306 |
// break;
|
sl@0
|
307 |
if (gFileWrites>gMaxIteration)
|
sl@0
|
308 |
break;
|
sl@0
|
309 |
}
|
sl@0
|
310 |
}
|
sl@0
|
311 |
|
sl@0
|
312 |
LOCAL_C void KillThreads()
|
sl@0
|
313 |
//
|
sl@0
|
314 |
// Kill all threads
|
sl@0
|
315 |
//
|
sl@0
|
316 |
{
|
sl@0
|
317 |
test.Printf(_L("+Kill threads"));
|
sl@0
|
318 |
RThread t;
|
sl@0
|
319 |
|
sl@0
|
320 |
TInt r=t.Open(_L("TALERT_Thread0"),EOwnerThread);
|
sl@0
|
321 |
if(r==KErrNone)
|
sl@0
|
322 |
{
|
sl@0
|
323 |
t.Kill(KErrCancel);
|
sl@0
|
324 |
t.Close();
|
sl@0
|
325 |
}
|
sl@0
|
326 |
else
|
sl@0
|
327 |
test(r==KErrNotFound);
|
sl@0
|
328 |
|
sl@0
|
329 |
r=t.Open(_L("TALERT_Thread1"),EOwnerThread);
|
sl@0
|
330 |
if(r==KErrNone)
|
sl@0
|
331 |
{
|
sl@0
|
332 |
t.Kill(KErrCancel);
|
sl@0
|
333 |
t.Close();
|
sl@0
|
334 |
}
|
sl@0
|
335 |
else
|
sl@0
|
336 |
test(r==KErrNotFound);
|
sl@0
|
337 |
|
sl@0
|
338 |
r=t.Open(_L("TALERT_Thread2"),EOwnerThread);
|
sl@0
|
339 |
if(r==KErrNone)
|
sl@0
|
340 |
{
|
sl@0
|
341 |
t.Kill(KErrCancel);
|
sl@0
|
342 |
t.Close();
|
sl@0
|
343 |
}
|
sl@0
|
344 |
else
|
sl@0
|
345 |
test(r==KErrNotFound);
|
sl@0
|
346 |
|
sl@0
|
347 |
r=t.Open(_L("TALERT_Thread3"),EOwnerThread);
|
sl@0
|
348 |
if(r==KErrNone)
|
sl@0
|
349 |
{
|
sl@0
|
350 |
t.Kill(KErrCancel);
|
sl@0
|
351 |
t.Close();
|
sl@0
|
352 |
}
|
sl@0
|
353 |
else
|
sl@0
|
354 |
test(r==KErrNotFound);
|
sl@0
|
355 |
|
sl@0
|
356 |
r=t.Open(_L("TALERT_Thread4"),EOwnerThread);
|
sl@0
|
357 |
if(r==KErrNone)
|
sl@0
|
358 |
{
|
sl@0
|
359 |
t.Kill(KErrCancel);
|
sl@0
|
360 |
t.Close();
|
sl@0
|
361 |
}
|
sl@0
|
362 |
else
|
sl@0
|
363 |
test(r==KErrNotFound);
|
sl@0
|
364 |
|
sl@0
|
365 |
/* TFindThread threadFinder(_L("TALERT_*"));
|
sl@0
|
366 |
FOREVER
|
sl@0
|
367 |
{
|
sl@0
|
368 |
TFullName threadName;
|
sl@0
|
369 |
TInt r=threadFinder.Next(threadName);
|
sl@0
|
370 |
test.Printf(_L("r=%d"),r);
|
sl@0
|
371 |
if (r==KErrNotFound)
|
sl@0
|
372 |
break;
|
sl@0
|
373 |
test(r==KErrNone);
|
sl@0
|
374 |
test.Printf(_L("Killing Thread %S\n"),&threadName);
|
sl@0
|
375 |
RThread t;
|
sl@0
|
376 |
r=t.Open(threadName,EOwnerThread);
|
sl@0
|
377 |
test(r==KErrNone);
|
sl@0
|
378 |
t.Kill(KErrCancel);
|
sl@0
|
379 |
t.Close();
|
sl@0
|
380 |
} */
|
sl@0
|
381 |
test.Printf(_L("-Kill threads"));
|
sl@0
|
382 |
}
|
sl@0
|
383 |
|
sl@0
|
384 |
LOCAL_C void Test1()
|
sl@0
|
385 |
//
|
sl@0
|
386 |
// Create lots of threads and change notifiers
|
sl@0
|
387 |
//
|
sl@0
|
388 |
{
|
sl@0
|
389 |
test.Next(_L("Create lots of threads and change notifiers"));
|
sl@0
|
390 |
TInt r=TheFs.MkDirAll(gPathThread1);
|
sl@0
|
391 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
392 |
r=TheFs.MkDir(gPathThread2);
|
sl@0
|
393 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
394 |
|
sl@0
|
395 |
StartThread0(); // Read and write to D:
|
sl@0
|
396 |
StartThread1(); // Read and write to C:
|
sl@0
|
397 |
StartThread2(); // Read and write to D: (again)
|
sl@0
|
398 |
StartThread3(); // Set RFs::Notifiers
|
sl@0
|
399 |
StartThread4(); // Generate media changes
|
sl@0
|
400 |
StartClock(); // Time how long test has run
|
sl@0
|
401 |
KillThreads();
|
sl@0
|
402 |
}
|
sl@0
|
403 |
|
sl@0
|
404 |
LOCAL_C TInt ThreadHangTest(TAny*)
|
sl@0
|
405 |
//
|
sl@0
|
406 |
// Keep writing to the fileserver and setting gThreadTick
|
sl@0
|
407 |
//
|
sl@0
|
408 |
{
|
sl@0
|
409 |
|
sl@0
|
410 |
RFs fs;
|
sl@0
|
411 |
fs.Connect();
|
sl@0
|
412 |
fs.SetSessionPath(gPathThread0);
|
sl@0
|
413 |
|
sl@0
|
414 |
FOREVER
|
sl@0
|
415 |
{
|
sl@0
|
416 |
gFileCreateFail++;
|
sl@0
|
417 |
gThreadTick=ETrue;
|
sl@0
|
418 |
RFile f;
|
sl@0
|
419 |
TInt r=f.Replace(fs,_L("TwiddleThumbs"),EFileRead|EFileWrite);
|
sl@0
|
420 |
if (r!=KErrNone)
|
sl@0
|
421 |
continue;
|
sl@0
|
422 |
gFileCreateFail=0;
|
sl@0
|
423 |
f.Close();
|
sl@0
|
424 |
gThreadTick=ETrue;
|
sl@0
|
425 |
fs.Delete(_L("TwiddleThumbs"));
|
sl@0
|
426 |
gThreadTick=ETrue;
|
sl@0
|
427 |
}
|
sl@0
|
428 |
|
sl@0
|
429 |
//return(KErrNone);
|
sl@0
|
430 |
}
|
sl@0
|
431 |
|
sl@0
|
432 |
LOCAL_C void Test2()
|
sl@0
|
433 |
//
|
sl@0
|
434 |
// Create a hung server then kill the thread it wants to write to.
|
sl@0
|
435 |
//
|
sl@0
|
436 |
{
|
sl@0
|
437 |
|
sl@0
|
438 |
test.Next(_L("Create a hung server and kill the thread it is writing to"));
|
sl@0
|
439 |
TInt r=TheFs.MkDir(gPathThread0);
|
sl@0
|
440 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
441 |
StartThread4(); // Generate media changes
|
sl@0
|
442 |
|
sl@0
|
443 |
RThread clientThread;
|
sl@0
|
444 |
r=clientThread.Create(_L("TALERT_ThreadHangTest"),ThreadHangTest,0x4000,KHeapSize,KHeapSize,NULL,EOwnerThread);
|
sl@0
|
445 |
test(r==KErrNone);
|
sl@0
|
446 |
TRequestStatus status;
|
sl@0
|
447 |
clientThread.Logon(status);
|
sl@0
|
448 |
clientThread.Resume();
|
sl@0
|
449 |
gThreadTick=ETrue;
|
sl@0
|
450 |
test.Next(_L("ThreadHangTest is running"));
|
sl@0
|
451 |
|
sl@0
|
452 |
TInt count=0;
|
sl@0
|
453 |
FOREVER
|
sl@0
|
454 |
{
|
sl@0
|
455 |
test.Printf(_L("Thread tick = %d File create failures = %d \n"),count,gFileCreateFail);
|
sl@0
|
456 |
test.Printf(_L("Media changes = %d\n"),gMediaChanges);
|
sl@0
|
457 |
User::After(gHeartBeatInterval);
|
sl@0
|
458 |
if (gThreadTick==0)
|
sl@0
|
459 |
break;
|
sl@0
|
460 |
gThreadTick=0;
|
sl@0
|
461 |
count++;
|
sl@0
|
462 |
}
|
sl@0
|
463 |
|
sl@0
|
464 |
test.Next(_L("Thread is hung"));
|
sl@0
|
465 |
clientThread.Kill(KErrCancel);
|
sl@0
|
466 |
clientThread.Close();
|
sl@0
|
467 |
User::WaitForRequest(status);
|
sl@0
|
468 |
KillThreads();
|
sl@0
|
469 |
User::After(1000000);
|
sl@0
|
470 |
|
sl@0
|
471 |
test.Printf(_L("Press return to the clear notifier, then any key to continue test"));
|
sl@0
|
472 |
test.Getch();
|
sl@0
|
473 |
|
sl@0
|
474 |
test.Next(_L("Test fileserver is still alive after thread is killed"));
|
sl@0
|
475 |
WaitForMedia();
|
sl@0
|
476 |
r=TheFs.MkDir(gPathThread0); // Check fileserver ok
|
sl@0
|
477 |
if(r!=KErrNone && r!=KErrAlreadyExists)
|
sl@0
|
478 |
test.Printf(_L("r=%d"),r);
|
sl@0
|
479 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
480 |
|
sl@0
|
481 |
}
|
sl@0
|
482 |
|
sl@0
|
483 |
GLDEF_C void CallTestsL()
|
sl@0
|
484 |
//
|
sl@0
|
485 |
// Do tests relative to the session path
|
sl@0
|
486 |
//
|
sl@0
|
487 |
{
|
sl@0
|
488 |
|
sl@0
|
489 |
RThread().SetPriority(EPriorityLess);
|
sl@0
|
490 |
#if defined(__WINS__)
|
sl@0
|
491 |
if (gSessionPath[0]!='X')
|
sl@0
|
492 |
return;
|
sl@0
|
493 |
#else
|
sl@0
|
494 |
// Test on two drives where possible. This should be C: together with
|
sl@0
|
495 |
// the drive referenced by the default path. Where the default path is
|
sl@0
|
496 |
// C:, then only C: is used. The standard way to run the test is to
|
sl@0
|
497 |
// set the default path to D:
|
sl@0
|
498 |
|
sl@0
|
499 |
gPathThread0[0]=gSessionPath[0];
|
sl@0
|
500 |
gPathThread2[0]=gSessionPath[0];
|
sl@0
|
501 |
#endif
|
sl@0
|
502 |
|
sl@0
|
503 |
Test2();
|
sl@0
|
504 |
Test1();
|
sl@0
|
505 |
//This test can leave the drive corrupt so a format is required
|
sl@0
|
506 |
#if defined(__WINS__)
|
sl@0
|
507 |
Format(EDriveX);
|
sl@0
|
508 |
#else
|
sl@0
|
509 |
Format(EDriveD);
|
sl@0
|
510 |
#endif
|
sl@0
|
511 |
//clean up the talert directory after the test completes
|
sl@0
|
512 |
/* CFileMan* FileMan=NULL;
|
sl@0
|
513 |
FileMan=CFileMan::NewL(TheFs);
|
sl@0
|
514 |
TInt r=FileMan->RmDir(_L("\\F32-TST\\TALERT\\"));
|
sl@0
|
515 |
test.Printf(_L("r=%d"),r);
|
sl@0
|
516 |
test(r==KErrNone || r==KErrPathNotFound);
|
sl@0
|
517 |
delete FileMan;
|
sl@0
|
518 |
*/
|
sl@0
|
519 |
}
|