diff -r a179b74831c9 -r c1f20ce4abcf kerneltest/e32test/defrag/t_ramdefrag.cpp --- a/kerneltest/e32test/defrag/t_ramdefrag.cpp Thu Aug 19 11:14:22 2010 +0300 +++ b/kerneltest/e32test/defrag/t_ramdefrag.cpp Tue Aug 31 16:34:26 2010 +0300 @@ -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; @@ -7078,16 +7091,20 @@ //! @SYMPREQ PREQ308 //! @SYMTestPriority High //! @SYMTestActions -//! 1. Allocate fixed pages and call function to free all fixed pages allocated. +//! 1. Allocate fixed pages and call function to free all fixed pages allocated. +//! 2. Claim a RAM zone and then free it via Epoc::FreeRamZone(). +//! 3. Invoke Epoc::FreeRamZone() with an invalid RAM zone ID. //! //! @SYMTestExpectedResults //! 1. KErrNone +//! 2. KErrNone +//! 3. KErrArgument //--------------------------------------------------------------------------------------------------------------------- TInt TestFreeZone() { TInt r = 0; TUint zoneID = 0; - test.Start(_L("Test1: Free allocated pages")); + test.Start(_L("Test1: Freeing allocated pages")); TestStart(); TInt pages = 50; @@ -7133,7 +7150,58 @@ } } TestEnd(); - + test.End(); + + test.Start(_L("Test2: Epoc::FreeRamZone() on a claimed RAM zone")); + TestStart(); + GetAllPageInfo(); + TUint zoneIndex = 0; + while (zoneIndex < gZoneCount) + { + if (gZoneUtilArray[zoneIndex].iFreePages == gZoneUtilArray[zoneIndex].iPhysPages) + break; + zoneIndex++; + } + if (zoneIndex >= gZoneCount) + { + test.Printf(_L("Cannot find zone to perform test, Skipping test step...\n")); + goto Test2End; + } + zoneID = gZoneConfigArray[zoneIndex].iZoneId; + r = Ldd.CallDefrag(DEFRAG_TYPE_CLAIM, DEFRAG_VER_SYNC, zoneID); + if (r != KErrNone) + { + test.Printf(_L("Fail: r = %d, expected = %d\n"), r, KErrNone); + TEST_FAIL; + } + GetAllPageInfo(); + if (gZoneUtilArray[zoneIndex].iPhysPages != gZoneUtilArray[zoneIndex].iAllocFixed) + { + test.Printf(_L("Fail: RAM zone ID %d not claimed successfully"), zoneID); + TEST_FAIL; + } + r = Ldd.FreeZoneId(zoneID); + GetAllPageInfo(); + if (r != KErrNone || + gZoneUtilArray[zoneIndex].iPhysPages != gZoneUtilArray[zoneIndex].iFreePages) + { + test.Printf(_L("Fail: RAM zone ID %d not freed successfully r=%d"), zoneID, r); + TEST_FAIL; + } +Test2End: + TestEnd(); + test.End(); + + test.Start(_L("Test2: Epoc::FreeRamZone() on an invalid RAM zone")); + TestStart(); + r = Ldd.FreeZoneId(KInvalidZoneID); + if (r != KErrArgument) + { + test.Printf(_L("Fail: Error RAM zone ID %d r=%d"), KInvalidZoneID, r); + TEST_FAIL; + } + + TestEnd(); test.End(); return KErrNone; }