First public contribution.
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\defrag\t_defrag_ref.cpp
16 // Test application that uses the reference defragmantation driver to invoke
17 // the top-level defragmentation operations.
21 // - Load and open the logical device driver ("D_DEFRAG_REF.LDD"). Verify
23 // - Request that the driver attempt to trigger various defragmentation
24 // operations. Verify that they complete successfully.
25 // Platforms/Drives/Compatibility:
26 // Hardware only. No defrag support on emulator.
27 // Assumptions/Requirement/Pre-requisites:
28 // Failures and causes:
29 // Base Port information:
33 #define __E32TEST_EXTENSION__
35 #include "d_defrag_ref.h"
36 #include "..\..\mmu\mmudetect.h"
38 LOCAL_D RTest test(_L("T_DEFRAG_REF"));
40 const TPtrC KLddFileName=_L("d_defrag_ref.ldd");
42 GLDEF_C TInt E32Main()
47 test.Printf(_L("This test requires an MMU\n"));
51 test.Start(_L("Load test LDD"));
52 TInt r=User::LoadLogicalDevice(KLddFileName);
53 test(r==KErrNone || r==KErrAlreadyExists);
55 RDefragChannel defrag;
57 test.Next(_L("Open test LDD"));
59 if (r == KErrNotSupported)
60 {// This system has no defrag support so can't continue
65 test.Next(_L("Test calls to GeneralDefragRam DFC"));
66 test_KErrNone(defrag.GeneralDefragDfc(&req));
68 test.Next(_L("Only one defrag operation can be active per channel"));
69 test_Equal(KErrInUse, defrag.GeneralDefrag());
71 test.Next(_L("Wait for defrag request to complete"));
72 User::WaitForRequest(req);
73 test_KErrNone(defrag.GeneralDefragDfcComplete());
75 test.Next(_L("Test calls to GeneralDefragRam"));
76 test_KErrNone(defrag.GeneralDefrag());
78 test.Next(_L("Test calls to GeneralDefragRamSem"));
79 test_KErrNone(defrag.GeneralDefragSem());
81 test.Next(_L("Test allocating into the least preferable zone"));
82 r = defrag.AllocLowestZone();
83 test(r == KErrNone || r == KErrNoMemory);
86 test.Next(_L("Test closing the chunk mapped to the least preferable zone"));
87 test_KErrNone(defrag.CloseChunk());
90 test.Next(_L("Test claiming the least preferable zone"));
91 r = defrag.ClaimLowestZone();
92 test(r == KErrNone || r == KErrNoMemory);
95 test.Next(_L("Test closing the chunk mapped to the least preferable zone"));
96 test_KErrNone(defrag.CloseChunk());
100 test.Next(_L("Close test LDD"));
102 User::FreeLogicalDevice(KLddFileName);