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