|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // e32test\defrag\t_defrag_ref.cpp |
|
15 // Overview: |
|
16 // Test application that uses the reference defragmantation driver to invoke |
|
17 // the top-level defragmentation operations. |
|
18 // API Information: |
|
19 // RBusLogicalChannel |
|
20 // Details: |
|
21 // - Load and open the logical device driver ("D_DEFRAG_REF.LDD"). Verify |
|
22 // results. |
|
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: |
|
30 // |
|
31 // |
|
32 |
|
33 #define __E32TEST_EXTENSION__ |
|
34 #include <e32test.h> |
|
35 #include "d_defrag_ref.h" |
|
36 #include "..\..\mmu\mmudetect.h" |
|
37 |
|
38 LOCAL_D RTest test(_L("T_DEFRAG_REF")); |
|
39 |
|
40 const TPtrC KLddFileName=_L("d_defrag_ref.ldd"); |
|
41 |
|
42 GLDEF_C TInt E32Main() |
|
43 { |
|
44 test.Title(); |
|
45 if (!HaveMMU()) |
|
46 { |
|
47 test.Printf(_L("This test requires an MMU\n")); |
|
48 return KErrNone; |
|
49 } |
|
50 |
|
51 test.Start(_L("Load test LDD")); |
|
52 TInt r=User::LoadLogicalDevice(KLddFileName); |
|
53 test(r==KErrNone || r==KErrAlreadyExists); |
|
54 |
|
55 RDefragChannel defrag; |
|
56 TRequestStatus req; |
|
57 test.Next(_L("Open test LDD")); |
|
58 r = defrag.Open(); |
|
59 if (r == KErrNotSupported) |
|
60 {// This system has no defrag support so can't continue |
|
61 goto exit; |
|
62 } |
|
63 test_KErrNone(r); |
|
64 |
|
65 test.Next(_L("Test calls to GeneralDefragRam DFC")); |
|
66 test_KErrNone(defrag.GeneralDefragDfc(&req)); |
|
67 |
|
68 test.Next(_L("Only one defrag operation can be active per channel")); |
|
69 test_Equal(KErrInUse, defrag.GeneralDefrag()); |
|
70 |
|
71 test.Next(_L("Wait for defrag request to complete")); |
|
72 User::WaitForRequest(req); |
|
73 test_KErrNone(defrag.GeneralDefragDfcComplete()); |
|
74 |
|
75 test.Next(_L("Test calls to GeneralDefragRam")); |
|
76 test_KErrNone(defrag.GeneralDefrag()); |
|
77 |
|
78 test.Next(_L("Test calls to GeneralDefragRamSem")); |
|
79 test_KErrNone(defrag.GeneralDefragSem()); |
|
80 |
|
81 test.Next(_L("Test allocating into the least preferable zone")); |
|
82 r = defrag.AllocLowestZone(); |
|
83 test(r == KErrNone || r == KErrNoMemory); |
|
84 if (r == KErrNone) |
|
85 { |
|
86 test.Next(_L("Test closing the chunk mapped to the least preferable zone")); |
|
87 test_KErrNone(defrag.CloseChunk()); |
|
88 } |
|
89 |
|
90 test.Next(_L("Test claiming the least preferable zone")); |
|
91 r = defrag.ClaimLowestZone(); |
|
92 test(r == KErrNone || r == KErrNoMemory); |
|
93 if (r == KErrNone) |
|
94 { |
|
95 test.Next(_L("Test closing the chunk mapped to the least preferable zone")); |
|
96 test_KErrNone(defrag.CloseChunk()); |
|
97 } |
|
98 |
|
99 exit: |
|
100 test.Next(_L("Close test LDD")); |
|
101 defrag.Close(); |
|
102 User::FreeLogicalDevice(KLddFileName); |
|
103 |
|
104 test.End(); |
|
105 return(KErrNone); |
|
106 } |