1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/smpsoak/t_smpsoak.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,182 @@
1.4 +// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// e32test\smpsoak\t_smpsoak.h
1.18 +
1.19 +#if (!defined __T_SMPSOAK_H__)
1.20 +#define __T_SMPSOAK_H__
1.21 +
1.22 +#define __E32TEST_EXTENSION__
1.23 +// EPOC includes
1.24 +#include <e32test.h>
1.25 +#include <u32hal.h>
1.26 +#include <f32file.h>
1.27 +#include <e32math.h>
1.28 +
1.29 +// User Includes
1.30 +#include "d_smpsoak.h"
1.31 +
1.32 +TBool TestSilent = EFalse;
1.33 +TBool Period = EFalse;
1.34 +TBool timeout = EFalse;
1.35 +TBool ThreadPriorityLow = EFalse;
1.36 +TBuf<25> gCmdLine;
1.37 +_LIT(KCmdLineProcess, "%s");
1.38 +_LIT(KCmdLineBackground, "-b %s");
1.39 +_LIT(KCmdLinePeriod, "-p %d %s");
1.40 +
1.41 +TUint gPeriod = 10000;
1.42 +
1.43 +#define PRINT(args)\
1.44 + if (!TestSilent)\
1.45 + test.Printf args
1.46 +
1.47 +//Global Literals
1.48 +_LIT(KGlobalWriteSem, "GlobalWriteSem");
1.49 +_LIT(KGlobalReadSem, "GlobalReadSem");
1.50 +_LIT(KGlobalWRChunk, "GlobalWRChunk");
1.51 +_LIT(KSessionPath, "?:\\SMPSOAK-TST\\");
1.52 +_LIT(KDir, "Dir%d\\");
1.53 +_LIT(KFile, "\\SMPSOAK-TST\\Dir%d\\File%d.txt");
1.54 +_LIT(KFileData, "A$$$BCDEFGHIJKLMNOPQRSTUVWXY$$$Z");
1.55 +const TUint8* pattern = (TText8*)("A11$$222BCDEUVWXY££££$$$Z");
1.56 +
1.57 +
1.58 +//Global's used between the process
1.59 +const TUint32 KCpuAffinityAny=0xffffffffu;
1.60 +
1.61 +static RSemaphore gWriteSem;
1.62 +static RSemaphore gReadSem;
1.63 +static RChunk gChunk;
1.64 +static volatile TBool gAbort = EFalse; // Set true when escape key pressed
1.65 +static RSMPSoak gSMPStressDrv;
1.66 +static RSemaphore gSwitchSem;
1.67 +
1.68 +//Chunk Allocation IPC Read/Write operations
1.69 +static const TInt KChunkMaxSize = 0x01000000; //16 MB
1.70 +static const TInt KChunkSize = 0x400000; //4MB
1.71 +TBuf8<KChunkSize> memData;
1.72 +
1.73 +//Heap Allocations for OOM Threads
1.74 +const TInt KHeapMaxiSize = 0x200000; //2MB
1.75 +const TInt KHeapReserveSize = 0x100000; //1MB
1.76 +RSemaphore ooMemSem;
1.77 +
1.78 +//For Thread Creation
1.79 +const TInt KHeapMinSize= 0x1000;
1.80 +const TInt KHeapMaxSize= 0x1000;
1.81 +const TInt KTimerPeriod = 10000;
1.82 +const TInt KRandSeed= 1234;
1.83 +//Used by File thread's
1.84 +const TInt KFileNameLength = 100;
1.85 +const TInt KPriorityOrder = 4;
1.86 +static RTest test(_L("T_SMPSoak"));
1.87 +//Enum's for Memory Thread Operations
1.88 +enum
1.89 + {
1.90 + EChunkNone,
1.91 + EChunkNormalThread,
1.92 + EChunkDisconnectedThread,
1.93 + EChunkDoubleEndedThread,
1.94 + EChunkNormalProcess,
1.95 + EChunkDisconnectedProcess,
1.96 + EChunkDoubleEndedProcess,
1.97 + };
1.98 +//Process Priority
1.99 +enum
1.100 + {
1.101 + EpriorityFixed,
1.102 + EPriorityList,
1.103 + EPriorityIncrement,
1.104 + EPriorityRandom,
1.105 + };
1.106 +//Memory table structure for Memory thread
1.107 +struct TMemory
1.108 + {
1.109 + TPtrC globalChunkName;
1.110 + TInt chunkType;
1.111 + TInt initialBottom;
1.112 + TInt initialTop;
1.113 + TInt maxSize;
1.114 + };
1.115 +
1.116 +struct TChunkInfo
1.117 + {
1.118 + RChunk chunk;
1.119 + TInt lastBottom;
1.120 + TInt lastTop;
1.121 + };
1.122 +enum
1.123 + {
1.124 + KNumThreads = 7,
1.125 + KNumProcess = 4,
1.126 + KNumFileThreads = 4,
1.127 + KNumTimerThreads = 2,
1.128 + KNumOOMThreads = 4,
1.129 + KNumChunks = 13
1.130 + };
1.131 +TInt NumProcess = KNumProcess;
1.132 +//Device information for device thread
1.133 +_LIT(KDevices,"CDZ");
1.134 +_LIT(KDevLdd1,"ecomm.ldd");
1.135 +_LIT(KDevLdd1Name,"comm");
1.136 +_LIT(KDevLdd2,"elocd.ldd");
1.137 +_LIT(KDevLdd2Name,"LocDrv");
1.138 +_LIT(KDevLdd3,"enet.ldd");
1.139 +_LIT(KDevLdd3Name,"Ethernet");
1.140 +_LIT(KDevLdd4,"esoundsc.ldd");
1.141 +_LIT(KDevLdd4Name,"SoundSc");
1.142 +_LIT(KDevLdd5,"eusbc.ldd");
1.143 +_LIT(KDevLdd5Name, "Usbc");
1.144 +
1.145 +//Thread data for each thread
1.146 +struct TThreadData
1.147 + {
1.148 + TInt threadPriorities[4];
1.149 + TInt threadPriorityChange;
1.150 + TUint32 cpuAffinity;
1.151 + TInt delayTime;
1.152 + TInt numThreads;
1.153 + TAny *listPtr;
1.154 + TInt dirID;
1.155 + TInt numFile;
1.156 + };
1.157 +
1.158 +struct TThread
1.159 + {
1.160 + TPtrC threadName;
1.161 + TThreadFunction threadFunction;
1.162 + TThreadData threadData;
1.163 + };
1.164 +
1.165 +struct TProcess
1.166 + {
1.167 + TPtrC processFileName;
1.168 + TPtrC operation;
1.169 + TUint32 cpuAffinity;
1.170 + };
1.171 +
1.172 +inline void ShowHelp()
1.173 + {
1.174 + PRINT(_L("***************************************\n"));
1.175 + PRINT(_L("The following are immediate commands\n"));
1.176 + PRINT(_L("-l run includes Out of Memory thread tests \n"));
1.177 + PRINT(_L("-b run in silent mode\n"));
1.178 + PRINT(_L("-t nn test run with timeout in seconds\n"));
1.179 + PRINT(_L("-p nnnn period for each thread to sleep in iteration\n"));
1.180 + PRINT(_L("-h show this help\n"));
1.181 + PRINT(_L("Esc to shutdown\n"));
1.182 + PRINT(_L("***************************************\n"));
1.183 + }
1.184 +#endif /* __T_SMPSOAK_H__ */
1.185 +