kerneltest/e32test/defrag/t_ramdefrag.cpp
changeset 102 ef2a444a7410
parent 90 947f0dc9f7a8
child 152 657f875b013e
equal deleted inserted replaced
90:947f0dc9f7a8 102:ef2a444a7410
  7071 //! @SYMTestType				CIT
  7071 //! @SYMTestType				CIT
  7072 //! @SYMTestCaseDesc			Verifying the function Epoc::FreePhysicalRam()
  7072 //! @SYMTestCaseDesc			Verifying the function Epoc::FreePhysicalRam()
  7073 //! @SYMPREQ					PREQ308
  7073 //! @SYMPREQ					PREQ308
  7074 //! @SYMTestPriority			High
  7074 //! @SYMTestPriority			High
  7075 //! @SYMTestActions				
  7075 //! @SYMTestActions				
  7076 //! 	1.	Allocate fixed pages and call function to free all fixed pages allocated.  
  7076 //! 	1.	Allocate fixed pages and call function to free all fixed pages allocated.
       
  7077 //!		2.	Claim a RAM zone and then free it via Epoc::FreeRamZone().
       
  7078 //!		3.	Invoke Epoc::FreeRamZone() with an invalid RAM zone ID.
  7077 //! 
  7079 //! 
  7078 //! @SYMTestExpectedResults
  7080 //! @SYMTestExpectedResults
  7079 //! 	1.	KErrNone
  7081 //! 	1.	KErrNone
       
  7082 //!		2.	KErrNone
       
  7083 //!		3.	KErrArgument
  7080 //---------------------------------------------------------------------------------------------------------------------
  7084 //---------------------------------------------------------------------------------------------------------------------
  7081 TInt TestFreeZone()
  7085 TInt TestFreeZone()
  7082 	{
  7086 	{
  7083 	TInt r = 0;
  7087 	TInt r = 0;
  7084 	TUint zoneID = 0;
  7088 	TUint zoneID = 0;
  7085 	test.Start(_L("Test1: Free allocated pages"));	
  7089 	test.Start(_L("Test1: Freeing allocated pages"));	
  7086 	TestStart();	
  7090 	TestStart();	
  7087 	
  7091 	
  7088 	TInt pages = 50;
  7092 	TInt pages = 50;
  7089 
  7093 
  7090 	GetAllPageInfo();
  7094 	GetAllPageInfo();
  7126 			test.Printf(_L("Fail: r = %d, expected = %d\n"), r, KErrNone);
  7130 			test.Printf(_L("Fail: r = %d, expected = %d\n"), r, KErrNone);
  7127 			TEST_FAIL;
  7131 			TEST_FAIL;
  7128 			}
  7132 			}
  7129 		}
  7133 		}
  7130 	TestEnd();
  7134 	TestEnd();
  7131 
  7135 	test.End();
       
  7136 
       
  7137 	test.Start(_L("Test2: Epoc::FreeRamZone() on a claimed RAM zone"));
       
  7138 	TestStart();
       
  7139 	GetAllPageInfo();
       
  7140 	TUint zoneIndex = 0;
       
  7141 	while (zoneIndex < gZoneCount)
       
  7142 		{
       
  7143 		if (gZoneUtilArray[zoneIndex].iFreePages == gZoneUtilArray[zoneIndex].iPhysPages)
       
  7144 			break;
       
  7145 		zoneIndex++;
       
  7146 		}
       
  7147 	if (zoneIndex >= gZoneCount)
       
  7148 		{
       
  7149 		test.Printf(_L("Cannot find zone to perform test, Skipping test step...\n"));
       
  7150 		goto Test2End;
       
  7151 		}
       
  7152 	zoneID = gZoneConfigArray[zoneIndex].iZoneId;
       
  7153 	r = Ldd.CallDefrag(DEFRAG_TYPE_CLAIM, DEFRAG_VER_SYNC, zoneID);
       
  7154 	if (r != KErrNone)
       
  7155 		{
       
  7156 		test.Printf(_L("Fail: r = %d, expected = %d\n"), r, KErrNone);
       
  7157 		TEST_FAIL;
       
  7158 		}
       
  7159 	GetAllPageInfo();
       
  7160 	if (gZoneUtilArray[zoneIndex].iPhysPages != gZoneUtilArray[zoneIndex].iAllocFixed)
       
  7161 		{
       
  7162 		test.Printf(_L("Fail: RAM zone ID %d not claimed successfully"), zoneID);
       
  7163 		TEST_FAIL;
       
  7164 		}
       
  7165 	r = Ldd.FreeZoneId(zoneID);
       
  7166 	GetAllPageInfo();
       
  7167 	if (r != KErrNone ||
       
  7168 		gZoneUtilArray[zoneIndex].iPhysPages != gZoneUtilArray[zoneIndex].iFreePages)
       
  7169 		{
       
  7170 		test.Printf(_L("Fail: RAM zone ID %d not freed successfully r=%d"), zoneID, r);
       
  7171 		TEST_FAIL;
       
  7172 		}
       
  7173 Test2End:
       
  7174 	TestEnd();
       
  7175 	test.End();
       
  7176 
       
  7177 	test.Start(_L("Test2: Epoc::FreeRamZone() on an invalid RAM zone"));
       
  7178 	TestStart();
       
  7179 	r = Ldd.FreeZoneId(KInvalidZoneID);
       
  7180 	if (r != KErrArgument)
       
  7181 		{
       
  7182 		test.Printf(_L("Fail: Error RAM zone ID %d r=%d"), KInvalidZoneID, r);
       
  7183 		TEST_FAIL;
       
  7184 		}
       
  7185 	
       
  7186 	TestEnd();
  7132 	test.End();
  7187 	test.End();
  7133 	return KErrNone;
  7188 	return KErrNone;
  7134 	}
  7189 	}
  7135 
  7190 
  7136 
  7191