sl@0
|
1 |
// Copyright (c) 2001-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 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
|
sl@0
|
17 |
#ifndef __TF_WRITE_H__
|
sl@0
|
18 |
#define __TF_WRITE_H__
|
sl@0
|
19 |
|
sl@0
|
20 |
#include <e32std.h>
|
sl@0
|
21 |
|
sl@0
|
22 |
enum TPanicNo
|
sl@0
|
23 |
{
|
sl@0
|
24 |
EPanicGetDesOverflow,
|
sl@0
|
25 |
EPanicGetDesInitialOverflow,
|
sl@0
|
26 |
EPanicCheckOverflow,
|
sl@0
|
27 |
EPanicCompareDescOverflow,
|
sl@0
|
28 |
EPanicEraseBlockOOR,
|
sl@0
|
29 |
EPanicEraseBlockNeg,
|
sl@0
|
30 |
EPanicJoinMaths
|
sl@0
|
31 |
};
|
sl@0
|
32 |
|
sl@0
|
33 |
GLREF_C void Panic( TPanicNo aPanic );
|
sl@0
|
34 |
|
sl@0
|
35 |
class CWriteTest;
|
sl@0
|
36 |
|
sl@0
|
37 |
class MGeneralizedWrite
|
sl@0
|
38 |
//
|
sl@0
|
39 |
// Provides an generic interface to a write function which
|
sl@0
|
40 |
// can be either the simple of thread version. Used to hide which
|
sl@0
|
41 |
// version of the write function a test is using
|
sl@0
|
42 |
//
|
sl@0
|
43 |
{
|
sl@0
|
44 |
public:
|
sl@0
|
45 |
virtual void Write(TInt aPos,const TDesC8& aSrc) = 0;
|
sl@0
|
46 |
virtual void CheckedWrite(TInt aPos,const TDesC8& aSrc) = 0;
|
sl@0
|
47 |
};
|
sl@0
|
48 |
|
sl@0
|
49 |
class TWriteBase: public MGeneralizedWrite
|
sl@0
|
50 |
{
|
sl@0
|
51 |
public:
|
sl@0
|
52 |
TWriteBase( CWriteTest& aOwner );
|
sl@0
|
53 |
virtual void CheckedWrite(TInt aPos,const TDesC8& aSrc);
|
sl@0
|
54 |
|
sl@0
|
55 |
protected:
|
sl@0
|
56 |
CWriteTest& iOwner;
|
sl@0
|
57 |
};
|
sl@0
|
58 |
|
sl@0
|
59 |
|
sl@0
|
60 |
class TSimpleWrite : public TWriteBase
|
sl@0
|
61 |
//
|
sl@0
|
62 |
// Simple implementation of write function
|
sl@0
|
63 |
//
|
sl@0
|
64 |
{
|
sl@0
|
65 |
public:
|
sl@0
|
66 |
TSimpleWrite( CWriteTest& aOwner );
|
sl@0
|
67 |
virtual void Write( TInt aPos, const TDesC8& aSrc );
|
sl@0
|
68 |
|
sl@0
|
69 |
private:
|
sl@0
|
70 |
TBusLocalDrive& iDrive;
|
sl@0
|
71 |
};
|
sl@0
|
72 |
|
sl@0
|
73 |
class TThreadWrite : public TWriteBase
|
sl@0
|
74 |
//
|
sl@0
|
75 |
// Thread implementation of write function
|
sl@0
|
76 |
//
|
sl@0
|
77 |
{
|
sl@0
|
78 |
public:
|
sl@0
|
79 |
TThreadWrite( CWriteTest& aOwner );
|
sl@0
|
80 |
virtual void Write(TInt aPos,const TDesC8& aSrc);
|
sl@0
|
81 |
|
sl@0
|
82 |
// Thread functions with offset, added by this class
|
sl@0
|
83 |
void CheckedThreadWrite(TInt aPos, TInt aLength, const TDesC8& aSrc, TInt aDescOffset );
|
sl@0
|
84 |
void CurrentThreadCheckedThreadWrite(TInt aPos, TInt aLength, const TDesC8& aSrc, TInt aDescOffset );
|
sl@0
|
85 |
|
sl@0
|
86 |
private:
|
sl@0
|
87 |
TBusLocalDrive& iDrive;
|
sl@0
|
88 |
const TInt iThreadHandle;
|
sl@0
|
89 |
};
|
sl@0
|
90 |
|
sl@0
|
91 |
|
sl@0
|
92 |
class CBlockManager : public CBase
|
sl@0
|
93 |
//
|
sl@0
|
94 |
// class used to control erasing and allocation of blocks
|
sl@0
|
95 |
//
|
sl@0
|
96 |
{
|
sl@0
|
97 |
public:
|
sl@0
|
98 |
CBlockManager( TBusLocalDrive& iDrive, CWriteTest& aOwner );
|
sl@0
|
99 |
~CBlockManager();
|
sl@0
|
100 |
|
sl@0
|
101 |
void CreateL();
|
sl@0
|
102 |
|
sl@0
|
103 |
void EraseBlock( TInt aBlockNumber );
|
sl@0
|
104 |
void EraseAllBlocks();
|
sl@0
|
105 |
void VerifyErased( TInt aBlockNumber );
|
sl@0
|
106 |
|
sl@0
|
107 |
void InitialiseSequentialBlockAllocator();
|
sl@0
|
108 |
TInt NextErasedBlock();
|
sl@0
|
109 |
|
sl@0
|
110 |
void InitialiseDataChunkAllocator();
|
sl@0
|
111 |
TUint NextErasedDataChunk( TInt aRequiredLength, TInt aMultiple=4 );
|
sl@0
|
112 |
|
sl@0
|
113 |
|
sl@0
|
114 |
inline TInt BlockCount() const;
|
sl@0
|
115 |
inline TInt BlockSize() const;
|
sl@0
|
116 |
inline TInt FlashSize() const;
|
sl@0
|
117 |
inline TUint BlockAddress( TInt aBlockNumber ) const;
|
sl@0
|
118 |
|
sl@0
|
119 |
private:
|
sl@0
|
120 |
TBusLocalDrive& iDrive;
|
sl@0
|
121 |
TBuf8<512> iReadBuffer;
|
sl@0
|
122 |
CWriteTest& iOwner;
|
sl@0
|
123 |
TInt iBlockCount;
|
sl@0
|
124 |
TInt iBlockSize;
|
sl@0
|
125 |
|
sl@0
|
126 |
enum TEraseStatus
|
sl@0
|
127 |
{
|
sl@0
|
128 |
EErased,
|
sl@0
|
129 |
ENotErased
|
sl@0
|
130 |
};
|
sl@0
|
131 |
TEraseStatus* iEraseArray;
|
sl@0
|
132 |
|
sl@0
|
133 |
TInt iNextBlock;
|
sl@0
|
134 |
|
sl@0
|
135 |
TInt iDataBlock;
|
sl@0
|
136 |
TInt iDataOffset;
|
sl@0
|
137 |
};
|
sl@0
|
138 |
|
sl@0
|
139 |
|
sl@0
|
140 |
|
sl@0
|
141 |
class CWriteTest : public CBase
|
sl@0
|
142 |
{
|
sl@0
|
143 |
public:
|
sl@0
|
144 |
~CWriteTest();
|
sl@0
|
145 |
|
sl@0
|
146 |
void CreateL();
|
sl@0
|
147 |
|
sl@0
|
148 |
void DoTests();
|
sl@0
|
149 |
|
sl@0
|
150 |
TBool CompareAgainstFlash( TInt aFlashOffset, const TDesC8& aDes );
|
sl@0
|
151 |
TBool CompareAgainstFlash( TInt aFlashOffset, TInt aLength, const TDesC8& aDes, TInt aDescOffset );
|
sl@0
|
152 |
|
sl@0
|
153 |
inline const TUint8* ChunkBase() const;
|
sl@0
|
154 |
inline TBusLocalDrive& Drive();
|
sl@0
|
155 |
inline TInt DummyThreadHandle() const;
|
sl@0
|
156 |
|
sl@0
|
157 |
private:
|
sl@0
|
158 |
static TInt DummyThread( TAny* aParam );
|
sl@0
|
159 |
|
sl@0
|
160 |
void CreateRandomData( TDes8& aDestBuf, TInt aLength );
|
sl@0
|
161 |
TBool CheckOnes( TUint aFlashOffset, TInt aLength );
|
sl@0
|
162 |
void CreateTestData( TInt aBlockNumber, TBool aEndOfBlock );
|
sl@0
|
163 |
|
sl@0
|
164 |
void SimpleWriteTest();
|
sl@0
|
165 |
void SimpleThreadWriteTest();
|
sl@0
|
166 |
void DoSimpleWriteTest( MGeneralizedWrite& aWriter );
|
sl@0
|
167 |
|
sl@0
|
168 |
void AlignedWriteTest();
|
sl@0
|
169 |
void AlignedThreadWriteTest();
|
sl@0
|
170 |
void DoAlignedWriteTest( MGeneralizedWrite& aWriter );
|
sl@0
|
171 |
|
sl@0
|
172 |
void UnalignedWriteTest();
|
sl@0
|
173 |
void UnalignedThreadWriteTest();
|
sl@0
|
174 |
void DoUnalignedWriteTest( MGeneralizedWrite& aWriter );
|
sl@0
|
175 |
|
sl@0
|
176 |
void OffsetDescriptorAlignedWriteTest();
|
sl@0
|
177 |
void OffsetDescriptorUnalignedWriteTest();
|
sl@0
|
178 |
void OffsetDescriptorCurrentThreadAlignedWriteTest();
|
sl@0
|
179 |
void OffsetDescriptorCurrentThreadUnalignedWriteTest();
|
sl@0
|
180 |
|
sl@0
|
181 |
void JoinedWriteTest();
|
sl@0
|
182 |
void JoinedThreadWriteTest();
|
sl@0
|
183 |
|
sl@0
|
184 |
void SingleBitOverwriteTest();
|
sl@0
|
185 |
void TwoBitOverwriteTest();
|
sl@0
|
186 |
|
sl@0
|
187 |
void RunSimulationTest();
|
sl@0
|
188 |
|
sl@0
|
189 |
|
sl@0
|
190 |
private:
|
sl@0
|
191 |
TBusLocalDrive iDrive;
|
sl@0
|
192 |
TBool iDriveOpened;
|
sl@0
|
193 |
TBuf8<512> iReadBuffer;
|
sl@0
|
194 |
CBlockManager* iBlocks;
|
sl@0
|
195 |
|
sl@0
|
196 |
TRandomGenerator iRandom;
|
sl@0
|
197 |
|
sl@0
|
198 |
TSimpleWrite* iSimpleWriter;
|
sl@0
|
199 |
TThreadWrite* iThreadWriter;
|
sl@0
|
200 |
|
sl@0
|
201 |
RThread iDummyThread;
|
sl@0
|
202 |
};
|
sl@0
|
203 |
|
sl@0
|
204 |
|
sl@0
|
205 |
|
sl@0
|
206 |
|
sl@0
|
207 |
inline TBusLocalDrive& CWriteTest::Drive()
|
sl@0
|
208 |
{
|
sl@0
|
209 |
return iDrive;
|
sl@0
|
210 |
}
|
sl@0
|
211 |
|
sl@0
|
212 |
inline TInt CWriteTest::DummyThreadHandle() const
|
sl@0
|
213 |
{
|
sl@0
|
214 |
return iDummyThread.Handle();
|
sl@0
|
215 |
}
|
sl@0
|
216 |
|
sl@0
|
217 |
|
sl@0
|
218 |
#endif
|
sl@0
|
219 |
|