sl@0
|
1 |
// Copyright (c) 1996-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 |
// f32test\bench\t_fsrvbm.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <f32file.h>
|
sl@0
|
19 |
#include <e32test.h>
|
sl@0
|
20 |
#include "t_select.h"
|
sl@0
|
21 |
#include "../server/t_server.h"
|
sl@0
|
22 |
|
sl@0
|
23 |
GLDEF_D RTest test(_L("File Server Benchmarks"));
|
sl@0
|
24 |
|
sl@0
|
25 |
LOCAL_D RSemaphore client;
|
sl@0
|
26 |
LOCAL_D TInt speedCount;
|
sl@0
|
27 |
LOCAL_D const TInt KHeapSize=0x2000;
|
sl@0
|
28 |
LOCAL_D TBuf8<4096> buf;
|
sl@0
|
29 |
//
|
sl@0
|
30 |
LOCAL_D TDriveList gDriveList;
|
sl@0
|
31 |
//
|
sl@0
|
32 |
LOCAL_D TInt gLocalDrive;
|
sl@0
|
33 |
LOCAL_D TInt gLocalDriveReadSize;
|
sl@0
|
34 |
LOCAL_D TInt gLocalDriveWriteSize;
|
sl@0
|
35 |
//
|
sl@0
|
36 |
LOCAL_D TFileName gFindEntryDir;
|
sl@0
|
37 |
LOCAL_D TInt gFindEntrySearchStart;
|
sl@0
|
38 |
LOCAL_D TInt gFindEntrySearchFinish;
|
sl@0
|
39 |
//
|
sl@0
|
40 |
LOCAL_D TInt gSeekPos1;
|
sl@0
|
41 |
LOCAL_D TInt gSeekPos2;
|
sl@0
|
42 |
LOCAL_D TFileName gSeekFile;
|
sl@0
|
43 |
|
sl@0
|
44 |
LOCAL_D TInt ThreadCount=0;
|
sl@0
|
45 |
|
sl@0
|
46 |
#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
sl@0
|
47 |
|
sl@0
|
48 |
const TInt64 KGb = 1 << 30;
|
sl@0
|
49 |
const TInt64 K2GB = 2 * KGb;
|
sl@0
|
50 |
const TInt64 K3GB = 3 * KGb;
|
sl@0
|
51 |
|
sl@0
|
52 |
LOCAL_D TInt64 gLSeekPos1;
|
sl@0
|
53 |
LOCAL_D TInt64 gLSeekPos2;
|
sl@0
|
54 |
|
sl@0
|
55 |
enum TSelectedTest
|
sl@0
|
56 |
{
|
sl@0
|
57 |
ELocalDriveTest, EFindEntryTest, EFileSeekTest, EFileSeekRFile64Test
|
sl@0
|
58 |
};
|
sl@0
|
59 |
#else
|
sl@0
|
60 |
enum TSelectedTest
|
sl@0
|
61 |
{
|
sl@0
|
62 |
ELocalDriveTest, EFindEntryTest, EFileSeekTest
|
sl@0
|
63 |
};
|
sl@0
|
64 |
#endif ////SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
sl@0
|
65 |
|
sl@0
|
66 |
|
sl@0
|
67 |
// RFs::CheckDisk() will return an error if the directory depth exceeds this value :
|
sl@0
|
68 |
const TInt KCheckDskMaxRecursionLevel = 50;
|
sl@0
|
69 |
|
sl@0
|
70 |
LOCAL_C void FormatFat(TDriveUnit aDrive)
|
sl@0
|
71 |
//
|
sl@0
|
72 |
// Call all RFormat methods
|
sl@0
|
73 |
//
|
sl@0
|
74 |
{
|
sl@0
|
75 |
|
sl@0
|
76 |
RFormat format;
|
sl@0
|
77 |
TPckgBuf<TInt> count;
|
sl@0
|
78 |
TInt r=format.Open(TheFs,aDrive.Name(),EHighDensity,count());
|
sl@0
|
79 |
test(r==KErrNone);
|
sl@0
|
80 |
test(count()==100);
|
sl@0
|
81 |
TRequestStatus status;
|
sl@0
|
82 |
while (count())
|
sl@0
|
83 |
{
|
sl@0
|
84 |
format.Next(count,status);
|
sl@0
|
85 |
User::WaitForRequest(status);
|
sl@0
|
86 |
test(status==KErrNone);
|
sl@0
|
87 |
}
|
sl@0
|
88 |
format.Close();
|
sl@0
|
89 |
}
|
sl@0
|
90 |
|
sl@0
|
91 |
LOCAL_C void DoTest(TThreadFunction aFunction)
|
sl@0
|
92 |
//
|
sl@0
|
93 |
// Do a speed test
|
sl@0
|
94 |
//
|
sl@0
|
95 |
{
|
sl@0
|
96 |
|
sl@0
|
97 |
RThread speedy;
|
sl@0
|
98 |
TBuf<8> buf=_L("Speedy");
|
sl@0
|
99 |
buf.AppendNum(ThreadCount++);
|
sl@0
|
100 |
TInt r=speedy.Create(buf,aFunction,KDefaultStackSize,KHeapSize,KHeapSize,NULL);
|
sl@0
|
101 |
test(r==KErrNone);
|
sl@0
|
102 |
//
|
sl@0
|
103 |
speedy.SetPriority(EPriorityLess);
|
sl@0
|
104 |
speedy.Resume();
|
sl@0
|
105 |
client.Wait();
|
sl@0
|
106 |
|
sl@0
|
107 |
r = TheFs.CheckDisk(gSessionPath);
|
sl@0
|
108 |
test (r == KErrNone);
|
sl@0
|
109 |
|
sl@0
|
110 |
//
|
sl@0
|
111 |
User::After(300000);
|
sl@0
|
112 |
TInt b=speedCount;
|
sl@0
|
113 |
User::After(3000000);
|
sl@0
|
114 |
TInt n=speedCount;
|
sl@0
|
115 |
test.Printf(_L(" Completed %d calls per second\n"),(n-b)/3);
|
sl@0
|
116 |
|
sl@0
|
117 |
test(TheFs.CheckDisk(gSessionPath) == KErrNone);
|
sl@0
|
118 |
|
sl@0
|
119 |
//
|
sl@0
|
120 |
speedy.Kill(KErrNone);
|
sl@0
|
121 |
test(r==KErrNone);
|
sl@0
|
122 |
speedy.Close();
|
sl@0
|
123 |
}
|
sl@0
|
124 |
|
sl@0
|
125 |
LOCAL_C TInt rawReadData(TAny*)
|
sl@0
|
126 |
//
|
sl@0
|
127 |
// The entry point for the speed test thread.
|
sl@0
|
128 |
//
|
sl@0
|
129 |
{
|
sl@0
|
130 |
|
sl@0
|
131 |
speedCount=0;
|
sl@0
|
132 |
TBusLocalDrive localDrive;
|
sl@0
|
133 |
TBool changed;
|
sl@0
|
134 |
localDrive.Connect(gLocalDrive,changed);
|
sl@0
|
135 |
client.Signal();
|
sl@0
|
136 |
FOREVER
|
sl@0
|
137 |
{
|
sl@0
|
138 |
localDrive.Read(512+32,gLocalDriveReadSize,buf);
|
sl@0
|
139 |
speedCount++;
|
sl@0
|
140 |
}
|
sl@0
|
141 |
// return(KErrNone);
|
sl@0
|
142 |
}
|
sl@0
|
143 |
|
sl@0
|
144 |
LOCAL_C TInt rawWriteData(TAny*)
|
sl@0
|
145 |
//
|
sl@0
|
146 |
// The entry point for the speed test thread.
|
sl@0
|
147 |
//
|
sl@0
|
148 |
{
|
sl@0
|
149 |
|
sl@0
|
150 |
speedCount=0;
|
sl@0
|
151 |
TBusLocalDrive localDrive;
|
sl@0
|
152 |
TBool changed;
|
sl@0
|
153 |
localDrive.Connect(gLocalDrive,changed);
|
sl@0
|
154 |
buf.SetLength(gLocalDriveWriteSize);
|
sl@0
|
155 |
client.Signal();
|
sl@0
|
156 |
FOREVER
|
sl@0
|
157 |
{
|
sl@0
|
158 |
localDrive.Write(512+32,buf);
|
sl@0
|
159 |
speedCount++;
|
sl@0
|
160 |
}
|
sl@0
|
161 |
// return(KErrNone);
|
sl@0
|
162 |
}
|
sl@0
|
163 |
|
sl@0
|
164 |
LOCAL_C void TestLocalDriveRead(TInt drive,TInt readsize)
|
sl@0
|
165 |
//
|
sl@0
|
166 |
// Test TBusLocalDrive read
|
sl@0
|
167 |
//
|
sl@0
|
168 |
{
|
sl@0
|
169 |
|
sl@0
|
170 |
test.Printf(_L("TBusLocalDrive %d Reading %d bytes"),drive,readsize);
|
sl@0
|
171 |
#if defined(__WINS__)
|
sl@0
|
172 |
if (drive==EDriveX)
|
sl@0
|
173 |
drive=1;
|
sl@0
|
174 |
else if (drive==EDriveY)
|
sl@0
|
175 |
drive=0;
|
sl@0
|
176 |
#endif
|
sl@0
|
177 |
gLocalDrive=drive;
|
sl@0
|
178 |
gLocalDriveReadSize=readsize;
|
sl@0
|
179 |
DoTest(rawReadData);
|
sl@0
|
180 |
}
|
sl@0
|
181 |
|
sl@0
|
182 |
LOCAL_C void TestLocalDriveWrite(TInt drive,TInt writesize)
|
sl@0
|
183 |
//
|
sl@0
|
184 |
// Test TBusLocalDrive write
|
sl@0
|
185 |
//
|
sl@0
|
186 |
{
|
sl@0
|
187 |
|
sl@0
|
188 |
test.Printf(_L("TBusLocalDrive %d Writing %d bytes"),drive,writesize);
|
sl@0
|
189 |
#if defined(__WINS__)
|
sl@0
|
190 |
if (drive==EDriveX)
|
sl@0
|
191 |
drive=1;
|
sl@0
|
192 |
else if (drive==EDriveY)
|
sl@0
|
193 |
drive=0;
|
sl@0
|
194 |
#endif
|
sl@0
|
195 |
gLocalDrive=drive;
|
sl@0
|
196 |
gLocalDriveWriteSize=writesize;
|
sl@0
|
197 |
DoTest(rawWriteData);
|
sl@0
|
198 |
}
|
sl@0
|
199 |
|
sl@0
|
200 |
LOCAL_C TInt FindEntryBounce(TAny*)
|
sl@0
|
201 |
//
|
sl@0
|
202 |
// Find entries in hierarchy
|
sl@0
|
203 |
//
|
sl@0
|
204 |
{
|
sl@0
|
205 |
|
sl@0
|
206 |
speedCount=0;
|
sl@0
|
207 |
RFs fs;
|
sl@0
|
208 |
TInt r=fs.Connect();
|
sl@0
|
209 |
test(r==KErrNone);
|
sl@0
|
210 |
r=fs.SetSessionPath(gSessionPath);
|
sl@0
|
211 |
test(r==KErrNone);
|
sl@0
|
212 |
client.Signal();
|
sl@0
|
213 |
FOREVER
|
sl@0
|
214 |
{
|
sl@0
|
215 |
TEntry entry;
|
sl@0
|
216 |
r=fs.Entry(gFindEntryDir,entry);
|
sl@0
|
217 |
test(r==KErrNone);
|
sl@0
|
218 |
r=fs.Entry(_L("\\F32-TST"),entry);
|
sl@0
|
219 |
test(r==KErrNone);
|
sl@0
|
220 |
speedCount++;
|
sl@0
|
221 |
}
|
sl@0
|
222 |
// fs.Close();
|
sl@0
|
223 |
// return(KErrNone);
|
sl@0
|
224 |
}
|
sl@0
|
225 |
|
sl@0
|
226 |
LOCAL_C void TestFindEntryBounce(TInt aDepth)
|
sl@0
|
227 |
//
|
sl@0
|
228 |
// Find entries at different depths
|
sl@0
|
229 |
//
|
sl@0
|
230 |
{
|
sl@0
|
231 |
|
sl@0
|
232 |
test.Printf(_L("Find entry 1 then find entry %d"),aDepth);
|
sl@0
|
233 |
gFindEntryDir=_L("\\F32-TST\\");
|
sl@0
|
234 |
TInt i;
|
sl@0
|
235 |
for(i=0;i<aDepth;i++)
|
sl@0
|
236 |
{
|
sl@0
|
237 |
gFindEntryDir+=_L("X");
|
sl@0
|
238 |
gFindEntryDir.AppendNum(i);
|
sl@0
|
239 |
gFindEntryDir+=_L("\\");
|
sl@0
|
240 |
}
|
sl@0
|
241 |
gFindEntryDir+=_L("X");
|
sl@0
|
242 |
gFindEntryDir.AppendNum(i);
|
sl@0
|
243 |
DoTest(FindEntryBounce);
|
sl@0
|
244 |
}
|
sl@0
|
245 |
|
sl@0
|
246 |
LOCAL_C TInt FindEntrySearch(TAny*)
|
sl@0
|
247 |
//
|
sl@0
|
248 |
// Find entries in hierarchy
|
sl@0
|
249 |
//
|
sl@0
|
250 |
{
|
sl@0
|
251 |
|
sl@0
|
252 |
speedCount=0;
|
sl@0
|
253 |
RFs fs;
|
sl@0
|
254 |
TInt r=fs.Connect();
|
sl@0
|
255 |
test(r==KErrNone);
|
sl@0
|
256 |
r=fs.SetSessionPath(gSessionPath);
|
sl@0
|
257 |
test(r==KErrNone);
|
sl@0
|
258 |
client.Signal();
|
sl@0
|
259 |
FOREVER
|
sl@0
|
260 |
{
|
sl@0
|
261 |
TFileName temp=gFindEntryDir;
|
sl@0
|
262 |
for(TInt i=gFindEntrySearchStart;i<gFindEntrySearchFinish;i++)
|
sl@0
|
263 |
{
|
sl@0
|
264 |
temp+=_L("X");
|
sl@0
|
265 |
temp.AppendNum(i);
|
sl@0
|
266 |
TEntry entry;
|
sl@0
|
267 |
r=fs.Entry(temp,entry);
|
sl@0
|
268 |
test(r==KErrNone);
|
sl@0
|
269 |
temp+=_L("\\");
|
sl@0
|
270 |
}
|
sl@0
|
271 |
speedCount++;
|
sl@0
|
272 |
}
|
sl@0
|
273 |
// fs.Close();
|
sl@0
|
274 |
// return(KErrNone);
|
sl@0
|
275 |
}
|
sl@0
|
276 |
|
sl@0
|
277 |
LOCAL_C void TestFindEntrySearch(TInt aStart, TInt aFinish)
|
sl@0
|
278 |
//
|
sl@0
|
279 |
// Find entries at different depths
|
sl@0
|
280 |
//
|
sl@0
|
281 |
{
|
sl@0
|
282 |
|
sl@0
|
283 |
test.Printf(_L("Find entries %d to %d"),aStart,aFinish);
|
sl@0
|
284 |
gFindEntrySearchStart=aStart;
|
sl@0
|
285 |
gFindEntrySearchFinish=aFinish;
|
sl@0
|
286 |
gFindEntryDir=_L("\\F32-TST\\");
|
sl@0
|
287 |
for(TInt i=0;i<aStart;i++)
|
sl@0
|
288 |
{
|
sl@0
|
289 |
gFindEntryDir+=_L("X");
|
sl@0
|
290 |
gFindEntryDir.AppendNum(i);
|
sl@0
|
291 |
gFindEntryDir+=_L("\\");
|
sl@0
|
292 |
}
|
sl@0
|
293 |
DoTest(FindEntrySearch);
|
sl@0
|
294 |
}
|
sl@0
|
295 |
|
sl@0
|
296 |
LOCAL_C TInt FileSeekTest(TAny*)
|
sl@0
|
297 |
//
|
sl@0
|
298 |
// Read 16bytes at different locations
|
sl@0
|
299 |
//
|
sl@0
|
300 |
{
|
sl@0
|
301 |
|
sl@0
|
302 |
speedCount=0;
|
sl@0
|
303 |
RFs fs;
|
sl@0
|
304 |
TInt r=fs.Connect();
|
sl@0
|
305 |
test(r==KErrNone);
|
sl@0
|
306 |
r=fs.SetSessionPath(gSessionPath);
|
sl@0
|
307 |
test(r==KErrNone);
|
sl@0
|
308 |
RFile f;
|
sl@0
|
309 |
r=f.Open(fs,gSeekFile,EFileRead); // 3rd arg was EFileRandomAccess, but this no longer exists
|
sl@0
|
310 |
test(r==KErrNone);
|
sl@0
|
311 |
client.Signal();
|
sl@0
|
312 |
FOREVER
|
sl@0
|
313 |
{
|
sl@0
|
314 |
r=f.Read(gSeekPos1,buf,16);
|
sl@0
|
315 |
test(r==KErrNone);
|
sl@0
|
316 |
r=f.Read(gSeekPos2,buf,16);
|
sl@0
|
317 |
test(r==KErrNone);
|
sl@0
|
318 |
speedCount++;
|
sl@0
|
319 |
}
|
sl@0
|
320 |
// f.Close();
|
sl@0
|
321 |
// fs.Close();
|
sl@0
|
322 |
// return(KErrNone);
|
sl@0
|
323 |
}
|
sl@0
|
324 |
|
sl@0
|
325 |
#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
sl@0
|
326 |
|
sl@0
|
327 |
LOCAL_C TInt FileSeekRFile64Test(TAny*)
|
sl@0
|
328 |
//
|
sl@0
|
329 |
// Read 16bytes at different locations
|
sl@0
|
330 |
//
|
sl@0
|
331 |
{
|
sl@0
|
332 |
|
sl@0
|
333 |
speedCount=0;
|
sl@0
|
334 |
RFs fs;
|
sl@0
|
335 |
TInt r=fs.Connect();
|
sl@0
|
336 |
test(r==KErrNone);
|
sl@0
|
337 |
r=fs.SetSessionPath(gSessionPath);
|
sl@0
|
338 |
test(r==KErrNone);
|
sl@0
|
339 |
RFile64 f;
|
sl@0
|
340 |
r=f.Open(fs,gSeekFile,EFileRead); // 3rd arg was EFileRandomAccess, but this no longer exists
|
sl@0
|
341 |
test(r==KErrNone);
|
sl@0
|
342 |
client.Signal();
|
sl@0
|
343 |
FOREVER
|
sl@0
|
344 |
{
|
sl@0
|
345 |
r=f.Read(gLSeekPos1,buf,16);
|
sl@0
|
346 |
test(r==KErrNone);
|
sl@0
|
347 |
r=f.Read(gLSeekPos2,buf,16);
|
sl@0
|
348 |
test(r==KErrNone);
|
sl@0
|
349 |
speedCount++;
|
sl@0
|
350 |
}
|
sl@0
|
351 |
}
|
sl@0
|
352 |
|
sl@0
|
353 |
LOCAL_C void TestSeek64(TInt64 aLoc1, TInt64 aLoc2)
|
sl@0
|
354 |
//
|
sl@0
|
355 |
// Read 16bytes at different locations
|
sl@0
|
356 |
//
|
sl@0
|
357 |
{
|
sl@0
|
358 |
|
sl@0
|
359 |
test.Printf(_L("Read 16bytes at positions %ld and %ld"),aLoc1,aLoc2);
|
sl@0
|
360 |
|
sl@0
|
361 |
gLSeekPos1=aLoc1;
|
sl@0
|
362 |
gLSeekPos2=aLoc2;
|
sl@0
|
363 |
DoTest(FileSeekRFile64Test);
|
sl@0
|
364 |
}
|
sl@0
|
365 |
|
sl@0
|
366 |
#endif //SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
sl@0
|
367 |
|
sl@0
|
368 |
LOCAL_C void TestSeek(TInt aLoc1, TInt aLoc2)
|
sl@0
|
369 |
//
|
sl@0
|
370 |
// Read 16bytes at different locations
|
sl@0
|
371 |
//
|
sl@0
|
372 |
{
|
sl@0
|
373 |
|
sl@0
|
374 |
test.Printf(_L("Read 16bytes at positions %d and %d"),aLoc1,aLoc2);
|
sl@0
|
375 |
gSeekPos1=aLoc1;
|
sl@0
|
376 |
gSeekPos2=aLoc2;
|
sl@0
|
377 |
DoTest(FileSeekTest);
|
sl@0
|
378 |
}
|
sl@0
|
379 |
|
sl@0
|
380 |
LOCAL_C void InitializeDrive(CSelectionBox* aSelector)
|
sl@0
|
381 |
//
|
sl@0
|
382 |
// Get the drive into a good state
|
sl@0
|
383 |
//
|
sl@0
|
384 |
{
|
sl@0
|
385 |
|
sl@0
|
386 |
TDriveUnit drive=((CSelectionBox*)aSelector)->CurrentDrive();
|
sl@0
|
387 |
gSessionPath[0]=TUint8('A'+drive);
|
sl@0
|
388 |
TInt r=TheFs.SetSessionPath(gSessionPath);
|
sl@0
|
389 |
test(r==KErrNone);
|
sl@0
|
390 |
TDriveInfo driveInfo;
|
sl@0
|
391 |
r=TheFs.Drive(driveInfo);
|
sl@0
|
392 |
test(r==KErrNone);
|
sl@0
|
393 |
if (driveInfo.iType==EMediaNotPresent)
|
sl@0
|
394 |
{
|
sl@0
|
395 |
test.Printf(_L("ERROR: MEDIA NOT PRESENT <Press return to continue>\n"));
|
sl@0
|
396 |
test.Getch();
|
sl@0
|
397 |
return;
|
sl@0
|
398 |
}
|
sl@0
|
399 |
r=TheFs.MkDirAll(gSessionPath);
|
sl@0
|
400 |
test(r==KErrCorrupt || r==KErrAlreadyExists || r==KErrNone);
|
sl@0
|
401 |
if (r==KErrCorrupt)
|
sl@0
|
402 |
FormatFat(gSessionPath[0]-'A');
|
sl@0
|
403 |
if (r!=KErrNone && r!=KErrAlreadyExists)
|
sl@0
|
404 |
{
|
sl@0
|
405 |
r=TheFs.MkDirAll(gSessionPath);
|
sl@0
|
406 |
test(r==KErrNone);
|
sl@0
|
407 |
}
|
sl@0
|
408 |
}
|
sl@0
|
409 |
|
sl@0
|
410 |
|
sl@0
|
411 |
LOCAL_C TInt ValidateDriveSelection(TDriveUnit aDrive,TSelectedTest aTest)
|
sl@0
|
412 |
{
|
sl@0
|
413 |
if ((aDrive==EDriveZ)||((aDrive==EDriveC)&&(aTest==ELocalDriveTest)))
|
sl@0
|
414 |
{
|
sl@0
|
415 |
|
sl@0
|
416 |
test.Printf(_L("Test not available for this drive\n"));
|
sl@0
|
417 |
test.Printf(_L("Press any key to continue...\n"));
|
sl@0
|
418 |
test.Getch();
|
sl@0
|
419 |
return (KErrNotSupported);
|
sl@0
|
420 |
}
|
sl@0
|
421 |
else
|
sl@0
|
422 |
return (KErrNone);
|
sl@0
|
423 |
}
|
sl@0
|
424 |
|
sl@0
|
425 |
|
sl@0
|
426 |
|
sl@0
|
427 |
LOCAL_C TInt TestLocalDrive(TAny* aSelector)
|
sl@0
|
428 |
//
|
sl@0
|
429 |
// Test TBusLocalDrive
|
sl@0
|
430 |
//
|
sl@0
|
431 |
{
|
sl@0
|
432 |
|
sl@0
|
433 |
if (((CSelectionBox*)aSelector)->CurrentKeyPress()!=EKeyEnter)
|
sl@0
|
434 |
return(KErrNone);
|
sl@0
|
435 |
TDriveUnit drive=((CSelectionBox*)aSelector)->CurrentDrive();
|
sl@0
|
436 |
TInt r=ValidateDriveSelection(drive,ELocalDriveTest);
|
sl@0
|
437 |
if (r==KErrNotSupported)
|
sl@0
|
438 |
return (r);
|
sl@0
|
439 |
|
sl@0
|
440 |
InitializeDrive((CSelectionBox*)aSelector);
|
sl@0
|
441 |
//
|
sl@0
|
442 |
TBuf<128> testTitle;
|
sl@0
|
443 |
TBuf<KMaxFileName> name=drive.Name();
|
sl@0
|
444 |
testTitle.Format(_L("Test TBusLocalDrive %S"),&name);
|
sl@0
|
445 |
test.Start(testTitle);
|
sl@0
|
446 |
TestLocalDriveRead(drive,16);
|
sl@0
|
447 |
TestLocalDriveRead(drive,1024);
|
sl@0
|
448 |
TestLocalDriveRead(drive,4096);
|
sl@0
|
449 |
//
|
sl@0
|
450 |
TestLocalDriveWrite(drive,16);
|
sl@0
|
451 |
TestLocalDriveWrite(drive,1024);
|
sl@0
|
452 |
TestLocalDriveWrite(drive,4096);
|
sl@0
|
453 |
//
|
sl@0
|
454 |
test.Printf(_L("Test finished, reformatting drive %d\n"),gSessionPath[0]-'A');
|
sl@0
|
455 |
FormatFat(gSessionPath[0]-'A');
|
sl@0
|
456 |
test.End();
|
sl@0
|
457 |
return(KErrNone);
|
sl@0
|
458 |
}
|
sl@0
|
459 |
|
sl@0
|
460 |
LOCAL_C TInt TestFindEntries(TAny* aSelector)
|
sl@0
|
461 |
//
|
sl@0
|
462 |
// Test Entry
|
sl@0
|
463 |
//
|
sl@0
|
464 |
{
|
sl@0
|
465 |
|
sl@0
|
466 |
if (((CSelectionBox*)aSelector)->CurrentKeyPress()!=EKeyEnter)
|
sl@0
|
467 |
return(KErrNone);
|
sl@0
|
468 |
|
sl@0
|
469 |
TInt r=ValidateDriveSelection(((CSelectionBox*)aSelector)->CurrentDrive(),EFindEntryTest);
|
sl@0
|
470 |
if (r==KErrNotSupported)
|
sl@0
|
471 |
return(r);
|
sl@0
|
472 |
|
sl@0
|
473 |
InitializeDrive((CSelectionBox*)aSelector);
|
sl@0
|
474 |
//
|
sl@0
|
475 |
test.Start(_L("Test Entry"));
|
sl@0
|
476 |
TFileName dirFiftyDeep=_L("\\F32-TST\\"); // root + first directory = 2 directory levels
|
sl@0
|
477 |
for(TInt i=0;i<KCheckDskMaxRecursionLevel-2;i++) // 0 to 47 = 48 directory levels
|
sl@0
|
478 |
{
|
sl@0
|
479 |
dirFiftyDeep+=_L("X");
|
sl@0
|
480 |
dirFiftyDeep.AppendNum(i);
|
sl@0
|
481 |
dirFiftyDeep+=_L("\\");
|
sl@0
|
482 |
}
|
sl@0
|
483 |
r=TheFs.MkDirAll(dirFiftyDeep);
|
sl@0
|
484 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
485 |
//
|
sl@0
|
486 |
TestFindEntryBounce(2);
|
sl@0
|
487 |
TestFindEntryBounce(10);
|
sl@0
|
488 |
TestFindEntryBounce(20);
|
sl@0
|
489 |
TestFindEntryBounce(KCheckDskMaxRecursionLevel-3);
|
sl@0
|
490 |
//
|
sl@0
|
491 |
TestFindEntrySearch(1,5);
|
sl@0
|
492 |
TestFindEntrySearch(1,10);
|
sl@0
|
493 |
TestFindEntrySearch(10,15);
|
sl@0
|
494 |
TestFindEntrySearch(10,20);
|
sl@0
|
495 |
//
|
sl@0
|
496 |
test.Printf(_L("Test finished, removing directory\n"));
|
sl@0
|
497 |
CFileMan* fMan=CFileMan::NewL(TheFs);
|
sl@0
|
498 |
r=fMan->RmDir(_L("\\F32-TST\\X0\\"));
|
sl@0
|
499 |
test(r==KErrNone);
|
sl@0
|
500 |
delete fMan;
|
sl@0
|
501 |
test.End();
|
sl@0
|
502 |
return(KErrNone);
|
sl@0
|
503 |
}
|
sl@0
|
504 |
|
sl@0
|
505 |
LOCAL_C TInt TestFileSeek(TAny* aSelector)
|
sl@0
|
506 |
//
|
sl@0
|
507 |
// Test Seek
|
sl@0
|
508 |
//
|
sl@0
|
509 |
{
|
sl@0
|
510 |
|
sl@0
|
511 |
if (((CSelectionBox*)aSelector)->CurrentKeyPress()!=EKeyEnter)
|
sl@0
|
512 |
return(KErrNone);
|
sl@0
|
513 |
|
sl@0
|
514 |
TInt r=ValidateDriveSelection(((CSelectionBox*)aSelector)->CurrentDrive(),EFileSeekTest);
|
sl@0
|
515 |
if (r==KErrNotSupported)
|
sl@0
|
516 |
return (r);
|
sl@0
|
517 |
|
sl@0
|
518 |
InitializeDrive((CSelectionBox*)aSelector);
|
sl@0
|
519 |
//
|
sl@0
|
520 |
test.Start(_L("Test Seek"));
|
sl@0
|
521 |
RFile f;
|
sl@0
|
522 |
gSeekFile=_L("\\F32-TST\\FILE512K.BIG");
|
sl@0
|
523 |
r=f.Replace(TheFs,gSeekFile,EFileWrite);
|
sl@0
|
524 |
test(r==KErrNone);
|
sl@0
|
525 |
r=f.SetSize(524268);
|
sl@0
|
526 |
test(r==KErrNone);
|
sl@0
|
527 |
f.Close();
|
sl@0
|
528 |
//
|
sl@0
|
529 |
TestSeek(0,1000);
|
sl@0
|
530 |
TestSeek(0,10000);
|
sl@0
|
531 |
TestSeek(5000,6000);
|
sl@0
|
532 |
TestSeek(5000,15000);
|
sl@0
|
533 |
TestSeek(10000,100000);
|
sl@0
|
534 |
TestSeek(200000,500000);
|
sl@0
|
535 |
//
|
sl@0
|
536 |
r=TheFs.Delete(gSeekFile);
|
sl@0
|
537 |
test(r==KErrNone);
|
sl@0
|
538 |
test.End();
|
sl@0
|
539 |
return(KErrNone);
|
sl@0
|
540 |
}
|
sl@0
|
541 |
|
sl@0
|
542 |
#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
sl@0
|
543 |
//Read the file at position beyond 2GB-1
|
sl@0
|
544 |
//Minimum required disk space for this test is 3GB
|
sl@0
|
545 |
//
|
sl@0
|
546 |
LOCAL_C TInt TestLargeFileSeek(TAny* aSelector)
|
sl@0
|
547 |
{
|
sl@0
|
548 |
|
sl@0
|
549 |
if (((CSelectionBox*)aSelector)->CurrentKeyPress()!=EKeyEnter)
|
sl@0
|
550 |
return(KErrNone);
|
sl@0
|
551 |
|
sl@0
|
552 |
TInt r=ValidateDriveSelection(((CSelectionBox*)aSelector)->CurrentDrive(),EFileSeekRFile64Test);
|
sl@0
|
553 |
if (r==KErrNotSupported)
|
sl@0
|
554 |
return (r);
|
sl@0
|
555 |
|
sl@0
|
556 |
InitializeDrive((CSelectionBox*)aSelector);
|
sl@0
|
557 |
//
|
sl@0
|
558 |
test.Start(_L("Test large File Seek"));
|
sl@0
|
559 |
|
sl@0
|
560 |
RFile64 BigFile;
|
sl@0
|
561 |
gSeekFile=_L("\\F32-TST\\FILE4GBMINUS2.BIG");
|
sl@0
|
562 |
r=BigFile.Replace(TheFs,gSeekFile,EFileWrite);
|
sl@0
|
563 |
test(r==KErrNone);
|
sl@0
|
564 |
|
sl@0
|
565 |
//check Disk space
|
sl@0
|
566 |
TVolumeInfo volInfo;
|
sl@0
|
567 |
|
sl@0
|
568 |
r = TheFs.Volume(volInfo);
|
sl@0
|
569 |
test(r==KErrNone);
|
sl@0
|
570 |
|
sl@0
|
571 |
//Get the free space available for test
|
sl@0
|
572 |
if(volInfo.iFree < (K3GB-2))
|
sl@0
|
573 |
{
|
sl@0
|
574 |
BigFile.Close();
|
sl@0
|
575 |
test(r==KErrNone);
|
sl@0
|
576 |
r=TheFs.Delete(gSeekFile);
|
sl@0
|
577 |
test.Printf(_L("Large File test is skipped: Free space %ld \n"),volInfo.iFree);
|
sl@0
|
578 |
return r;
|
sl@0
|
579 |
}
|
sl@0
|
580 |
|
sl@0
|
581 |
r=BigFile.SetSize(K3GB-2);
|
sl@0
|
582 |
test(r==KErrNone);
|
sl@0
|
583 |
BigFile.Close();
|
sl@0
|
584 |
|
sl@0
|
585 |
TestSeek64(0,1000);
|
sl@0
|
586 |
TestSeek64(5000,6000);
|
sl@0
|
587 |
TestSeek64(200000,500000);
|
sl@0
|
588 |
TestSeek64(K2GB,K2GB+1000);
|
sl@0
|
589 |
TestSeek64(K3GB-1000,K3GB-2000);
|
sl@0
|
590 |
TestSeek64(K3GB-50, K3GB-20);
|
sl@0
|
591 |
r=TheFs.Delete(gSeekFile);
|
sl@0
|
592 |
test(r==KErrNone);
|
sl@0
|
593 |
|
sl@0
|
594 |
test.End();
|
sl@0
|
595 |
return(KErrNone);
|
sl@0
|
596 |
|
sl@0
|
597 |
}
|
sl@0
|
598 |
#endif //SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
sl@0
|
599 |
|
sl@0
|
600 |
GLDEF_C void CallTestsL()
|
sl@0
|
601 |
//
|
sl@0
|
602 |
// Call all tests
|
sl@0
|
603 |
//
|
sl@0
|
604 |
{
|
sl@0
|
605 |
|
sl@0
|
606 |
TInt r=client.CreateLocal(0);
|
sl@0
|
607 |
test(r==KErrNone);
|
sl@0
|
608 |
gSessionPath=_L("?:\\F32-TST\\");
|
sl@0
|
609 |
CSelectionBox* TheSelector=CSelectionBox::NewL(test.Console());
|
sl@0
|
610 |
TCallBack localDrivesCb(TestLocalDrive,TheSelector);
|
sl@0
|
611 |
TCallBack findEntriesCb(TestFindEntries,TheSelector);
|
sl@0
|
612 |
TCallBack fileSeekCb(TestFileSeek,TheSelector);
|
sl@0
|
613 |
|
sl@0
|
614 |
#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
sl@0
|
615 |
TCallBack largefileSeekCb(TestLargeFileSeek,TheSelector);
|
sl@0
|
616 |
#endif //SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
sl@0
|
617 |
|
sl@0
|
618 |
TheSelector->AddDriveSelectorL(TheFs);
|
sl@0
|
619 |
TheSelector->AddLineL(_L("Test LocalDrive"),localDrivesCb);
|
sl@0
|
620 |
TheSelector->AddLineL(_L("Test Find Entries"),findEntriesCb);
|
sl@0
|
621 |
TheSelector->AddLineL(_L("Test File Seek"),fileSeekCb);
|
sl@0
|
622 |
|
sl@0
|
623 |
#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
sl@0
|
624 |
TheSelector->AddLineL(_L("Test large File Seek"),largefileSeekCb);
|
sl@0
|
625 |
#endif //SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
sl@0
|
626 |
TheSelector->Run();
|
sl@0
|
627 |
client.Close();
|
sl@0
|
628 |
delete TheSelector;
|
sl@0
|
629 |
}
|