sl@0
|
1 |
// Copyright (c) 1996-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 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
//! @file f32test\concur\t_tdebug.cpp
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <e32test.h>
|
sl@0
|
19 |
#include <f32file.h>
|
sl@0
|
20 |
#include "t_server.h"
|
sl@0
|
21 |
#include "t_tdebug.h"
|
sl@0
|
22 |
#include "cfafsdlyif.h"
|
sl@0
|
23 |
|
sl@0
|
24 |
TThreadData TTest::iData[KMaxThreads];
|
sl@0
|
25 |
TThreadData TTest::iDummy;
|
sl@0
|
26 |
TFullName TTest::iWhere;
|
sl@0
|
27 |
RMutex TTest::iDebugLock;
|
sl@0
|
28 |
RMutex TTest::iPrintLock;
|
sl@0
|
29 |
TBool TTest::iInit = EFalse;
|
sl@0
|
30 |
|
sl@0
|
31 |
LOCAL_C TFileName gErrorPos;
|
sl@0
|
32 |
|
sl@0
|
33 |
// Instance of the class to force initialisation.
|
sl@0
|
34 |
LOCAL_C TTest gTest;
|
sl@0
|
35 |
|
sl@0
|
36 |
LOCAL_C TInt KSecond = 1000000;
|
sl@0
|
37 |
|
sl@0
|
38 |
class TTestOverflowTruncate : public TDesOverflow
|
sl@0
|
39 |
///
|
sl@0
|
40 |
/// Used to suppress overflow when appending formatted text to a buffer.
|
sl@0
|
41 |
///
|
sl@0
|
42 |
{
|
sl@0
|
43 |
public:
|
sl@0
|
44 |
virtual void Overflow(TDes &/*aDes*/) {}
|
sl@0
|
45 |
};
|
sl@0
|
46 |
|
sl@0
|
47 |
TTest::TTest()
|
sl@0
|
48 |
//
|
sl@0
|
49 |
// Constructor, forces initialisation of variables.
|
sl@0
|
50 |
//
|
sl@0
|
51 |
{
|
sl@0
|
52 |
Init();
|
sl@0
|
53 |
}
|
sl@0
|
54 |
|
sl@0
|
55 |
TInt TTest::Init()
|
sl@0
|
56 |
///
|
sl@0
|
57 |
/// Initialise stuff (currently just the locks) if it hasn't been
|
sl@0
|
58 |
/// done already.
|
sl@0
|
59 |
///
|
sl@0
|
60 |
{
|
sl@0
|
61 |
if (!iInit)
|
sl@0
|
62 |
{
|
sl@0
|
63 |
TInt r = KErrNone;
|
sl@0
|
64 |
r = iDebugLock.CreateLocal();
|
sl@0
|
65 |
if (r != KErrNone)
|
sl@0
|
66 |
{
|
sl@0
|
67 |
RDebug::Print(_L("ERROR %d creating iDebugLock\n"), r);
|
sl@0
|
68 |
return r;
|
sl@0
|
69 |
}
|
sl@0
|
70 |
r = iPrintLock.CreateLocal();
|
sl@0
|
71 |
if (r != KErrNone)
|
sl@0
|
72 |
{
|
sl@0
|
73 |
RDebug::Print(_L("ERROR %d creating iPrintLock\n"), r);
|
sl@0
|
74 |
return r;
|
sl@0
|
75 |
}
|
sl@0
|
76 |
iInit = ETrue;
|
sl@0
|
77 |
}
|
sl@0
|
78 |
return KErrNone;
|
sl@0
|
79 |
}
|
sl@0
|
80 |
|
sl@0
|
81 |
TInt TTest::Create(TInt aNum, TThreadFunction aFunction, const TDesC& aName)
|
sl@0
|
82 |
///
|
sl@0
|
83 |
/// Create a thread, setting up the name and our data area.
|
sl@0
|
84 |
///
|
sl@0
|
85 |
{
|
sl@0
|
86 |
if (aNum < 0 || aNum > KMaxThreads)
|
sl@0
|
87 |
{
|
sl@0
|
88 |
test.Printf(_L("Illegal thread %d\n"), aNum);
|
sl@0
|
89 |
test(EFalse);
|
sl@0
|
90 |
}
|
sl@0
|
91 |
TThreadData &d = iData[aNum];
|
sl@0
|
92 |
// test.Printf(_L("creating thread %d (%S)\n"), aNum, &aName);
|
sl@0
|
93 |
// d.iThread.LogonCancel(d.iStat);
|
sl@0
|
94 |
// d.iThread.Close();
|
sl@0
|
95 |
TInt r;
|
sl@0
|
96 |
r = d.iThread.Create(aName, aFunction, KDefaultStackSize+32*1024, KMinHeapSize, 0x20000, &d);
|
sl@0
|
97 |
if (r != KErrNone)
|
sl@0
|
98 |
{
|
sl@0
|
99 |
TBuf<128> buf;
|
sl@0
|
100 |
test.Printf(_L("Error creating thread %d '%S' (was %d '%S'): %S\n"),
|
sl@0
|
101 |
aNum, &aName, d.iNum, &d.iName, &TTest::ErrStr(r, buf));
|
sl@0
|
102 |
test(0);
|
sl@0
|
103 |
}
|
sl@0
|
104 |
d.iId = d.iThread.Id();
|
sl@0
|
105 |
d.iNum = aNum;
|
sl@0
|
106 |
d.iName = aName;
|
sl@0
|
107 |
d.iThread.Logon(d.iStat);
|
sl@0
|
108 |
return r;
|
sl@0
|
109 |
}
|
sl@0
|
110 |
|
sl@0
|
111 |
TInt TTest::RunOnly()
|
sl@0
|
112 |
///
|
sl@0
|
113 |
/// Resume all of the threads we have created.
|
sl@0
|
114 |
///
|
sl@0
|
115 |
{
|
sl@0
|
116 |
TInt i;
|
sl@0
|
117 |
for (i = 0; i < KMaxThreads; i++)
|
sl@0
|
118 |
{
|
sl@0
|
119 |
if (iData[i].iId > 0)
|
sl@0
|
120 |
{
|
sl@0
|
121 |
iData[i].iThread.Resume();
|
sl@0
|
122 |
}
|
sl@0
|
123 |
}
|
sl@0
|
124 |
return KErrNone;
|
sl@0
|
125 |
}
|
sl@0
|
126 |
|
sl@0
|
127 |
TInt TTest::Run(TBool aExitAny, TInt aTimeout)
|
sl@0
|
128 |
///
|
sl@0
|
129 |
/// Run until all (or any one) threads has completed, or until a timeout.
|
sl@0
|
130 |
/// @param aExitAny If true, exit when the first thread completes, otherwise
|
sl@0
|
131 |
/// wait until they have all completed.
|
sl@0
|
132 |
/// @param aTimeout if zero, no timeout, otherwise it is the timeout in microseconds.
|
sl@0
|
133 |
///
|
sl@0
|
134 |
{
|
sl@0
|
135 |
TInt i;
|
sl@0
|
136 |
TInt status = RunOnly();
|
sl@0
|
137 |
RTimer timer;
|
sl@0
|
138 |
TRequestStatus tstat;
|
sl@0
|
139 |
timer.CreateLocal();
|
sl@0
|
140 |
if (aTimeout)
|
sl@0
|
141 |
timer.After(tstat, aTimeout);
|
sl@0
|
142 |
for (;;)
|
sl@0
|
143 |
{
|
sl@0
|
144 |
status = KErrNone;
|
sl@0
|
145 |
User::WaitForAnyRequest();
|
sl@0
|
146 |
if (aTimeout > 0 && tstat != KRequestPending)
|
sl@0
|
147 |
break;
|
sl@0
|
148 |
TBool running = EFalse;
|
sl@0
|
149 |
for (i = 0; i < KMaxThreads; i++)
|
sl@0
|
150 |
{
|
sl@0
|
151 |
if (iData[i].iId > 0)
|
sl@0
|
152 |
{
|
sl@0
|
153 |
if (iData[i].iStat == KRequestPending)
|
sl@0
|
154 |
{
|
sl@0
|
155 |
running = ETrue;
|
sl@0
|
156 |
}
|
sl@0
|
157 |
else
|
sl@0
|
158 |
{
|
sl@0
|
159 |
TThreadData &d = iData[i];
|
sl@0
|
160 |
// ignore result of LogonCancel, since we know thread has finished
|
sl@0
|
161 |
d.iThread.LogonCancel(d.iStat);
|
sl@0
|
162 |
d.iThread.Close();
|
sl@0
|
163 |
d.iId = 0;
|
sl@0
|
164 |
if (d.iStat != KErrNone)
|
sl@0
|
165 |
{
|
sl@0
|
166 |
status = KErrAbort;
|
sl@0
|
167 |
TBuf<32> ebuf;
|
sl@0
|
168 |
test.Printf(_L("ERROR: %S in thread %S: %S\n %S"),
|
sl@0
|
169 |
&ErrStr(d.iStat.Int(), ebuf), &d.iName, &d.iMess, &iWhere);
|
sl@0
|
170 |
if (aExitAny)
|
sl@0
|
171 |
{
|
sl@0
|
172 |
running = EFalse;
|
sl@0
|
173 |
break;
|
sl@0
|
174 |
}
|
sl@0
|
175 |
}
|
sl@0
|
176 |
}
|
sl@0
|
177 |
}
|
sl@0
|
178 |
}
|
sl@0
|
179 |
if (!running)
|
sl@0
|
180 |
break;
|
sl@0
|
181 |
}
|
sl@0
|
182 |
timer.Cancel();
|
sl@0
|
183 |
timer.Close();
|
sl@0
|
184 |
return status;
|
sl@0
|
185 |
}
|
sl@0
|
186 |
|
sl@0
|
187 |
void TTest::KillAll(TInt aReason)
|
sl@0
|
188 |
//
|
sl@0
|
189 |
// Kill (destroy) all of the created threads, then wait for up to 10 seconds
|
sl@0
|
190 |
// for them all to die (and just exit if any are still alive).
|
sl@0
|
191 |
//
|
sl@0
|
192 |
{
|
sl@0
|
193 |
for (TInt i = 0; i < KMaxThreads; i++)
|
sl@0
|
194 |
{
|
sl@0
|
195 |
if (iData[i].iId > 0)
|
sl@0
|
196 |
{
|
sl@0
|
197 |
TThreadData &d = iData[i];
|
sl@0
|
198 |
d.iThread.Kill(aReason);
|
sl@0
|
199 |
}
|
sl@0
|
200 |
}
|
sl@0
|
201 |
Run(EFalse, 10*KSecond);
|
sl@0
|
202 |
}
|
sl@0
|
203 |
|
sl@0
|
204 |
TThreadData& TTest::Self()
|
sl@0
|
205 |
///
|
sl@0
|
206 |
/// Return a reference to the current thread; if it's not one we've created
|
sl@0
|
207 |
/// return a reference to a dummy data area indicating no thread.
|
sl@0
|
208 |
///
|
sl@0
|
209 |
{
|
sl@0
|
210 |
RThread me;
|
sl@0
|
211 |
TInt i;
|
sl@0
|
212 |
for (i = 0; i < KMaxThreads; i++)
|
sl@0
|
213 |
{
|
sl@0
|
214 |
if (me.Id() == iData[i].iId)
|
sl@0
|
215 |
{
|
sl@0
|
216 |
return iData[i];
|
sl@0
|
217 |
}
|
sl@0
|
218 |
}
|
sl@0
|
219 |
iDummy.iId = 0;
|
sl@0
|
220 |
iDummy.iNum = -1;
|
sl@0
|
221 |
iDummy.iName.Format(_L("#%d"), (TUint)me.Id());
|
sl@0
|
222 |
return iDummy;
|
sl@0
|
223 |
}
|
sl@0
|
224 |
|
sl@0
|
225 |
TThreadData& TTest::Data(TInt aIndex)
|
sl@0
|
226 |
///
|
sl@0
|
227 |
/// Return a reference to the data area for the specified thread, or to a
|
sl@0
|
228 |
/// dummy area if it's not in the right range.
|
sl@0
|
229 |
///
|
sl@0
|
230 |
/// @param aIndex index to the thread (ThreadData::iNum is the same number).
|
sl@0
|
231 |
///
|
sl@0
|
232 |
{
|
sl@0
|
233 |
if (aIndex >= 0 && aIndex < KMaxThreads)
|
sl@0
|
234 |
return iData[aIndex];
|
sl@0
|
235 |
iDummy.iId = 0;
|
sl@0
|
236 |
iDummy.iNum = -1;
|
sl@0
|
237 |
iDummy.iName = _L("");
|
sl@0
|
238 |
return iDummy;
|
sl@0
|
239 |
}
|
sl@0
|
240 |
|
sl@0
|
241 |
void TTest::Start(const TDesC& aStr)
|
sl@0
|
242 |
///
|
sl@0
|
243 |
/// Output "START TEST" and the string.
|
sl@0
|
244 |
///
|
sl@0
|
245 |
{
|
sl@0
|
246 |
Printf(_L("START TEST: %S\n"), &aStr);
|
sl@0
|
247 |
}
|
sl@0
|
248 |
|
sl@0
|
249 |
void TTest::Next(const TDesC& aStr)
|
sl@0
|
250 |
///
|
sl@0
|
251 |
/// Output "NEXT TEST" and the string.
|
sl@0
|
252 |
///
|
sl@0
|
253 |
{
|
sl@0
|
254 |
Printf(_L("NEXT TEST: %S\n"), &aStr);
|
sl@0
|
255 |
}
|
sl@0
|
256 |
|
sl@0
|
257 |
void TTest::PrintLock()
|
sl@0
|
258 |
///
|
sl@0
|
259 |
/// Wait if another task is doing output.
|
sl@0
|
260 |
///
|
sl@0
|
261 |
{
|
sl@0
|
262 |
iPrintLock.Wait();
|
sl@0
|
263 |
}
|
sl@0
|
264 |
|
sl@0
|
265 |
void TTest::PrintUnlock()
|
sl@0
|
266 |
///
|
sl@0
|
267 |
/// Signal that output is complete so that other tasks can do output.
|
sl@0
|
268 |
///
|
sl@0
|
269 |
{
|
sl@0
|
270 |
iPrintLock.Signal();
|
sl@0
|
271 |
}
|
sl@0
|
272 |
|
sl@0
|
273 |
void TTest::Printf(TRefByValue<const TDesC> aFmt, ...)
|
sl@0
|
274 |
///
|
sl@0
|
275 |
/// Output the formatted text, prepending it with the thread name if it is one
|
sl@0
|
276 |
/// we've created. Parameters as for printf(). Note that if more than one
|
sl@0
|
277 |
/// thread tries to call it at the same time it will lock so that only one is
|
sl@0
|
278 |
/// processed at a time, the debug output isn't thread-safe (it can mix
|
sl@0
|
279 |
/// characters from different threads).
|
sl@0
|
280 |
///
|
sl@0
|
281 |
{
|
sl@0
|
282 |
TTestOverflowTruncate overflow;
|
sl@0
|
283 |
VA_LIST list;
|
sl@0
|
284 |
VA_START(list, aFmt);
|
sl@0
|
285 |
TBuf<256> buf;
|
sl@0
|
286 |
buf.SetLength(0);
|
sl@0
|
287 |
if (Self().iNum >= 0)
|
sl@0
|
288 |
{
|
sl@0
|
289 |
buf.Append(Self().iName);
|
sl@0
|
290 |
buf.Append(_L(": "));
|
sl@0
|
291 |
}
|
sl@0
|
292 |
buf.AppendFormatList(aFmt, list, &overflow);
|
sl@0
|
293 |
#if defined(__WINS__)
|
sl@0
|
294 |
if (buf.Right(1) != _L("\n"))
|
sl@0
|
295 |
buf.Append(_L("\n"));
|
sl@0
|
296 |
#else
|
sl@0
|
297 |
if (buf.Right(1) == _L("\n"))
|
sl@0
|
298 |
buf.SetLength(buf.Length() - 1);
|
sl@0
|
299 |
#endif
|
sl@0
|
300 |
iDebugLock.Wait();
|
sl@0
|
301 |
RDebug::Print(_L("%S"), &buf);
|
sl@0
|
302 |
iDebugLock.Signal();
|
sl@0
|
303 |
VA_END(list);
|
sl@0
|
304 |
}
|
sl@0
|
305 |
|
sl@0
|
306 |
void TTest::Printf()
|
sl@0
|
307 |
///
|
sl@0
|
308 |
/// Output a blank line, prepended with the thread name if any.
|
sl@0
|
309 |
///
|
sl@0
|
310 |
{
|
sl@0
|
311 |
Printf(_L("\n"));
|
sl@0
|
312 |
}
|
sl@0
|
313 |
|
sl@0
|
314 |
void TTest::Fail(TPos aPos, TRefByValue<const TDesC> aFmt, ...)
|
sl@0
|
315 |
///
|
sl@0
|
316 |
/// Output an error message (formatted as for printf()), then exit the thread.
|
sl@0
|
317 |
/// The message is placed in the buffer associated with the thread so that
|
sl@0
|
318 |
/// the parent task can display it.
|
sl@0
|
319 |
///
|
sl@0
|
320 |
{
|
sl@0
|
321 |
VA_LIST list;
|
sl@0
|
322 |
VA_START(list, aFmt);
|
sl@0
|
323 |
Self().iMess.FormatList(aFmt, list);
|
sl@0
|
324 |
iDebugLock.Wait();
|
sl@0
|
325 |
TPtrC8 ptr((TUint8*)aPos.iFailFile);
|
sl@0
|
326 |
gErrorPos.Copy(ptr);
|
sl@0
|
327 |
iWhere.Format(_L(" %S line %d\n"), &gErrorPos, aPos.iFailLine);
|
sl@0
|
328 |
RDebug::Print(_L("\n"));
|
sl@0
|
329 |
RDebug::Print(_L("ERROR in thread %S: %S"), &Self().iName, &Self().iMess);
|
sl@0
|
330 |
RDebug::Print(_L(" %S line %d\n"), &gErrorPos, aPos.iFailLine);
|
sl@0
|
331 |
RDebug::Print(_L("\n"));
|
sl@0
|
332 |
iDebugLock.Signal();
|
sl@0
|
333 |
User::Exit(KErrAbort);
|
sl@0
|
334 |
}
|
sl@0
|
335 |
|
sl@0
|
336 |
void TTest::Fail(TPos aPos, TInt aErr, TRefByValue<const TDesC> aFmt, ...)
|
sl@0
|
337 |
///
|
sl@0
|
338 |
/// Output an error message including the interpreted error value followed
|
sl@0
|
339 |
/// by the specified text (formatted as for printf()), then exit the thread.
|
sl@0
|
340 |
/// The message is placed in the buffer associated with the thread so that
|
sl@0
|
341 |
/// the parent task can display it.
|
sl@0
|
342 |
///
|
sl@0
|
343 |
{
|
sl@0
|
344 |
VA_LIST list;
|
sl@0
|
345 |
VA_START(list, aFmt);
|
sl@0
|
346 |
TBuf<32> ebuf;
|
sl@0
|
347 |
ErrStr(aErr, ebuf);
|
sl@0
|
348 |
Self().iMess.FormatList(aFmt, list);
|
sl@0
|
349 |
iDebugLock.Wait();
|
sl@0
|
350 |
TPtrC8 ptr((TUint8*)aPos.iFailFile);
|
sl@0
|
351 |
gErrorPos.Copy(ptr);
|
sl@0
|
352 |
iWhere.Format(_L(" %S line %d\n"), &gErrorPos, aPos.iFailLine);
|
sl@0
|
353 |
RDebug::Print(_L("\n"));
|
sl@0
|
354 |
RDebug::Print(_L("%S in thread %S: %S"), &ebuf, &Self().iName, &Self().iMess);
|
sl@0
|
355 |
RDebug::Print(_L(" %S line %d\n"), &gErrorPos, aPos.iFailLine);
|
sl@0
|
356 |
RDebug::Print(_L("\n"));
|
sl@0
|
357 |
iDebugLock.Signal();
|
sl@0
|
358 |
User::Exit(aErr);
|
sl@0
|
359 |
}
|
sl@0
|
360 |
|
sl@0
|
361 |
TDesC& TTest::ErrStr(TInt aErr, TDes& aDes)
|
sl@0
|
362 |
///
|
sl@0
|
363 |
/// Interpret an error status value as a string in the specified buffer.
|
sl@0
|
364 |
/// If the value isn't recognised then it formats a string containing the
|
sl@0
|
365 |
/// value itself (like "Error -65").
|
sl@0
|
366 |
/// @param aErr The error value.
|
sl@0
|
367 |
/// @param aDes Descriptor of the buffer to be used.
|
sl@0
|
368 |
/// @return Descriptor of the buffer.
|
sl@0
|
369 |
///
|
sl@0
|
370 |
{
|
sl@0
|
371 |
switch (aErr)
|
sl@0
|
372 |
{
|
sl@0
|
373 |
case KErrNone:
|
sl@0
|
374 |
aDes = _L("KErrNone");
|
sl@0
|
375 |
break;
|
sl@0
|
376 |
case KErrNotFound:
|
sl@0
|
377 |
aDes = _L("KErrNotFound");
|
sl@0
|
378 |
break;
|
sl@0
|
379 |
case KErrGeneral:
|
sl@0
|
380 |
aDes = _L("KErrGeneral");
|
sl@0
|
381 |
break;
|
sl@0
|
382 |
case KErrCancel:
|
sl@0
|
383 |
aDes = _L("KErrCancel");
|
sl@0
|
384 |
break;
|
sl@0
|
385 |
case KErrNoMemory:
|
sl@0
|
386 |
aDes = _L("KErrNoMemory");
|
sl@0
|
387 |
break;
|
sl@0
|
388 |
case KErrNotSupported:
|
sl@0
|
389 |
aDes = _L("KErrNotSupported");
|
sl@0
|
390 |
break;
|
sl@0
|
391 |
case KErrArgument:
|
sl@0
|
392 |
aDes = _L("KErrArgument");
|
sl@0
|
393 |
break;
|
sl@0
|
394 |
case KErrTotalLossOfPrecision:
|
sl@0
|
395 |
aDes = _L("KErrTotalLossOfPrecision");
|
sl@0
|
396 |
break;
|
sl@0
|
397 |
case KErrBadHandle:
|
sl@0
|
398 |
aDes = _L("KErrBadHandle");
|
sl@0
|
399 |
break;
|
sl@0
|
400 |
case KErrOverflow:
|
sl@0
|
401 |
aDes = _L("KErrOverflow");
|
sl@0
|
402 |
break;
|
sl@0
|
403 |
case KErrUnderflow:
|
sl@0
|
404 |
aDes = _L("KErrUnderflow");
|
sl@0
|
405 |
break;
|
sl@0
|
406 |
case KErrAlreadyExists:
|
sl@0
|
407 |
aDes = _L("KErrAlreadyExists");
|
sl@0
|
408 |
break;
|
sl@0
|
409 |
case KErrPathNotFound:
|
sl@0
|
410 |
aDes = _L("KErrPathNotFound");
|
sl@0
|
411 |
break;
|
sl@0
|
412 |
case KErrDied:
|
sl@0
|
413 |
aDes = _L("KErrDied");
|
sl@0
|
414 |
break;
|
sl@0
|
415 |
case KErrInUse:
|
sl@0
|
416 |
aDes = _L("KErrInUse");
|
sl@0
|
417 |
break;
|
sl@0
|
418 |
case KErrServerTerminated:
|
sl@0
|
419 |
aDes = _L("KErrServerTerminated");
|
sl@0
|
420 |
break;
|
sl@0
|
421 |
case KErrServerBusy:
|
sl@0
|
422 |
aDes = _L("KErrServerBusy");
|
sl@0
|
423 |
break;
|
sl@0
|
424 |
case KErrCompletion:
|
sl@0
|
425 |
aDes = _L("KErrCompletion");
|
sl@0
|
426 |
break;
|
sl@0
|
427 |
case KErrNotReady:
|
sl@0
|
428 |
aDes = _L("KErrNotReady");
|
sl@0
|
429 |
break;
|
sl@0
|
430 |
case KErrUnknown:
|
sl@0
|
431 |
aDes = _L("KErrUnknown");
|
sl@0
|
432 |
break;
|
sl@0
|
433 |
case KErrCorrupt:
|
sl@0
|
434 |
aDes = _L("KErrCorrupt");
|
sl@0
|
435 |
break;
|
sl@0
|
436 |
case KErrAccessDenied:
|
sl@0
|
437 |
aDes = _L("KErrAccessDenied");
|
sl@0
|
438 |
break;
|
sl@0
|
439 |
case KErrLocked:
|
sl@0
|
440 |
aDes = _L("KErrLocked");
|
sl@0
|
441 |
break;
|
sl@0
|
442 |
case KErrWrite:
|
sl@0
|
443 |
aDes = _L("KErrWrite");
|
sl@0
|
444 |
break;
|
sl@0
|
445 |
case KErrDisMounted:
|
sl@0
|
446 |
aDes = _L("KErrDisMounted");
|
sl@0
|
447 |
break;
|
sl@0
|
448 |
case KErrEof:
|
sl@0
|
449 |
aDes = _L("KErrEof");
|
sl@0
|
450 |
break;
|
sl@0
|
451 |
case KErrDiskFull:
|
sl@0
|
452 |
aDes = _L("KErrDiskFull");
|
sl@0
|
453 |
break;
|
sl@0
|
454 |
case KErrBadDriver:
|
sl@0
|
455 |
aDes = _L("KErrBadDriver");
|
sl@0
|
456 |
break;
|
sl@0
|
457 |
case KErrBadName:
|
sl@0
|
458 |
aDes = _L("KErrBadName");
|
sl@0
|
459 |
break;
|
sl@0
|
460 |
case KErrCommsLineFail:
|
sl@0
|
461 |
aDes = _L("KErrCommsLineFail");
|
sl@0
|
462 |
break;
|
sl@0
|
463 |
case KErrCommsFrame:
|
sl@0
|
464 |
aDes = _L("KErrCommsFrame");
|
sl@0
|
465 |
break;
|
sl@0
|
466 |
case KErrCommsOverrun:
|
sl@0
|
467 |
aDes = _L("KErrCommsOverrun");
|
sl@0
|
468 |
break;
|
sl@0
|
469 |
case KErrCommsParity:
|
sl@0
|
470 |
aDes = _L("KErrCommsParity");
|
sl@0
|
471 |
break;
|
sl@0
|
472 |
case KErrTimedOut:
|
sl@0
|
473 |
aDes = _L("KErrTimedOut");
|
sl@0
|
474 |
break;
|
sl@0
|
475 |
case KErrCouldNotConnect:
|
sl@0
|
476 |
aDes = _L("KErrCouldNotConnect");
|
sl@0
|
477 |
break;
|
sl@0
|
478 |
case KErrCouldNotDisconnect:
|
sl@0
|
479 |
aDes = _L("KErrCouldNotDisconnect");
|
sl@0
|
480 |
break;
|
sl@0
|
481 |
case KErrDisconnected:
|
sl@0
|
482 |
aDes = _L("KErrDisconnected");
|
sl@0
|
483 |
break;
|
sl@0
|
484 |
case KErrBadLibraryEntryPoint:
|
sl@0
|
485 |
aDes = _L("KErrBadLibraryEntryPoint");
|
sl@0
|
486 |
break;
|
sl@0
|
487 |
case KErrBadDescriptor:
|
sl@0
|
488 |
aDes = _L("KErrBadDescriptor");
|
sl@0
|
489 |
break;
|
sl@0
|
490 |
case KErrAbort:
|
sl@0
|
491 |
aDes = _L("KErrAbort");
|
sl@0
|
492 |
break;
|
sl@0
|
493 |
case KErrTooBig:
|
sl@0
|
494 |
aDes = _L("KErrTooBig");
|
sl@0
|
495 |
break;
|
sl@0
|
496 |
case KErrDivideByZero:
|
sl@0
|
497 |
aDes = _L("KErrDivideByZero");
|
sl@0
|
498 |
break;
|
sl@0
|
499 |
case KErrBadPower:
|
sl@0
|
500 |
aDes = _L("KErrBadPower");
|
sl@0
|
501 |
break;
|
sl@0
|
502 |
case KErrDirFull:
|
sl@0
|
503 |
aDes = _L("KErrDirFull");
|
sl@0
|
504 |
break;
|
sl@0
|
505 |
case KErrHardwareNotAvailable:
|
sl@0
|
506 |
aDes = _L("KErrHardwareNotAvailable");
|
sl@0
|
507 |
break;
|
sl@0
|
508 |
case KErrSessionClosed:
|
sl@0
|
509 |
aDes = _L("KErrSessionClosed");
|
sl@0
|
510 |
break;
|
sl@0
|
511 |
case KErrPermissionDenied:
|
sl@0
|
512 |
aDes = _L("KErrPermissionDenied");
|
sl@0
|
513 |
break;
|
sl@0
|
514 |
case KRequestPending:
|
sl@0
|
515 |
aDes = _L("KRequestPending");
|
sl@0
|
516 |
break;
|
sl@0
|
517 |
default:
|
sl@0
|
518 |
aDes = _L("Error ");
|
sl@0
|
519 |
aDes.AppendNum(aErr);
|
sl@0
|
520 |
break;
|
sl@0
|
521 |
}
|
sl@0
|
522 |
return aDes;
|
sl@0
|
523 |
}
|
sl@0
|
524 |
|
sl@0
|
525 |
TInt TTest::ParseCommandArguments(TPtrC aArgV[], TInt aArgMax)
|
sl@0
|
526 |
///
|
sl@0
|
527 |
/// Parse command line. Put the parameters into array aArgv for
|
sl@0
|
528 |
/// use by the tests, strip out flags starting with / or - and interpret
|
sl@0
|
529 |
/// them to set debug flags.
|
sl@0
|
530 |
///
|
sl@0
|
531 |
{
|
sl@0
|
532 |
RFs fs;
|
sl@0
|
533 |
TInt r = fs.Connect();
|
sl@0
|
534 |
test(r == KErrNone);
|
sl@0
|
535 |
TInt flags = 0;
|
sl@0
|
536 |
TInt argc = ParseCommandArguments(aArgV, aArgMax, flags);
|
sl@0
|
537 |
fs.SetDebugRegister(flags);
|
sl@0
|
538 |
fs.Close();
|
sl@0
|
539 |
return argc;
|
sl@0
|
540 |
}
|
sl@0
|
541 |
|
sl@0
|
542 |
TInt TTest::ParseCommandArguments(TPtrC aArgV[], TInt aArgMax, TInt& aDebugFlags)
|
sl@0
|
543 |
///
|
sl@0
|
544 |
/// Parse command line. Put the parameters into array aArgv for
|
sl@0
|
545 |
/// use by the tests, strip out flags starting with / or - and interpret
|
sl@0
|
546 |
/// them to set debug flags.
|
sl@0
|
547 |
///
|
sl@0
|
548 |
{
|
sl@0
|
549 |
LOCAL_D TBuf<0x100> cmd;
|
sl@0
|
550 |
User::CommandLine(cmd);
|
sl@0
|
551 |
TLex lex(cmd);
|
sl@0
|
552 |
TPtrC token=lex.NextToken();
|
sl@0
|
553 |
TFileName thisfile=RProcess().FileName();
|
sl@0
|
554 |
if (token.MatchF(thisfile)==0)
|
sl@0
|
555 |
{
|
sl@0
|
556 |
token.Set(lex.NextToken());
|
sl@0
|
557 |
}
|
sl@0
|
558 |
// set up parameter list (offset zero is the filename)
|
sl@0
|
559 |
TInt argc = 0;
|
sl@0
|
560 |
aArgV[argc++].Set(thisfile);
|
sl@0
|
561 |
while (token.Length() != 0)
|
sl@0
|
562 |
{
|
sl@0
|
563 |
TChar ch = token[0];
|
sl@0
|
564 |
// strip out (and interpret) flags starting with - or /
|
sl@0
|
565 |
if (ch == '-' || ch == '/')
|
sl@0
|
566 |
{
|
sl@0
|
567 |
for (TInt i = 1; i < token.Length(); i++)
|
sl@0
|
568 |
{
|
sl@0
|
569 |
switch (User::UpperCase(token[i]))
|
sl@0
|
570 |
{
|
sl@0
|
571 |
case 'D':
|
sl@0
|
572 |
aDebugFlags |= KDLYFAST;
|
sl@0
|
573 |
break;
|
sl@0
|
574 |
case 'F':
|
sl@0
|
575 |
aDebugFlags |= KFSYS;
|
sl@0
|
576 |
break;
|
sl@0
|
577 |
case 'I':
|
sl@0
|
578 |
aDebugFlags |= KISO9660;
|
sl@0
|
579 |
break;
|
sl@0
|
580 |
case 'L':
|
sl@0
|
581 |
aDebugFlags |= KFLDR;
|
sl@0
|
582 |
break;
|
sl@0
|
583 |
#ifdef __CONCURRENT_FILE_ACCESS__
|
sl@0
|
584 |
case 'M':
|
sl@0
|
585 |
aDebugFlags |= KTHRD;
|
sl@0
|
586 |
break;
|
sl@0
|
587 |
#endif
|
sl@0
|
588 |
case 'N':
|
sl@0
|
589 |
aDebugFlags |= KNTFS;
|
sl@0
|
590 |
break;
|
sl@0
|
591 |
case 'S':
|
sl@0
|
592 |
aDebugFlags |= KFSERV;
|
sl@0
|
593 |
break;
|
sl@0
|
594 |
case 'T':
|
sl@0
|
595 |
aDebugFlags |= KLFFS;
|
sl@0
|
596 |
break;
|
sl@0
|
597 |
case 'Y':
|
sl@0
|
598 |
aDebugFlags |= KDLYTRC;
|
sl@0
|
599 |
break;
|
sl@0
|
600 |
}
|
sl@0
|
601 |
}
|
sl@0
|
602 |
}
|
sl@0
|
603 |
else if (argc < aArgMax)
|
sl@0
|
604 |
aArgV[argc++].Set(token);
|
sl@0
|
605 |
token.Set(lex.NextToken());
|
sl@0
|
606 |
}
|
sl@0
|
607 |
return argc;
|
sl@0
|
608 |
}
|
sl@0
|
609 |
|
sl@0
|
610 |
TChar TTest::DefaultDriveChar()
|
sl@0
|
611 |
{
|
sl@0
|
612 |
TFileName session;
|
sl@0
|
613 |
RFs fs;
|
sl@0
|
614 |
fs.Connect();
|
sl@0
|
615 |
fs.SessionPath(session);
|
sl@0
|
616 |
fs.Close();
|
sl@0
|
617 |
TChar drvch = User::UpperCase(session[0]);
|
sl@0
|
618 |
return drvch;
|
sl@0
|
619 |
}
|
sl@0
|
620 |
|
sl@0
|
621 |
TTest::TPos::TPos(const char *aFile, TInt aLine)
|
sl@0
|
622 |
{
|
sl@0
|
623 |
iFailFile = aFile;
|
sl@0
|
624 |
iFailLine = aLine;
|
sl@0
|
625 |
}
|
sl@0
|
626 |
|