author | Mike Kinghan <mikek@symbian.org> |
Sun, 18 Jul 2010 10:20:49 +0100 | |
branch | GCC_SURGE |
changeset 206 | ced41fd9a298 |
parent 33 | 0173bcd7697c |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 2008-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 |
// f32test\demandpaging\t_paginginfo.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#include <e32test.h> |
|
19 |
||
20 |
RTest test(_L("t_paginginfo")); |
|
21 |
||
22 |
#include <e32rom.h> |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
23 |
#include <e32svr.h> |
0 | 24 |
#include <u32hal.h> |
25 |
#include <f32file.h> |
|
26 |
#include <f32dbg.h> |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
27 |
#include <d32locd.h> |
0 | 28 |
#include "testdefs.h" |
29 |
#include <hal.h> |
|
30 |
||
31 |
||
32 |
TInt DriveNumber=-1; // Parameter - Which drive? -1 = autodetect. |
|
33 |
TInt locDriveNumber; |
|
34 |
||
35 |
TBusLocalDrive Drive; |
|
36 |
TBool DisplayStats = ETrue; |
|
37 |
TBool ManualTest = EFalse; |
|
38 |
||
39 |
TInt findDataPagingDrive() |
|
40 |
/** |
|
41 |
Find the drive containing a swap partition. |
|
42 |
||
43 |
@return Local drive identifier. |
|
44 |
*/ |
|
45 |
{ |
|
46 |
TInt drive = KErrNotFound; |
|
47 |
||
48 |
test.Printf(_L("Searching for data paging drive:\n")); |
|
49 |
||
50 |
for(TInt i = 0; i < KMaxLocalDrives && drive < 0; ++i) |
|
51 |
{ |
|
52 |
RLocalDrive d; |
|
53 |
TBool change = EFalse; |
|
54 |
||
55 |
if(d.Connect(i, change) == KErrNone) |
|
56 |
{ |
|
57 |
test.Printf(_L("Connected to local drive %d\n"), i); |
|
58 |
TLocalDriveCapsV4 dc; |
|
59 |
TPckg<TLocalDriveCapsV4> capsPack(dc); |
|
60 |
||
61 |
if(d.Caps(capsPack) == KErrNone) |
|
62 |
{ |
|
63 |
if ((dc.iMediaAtt & KMediaAttPageable) && |
|
64 |
(dc.iPartitionType == KPartitionTypePagedData)) |
|
65 |
{ |
|
66 |
test.Printf(_L("Found swap partition on local drive %d\n"), i); |
|
67 |
drive = i; |
|
68 |
||
69 |
TPageDeviceInfo pageDeviceInfo; |
|
70 |
||
71 |
TPtr8 pageDeviceInfoBuf((TUint8*) &pageDeviceInfo, sizeof(pageDeviceInfo)); |
|
72 |
pageDeviceInfoBuf.FillZ(); |
|
73 |
||
74 |
TInt r = d.QueryDevice(RLocalDrive::EQueryPageDeviceInfo, pageDeviceInfoBuf); |
|
75 |
||
76 |
test.Printf(_L("EQueryPageDeviceInfo on local drive %d returned %d\n"), i, r); |
|
77 |
} |
|
78 |
} |
|
79 |
d.Close(); |
|
80 |
} |
|
81 |
} |
|
82 |
return drive; |
|
83 |
} |
|
84 |
||
85 |
||
86 |
||
87 |
void DisplayPageDeviceInfo(TInt aDataPagingDrive) |
|
88 |
{ |
|
89 |
test.Printf(_L("Stats: \n")); |
|
90 |
||
91 |
SMediaPagingInfo info; |
|
92 |
TInt r = UserSvr::HalFunction(EHalGroupMedia,EMediaHalGetPagingInfo,(TAny*) aDataPagingDrive, &info); |
|
93 |
test.Printf(_L("HAL: EMediaHalGetPagingInfo returned %d\n"), r); |
|
94 |
if (r == KErrNone) |
|
95 |
{ |
|
96 |
test.Printf(_L("iRomPageInCount %d\n"), info.iRomPageInCount); |
|
97 |
test.Printf(_L("iCodePageInCount %d\n"), info.iCodePageInCount); |
|
98 |
test.Printf(_L("iDataPageInCount %d\n"), info.iDataPageInCount); |
|
99 |
test.Printf(_L("iDataPageOutCount %d\n"), info.iDataPageOutCount); |
|
100 |
test.Printf(_L("iDataPageOutBackgroundCount %d\n"), info.iDataPageOutBackgroundCount); |
|
101 |
} |
|
102 |
||
103 |
||
104 |
RLocalDrive d; |
|
105 |
TBool change = EFalse; |
|
106 |
r = d.Connect(aDataPagingDrive, change); |
|
107 |
test (r == KErrNone); |
|
108 |
||
109 |
TPageDeviceInfo pageDeviceInfo; |
|
110 |
TPtr8 pageDeviceInfoBuf((TUint8*) &pageDeviceInfo, sizeof(pageDeviceInfo)); |
|
111 |
pageDeviceInfoBuf.FillZ(); |
|
112 |
r = d.QueryDevice(RLocalDrive::EQueryPageDeviceInfo, pageDeviceInfoBuf); |
|
113 |
test (r == KErrNone || r == KErrNotSupported); |
|
114 |
||
115 |
d.Close(); |
|
116 |
test.Printf(_L("iReservoirBlockCount %d\n"), pageDeviceInfo.iReservoirBlockCount); |
|
117 |
test.Printf(_L("iBadBlockCount %d\n"), pageDeviceInfo.iBadBlockCount); |
|
118 |
||
119 |
} |
|
120 |
||
121 |
// |
|
122 |
// The gubbins that starts all the tests |
|
123 |
// |
|
124 |
// ParseCommandLine reads the arguments and sets globals accordingly. |
|
125 |
// |
|
126 |
||
127 |
void ParseCommandLine() |
|
128 |
{ |
|
129 |
TBuf<32> args; |
|
130 |
User::CommandLine(args); |
|
131 |
TLex lex(args); |
|
132 |
||
133 |
FOREVER |
|
134 |
{ |
|
135 |
||
136 |
TPtrC token=lex.NextToken(); |
|
137 |
if(token.Length()!=0) |
|
138 |
{ |
|
139 |
if ((token.Length()==2) && (token[1]==':')) |
|
140 |
DriveNumber=User::UpperCase(token[0])-'A'; |
|
141 |
else if (token.Length()==1) |
|
142 |
{ |
|
143 |
TChar driveLetter = User::UpperCase(token[0]); |
|
144 |
if ((driveLetter>='A') && (driveLetter<='Z')) |
|
145 |
DriveNumber=driveLetter - (TChar) 'A'; |
|
146 |
else |
|
147 |
test.Printf(_L("Unknown argument '%S' was ignored.\n"), &token); |
|
148 |
} |
|
149 |
else if ((token==_L("help")) || (token==_L("-h")) || (token==_L("-?"))) |
|
150 |
{ |
|
151 |
test.Printf(_L("\nUsage: t_paginginfo [enable] [disable] [stats]\n\n")); |
|
152 |
test.Getch(); |
|
153 |
} |
|
154 |
else if (token==_L("stats")) |
|
155 |
{ |
|
156 |
DisplayStats = ETrue; |
|
157 |
} |
|
158 |
else if (token==_L("-m")) |
|
159 |
{ |
|
160 |
ManualTest = ETrue; |
|
161 |
} |
|
162 |
else |
|
163 |
test.Printf(_L("Unknown argument '%S' was ignored.\n"), &token); |
|
164 |
} |
|
165 |
else |
|
166 |
break; |
|
167 |
||
168 |
} |
|
169 |
} |
|
170 |
||
171 |
// |
|
172 |
// E32Main |
|
173 |
// |
|
174 |
||
175 |
TInt E32Main() |
|
176 |
{ |
|
177 |
test.Title(); |
|
178 |
||
179 |
test.Start(_L("Check that the rom is paged")); |
|
180 |
||
181 |
TRomHeader* romHeader = (TRomHeader*)UserSvr::RomHeaderAddress(); |
|
182 |
||
183 |
if (romHeader->iPageableRomStart==NULL) |
|
184 |
{ |
|
185 |
test.Printf(_L("Test ROM is not paged - test skipped!\r\n")); |
|
186 |
test.End(); |
|
187 |
return 0; |
|
188 |
} |
|
189 |
ParseCommandLine(); |
|
190 |
||
191 |
TInt dataPagingDrive = findDataPagingDrive(); |
|
192 |
if (dataPagingDrive == KErrNotFound) |
|
193 |
{ |
|
194 |
test.Printf(_L("Swap partition not found - test skipped!\r\n")); |
|
195 |
test.End(); |
|
196 |
return 0; |
|
197 |
} |
|
198 |
||
199 |
||
200 |
||
201 |
if (DisplayStats) |
|
202 |
{ |
|
203 |
DisplayPageDeviceInfo(dataPagingDrive); |
|
204 |
||
205 |
if (ManualTest) |
|
206 |
test.Getch(); |
|
207 |
||
208 |
test.End(); |
|
209 |
return 0; |
|
210 |
} |
|
211 |
||
212 |
||
213 |
||
214 |
test.End(); |
|
215 |
return 0; |
|
216 |
} |
|
217 |
||
218 |