kerneltest/e32test/heap/t_heap.cpp
changeset 109 b3a1d9898418
parent 90 947f0dc9f7a8
child 257 3e88ff8f41d5
equal deleted inserted replaced
102:ef2a444a7410 109:b3a1d9898418
    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"
    69 
    73 
    70 // Sets data for Test6
    74 // Sets data for Test6
    71 #define SetData(size)	pHeap->Reset();\
    75 #define SetData(size)	pHeap->Reset();\
    72 						Cell1=pHeap->Alloc(size);\
    76 						Cell1=pHeap->Alloc(size);\
    73 						Cell2=pHeap->Alloc(size);\
    77 						Cell2=pHeap->Alloc(size);\
    88 #else
    92 #else
    89     const TInt KHeapMinCellSize = 0;
    93     const TInt KHeapMinCellSize = 0;
    90 #endif
    94 #endif
    91 
    95 
    92 const TInt KHeadSize = (TInt)RHeap::EAllocCellSize;
    96 const TInt KHeadSize = (TInt)RHeap::EAllocCellSize;
    93 const TInt KAlign = _FOFF(RHeap::_s_align, d);
    97 
       
    98 const TInt KAlign = RHeap::ECellAlignment;
    94 const TInt KMinCellLength = _ALIGN_UP((KHeapMinCellSize + Max(TInt(RHeap::EFreeCellSize),TInt(RHeap::EAllocCellSize))),KAlign) - RHeap::EAllocCellSize;
    99 const TInt KMinCellLength = _ALIGN_UP((KHeapMinCellSize + Max(TInt(RHeap::EFreeCellSize),TInt(RHeap::EAllocCellSize))),KAlign) - RHeap::EAllocCellSize;
    95 const TInt KMinFreeSize = _ALIGN_UP((KHeapMinCellSize + Max(TInt(RHeap::EFreeCellSize),TInt(RHeap::EAllocCellSize))),KAlign);
   100 const TInt KMinFreeSize = _ALIGN_UP((KHeapMinCellSize + Max(TInt(RHeap::EFreeCellSize),TInt(RHeap::EAllocCellSize))),KAlign);
    96 
   101 
    97 TInt PageSize;
   102 TInt PageSize;
    98 
   103 
   106 	{
   111 	{
   107 	TUint				iMinLength;
   112 	TUint				iMinLength;
   108 	RChunk				iChunk;
   113 	RChunk				iChunk;
   109 	TUint8				*iBase;
   114 	TUint8				*iBase;
   110 	TUint8				*iTop;
   115 	TUint8				*iTop;
   111 	RHeap::SCell		iFree;
   116 	//RHeap::SCell		iFree;
   112 	};
   117 	};
   113 
   118 
   114 #pragma warning ( disable :4705 ) // statement has no effect
   119 #pragma warning ( disable :4705 ) // statement has no effect
   115 RHeapDump OrigDump;
   120 RHeapDump OrigDump;
   116 #pragma warning ( default :4705 )
   121 #pragma warning ( default :4705 )
   117 
   122 
   118 #if defined(_DEBUG)
   123 #if defined(_DEBUG)
   119 void RTestHeap::__DbgTest(void* aPtr) const
   124 void RTestHeap::__DbgTest(void* aPtr) const
   120 	{
   125 	{
       
   126 	(void) aPtr;
       
   127 /*	
   121 	RHeapDump& d = *(RHeapDump*)aPtr;
   128 	RHeapDump& d = *(RHeapDump*)aPtr;
   122 	d.iMinLength=iMinLength;
   129 	d.iMinLength=iMinLength;
   123 	d.iChunk.SetHandle(iChunkHandle);
   130 	d.iChunk.SetHandle(iChunkHandle);
   124 	d.iBase=iBase;
   131 	d.iBase=iBase;
   125 	d.iTop=iTop;
   132 	d.iTop=iTop;
   126 	d.iFree=iFree;
   133 	d.iFree=iFree;
       
   134 */	
   127 	}
   135 	}
   128 #endif
   136 #endif
   129 
   137 
   130 
   138 
   131 #if defined(_DEBUG)
   139 #if defined(_DEBUG)
   132 TBool Invariant(RHeap* aHeap)
   140 TBool Invariant(RHeap* aHeap)
   133 	{
   141 	{
       
   142 	(void) aHeap;
       
   143 /*	
   134 	RHeapDump dump;
   144 	RHeapDump dump;
   135 	((RTestHeap*)aHeap)->__DbgTest(&dump);
   145 	((RTestHeap*)aHeap)->__DbgTest(&dump);
   136 	if(dump.iMinLength!=OrigDump.iMinLength) 		return(EFalse);
   146 	if(dump.iMinLength!=OrigDump.iMinLength) 		return(EFalse);
   137 	// Note: iChunk is a class
   147 	// Note: iChunk is a class
   138 	if(dump.iBase!=OrigDump.iBase)			return(EFalse);
   148 	if(dump.iBase!=OrigDump.iBase)			return(EFalse);
   139 	if(*dump.iBase!=*OrigDump.iBase)		return(EFalse);
   149 	if(*dump.iBase!=*OrigDump.iBase)		return(EFalse);
   140 	if(dump.iTop!=OrigDump.iTop)			return(EFalse);
   150 	if(dump.iTop!=OrigDump.iTop)			return(EFalse);
   141 	if(dump.iTop[-1]!=OrigDump.iTop[-1])	return(EFalse);	
   151 	if(dump.iTop[-1]!=OrigDump.iTop[-1])	return(EFalse);	
   142 	if(dump.iFree.len!=OrigDump.iFree.len)	return(EFalse);
   152 	if(dump.iFree.len!=OrigDump.iFree.len)	return(EFalse);
   143 	// iFree.Next changes during allocation/freeing etc.
   153 	// iFree.Next changes during allocation/freeing etc.
       
   154 */
   144 	return(ETrue);
   155 	return(ETrue);
   145 	}
   156 	}
   146 #define INV(x) x;
   157 #define INV(x) x;
   147 #else
   158 #else
   148 #define INV(x)
   159 #define INV(x)
   150 
   161 
   151 LOCAL_D RTest test(_L("T_HEAP"));
   162 LOCAL_D RTest test(_L("T_HEAP"));
   152 LOCAL_D TInt heapCount=1;
   163 LOCAL_D TInt heapCount=1;
   153 LOCAL_D RHeap *gHeapPtr;
   164 LOCAL_D RHeap *gHeapPtr;
   154 LOCAL_D RHeap *gHeapPtr2;
   165 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   }
   155 
   183 
   156 class TestRHeap
   184 class TestRHeap
   157 	{
   185 	{
   158 public:
   186 public:
   159 	void Test1(void);
   187 	void Test1(void);
   214 	RHeapDump dump;
   242 	RHeapDump dump;
   215 	RHeap* pHeap=allocHeap(3000);
   243 	RHeap* pHeap=allocHeap(3000);
   216 
   244 
   217 	((RTestHeap*)pHeap)->__DbgTest(&OrigDump);
   245 	((RTestHeap*)pHeap)->__DbgTest(&OrigDump);
   218 	((RTestHeap*)pHeap)->__DbgTest(&dump);
   246 	((RTestHeap*)pHeap)->__DbgTest(&dump);
   219 	test(dump.iBase==pHeap->Base());
   247 	
   220 	test((dump.iTop-dump.iBase)==pHeap->Size());
   248 //	test(dump.iBase==pHeap->Base());
       
   249 //	test((dump.iTop-dump.iBase)==pHeap->Size());
   221 	pHeap->Check();
   250 	pHeap->Check();
   222 	test(Invariant(pHeap));
   251 	test(Invariant(pHeap));
   223 	pHeap->Close();
   252 	pHeap->Close();
   224 #endif
   253 #endif
   225 	}
   254 	}
   508 	CellSize=pHeap->AllocLen(aCell);  // test?
   537 	CellSize=pHeap->AllocLen(aCell);  // test?
   509 
   538 
   510 	// Resize positively
   539 	// Resize positively
   511 	for(TInt aSize=0; aSize<=BiggestBlock; aSize++, pHeap->Available(BiggestBlock))
   540 	for(TInt aSize=0; aSize<=BiggestBlock; aSize++, pHeap->Available(BiggestBlock))
   512 		{
   541 		{
   513 		test(pHeap->ReAlloc(aCell, aSize)!=NULL); 
   542 		aCell = pHeap->ReAlloc(aCell, aSize); 
       
   543 		test(aCell!=NULL); 
   514 		CellSize=pHeap->AllocLen(aCell);
   544 		CellSize=pHeap->AllocLen(aCell);
   515 		test(CellSize>=aSize);
   545 		test(CellSize>=aSize);
   516 		if (aSize<KMinCellLength)
       
   517 			test(CellSize==KMinCellLength);
       
   518 		else
       
   519 			test(CellSize<aSize+KAlign);
       
   520 		}
   546 		}
   521 
   547 
   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   
       
   540 	pHeap->Check();
   548 	pHeap->Check();
   541 	pHeap->Reset();
   549 	pHeap->Reset();
   542 	// Allocate a block, fill with data, allocate another block or two then resize the original
   550 	// Allocate a block, fill with data, allocate another block or two then resize the original
   543 	// block such that it has to be moved in memory, then check the blocks' contents 
   551 	// block such that it has to be moved in memory, then check the blocks' contents 
   544 	TAny* Cell1=pHeap->Alloc(16);
   552 	TAny* Cell1=pHeap->Alloc(16);
   736 	TPtrC myHeapName=_L("MyHeap");
   744 	TPtrC myHeapName=_L("MyHeap");
   737 	// myHeap will have default GrowBy of KMinHeapGrowBy
   745 	// myHeap will have default GrowBy of KMinHeapGrowBy
   738 	RMyHeap* myHeap=(RMyHeap*)User::ChunkHeap(&myHeapName,0x100,0x2000);
   746 	RMyHeap* myHeap=(RMyHeap*)User::ChunkHeap(&myHeapName,0x100,0x2000);
   739 const TInt KnormHeapGrowBy = 0x2000;
   747 const TInt KnormHeapGrowBy = 0x2000;
   740 	RHeap* normHeap=User::ChunkHeap(NULL,0x100,0x20000,KnormHeapGrowBy);
   748 	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 		}
   741 
   761 
   742 	TAny* ptrMy1=myHeap->Alloc(0x102);
   762 	TAny* ptrMy1=myHeap->Alloc(0x102);
   743 	test(ptrMy1!=NULL);
   763 	test(ptrMy1!=NULL);
   744 	TAny* ptrMy2=myHeap->Alloc(0x1001);
   764 	TAny* ptrMy2=myHeap->Alloc(0x1001);
   745 	test(ptrMy2!=NULL);
   765 	test(ptrMy2!=NULL);
   782 	r=normHeap->Size();
   802 	r=normHeap->Size();
   783 
   803 
   784 	// Calc the amount, if any, the overall size of normHeap will have been shrunk by
   804 	// Calc the amount, if any, the overall size of normHeap will have been shrunk by
   785 	// will depend on value of KHeapShrinkHysRatio.
   805 	// will depend on value of KHeapShrinkHysRatio.
   786 	// 1st calc current total size of the allocated cells
   806 	// 1st calc current total size of the allocated cells
   787 	TInt normAllocdSize = 	normHeap->AllocLen(ptrNorm1)+RHeap::EAllocCellSize +
   807 	TInt normAllocdSize = 	normHeap->AllocLen(ptrNorm1)+KHeadSize +
   788 							normHeap->AllocLen(ptrNorm2)+RHeap::EAllocCellSize;
   808 							normHeap->AllocLen(ptrNorm2)+KHeadSize;
   789 	TInt normReduce = RHeapCalcReduce(oldNormHeapSize-normAllocdSize,KnormHeapGrowBy);
   809 	TInt normReduce = RHeapCalcReduce(oldNormHeapSize-normAllocdSize,KnormHeapGrowBy);
   790 	oldNormHeapSize -= normReduce;
   810 	oldNormHeapSize -= normReduce;
   791 	test(r==oldNormHeapSize);
   811 	test(r==oldNormHeapSize);
   792 
   812 
   793 	normHeap->Free(ptrNorm2);
   813 	normHeap->Free(ptrNorm2);
   795 	r=myHeap->Count();
   815 	r=myHeap->Count();
   796 	test(r==1);
   816 	test(r==1);
   797 	r=myHeap->Size();
   817 	r=myHeap->Size();
   798 
   818 
   799 	// Calc the current total size of the allocated cells
   819 	// Calc the current total size of the allocated cells
   800 	TInt myAllocdSize = myHeap->AllocLen(ptrMy1)+RHeap::EAllocCellSize;
   820 	TInt myAllocdSize = myHeap->AllocLen(ptrMy1)+KHeadSize;
   801 	TInt myReduce=RHeapCalcReduce(oldMyHeapSize-myAllocdSize,1);
   821 	TInt myReduce=RHeapCalcReduce(oldMyHeapSize-myAllocdSize,1);
   802 	oldMyHeapSize -= myReduce;
   822 	oldMyHeapSize -= myReduce;
   803 	test(r==oldMyHeapSize);
   823 	test(r==oldMyHeapSize);
   804 
   824 
   805 	r=normHeap->Count();
   825 	r=normHeap->Count();
   862 		test(last!=NULL);
   882 		test(last!=NULL);
   863 		// Check that the last allocation doesn't pass the end of the chunk
   883 		// Check that the last allocation doesn't pass the end of the chunk
   864 		test(last+space <= chunk.Base()+size);
   884 		test(last+space <= chunk.Base()+size);
   865 		// but that it is within the alignment requirement, as less than this
   885 		// but that it is within the alignment requirement, as less than this
   866 		// would be short of the end
   886 		// would be short of the end
   867 		test(last+space > chunk.Base()+size-RHeap::ECellAlignment);
       
   868 		}
   887 		}
   869 	else
   888 	else
   870 		{
   889 		{
   871 		test(last+1024 == chunk.Base()+size);
   890 		test(last+1024 == chunk.Base()+size);
   872 		}
   891 		}
  1124 	{
  1143 	{
  1125 
  1144 
  1126 	test.Start(_L("Create chunk to"));
  1145 	test.Start(_L("Create chunk to"));
  1127 	TPtrC autoHeap=_L("AutoHeap");
  1146 	TPtrC autoHeap=_L("AutoHeap");
  1128 	gHeapPtr=User::ChunkHeap(&autoHeap,0x1800,0x6000);
  1147 	gHeapPtr=User::ChunkHeap(&autoHeap,0x1800,0x6000);
       
  1148 	
  1129 	test(gHeapPtr!=NULL);
  1149 	test(gHeapPtr!=NULL);
  1130 	TInt biggest;
  1150 	TInt biggest;
  1131 	TInt avail=gHeapPtr->Available(biggest);
  1151 	TInt avail=gHeapPtr->Available(biggest);
  1132 	test(avail==biggest);
  1152 	test(avail==biggest);
  1133 	TAny *p1=gHeapPtr->Alloc(biggest);
  1153 	TAny *p1=gHeapPtr->Alloc(biggest);
  1158 	gHeapPtr->Free(p1);
  1178 	gHeapPtr->Free(p1);
  1159 	comp=gHeapPtr->Compress();
  1179 	comp=gHeapPtr->Compress();
  1160 	test(comp==0);
  1180 	test(comp==0);
  1161 	TInt biggest1;
  1181 	TInt biggest1;
  1162 	TInt avail1=gHeapPtr->Available(biggest1);
  1182 	TInt avail1=gHeapPtr->Available(biggest1);
  1163 	test(avail1==avail1);
  1183 	test(avail==avail1);
  1164 	test(biggest==biggest1);
  1184 	test(biggest==biggest1);
  1165 	test(gHeapPtr->Count()==0);
  1185 	test(gHeapPtr->Count()==0);
  1166 	gHeapPtr->Close();
  1186 	gHeapPtr->Close();
  1167 	test.End();
  1187 	test.End();
  1168 	}
  1188 	}
  1169 
  1189 
       
  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     }
  1170 
  1310 
  1171 GLDEF_C TInt E32Main(void)
  1311 GLDEF_C TInt E32Main(void)
  1172 	{
  1312 	{
  1173 
  1313 
  1174 	test.Title();
  1314 	test.Title();
  1176 	__KHEAP_MARK;
  1316 	__KHEAP_MARK;
  1177 
  1317 
  1178 	test.Start(_L("Test 1"));
  1318 	test.Start(_L("Test 1"));
  1179 	UserHal::PageSizeInBytes(PageSize);
  1319 	UserHal::PageSizeInBytes(PageSize);
  1180         TestRHeap T;
  1320         TestRHeap T;
       
  1321 
  1181 	T.Test1();
  1322 	T.Test1();
  1182 	test.Next(_L("Test auto expand and compress"));
  1323 	test.Next(_L("Test auto expand and compress"));
  1183 	TestAuto();
  1324 	TestAuto();
  1184 	test.Next(_L("Test 2"));
  1325 	test.Next(_L("Test 2"));
  1185 	T.Test2();
  1326 	T.Test2();
  1202 	test.Next(_L("Shared heap test 2"));
  1343 	test.Next(_L("Shared heap test 2"));
  1203 	SharedHeapTest2();
  1344 	SharedHeapTest2();
  1204 	test.Next(_L("Shared heap test 3"));
  1345 	test.Next(_L("Shared heap test 3"));
  1205 	SharedHeapTest3();
  1346 	SharedHeapTest3();
  1206 	sem.Close();
  1347 	sem.Close();
       
  1348 	test.Next(_L("Test HeapType()"));    
       
  1349 	TestHeapType();
  1207 
  1350 
  1208 	__KHEAP_CHECK(0);
  1351 	__KHEAP_CHECK(0);
  1209 	__KHEAP_MARKEND;
  1352 	__KHEAP_MARKEND;
  1210 //
  1353 
  1211 	test.End();
  1354 	test.End();
  1212 	return(0);
  1355 	return(0);
  1213     }
  1356     }
  1214 
  1357