os/kernelhwsrv/kerneltest/f32test/loader/t_ldrtst.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/f32test/loader/t_ldrtst.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,172 @@
     1.4 +// Copyright (c) 1999-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 +// f32test\loader\t_ldrtst.h
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#ifndef __T_LDRTST_H__
    1.22 +#define __T_LDRTST_H__
    1.23 +
    1.24 +#define __INCLUDE_DEPENDENCY_GRAPH
    1.25 +
    1.26 +#include <e32svr.h>
    1.27 +#include <e32test.h>
    1.28 +#include <e32ver.h>
    1.29 +#include "dlltree.h"
    1.30 +#include "dllt.h"
    1.31 +#include "exetifc.h"
    1.32 +#include <d_ldrtst.h>
    1.33 +#include <f32file.h>
    1.34 +#include <f32dbg.h>
    1.35 +#include <e32rom.h>
    1.36 +
    1.37 +GLREF_D RTest test;
    1.38 +
    1.39 +class TModuleList;
    1.40 +class TModuleSet
    1.41 +	{
    1.42 +public:
    1.43 +	TModuleSet();
    1.44 +	TModuleSet(const TModuleList&, TInt aMask, TInt aVal);
    1.45 +	void Add(TInt aModule);
    1.46 +	void Remove(TInt aModule);
    1.47 +	void Remove(const TModuleList&);
    1.48 +	void Display(const TDesC& aTitle) const;
    1.49 +	inline TBool Present(TInt aModule) const
    1.50 +		{ return iBitMap[aModule>>3]&(1<<(aModule&7)); }
    1.51 +public:
    1.52 +	TInt iCount;
    1.53 +	TUint8 iBitMap[(KNumModules+7)/8];
    1.54 +	};
    1.55 +
    1.56 +class TModuleList
    1.57 +	{
    1.58 +public:
    1.59 +	TModuleList();
    1.60 +	void SetCount();
    1.61 +	void Display(const TDesC& aTitle) const;
    1.62 +	TBool IsPresent(TInt aModNum) const;
    1.63 +	TInt Find(TInt aModNum) const;
    1.64 +	void Add(const SDllInfo& a);
    1.65 +public:
    1.66 +	TInt iCount;
    1.67 +	SDllInfo iInfo[KNumModules];
    1.68 +	};
    1.69 +
    1.70 +class LoaderTest
    1.71 +	{
    1.72 +public:
    1.73 +	static LoaderTest* New();
    1.74 +	void Close();
    1.75 +	void Init();
    1.76 +public:
    1.77 +	void TestOneByOne();
    1.78 +	void TestMultipleExeInstances();
    1.79 +	void TestOOM();
    1.80 +	void TestMultipleLoads();
    1.81 +private:
    1.82 +	TBool IsRomAddress(TLinAddr a);
    1.83 +	TBool IsRamCodeAddress(TLinAddr a);
    1.84 +	TBool CheckDataAddress(TLinAddr a, TInt aDllNum, TInt aExeNum);
    1.85 +	TInt DetermineDllLoadResult(TInt aDllNum, TInt aExeNum);
    1.86 +	TInt DetermineDllLoadResult(TInt aDllNum, TInt aExeNum1, TInt aExeNum2);
    1.87 +	TInt DetermineLoadExe2Result(TInt aExeNum);
    1.88 +	void DumpModuleList(const TModuleList& aList, TInt aExeNum);
    1.89 +	void DumpModuleInfo(const SDllInfo& aInfo, TInt aExeNum);
    1.90 +	void CheckModuleList(TInt aRoot, const TModuleList& aList);
    1.91 +public:
    1.92 +	void TraceOn();
    1.93 +	void TraceOff();
    1.94 +private:
    1.95 +	LoaderTest();
    1.96 +	~LoaderTest();
    1.97 +public:
    1.98 +	RFs iFs;
    1.99 +	RLdrTest iDev;
   1.100 +	TUint32 iMemModelAtt;
   1.101 +	TInt iCmdLine[8];
   1.102 +	};
   1.103 +
   1.104 +
   1.105 +const TInt KMaxHandlesPerDll=4;
   1.106 +const TInt KMaxHandles=KMaxHandlesPerDll*KNumModules;
   1.107 +
   1.108 +struct SModuleInstance
   1.109 +	{
   1.110 +	TInt iAccessCount;
   1.111 +	TInt iModNum;
   1.112 +	TLinAddr iEntryPointAddress;
   1.113 +	TModuleHandle iModuleHandle;
   1.114 +	TLinAddr iData;
   1.115 +	TAny* iCodeSeg;
   1.116 +	};
   1.117 +
   1.118 +class CGlobalModuleList;
   1.119 +class CPerProcessInfo : public CBase
   1.120 +	{
   1.121 +public:
   1.122 +	static CPerProcessInfo* New(TInt aExeNum, CGlobalModuleList& aG);
   1.123 +	virtual ~CPerProcessInfo();
   1.124 +	void GetModuleSet(TModuleSet& aSet);
   1.125 +	void Check();
   1.126 +	void Unlink(const SDllInfo& a, TModuleList& aList);
   1.127 +	TInt Load(TInt aDllNum);
   1.128 +	TInt AddModules(TInt aDllNum, TModuleList* aCList, TModuleList* aIList);
   1.129 +	TInt CloseHandle(TInt aHandle);
   1.130 +private:
   1.131 +	CPerProcessInfo();
   1.132 +	TInt Init();
   1.133 +public:
   1.134 +	TInt iExeNum;
   1.135 +	TRequestStatus iStatus;
   1.136 +	RProcess iProcess;
   1.137 +	RLoaderTest iSession;
   1.138 +	RLdrTest iDev;
   1.139 +	CGlobalModuleList* iGlobalList;
   1.140 +	TInt iModuleNum[KMaxHandles];
   1.141 +	TInt iHandleCount[KNumModules];
   1.142 +	SModuleInstance* iModules[KNumModules];
   1.143 +	};
   1.144 +
   1.145 +class CGlobalModuleList : public CBase
   1.146 +	{
   1.147 +public:
   1.148 +	static CGlobalModuleList* New(const LoaderTest&);
   1.149 +	virtual ~CGlobalModuleList();
   1.150 +	void Close(SModuleInstance* a);
   1.151 +	void Free(SModuleInstance* a);
   1.152 +	SModuleInstance* GetMI();
   1.153 +	TAny* CodeSegFromHandle(TModuleHandle aModHandle);
   1.154 +	void CheckAll();
   1.155 +	TInt Load(TInt aExeNum, TInt aDllNum);
   1.156 +	TInt CloseHandle(TInt aExeNum, TInt aDllNum);
   1.157 +private:
   1.158 +	CGlobalModuleList();
   1.159 +	void Init();
   1.160 +public:
   1.161 +	TInt iMaxModules;
   1.162 +	TInt iNumExes;
   1.163 +	TInt iFixedExes;
   1.164 +	TInt iParam;
   1.165 +	RLdrTest iDev;
   1.166 +	TUint32 iMemModelAtt;
   1.167 +	CPerProcessInfo* iPPInfo[KNumModules];
   1.168 +	RPointerArray<SModuleInstance> iModules;
   1.169 +	SModuleInstance* iModuleAlloc;
   1.170 +	SModuleInstance* iFreeModules;
   1.171 +	};
   1.172 +
   1.173 +void GetNonZFileName(const TDesC& aOrigName, TDes& aNonZName);
   1.174 +
   1.175 +#endif