0
|
1 |
// Copyright (c) 1996-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 |
//
|
|
15 |
|
|
16 |
//! @file f32test\concur\t_tdebug.h
|
|
17 |
|
|
18 |
#ifndef __T_TDEBUG_H__
|
|
19 |
#define __T_TDEBUG_H__
|
|
20 |
|
|
21 |
struct TThreadData
|
|
22 |
/// Data about a test task
|
|
23 |
{
|
|
24 |
RThread iThread; ///< thread class
|
|
25 |
TThreadId iId; ///< thread ID
|
|
26 |
TInt iNum; ///< thread number
|
|
27 |
TRequestStatus iStat; ///< current thread status
|
|
28 |
TFullName iFile; ///< file to be used for testing
|
|
29 |
TBuf<64> iName; ///< name of this thread
|
|
30 |
TBuf<256> iMess; ///< buffer for return messages
|
|
31 |
TAny* iData; ///< other data to be passed to the thread
|
|
32 |
};
|
|
33 |
|
|
34 |
const TInt KMaxThreads = 100;
|
|
35 |
|
|
36 |
class TTest
|
|
37 |
/// Replacement for RTest, for use within a task (RTest doesn't work in multiple tasks).
|
|
38 |
/// Each of the output commands prints the task name first on the line.
|
|
39 |
/// Note that all of the functions and data members of this class are static, they are
|
|
40 |
/// shared among all threads using the class.
|
|
41 |
{
|
|
42 |
public:
|
|
43 |
class TPos
|
|
44 |
{
|
|
45 |
public:
|
|
46 |
TPos(const char *aFile, TInt aLine);
|
|
47 |
public:
|
|
48 |
const char* iFailFile;
|
|
49 |
TInt iFailLine;
|
|
50 |
|
|
51 |
};
|
|
52 |
|
|
53 |
public:
|
|
54 |
TTest();
|
|
55 |
static void Start(const TDesC& aStr);
|
|
56 |
static void End(const TDesC& aStr);
|
|
57 |
static void Next(const TDesC& aStr);
|
|
58 |
static void PrintLock();
|
|
59 |
static void PrintUnlock();
|
|
60 |
static void Printf(TRefByValue<const TDesC> aFmt, ...);
|
|
61 |
static void Printf();
|
|
62 |
static void Fail(TPos aPos, TRefByValue<const TDesC> aFmt, ...);
|
|
63 |
static void Fail(TPos aPos, TInt aErr, TRefByValue<const TDesC> aFmt, ...);
|
|
64 |
|
|
65 |
static TDesC& ErrStr(TInt aErr, TDes& aDes);
|
|
66 |
|
|
67 |
static TInt Create(TInt aNum, TThreadFunction aFunction, const TDesC& aName);
|
|
68 |
static TInt Run(TBool aExitAny = EFalse, TInt aTimeout = 0);
|
|
69 |
static TInt RunOnly();
|
|
70 |
static void KillAll(TInt aReason);
|
|
71 |
|
|
72 |
static TThreadData& Self();
|
|
73 |
static TThreadData& Data(TInt aIndex);
|
|
74 |
|
|
75 |
static TInt ParseCommandArguments(TPtrC aArgV[], TInt aArgMax);
|
|
76 |
static TInt ParseCommandArguments(TPtrC aArgV[], TInt aArgMax, TInt& aDebFlags);
|
|
77 |
static TChar DefaultDriveChar();
|
|
78 |
|
|
79 |
static TInt Init();
|
|
80 |
|
|
81 |
private:
|
|
82 |
static TThreadData iData[KMaxThreads];
|
|
83 |
static TThreadData iDummy;
|
|
84 |
static RMutex iDebugLock;
|
|
85 |
static RMutex iPrintLock;
|
|
86 |
static TBool iInit;
|
|
87 |
static TFullName iWhere;
|
|
88 |
};
|
|
89 |
|
|
90 |
// Exit (panic) if the condition isn't met.
|
|
91 |
#define TEST(cond) if (!(cond)) { _LIT(err, #cond); TTest::Fail(HERE, _L("failed %S at line %d"), &err, __LINE__); }
|
|
92 |
#define HERE TTest::TPos(__FILE__, __LINE__)
|
|
93 |
|
|
94 |
// Define the TInt64 macros if they aren't already defined.
|
|
95 |
#ifndef MAKE_TINT64
|
|
96 |
#define MAKE_TINT64(h,l) ( TInt64((h), (l)) )
|
|
97 |
#define MAKE_TUINT64(h,l) ( TInt64((h), (l)) )
|
|
98 |
#define I64HIGH(x) ( (x).High() )
|
|
99 |
#define I64LOW(x) ( (x).Low() )
|
|
100 |
#define I64INT(x) ( (x).GetTInt() )
|
|
101 |
#define I64REAL(x) ( (x).GetTReal() )
|
|
102 |
#endif
|
|
103 |
|
|
104 |
#endif
|