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