sl@0
|
1 |
// Copyright (c) 2008-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\demandpaging\t_dpapi.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
//
|
sl@0
|
19 |
#define __E32TEST_EXTENSION__
|
sl@0
|
20 |
#include <e32test.h>
|
sl@0
|
21 |
#include <dptest.h>
|
sl@0
|
22 |
#include <e32hal.h>
|
sl@0
|
23 |
#include <u32exec.h>
|
sl@0
|
24 |
#include <e32svr.h>
|
sl@0
|
25 |
#include <e32panic.h>
|
sl@0
|
26 |
#include "u32std.h"
|
sl@0
|
27 |
|
sl@0
|
28 |
#include "t_dpcmn.h"
|
sl@0
|
29 |
|
sl@0
|
30 |
RTest test(_L("T_DPAPI"));
|
sl@0
|
31 |
|
sl@0
|
32 |
TInt TestingTChunkCreate();
|
sl@0
|
33 |
TInt TestingTChunkHeapCreate();
|
sl@0
|
34 |
TInt TestingTThreadCreate();
|
sl@0
|
35 |
|
sl@0
|
36 |
void TestGlobalConfig()
|
sl@0
|
37 |
{
|
sl@0
|
38 |
test_Equal(gDataPagingSupported, gDataPagingPolicy != EKernelConfigDataPagingPolicyNoPaging);
|
sl@0
|
39 |
}
|
sl@0
|
40 |
|
sl@0
|
41 |
enum TPagedSetting
|
sl@0
|
42 |
{
|
sl@0
|
43 |
EDefault,
|
sl@0
|
44 |
EPaged,
|
sl@0
|
45 |
EUnpaged
|
sl@0
|
46 |
};
|
sl@0
|
47 |
|
sl@0
|
48 |
TPagedSetting GetMmpPagedSetting()
|
sl@0
|
49 |
{
|
sl@0
|
50 |
// t_dpapi suffixes:
|
sl@0
|
51 |
// c => ram loaded code
|
sl@0
|
52 |
// p => pageddata
|
sl@0
|
53 |
// u => unpageddata
|
sl@0
|
54 |
|
sl@0
|
55 |
TFileName name = RProcess().FileName();
|
sl@0
|
56 |
test.Printf(_L("%S\n"), &name);
|
sl@0
|
57 |
TInt pos = name.LocateReverse('\\');
|
sl@0
|
58 |
test(pos >= 0 && pos < (name.Length() - 1));
|
sl@0
|
59 |
TPtrC leaf = name.Mid(pos + 1);
|
sl@0
|
60 |
if (leaf == _L("t_dpapi_p.exe") || leaf == _L("t_dpapi_cp.exe"))
|
sl@0
|
61 |
return EPaged;
|
sl@0
|
62 |
else if (leaf == _L("t_dpapi_u.exe") || leaf == _L("t_dpapi_cu.exe"))
|
sl@0
|
63 |
return EUnpaged;
|
sl@0
|
64 |
test(leaf == _L("t_dpapi.exe") || leaf == _L("t_dpapi_c.exe"));
|
sl@0
|
65 |
return EDefault;
|
sl@0
|
66 |
}
|
sl@0
|
67 |
|
sl@0
|
68 |
TPagedSetting ExpectedProcessPagedSetting(TPagedSetting aMmpPagedSetting)
|
sl@0
|
69 |
{
|
sl@0
|
70 |
switch (gDataPagingPolicy)
|
sl@0
|
71 |
{
|
sl@0
|
72 |
case EKernelConfigDataPagingPolicyAlwaysPage:
|
sl@0
|
73 |
return EPaged;
|
sl@0
|
74 |
|
sl@0
|
75 |
case EKernelConfigDataPagingPolicyNoPaging:
|
sl@0
|
76 |
return EUnpaged;
|
sl@0
|
77 |
|
sl@0
|
78 |
case EKernelConfigDataPagingPolicyDefaultUnpaged:
|
sl@0
|
79 |
return aMmpPagedSetting == EDefault ? EUnpaged : aMmpPagedSetting;
|
sl@0
|
80 |
|
sl@0
|
81 |
case EKernelConfigDataPagingPolicyDefaultPaged:
|
sl@0
|
82 |
return aMmpPagedSetting == EDefault ? EPaged : aMmpPagedSetting;
|
sl@0
|
83 |
|
sl@0
|
84 |
default:
|
sl@0
|
85 |
test(EFalse);
|
sl@0
|
86 |
}
|
sl@0
|
87 |
return EDefault;
|
sl@0
|
88 |
}
|
sl@0
|
89 |
|
sl@0
|
90 |
void TestMmpFileDataPagedKeyword()
|
sl@0
|
91 |
{
|
sl@0
|
92 |
TPagedSetting expected = ExpectedProcessPagedSetting(GetMmpPagedSetting());
|
sl@0
|
93 |
TPagedSetting actual = gProcessPaged ? EPaged : EUnpaged;
|
sl@0
|
94 |
test_Equal(expected, actual);
|
sl@0
|
95 |
}
|
sl@0
|
96 |
|
sl@0
|
97 |
TInt E32Main()
|
sl@0
|
98 |
{
|
sl@0
|
99 |
test.Title();
|
sl@0
|
100 |
test_KErrNone(GetGlobalPolicies());
|
sl@0
|
101 |
|
sl@0
|
102 |
test.Start(_L("Test global datapaging configuration"));
|
sl@0
|
103 |
TestGlobalConfig();
|
sl@0
|
104 |
|
sl@0
|
105 |
test.Next(_L("Test mmp file data paged keyword"));
|
sl@0
|
106 |
TestMmpFileDataPagedKeyword();
|
sl@0
|
107 |
|
sl@0
|
108 |
test.Next(_L("TestingTChunkCreate"));
|
sl@0
|
109 |
TestingTChunkCreate();
|
sl@0
|
110 |
|
sl@0
|
111 |
test.Next(_L("TestingTThreadCreate"));
|
sl@0
|
112 |
TestingTThreadCreate();
|
sl@0
|
113 |
|
sl@0
|
114 |
test.Next(_L("TestingTChunkHeapCreate"));
|
sl@0
|
115 |
TestingTChunkHeapCreate();
|
sl@0
|
116 |
|
sl@0
|
117 |
test.End();
|
sl@0
|
118 |
return 0;
|
sl@0
|
119 |
}
|