43 // |
43 // |
44 |
44 |
45 #include <e32test.h> |
45 #include <e32test.h> |
46 #include <e32def.h> |
46 #include <e32def.h> |
47 #include <e32def_private.h> |
47 #include <e32def_private.h> |
|
48 #include "dla.h" |
|
49 #include "slab.h" |
|
50 #include "page_alloc.h" |
|
51 #include "heap_hybrid.h" |
|
52 #define KHEAPCELLINFO RHybridHeap::SHeapCellInfo |
48 |
53 |
49 LOCAL_D RTest test(_L("T_HEAPDB")); |
54 LOCAL_D RTest test(_L("T_HEAPDB")); |
50 |
55 |
51 #if defined(_DEBUG) |
56 #if defined(_DEBUG) |
52 |
57 |
53 RHeap::SHeapCellInfo CellInfo[4]; |
58 KHEAPCELLINFO CellInfo[4]; |
54 |
59 |
55 class RTestHeap : public RHeap |
60 class RTestHeap : public RHeap |
56 { |
61 { |
57 public: |
62 public: |
58 void AttachInfo(SHeapCellInfo* aInfo) |
63 void AttachInfo(KHEAPCELLINFO* aInfo) |
59 {iTestData = aInfo;} |
64 { |
|
65 RHybridHeap::STestCommand cmd; |
|
66 cmd.iData = aInfo; |
|
67 cmd.iCommand = RHybridHeap::ETestData; |
|
68 DebugFunction(RHeap::EHybridHeap, (TAny*)&cmd); |
|
69 } |
60 }; |
70 }; |
61 |
71 |
62 void AttachToHeap(RHeap* aHeap, TInt aInfo) |
72 void AttachToHeap(RHeap* aHeap, TInt aInfo) |
63 { |
73 { |
64 if (!aHeap) |
74 if (!aHeap) |
66 ((RTestHeap*)aHeap)->AttachInfo(CellInfo + aInfo); |
76 ((RTestHeap*)aHeap)->AttachInfo(CellInfo + aInfo); |
67 } |
77 } |
68 |
78 |
69 void TestCellInfo(TInt aInfo, TInt aNest, TInt aAllocCount, TInt aLevelAlloc, TInt aSize, TAny* aAddr) |
79 void TestCellInfo(TInt aInfo, TInt aNest, TInt aAllocCount, TInt aLevelAlloc, TInt aSize, TAny* aAddr) |
70 { |
80 { |
71 RHeap::SHeapCellInfo& ci = CellInfo[aInfo]; |
81 (void) aSize; |
|
82 KHEAPCELLINFO& ci = CellInfo[aInfo]; |
72 RHeap::SDebugCell& cell = *ci.iStranded; |
83 RHeap::SDebugCell& cell = *ci.iStranded; |
73 test(cell.nestingLevel == aNest); |
84 test(cell.nestingLevel == aNest); |
74 test(cell.allocCount == aAllocCount); |
85 test(cell.allocCount == aAllocCount); |
75 test(ci.iLevelAlloc == aLevelAlloc); |
86 test(ci.iLevelAlloc == aLevelAlloc); |
76 test(cell.len == aSize + RHeap::EAllocCellSize); |
|
77 test((&cell+1) == aAddr); |
87 test((&cell+1) == aAddr); |
78 } |
88 } |
79 |
89 |
80 const TInt KMaxFailureRate=100; |
90 const TInt KMaxFailureRate=100; |
81 const TInt KThreadMemError=-50; |
91 const TInt KThreadMemError=-50; |
82 const TInt KCellSize=(sizeof(RHeap::SCell)); // Size of free cell header |
|
83 const TInt KHeadSize=(sizeof(RHeap::SDebugCell)); // Size of allocated cell header with space for heaven info |
|
84 |
92 |
85 LOCAL_D TInt heapCount=1; |
93 LOCAL_D TInt heapCount=1; |
86 LOCAL_D RSemaphore threadSemaphore; |
94 LOCAL_D RSemaphore threadSemaphore; |
87 LOCAL_D TBool array1[KMaxFailureRate+1]; |
95 LOCAL_D TBool array1[KMaxFailureRate+1]; |
88 LOCAL_D TBool array2[KMaxFailureRate+1]; |
96 LOCAL_D TBool array2[KMaxFailureRate+1]; |