sl@0
|
1 |
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// e32test\defrag\t_defrag_ref.cpp
|
sl@0
|
15 |
// Overview:
|
sl@0
|
16 |
// Test application that uses the reference defragmantation driver to invoke
|
sl@0
|
17 |
// the top-level defragmentation operations.
|
sl@0
|
18 |
// API Information:
|
sl@0
|
19 |
// RBusLogicalChannel
|
sl@0
|
20 |
// Details:
|
sl@0
|
21 |
// - Load and open the logical device driver ("D_DEFRAG_REF.LDD"). Verify
|
sl@0
|
22 |
// results.
|
sl@0
|
23 |
// - Request that the driver attempt to trigger various defragmentation
|
sl@0
|
24 |
// operations. Verify that they complete successfully.
|
sl@0
|
25 |
// Platforms/Drives/Compatibility:
|
sl@0
|
26 |
// Hardware only. No defrag support on emulator.
|
sl@0
|
27 |
// Assumptions/Requirement/Pre-requisites:
|
sl@0
|
28 |
// Failures and causes:
|
sl@0
|
29 |
// Base Port information:
|
sl@0
|
30 |
//
|
sl@0
|
31 |
//
|
sl@0
|
32 |
|
sl@0
|
33 |
#define __E32TEST_EXTENSION__
|
sl@0
|
34 |
#include <e32test.h>
|
sl@0
|
35 |
#include "d_defrag_ref.h"
|
sl@0
|
36 |
#include "..\..\mmu\mmudetect.h"
|
sl@0
|
37 |
|
sl@0
|
38 |
LOCAL_D RTest test(_L("T_DEFRAG_REF"));
|
sl@0
|
39 |
|
sl@0
|
40 |
const TPtrC KLddFileName=_L("d_defrag_ref.ldd");
|
sl@0
|
41 |
|
sl@0
|
42 |
GLDEF_C TInt E32Main()
|
sl@0
|
43 |
{
|
sl@0
|
44 |
test.Title();
|
sl@0
|
45 |
if (!HaveMMU())
|
sl@0
|
46 |
{
|
sl@0
|
47 |
test.Printf(_L("This test requires an MMU\n"));
|
sl@0
|
48 |
return KErrNone;
|
sl@0
|
49 |
}
|
sl@0
|
50 |
|
sl@0
|
51 |
test.Start(_L("Load test LDD"));
|
sl@0
|
52 |
TInt r=User::LoadLogicalDevice(KLddFileName);
|
sl@0
|
53 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
54 |
|
sl@0
|
55 |
RDefragChannel defrag;
|
sl@0
|
56 |
TRequestStatus req;
|
sl@0
|
57 |
test.Next(_L("Open test LDD"));
|
sl@0
|
58 |
r = defrag.Open();
|
sl@0
|
59 |
if (r == KErrNotSupported)
|
sl@0
|
60 |
{// This system has no defrag support so can't continue
|
sl@0
|
61 |
goto exit;
|
sl@0
|
62 |
}
|
sl@0
|
63 |
test_KErrNone(r);
|
sl@0
|
64 |
|
sl@0
|
65 |
test.Next(_L("Test calls to GeneralDefragRam DFC"));
|
sl@0
|
66 |
test_KErrNone(defrag.GeneralDefragDfc(&req));
|
sl@0
|
67 |
|
sl@0
|
68 |
test.Next(_L("Only one defrag operation can be active per channel"));
|
sl@0
|
69 |
test_Equal(KErrInUse, defrag.GeneralDefrag());
|
sl@0
|
70 |
|
sl@0
|
71 |
test.Next(_L("Wait for defrag request to complete"));
|
sl@0
|
72 |
User::WaitForRequest(req);
|
sl@0
|
73 |
test_KErrNone(defrag.GeneralDefragDfcComplete());
|
sl@0
|
74 |
|
sl@0
|
75 |
test.Next(_L("Test calls to GeneralDefragRam"));
|
sl@0
|
76 |
test_KErrNone(defrag.GeneralDefrag());
|
sl@0
|
77 |
|
sl@0
|
78 |
test.Next(_L("Test calls to GeneralDefragRamSem"));
|
sl@0
|
79 |
test_KErrNone(defrag.GeneralDefragSem());
|
sl@0
|
80 |
|
sl@0
|
81 |
test.Next(_L("Test allocating into the least preferable zone"));
|
sl@0
|
82 |
r = defrag.AllocLowestZone();
|
sl@0
|
83 |
test(r == KErrNone || r == KErrNoMemory);
|
sl@0
|
84 |
if (r == KErrNone)
|
sl@0
|
85 |
{
|
sl@0
|
86 |
test.Next(_L("Test closing the chunk mapped to the least preferable zone"));
|
sl@0
|
87 |
test_KErrNone(defrag.CloseChunk());
|
sl@0
|
88 |
}
|
sl@0
|
89 |
|
sl@0
|
90 |
test.Next(_L("Test claiming the least preferable zone"));
|
sl@0
|
91 |
r = defrag.ClaimLowestZone();
|
sl@0
|
92 |
test(r == KErrNone || r == KErrNoMemory);
|
sl@0
|
93 |
if (r == KErrNone)
|
sl@0
|
94 |
{
|
sl@0
|
95 |
test.Next(_L("Test closing the chunk mapped to the least preferable zone"));
|
sl@0
|
96 |
test_KErrNone(defrag.CloseChunk());
|
sl@0
|
97 |
}
|
sl@0
|
98 |
|
sl@0
|
99 |
exit:
|
sl@0
|
100 |
test.Next(_L("Close test LDD"));
|
sl@0
|
101 |
defrag.Close();
|
sl@0
|
102 |
User::FreeLogicalDevice(KLddFileName);
|
sl@0
|
103 |
|
sl@0
|
104 |
test.End();
|
sl@0
|
105 |
return(KErrNone);
|
sl@0
|
106 |
}
|