0
|
1 |
// Copyright (c) 1996-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\server\t_fsys.cpp
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#define __E32TEST_EXTENSION__
|
|
19 |
|
|
20 |
#include <f32file.h>
|
|
21 |
#include <f32file_private.h>
|
|
22 |
#include <e32test.h>
|
|
23 |
#include "t_server.h"
|
|
24 |
#include "fat_utils.h"
|
|
25 |
#include "filesystem_fat.h"
|
|
26 |
|
|
27 |
using namespace Fat_Test_Utils;
|
|
28 |
|
|
29 |
RTest test(_L("T_FSYS"));
|
|
30 |
|
|
31 |
static void TestFileSystemNames()
|
|
32 |
{
|
|
33 |
test.Next(_L("Read file system names for all drives"));
|
|
34 |
TFullName name;
|
|
35 |
TInt r;
|
|
36 |
for(TInt i=EDriveA;i<KMaxDrives;++i)
|
|
37 |
{
|
|
38 |
r=TheFs.FileSystemName(name,i);
|
|
39 |
test(r==KErrNone || r==KErrNotFound);
|
|
40 |
TChar c;
|
|
41 |
r=RFs::DriveToChar(i,c);
|
|
42 |
test(r==KErrNone);
|
|
43 |
if(name.Length())
|
|
44 |
test.Printf(_L("File System Name on drive %c is %S\n"),(char)c,&name);
|
|
45 |
else
|
|
46 |
test.Printf(_L("No file system on drive %c\n"),(char)c);
|
|
47 |
}
|
|
48 |
}
|
|
49 |
|
|
50 |
static void CheckDismount(TDesC& aFs,TInt aDrive)
|
|
51 |
{
|
|
52 |
|
|
53 |
if (aDrive==EDriveC) // ??? Can't test on C: - see below
|
|
54 |
return;
|
|
55 |
TInt r;
|
|
56 |
TFullName oldSess, newSess;
|
|
57 |
r=TheFs.SessionPath(oldSess);
|
|
58 |
test(r==KErrNone);
|
|
59 |
TChar c;
|
|
60 |
r=TheFs.DriveToChar(aDrive,c);
|
|
61 |
test(r==KErrNone);
|
|
62 |
newSess.Append(c);
|
|
63 |
newSess.Append(':');
|
|
64 |
newSess.Append('\\');
|
|
65 |
|
|
66 |
TBuf<128> b;
|
|
67 |
TDriveInfo di;
|
|
68 |
r=TheFs.Drive(di,aDrive);
|
|
69 |
test(r==KErrNone);
|
|
70 |
b.Format(_L("Test dismounting of test file system on %c: (DrvAtt:%x MedAtt:%x)"),(TUint)c,di.iDriveAtt,di.iMediaAtt);
|
|
71 |
test.Next(b);
|
|
72 |
|
|
73 |
// Test cannot dismount on rom drive
|
|
74 |
test.Next(_L("Test cannot dismount on Rom drive"));
|
|
75 |
TFullName zName;
|
|
76 |
r=TheFs.FileSystemName(zName,EDriveZ);
|
|
77 |
test(r==KErrNone);
|
|
78 |
r=TheFs.DismountFileSystem(zName,EDriveZ);
|
|
79 |
test.Printf(_L("r=%d"),r);
|
|
80 |
// NB if paging is enabled on a ROFS partition which is part of the composite file system then the
|
|
81 |
// likelihood is that there will be a at least one file clamped: in this case there error will be KErrInUse
|
|
82 |
test(r==KErrAccessDenied || r==KErrInUse);
|
|
83 |
|
|
84 |
// Test cannot dismount on wrong drive
|
|
85 |
test.Next(_L("Test cannot dismount on wrong drive"));
|
|
86 |
r=TheFs.DismountFileSystem(aFs,EDriveA);
|
|
87 |
test(r==KErrNotReady);
|
|
88 |
|
|
89 |
// Test cannot dismount with wrong name
|
|
90 |
test.Next(_L("Test cannot dismount with wrong file system name"));
|
|
91 |
r=TheFs.DismountFileSystem(_L("abc"),aDrive);
|
|
92 |
test(r==KErrNotFound);
|
|
93 |
|
|
94 |
// Test cannot dismount with a file open
|
|
95 |
test.Next(_L("Test cannot dismount with a file open"));
|
|
96 |
r=TheFs.SetSessionPath(newSess);
|
|
97 |
RFile file;
|
|
98 |
r=file.Replace(TheFs,_L("abc"),EFileShareAny);
|
|
99 |
test(r==KErrNone);
|
|
100 |
r=TheFs.SessionPath(newSess);
|
|
101 |
TBool open;
|
|
102 |
r=TheFs.IsFileOpen(_L("abc"),open);
|
|
103 |
test(r==KErrNone);
|
|
104 |
test(open);
|
|
105 |
r=TheFs.DismountFileSystem(aFs,aDrive);
|
|
106 |
test(r==KErrInUse);
|
|
107 |
file.Close();
|
|
108 |
|
|
109 |
// Now test dismount works
|
|
110 |
test.Next(_L("Test dismounts OK"));
|
|
111 |
r=TheFs.DismountFileSystem(aFs,aDrive);
|
|
112 |
if(r!=KErrNone)
|
|
113 |
{
|
|
114 |
test.Printf(_L("Error = %d"),r);
|
|
115 |
test(EFalse);
|
|
116 |
}
|
|
117 |
TFullName n;
|
|
118 |
r=TheFs.FileSystemName(n,aDrive);
|
|
119 |
test(r==KErrNone || r==KErrNotFound);
|
|
120 |
test(!n.Length());
|
|
121 |
r=file.Replace(TheFs,_L("abc"),EFileShareAny);
|
|
122 |
test(r==KErrNotReady);
|
|
123 |
file.Close();
|
|
124 |
|
|
125 |
r=TheFs.MountFileSystem(aFs,aDrive);
|
|
126 |
if(r!=KErrNone)
|
|
127 |
{
|
|
128 |
test.Printf(_L("error = %d\n"),r);
|
|
129 |
test(EFalse);
|
|
130 |
}
|
|
131 |
r=TheFs.FileSystemName(n,aDrive);
|
|
132 |
test(r==KErrNone);
|
|
133 |
test(n.Compare(aFs)==0);
|
|
134 |
r=file.Replace(TheFs,_L("abc"),EFileShareAny); // ??? bang
|
|
135 |
test(r==KErrNone);
|
|
136 |
file.Close();
|
|
137 |
r=TheFs.SetSessionPath(oldSess);
|
|
138 |
test(r==KErrNone);
|
|
139 |
}
|
|
140 |
|
|
141 |
static void TestDismountFileSystem(TInt aDrive)
|
|
142 |
{
|
|
143 |
|
|
144 |
TInt r;
|
|
145 |
TFullName name;
|
|
146 |
r=TheFs.FileSystemName(name,aDrive);
|
|
147 |
test(r==KErrNone || r==KErrNotFound);
|
|
148 |
if(name.Length())
|
|
149 |
CheckDismount(name,aDrive);
|
|
150 |
}
|
|
151 |
|
|
152 |
#if defined(__EPOC32__)
|
|
153 |
static void TestFileSystem(TInt aDrive)
|
|
154 |
//
|
|
155 |
// Mount a new CTestFileSystem on the drive under test
|
|
156 |
//
|
|
157 |
{
|
|
158 |
TBuf<64> b;
|
|
159 |
TChar c;
|
|
160 |
TInt r=TheFs.DriveToChar(aDrive,c);
|
|
161 |
test(r==KErrNone);
|
|
162 |
TDriveInfo di;
|
|
163 |
r=TheFs.Drive(di,aDrive);
|
|
164 |
test(r==KErrNone);
|
|
165 |
b.Format(_L("Test mounting of test file system on %c: (DrvAtt:%x MedAtt:%x)"),(TUint)c,di.iDriveAtt,di.iMediaAtt);
|
|
166 |
test.Next(b);
|
|
167 |
|
|
168 |
test.Next(_L("Test mounting of test file system"));
|
|
169 |
r=TheFs.AddFileSystem(_L("T_TFSYS"));
|
|
170 |
if(r!=KErrNone && r!=KErrAlreadyExists)
|
|
171 |
{
|
|
172 |
test.Printf(_L("error=%d"),r);
|
|
173 |
test(EFalse);
|
|
174 |
}
|
|
175 |
|
|
176 |
|
|
177 |
TFullName oldFs;
|
|
178 |
r=TheFs.FileSystemName(oldFs,aDrive);
|
|
179 |
// TFileName oldFs;
|
|
180 |
// r=TheFs.FileSystemName(oldFs,aDrive);
|
|
181 |
test(r==KErrNone);
|
|
182 |
r=TheFs.DismountFileSystem(oldFs,aDrive);
|
|
183 |
if(r!=KErrNone)
|
|
184 |
{
|
|
185 |
test.Printf(_L("Error = %d"),r);
|
|
186 |
test(EFalse);
|
|
187 |
}
|
|
188 |
r=TheFs.MountFileSystem(_L("Test"),aDrive);
|
|
189 |
test(r==KErrNone);
|
|
190 |
|
|
191 |
TFileName newFs;
|
|
192 |
r=TheFs.FileSystemName(newFs,aDrive);
|
|
193 |
test(r==KErrNone);
|
|
194 |
test(newFs.Compare(_L("Test"))==0);
|
|
195 |
|
|
196 |
// Check attributes
|
|
197 |
TDriveInfo info;
|
|
198 |
r=TheFs.Drive(info,aDrive);
|
|
199 |
test(r==KErrNone);
|
|
200 |
|
|
201 |
test.Printf(_L("iType=%d,iBattery=%d,iDriveAtt=%x,iMediaAtt=%x\n"),(TUint)info.iType,\
|
|
202 |
(TUint)info.iBattery,info.iDriveAtt,info.iMediaAtt);
|
|
203 |
|
|
204 |
//Try to remove filesystem without dismounting.
|
|
205 |
r=TheFs.RemoveFileSystem(_L("Test"));
|
|
206 |
if(r!=KErrInUse)
|
|
207 |
{
|
|
208 |
test.Printf(_L("error=%d"),r);
|
|
209 |
test(EFalse);
|
|
210 |
}
|
|
211 |
r=TheFs.FileSystemName(newFs,aDrive);
|
|
212 |
test(r==KErrNone);
|
|
213 |
test(newFs.Compare(_L("Test"))==0);
|
|
214 |
|
|
215 |
r=TheFs.DismountFileSystem(newFs,aDrive);
|
|
216 |
test(r==KErrNone);
|
|
217 |
|
|
218 |
r=TheFs.MountFileSystem(oldFs,aDrive);
|
|
219 |
test(r==KErrNone);
|
|
220 |
}
|
|
221 |
#endif
|
|
222 |
|
|
223 |
static void TestMountInvalidDrive()
|
|
224 |
//
|
|
225 |
// Attempt to mount FAT on non-local drive
|
|
226 |
{
|
|
227 |
test.Start(_L("TestMountInvalidDrive"));
|
|
228 |
|
|
229 |
TInt r;
|
|
230 |
|
|
231 |
test.Next(_L("Adding EFAT"));
|
|
232 |
#ifdef __WINS__
|
|
233 |
_LIT(KFsNm, "EFAT");
|
|
234 |
#else
|
|
235 |
_LIT(KFsNm, "ELOCAL");
|
|
236 |
#endif
|
|
237 |
|
|
238 |
r = TheFs.AddFileSystem(KFsNm);
|
|
239 |
test.Printf(_L("afs: r = %d\n"), r);
|
|
240 |
test(r == KErrNone || r == KErrAlreadyExists);
|
|
241 |
test.Next(_L("mounting FAT on drive R"));
|
|
242 |
r = TheFs.MountFileSystem(KFileSystemName_FAT, EDriveR);
|
|
243 |
test(r == KErrArgument);
|
|
244 |
|
|
245 |
test.End();
|
|
246 |
}
|
|
247 |
|
|
248 |
// Additional step for INC083446: Corrupted miniSD not detected as corrupted by phone
|
|
249 |
static void TestMountingBrokenMedia(TInt aDrive)
|
|
250 |
//
|
|
251 |
// Mount a new CTestFileSystem on the drive under test
|
|
252 |
//
|
|
253 |
{
|
|
254 |
if (aDrive==EDriveC) // ??? Can't test on C:
|
|
255 |
return;
|
|
256 |
|
|
257 |
TBuf<64> b;
|
|
258 |
TChar c;
|
|
259 |
TInt r=TheFs.DriveToChar(aDrive,c);
|
|
260 |
test(r==KErrNone);
|
|
261 |
TDriveInfo di;
|
|
262 |
r=TheFs.Drive(di,aDrive);
|
|
263 |
test(r==KErrNone);
|
|
264 |
b.Format(_L("Test mounting of test file system on %c: (DrvAtt:%x MedAtt:%x)"),(TUint)c,di.iDriveAtt,di.iMediaAtt);
|
|
265 |
test.Next(b);
|
|
266 |
|
|
267 |
test.Next(_L("Test mounting of test file system"));
|
|
268 |
r=TheFs.AddFileSystem(_L("T_TFSYS2"));
|
|
269 |
if(r!=KErrNone && r!=KErrAlreadyExists)
|
|
270 |
{
|
|
271 |
test.Printf(_L("error=%d"),r);
|
|
272 |
test(EFalse);
|
|
273 |
}
|
|
274 |
|
|
275 |
|
|
276 |
TFullName oldFs;
|
|
277 |
r=TheFs.FileSystemName(oldFs,aDrive);
|
|
278 |
test(r==KErrNone);
|
|
279 |
r=TheFs.DismountFileSystem(oldFs,aDrive);
|
|
280 |
if(r!=KErrNone)
|
|
281 |
{
|
|
282 |
test.Printf(_L("Error = %d"),r);
|
|
283 |
test(EFalse);
|
|
284 |
}
|
|
285 |
r=TheFs.MountFileSystem(_L("Test2"),aDrive);
|
|
286 |
test(r == KErrCorrupt);
|
|
287 |
|
|
288 |
TFileName newFs;
|
|
289 |
r=TheFs.FileSystemName(newFs,aDrive);
|
|
290 |
test(r==KErrNone);
|
|
291 |
test(newFs.Compare(_L("Test2"))==0);
|
|
292 |
|
|
293 |
// Get the number of remounts by checking the volume attributes -
|
|
294 |
// T_TFSYS2 hijacks the iBattery member to report back the number of times MountL() has been called
|
|
295 |
TDriveInfo info;
|
|
296 |
TInt remounts;
|
|
297 |
r=TheFs.Drive(info,aDrive);
|
|
298 |
test(r==KErrNone);
|
|
299 |
test.Printf(_L("iType=%d,iBattery=%d,iDriveAtt=%x,iMediaAtt=%x\n"),(TUint)info.iType,\
|
|
300 |
(TUint)info.iBattery,info.iDriveAtt,info.iMediaAtt);
|
|
301 |
remounts = (TInt) info.iBattery;
|
|
302 |
test.Printf(_L("Initial remounts = %d"), remounts);
|
|
303 |
|
|
304 |
// Make the file server attempt to remount the drive by looking for a non-existant DLL
|
|
305 |
// The file server should setop trying to remount the driver after KMaxMountFailures attempts
|
|
306 |
const TInt KMaxMountFailures = 3; // copied from sf_drv.cpp
|
|
307 |
const TInt KEntryAttempts = 10;
|
|
308 |
TInt entryAttempts;
|
|
309 |
for (entryAttempts=0; entryAttempts < KEntryAttempts; entryAttempts++)
|
|
310 |
{
|
|
311 |
TEntry entry;
|
|
312 |
_LIT(KNonExistantFilename, "NONEXISTANT_FILENAME.DLL");
|
|
313 |
r = TheFs.Entry(KNonExistantFilename, entry);
|
|
314 |
test(r == KErrCorrupt);
|
|
315 |
}
|
|
316 |
r=TheFs.Drive(info,aDrive);
|
|
317 |
test(r==KErrNone);
|
|
318 |
test.Printf(_L("iType=%d,iBattery=%d,iDriveAtt=%x,iMediaAtt=%x\n"),(TUint)info.iType,\
|
|
319 |
(TUint)info.iBattery,info.iDriveAtt,info.iMediaAtt);
|
|
320 |
remounts = (TInt) info.iBattery;
|
|
321 |
test.Printf(_L("Remounts = %d"), remounts);
|
|
322 |
test(remounts == KMaxMountFailures);
|
|
323 |
|
|
324 |
|
|
325 |
// simulate a media change to reset failure count
|
|
326 |
r = TheFs.RemountDrive(aDrive, NULL, 0);
|
|
327 |
|
|
328 |
// now try mounting again & verify the the file server attempts to mount the drive again
|
|
329 |
for (entryAttempts=0; entryAttempts < KEntryAttempts; entryAttempts++)
|
|
330 |
{
|
|
331 |
TEntry entry;
|
|
332 |
_LIT(KNonExistantFilename, "NONEXISTANT_FILENAME.DLL");
|
|
333 |
r = TheFs.Entry(KNonExistantFilename, entry);
|
|
334 |
test(r == KErrCorrupt);
|
|
335 |
}
|
|
336 |
r=TheFs.Drive(info,aDrive);
|
|
337 |
test(r==KErrNone);
|
|
338 |
test.Printf(_L("iType=%d,iBattery=%d,iDriveAtt=%x,iMediaAtt=%x\n"),(TUint)info.iType,\
|
|
339 |
(TUint)info.iBattery,info.iDriveAtt,info.iMediaAtt);
|
|
340 |
remounts = (TInt) info.iBattery;
|
|
341 |
test.Printf(_L("Remounts = %d"), remounts);
|
|
342 |
test(remounts == KMaxMountFailures * 2);
|
|
343 |
|
|
344 |
|
|
345 |
|
|
346 |
r=TheFs.DismountFileSystem(newFs,aDrive);
|
|
347 |
test(r==KErrNone);
|
|
348 |
r=TheFs.MountFileSystem(oldFs,aDrive);
|
|
349 |
test(r==KErrNone);
|
|
350 |
|
|
351 |
r=TheFs.RemoveFileSystem(_L("Test2"));
|
|
352 |
if(r!=KErrNone)
|
|
353 |
{
|
|
354 |
test.Printf(_L("error=%d"),r);
|
|
355 |
test(EFalse);
|
|
356 |
}
|
|
357 |
}
|
|
358 |
|
|
359 |
|
|
360 |
/**
|
|
361 |
Testing obtaining media serial number for the substituted drives
|
|
362 |
*/
|
|
363 |
static void TestSubstDriveMediaSerialNumber()
|
|
364 |
{
|
|
365 |
test.Next(_L("Test obtaining media serial number for the substituted drives"));
|
|
366 |
|
|
367 |
TInt nRes;
|
|
368 |
const TInt currDrvNum=CurrentDrive();
|
|
369 |
|
|
370 |
TDriveInfo drvInfo;
|
|
371 |
nRes=TheFs.Drive(drvInfo, currDrvNum);
|
|
372 |
test(nRes==KErrNone);
|
|
373 |
|
|
374 |
if(drvInfo.iDriveAtt & (KDriveAttRom | KDriveAttRedirected | KDriveAttSubsted))
|
|
375 |
{
|
|
376 |
test.Printf(_L("Can't test on this drive!\n"));
|
|
377 |
return;
|
|
378 |
}
|
|
379 |
|
|
380 |
TMediaSerialNumber serNum;
|
|
381 |
|
|
382 |
//-- test Media Serial Number on unexisting drive
|
|
383 |
{
|
|
384 |
for(TInt drvNum=EDriveA; drvNum<=EDriveZ; ++drvNum)
|
|
385 |
{
|
|
386 |
TDriveInfo drvInfo;
|
|
387 |
if(KErrNone==TheFs.Drive(drvInfo, drvNum) && drvInfo.iType==EMediaNotPresent)
|
|
388 |
{
|
|
389 |
// found a non-extant drive, test it...
|
|
390 |
nRes = TheFs.GetMediaSerialNumber(serNum, drvNum);
|
|
391 |
test(nRes == KErrNotReady);
|
|
392 |
break;
|
|
393 |
}
|
|
394 |
}
|
|
395 |
}
|
|
396 |
|
|
397 |
nRes = TheFs.GetMediaSerialNumber(serNum, currDrvNum);
|
|
398 |
if(nRes != KErrNone)
|
|
399 |
{
|
|
400 |
test.Printf(_L("Test is inconsintent on this drive!\n"));
|
|
401 |
return;
|
|
402 |
}
|
|
403 |
|
|
404 |
TFileName substPath; //-- path to the directory to substitute
|
|
405 |
const TInt KSubstDrv = EDriveO; //-- drive to be substituted
|
|
406 |
|
|
407 |
//-- make directory, which will be substituted ad a drive
|
|
408 |
substPath.Format(_L("%c:\\SubstDrv1\\"), (TUint8)'A'+currDrvNum);
|
|
409 |
MakeDir(substPath);
|
|
410 |
|
|
411 |
nRes = TheFs.SetSubst(substPath, KSubstDrv);
|
|
412 |
test(nRes == KErrNone);
|
|
413 |
|
|
414 |
//-- an attempt to obtain Media Serial Number on a substed drive shall result in KErrNotSupported
|
|
415 |
nRes = TheFs.GetMediaSerialNumber(serNum, KSubstDrv);
|
|
416 |
test(nRes == KErrNotSupported);
|
|
417 |
|
|
418 |
//-- delete substed drive
|
|
419 |
nRes = TheFs.SetSubst(_L(""), KSubstDrv);
|
|
420 |
test(nRes == KErrNone);
|
|
421 |
}
|
|
422 |
|
|
423 |
|
|
424 |
//----------------------------------------------------------------------------------------------
|
|
425 |
//! @SYMTestCaseID PBASE-t_fsys-0317
|
|
426 |
//! @SYMTestType CIT
|
|
427 |
//! @SYMPREQ CR0882
|
|
428 |
//! @SYMTestCaseDesc This test case is testing querying file system sub type name using
|
|
429 |
//! RFs::QueryVolumeInfoExt() API.
|
|
430 |
//! @SYMTestActions 1 querys sub type of file system on volumes mounted with 'Fat' file system
|
|
431 |
//! 2 querys sub type of file system on volumes mounted with 'Lffs' file system
|
|
432 |
//! 3 querys sub type of file system on volumes mounted with 'rofs' file system
|
|
433 |
//! 4 querys sub type of file system on volumes mounted with other file systems
|
|
434 |
//! @SYMTestExpectedResults
|
|
435 |
//! 1 returned error code should be KErrNone, descriptor should match 'FAT12' or 'FAT16' or 'FAT32'
|
|
436 |
//! 2 returned error code should be KErrNotSupported, descriptor should match 'Lffs'
|
|
437 |
//! 3 returned error code should be KErrNotSupported, descriptor should match 'rofs'
|
|
438 |
//! 4 returned error code should be KErrNotSupported, descriptor length should not be zero
|
|
439 |
//! @SYMTestPriority High
|
|
440 |
//! @SYMTestStatus Implemented
|
|
441 |
//----------------------------------------------------------------------------------------------
|
|
442 |
static void TestFileSystemSubTypeQuery()
|
|
443 |
{
|
|
444 |
test.Next(_L("Test querying sub type of the mounted file system"));
|
|
445 |
TFSName fsName;
|
|
446 |
TPckgBuf<TFSName> subName;
|
|
447 |
TInt i, r;
|
|
448 |
TDriveInfo driveInfo;
|
|
449 |
TPckgBuf<TBool> fDrvSyncBuf;
|
|
450 |
|
|
451 |
|
|
452 |
for(i = EDriveA; i <= EDriveZ; ++i, subName.Zero())
|
|
453 |
{
|
|
454 |
r = TheFs.FileSystemName(fsName, i);
|
|
455 |
if (r == KErrNone)
|
|
456 |
{
|
|
457 |
test.Printf(_L("Tested on drive: %c.\n"), (char)(i+'A'));
|
|
458 |
r=TheFs.Drive(driveInfo, i);
|
|
459 |
test(r==KErrNone);
|
|
460 |
|
|
461 |
if (driveInfo.iType==EMediaNotPresent)
|
|
462 |
{
|
|
463 |
test.Printf(_L("The media is not present.\n"));
|
|
464 |
r = TheFs.QueryVolumeInfoExt(i, EFileSystemSubType, subName);
|
|
465 |
test(r == KErrNone || r == KErrNotReady);
|
|
466 |
}
|
|
467 |
else if (driveInfo.iType==EMediaCdRom)
|
|
468 |
{
|
|
469 |
test.Printf(_L("CD ROM with no media will report not ready!\n"));
|
|
470 |
r = TheFs.QueryVolumeInfoExt(i, EFileSystemSubType, subName);
|
|
471 |
test(r == KErrNotReady);
|
|
472 |
}
|
|
473 |
else
|
|
474 |
{
|
|
475 |
r = TheFs.QueryVolumeInfoExt(i, EFileSystemSubType, subName);
|
|
476 |
test_KErrNone(r);
|
|
477 |
|
|
478 |
//-- test EIsDriveSync command
|
|
479 |
r = TheFs.QueryVolumeInfoExt(i, EIsDriveSync, fDrvSyncBuf);
|
|
480 |
test(r == KErrNone);
|
|
481 |
if(fDrvSyncBuf())
|
|
482 |
test.Printf(_L("The drive is Synchronous.\n"));
|
|
483 |
else
|
|
484 |
test.Printf(_L("The drive is Asynchronous.\n"));
|
|
485 |
|
|
486 |
//-----------------
|
|
487 |
|
|
488 |
// if Fat, testing returning sub type name
|
|
489 |
if (fsName.CompareF(KFileSystemName_FAT)==0)
|
|
490 |
{
|
|
491 |
test(r == KErrNone);
|
|
492 |
test(subName().CompareF(KFSSubType_FAT12)==0 ||
|
|
493 |
subName().CompareF(KFSSubType_FAT16)==0 ||
|
|
494 |
subName().CompareF(KFSSubType_FAT32)==0);
|
|
495 |
continue;
|
|
496 |
}
|
|
497 |
|
|
498 |
// if Lffs, testing returning file system name
|
|
499 |
if (fsName.CompareF(_L("Lffs"))==0)
|
|
500 |
{
|
|
501 |
test(r == KErrNone);
|
|
502 |
test(subName().CompareF(_L("Lffs"))==0);
|
|
503 |
continue;
|
|
504 |
}
|
|
505 |
// if rofs, testing returning file system name
|
|
506 |
if (fsName.CompareF(_L("rofs"))==0)
|
|
507 |
{
|
|
508 |
test(r == KErrNone);
|
|
509 |
test(subName().CompareF(_L("rofs"))==0);
|
|
510 |
continue;
|
|
511 |
}
|
|
512 |
// if Composite, testing returning file system name
|
|
513 |
if (fsName.CompareF(_L("Composite"))==0)
|
|
514 |
{
|
|
515 |
test(r == KErrNone);
|
|
516 |
test(subName().CompareF(_L("Composite"))==0);
|
|
517 |
continue;
|
|
518 |
}
|
|
519 |
|
|
520 |
// else
|
|
521 |
test(r == KErrNone);
|
|
522 |
test(subName().Length()!=0);
|
|
523 |
|
|
524 |
}
|
|
525 |
}
|
|
526 |
}
|
|
527 |
}
|
|
528 |
|
|
529 |
//----------------------------------------------------------------------------------------------
|
|
530 |
//! @SYMTestCaseID PBASE-t_fsys-0318
|
|
531 |
//! @SYMTestType CIT
|
|
532 |
//! @SYMPREQ CR0882
|
|
533 |
//! @SYMTestCaseDesc This test case is testing querying file system's cluster size using
|
|
534 |
//! RFs::QueryVolumeInfoExt() API.
|
|
535 |
//! @SYMTestActions 1 querys cluster size of file system on volumes mounted with 'Fat' file system
|
|
536 |
//! 2 querys cluster size of file system on volumes mounted with 'Lffs' file system
|
|
537 |
//! 3 querys cluster size of file system on volumes mounted with other file systems
|
|
538 |
//! @SYMTestExpectedResults
|
|
539 |
//! 1 returned error code should be KErrNone, cluster size should be non-zero
|
|
540 |
//! 2 returned error code should be KErrNone, cluster size should be 512
|
|
541 |
//! 3 returned error code should be KErrNone, cluster size should be KErrNotSupported
|
|
542 |
//! @SYMTestPriority High
|
|
543 |
//! @SYMTestStatus Implemented
|
|
544 |
//----------------------------------------------------------------------------------------------
|
|
545 |
static void TestFileSystemClusterSizeQuery()
|
|
546 |
{
|
|
547 |
test.Next(_L("Test querying cluster size information of the mounted file system"));
|
|
548 |
TFullName fsName;
|
|
549 |
TPckgBuf<TVolumeIOParamInfo> ioInfo;
|
|
550 |
TInt i, r;
|
|
551 |
TDriveInfo driveInfo;
|
|
552 |
for(i = EDriveA; i <= EDriveZ; ++i)
|
|
553 |
{
|
|
554 |
r = TheFs.FileSystemName(fsName, i);
|
|
555 |
if (r == KErrNone)
|
|
556 |
{
|
|
557 |
test.Printf(_L("Tested on drive: %c.\n"), (char)(i+'A'));
|
|
558 |
|
|
559 |
r=TheFs.Drive(driveInfo, i);
|
|
560 |
test(r==KErrNone);
|
|
561 |
// if no media present
|
|
562 |
if (driveInfo.iType==EMediaNotPresent)
|
|
563 |
{
|
|
564 |
r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo);
|
|
565 |
test(r == KErrNone || r == KErrNotReady);
|
|
566 |
}
|
|
567 |
else if (driveInfo.iType==EMediaCdRom)
|
|
568 |
{
|
|
569 |
test.Printf(_L("CD ROM with no media!\n"));
|
|
570 |
r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo);
|
|
571 |
test(r == KErrNone);
|
|
572 |
}
|
|
573 |
else
|
|
574 |
{
|
|
575 |
r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo);
|
|
576 |
test(KErrNone == r);
|
|
577 |
// if Fat
|
|
578 |
if (fsName.CompareF(KFileSystemName_FAT)==0)
|
|
579 |
{
|
|
580 |
test(ioInfo().iClusterSize != 0);
|
|
581 |
continue;
|
|
582 |
}
|
|
583 |
// else if Lffs
|
|
584 |
if (fsName.CompareF(_L("Lffs"))==0)
|
|
585 |
{
|
|
586 |
TBusLocalDrive drive;
|
|
587 |
TBool changeFlag = EFalse;
|
|
588 |
TInt locDriveNumber;
|
|
589 |
TLocalDriveCaps DriveCaps;
|
|
590 |
TLocalDriveCapsV7 DriveCapsV7;
|
|
591 |
for(locDriveNumber = 0; locDriveNumber < KMaxLocalDrives; locDriveNumber++)
|
|
592 |
{
|
|
593 |
r = drive.Connect(locDriveNumber,changeFlag);
|
|
594 |
if(r==KErrNone)
|
|
595 |
{
|
|
596 |
|
|
597 |
TPckg<TLocalDriveCaps> capsPckg(DriveCaps);
|
|
598 |
r=drive.Caps(capsPckg);
|
|
599 |
if((r==KErrNone) && (DriveCaps.iFileSystemId==KDriveFileSysLFFS))
|
|
600 |
{
|
|
601 |
break;
|
|
602 |
}
|
|
603 |
drive.Disconnect();
|
|
604 |
}
|
|
605 |
}
|
|
606 |
TPckg<TLocalDriveCapsV7> capsPckg(DriveCapsV7);
|
|
607 |
r=drive.Caps(capsPckg);
|
|
608 |
test(r==KErrNone);
|
|
609 |
drive.Disconnect();
|
|
610 |
if(DriveCapsV7.iObjectModeSize == 0)
|
|
611 |
{
|
|
612 |
test(ioInfo().iClusterSize == 512);
|
|
613 |
continue;
|
|
614 |
}
|
|
615 |
else
|
|
616 |
{
|
|
617 |
test((TUint32)(ioInfo().iClusterSize) == DriveCapsV7.iObjectModeSize);
|
|
618 |
continue;
|
|
619 |
}
|
|
620 |
}
|
|
621 |
// else
|
|
622 |
//-- we can not suggest anything about unknown filesystem, thus do not check the result.
|
|
623 |
//test(ioInfo().iClusterSize == KErrNotSupported);
|
|
624 |
|
|
625 |
}
|
|
626 |
}
|
|
627 |
}
|
|
628 |
}
|
|
629 |
|
|
630 |
//----------------------------------------------------------------------------------------------
|
|
631 |
//! @SYMTestCaseID PBASE-t_fsys-0319
|
|
632 |
//! @SYMTestType CIT
|
|
633 |
//! @SYMPREQ CR0882
|
|
634 |
//! @SYMTestCaseDesc This test case is testing querying block size of underlying media using
|
|
635 |
//! RFs::QueryVolumeInfoExt() API.
|
|
636 |
//! @SYMTestActions 1 querys block size on volumes mounted with MMC card type of media
|
|
637 |
//! 2 querys block size on volumes mounted with RAM type of media
|
|
638 |
//! 3 querys block size on volumes mounted with NOR flash type of media
|
|
639 |
//! 4 querys block size on volumes mounted with Nand flash (code) type of media
|
|
640 |
//! 5 querys block size on volumes mounted with Nand flash (data) type of media
|
|
641 |
//! @SYMTestExpectedResults
|
|
642 |
//! 1 returned error code should be KErrNone, block size should be 512
|
|
643 |
//! 2 returned error code should be KErrNone, block size should be KDefaultVolumeBlockSize
|
|
644 |
//! 3 returned error code should be KErrNone, block size should be KDefaultVolumeBlockSize
|
|
645 |
//! 4 returned error code should be KErrNone, block size should be 512
|
|
646 |
//! 5 returned error code should be KErrNone, block size should be 512
|
|
647 |
//! @SYMTestPriority High
|
|
648 |
//! @SYMTestStatus Implemented
|
|
649 |
//----------------------------------------------------------------------------------------------
|
|
650 |
static void TestMediaBlockSizeQuery()
|
|
651 |
{
|
|
652 |
test.Next(_L("Test querying block size information of the underlying media"));
|
|
653 |
#if defined(__WINS__)
|
|
654 |
test.Printf(_L("This test case runs on hardware only"));
|
|
655 |
return;
|
|
656 |
|
|
657 |
#else // test runs on hardware only.
|
|
658 |
TFSName fsName;
|
|
659 |
TPckgBuf<TVolumeIOParamInfo> ioInfo;
|
|
660 |
TInt i, r;
|
|
661 |
TDriveInfo driveInfo;
|
|
662 |
for(i = EDriveA; i <= EDriveZ; ++i)
|
|
663 |
{
|
|
664 |
r = TheFs.FileSystemName(fsName, i);
|
|
665 |
if (r == KErrNone)
|
|
666 |
{
|
|
667 |
test.Printf(_L("Tested on drive: %c.\n"), (char)(i+'A'));
|
|
668 |
r=TheFs.Drive(driveInfo, i);
|
|
669 |
test(r==KErrNone);
|
|
670 |
// if no media present
|
|
671 |
if (driveInfo.iType==EMediaNotPresent)
|
|
672 |
{
|
|
673 |
r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo);
|
|
674 |
test(r == KErrNone || r == KErrNotReady);
|
|
675 |
}
|
|
676 |
else
|
|
677 |
{
|
|
678 |
r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo);
|
|
679 |
test(KErrNone == r);
|
|
680 |
// if MMC, test block size >= 512;
|
|
681 |
// (Version 4.3 MMC cards introduce the concept of a "Super Page" which should be used as
|
|
682 |
// guide when calculating the cluster size. For these cards the reported block size may be
|
|
683 |
// any multiple of 512).
|
|
684 |
if ((driveInfo.iType == EMediaHardDisk) &&
|
|
685 |
(driveInfo.iDriveAtt & KDriveAttRemovable) &&
|
|
686 |
(driveInfo.iDriveAtt & KDriveAttLocal))
|
|
687 |
{
|
|
688 |
test(ioInfo().iBlockSize >= 512);
|
|
689 |
continue;
|
|
690 |
}
|
|
691 |
// if RAM, test block size == 1;
|
|
692 |
if ((driveInfo.iType == EMediaRam) &&
|
|
693 |
(driveInfo.iDriveAtt & KDriveAttLocal) &&
|
|
694 |
(driveInfo.iDriveAtt & KDriveAttInternal))
|
|
695 |
{
|
|
696 |
test(ioInfo().iBlockSize == 1);
|
|
697 |
continue;
|
|
698 |
}
|
|
699 |
// if NOR flash, test block size == 512 (default block size);
|
|
700 |
if ((driveInfo.iType == EMediaFlash) &&
|
|
701 |
(driveInfo.iDriveAtt & KDriveAttLocal) &&
|
|
702 |
(driveInfo.iDriveAtt & KDriveAttInternal))
|
|
703 |
{
|
|
704 |
TBusLocalDrive drive;
|
|
705 |
TBool changeFlag = EFalse;
|
|
706 |
TInt locDriveNumber;
|
|
707 |
TLocalDriveCaps DriveCaps;
|
|
708 |
TLocalDriveCapsV7 DriveCapsV7;
|
|
709 |
for(locDriveNumber = 0; locDriveNumber < KMaxLocalDrives; locDriveNumber++)
|
|
710 |
{
|
|
711 |
r = drive.Connect(locDriveNumber,changeFlag);
|
|
712 |
if(r==KErrNone)
|
|
713 |
{
|
|
714 |
TPckg<TLocalDriveCaps> capsPckg(DriveCaps);
|
|
715 |
r=drive.Caps(capsPckg);
|
|
716 |
if((r==KErrNone) && (DriveCaps.iFileSystemId==KDriveFileSysLFFS))
|
|
717 |
{
|
|
718 |
|
|
719 |
break;
|
|
720 |
}
|
|
721 |
drive.Disconnect();
|
|
722 |
}
|
|
723 |
}
|
|
724 |
TPckg<TLocalDriveCapsV7> capsPckg(DriveCapsV7);
|
|
725 |
r=drive.Caps(capsPckg);
|
|
726 |
test(r==KErrNone);
|
|
727 |
if ((fsName.CompareF(_L("Lffs"))==0) && (DriveCapsV7.iObjectModeSize != 0))
|
|
728 |
{
|
|
729 |
|
|
730 |
test(ioInfo().iBlockSize == (TInt) DriveCapsV7.iObjectModeSize);
|
|
731 |
continue;
|
|
732 |
}
|
|
733 |
else
|
|
734 |
{
|
|
735 |
test(ioInfo().iBlockSize == (TInt) KDefaultVolumeBlockSize);
|
|
736 |
continue;
|
|
737 |
}
|
|
738 |
}
|
|
739 |
// if Nand flash (with Fat file system), test block size == 512 (small-block) or 2048 (large-block)
|
|
740 |
if ((driveInfo.iType == EMediaNANDFlash) &&
|
|
741 |
(driveInfo.iDriveAtt & KDriveAttLocal) &&
|
|
742 |
(driveInfo.iDriveAtt & KDriveAttInternal))
|
|
743 |
{
|
|
744 |
test(ioInfo().iBlockSize == 512 || ioInfo().iBlockSize == 2048);
|
|
745 |
continue;
|
|
746 |
}
|
|
747 |
}
|
|
748 |
}
|
|
749 |
}
|
|
750 |
#endif // __WINS__
|
|
751 |
}
|
|
752 |
|
|
753 |
//----------------------------------------------------------------------------------------------
|
|
754 |
//! @SYMTestCaseID PBASE-t_fsys-0320
|
|
755 |
//! @SYMTestType CIT
|
|
756 |
//! @SYMPREQ CR0882
|
|
757 |
//! @SYMTestCaseDesc This test case is testing wrapper API RFs::FileSystemSubType() has the same
|
|
758 |
//! behaviours as RFs::QueryVolumeInfoExt()
|
|
759 |
//! @SYMTestActions 1 querys file system sub type name by both APIs
|
|
760 |
//! @SYMTestExpectedResults
|
|
761 |
//! 1 returned error codes and descriptors of both API should be identical
|
|
762 |
//! @SYMTestPriority High
|
|
763 |
//! @SYMTestStatus Implemented
|
|
764 |
//----------------------------------------------------------------------------------------------
|
|
765 |
static void TestFileSystemSubType()
|
|
766 |
{
|
|
767 |
test.Next(_L("Test wrapper API RFs::FileSystemSubType()'s behaviour"));
|
|
768 |
TFSName fsName;
|
|
769 |
TPckgBuf<TFSName> subName;
|
|
770 |
TInt r;
|
|
771 |
TFSName subName1;
|
|
772 |
TInt r1;
|
|
773 |
|
|
774 |
for(TInt i = EDriveA; i <= EDriveZ; ++i)
|
|
775 |
{
|
|
776 |
r = TheFs.FileSystemName(fsName, i);
|
|
777 |
if (r == KErrNone)
|
|
778 |
{
|
|
779 |
test.Printf(_L("Tested on drive: %c.\n"), (char)(i+'A'));
|
|
780 |
r = TheFs.QueryVolumeInfoExt(i, EFileSystemSubType, subName);
|
|
781 |
r1 = TheFs.FileSystemSubType(i, subName1);
|
|
782 |
test(r==r1);
|
|
783 |
if (subName().Length())
|
|
784 |
{
|
|
785 |
test(subName().CompareF(subName1)==0);
|
|
786 |
}
|
|
787 |
else
|
|
788 |
{
|
|
789 |
test(subName1.Length()==0);
|
|
790 |
}
|
|
791 |
}
|
|
792 |
}
|
|
793 |
}
|
|
794 |
|
|
795 |
//----------------------------------------------------------------------------------------------
|
|
796 |
//! @SYMTestCaseID PBASE-t_fsys-0321
|
|
797 |
//! @SYMTestType CIT
|
|
798 |
//! @SYMPREQ CR0882
|
|
799 |
//! @SYMTestCaseDesc This test case is testing wrapper API RFs::VolumeIOParam() has the same
|
|
800 |
//! behaviours as RFs::QueryVolumeInfoExt()
|
|
801 |
//! @SYMTestActions 1 querys volume IO params by both APIs
|
|
802 |
//! @SYMTestExpectedResults
|
|
803 |
//! 1 returned error codes and IO param values of both API should be identical
|
|
804 |
//! @SYMTestPriority High
|
|
805 |
//! @SYMTestStatus Implemented
|
|
806 |
//----------------------------------------------------------------------------------------------
|
|
807 |
static void TestVolumeIOParam()
|
|
808 |
{
|
|
809 |
test.Next(_L("Test wrapper API RFs::VolumeIOParam()'s behaviour"));
|
|
810 |
TFSName fsName;
|
|
811 |
TPckgBuf<TVolumeIOParamInfo> ioInfo;
|
|
812 |
TInt r;
|
|
813 |
TVolumeIOParamInfo ioInfo1;
|
|
814 |
TInt r1;
|
|
815 |
|
|
816 |
for(TInt i = EDriveA; i <= EDriveZ; ++i)
|
|
817 |
{
|
|
818 |
r = TheFs.FileSystemName(fsName, i);
|
|
819 |
if (r == KErrNone)
|
|
820 |
{
|
|
821 |
test.Printf(_L("Tested on drive: %c.\n"), (char)(i+'A'));
|
|
822 |
r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo);
|
|
823 |
r1 = TheFs.VolumeIOParam(i, ioInfo1);
|
|
824 |
test(r==r1);
|
|
825 |
test(ioInfo().iBlockSize == ioInfo1.iBlockSize);
|
|
826 |
test(ioInfo().iClusterSize == ioInfo1.iClusterSize);
|
|
827 |
test(ioInfo().iRecReadBufSize == ioInfo1.iRecReadBufSize);
|
|
828 |
test(ioInfo().iRecWriteBufSize == ioInfo1.iRecWriteBufSize);
|
|
829 |
}
|
|
830 |
}
|
|
831 |
}
|
|
832 |
|
|
833 |
|
|
834 |
//----------------------------------------------------------------------------------------------
|
|
835 |
//! @SYMTestCaseID PBASE-t_fsys-0322
|
|
836 |
//! @SYMTestType CIT
|
|
837 |
//! @SYMPREQ CR0882
|
|
838 |
//! @SYMTestCaseDesc This test case is testing RFs::QueryVolumeInfoExt() API on a testing file system
|
|
839 |
//! @SYMTestActions 0 mounts testing file system on a certain drive
|
|
840 |
//! 1 querys file system's sub type name on the drive under testing
|
|
841 |
//! 2 querys file system's cluster size on the drive under testing
|
|
842 |
//! @SYMTestExpectedResults
|
|
843 |
//! 1 returned error code should be KErrNone, sub type name should match 'Test3SubType'
|
|
844 |
//! 2 returned error code should be KErrNone, cluster size should equal 1024
|
|
845 |
//! @SYMTestPriority High
|
|
846 |
//! @SYMTestStatus Implemented
|
|
847 |
//----------------------------------------------------------------------------------------------
|
|
848 |
static void TestQueryVolumeInfoExtOnTestFS(TInt aDrive)
|
|
849 |
{
|
|
850 |
if (aDrive==EDriveC) // Can't test on C:
|
|
851 |
return;
|
|
852 |
|
|
853 |
TInt r;
|
|
854 |
|
|
855 |
test.Printf(_L("Tested on drive: %c.\n"), (char)(aDrive+'A'));
|
|
856 |
|
|
857 |
// Mount a new CTestFileSystem on the drive under test
|
|
858 |
test.Next(_L("Test RFs::QueryVolumeInfoExt() on Testing File System"));
|
|
859 |
r = TheFs.AddFileSystem(_L("T_TFSYS3"));
|
|
860 |
if (r != KErrNone && r != KErrAlreadyExists)
|
|
861 |
{
|
|
862 |
test.Printf(_L("error=%d"),r);
|
|
863 |
test(EFalse);
|
|
864 |
}
|
|
865 |
TFSName oldFs;
|
|
866 |
r = TheFs.FileSystemName(oldFs,aDrive);
|
|
867 |
test(r==KErrNone);
|
|
868 |
r = TheFs.DismountFileSystem(oldFs,aDrive);
|
|
869 |
if (r != KErrNone)
|
|
870 |
{
|
|
871 |
test.Printf(_L("Error = %d"),r);
|
|
872 |
test(EFalse);
|
|
873 |
}
|
|
874 |
r = TheFs.MountFileSystem(_L("Test3"),aDrive);
|
|
875 |
test(r==KErrNone);
|
|
876 |
TFSName newFs;
|
|
877 |
r = TheFs.FileSystemName(newFs,aDrive);
|
|
878 |
test(r==KErrNone);
|
|
879 |
test(newFs.Compare(_L("Test3"))==0);
|
|
880 |
|
|
881 |
// Sub type name query:
|
|
882 |
TPckgBuf<TFSName> subNameP;
|
|
883 |
r = TheFs.QueryVolumeInfoExt(aDrive, EFileSystemSubType, subNameP);
|
|
884 |
test(r==KErrNone);
|
|
885 |
test(subNameP() == _L("Test3SubType"));
|
|
886 |
|
|
887 |
// Cluster size querys:
|
|
888 |
TPckgBuf<TVolumeIOParamInfo> ioInfoP;
|
|
889 |
r = TheFs.QueryVolumeInfoExt(aDrive, EIOParamInfo, ioInfoP);
|
|
890 |
test(r==KErrNone);
|
|
891 |
test(ioInfoP().iClusterSize==1024);
|
|
892 |
|
|
893 |
// Mount the original file system back
|
|
894 |
r=TheFs.DismountFileSystem(newFs,aDrive);
|
|
895 |
test(r==KErrNone);
|
|
896 |
r=TheFs.MountFileSystem(oldFs,aDrive);
|
|
897 |
test(r==KErrNone);
|
|
898 |
|
|
899 |
r=TheFs.RemoveFileSystem(_L("Test3"));
|
|
900 |
if(r!=KErrNone)
|
|
901 |
{
|
|
902 |
test.Printf(_L("error=%d"),r);
|
|
903 |
test(EFalse);
|
|
904 |
}
|
|
905 |
}
|
|
906 |
|
|
907 |
|
|
908 |
//----------------------------------------------------------------------------------------------
|
|
909 |
/**
|
|
910 |
Test remounting the file system with objects opened.
|
|
911 |
scenario:
|
|
912 |
1. create a file
|
|
913 |
2. open it.
|
|
914 |
3. forcedly remount the file system
|
|
915 |
4. read this file (this will imply remounting the filesystem)
|
|
916 |
*/
|
|
917 |
static void TestRemountFSWithOpenedObjects()
|
|
918 |
{
|
|
919 |
test.Next(_L("Testing forcedly remounting FS with objects opened.\n"));
|
|
920 |
|
|
921 |
TInt nRes;
|
|
922 |
|
|
923 |
//-- 1. create a file
|
|
924 |
_LIT(KFile, "\\test_file.file");
|
|
925 |
const TUint KFileSz = 5000;
|
|
926 |
|
|
927 |
nRes = CreateCheckableStuffedFile(TheFs, KFile, KFileSz);
|
|
928 |
test_KErrNone(nRes);
|
|
929 |
|
|
930 |
RFile file;
|
|
931 |
|
|
932 |
//-- 2. open this file
|
|
933 |
nRes = file.Open(TheFs, KFile, EFileRead);
|
|
934 |
test_KErrNone(nRes);
|
|
935 |
|
|
936 |
//-- 2.1 try to dismount the FS, it must fail because of the opened object.
|
|
937 |
TBuf<40> fsName;
|
|
938 |
nRes = TheFs.FileSystemName(fsName, CurrentDrive());
|
|
939 |
test_KErrNone(nRes);
|
|
940 |
|
|
941 |
nRes = TheFs.DismountFileSystem(fsName, CurrentDrive());
|
|
942 |
test(nRes == KErrInUse);
|
|
943 |
|
|
944 |
|
|
945 |
//-- 3. forcedly remount the drive
|
|
946 |
nRes = TheFs.RemountDrive(CurrentDrive());
|
|
947 |
if(nRes == KErrNotSupported)
|
|
948 |
{//-- this feature is not supported and the test is inconsistent.
|
|
949 |
test.Printf(_L("RemountDrive() is not supported, the test is inconsistent!"));
|
|
950 |
|
|
951 |
//-- remounting must work at least on MMC drives
|
|
952 |
const TBool isFAT = Is_Fat(TheFs, CurrentDrive());
|
|
953 |
|
|
954 |
TDriveInfo driveInfo;
|
|
955 |
nRes = TheFs.Drive(driveInfo, CurrentDrive());
|
|
956 |
test_KErrNone(nRes);
|
|
957 |
|
|
958 |
test(!isFAT || (!(driveInfo.iDriveAtt & KDriveAttRemovable)));
|
|
959 |
|
|
960 |
}
|
|
961 |
else
|
|
962 |
{
|
|
963 |
test_KErrNone(nRes);
|
|
964 |
}
|
|
965 |
|
|
966 |
User::After(500*K1mSec);
|
|
967 |
|
|
968 |
//-- 4. read this file. The FS will be remounted and the read must be OK.
|
|
969 |
TBuf8<40> buf;
|
|
970 |
nRes = file.Read(0, buf, 30);
|
|
971 |
test_KErrNone(nRes);
|
|
972 |
|
|
973 |
file.Close();
|
|
974 |
|
|
975 |
//-- 5. verify the file, just in case.
|
|
976 |
nRes = VerifyCheckableFile(TheFs, KFile);
|
|
977 |
test_KErrNone(nRes);
|
|
978 |
|
|
979 |
//-- 6. delete the file
|
|
980 |
TheFs.Delete(KFile);
|
|
981 |
|
|
982 |
}
|
|
983 |
//----------------------------------------------------------------------------------------------
|
|
984 |
static void TestFileSystem_MaxSupportedFileSizeQuery()
|
|
985 |
{
|
|
986 |
test.Next(_L("Test querying max. supported file size on this file system"));
|
|
987 |
TFullName fsName;
|
|
988 |
TPckgBuf<TVolumeIOParamInfo> ioInfo;
|
|
989 |
TVolumeIOParamInfo& volInfo = ioInfo();
|
|
990 |
|
|
991 |
const TInt drvNo=CurrentDrive();
|
|
992 |
|
|
993 |
TInt nRes;
|
|
994 |
|
|
995 |
nRes = TheFs.FileSystemName(fsName, drvNo);
|
|
996 |
test_KErrNone(nRes);
|
|
997 |
|
|
998 |
nRes = TheFs.QueryVolumeInfoExt(drvNo, EIOParamInfo, ioInfo);
|
|
999 |
test_KErrNone(nRes);
|
|
1000 |
|
|
1001 |
test.Printf(_L("FS:'%S' Max File Size:0x%LX\n"), &fsName, volInfo.iMaxSupportedFileSize);
|
|
1002 |
if(volInfo.iMaxSupportedFileSize == KMaxTUint64)
|
|
1003 |
{
|
|
1004 |
test.Printf(_L("Max File Size query isn't supported by this FS\n"));
|
|
1005 |
}
|
|
1006 |
|
|
1007 |
|
|
1008 |
//-- check the value for FAT FS only.
|
|
1009 |
if(Is_Fat(TheFs, drvNo))
|
|
1010 |
{
|
|
1011 |
test(volInfo.iMaxSupportedFileSize == KMaxSupportedFatFileSize);
|
|
1012 |
}
|
|
1013 |
|
|
1014 |
}
|
|
1015 |
|
|
1016 |
//----------------------------------------------------------------------------------------------
|
|
1017 |
GLDEF_C void CallTestsL()
|
|
1018 |
//
|
|
1019 |
// Do all tests
|
|
1020 |
//
|
|
1021 |
{
|
|
1022 |
|
|
1023 |
//-- set up console output
|
|
1024 |
Fat_Test_Utils::SetConsole(test.Console());
|
|
1025 |
|
|
1026 |
TInt drive=CurrentDrive();
|
|
1027 |
|
|
1028 |
PrintDrvInfo(TheFs, drive);
|
|
1029 |
|
|
1030 |
//Do not run this test on the NAND drive, as
|
|
1031 |
//this has the FTL mounted as a primary extension
|
|
1032 |
//which causes the test to fail
|
|
1033 |
#if defined(__WINS__)
|
|
1034 |
if (drive==EDriveU)
|
|
1035 |
return;
|
|
1036 |
#else
|
|
1037 |
TDriveInfo driveInfo;
|
|
1038 |
TheFs.Drive(driveInfo,drive);
|
|
1039 |
if (driveInfo.iType == EMediaNANDFlash)
|
|
1040 |
{
|
|
1041 |
return;
|
|
1042 |
}
|
|
1043 |
#endif
|
|
1044 |
|
|
1045 |
//---------------------------------------
|
|
1046 |
|
|
1047 |
TestFileSystemNames();
|
|
1048 |
TestDismountFileSystem(CurrentDrive());
|
|
1049 |
#if defined(__EPOC32__)
|
|
1050 |
TestFileSystem(CurrentDrive());
|
|
1051 |
#endif
|
|
1052 |
|
|
1053 |
TestMountInvalidDrive();
|
|
1054 |
|
|
1055 |
TestMountingBrokenMedia(CurrentDrive());
|
|
1056 |
TestSubstDriveMediaSerialNumber();
|
|
1057 |
|
|
1058 |
TestFileSystemSubTypeQuery();
|
|
1059 |
TestFileSystemClusterSizeQuery();
|
|
1060 |
TestMediaBlockSizeQuery();
|
|
1061 |
TestFileSystemSubType();
|
|
1062 |
TestVolumeIOParam();
|
|
1063 |
TestQueryVolumeInfoExtOnTestFS(CurrentDrive());
|
|
1064 |
|
|
1065 |
TestFileSystem_MaxSupportedFileSizeQuery();
|
|
1066 |
|
|
1067 |
TestRemountFSWithOpenedObjects();
|
|
1068 |
|
|
1069 |
|
|
1070 |
}
|