kerneltest/e32test/heap/t_heap.cpp
branchRCL_3
changeset 44 3e88ff8f41d5
parent 43 c1f20ce4abcf
equal deleted inserted replaced
43:c1f20ce4abcf 44:3e88ff8f41d5
    64 
    64 
    65 #include <e32test.h>
    65 #include <e32test.h>
    66 #include <e32hal.h>
    66 #include <e32hal.h>
    67 #include <e32def.h>
    67 #include <e32def.h>
    68 #include <e32def_private.h>
    68 #include <e32def_private.h>
    69 #include "dla.h"
       
    70 #include "slab.h"
       
    71 #include "page_alloc.h"
       
    72 #include "heap_hybrid.h"
       
    73 
    69 
    74 // Sets data for Test6
    70 // Sets data for Test6
    75 #define SetData(size)	pHeap->Reset();\
    71 #define SetData(size)	pHeap->Reset();\
    76 						Cell1=pHeap->Alloc(size);\
    72 						Cell1=pHeap->Alloc(size);\
    77 						Cell2=pHeap->Alloc(size);\
    73 						Cell2=pHeap->Alloc(size);\
    92 #else
    88 #else
    93     const TInt KHeapMinCellSize = 0;
    89     const TInt KHeapMinCellSize = 0;
    94 #endif
    90 #endif
    95 
    91 
    96 const TInt KHeadSize = (TInt)RHeap::EAllocCellSize;
    92 const TInt KHeadSize = (TInt)RHeap::EAllocCellSize;
    97 
    93 const TInt KAlign = _FOFF(RHeap::_s_align, d);
    98 const TInt KAlign = RHeap::ECellAlignment;
       
    99 const TInt KMinCellLength = _ALIGN_UP((KHeapMinCellSize + Max(TInt(RHeap::EFreeCellSize),TInt(RHeap::EAllocCellSize))),KAlign) - RHeap::EAllocCellSize;
    94 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);
    95 const TInt KMinFreeSize = _ALIGN_UP((KHeapMinCellSize + Max(TInt(RHeap::EFreeCellSize),TInt(RHeap::EAllocCellSize))),KAlign);
   101 
    96 
   102 TInt PageSize;
    97 TInt PageSize;
   103 
    98 
   111 	{
   106 	{
   112 	TUint				iMinLength;
   107 	TUint				iMinLength;
   113 	RChunk				iChunk;
   108 	RChunk				iChunk;
   114 	TUint8				*iBase;
   109 	TUint8				*iBase;
   115 	TUint8				*iTop;
   110 	TUint8				*iTop;
   116 	//RHeap::SCell		iFree;
   111 	RHeap::SCell		iFree;
   117 	};
   112 	};
   118 
   113 
   119 #pragma warning ( disable :4705 ) // statement has no effect
   114 #pragma warning ( disable :4705 ) // statement has no effect
   120 RHeapDump OrigDump;
   115 RHeapDump OrigDump;
   121 #pragma warning ( default :4705 )
   116 #pragma warning ( default :4705 )
   122 
   117 
   123 #if defined(_DEBUG)
   118 #if defined(_DEBUG)
   124 void RTestHeap::__DbgTest(void* aPtr) const
   119 void RTestHeap::__DbgTest(void* aPtr) const
   125 	{
   120 	{
   126 	(void) aPtr;
       
   127 /*	
       
   128 	RHeapDump& d = *(RHeapDump*)aPtr;
   121 	RHeapDump& d = *(RHeapDump*)aPtr;
   129 	d.iMinLength=iMinLength;
   122 	d.iMinLength=iMinLength;
   130 	d.iChunk.SetHandle(iChunkHandle);
   123 	d.iChunk.SetHandle(iChunkHandle);
   131 	d.iBase=iBase;
   124 	d.iBase=iBase;
   132 	d.iTop=iTop;
   125 	d.iTop=iTop;
   133 	d.iFree=iFree;
   126 	d.iFree=iFree;
   134 */	
       
   135 	}
   127 	}
   136 #endif
   128 #endif
   137 
   129 
   138 
   130 
   139 #if defined(_DEBUG)
   131 #if defined(_DEBUG)
   140 TBool Invariant(RHeap* aHeap)
   132 TBool Invariant(RHeap* aHeap)
   141 	{
   133 	{
   142 	(void) aHeap;
       
   143 /*	
       
   144 	RHeapDump dump;
   134 	RHeapDump dump;
   145 	((RTestHeap*)aHeap)->__DbgTest(&dump);
   135 	((RTestHeap*)aHeap)->__DbgTest(&dump);
   146 	if(dump.iMinLength!=OrigDump.iMinLength) 		return(EFalse);
   136 	if(dump.iMinLength!=OrigDump.iMinLength) 		return(EFalse);
   147 	// Note: iChunk is a class
   137 	// Note: iChunk is a class
   148 	if(dump.iBase!=OrigDump.iBase)			return(EFalse);
   138 	if(dump.iBase!=OrigDump.iBase)			return(EFalse);
   149 	if(*dump.iBase!=*OrigDump.iBase)		return(EFalse);
   139 	if(*dump.iBase!=*OrigDump.iBase)		return(EFalse);
   150 	if(dump.iTop!=OrigDump.iTop)			return(EFalse);
   140 	if(dump.iTop!=OrigDump.iTop)			return(EFalse);
   151 	if(dump.iTop[-1]!=OrigDump.iTop[-1])	return(EFalse);	
   141 	if(dump.iTop[-1]!=OrigDump.iTop[-1])	return(EFalse);	
   152 	if(dump.iFree.len!=OrigDump.iFree.len)	return(EFalse);
   142 	if(dump.iFree.len!=OrigDump.iFree.len)	return(EFalse);
   153 	// iFree.Next changes during allocation/freeing etc.
   143 	// iFree.Next changes during allocation/freeing etc.
   154 */
       
   155 	return(ETrue);
   144 	return(ETrue);
   156 	}
   145 	}
   157 #define INV(x) x;
   146 #define INV(x) x;
   158 #else
   147 #else
   159 #define INV(x)
   148 #define INV(x)
   161 
   150 
   162 LOCAL_D RTest test(_L("T_HEAP"));
   151 LOCAL_D RTest test(_L("T_HEAP"));
   163 LOCAL_D TInt heapCount=1;
   152 LOCAL_D TInt heapCount=1;
   164 LOCAL_D RHeap *gHeapPtr;
   153 LOCAL_D RHeap *gHeapPtr;
   165 LOCAL_D RHeap *gHeapPtr2;
   154 LOCAL_D RHeap *gHeapPtr2;
   166 
       
   167 /*
       
   168 Friend class of RHeapHybrid to access to hybrid heap metadata
       
   169 */
       
   170 class TestHybridHeap
       
   171 {
       
   172 public:
       
   173     static TBool IsHybrid(const RHybridHeap * aHybridHeap);
       
   174 };
       
   175 
       
   176 TBool TestHybridHeap::IsHybrid(const RHybridHeap * aHybridHeap)
       
   177   {
       
   178   if (aHybridHeap->iDLOnly)
       
   179       return EFalse;
       
   180   else
       
   181       return ETrue;
       
   182   }
       
   183 
   155 
   184 class TestRHeap
   156 class TestRHeap
   185 	{
   157 	{
   186 public:
   158 public:
   187 	void Test1(void);
   159 	void Test1(void);
   242 	RHeapDump dump;
   214 	RHeapDump dump;
   243 	RHeap* pHeap=allocHeap(3000);
   215 	RHeap* pHeap=allocHeap(3000);
   244 
   216 
   245 	((RTestHeap*)pHeap)->__DbgTest(&OrigDump);
   217 	((RTestHeap*)pHeap)->__DbgTest(&OrigDump);
   246 	((RTestHeap*)pHeap)->__DbgTest(&dump);
   218 	((RTestHeap*)pHeap)->__DbgTest(&dump);
   247 	
   219 	test(dump.iBase==pHeap->Base());
   248 //	test(dump.iBase==pHeap->Base());
   220 	test((dump.iTop-dump.iBase)==pHeap->Size());
   249 //	test((dump.iTop-dump.iBase)==pHeap->Size());
       
   250 	pHeap->Check();
   221 	pHeap->Check();
   251 	test(Invariant(pHeap));
   222 	test(Invariant(pHeap));
   252 	pHeap->Close();
   223 	pHeap->Close();
   253 #endif
   224 #endif
   254 	}
   225 	}
   537 	CellSize=pHeap->AllocLen(aCell);  // test?
   508 	CellSize=pHeap->AllocLen(aCell);  // test?
   538 
   509 
   539 	// Resize positively
   510 	// Resize positively
   540 	for(TInt aSize=0; aSize<=BiggestBlock; aSize++, pHeap->Available(BiggestBlock))
   511 	for(TInt aSize=0; aSize<=BiggestBlock; aSize++, pHeap->Available(BiggestBlock))
   541 		{
   512 		{
   542 		aCell = pHeap->ReAlloc(aCell, aSize); 
   513 		test(pHeap->ReAlloc(aCell, aSize)!=NULL); 
   543 		test(aCell!=NULL); 
       
   544 		CellSize=pHeap->AllocLen(aCell);
   514 		CellSize=pHeap->AllocLen(aCell);
   545 		test(CellSize>=aSize);
   515 		test(CellSize>=aSize);
       
   516 		if (aSize<KMinCellLength)
       
   517 			test(CellSize==KMinCellLength);
       
   518 		else
       
   519 			test(CellSize<aSize+KAlign);
   546 		}
   520 		}
   547 
   521 
       
   522 	// Note: when increasing a cell size the size is rounded up to the nearest 4 but when 
       
   523 	// decreasing a cell the size is rounded down to the nearest 8 - this is due to the fact
       
   524 	// that when memory is released its size must be big enough to hold a free cell header which
       
   525 	// is greater(8) than an allocated header(4)
       
   526 	// i.e. size = 16, resize to 17 => result  is 20. But resize to 15 stays as 16, resize to 9
       
   527 	// stays as 16 but resize as 8 will resize to 8
       
   528 
       
   529 	for(TInt aSize2=(TInt)pHeap->AllocLen(aCell); aSize2>=0; aSize2--)
       
   530 		{
       
   531 		test(pHeap->ReAlloc(aCell, aSize2)!=NULL);
       
   532 
       
   533 		test((TInt)pHeap->AllocLen(aCell)>=aSize2);		
       
   534 
       
   535 		TInt aTmpSize2 = Max(_ALIGN_UP(aSize2 + RHeap::EAllocCellSize, KAlign), KMinFreeSize);
       
   536 
       
   537 		test((TInt)pHeap->AllocLen(aCell)<=aTmpSize2+KMinFreeSize);		
       
   538 		}
       
   539   
   548 	pHeap->Check();
   540 	pHeap->Check();
   549 	pHeap->Reset();
   541 	pHeap->Reset();
   550 	// Allocate a block, fill with data, allocate another block or two then resize the original
   542 	// 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 
   543 	// block such that it has to be moved in memory, then check the blocks' contents 
   552 	TAny* Cell1=pHeap->Alloc(16);
   544 	TAny* Cell1=pHeap->Alloc(16);
   744 	TPtrC myHeapName=_L("MyHeap");
   736 	TPtrC myHeapName=_L("MyHeap");
   745 	// myHeap will have default GrowBy of KMinHeapGrowBy
   737 	// myHeap will have default GrowBy of KMinHeapGrowBy
   746 	RMyHeap* myHeap=(RMyHeap*)User::ChunkHeap(&myHeapName,0x100,0x2000);
   738 	RMyHeap* myHeap=(RMyHeap*)User::ChunkHeap(&myHeapName,0x100,0x2000);
   747 const TInt KnormHeapGrowBy = 0x2000;
   739 const TInt KnormHeapGrowBy = 0x2000;
   748 	RHeap* normHeap=User::ChunkHeap(NULL,0x100,0x20000,KnormHeapGrowBy);
   740 	RHeap* normHeap=User::ChunkHeap(NULL,0x100,0x20000,KnormHeapGrowBy);
   749 	//
       
   750 	// Configure paged heap threshold 128 Kb (pagepower 17)
       
   751 	//
       
   752 	RHybridHeap::STestCommand conf;
       
   753 	conf.iCommand = RHybridHeap::EGetConfig;
       
   754 	if ( normHeap->DebugFunction(RHeap::EHybridHeap, (TAny*)&conf ) == KErrNone )
       
   755 		{
       
   756 		test.Printf(_L("New allocator detected, configuring paged threshold to 128 kb\r\n"));
       
   757 		conf.iCommand = RHybridHeap::ESetConfig;
       
   758 		conf.iConfig.iPagePower = 17;
       
   759 		test( normHeap->DebugFunction(RHeap::EHybridHeap, (TAny*)&conf ) == KErrNone);
       
   760 		}
       
   761 
   741 
   762 	TAny* ptrMy1=myHeap->Alloc(0x102);
   742 	TAny* ptrMy1=myHeap->Alloc(0x102);
   763 	test(ptrMy1!=NULL);
   743 	test(ptrMy1!=NULL);
   764 	TAny* ptrMy2=myHeap->Alloc(0x1001);
   744 	TAny* ptrMy2=myHeap->Alloc(0x1001);
   765 	test(ptrMy2!=NULL);
   745 	test(ptrMy2!=NULL);
   802 	r=normHeap->Size();
   782 	r=normHeap->Size();
   803 
   783 
   804 	// Calc the amount, if any, the overall size of normHeap will have been shrunk by
   784 	// Calc the amount, if any, the overall size of normHeap will have been shrunk by
   805 	// will depend on value of KHeapShrinkHysRatio.
   785 	// will depend on value of KHeapShrinkHysRatio.
   806 	// 1st calc current total size of the allocated cells
   786 	// 1st calc current total size of the allocated cells
   807 	TInt normAllocdSize = 	normHeap->AllocLen(ptrNorm1)+KHeadSize +
   787 	TInt normAllocdSize = 	normHeap->AllocLen(ptrNorm1)+RHeap::EAllocCellSize +
   808 							normHeap->AllocLen(ptrNorm2)+KHeadSize;
   788 							normHeap->AllocLen(ptrNorm2)+RHeap::EAllocCellSize;
   809 	TInt normReduce = RHeapCalcReduce(oldNormHeapSize-normAllocdSize,KnormHeapGrowBy);
   789 	TInt normReduce = RHeapCalcReduce(oldNormHeapSize-normAllocdSize,KnormHeapGrowBy);
   810 	oldNormHeapSize -= normReduce;
   790 	oldNormHeapSize -= normReduce;
   811 	test(r==oldNormHeapSize);
   791 	test(r==oldNormHeapSize);
   812 
   792 
   813 	normHeap->Free(ptrNorm2);
   793 	normHeap->Free(ptrNorm2);
   815 	r=myHeap->Count();
   795 	r=myHeap->Count();
   816 	test(r==1);
   796 	test(r==1);
   817 	r=myHeap->Size();
   797 	r=myHeap->Size();
   818 
   798 
   819 	// Calc the current total size of the allocated cells
   799 	// Calc the current total size of the allocated cells
   820 	TInt myAllocdSize = myHeap->AllocLen(ptrMy1)+KHeadSize;
   800 	TInt myAllocdSize = myHeap->AllocLen(ptrMy1)+RHeap::EAllocCellSize;
   821 	TInt myReduce=RHeapCalcReduce(oldMyHeapSize-myAllocdSize,1);
   801 	TInt myReduce=RHeapCalcReduce(oldMyHeapSize-myAllocdSize,1);
   822 	oldMyHeapSize -= myReduce;
   802 	oldMyHeapSize -= myReduce;
   823 	test(r==oldMyHeapSize);
   803 	test(r==oldMyHeapSize);
   824 
   804 
   825 	r=normHeap->Count();
   805 	r=normHeap->Count();
   882 		test(last!=NULL);
   862 		test(last!=NULL);
   883 		// Check that the last allocation doesn't pass the end of the chunk
   863 		// Check that the last allocation doesn't pass the end of the chunk
   884 		test(last+space <= chunk.Base()+size);
   864 		test(last+space <= chunk.Base()+size);
   885 		// but that it is within the alignment requirement, as less than this
   865 		// but that it is within the alignment requirement, as less than this
   886 		// would be short of the end
   866 		// would be short of the end
       
   867 		test(last+space > chunk.Base()+size-RHeap::ECellAlignment);
   887 		}
   868 		}
   888 	else
   869 	else
   889 		{
   870 		{
   890 		test(last+1024 == chunk.Base()+size);
   871 		test(last+1024 == chunk.Base()+size);
   891 		}
   872 		}
  1143 	{
  1124 	{
  1144 
  1125 
  1145 	test.Start(_L("Create chunk to"));
  1126 	test.Start(_L("Create chunk to"));
  1146 	TPtrC autoHeap=_L("AutoHeap");
  1127 	TPtrC autoHeap=_L("AutoHeap");
  1147 	gHeapPtr=User::ChunkHeap(&autoHeap,0x1800,0x6000);
  1128 	gHeapPtr=User::ChunkHeap(&autoHeap,0x1800,0x6000);
  1148 	
       
  1149 	test(gHeapPtr!=NULL);
  1129 	test(gHeapPtr!=NULL);
  1150 	TInt biggest;
  1130 	TInt biggest;
  1151 	TInt avail=gHeapPtr->Available(biggest);
  1131 	TInt avail=gHeapPtr->Available(biggest);
  1152 	test(avail==biggest);
  1132 	test(avail==biggest);
  1153 	TAny *p1=gHeapPtr->Alloc(biggest);
  1133 	TAny *p1=gHeapPtr->Alloc(biggest);
  1178 	gHeapPtr->Free(p1);
  1158 	gHeapPtr->Free(p1);
  1179 	comp=gHeapPtr->Compress();
  1159 	comp=gHeapPtr->Compress();
  1180 	test(comp==0);
  1160 	test(comp==0);
  1181 	TInt biggest1;
  1161 	TInt biggest1;
  1182 	TInt avail1=gHeapPtr->Available(biggest1);
  1162 	TInt avail1=gHeapPtr->Available(biggest1);
  1183 	test(avail==avail1);
  1163 	test(avail1==avail1);
  1184 	test(biggest==biggest1);
  1164 	test(biggest==biggest1);
  1185 	test(gHeapPtr->Count()==0);
  1165 	test(gHeapPtr->Count()==0);
  1186 	gHeapPtr->Close();
  1166 	gHeapPtr->Close();
  1187 	test.End();
  1167 	test.End();
  1188 	}
  1168 	}
  1189 
  1169 
  1190 LOCAL_C TInt NormalChunk(RChunk& aChunk, TInt aInitialSize, TInt aMaxSize)
       
  1191     {
       
  1192     TChunkCreateInfo createInfo;
       
  1193     createInfo.SetNormal(aInitialSize, aMaxSize);
       
  1194     TInt r=aChunk.Create(createInfo);
       
  1195     return r;
       
  1196     }    
       
  1197 
       
  1198 LOCAL_C TInt DisconnectedChunk(RChunk& aChunk, TInt aInitialBottom, TInt aInitialTop, TInt aMaxSize)
       
  1199     {
       
  1200     TChunkCreateInfo createInfo;
       
  1201     createInfo.SetDisconnected(aInitialBottom, aInitialTop, aMaxSize);
       
  1202     TInt r=aChunk.Create(createInfo);
       
  1203     return r;  
       
  1204     }
       
  1205 
       
  1206 LOCAL_C TBool TestIsHybridHeap(RHeap* aHeap)
       
  1207     {
       
  1208     RHybridHeap::STestCommand cmd;
       
  1209     cmd.iCommand = RHybridHeap::EHeapMetaData;
       
  1210     aHeap->DebugFunction(RHeap::EHybridHeap, (TAny*)&cmd, 0);
       
  1211                
       
  1212     RHybridHeap* hybridHeap = (RHybridHeap*) cmd.iData;
       
  1213     return (TestHybridHeap::IsHybrid(hybridHeap));  
       
  1214     }
       
  1215 
       
  1216 LOCAL_C void TestHeapType()
       
  1217     {
       
  1218     TBool onlyDL = EFalse;
       
  1219     _LIT(KHeap, "NamedHeap");
       
  1220     // 1: Create a heap in a local chunk
       
  1221     RHeap* heap;
       
  1222     heap = UserHeap::ChunkHeap(NULL,0x100,0x2000);
       
  1223     TBool hybrid = TestIsHybridHeap(heap);
       
  1224     if (hybrid==0)
       
  1225         {
       
  1226         test.Printf(_L("Only DL allocator is in use \n"));
       
  1227         onlyDL = ETrue;;
       
  1228         }
       
  1229     else
       
  1230         test(hybrid==1); 
       
  1231     heap->Close();
       
  1232     
       
  1233     // 2: Create a heap in a global chunk
       
  1234     heap = UserHeap::ChunkHeap(&KHeap,0,0x1800,0x6000);
       
  1235     hybrid = TestIsHybridHeap(heap);
       
  1236     if(!onlyDL)
       
  1237         test(hybrid==1); 
       
  1238     heap->Close();
       
  1239     
       
  1240     // 3: Create a heap in an existing normal chunk
       
  1241     RChunk chunk;
       
  1242     TInt r = NormalChunk(chunk,0,0x1000);
       
  1243     heap = UserHeap::ChunkHeap(chunk,0);
       
  1244     hybrid = TestIsHybridHeap(heap);
       
  1245     test(hybrid==0);
       
  1246     heap->Close();
       
  1247                    
       
  1248     // 4: Create a heap in an existing disconnected chunk
       
  1249     // when offset = 0.  Minimum heap size for a hybrid heap is 12KB
       
  1250     r = DisconnectedChunk(chunk,0,0,0x3000);
       
  1251     heap = UserHeap::ChunkHeap(chunk,0);
       
  1252     hybrid = TestIsHybridHeap(heap);
       
  1253     if(!onlyDL)
       
  1254         test(hybrid==1);
       
  1255     heap->Close();
       
  1256         
       
  1257     // 5: Create a heap in an existing disconnected chunk
       
  1258     // when offset > 0
       
  1259     r = DisconnectedChunk(chunk,0,0x1800,0x6000); 
       
  1260     heap = UserHeap::OffsetChunkHeap(chunk,0,0x2800);
       
  1261     hybrid = TestIsHybridHeap(heap);
       
  1262     test(hybrid==0);
       
  1263     heap->Close();
       
  1264     
       
  1265     // 6: Create a fixed length heap at a normal chunk's base address 
       
  1266     r = NormalChunk(chunk,0x1000,0x1000);
       
  1267     heap = UserHeap::FixedHeap(chunk.Base(), 0x1000);
       
  1268     hybrid = TestIsHybridHeap(heap);
       
  1269     test(hybrid==0);
       
  1270     heap->Close();
       
  1271     chunk.Close();
       
  1272     
       
  1273     // 7: Create a fixed length heap at a disconnected chunk's base address
       
  1274     // when bottom = 0
       
  1275     r = DisconnectedChunk(chunk,0,0x2000,0x2000); 
       
  1276     heap = UserHeap::FixedHeap(chunk.Base(), 0x2000);
       
  1277     hybrid = TestIsHybridHeap(heap);
       
  1278     test(hybrid==0);
       
  1279     heap->Close();
       
  1280     chunk.Close();
       
  1281         
       
  1282     // 8: Create a fixed length heap at a disconnected chunk's base address
       
  1283     // when bottom > 0
       
  1284     r = DisconnectedChunk(chunk,0x6000,0x7000,0x13000); 
       
  1285     heap = UserHeap::FixedHeap(chunk.Base()+ 0x6000, 0x1000); 
       
  1286     hybrid = TestIsHybridHeap(heap);
       
  1287     test(hybrid==0);
       
  1288     heap->Close();
       
  1289     chunk.Close();
       
  1290     
       
  1291     // 9: Create a fixed length heap for allocated buffer
       
  1292     heap = UserHeap::ChunkHeap(&KNullDesC(), 4096, (4096 * 1024));
       
  1293     test(heap != NULL);
       
  1294     TAny* buffer = heap->Alloc(1024 * 1024);    
       
  1295     test(buffer != NULL);
       
  1296     TInt lth = heap->AllocLen(buffer);
       
  1297     test.Printf(_L("Fixed heap buffer: %x, length: %x \n"), buffer, lth);  
       
  1298 
       
  1299     RHeap* heapf = UserHeap::FixedHeap(buffer, (1024 * 1024));
       
  1300     test(heapf != NULL);
       
  1301     test.Printf(_L("Fixed heap: %x \n"), heapf);
       
  1302     hybrid = TestIsHybridHeap(heapf);
       
  1303     test(hybrid==0);
       
  1304 
       
  1305     heapf->Close();
       
  1306     heap->Free(buffer);
       
  1307 
       
  1308     heap->Close();
       
  1309     }
       
  1310 
  1170 
  1311 GLDEF_C TInt E32Main(void)
  1171 GLDEF_C TInt E32Main(void)
  1312 	{
  1172 	{
  1313 
  1173 
  1314 	test.Title();
  1174 	test.Title();
  1316 	__KHEAP_MARK;
  1176 	__KHEAP_MARK;
  1317 
  1177 
  1318 	test.Start(_L("Test 1"));
  1178 	test.Start(_L("Test 1"));
  1319 	UserHal::PageSizeInBytes(PageSize);
  1179 	UserHal::PageSizeInBytes(PageSize);
  1320         TestRHeap T;
  1180         TestRHeap T;
  1321 
       
  1322 	T.Test1();
  1181 	T.Test1();
  1323 	test.Next(_L("Test auto expand and compress"));
  1182 	test.Next(_L("Test auto expand and compress"));
  1324 	TestAuto();
  1183 	TestAuto();
  1325 	test.Next(_L("Test 2"));
  1184 	test.Next(_L("Test 2"));
  1326 	T.Test2();
  1185 	T.Test2();
  1343 	test.Next(_L("Shared heap test 2"));
  1202 	test.Next(_L("Shared heap test 2"));
  1344 	SharedHeapTest2();
  1203 	SharedHeapTest2();
  1345 	test.Next(_L("Shared heap test 3"));
  1204 	test.Next(_L("Shared heap test 3"));
  1346 	SharedHeapTest3();
  1205 	SharedHeapTest3();
  1347 	sem.Close();
  1206 	sem.Close();
  1348 	test.Next(_L("Test HeapType()"));    
       
  1349 	TestHeapType();
       
  1350 
  1207 
  1351 	__KHEAP_CHECK(0);
  1208 	__KHEAP_CHECK(0);
  1352 	__KHEAP_MARKEND;
  1209 	__KHEAP_MARKEND;
  1353 
  1210 //
  1354 	test.End();
  1211 	test.End();
  1355 	return(0);
  1212 	return(0);
  1356     }
  1213     }
  1357 
  1214