sl@0
|
1 |
// Copyright (c) 2002-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 |
// e32test\smpsoak\t_smpsoak.h
|
sl@0
|
15 |
|
sl@0
|
16 |
#if (!defined __T_SMPSOAK_H__)
|
sl@0
|
17 |
#define __T_SMPSOAK_H__
|
sl@0
|
18 |
|
sl@0
|
19 |
#define __E32TEST_EXTENSION__
|
sl@0
|
20 |
// EPOC includes
|
sl@0
|
21 |
#include <e32test.h>
|
sl@0
|
22 |
#include <u32hal.h>
|
sl@0
|
23 |
#include <f32file.h>
|
sl@0
|
24 |
#include <e32math.h>
|
sl@0
|
25 |
|
sl@0
|
26 |
// User Includes
|
sl@0
|
27 |
#include "d_smpsoak.h"
|
sl@0
|
28 |
|
sl@0
|
29 |
TBool TestSilent = EFalse;
|
sl@0
|
30 |
TBool Period = EFalse;
|
sl@0
|
31 |
TBool timeout = EFalse;
|
sl@0
|
32 |
TBool ThreadPriorityLow = EFalse;
|
sl@0
|
33 |
TBuf<25> gCmdLine;
|
sl@0
|
34 |
_LIT(KCmdLineProcess, "%s");
|
sl@0
|
35 |
_LIT(KCmdLineBackground, "-b %s");
|
sl@0
|
36 |
_LIT(KCmdLinePeriod, "-p %d %s");
|
sl@0
|
37 |
|
sl@0
|
38 |
TUint gPeriod = 10000;
|
sl@0
|
39 |
|
sl@0
|
40 |
#define PRINT(args)\
|
sl@0
|
41 |
if (!TestSilent)\
|
sl@0
|
42 |
test.Printf args
|
sl@0
|
43 |
|
sl@0
|
44 |
//Global Literals
|
sl@0
|
45 |
_LIT(KGlobalWriteSem, "GlobalWriteSem");
|
sl@0
|
46 |
_LIT(KGlobalReadSem, "GlobalReadSem");
|
sl@0
|
47 |
_LIT(KGlobalWRChunk, "GlobalWRChunk");
|
sl@0
|
48 |
_LIT(KSessionPath, "?:\\SMPSOAK-TST\\");
|
sl@0
|
49 |
_LIT(KDir, "Dir%d\\");
|
sl@0
|
50 |
_LIT(KFile, "\\SMPSOAK-TST\\Dir%d\\File%d.txt");
|
sl@0
|
51 |
_LIT(KFileData, "A$$$BCDEFGHIJKLMNOPQRSTUVWXY$$$Z");
|
sl@0
|
52 |
const TUint8* pattern = (TText8*)("A11$$222BCDEUVWXY££££$$$Z");
|
sl@0
|
53 |
|
sl@0
|
54 |
|
sl@0
|
55 |
//Global's used between the process
|
sl@0
|
56 |
const TUint32 KCpuAffinityAny=0xffffffffu;
|
sl@0
|
57 |
|
sl@0
|
58 |
static RSemaphore gWriteSem;
|
sl@0
|
59 |
static RSemaphore gReadSem;
|
sl@0
|
60 |
static RChunk gChunk;
|
sl@0
|
61 |
static volatile TBool gAbort = EFalse; // Set true when escape key pressed
|
sl@0
|
62 |
static RSMPSoak gSMPStressDrv;
|
sl@0
|
63 |
static RSemaphore gSwitchSem;
|
sl@0
|
64 |
|
sl@0
|
65 |
//Chunk Allocation IPC Read/Write operations
|
sl@0
|
66 |
static const TInt KChunkMaxSize = 0x01000000; //16 MB
|
sl@0
|
67 |
static const TInt KChunkSize = 0x400000; //4MB
|
sl@0
|
68 |
TBuf8<KChunkSize> memData;
|
sl@0
|
69 |
|
sl@0
|
70 |
//Heap Allocations for OOM Threads
|
sl@0
|
71 |
const TInt KHeapMaxiSize = 0x200000; //2MB
|
sl@0
|
72 |
const TInt KHeapReserveSize = 0x100000; //1MB
|
sl@0
|
73 |
RSemaphore ooMemSem;
|
sl@0
|
74 |
|
sl@0
|
75 |
//For Thread Creation
|
sl@0
|
76 |
const TInt KHeapMinSize= 0x1000;
|
sl@0
|
77 |
const TInt KHeapMaxSize= 0x1000;
|
sl@0
|
78 |
const TInt KTimerPeriod = 10000;
|
sl@0
|
79 |
const TInt KRandSeed= 1234;
|
sl@0
|
80 |
//Used by File thread's
|
sl@0
|
81 |
const TInt KFileNameLength = 100;
|
sl@0
|
82 |
const TInt KPriorityOrder = 4;
|
sl@0
|
83 |
static RTest test(_L("T_SMPSoak"));
|
sl@0
|
84 |
//Enum's for Memory Thread Operations
|
sl@0
|
85 |
enum
|
sl@0
|
86 |
{
|
sl@0
|
87 |
EChunkNone,
|
sl@0
|
88 |
EChunkNormalThread,
|
sl@0
|
89 |
EChunkDisconnectedThread,
|
sl@0
|
90 |
EChunkDoubleEndedThread,
|
sl@0
|
91 |
EChunkNormalProcess,
|
sl@0
|
92 |
EChunkDisconnectedProcess,
|
sl@0
|
93 |
EChunkDoubleEndedProcess,
|
sl@0
|
94 |
};
|
sl@0
|
95 |
//Process Priority
|
sl@0
|
96 |
enum
|
sl@0
|
97 |
{
|
sl@0
|
98 |
EpriorityFixed,
|
sl@0
|
99 |
EPriorityList,
|
sl@0
|
100 |
EPriorityIncrement,
|
sl@0
|
101 |
EPriorityRandom,
|
sl@0
|
102 |
};
|
sl@0
|
103 |
//Memory table structure for Memory thread
|
sl@0
|
104 |
struct TMemory
|
sl@0
|
105 |
{
|
sl@0
|
106 |
TPtrC globalChunkName;
|
sl@0
|
107 |
TInt chunkType;
|
sl@0
|
108 |
TInt initialBottom;
|
sl@0
|
109 |
TInt initialTop;
|
sl@0
|
110 |
TInt maxSize;
|
sl@0
|
111 |
};
|
sl@0
|
112 |
|
sl@0
|
113 |
struct TChunkInfo
|
sl@0
|
114 |
{
|
sl@0
|
115 |
RChunk chunk;
|
sl@0
|
116 |
TInt lastBottom;
|
sl@0
|
117 |
TInt lastTop;
|
sl@0
|
118 |
};
|
sl@0
|
119 |
enum
|
sl@0
|
120 |
{
|
sl@0
|
121 |
KNumThreads = 7,
|
sl@0
|
122 |
KNumProcess = 4,
|
sl@0
|
123 |
KNumFileThreads = 4,
|
sl@0
|
124 |
KNumTimerThreads = 2,
|
sl@0
|
125 |
KNumOOMThreads = 4,
|
sl@0
|
126 |
KNumChunks = 13
|
sl@0
|
127 |
};
|
sl@0
|
128 |
TInt NumProcess = KNumProcess;
|
sl@0
|
129 |
//Device information for device thread
|
sl@0
|
130 |
_LIT(KDevices,"CDZ");
|
sl@0
|
131 |
_LIT(KDevLdd1,"ecomm.ldd");
|
sl@0
|
132 |
_LIT(KDevLdd1Name,"comm");
|
sl@0
|
133 |
_LIT(KDevLdd2,"elocd.ldd");
|
sl@0
|
134 |
_LIT(KDevLdd2Name,"LocDrv");
|
sl@0
|
135 |
_LIT(KDevLdd3,"enet.ldd");
|
sl@0
|
136 |
_LIT(KDevLdd3Name,"Ethernet");
|
sl@0
|
137 |
_LIT(KDevLdd4,"esoundsc.ldd");
|
sl@0
|
138 |
_LIT(KDevLdd4Name,"SoundSc");
|
sl@0
|
139 |
_LIT(KDevLdd5,"eusbc.ldd");
|
sl@0
|
140 |
_LIT(KDevLdd5Name, "Usbc");
|
sl@0
|
141 |
|
sl@0
|
142 |
//Thread data for each thread
|
sl@0
|
143 |
struct TThreadData
|
sl@0
|
144 |
{
|
sl@0
|
145 |
TInt threadPriorities[4];
|
sl@0
|
146 |
TInt threadPriorityChange;
|
sl@0
|
147 |
TUint32 cpuAffinity;
|
sl@0
|
148 |
TInt delayTime;
|
sl@0
|
149 |
TInt numThreads;
|
sl@0
|
150 |
TAny *listPtr;
|
sl@0
|
151 |
TInt dirID;
|
sl@0
|
152 |
TInt numFile;
|
sl@0
|
153 |
};
|
sl@0
|
154 |
|
sl@0
|
155 |
struct TThread
|
sl@0
|
156 |
{
|
sl@0
|
157 |
TPtrC threadName;
|
sl@0
|
158 |
TThreadFunction threadFunction;
|
sl@0
|
159 |
TThreadData threadData;
|
sl@0
|
160 |
};
|
sl@0
|
161 |
|
sl@0
|
162 |
struct TProcess
|
sl@0
|
163 |
{
|
sl@0
|
164 |
TPtrC processFileName;
|
sl@0
|
165 |
TPtrC operation;
|
sl@0
|
166 |
TUint32 cpuAffinity;
|
sl@0
|
167 |
};
|
sl@0
|
168 |
|
sl@0
|
169 |
inline void ShowHelp()
|
sl@0
|
170 |
{
|
sl@0
|
171 |
PRINT(_L("***************************************\n"));
|
sl@0
|
172 |
PRINT(_L("The following are immediate commands\n"));
|
sl@0
|
173 |
PRINT(_L("-l run includes Out of Memory thread tests \n"));
|
sl@0
|
174 |
PRINT(_L("-b run in silent mode\n"));
|
sl@0
|
175 |
PRINT(_L("-t nn test run with timeout in seconds\n"));
|
sl@0
|
176 |
PRINT(_L("-p nnnn period for each thread to sleep in iteration\n"));
|
sl@0
|
177 |
PRINT(_L("-h show this help\n"));
|
sl@0
|
178 |
PRINT(_L("Esc to shutdown\n"));
|
sl@0
|
179 |
PRINT(_L("***************************************\n"));
|
sl@0
|
180 |
}
|
sl@0
|
181 |
#endif /* __T_SMPSOAK_H__ */
|
sl@0
|
182 |
|