kerneltest/e32test/defrag/t_ramdefrag.cpp
branchRCL_3
changeset 256 c1f20ce4abcf
parent 117 5b5d147c7838
child 257 3e88ff8f41d5
equal deleted inserted replaced
249:a179b74831c9 256:c1f20ce4abcf
   541 	gTestStarted = ETrue;
   541 	gTestStarted = ETrue;
   542 
   542 
   543 	Ldd.ResetDriver();
   543 	Ldd.ResetDriver();
   544 	
   544 	
   545 	Ldd.CallDefrag(DEFRAG_TYPE_GEN, DEFRAG_VER_SYNC);
   545 	Ldd.CallDefrag(DEFRAG_TYPE_GEN, DEFRAG_VER_SYNC);
   546 	if (VerifyMovDisAlloc() != KErrNone)
   546 	TInt r;
       
   547 	r = VerifyMovDisAlloc();
       
   548 	if (r == KErrGeneral)
       
   549 		{
       
   550 		// A rare set of circumstances may cause some of the movable pages to be in
       
   551 		// use during the defrag and thus not be moved to the correct RAM zone. Run
       
   552 		// the defrag once more to give it a chance to move these pages. We ensure
       
   553 		// that there is no pending asynchronous clean up operation before doing so.
       
   554 		UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, 0, 0);
       
   555 		Ldd.CallDefrag(DEFRAG_TYPE_GEN, DEFRAG_VER_SYNC);
       
   556 		r = VerifyMovDisAlloc();
       
   557 		}
       
   558 
       
   559 	if (r != KErrNone)
   547 		{
   560 		{
   548 		CLEANUP(;);
   561 		CLEANUP(;);
   549 		TEST_FAIL;
   562 		TEST_FAIL;
   550 		}
   563 		}
   551 	
   564 	
  7076 //! @SYMTestType				CIT
  7089 //! @SYMTestType				CIT
  7077 //! @SYMTestCaseDesc			Verifying the function Epoc::FreePhysicalRam()
  7090 //! @SYMTestCaseDesc			Verifying the function Epoc::FreePhysicalRam()
  7078 //! @SYMPREQ					PREQ308
  7091 //! @SYMPREQ					PREQ308
  7079 //! @SYMTestPriority			High
  7092 //! @SYMTestPriority			High
  7080 //! @SYMTestActions				
  7093 //! @SYMTestActions				
  7081 //! 	1.	Allocate fixed pages and call function to free all fixed pages allocated.  
  7094 //! 	1.	Allocate fixed pages and call function to free all fixed pages allocated.
       
  7095 //!		2.	Claim a RAM zone and then free it via Epoc::FreeRamZone().
       
  7096 //!		3.	Invoke Epoc::FreeRamZone() with an invalid RAM zone ID.
  7082 //! 
  7097 //! 
  7083 //! @SYMTestExpectedResults
  7098 //! @SYMTestExpectedResults
  7084 //! 	1.	KErrNone
  7099 //! 	1.	KErrNone
       
  7100 //!		2.	KErrNone
       
  7101 //!		3.	KErrArgument
  7085 //---------------------------------------------------------------------------------------------------------------------
  7102 //---------------------------------------------------------------------------------------------------------------------
  7086 TInt TestFreeZone()
  7103 TInt TestFreeZone()
  7087 	{
  7104 	{
  7088 	TInt r = 0;
  7105 	TInt r = 0;
  7089 	TUint zoneID = 0;
  7106 	TUint zoneID = 0;
  7090 	test.Start(_L("Test1: Free allocated pages"));	
  7107 	test.Start(_L("Test1: Freeing allocated pages"));	
  7091 	TestStart();	
  7108 	TestStart();	
  7092 	
  7109 	
  7093 	TInt pages = 50;
  7110 	TInt pages = 50;
  7094 
  7111 
  7095 	GetAllPageInfo();
  7112 	GetAllPageInfo();
  7131 			test.Printf(_L("Fail: r = %d, expected = %d\n"), r, KErrNone);
  7148 			test.Printf(_L("Fail: r = %d, expected = %d\n"), r, KErrNone);
  7132 			TEST_FAIL;
  7149 			TEST_FAIL;
  7133 			}
  7150 			}
  7134 		}
  7151 		}
  7135 	TestEnd();
  7152 	TestEnd();
  7136 
  7153 	test.End();
       
  7154 
       
  7155 	test.Start(_L("Test2: Epoc::FreeRamZone() on a claimed RAM zone"));
       
  7156 	TestStart();
       
  7157 	GetAllPageInfo();
       
  7158 	TUint zoneIndex = 0;
       
  7159 	while (zoneIndex < gZoneCount)
       
  7160 		{
       
  7161 		if (gZoneUtilArray[zoneIndex].iFreePages == gZoneUtilArray[zoneIndex].iPhysPages)
       
  7162 			break;
       
  7163 		zoneIndex++;
       
  7164 		}
       
  7165 	if (zoneIndex >= gZoneCount)
       
  7166 		{
       
  7167 		test.Printf(_L("Cannot find zone to perform test, Skipping test step...\n"));
       
  7168 		goto Test2End;
       
  7169 		}
       
  7170 	zoneID = gZoneConfigArray[zoneIndex].iZoneId;
       
  7171 	r = Ldd.CallDefrag(DEFRAG_TYPE_CLAIM, DEFRAG_VER_SYNC, zoneID);
       
  7172 	if (r != KErrNone)
       
  7173 		{
       
  7174 		test.Printf(_L("Fail: r = %d, expected = %d\n"), r, KErrNone);
       
  7175 		TEST_FAIL;
       
  7176 		}
       
  7177 	GetAllPageInfo();
       
  7178 	if (gZoneUtilArray[zoneIndex].iPhysPages != gZoneUtilArray[zoneIndex].iAllocFixed)
       
  7179 		{
       
  7180 		test.Printf(_L("Fail: RAM zone ID %d not claimed successfully"), zoneID);
       
  7181 		TEST_FAIL;
       
  7182 		}
       
  7183 	r = Ldd.FreeZoneId(zoneID);
       
  7184 	GetAllPageInfo();
       
  7185 	if (r != KErrNone ||
       
  7186 		gZoneUtilArray[zoneIndex].iPhysPages != gZoneUtilArray[zoneIndex].iFreePages)
       
  7187 		{
       
  7188 		test.Printf(_L("Fail: RAM zone ID %d not freed successfully r=%d"), zoneID, r);
       
  7189 		TEST_FAIL;
       
  7190 		}
       
  7191 Test2End:
       
  7192 	TestEnd();
       
  7193 	test.End();
       
  7194 
       
  7195 	test.Start(_L("Test2: Epoc::FreeRamZone() on an invalid RAM zone"));
       
  7196 	TestStart();
       
  7197 	r = Ldd.FreeZoneId(KInvalidZoneID);
       
  7198 	if (r != KErrArgument)
       
  7199 		{
       
  7200 		test.Printf(_L("Fail: Error RAM zone ID %d r=%d"), KInvalidZoneID, r);
       
  7201 		TEST_FAIL;
       
  7202 		}
       
  7203 	
       
  7204 	TestEnd();
  7137 	test.End();
  7205 	test.End();
  7138 	return KErrNone;
  7206 	return KErrNone;
  7139 	}
  7207 	}
  7140 
  7208 
  7141 
  7209