kerneltest/e32test/defrag/t_ramdefrag.cpp
changeset 243 c7a0ce20c48c
parent 176 af6ec97d9189
--- a/kerneltest/e32test/defrag/t_ramdefrag.cpp	Mon Jul 26 10:52:56 2010 +0100
+++ b/kerneltest/e32test/defrag/t_ramdefrag.cpp	Fri Aug 06 16:34:38 2010 +0100
@@ -543,7 +543,20 @@
 	Ldd.ResetDriver();
 	
 	Ldd.CallDefrag(DEFRAG_TYPE_GEN, DEFRAG_VER_SYNC);
-	if (VerifyMovDisAlloc() != KErrNone)
+	TInt r;
+	r = VerifyMovDisAlloc();
+	if (r == KErrGeneral)
+		{
+		// A rare set of circumstances may cause some of the movable pages to be in
+		// use during the defrag and thus not be moved to the correct RAM zone. Run
+		// the defrag once more to give it a chance to move these pages. We ensure
+		// that there is no pending asynchronous clean up operation before doing so.
+		UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, 0, 0);
+		Ldd.CallDefrag(DEFRAG_TYPE_GEN, DEFRAG_VER_SYNC);
+		r = VerifyMovDisAlloc();
+		}
+
+	if (r != KErrNone)
 		{
 		CLEANUP(;);
 		TEST_FAIL;