0
|
1 |
// Copyright (c) 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 "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 |
// Test wrapper for unit tests of the self lib
|
|
15 |
|
|
16 |
/**
|
|
17 |
* @file CSelfLibWrapper.h
|
|
18 |
* @internalTechnology
|
|
19 |
* @prototype
|
|
20 |
*/
|
|
21 |
|
|
22 |
#ifndef __CSELFLIB_WRAPPER_H__
|
|
23 |
#define __CSELFLIB_WRAPPER_H__
|
|
24 |
|
|
25 |
#include <datawrapper.h>
|
|
26 |
#include <selflib.h>
|
|
27 |
#include <hal.h>
|
|
28 |
|
|
29 |
//Constructor TestCase names
|
|
30 |
_LIT(KSELFNewLC, "NewLC");
|
|
31 |
_LIT(KSELFNewL, "NewL");
|
|
32 |
|
|
33 |
//Negative tests for construction
|
|
34 |
_LIT(KSELF_InvalidSignature, "TestConstruction_InvalidFile_Signature");
|
|
35 |
_LIT(KSELF_InvalidSize, "TestConstruction_InvalidFile_Size");
|
|
36 |
_LIT(KSELF_NotSupported, "TestConstruction_NotSupported");
|
|
37 |
_LIT(KSELF_TestConstruction_Inuse, "TestConstruction_Inuse");
|
|
38 |
|
|
39 |
//Test for getters
|
|
40 |
_LIT(KSELF_GetElfHeaderL, "GetElfHeaderL");
|
|
41 |
|
|
42 |
//Test for insertion
|
|
43 |
_LIT(KSELF_InsertVariantSpecificData, "InsertVariantSpecificData");
|
|
44 |
_LIT(KSELF_InsertMultipleVariants, "InsertMultipleVariants");
|
|
45 |
_LIT(KSELF_InsertNothingAndUpdate, "InsertNothingAndUpdate");
|
|
46 |
_LIT(KSELF_TestPerformance, "TestPerformance");
|
|
47 |
_LIT(KSELF_TestStress, "TestStress");
|
|
48 |
|
|
49 |
//ELF Files to test
|
|
50 |
_LIT(KSELFFileName, "C:\\data\\testelf1.elf");
|
|
51 |
_LIT(KSELFFileNameInvalidBySignature, "C:\\data\\testelfinvalid.elf");
|
|
52 |
_LIT(KSELFFileNameTiny, "C:\\data\\tinytestelf.elf");
|
|
53 |
_LIT(KSELFFileNameNonExistant, "C:\\idontexist1.elf");
|
|
54 |
_LIT(KSELFFileNameExe, "C:\\data\\testelfexecutable.elf");
|
|
55 |
|
|
56 |
_LIT(KROMSELFFileName, "Z:\\data\\testelf1.elf");
|
|
57 |
_LIT(KROMSELFFileNameInvalidBySignature, "Z:\\data\\testelfinvalid.elf");
|
|
58 |
_LIT(KROMSELFFileNameTiny, "Z:\\data\\tinytestelf.elf");
|
|
59 |
_LIT(KROMSELFFileNameNonExistant, "Z:\\idontexist1.elf");
|
|
60 |
_LIT(KROMSELFFileNameExe, "Z:\\data\\testelfexecutable.elf");
|
|
61 |
|
|
62 |
//Preamble tests
|
|
63 |
_LIT(KPrepareFiles, "PrepareFiles");
|
|
64 |
_LIT(KTearDownFiles, "TearDownFiles");
|
|
65 |
|
|
66 |
/**
|
|
67 |
* Can only use in void functions
|
|
68 |
* @param x Boolean
|
|
69 |
* @param If we fail, pop and destroy y items
|
|
70 |
*/
|
|
71 |
#define T_SELFLIB_ASSERT_TRUE(x, y)\
|
|
72 |
if(x == 0){\
|
|
73 |
ERR_PRINTF2(_L("Assertion Error in CSELFLibWrapper.cpp line [%d]"), __LINE__);\
|
|
74 |
SetBlockResult(EFail);\
|
|
75 |
if(y>0)\
|
|
76 |
CleanupStack::PopAndDestroy(y);\
|
|
77 |
return;\
|
|
78 |
}\
|
|
79 |
|
|
80 |
/**
|
|
81 |
* Use for TUint returning functions
|
|
82 |
* @param x Boolean
|
|
83 |
* @param If we fail, pop and destroy y items and return z
|
|
84 |
*/
|
|
85 |
#define T_SELFLIB_ASSERT_TRUE_RET(x, y, z) \
|
|
86 |
if(!x){\
|
|
87 |
ERR_PRINTF2(_L("Assertion Error in CSELFLibWrapper.cpp line [%d]"), __LINE__);\
|
|
88 |
SetBlockResult(EFail);\
|
|
89 |
if(y>0)\
|
|
90 |
CleanupStack::PopAndDestroy(y);\
|
|
91 |
return z; \
|
|
92 |
}
|
|
93 |
|
|
94 |
_LIT8(KTestData1, "This is some test variant data");
|
|
95 |
_LIT8(KTestData2, "This is some more variant data");
|
|
96 |
_LIT8(KTestData3, "This is even more variant data");
|
|
97 |
|
|
98 |
static const TUint KLargeDataSize = 0xE1000;
|
|
99 |
|
|
100 |
/**
|
|
101 |
* This class is responsible for testing the SELF editing library
|
|
102 |
*/
|
|
103 |
class CSELFLibWrapper : public CDataWrapper
|
|
104 |
{
|
|
105 |
public:
|
|
106 |
static CSELFLibWrapper* NewL();
|
|
107 |
~CSELFLibWrapper();
|
|
108 |
|
|
109 |
virtual TBool DoCommandL(const TTEFFunction& aCommand,
|
|
110 |
const TTEFSectionName& aSection,
|
|
111 |
const TInt aAsyncErrorIndex);
|
|
112 |
|
|
113 |
virtual TAny* GetObject() { return NULL; /* *iObject */ }
|
|
114 |
virtual void SetObject(TAny* aObject) { (void)aObject; }
|
|
115 |
|
|
116 |
protected:
|
|
117 |
void ConstructL();
|
|
118 |
|
|
119 |
private:
|
|
120 |
CSELFLibWrapper();
|
|
121 |
void LogELFHeader(const Elf32_Ehdr& aHeader);
|
|
122 |
|
|
123 |
//Test cases
|
|
124 |
void TestNewL_L();
|
|
125 |
void TestNewLC_L();
|
|
126 |
void TestInsertDataL();
|
|
127 |
void TestConstruction_InvalidELF_SignatureL();
|
|
128 |
void TestConstruction_InvalidELF_SizeL();
|
|
129 |
void TestConstruction_ValidELF_NotSupported();
|
|
130 |
void TestConstruction_Inuse();
|
|
131 |
void TestGetElfHeaderL();
|
|
132 |
void TestMultipleInsertionL();
|
|
133 |
void TestInsertNothingL();
|
|
134 |
void TestPerformanceL();
|
|
135 |
void TestStressL();
|
|
136 |
|
|
137 |
void CopyFilesToWritablePlaceL();
|
|
138 |
void TearDownFilesL();
|
|
139 |
|
|
140 |
TInt GetNumberofVariantSegmentsL(const TDesC& aFilename);
|
|
141 |
TInt GetVariantSegmentSizeL(const TUint aIndex, const TDesC& aFilename);
|
|
142 |
void GetVariantSegmentDataL(TUint aIndex, TDes8& aData, const TDesC& aFilename);
|
|
143 |
TInt HelpTicksPerSecond();
|
|
144 |
|
|
145 |
private:
|
|
146 |
RFs iFs;
|
|
147 |
};
|
|
148 |
|
|
149 |
#endif // __CSELFLIB_WRAPPER_H__
|