sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test\defrag\t_defrag_ref.cpp sl@0: // Overview: sl@0: // Test application that uses the reference defragmantation driver to invoke sl@0: // the top-level defragmentation operations. sl@0: // API Information: sl@0: // RBusLogicalChannel sl@0: // Details: sl@0: // - Load and open the logical device driver ("D_DEFRAG_REF.LDD"). Verify sl@0: // results. sl@0: // - Request that the driver attempt to trigger various defragmentation sl@0: // operations. Verify that they complete successfully. sl@0: // Platforms/Drives/Compatibility: sl@0: // Hardware only. No defrag support on emulator. sl@0: // Assumptions/Requirement/Pre-requisites: sl@0: // Failures and causes: sl@0: // Base Port information: sl@0: // sl@0: // sl@0: sl@0: #define __E32TEST_EXTENSION__ sl@0: #include sl@0: #include "d_defrag_ref.h" sl@0: #include "..\..\mmu\mmudetect.h" sl@0: sl@0: LOCAL_D RTest test(_L("T_DEFRAG_REF")); sl@0: sl@0: const TPtrC KLddFileName=_L("d_defrag_ref.ldd"); sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: { sl@0: test.Title(); sl@0: if (!HaveMMU()) sl@0: { sl@0: test.Printf(_L("This test requires an MMU\n")); sl@0: return KErrNone; sl@0: } sl@0: sl@0: test.Start(_L("Load test LDD")); sl@0: TInt r=User::LoadLogicalDevice(KLddFileName); sl@0: test(r==KErrNone || r==KErrAlreadyExists); sl@0: sl@0: RDefragChannel defrag; sl@0: TRequestStatus req; sl@0: test.Next(_L("Open test LDD")); sl@0: r = defrag.Open(); sl@0: if (r == KErrNotSupported) sl@0: {// This system has no defrag support so can't continue sl@0: goto exit; sl@0: } sl@0: test_KErrNone(r); sl@0: sl@0: test.Next(_L("Test calls to GeneralDefragRam DFC")); sl@0: test_KErrNone(defrag.GeneralDefragDfc(&req)); sl@0: sl@0: test.Next(_L("Only one defrag operation can be active per channel")); sl@0: test_Equal(KErrInUse, defrag.GeneralDefrag()); sl@0: sl@0: test.Next(_L("Wait for defrag request to complete")); sl@0: User::WaitForRequest(req); sl@0: test_KErrNone(defrag.GeneralDefragDfcComplete()); sl@0: sl@0: test.Next(_L("Test calls to GeneralDefragRam")); sl@0: test_KErrNone(defrag.GeneralDefrag()); sl@0: sl@0: test.Next(_L("Test calls to GeneralDefragRamSem")); sl@0: test_KErrNone(defrag.GeneralDefragSem()); sl@0: sl@0: test.Next(_L("Test allocating into the least preferable zone")); sl@0: r = defrag.AllocLowestZone(); sl@0: test(r == KErrNone || r == KErrNoMemory); sl@0: if (r == KErrNone) sl@0: { sl@0: test.Next(_L("Test closing the chunk mapped to the least preferable zone")); sl@0: test_KErrNone(defrag.CloseChunk()); sl@0: } sl@0: sl@0: test.Next(_L("Test claiming the least preferable zone")); sl@0: r = defrag.ClaimLowestZone(); sl@0: test(r == KErrNone || r == KErrNoMemory); sl@0: if (r == KErrNone) sl@0: { sl@0: test.Next(_L("Test closing the chunk mapped to the least preferable zone")); sl@0: test_KErrNone(defrag.CloseChunk()); sl@0: } sl@0: sl@0: exit: sl@0: test.Next(_L("Close test LDD")); sl@0: defrag.Close(); sl@0: User::FreeLogicalDevice(KLddFileName); sl@0: sl@0: test.End(); sl@0: return(KErrNone); sl@0: }