author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 31 Aug 2010 16:34:26 +0300 | |
branch | RCL_3 |
changeset 43 | c1f20ce4abcf |
parent 19 | 4a8fed1c0ef6 |
child 44 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1995-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\heap\t_heap.cpp |
|
15 |
// Overview: |
|
16 |
// Tests RHeap class. |
|
17 |
// API Information: |
|
18 |
// RHeap |
|
19 |
// Details: |
|
20 |
// - Test that the expected methods are in the DLL by calling each one. |
|
21 |
// - Test heap auto expansion and compression by calling Alloc and Compress |
|
22 |
// and verifying the results are as expected. |
|
23 |
// - Verify the heap dump Base, Size, MinLength, Top and len values. |
|
24 |
// - Test the RHeap AllocSize, Alloc, AllocLen, Count and Free methods. Verify |
|
25 |
// results are as expected. Check heap object and confirm Invariant status. |
|
26 |
// - For an RHeap object, test and verify the results of: allocate some cells, |
|
27 |
// free them with Reset, allocate some cells again, free them with Free, |
|
28 |
// allocate some cells again, free them backwards, allocate again, free the |
|
29 |
// odd cells then the even cells, allocate again, free one half then the other. |
|
30 |
// Check heap object and confirm Invariant status. |
|
31 |
// - For an RHeap object, test and verify the results of: attempt to resize a |
|
32 |
// block above the space available, resize the block to 0, resize positively, |
|
33 |
// allocate a block, fill with data, allocate another block or two then resize |
|
34 |
// the original block such that it has to be moved in memory, then check the |
|
35 |
// blocks' contents, test data was copied on reallocation, resize blocks and |
|
36 |
// verify data integrity, expand and shrink, verify data. |
|
37 |
// Check heap object and confirm Invariant status. |
|
38 |
// - For an RHeap object, test and verify the results of: Alloc some cells, |
|
39 |
// verify the Count, Check the object, Free some cells, verify the Count, |
|
40 |
// Check and Reset the object, corrupt the heap data and reset the object. |
|
41 |
// - Test the leaving methods: AllocL and ReAllocL. Verify the results are as |
|
42 |
// expected. |
|
43 |
// - Test the RHeap methods: Alloc, Count, Size, Free and Close. Verify results |
|
44 |
// are as expected. |
|
45 |
// - Test sharing a chunk heap between two separate threads. Each thread |
|
46 |
// accesses the shared heap in a timed loop, to ensure that some true |
|
47 |
// concurrency. |
|
48 |
// - Test sharing a chunk heap between two separate threads. Run each thread in |
|
49 |
// a timed loop, to ensure that some true concurrency. Each thread accesses |
|
50 |
// the shared heap and results are verified. The heap size is used to verify |
|
51 |
// no leaks and that the largest available space is still available. The heap |
|
52 |
// is checked to verify that no cells remain allocated after the tests are |
|
53 |
// complete. |
|
54 |
// - Test sharing a heap between two threads. The thread whose heap it was is |
|
55 |
// killed first. Each thread accesses the shared heap and results are |
|
56 |
// verified. |
|
57 |
// Platforms/Drives/Compatibility: |
|
58 |
// All |
|
59 |
// Assumptions/Requirement/Pre-requisites: |
|
60 |
// Failures and causes: |
|
61 |
// Base Port information: |
|
62 |
// |
|
63 |
// |
|
64 |
||
65 |
#include <e32test.h> |
|
66 |
#include <e32hal.h> |
|
67 |
#include <e32def.h> |
|
68 |
#include <e32def_private.h> |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
69 |
#include "dla.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
70 |
#include "slab.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
71 |
#include "page_alloc.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
72 |
#include "heap_hybrid.h" |
0 | 73 |
|
74 |
// Sets data for Test6 |
|
75 |
#define SetData(size) pHeap->Reset();\ |
|
76 |
Cell1=pHeap->Alloc(size);\ |
|
77 |
Cell2=pHeap->Alloc(size);\ |
|
78 |
Cell3=pHeap->Alloc(size);\ |
|
79 |
for(pC=(TText8*)Cell1; pC<(TText8*)Cell1+pHeap->AllocLen(Cell1); *pC++='x');\ |
|
80 |
for(pC=(TText8*)Cell2; pC<(TText8*)Cell2+pHeap->AllocLen(Cell2); *pC++='y');\ |
|
81 |
for(pC=(TText8*)Cell3; pC<(TText8*)Cell3+pHeap->AllocLen(Cell3); *pC++='z');\ |
|
82 |
OrigLen=pHeap->AllocLen(Cell2); |
|
83 |
||
84 |
// Tests cell contents for Test6 |
|
85 |
#define TestCells(Cell2Len) for(pC=(TText8*)Cell1; pC<(TText8*)Cell1+pHeap->AllocLen(Cell1); test(*pC++=='x'));\ |
|
86 |
for(pC=(TText8*)Cell2; pC<(TText8*)Cell2+Cell2Len; test(*pC++=='y'));\ |
|
87 |
for(pC=(TText8*)Cell3; pC<(TText8*)Cell3+pHeap->AllocLen(Cell3); test(*pC++=='z'));\ |
|
88 |
pHeap->Check(); |
|
89 |
||
90 |
#ifdef __EABI__ |
|
91 |
IMPORT_D extern const TInt KHeapMinCellSize; |
|
92 |
#else |
|
93 |
const TInt KHeapMinCellSize = 0; |
|
94 |
#endif |
|
95 |
||
96 |
const TInt KHeadSize = (TInt)RHeap::EAllocCellSize; |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
97 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
98 |
const TInt KAlign = RHeap::ECellAlignment; |
0 | 99 |
const TInt KMinCellLength = _ALIGN_UP((KHeapMinCellSize + Max(TInt(RHeap::EFreeCellSize),TInt(RHeap::EAllocCellSize))),KAlign) - RHeap::EAllocCellSize; |
100 |
const TInt KMinFreeSize = _ALIGN_UP((KHeapMinCellSize + Max(TInt(RHeap::EFreeCellSize),TInt(RHeap::EAllocCellSize))),KAlign); |
|
101 |
||
102 |
TInt PageSize; |
|
103 |
||
104 |
class RTestHeap : public RHeap |
|
105 |
{ |
|
106 |
public: |
|
107 |
void __DbgTest(void* pRHeapDump) const; |
|
108 |
}; |
|
109 |
||
110 |
struct RHeapDump |
|
111 |
{ |
|
112 |
TUint iMinLength; |
|
113 |
RChunk iChunk; |
|
114 |
TUint8 *iBase; |
|
115 |
TUint8 *iTop; |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
116 |
//RHeap::SCell iFree; |
0 | 117 |
}; |
118 |
||
119 |
#pragma warning ( disable :4705 ) // statement has no effect |
|
120 |
RHeapDump OrigDump; |
|
121 |
#pragma warning ( default :4705 ) |
|
122 |
||
123 |
#if defined(_DEBUG) |
|
124 |
void RTestHeap::__DbgTest(void* aPtr) const |
|
125 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
126 |
(void) aPtr; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
127 |
/* |
0 | 128 |
RHeapDump& d = *(RHeapDump*)aPtr; |
129 |
d.iMinLength=iMinLength; |
|
130 |
d.iChunk.SetHandle(iChunkHandle); |
|
131 |
d.iBase=iBase; |
|
132 |
d.iTop=iTop; |
|
133 |
d.iFree=iFree; |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
134 |
*/ |
0 | 135 |
} |
136 |
#endif |
|
137 |
||
138 |
||
139 |
#if defined(_DEBUG) |
|
140 |
TBool Invariant(RHeap* aHeap) |
|
141 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
142 |
(void) aHeap; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
143 |
/* |
0 | 144 |
RHeapDump dump; |
145 |
((RTestHeap*)aHeap)->__DbgTest(&dump); |
|
146 |
if(dump.iMinLength!=OrigDump.iMinLength) return(EFalse); |
|
147 |
// Note: iChunk is a class |
|
148 |
if(dump.iBase!=OrigDump.iBase) return(EFalse); |
|
149 |
if(*dump.iBase!=*OrigDump.iBase) return(EFalse); |
|
150 |
if(dump.iTop!=OrigDump.iTop) return(EFalse); |
|
151 |
if(dump.iTop[-1]!=OrigDump.iTop[-1]) return(EFalse); |
|
152 |
if(dump.iFree.len!=OrigDump.iFree.len) return(EFalse); |
|
153 |
// iFree.Next changes during allocation/freeing etc. |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
154 |
*/ |
0 | 155 |
return(ETrue); |
156 |
} |
|
157 |
#define INV(x) x; |
|
158 |
#else |
|
159 |
#define INV(x) |
|
160 |
#endif |
|
161 |
||
162 |
LOCAL_D RTest test(_L("T_HEAP")); |
|
163 |
LOCAL_D TInt heapCount=1; |
|
164 |
LOCAL_D RHeap *gHeapPtr; |
|
165 |
LOCAL_D RHeap *gHeapPtr2; |
|
166 |
||
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
167 |
/* |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
168 |
Friend class of RHeapHybrid to access to hybrid heap metadata |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
169 |
*/ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
170 |
class TestHybridHeap |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
171 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
172 |
public: |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
173 |
static TBool IsHybrid(const RHybridHeap * aHybridHeap); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
174 |
}; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
175 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
176 |
TBool TestHybridHeap::IsHybrid(const RHybridHeap * aHybridHeap) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
177 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
178 |
if (aHybridHeap->iDLOnly) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
179 |
return EFalse; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
180 |
else |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
181 |
return ETrue; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
182 |
} |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
183 |
|
0 | 184 |
class TestRHeap |
185 |
{ |
|
186 |
public: |
|
187 |
void Test1(void); |
|
188 |
void Test2(void); |
|
189 |
void Test3(void); |
|
190 |
void Test4(void); |
|
191 |
void Test5(void); |
|
192 |
void Test7(void); |
|
193 |
void Test8(void); |
|
194 |
void TestCompressAll(void); |
|
195 |
void TestOffset(void); |
|
196 |
private: |
|
197 |
TInt RHeapCalcReduce(TInt aCellSize, TInt aGrowBy); |
|
198 |
}; |
|
199 |
||
200 |
LOCAL_C RHeap* allocHeap(TInt aSize) |
|
201 |
// |
|
202 |
// Allocate a chunk heap with max size aSize |
|
203 |
// |
|
204 |
{ |
|
205 |
||
206 |
TName n; |
|
207 |
n.Format(_L("TESTHEAP%d"),heapCount++); |
|
208 |
return(User::ChunkHeap(&n,aSize,aSize)); |
|
209 |
} |
|
210 |
||
211 |
//////////////////////////////////////////////////////////////////////////////////////// |
|
212 |
// Test that methods are in the DLL |
|
213 |
//////////////////////////////////////////////////////////////////////////////////////// |
|
214 |
void TestRHeap::Test1(void) |
|
215 |
{ |
|
216 |
TAny* aCell; |
|
217 |
TInt aVar; |
|
218 |
RHeap* pHeap=allocHeap(3000); // tests first constructor indirectly |
|
219 |
// constructor with Chunk not tested |
|
220 |
pHeap->Base(); |
|
221 |
pHeap->Size(); |
|
222 |
pHeap->Available(aVar); |
|
223 |
pHeap->Check(); |
|
224 |
pHeap->Count(); |
|
225 |
pHeap->Count(aVar); |
|
226 |
aCell=pHeap->Alloc(50); |
|
227 |
pHeap->Free(aCell); |
|
228 |
aCell=pHeap->AllocL(50); |
|
229 |
pHeap->AllocLen(aCell); |
|
230 |
pHeap->ReAlloc(aCell, 100); |
|
231 |
pHeap->ReAllocL(aCell, 150); |
|
232 |
pHeap->Reset(); |
|
233 |
pHeap->Close(); |
|
234 |
} |
|
235 |
||
236 |
/////////////////////////////////////////////////////////////////////////////// |
|
237 |
// Test Assorted Methods 1 |
|
238 |
////////////////////////////////////////////////////////////////////////////// |
|
239 |
void TestRHeap::Test2(void) |
|
240 |
{ |
|
241 |
#if defined(_DEBUG) |
|
242 |
RHeapDump dump; |
|
243 |
RHeap* pHeap=allocHeap(3000); |
|
244 |
||
245 |
((RTestHeap*)pHeap)->__DbgTest(&OrigDump); |
|
246 |
((RTestHeap*)pHeap)->__DbgTest(&dump); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
247 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
248 |
// test(dump.iBase==pHeap->Base()); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
249 |
// test((dump.iTop-dump.iBase)==pHeap->Size()); |
0 | 250 |
pHeap->Check(); |
251 |
test(Invariant(pHeap)); |
|
252 |
pHeap->Close(); |
|
253 |
#endif |
|
254 |
} |
|
255 |
||
256 |
/////////////////////////////////////////////////////////////////////////////// |
|
257 |
// Test Assorted Methods 2 |
|
258 |
////////////////////////////////////////////////////////////////////////////// |
|
259 |
void TestRHeap::Test3(void) |
|
260 |
{ |
|
261 |
TInt CellLen; |
|
262 |
TInt OrigBiggestBlock, BiggestBlock; |
|
263 |
TAny* aCell; |
|
264 |
TInt FreeCount, AllocCount, AllocSize; |
|
265 |
RHeap* pHeap=allocHeap(5000); |
|
266 |
||
267 |
#if defined(_DEBUG) |
|
268 |
((RTestHeap*)pHeap)->__DbgTest(&OrigDump); |
|
269 |
#endif |
|
270 |
||
271 |
// test AllocSize |
|
272 |
AllocCount=pHeap->Count(FreeCount); |
|
273 |
test(pHeap->AllocSize(AllocSize)==pHeap->Count()); |
|
274 |
test(AllocSize==0); |
|
275 |
test(AllocCount==pHeap->Count()); |
|
276 |
test(AllocCount==0); |
|
277 |
test(FreeCount==1); |
|
278 |
||
279 |
TAny* p1=pHeap->Alloc(1); |
|
280 |
test(pHeap->AllocSize(AllocSize)==1); |
|
281 |
test(AllocSize==pHeap->AllocLen(p1)); |
|
282 |
||
283 |
TAny* p2=pHeap->Alloc(8); |
|
284 |
test(pHeap->AllocSize(AllocSize)==2); |
|
285 |
test(AllocSize==pHeap->AllocLen(p1)+pHeap->AllocLen(p2)); |
|
286 |
||
287 |
TAny* p3=pHeap->Alloc(127); |
|
288 |
test(pHeap->AllocSize(AllocSize)==3); |
|
289 |
test(AllocSize==pHeap->AllocLen(p1)+pHeap->AllocLen(p2)+pHeap->AllocLen(p3)); |
|
290 |
||
291 |
pHeap->Free(p2); |
|
292 |
test(pHeap->AllocSize(AllocSize)==2); |
|
293 |
test(AllocSize==pHeap->AllocLen(p1)+pHeap->AllocLen(p3)); |
|
294 |
||
295 |
pHeap->Free(p1); |
|
296 |
test(pHeap->AllocSize(AllocSize)==1); |
|
297 |
test(AllocSize==pHeap->AllocLen(p3)); |
|
298 |
||
299 |
pHeap->Free(p3); |
|
300 |
test(pHeap->AllocSize(AllocSize)==0); |
|
301 |
test(AllocSize==0); |
|
302 |
||
303 |
pHeap->Available(OrigBiggestBlock); |
|
304 |
||
305 |
// Request too large a block |
|
306 |
test((aCell=pHeap->Alloc(OrigBiggestBlock+1))==NULL); |
|
307 |
AllocCount=pHeap->Count(FreeCount); |
|
308 |
test(AllocCount==0); |
|
309 |
test(FreeCount==1); |
|
310 |
||
311 |
||
312 |
// Request block same size as that available |
|
313 |
test((aCell=pHeap->Alloc(OrigBiggestBlock))!=NULL); |
|
314 |
test(pHeap->Available(BiggestBlock)==0); |
|
315 |
test(BiggestBlock==0); |
|
316 |
test(pHeap->AllocLen(aCell)==OrigBiggestBlock); |
|
317 |
AllocCount=pHeap->Count(FreeCount); |
|
318 |
test(AllocCount==pHeap->Count()); |
|
319 |
test(AllocCount==1); |
|
320 |
test(FreeCount==0); |
|
321 |
pHeap->Check(); |
|
322 |
// Free the block |
|
323 |
pHeap->FreeZ(aCell); |
|
324 |
test(aCell==NULL); |
|
325 |
pHeap->Available(BiggestBlock); |
|
326 |
test(BiggestBlock==OrigBiggestBlock); |
|
327 |
AllocCount=pHeap->Count(FreeCount); |
|
328 |
test(AllocCount==0); |
|
329 |
test(FreeCount==1); |
|
330 |
||
331 |
||
332 |
// Request a block much smaller than that available |
|
333 |
test((aCell=pHeap->Alloc(1))!=NULL); |
|
334 |
CellLen=pHeap->AllocLen(aCell); |
|
335 |
pHeap->Available(BiggestBlock); |
|
336 |
test(pHeap->Available(BiggestBlock)==BiggestBlock); |
|
337 |
test((BiggestBlock+CellLen+KHeadSize)==OrigBiggestBlock); |
|
338 |
// NOTE: if a block of 1000 was initially available, getting a cell of length 100 DOES NOT |
|
339 |
// leave 900 available as some of the 1000(KHeadSize) is used up storing the length of the |
|
340 |
// allocated block |
|
341 |
AllocCount=pHeap->Count(FreeCount); |
|
342 |
test(AllocCount==1); |
|
343 |
test(FreeCount==1); |
|
344 |
pHeap->Check(); |
|
345 |
// Free the block |
|
346 |
pHeap->Free(aCell); |
|
347 |
test(aCell!=NULL); |
|
348 |
pHeap->Available(BiggestBlock); |
|
349 |
test(BiggestBlock==OrigBiggestBlock); |
|
350 |
AllocCount=pHeap->Count(FreeCount); |
|
351 |
test(AllocCount==0); |
|
352 |
test(FreeCount==1); |
|
353 |
||
354 |
||
355 |
// Request a block only just smaller than that available |
|
356 |
test((aCell=pHeap->Alloc(OrigBiggestBlock-1))!=NULL); |
|
357 |
CellLen=pHeap->AllocLen(aCell); |
|
358 |
AllocCount=pHeap->Count(FreeCount); |
|
359 |
test(AllocCount==1); |
|
360 |
test(FreeCount==0); |
|
361 |
pHeap->Check(); |
|
362 |
// Free the block |
|
363 |
pHeap->Free(aCell); |
|
364 |
pHeap->Available(BiggestBlock); |
|
365 |
test(BiggestBlock==OrigBiggestBlock); |
|
366 |
AllocCount=pHeap->Count(FreeCount); |
|
367 |
test(AllocCount==0); |
|
368 |
test(FreeCount==1); |
|
369 |
||
370 |
||
371 |
//Request a block of 0 size Note: 0 may not necessarily be allocated (probably will be 4) |
|
372 |
test((aCell=pHeap->Alloc(0))!=NULL); |
|
373 |
pHeap->Available(BiggestBlock); |
|
374 |
AllocCount=pHeap->Count(FreeCount); |
|
375 |
test(AllocCount==1); |
|
376 |
test(FreeCount==1); |
|
377 |
pHeap->Check(); |
|
378 |
//Free the block |
|
379 |
pHeap->Free(aCell); |
|
380 |
pHeap->Available(BiggestBlock); |
|
381 |
test(BiggestBlock==OrigBiggestBlock); |
|
382 |
AllocCount=pHeap->Count(FreeCount); |
|
383 |
test(AllocCount==0); |
|
384 |
test(FreeCount==1); |
|
385 |
pHeap->Check(); |
|
386 |
INV(test(Invariant(pHeap))); |
|
387 |
||
388 |
// close heap so we don't exceed chunk limit |
|
389 |
pHeap->Close(); |
|
390 |
} |
|
391 |
||
392 |
/////////////////////////////////////////////////////////////////////////////// |
|
393 |
// Test Assorted Methods 3 - Here we go loopy loo, here we go loopy li |
|
394 |
////////////////////////////////////////////////////////////////////////////// |
|
395 |
void TestRHeap::Test4(void) |
|
396 |
{ |
|
397 |
TInt OrigBiggestBlock, BiggestBlock, FreeCount, AllocCount; |
|
398 |
RHeap* pHeap=allocHeap(5000); |
|
399 |
||
400 |
pHeap->Available(OrigBiggestBlock); |
|
401 |
#if defined(_DEBUG) |
|
402 |
((RTestHeap*)pHeap)->__DbgTest(&OrigDump); |
|
403 |
#endif |
|
404 |
||
405 |
for(TInt ArraySize=1; ArraySize<=100; ArraySize++) |
|
406 |
{ |
|
407 |
TAny** ArrayOfCells; |
|
408 |
ArrayOfCells= new TAny*[ArraySize]; |
|
409 |
TInt ArrayIndex; |
|
410 |
||
411 |
// Allocate some cells |
|
412 |
for(ArrayIndex=0; ArrayIndex<ArraySize;ArrayIndex++) |
|
413 |
ArrayOfCells[ArrayIndex]=pHeap->Alloc(OrigBiggestBlock/(ArraySize*3)); |
|
414 |
pHeap->Available(BiggestBlock); |
|
415 |
test(BiggestBlock!=OrigBiggestBlock); |
|
416 |
AllocCount=pHeap->Count(FreeCount); |
|
417 |
test((TInt)AllocCount==ArraySize); |
|
418 |
test(FreeCount==1); |
|
419 |
pHeap->Check(); |
|
420 |
// Now free them with Reset |
|
421 |
pHeap->Reset(); |
|
422 |
pHeap->Available(BiggestBlock); |
|
423 |
test(BiggestBlock==OrigBiggestBlock); |
|
424 |
AllocCount=pHeap->Count(FreeCount); |
|
425 |
test(AllocCount==0); |
|
426 |
test(FreeCount==1); |
|
427 |
||
428 |
||
429 |
// Allocate some cells again |
|
430 |
for(ArrayIndex=0; ArrayIndex<ArraySize;ArrayIndex++) |
|
431 |
ArrayOfCells[ArrayIndex]=pHeap->Alloc(OrigBiggestBlock/(ArraySize*3)); |
|
432 |
pHeap->Available(BiggestBlock); |
|
433 |
test(BiggestBlock!=OrigBiggestBlock); |
|
434 |
AllocCount=pHeap->Count(FreeCount); |
|
435 |
test((TInt)AllocCount==ArraySize); |
|
436 |
test(FreeCount==1); |
|
437 |
pHeap->Check(); |
|
438 |
// Free them with Free |
|
439 |
for(ArrayIndex=0; ArrayIndex<ArraySize;ArrayIndex++) |
|
440 |
pHeap->Free(ArrayOfCells[ArrayIndex]); |
|
441 |
pHeap->Available(BiggestBlock); |
|
442 |
test(BiggestBlock==OrigBiggestBlock); |
|
443 |
AllocCount=pHeap->Count(FreeCount); |
|
444 |
test(AllocCount==0); |
|
445 |
test(FreeCount==1); |
|
446 |
||
447 |
||
448 |
// Allocate some cells again |
|
449 |
for(ArrayIndex=0; ArrayIndex<ArraySize;ArrayIndex++) |
|
450 |
ArrayOfCells[ArrayIndex]=pHeap->Alloc(OrigBiggestBlock/(ArraySize*3)); |
|
451 |
pHeap->Available(BiggestBlock); |
|
452 |
test(BiggestBlock!=OrigBiggestBlock); |
|
453 |
AllocCount=pHeap->Count(FreeCount); |
|
454 |
test((TInt)AllocCount==ArraySize); |
|
455 |
test(FreeCount==1); |
|
456 |
pHeap->Check(); |
|
457 |
// Free them backwards |
|
458 |
for(ArrayIndex=ArraySize-1; ArrayIndex>=0; ArrayIndex--) |
|
459 |
pHeap->Free(ArrayOfCells[ArrayIndex]); |
|
460 |
pHeap->Available(BiggestBlock); |
|
461 |
test(BiggestBlock==OrigBiggestBlock); |
|
462 |
AllocCount=pHeap->Count(FreeCount); |
|
463 |
test(AllocCount==0); |
|
464 |
test(FreeCount==1); |
|
465 |
||
466 |
||
467 |
// Allocate some cells again |
|
468 |
for(ArrayIndex=0; ArrayIndex<ArraySize;ArrayIndex++) |
|
469 |
ArrayOfCells[ArrayIndex]=pHeap->Alloc(OrigBiggestBlock/(ArraySize*3)); |
|
470 |
pHeap->Available(BiggestBlock); |
|
471 |
test(BiggestBlock!=OrigBiggestBlock); |
|
472 |
AllocCount=pHeap->Count(FreeCount); |
|
473 |
test((TInt)AllocCount==ArraySize); |
|
474 |
test(FreeCount==1); |
|
475 |
pHeap->Check(); |
|
476 |
// Free the odd cells then the even cells |
|
477 |
for(ArrayIndex=0; ArrayIndex<ArraySize; ArrayIndex+=2) |
|
478 |
pHeap->Free(ArrayOfCells[ArrayIndex]); |
|
479 |
pHeap->Check(); |
|
480 |
for(ArrayIndex=1; ArrayIndex<ArraySize; ArrayIndex+=2) |
|
481 |
pHeap->Free(ArrayOfCells[ArrayIndex]); |
|
482 |
pHeap->Check(); |
|
483 |
pHeap->Available(BiggestBlock); |
|
484 |
test(BiggestBlock==OrigBiggestBlock); |
|
485 |
AllocCount=pHeap->Count(FreeCount); |
|
486 |
test(AllocCount==0); |
|
487 |
test(FreeCount==1); |
|
488 |
||
489 |
||
490 |
// Allocate some cells again |
|
491 |
for(ArrayIndex=0; ArrayIndex<ArraySize;ArrayIndex++) |
|
492 |
ArrayOfCells[ArrayIndex]=pHeap->Alloc(OrigBiggestBlock/(ArraySize*3)); |
|
493 |
pHeap->Available(BiggestBlock); |
|
494 |
test(BiggestBlock!=OrigBiggestBlock); |
|
495 |
AllocCount=pHeap->Count(FreeCount); |
|
496 |
test((TInt)AllocCount==ArraySize); |
|
497 |
test(FreeCount==1); |
|
498 |
pHeap->Check(); |
|
499 |
// Free one half then the other |
|
500 |
for(ArrayIndex=ArraySize-1; ArrayIndex>=ArraySize/2; ArrayIndex--) |
|
501 |
pHeap->Free(ArrayOfCells[ArrayIndex]); |
|
502 |
for(ArrayIndex=0; ArrayIndex<ArraySize/2; ArrayIndex++) |
|
503 |
pHeap->Free(ArrayOfCells[ArrayIndex]); |
|
504 |
AllocCount=pHeap->Count(FreeCount); |
|
505 |
test(AllocCount==0); |
|
506 |
test(FreeCount==1); |
|
507 |
||
508 |
delete [] ArrayOfCells; |
|
509 |
pHeap->Check(); |
|
510 |
INV(test(Invariant(pHeap))) |
|
511 |
} |
|
512 |
||
513 |
// close heap so we don't exceed chunk limit |
|
514 |
pHeap->Close(); |
|
515 |
} |
|
516 |
||
517 |
||
518 |
/////////////////////////////////////////////////////////////////////////////// |
|
519 |
// Test ReAlloc |
|
520 |
////////////////////////////////////////////////////////////////////////////// |
|
521 |
void TestRHeap::Test5(void) |
|
522 |
{ |
|
523 |
TInt BiggestBlock, CellSize; |
|
524 |
||
525 |
RHeap* pHeap=allocHeap(5000); |
|
526 |
#if defined(_DEBUG) |
|
527 |
((RTestHeap*)pHeap)->__DbgTest(&OrigDump); |
|
528 |
#endif |
|
529 |
pHeap->Available(BiggestBlock); |
|
530 |
TAny* aCell=pHeap->Alloc(BiggestBlock); |
|
531 |
||
532 |
// Attempt to resize the block above the space available |
|
533 |
test(pHeap->ReAlloc(aCell, BiggestBlock*2)==NULL); |
|
534 |
||
535 |
// Resize the block to 0 |
|
536 |
aCell=pHeap->ReAlloc(aCell, 0); |
|
537 |
CellSize=pHeap->AllocLen(aCell); // test? |
|
538 |
||
539 |
// Resize positively |
|
540 |
for(TInt aSize=0; aSize<=BiggestBlock; aSize++, pHeap->Available(BiggestBlock)) |
|
541 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
542 |
aCell = pHeap->ReAlloc(aCell, aSize); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
543 |
test(aCell!=NULL); |
0 | 544 |
CellSize=pHeap->AllocLen(aCell); |
545 |
test(CellSize>=aSize); |
|
546 |
} |
|
547 |
||
548 |
pHeap->Check(); |
|
549 |
pHeap->Reset(); |
|
550 |
// Allocate a block, fill with data, allocate another block or two then resize the original |
|
551 |
// block such that it has to be moved in memory, then check the blocks' contents |
|
552 |
TAny* Cell1=pHeap->Alloc(16); |
|
553 |
TText8* pC; |
|
554 |
TInt Cell1Size=pHeap->AllocLen(Cell1); |
|
555 |
for(pC=(TText8*)Cell1; pC<(TText8*)Cell1+Cell1Size; *pC++='x') |
|
556 |
; |
|
557 |
TAny* Cell2=pHeap->Alloc(16); |
|
558 |
TInt Cell2Size=pHeap->AllocLen(Cell2); |
|
559 |
for(pC=(TText8*)Cell2; pC<(TText8*)Cell2+pHeap->AllocLen(Cell2); *pC++='y') |
|
560 |
; |
|
561 |
Cell1=pHeap->ReAlloc(Cell1, 128); |
|
562 |
// Test data was copied on reallocation |
|
563 |
for(pC=(TText8*)Cell1; pC<(TText8*)Cell1+Cell1Size; test(*pC++=='x')) |
|
564 |
; |
|
565 |
// Test other data wasn't corrupted |
|
566 |
for(pC=(TText8*)Cell2; pC<(TText8*)Cell2+pHeap->AllocLen(Cell2); test(*pC++=='y')) |
|
567 |
; |
|
568 |
||
569 |
// Allocate another block |
|
570 |
TAny* Cell3=pHeap->Alloc(8); |
|
571 |
for(pC=(TText8*)Cell3; pC<(TText8*)Cell3+pHeap->AllocLen(Cell3); *pC++='z') |
|
572 |
; |
|
573 |
// test existing blocks to be safe |
|
574 |
for(pC=(TText8*)Cell1; pC<(TText8*)Cell1+Cell1Size; test(*pC++=='x')) |
|
575 |
; |
|
576 |
for(pC=(TText8*)Cell2; pC<(TText8*)Cell2+Cell2Size; test(*pC++=='y')) |
|
577 |
; |
|
578 |
// Resize previous blocks |
|
579 |
Cell1=pHeap->ReAlloc(Cell1, 16); // Shrink previously expanded block |
|
580 |
Cell2=pHeap->ReAlloc(Cell2, 64); |
|
581 |
// Now test data |
|
582 |
for(pC=(TText8*)Cell1; pC<(TText8*)Cell1+Cell1Size; test(*pC++=='x')) |
|
583 |
; |
|
584 |
for(pC=(TText8*)Cell2; pC<(TText8*)Cell2+Cell2Size; test(*pC++=='y')) |
|
585 |
; |
|
586 |
for(pC=(TText8*)Cell3; pC<(TText8*)Cell3+pHeap->AllocLen(Cell3); test(*pC++=='z')) |
|
587 |
; |
|
588 |
||
589 |
// Re-expand Cell1 |
|
590 |
Cell1=pHeap->ReAlloc(Cell1, 1028); |
|
591 |
for(pC=(TText8*)Cell1; pC<(TText8*)Cell1+Cell1Size; test(*pC++=='x')) |
|
592 |
; |
|
593 |
for(pC=(TText8*)Cell2; pC<(TText8*)Cell2+Cell2Size; test(*pC++=='y')) |
|
594 |
; |
|
595 |
for(pC=(TText8*)Cell3; pC<(TText8*)Cell3+pHeap->AllocLen(Cell3); test(*pC++=='z')) |
|
596 |
; |
|
597 |
||
598 |
// Shrink cells back to original size |
|
599 |
Cell1=pHeap->ReAlloc(Cell1, Cell1Size); |
|
600 |
Cell2=pHeap->ReAlloc(Cell2, Cell2Size); |
|
601 |
for(pC=(TText8*)Cell1; pC<(TText8*)Cell1+Cell1Size; test(*pC++=='x')) |
|
602 |
; |
|
603 |
for(pC=(TText8*)Cell2; pC<(TText8*)Cell2+Cell2Size; test(*pC++=='y')) |
|
604 |
; |
|
605 |
for(pC=(TText8*)Cell3; pC<(TText8*)Cell3+pHeap->AllocLen(Cell3); test(*pC++=='z')) |
|
606 |
; |
|
607 |
||
608 |
pHeap->Check(); |
|
609 |
INV(test(Invariant(pHeap))); |
|
610 |
||
611 |
// close heap so we don't exceed chunk limit |
|
612 |
pHeap->Close(); |
|
613 |
} |
|
614 |
||
615 |
||
616 |
/////////////////////////////////////////////////////////////////////////////// |
|
617 |
// Test walking methods (more thoroughly than previously) |
|
618 |
////////////////////////////////////////////////////////////////////////////// |
|
619 |
void TestRHeap::Test7(void) |
|
620 |
{ |
|
621 |
TInt NumAllocated=0, NumFree=1, i; |
|
622 |
RHeap* pHeap=allocHeap(5000); |
|
623 |
||
624 |
TAny** ArrayOfCells; |
|
625 |
ArrayOfCells= new TAny*[100]; |
|
626 |
||
627 |
for(i=0; i<100; i++) |
|
628 |
{ |
|
629 |
ArrayOfCells[i]=pHeap->Alloc(8); |
|
630 |
NumAllocated++; |
|
631 |
test(NumAllocated==pHeap->Count(NumFree)); |
|
632 |
test(NumFree==1); |
|
633 |
} |
|
634 |
pHeap->Check(); |
|
635 |
||
636 |
for(i=0; i<100; i+=2) |
|
637 |
{ |
|
638 |
TInt temp; |
|
639 |
pHeap->Free(ArrayOfCells[i]); |
|
640 |
NumAllocated--; |
|
641 |
NumFree++; |
|
642 |
test(NumAllocated==pHeap->Count(temp)); |
|
643 |
test(NumFree==temp); |
|
644 |
} |
|
645 |
pHeap->Check(); |
|
646 |
pHeap->Reset(); |
|
647 |
||
648 |
||
649 |
/////////////////////////////////////////// |
|
650 |
// Corrupt data and see what happens |
|
651 |
/////////////////////////////////////////// |
|
652 |
// Corrupt allocated cell header |
|
653 |
ArrayOfCells[0]=pHeap->Alloc(32); |
|
654 |
TUint32* pC=(TUint32*)ArrayOfCells[0]-KHeadSize; |
|
655 |
*pC=0xa5a5a5a5u; |
|
656 |
// pHeap->Check(); |
|
657 |
||
658 |
// Corrupt free cell header |
|
659 |
pHeap->Reset(); |
|
660 |
ArrayOfCells[0]=pHeap->Alloc(32); |
|
661 |
pC=(TUint32*)ArrayOfCells[0]+(pHeap->AllocLen(ArrayOfCells[0])>>2); |
|
662 |
*pC=0xa1a1a1a1u; |
|
663 |
//pHeap->Check(); // Check doesn't pick it up but an access violation is generated |
|
664 |
||
665 |
// Write past end of heap |
|
666 |
pHeap->Reset(); |
|
667 |
TInt Avail; |
|
668 |
ArrayOfCells[0]=pHeap->Alloc(pHeap->Available(Avail)); |
|
669 |
pC=(TUint32*)ArrayOfCells[0]+(pHeap->AllocLen(ArrayOfCells[0])>>2); |
|
670 |
//*pC=0xa1a1a1a1u; // This line isn't picked up by Check (wouldn't expect it to) but the call |
|
671 |
//pHeap->Check(); // to delete below consequently crashes |
|
672 |
||
673 |
delete [] ArrayOfCells; |
|
674 |
||
675 |
// close heap so we don't exceed chunk limit |
|
676 |
pHeap->Close(); |
|
677 |
} |
|
678 |
||
679 |
////////////////////////////////////// |
|
680 |
// Test the leave methods |
|
681 |
////////////////////////////////////// |
|
682 |
void TestRHeap::Test8(void) |
|
683 |
{ |
|
684 |
||
685 |
TAny* aCell=NULL; |
|
686 |
RHeap* pHeap=allocHeap(1000); |
|
687 |
TRAPD(ret,aCell=pHeap->AllocL(100)) |
|
688 |
test(ret==KErrNone); |
|
689 |
TRAP(ret,aCell=pHeap->AllocL(PageSize)) |
|
690 |
test(ret==KErrNoMemory); |
|
691 |
TRAP(ret,aCell=pHeap->ReAllocL(aCell,32)) |
|
692 |
test(ret==KErrNone); |
|
693 |
TRAP(ret,aCell=pHeap->ReAllocL(NULL,10000)) |
|
694 |
test(ret==KErrNoMemory); |
|
695 |
||
696 |
// close heap so we don't exceed chunk limit |
|
697 |
pHeap->Close(); |
|
698 |
} |
|
699 |
||
700 |
class RMyHeap : public RHeap |
|
701 |
{ |
|
702 |
public: |
|
703 |
void MyCompressAll(){} |
|
704 |
private: |
|
705 |
RMyHeap(); |
|
706 |
}; |
|
707 |
||
708 |
#include "TestRHeapShrink.h" |
|
709 |
||
710 |
/** |
|
711 |
Calculates whether or not the heap with iGrowBy=aGrowBy will be reduced if a |
|
712 |
cell of size aCellSize bytes is the top free cell. |
|
713 |
It must be calculated as both the page size and min cell size could vary |
|
714 |
between different platforms/builds. Also, KHeapMinCellSize is 'patchdata' and can be |
|
715 |
different for particular ROM builds |
|
716 |
ASSUMPTIONS:- |
|
717 |
1 - The cell of aCellSize starts past the RHeap's iMinLength (i.e. all of it can be |
|
718 |
removed without the RHeap becoming smaller than iMinLength |
|
719 |
2 - The default value of aAlign was passed to RHeap contructor |
|
720 |
These should be safe as this is onl used by t_heap TestRHeap::CompressAll() |
|
721 |
@return The number of bytes the heap will be reduced by |
|
722 |
*/ |
|
723 |
TInt TestRHeap::RHeapCalcReduce(TInt aCellSize, TInt aGrowBy) |
|
724 |
{ |
|
725 |
TInt ret = 0; |
|
726 |
TInt pageSize = 0; |
|
727 |
test(UserHal::PageSizeInBytes(pageSize)==KErrNone); |
|
728 |
||
729 |
// adjust aGrowBy to match what RHeap would have aligned its iGrowBy to |
|
730 |
// see RHeap::RHeap() |
|
731 |
aGrowBy = _ALIGN_UP(aGrowBy, pageSize); |
|
732 |
if (aCellSize >= KHeapShrinkHysRatio*(aGrowBy>>8)) |
|
733 |
{ |
|
734 |
//calc for amount to reduce heap from RHeap::Reduce() |
|
735 |
// assumes that cell of aCellSize starts past the RHeap's iMinLength |
|
736 |
ret=_ALIGN_DOWN(aCellSize, pageSize); |
|
737 |
} |
|
738 |
return ret; |
|
739 |
} |
|
740 |
||
741 |
void TestRHeap::TestCompressAll() |
|
742 |
{ |
|
743 |
||
744 |
TPtrC myHeapName=_L("MyHeap"); |
|
745 |
// myHeap will have default GrowBy of KMinHeapGrowBy |
|
746 |
RMyHeap* myHeap=(RMyHeap*)User::ChunkHeap(&myHeapName,0x100,0x2000); |
|
747 |
const TInt KnormHeapGrowBy = 0x2000; |
|
748 |
RHeap* normHeap=User::ChunkHeap(NULL,0x100,0x20000,KnormHeapGrowBy); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
749 |
// |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
750 |
// Configure paged heap threshold 128 Kb (pagepower 17) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
751 |
// |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
752 |
RHybridHeap::STestCommand conf; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
753 |
conf.iCommand = RHybridHeap::EGetConfig; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
754 |
if ( normHeap->DebugFunction(RHeap::EHybridHeap, (TAny*)&conf ) == KErrNone ) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
755 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
756 |
test.Printf(_L("New allocator detected, configuring paged threshold to 128 kb\r\n")); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
757 |
conf.iCommand = RHybridHeap::ESetConfig; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
758 |
conf.iConfig.iPagePower = 17; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
759 |
test( normHeap->DebugFunction(RHeap::EHybridHeap, (TAny*)&conf ) == KErrNone); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
760 |
} |
0 | 761 |
|
762 |
TAny* ptrMy1=myHeap->Alloc(0x102); |
|
763 |
test(ptrMy1!=NULL); |
|
764 |
TAny* ptrMy2=myHeap->Alloc(0x1001); |
|
765 |
test(ptrMy2!=NULL); |
|
766 |
TInt r=myHeap->Count(); |
|
767 |
test(r==2); |
|
768 |
||
769 |
TAny* ptrNorm1=normHeap->Alloc(0x8002); |
|
770 |
test(ptrNorm1!=NULL); |
|
771 |
TAny* ptrNorm2=normHeap->Alloc(0x12fff); |
|
772 |
test(ptrNorm2!=NULL); |
|
773 |
TAny* ptrNorm3=normHeap->Alloc(0x334f); |
|
774 |
test(ptrNorm3!=NULL); |
|
775 |
r=normHeap->Count(); |
|
776 |
test(r==3); |
|
777 |
||
778 |
TInt oldMyHeapSize=myHeap->Size(); |
|
779 |
TInt oldNormHeapSize=normHeap->Size(); |
|
780 |
||
781 |
myHeap->MyCompressAll(); |
|
782 |
||
783 |
r=myHeap->Count(); |
|
784 |
test(r==2); |
|
785 |
r=myHeap->Size(); |
|
786 |
test(r==oldMyHeapSize); |
|
787 |
r=normHeap->Count(); |
|
788 |
test(r==3); |
|
789 |
r=normHeap->Size(); |
|
790 |
test(r==oldNormHeapSize); |
|
791 |
||
792 |
// Remove the cell on the top of the normHeap |
|
793 |
normHeap->Free(ptrNorm3); |
|
794 |
// check myHeap unaffected |
|
795 |
r=myHeap->Count(); |
|
796 |
test(r==2); |
|
797 |
r=myHeap->Size(); |
|
798 |
test(r==oldMyHeapSize); |
|
799 |
//check normHeap updated after free of top cell |
|
800 |
r=normHeap->Count(); |
|
801 |
test(r==2); |
|
802 |
r=normHeap->Size(); |
|
803 |
||
804 |
// Calc the amount, if any, the overall size of normHeap will have been shrunk by |
|
805 |
// will depend on value of KHeapShrinkHysRatio. |
|
806 |
// 1st calc current total size of the allocated cells |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
807 |
TInt normAllocdSize = normHeap->AllocLen(ptrNorm1)+KHeadSize + |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
808 |
normHeap->AllocLen(ptrNorm2)+KHeadSize; |
0 | 809 |
TInt normReduce = RHeapCalcReduce(oldNormHeapSize-normAllocdSize,KnormHeapGrowBy); |
810 |
oldNormHeapSize -= normReduce; |
|
811 |
test(r==oldNormHeapSize); |
|
812 |
||
813 |
normHeap->Free(ptrNorm2); |
|
814 |
myHeap->Free(ptrMy2); |
|
815 |
r=myHeap->Count(); |
|
816 |
test(r==1); |
|
817 |
r=myHeap->Size(); |
|
818 |
||
819 |
// Calc the current total size of the allocated cells |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
820 |
TInt myAllocdSize = myHeap->AllocLen(ptrMy1)+KHeadSize; |
0 | 821 |
TInt myReduce=RHeapCalcReduce(oldMyHeapSize-myAllocdSize,1); |
822 |
oldMyHeapSize -= myReduce; |
|
823 |
test(r==oldMyHeapSize); |
|
824 |
||
825 |
r=normHeap->Count(); |
|
826 |
test(r==1); |
|
827 |
r=normHeap->Size(); |
|
828 |
||
829 |
// cell represented by ptrNorm3 may have already caused the heap |
|
830 |
// size to be reduced so ensure normReduce is factored into calcs |
|
831 |
test(r==oldNormHeapSize-(0x16000-normReduce)); |
|
832 |
||
833 |
myHeap->Close(); |
|
834 |
normHeap->Close(); |
|
835 |
} |
|
836 |
||
837 |
||
838 |
void TestRHeap::TestOffset() |
|
839 |
{ |
|
840 |
TInt size = 0x100000; |
|
841 |
const TInt offset = 0x8; |
|
842 |
const TUint8 magic = 0x74; // arbitrary magic value |
|
843 |
RChunk chunk; |
|
844 |
RHeap* heap; |
|
845 |
||
846 |
chunk.CreateLocal(0, size); |
|
847 |
size = chunk.MaxSize(); // X86 has 4MB chunk size |
|
848 |
||
849 |
// try and create a heap with a large offset - no room to make RHeap, should fail |
|
850 |
heap = UserHeap::OffsetChunkHeap(chunk, 0, size); |
|
851 |
test(heap==NULL); |
|
852 |
||
853 |
// write some magic numbers into the offset-reserved area |
|
854 |
chunk.Adjust(offset); |
|
855 |
TUint8* reserved = chunk.Base(); |
|
856 |
TUint8* limit = reserved + offset; |
|
857 |
for (; reserved<limit; reserved++) |
|
858 |
*reserved = magic; |
|
859 |
||
860 |
// make a heap with an offset |
|
861 |
heap = UserHeap::OffsetChunkHeap(chunk, 0, offset); |
|
862 |
test(heap!=NULL); |
|
863 |
test(chunk.Base() + offset == (TUint8*)heap); |
|
864 |
TInt origsize = heap->Size(); |
|
865 |
||
866 |
// force the heap to grow to the maximum size by allocating 1kb blocks |
|
867 |
// and then allocating whatever is left. Check this really is the end |
|
868 |
// of the chunk. |
|
869 |
TUint8* temp = NULL; |
|
870 |
TUint8* last = NULL; |
|
871 |
do |
|
872 |
{ |
|
873 |
last = temp; |
|
874 |
temp = (TUint8*)heap->Alloc(1024); |
|
875 |
} |
|
876 |
while (temp != NULL); |
|
877 |
TInt biggestblock, space; |
|
878 |
space = heap->Available(biggestblock); |
|
879 |
if (space>0) |
|
880 |
{ |
|
881 |
last = (TUint8*)heap->Alloc(space); |
|
882 |
test(last!=NULL); |
|
883 |
// Check that the last allocation doesn't pass the end of the chunk |
|
884 |
test(last+space <= chunk.Base()+size); |
|
885 |
// but that it is within the alignment requirement, as less than this |
|
886 |
// would be short of the end |
|
887 |
} |
|
888 |
else |
|
889 |
{ |
|
890 |
test(last+1024 == chunk.Base()+size); |
|
891 |
} |
|
892 |
||
893 |
// try writing at the top end of it to make sure it's backed |
|
894 |
*(chunk.Base()+size-1) = 1; |
|
895 |
||
896 |
// test resetting the heap |
|
897 |
heap->Reset(); |
|
898 |
test(origsize == heap->Size()); |
|
899 |
||
900 |
// check reducing the heap works |
|
901 |
last = (TUint8*)heap->Alloc(size>>2); |
|
902 |
TInt midsize = heap->Size(); |
|
903 |
temp = (TUint8*)heap->Alloc(size>>2); |
|
904 |
heap->Free(temp); |
|
905 |
heap->Compress(); |
|
906 |
test(midsize == heap->Size()); |
|
907 |
heap->Free(last); |
|
908 |
heap->Compress(); |
|
909 |
test(origsize == heap->Size()); |
|
910 |
||
911 |
// check the magic numbers are still there |
|
912 |
for (reserved = chunk.Base(); reserved<limit; reserved++) |
|
913 |
test(*reserved==magic); |
|
914 |
||
915 |
heap->Close(); |
|
916 |
} |
|
917 |
||
918 |
||
919 |
RSemaphore sem; |
|
920 |
LOCAL_C void syncThreads(TAny* anArg) |
|
921 |
// |
|
922 |
// get the threads both running at the same time |
|
923 |
// |
|
924 |
{ |
|
925 |
if ((TInt)anArg==1) |
|
926 |
sem.Wait(); |
|
927 |
else |
|
928 |
sem.Signal(); |
|
929 |
} |
|
930 |
||
931 |
TInt comeInNumber=0; |
|
932 |
LOCAL_C TInt sharedHeapTest1(TAny* anArg) |
|
933 |
// |
|
934 |
// Shared heap test thread. |
|
935 |
// |
|
936 |
{ |
|
937 |
||
938 |
RHeap* pH = (RHeap*)&User::Allocator(); |
|
939 |
if (gHeapPtr && pH!=gHeapPtr) |
|
940 |
return(KErrGeneral); |
|
941 |
gHeapPtr2 = pH; |
|
942 |
||
943 |
syncThreads(anArg); |
|
944 |
||
945 |
TAny* a[0x100]; |
|
946 |
TInt mod=((TInt)anArg)*3; |
|
947 |
||
948 |
// Run in a timed loop, to ensure that we get some true concurrency |
|
949 |
RTimer timer; |
|
950 |
TTime now; |
|
951 |
TRequestStatus done; |
|
952 |
test(timer.CreateLocal()==KErrNone); |
|
953 |
now.HomeTime(); |
|
954 |
timer.At(done,now+TTimeIntervalSeconds(20)); |
|
955 |
||
956 |
while (done==KRequestPending && comeInNumber!=(TInt)anArg) |
|
957 |
{ |
|
958 |
TInt i=0; |
|
959 |
for (;i<0x100;i++) |
|
960 |
{ |
|
961 |
a[i]=User::Alloc(0x10); |
|
962 |
test(a[i]!=NULL); |
|
963 |
Mem::Fill(a[i],0x10,(((TInt)anArg)<<4)|(i&0x0F)); // marker |
|
964 |
if ((i%mod)==0) |
|
965 |
pH->Check(); |
|
966 |
} |
|
967 |
for (i=0;i<0x100;i++) |
|
968 |
{ |
|
969 |
User::Free(a[i]); |
|
970 |
if ((i%mod)==0) |
|
971 |
pH->Check(); |
|
972 |
} |
|
973 |
} |
|
974 |
timer.Cancel(); |
|
975 |
return((TInt)anArg); |
|
976 |
} |
|
977 |
||
978 |
LOCAL_C void bumpKernelGranularity() |
|
979 |
// |
|
980 |
// Push up the kernels granularities |
|
981 |
// |
|
982 |
{ |
|
983 |
||
984 |
RThread t[4]; |
|
985 |
TInt r; |
|
986 |
TUint i=0; |
|
987 |
for (;i<4;i++) |
|
988 |
{ |
|
989 |
TName n; |
|
990 |
n.Format(_L("Temp%d"),i); |
|
991 |
r=t[i].Create(n,sharedHeapTest1,KDefaultStackSize,NULL,NULL); |
|
992 |
test(r==KErrNone); |
|
993 |
} |
|
994 |
for (i=0;i<4;i++) |
|
995 |
{ |
|
996 |
t[i].Kill(KErrNone); |
|
997 |
t[i].Close(); |
|
998 |
} |
|
999 |
} |
|
1000 |
||
1001 |
LOCAL_C void createTestThreads(TThreadFunction aFunction,RHeap* aHeap) |
|
1002 |
// |
|
1003 |
// Create two test threads using the supplied entry point and heap |
|
1004 |
// |
|
1005 |
{ |
|
1006 |
||
1007 |
||
1008 |
test.Next(_L("Create t1")); |
|
1009 |
RThread t1; |
|
1010 |
TInt r=t1.Create(_L("Shared1"),aFunction,KDefaultStackSize,aHeap,(TAny*)1); |
|
1011 |
test(r==KErrNone); |
|
1012 |
TRequestStatus tStat1; |
|
1013 |
t1.Logon(tStat1); |
|
1014 |
test(tStat1==KRequestPending); |
|
1015 |
||
1016 |
test.Next(_L("Create t2")); |
|
1017 |
RThread t2; |
|
1018 |
r=t2.Create(_L("Shared2"),aFunction,KDefaultStackSize,aHeap,(TAny*)2); |
|
1019 |
test(r==KErrNone); |
|
1020 |
TRequestStatus tStat2; |
|
1021 |
t2.Logon(tStat2); |
|
1022 |
test(tStat2==KRequestPending); |
|
1023 |
||
1024 |
test.Next(_L("Wait for t1 or t2 - approx 20 seconds")); |
|
1025 |
t1.Resume(); |
|
1026 |
t2.Resume(); |
|
1027 |
User::WaitForRequest(tStat1,tStat2); |
|
1028 |
User::WaitForRequest(tStat1==KRequestPending ? tStat1 : tStat2); |
|
1029 |
test(tStat1==1); |
|
1030 |
test(tStat2==2); |
|
1031 |
CLOSE_AND_WAIT(t1); |
|
1032 |
CLOSE_AND_WAIT(t2); |
|
1033 |
} |
|
1034 |
||
1035 |
LOCAL_C void SharedHeapTest1() |
|
1036 |
// |
|
1037 |
// Shared heap test using normal chunk heap |
|
1038 |
// |
|
1039 |
{ |
|
1040 |
||
1041 |
sem.CreateLocal(0); // create synchronisation semaphore |
|
1042 |
test.Start(_L("Create chunk to share")); |
|
1043 |
TPtrC sharedHeap=_L("SharedHeap"); |
|
1044 |
TInt minsize = ((RHeap&)User::Allocator()).Size(); |
|
1045 |
gHeapPtr=User::ChunkHeap(&sharedHeap,minsize/*0x20000*/,0x40000); |
|
1046 |
test(gHeapPtr!=NULL); |
|
1047 |
TInt count=gHeapPtr->Count(); |
|
1048 |
createTestThreads(sharedHeapTest1,gHeapPtr); |
|
1049 |
test(count==gHeapPtr->Count()); |
|
1050 |
gHeapPtr->Close(); |
|
1051 |
test.End(); |
|
1052 |
} |
|
1053 |
||
1054 |
LOCAL_C void SharedHeapTest2() |
|
1055 |
// |
|
1056 |
// Shared heap test using the current threads heap. Can test kernel |
|
1057 |
// cleanup since granularity will have been handled by running |
|
1058 |
// SharedHeapTest2(). |
|
1059 |
// |
|
1060 |
{ |
|
1061 |
||
1062 |
test.Start(_L("Current chunk to share")); |
|
1063 |
test.Next(_L("Bump up granularities")); |
|
1064 |
// |
|
1065 |
// First create a number of threads to push up the kernels granularities |
|
1066 |
// |
|
1067 |
bumpKernelGranularity(); |
|
1068 |
// |
|
1069 |
__KHEAP_MARK; |
|
1070 |
gHeapPtr = (RHeap*)&User::Allocator(); |
|
1071 |
TInt biggest1; |
|
1072 |
TInt avail1=gHeapPtr->Available(biggest1); |
|
1073 |
TInt size1=gHeapPtr->Size(); |
|
1074 |
||
1075 |
createTestThreads(sharedHeapTest1,NULL); |
|
1076 |
||
1077 |
TInt biggest2; |
|
1078 |
TInt avail2=gHeapPtr->Available(biggest2); |
|
1079 |
TInt size2=gHeapPtr->Size(); |
|
1080 |
test.Printf(_L("Before: size %d, %d available (biggest %d)\r\n"),size1,avail1,biggest1); |
|
1081 |
test.Printf(_L("After: size %d, %d available (biggest %d)\r\n"),size2,avail2,biggest2); |
|
1082 |
test((size1-avail1)==(size2-avail2)); // no leaks |
|
1083 |
if (avail1==biggest1) // if it was a single block of free space before |
|
1084 |
test(avail2==biggest2); // then it should still be a single block |
|
1085 |
__KHEAP_MARKEND; |
|
1086 |
test.End(); |
|
1087 |
} |
|
1088 |
||
1089 |
LOCAL_C void SharedHeapTest3() |
|
1090 |
// |
|
1091 |
// Shared heap test borrowing a thread's default heap and |
|
1092 |
// killing threads in different orders. |
|
1093 |
// |
|
1094 |
{ |
|
1095 |
||
1096 |
test.Start(_L("Create t1 whose heap will be shared")); |
|
1097 |
gHeapPtr = NULL; |
|
1098 |
RThread t1; |
|
1099 |
TInt r=t1.Create(_L("Owner_T1"),sharedHeapTest1,KDefaultStackSize,0x20000,0x40000,(TAny*)1); |
|
1100 |
test(r==KErrNone); |
|
1101 |
TRequestStatus tStat1; |
|
1102 |
t1.Logon(tStat1); |
|
1103 |
test(tStat1==KRequestPending); |
|
1104 |
t1.SetPriority(EPriorityMore); //t1 gets to wait on semaphore sem, before we start t2 |
|
1105 |
t1.Resume(); |
|
1106 |
test.Next(_L("Create t2 sharing t1's heap")); |
|
1107 |
RThread t2; |
|
1108 |
r=t2.Create(_L("Sharer_T2"),sharedHeapTest1,KDefaultStackSize,gHeapPtr2,(TAny*)2); |
|
1109 |
test(r==KErrNone); |
|
1110 |
TRequestStatus tStat2; |
|
1111 |
t2.Logon(tStat2); |
|
1112 |
test(tStat2==KRequestPending); |
|
1113 |
||
1114 |
test.Next(_L("Get t1 to exit while t2 continues running")); |
|
1115 |
test(tStat1==KRequestPending); |
|
1116 |
test(tStat2==KRequestPending); |
|
1117 |
t1.SetPriority(EPriorityNormal); //back to the same priority as t2 |
|
1118 |
t2.Resume(); |
|
1119 |
test(tStat1==KRequestPending); |
|
1120 |
test(tStat2==KRequestPending); |
|
1121 |
comeInNumber=1; |
|
1122 |
test.Next(_L("Wait for t1")); |
|
1123 |
User::WaitForRequest(tStat1); |
|
1124 |
test(tStat1==1); |
|
1125 |
test(t1.ExitType()==EExitKill); |
|
1126 |
test(t1.ExitReason()==1); |
|
1127 |
test(tStat2==KRequestPending); |
|
1128 |
test(t2.ExitType()==EExitPending); |
|
1129 |
test.Next(_L("Wait for t2")); |
|
1130 |
User::WaitForRequest(tStat2); |
|
1131 |
test(tStat2==2); |
|
1132 |
test(t2.ExitType()==EExitKill); |
|
1133 |
test(t2.ExitReason()==2); |
|
1134 |
CLOSE_AND_WAIT(t2); |
|
1135 |
CLOSE_AND_WAIT(t1); |
|
1136 |
test.End(); |
|
1137 |
} |
|
1138 |
||
1139 |
LOCAL_C void TestAuto() |
|
1140 |
// |
|
1141 |
// Test heap auto expansion and compression |
|
1142 |
// |
|
1143 |
{ |
|
1144 |
||
1145 |
test.Start(_L("Create chunk to")); |
|
1146 |
TPtrC autoHeap=_L("AutoHeap"); |
|
1147 |
gHeapPtr=User::ChunkHeap(&autoHeap,0x1800,0x6000); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1148 |
|
0 | 1149 |
test(gHeapPtr!=NULL); |
1150 |
TInt biggest; |
|
1151 |
TInt avail=gHeapPtr->Available(biggest); |
|
1152 |
test(avail==biggest); |
|
1153 |
TAny *p1=gHeapPtr->Alloc(biggest); |
|
1154 |
test(p1!=NULL); |
|
1155 |
TAny *p2=gHeapPtr->Alloc(biggest); |
|
1156 |
test(p2!=NULL); |
|
1157 |
TAny *p3=gHeapPtr->Alloc(biggest); |
|
1158 |
test(p3!=NULL); |
|
1159 |
TAny *p4=gHeapPtr->Alloc(biggest); |
|
1160 |
test(p4==NULL); |
|
1161 |
TInt comp=gHeapPtr->Compress(); |
|
1162 |
test(comp==0); |
|
1163 |
gHeapPtr->Free(p2); |
|
1164 |
comp=gHeapPtr->Compress(); |
|
1165 |
test(comp==0); |
|
1166 |
gHeapPtr->Free(p3); |
|
1167 |
comp=gHeapPtr->Compress(); |
|
1168 |
// stop wins compiler warning of constant expression as KHeapShrinkHysRatio |
|
1169 |
// isn't constant for non-emulator builds but ROM 'patchdata' |
|
1170 |
#pragma warning(disable : 4127) |
|
1171 |
// When hysteresis value > 4.0*GrowBy then Free() calls |
|
1172 |
// won't shrink heap but normally will shrink heap |
|
1173 |
if (KHeapShrinkHysRatio <= 1024) |
|
1174 |
test(comp==0); |
|
1175 |
else |
|
1176 |
test(comp==0x4000); |
|
1177 |
#pragma warning(default : 4127) |
|
1178 |
gHeapPtr->Free(p1); |
|
1179 |
comp=gHeapPtr->Compress(); |
|
1180 |
test(comp==0); |
|
1181 |
TInt biggest1; |
|
1182 |
TInt avail1=gHeapPtr->Available(biggest1); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1183 |
test(avail==avail1); |
0 | 1184 |
test(biggest==biggest1); |
1185 |
test(gHeapPtr->Count()==0); |
|
1186 |
gHeapPtr->Close(); |
|
1187 |
test.End(); |
|
1188 |
} |
|
1189 |
||
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1190 |
LOCAL_C TInt NormalChunk(RChunk& aChunk, TInt aInitialSize, TInt aMaxSize) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1191 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1192 |
TChunkCreateInfo createInfo; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1193 |
createInfo.SetNormal(aInitialSize, aMaxSize); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1194 |
TInt r=aChunk.Create(createInfo); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1195 |
return r; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1196 |
} |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1197 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1198 |
LOCAL_C TInt DisconnectedChunk(RChunk& aChunk, TInt aInitialBottom, TInt aInitialTop, TInt aMaxSize) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1199 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1200 |
TChunkCreateInfo createInfo; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1201 |
createInfo.SetDisconnected(aInitialBottom, aInitialTop, aMaxSize); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1202 |
TInt r=aChunk.Create(createInfo); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1203 |
return r; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1204 |
} |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1205 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1206 |
LOCAL_C TBool TestIsHybridHeap(RHeap* aHeap) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1207 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1208 |
RHybridHeap::STestCommand cmd; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1209 |
cmd.iCommand = RHybridHeap::EHeapMetaData; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1210 |
aHeap->DebugFunction(RHeap::EHybridHeap, (TAny*)&cmd, 0); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1211 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1212 |
RHybridHeap* hybridHeap = (RHybridHeap*) cmd.iData; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1213 |
return (TestHybridHeap::IsHybrid(hybridHeap)); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1214 |
} |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1215 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1216 |
LOCAL_C void TestHeapType() |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1217 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1218 |
TBool onlyDL = EFalse; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1219 |
_LIT(KHeap, "NamedHeap"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1220 |
// 1: Create a heap in a local chunk |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1221 |
RHeap* heap; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1222 |
heap = UserHeap::ChunkHeap(NULL,0x100,0x2000); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1223 |
TBool hybrid = TestIsHybridHeap(heap); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1224 |
if (hybrid==0) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1225 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1226 |
test.Printf(_L("Only DL allocator is in use \n")); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1227 |
onlyDL = ETrue;; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1228 |
} |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1229 |
else |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1230 |
test(hybrid==1); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1231 |
heap->Close(); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1232 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1233 |
// 2: Create a heap in a global chunk |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1234 |
heap = UserHeap::ChunkHeap(&KHeap,0,0x1800,0x6000); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1235 |
hybrid = TestIsHybridHeap(heap); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1236 |
if(!onlyDL) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1237 |
test(hybrid==1); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1238 |
heap->Close(); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1239 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1240 |
// 3: Create a heap in an existing normal chunk |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1241 |
RChunk chunk; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1242 |
TInt r = NormalChunk(chunk,0,0x1000); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1243 |
heap = UserHeap::ChunkHeap(chunk,0); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1244 |
hybrid = TestIsHybridHeap(heap); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1245 |
test(hybrid==0); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1246 |
heap->Close(); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1247 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1248 |
// 4: Create a heap in an existing disconnected chunk |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1249 |
// when offset = 0. Minimum heap size for a hybrid heap is 12KB |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1250 |
r = DisconnectedChunk(chunk,0,0,0x3000); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1251 |
heap = UserHeap::ChunkHeap(chunk,0); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1252 |
hybrid = TestIsHybridHeap(heap); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1253 |
if(!onlyDL) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1254 |
test(hybrid==1); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1255 |
heap->Close(); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1256 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1257 |
// 5: Create a heap in an existing disconnected chunk |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1258 |
// when offset > 0 |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1259 |
r = DisconnectedChunk(chunk,0,0x1800,0x6000); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1260 |
heap = UserHeap::OffsetChunkHeap(chunk,0,0x2800); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1261 |
hybrid = TestIsHybridHeap(heap); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1262 |
test(hybrid==0); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1263 |
heap->Close(); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1264 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1265 |
// 6: Create a fixed length heap at a normal chunk's base address |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1266 |
r = NormalChunk(chunk,0x1000,0x1000); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1267 |
heap = UserHeap::FixedHeap(chunk.Base(), 0x1000); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1268 |
hybrid = TestIsHybridHeap(heap); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1269 |
test(hybrid==0); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1270 |
heap->Close(); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1271 |
chunk.Close(); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1272 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1273 |
// 7: Create a fixed length heap at a disconnected chunk's base address |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1274 |
// when bottom = 0 |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1275 |
r = DisconnectedChunk(chunk,0,0x2000,0x2000); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1276 |
heap = UserHeap::FixedHeap(chunk.Base(), 0x2000); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1277 |
hybrid = TestIsHybridHeap(heap); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1278 |
test(hybrid==0); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1279 |
heap->Close(); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1280 |
chunk.Close(); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1281 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1282 |
// 8: Create a fixed length heap at a disconnected chunk's base address |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1283 |
// when bottom > 0 |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1284 |
r = DisconnectedChunk(chunk,0x6000,0x7000,0x13000); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1285 |
heap = UserHeap::FixedHeap(chunk.Base()+ 0x6000, 0x1000); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1286 |
hybrid = TestIsHybridHeap(heap); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1287 |
test(hybrid==0); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1288 |
heap->Close(); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1289 |
chunk.Close(); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1290 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1291 |
// 9: Create a fixed length heap for allocated buffer |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1292 |
heap = UserHeap::ChunkHeap(&KNullDesC(), 4096, (4096 * 1024)); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1293 |
test(heap != NULL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1294 |
TAny* buffer = heap->Alloc(1024 * 1024); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1295 |
test(buffer != NULL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1296 |
TInt lth = heap->AllocLen(buffer); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1297 |
test.Printf(_L("Fixed heap buffer: %x, length: %x \n"), buffer, lth); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1298 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1299 |
RHeap* heapf = UserHeap::FixedHeap(buffer, (1024 * 1024)); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1300 |
test(heapf != NULL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1301 |
test.Printf(_L("Fixed heap: %x \n"), heapf); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1302 |
hybrid = TestIsHybridHeap(heapf); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1303 |
test(hybrid==0); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1304 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1305 |
heapf->Close(); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1306 |
heap->Free(buffer); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1307 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1308 |
heap->Close(); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1309 |
} |
0 | 1310 |
|
1311 |
GLDEF_C TInt E32Main(void) |
|
1312 |
{ |
|
1313 |
||
1314 |
test.Title(); |
|
1315 |
||
1316 |
__KHEAP_MARK; |
|
1317 |
||
1318 |
test.Start(_L("Test 1")); |
|
1319 |
UserHal::PageSizeInBytes(PageSize); |
|
1320 |
TestRHeap T; |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1321 |
|
0 | 1322 |
T.Test1(); |
1323 |
test.Next(_L("Test auto expand and compress")); |
|
1324 |
TestAuto(); |
|
1325 |
test.Next(_L("Test 2")); |
|
1326 |
T.Test2(); |
|
1327 |
test.Next(_L("Test 3")); |
|
1328 |
T.Test3(); |
|
1329 |
test.Next(_L("Test 4")); |
|
1330 |
T.Test4(); |
|
1331 |
test.Next(_L("Test 5")); |
|
1332 |
T.Test5(); |
|
1333 |
test.Next(_L("Test 7")); |
|
1334 |
T.Test7(); |
|
1335 |
test.Next(_L("Test 8")); |
|
1336 |
T.Test8(); |
|
1337 |
test.Next(_L("Test CompressAll()")); |
|
1338 |
T.TestCompressAll(); |
|
1339 |
test.Next(_L("Test offset heap")); |
|
1340 |
T.TestOffset(); |
|
1341 |
test.Next(_L("Shared heap test 1")); |
|
1342 |
SharedHeapTest1(); |
|
1343 |
test.Next(_L("Shared heap test 2")); |
|
1344 |
SharedHeapTest2(); |
|
1345 |
test.Next(_L("Shared heap test 3")); |
|
1346 |
SharedHeapTest3(); |
|
1347 |
sem.Close(); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1348 |
test.Next(_L("Test HeapType()")); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1349 |
TestHeapType(); |
0 | 1350 |
|
1351 |
__KHEAP_CHECK(0); |
|
1352 |
__KHEAP_MARKEND; |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1353 |
|
0 | 1354 |
test.End(); |
1355 |
return(0); |
|
1356 |
} |
|
1357 |