author | hgs |
Wed, 22 Sep 2010 10:53:45 +0100 | |
changeset 271 | dc268b18d709 |
parent 36 | 538db54a451d |
permissions | -rw-r--r-- |
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 |
// |
|
15 |
// Testing "automounter" filesystem plugin functionality. |
|
16 |
// |
|
17 |
// |
|
18 |
||
19 |
/** |
|
20 |
@file |
|
21 |
*/ |
|
22 |
||
23 |
#define __E32TEST_EXTENSION__ |
|
24 |
||
25 |
#include <f32file.h> |
|
26 |
#include <e32test.h> |
|
27 |
#include <e32math.h> |
|
28 |
#include <e32property.h> |
|
29 |
#include <f32dbg.h> |
|
30 |
||
31 |
#include "filesystem_fat.h" |
|
32 |
#include "filesystem_automounter.h" |
|
33 |
||
34 |
||
35 |
#include "t_server.h" |
|
36 |
#include "fat_utils.h" |
|
37 |
||
38 |
using namespace Fat_Test_Utils; |
|
39 |
||
40 |
||
41 |
||
42 |
||
43 |
RTest test(_L("T_Automounter")); |
|
44 |
||
45 |
static TInt gDriveNum=-1; ///< drive number we are dealing with |
|
46 |
||
47 |
//------------------------------------------------------------------- |
|
48 |
//-- the debug test property string can be used to control automounter in debug mode. |
|
49 |
const TUid KThisTestSID={0x10210EB3}; ///< this EXE SID |
|
271 | 50 |
const TUint KPropKey = 0; //-- property key |
51 |
||
52 |
//------------------------------------------------------------------- |
|
53 |
/** strings for the test property that will override estart.txt setting for the automounter */ |
|
54 |
//_LIT8(KSection, "AutoMounter"); ///< section name |
|
55 |
_LIT8(KKey_ChildFsList, "AM_FSNames"); ///< a key for the CSV list of child file system names |
|
56 |
_LIT8(KProp_DefFmtFsIdx, "AM_DefFmtFsIdx");///< a key for the optional parameter that specifies the child file system index, which will be used for formatting unrecognised media |
|
57 |
||
0 | 58 |
|
59 |
//------------------------------------------------------------------- |
|
60 |
//-- Actually, for testing autoounter, it is neccessary to have at least 3 filesystems: |
|
61 |
//-- automounter itself and any 2 dirrerent filesystems that can be used as child ones. |
|
62 |
//-- Let's use FAT as a 1st child, and exFAT as 2nd. All these 3 *.fsy shall be present. |
|
63 |
||
64 |
/** automounter filesystem name */ |
|
65 |
#define KAutoMounterFSName KFileSystemName_AutoMounter |
|
66 |
_LIT(KAutoMounterFsy, "automounter.fsy"); ///< automounter *.fsy module name |
|
67 |
||
68 |
||
69 |
//-- FAT is used as a child filesystem #0 |
|
70 |
||
71 |
/** filesystem #1 name */ |
|
72 |
#define KFSName1 KFileSystemName_FAT |
|
73 |
||
74 |
#if defined(__WINS__) //-- FAT fsy name is a mess. |
|
75 |
_LIT(KFsy1, "efat32.fsy"); |
|
76 |
#else |
|
77 |
_LIT(KFsy1, "elocal.fsy"); |
|
78 |
#endif |
|
79 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
80 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
81 |
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
82 |
//-- exFAT is used as a child filesystem #1. The problem here: some poor guys might not have the exFAT at all including the header file |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
83 |
//-- "filesystem_exfat.h" that defines exFAT volume formatting structure. Fortunately for them the exFAT formatting parameters like "sectors per cluster" and |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
84 |
//-- "number of FATs" have the same layout in the data container as FAT ones. So FAT formatting structure can be used for formatting exFAT. |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
85 |
//-- The macro defines if exFAT might not be available. |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
86 |
#define EXFAT_MIGHT_NOT_BE_PRESENT |
0 | 87 |
|
88 |
/** filesystem #2 name */ |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
89 |
#ifdef EXFAT_MIGHT_NOT_BE_PRESENT |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
90 |
_LIT(KFSName2, "exFAT"); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
91 |
#else |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
92 |
#define KFSName2 KFileSystemName_exFAT |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
93 |
#include "filesystem_exfat.h" |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
94 |
using namespace FileSystem_EXFAT; |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
95 |
#endif |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
96 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
97 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
98 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
99 |
|
0 | 100 |
_LIT(KFsy2, "exfat.fsy"); ///< filesystem #2 *.fsy module name |
101 |
||
102 |
TBool automounter_Loaded = EFalse; ///< ETrue if automounter.fsy is loaded; used for correct cleanup |
|
103 |
TBool childFs1_Loaded = EFalse; ///< ETrue if child #0 *.fsy is loaded; used for correct cleanup |
|
104 |
TBool childFs2_Loaded = EFalse; ///< ETrue if child #1 *.fsy is loaded; used for correct cleanup |
|
105 |
||
106 |
TFSDescriptor orgFsDescriptor; //-- keeps parameters of the original FS |
|
107 |
||
108 |
//------------------------------------------------------------------- |
|
109 |
||
110 |
/** |
|
111 |
perform some operations to see if the file system works at all |
|
112 |
*/ |
|
113 |
void CheckFsOperations() |
|
114 |
{ |
|
115 |
TInt nRes; |
|
116 |
||
117 |
TVolumeInfo v; |
|
118 |
nRes = TheFs.Volume(v); |
|
119 |
test_KErrNone(nRes); |
|
120 |
||
121 |
_LIT(KTestDir, "\\directory1\\DIR2\\another directory\\"); |
|
122 |
MakeDir(KTestDir); |
|
123 |
||
124 |
_LIT(KTestFile, "\\this is a file to test.bin"); |
|
125 |
nRes = CreateCheckableStuffedFile(TheFs, KTestFile, 20376); |
|
126 |
test_KErrNone(nRes); |
|
127 |
||
128 |
nRes = VerifyCheckableFile(TheFs, KTestFile); |
|
129 |
test_KErrNone(nRes); |
|
130 |
||
131 |
nRes = TheFs.Delete(KTestFile); |
|
132 |
test_KErrNone(nRes); |
|
133 |
||
271 | 134 |
nRes = TheFs.CheckDisk(gSessionPath); |
135 |
test_KErrNone(nRes); |
|
136 |
||
0 | 137 |
} |
138 |
||
139 |
//------------------------------------------------------------------- |
|
140 |
||
141 |
/** |
|
142 |
Check that FileSystem1 subtype matches one of the expected |
|
143 |
*/ |
|
144 |
void CheckSubtype_FS1(const TDesC& aFsSubtype) |
|
145 |
{ |
|
146 |
_LIT(KFatSubType12, "fat12"); |
|
147 |
_LIT(KFatSubType16, "fat16"); |
|
148 |
_LIT(KFatSubType32, "fat32"); |
|
149 |
||
150 |
test(aFsSubtype.CompareF(KFatSubType12) == 0 || aFsSubtype.CompareF(KFatSubType16) == 0 || aFsSubtype.CompareF(KFatSubType32) == 0 ); |
|
151 |
} |
|
152 |
||
153 |
//------------------------------------------------------------------- |
|
154 |
||
155 |
/** |
|
156 |
Check that FileSystem2 subtype matches expected |
|
157 |
*/ |
|
158 |
void CheckSubtype_FS2(const TDesC& aFsSubtype) |
|
159 |
{ |
|
160 |
_LIT(KExFatSubType, "exFAT"); |
|
161 |
test(aFsSubtype.CompareF(KExFatSubType) == 0); |
|
162 |
} |
|
163 |
||
164 |
||
165 |
//------------------------------------------------------------------- |
|
166 |
/** |
|
167 |
Dismounts Currently mounted file system. |
|
168 |
*/ |
|
169 |
static TInt DoDismountFS() |
|
170 |
{ |
|
271 | 171 |
TFSName fsName; |
0 | 172 |
TInt nRes; |
173 |
||
174 |
nRes = TheFs.FileSystemName(fsName, gDriveNum); |
|
175 |
if(nRes == KErrNone) |
|
176 |
{ |
|
177 |
test.Printf(_L("--- Dismounting FS:%S\n"), &fsName); |
|
178 |
nRes = TheFs.DismountFileSystem(fsName, gDriveNum); |
|
179 |
return nRes; |
|
180 |
} |
|
181 |
||
182 |
return KErrNone; //-- no file system mounted |
|
183 |
} |
|
184 |
||
185 |
//------------------------------------------------------------------- |
|
186 |
/** |
|
187 |
Dismounts Currently mounted file system. |
|
188 |
*/ |
|
189 |
static void DismountFS() |
|
190 |
{ |
|
191 |
test(DoDismountFS() == KErrNone); |
|
192 |
} |
|
193 |
||
194 |
//------------------------------------------------------------------- |
|
195 |
/** |
|
196 |
Dismounts Currently mounted file system. |
|
197 |
*/ |
|
198 |
static void ForceDismountFS() |
|
199 |
{ |
|
200 |
test.Printf(_L("--- Force dismounting current FS\n")); |
|
201 |
TRequestStatus stat; |
|
202 |
TheFs.NotifyDismount(gDriveNum, stat, EFsDismountForceDismount); |
|
203 |
User::WaitForRequest(stat); |
|
271 | 204 |
//test(stat.Int() == KErrNone); |
0 | 205 |
} |
206 |
||
207 |
||
208 |
||
209 |
//------------------------------------------------------------------- |
|
210 |
/** |
|
211 |
Mount the given file system. Mounting file system doesn't mean that it will be usable. |
|
212 |
For example, KErrCorrupt can be the result if FS doesn't recognise bootsectors etc. |
|
213 |
||
214 |
@param aFsName file system name |
|
215 |
@return error code |
|
216 |
*/ |
|
217 |
static TInt DoMountFS(const TDesC& aFsName) |
|
218 |
{ |
|
219 |
TInt nRes; |
|
220 |
test.Printf(_L("+++ Mounting FS:%S\n"), &aFsName); |
|
221 |
||
222 |
TFSDescriptor newFsDescriptor = orgFsDescriptor; |
|
223 |
newFsDescriptor.iFsName = aFsName; |
|
224 |
test(!newFsDescriptor.iDriveSynch); //-- mount the given FS as asynchronous one, the automounter can't be used on a synchronous drive anyway. |
|
225 |
||
226 |
nRes = MountFileSystem(TheFs, gDriveNum, newFsDescriptor); |
|
227 |
||
228 |
if(nRes != KErrNone) |
|
229 |
{ |
|
230 |
test.Printf(_L("++> Error Mounting FS! code:%d\n"), nRes); |
|
231 |
} |
|
232 |
else |
|
233 |
{ |
|
234 |
PrintDrvInfo(TheFs, gDriveNum); |
|
235 |
} |
|
236 |
||
237 |
||
238 |
return nRes; |
|
239 |
} |
|
240 |
||
241 |
||
242 |
//------------------------------------------------------------------- |
|
243 |
/** |
|
244 |
Explicitly mount the "automounter" FS |
|
245 |
*/ |
|
246 |
static void Mount_AutomounterFS() |
|
247 |
{ |
|
248 |
DismountFS(); |
|
249 |
DoMountFS(KAutoMounterFSName); |
|
250 |
} |
|
251 |
||
252 |
//------------------------------------------------------------------- |
|
253 |
/** |
|
254 |
Explicitly mount the FileSystem1 |
|
255 |
*/ |
|
256 |
static void Mount_FileSystem1() |
|
257 |
{ |
|
258 |
DismountFS(); |
|
259 |
DoMountFS(KFSName1); |
|
260 |
||
261 |
} |
|
262 |
||
263 |
//------------------------------------------------------------------- |
|
264 |
/** |
|
265 |
Explicitly mount the FileSystem2 |
|
266 |
*/ |
|
267 |
static void Mount_FileSystem2() |
|
268 |
{ |
|
269 |
DismountFS(); |
|
270 |
DoMountFS(KFSName2); |
|
271 |
} |
|
272 |
||
273 |
//------------------------------------------------------------------- |
|
274 |
/** |
|
275 |
Just fill first 32 sectors with zeroes. |
|
276 |
The volume will require formatting after this. |
|
277 |
*/ |
|
278 |
static void CorruptDrive() |
|
279 |
{ |
|
280 |
TInt nRes; |
|
281 |
test.Printf(_L("!!! corrupting the drive...\n")); |
|
282 |
||
283 |
RRawDisk rawDisk; |
|
284 |
nRes = rawDisk.Open(TheFs, gDriveNum); |
|
285 |
test(nRes == KErrNone); |
|
286 |
||
287 |
TBuf8<512> sectorBuf(512); |
|
288 |
||
289 |
sectorBuf.FillZ(); |
|
290 |
||
291 |
const TInt KSectors = 32; |
|
292 |
TInt64 mediaPos = 0; |
|
293 |
||
294 |
for(TInt i=0; i<KSectors; ++i) |
|
295 |
{ |
|
296 |
nRes = rawDisk.Write(mediaPos, sectorBuf); |
|
297 |
test(nRes == KErrNone); |
|
298 |
||
299 |
mediaPos += sectorBuf.Size(); |
|
300 |
} |
|
301 |
||
302 |
rawDisk.Close(); |
|
303 |
} |
|
304 |
||
305 |
//------------------------------------------------------------------- |
|
306 |
||
307 |
||
308 |
/** |
|
309 |
quick format the volume using all parameter by default |
|
310 |
*/ |
|
311 |
static void FormatVolume(TBool aQuickFormat = ETrue) |
|
312 |
{ |
|
313 |
TInt nRes; |
|
314 |
nRes = FormatDrive(TheFs, CurrentDrive(), aQuickFormat); |
|
315 |
test_KErrNone(nRes); |
|
316 |
} |
|
317 |
||
318 |
||
319 |
//------------------------------------------------------------------- |
|
320 |
TInt DoFormatSteps(RFormat& aFormat, TInt& aFmtCnt) |
|
321 |
{ |
|
322 |
TInt nRes = KErrNone; |
|
323 |
||
324 |
while(aFmtCnt) |
|
325 |
{ |
|
326 |
nRes = aFormat.Next(aFmtCnt); |
|
327 |
if(nRes != KErrNone) |
|
328 |
{ |
|
329 |
test.Printf(_L("RFormat::Next() failed! code:%d\n"), nRes); |
|
330 |
break; |
|
331 |
} |
|
332 |
} |
|
333 |
||
334 |
return nRes; |
|
335 |
} |
|
336 |
||
337 |
//------------------------------------------------------------------- |
|
338 |
||
339 |
/** |
|
340 |
initialise test global objects |
|
341 |
@return EFalse if something goes wrong |
|
342 |
*/ |
|
343 |
TBool InitGlobals() |
|
344 |
{ |
|
345 |
#ifndef _DEBUG |
|
346 |
test.Printf(_L("This test can't be performed in RELEASE mode! Skipping.\n")); |
|
347 |
test(0); |
|
348 |
#endif |
|
349 |
||
350 |
TInt nRes; |
|
351 |
||
352 |
//-- store original file system parameters |
|
353 |
nRes = GetFileSystemDescriptor(TheFs, gDriveNum, orgFsDescriptor); |
|
354 |
test_KErrNone(nRes); |
|
355 |
||
356 |
||
357 |
//======================================= |
|
358 |
//-- define a text propery that will override automounter config string in estart.txt |
|
359 |
//-- automounter must be able to parse this string. |
|
360 |
//-- The property key is a drive number being tested |
|
361 |
{ |
|
271 | 362 |
|
0 | 363 |
_LIT_SECURITY_POLICY_PASS(KTestPropPolicy); |
364 |
||
365 |
nRes = RProperty::Define(KThisTestSID, KPropKey, RProperty::EText, KTestPropPolicy, KTestPropPolicy); |
|
366 |
test(nRes == KErrNone || nRes == KErrAlreadyExists); |
|
367 |
||
368 |
//-- set the propery, it will override automounter config from estart.txt. |
|
369 |
//-- the config string has following format: "<fs_name1>,<fsname2>" |
|
271 | 370 |
//-- and this looks like: 'FSNames fat, exfat' |
371 |
||
0 | 372 |
|
373 |
TBuf8<50> cfgBuf(0); |
|
271 | 374 |
cfgBuf.Append(KKey_ChildFsList); |
375 |
||
376 |
cfgBuf.Append(_L(" ")); |
|
0 | 377 |
cfgBuf.Append(KFSName1); |
378 |
cfgBuf.Append(_L(" , ")); |
|
379 |
cfgBuf.Append(KFSName2); |
|
380 |
||
381 |
||
382 |
nRes = RProperty::Set(KThisTestSID, KPropKey, cfgBuf); |
|
383 |
test_KErrNone(nRes); |
|
384 |
||
385 |
} |
|
386 |
||
387 |
//======================================= |
|
388 |
//-- we must ensure that all 3 required *.fsy are present and load them. |
|
389 |
//-- the automounter must have child filesystems loaded before its initialisation. |
|
390 |
{ |
|
391 |
_LIT(KFsyFailure, "can't load '%S', code:%d, the test can't be performed!\n"); |
|
392 |
||
393 |
//-- child FS #0 |
|
394 |
nRes = TheFs.AddFileSystem(KFsy1); |
|
395 |
if(nRes != KErrNone && nRes != KErrAlreadyExists) |
|
396 |
{ |
|
397 |
test.Printf(KFsyFailure, &KFsy1, nRes); |
|
398 |
return EFalse; |
|
399 |
} |
|
400 |
childFs1_Loaded = ETrue; |
|
401 |
||
402 |
||
403 |
//-- child FS #1 |
|
404 |
nRes = TheFs.AddFileSystem(KFsy2); |
|
405 |
if(nRes != KErrNone && nRes != KErrAlreadyExists) |
|
406 |
{ |
|
407 |
test.Printf(KFsyFailure, &KFsy2, nRes); |
|
408 |
return EFalse; |
|
409 |
} |
|
410 |
childFs2_Loaded = ETrue; |
|
411 |
||
412 |
//-- automounter |
|
413 |
nRes = TheFs.AddFileSystem(KAutoMounterFsy); |
|
414 |
if(nRes != KErrNone && nRes != KErrAlreadyExists) |
|
415 |
{ |
|
416 |
test.Printf(KFsyFailure, &KAutoMounterFsy, nRes); |
|
417 |
return EFalse; |
|
418 |
} |
|
419 |
automounter_Loaded = ETrue; |
|
420 |
} |
|
421 |
||
422 |
||
423 |
//======================================= |
|
424 |
//-- dismount original file system and optional primary extension. Secondary extensions are not supported. |
|
425 |
||
426 |
test.Printf(_L("Dismounting the original FS:%S, PExt:%S \n"), &orgFsDescriptor.iFsName, &orgFsDescriptor.iPExtName); |
|
427 |
||
428 |
nRes = TheFs.DismountFileSystem(orgFsDescriptor.iFsName, gDriveNum); |
|
429 |
test_KErrNone(nRes); |
|
430 |
||
431 |
return ETrue; |
|
432 |
} |
|
433 |
||
434 |
//------------------------------------------------------------------- |
|
435 |
/** destroy test global objects */ |
|
436 |
void DestroyGlobals() |
|
437 |
{ |
|
438 |
test.Printf(_L("Restoring the environment....\n")); |
|
439 |
||
440 |
TInt nRes; |
|
441 |
||
442 |
//======================================= |
|
443 |
//-- dismount current filesystem that was used for testing and mount the original filesystem |
|
444 |
if(orgFsDescriptor.iFsName.Length()) |
|
445 |
{//-- the original file system had been dismounted during test initialisation; dismount whatever we have now |
|
446 |
test.Printf(_L("Mounting back the original FS:%S, PExt:%S \n"), &orgFsDescriptor.iFsName, &orgFsDescriptor.iPExtName); |
|
447 |
||
271 | 448 |
TFSName fsName; |
0 | 449 |
|
450 |
nRes = TheFs.FileSystemName(fsName, gDriveNum); |
|
451 |
if(nRes == KErrNone && fsName.CompareF(orgFsDescriptor.iFsName) != KErrNone) |
|
452 |
{ |
|
453 |
nRes = TheFs.DismountFileSystem(fsName, gDriveNum); |
|
454 |
test_KErrNone(nRes); |
|
455 |
||
456 |
||
457 |
//-- mount original FS as asynchronous one, the automounter can't be used on a synchronous drive anyway. |
|
458 |
MountFileSystem(TheFs, gDriveNum, orgFsDescriptor); |
|
459 |
||
460 |
FormatVolume(); |
|
461 |
} |
|
462 |
} |
|
463 |
||
464 |
//======================================= |
|
465 |
//-- delete test property |
|
466 |
RProperty::Delete(KThisTestSID, gDriveNum); |
|
467 |
||
468 |
//======================================= |
|
469 |
//-- if the original FS wasn't automounter, unload child file systems |
|
470 |
if(orgFsDescriptor.iFsName.CompareF(KFileSystemName_AutoMounter) != 0) |
|
471 |
{ |
|
472 |
||
473 |
if(childFs1_Loaded) |
|
474 |
{ |
|
475 |
nRes = TheFs.RemoveFileSystem(KFSName1); |
|
476 |
test(nRes == KErrNone || nRes == KErrInUse); //-- if the FS was used on some drive before test started, It will be KErrInUse |
|
477 |
childFs1_Loaded = EFalse; |
|
478 |
} |
|
479 |
||
480 |
if(childFs2_Loaded) |
|
481 |
{ |
|
482 |
nRes = TheFs.RemoveFileSystem(KFSName2); |
|
483 |
test(nRes == KErrNone || nRes == KErrInUse); //-- if the FS was used on some drive before test started, It will be KErrInUse |
|
484 |
childFs2_Loaded = EFalse; |
|
485 |
} |
|
486 |
||
487 |
||
488 |
//-- unload test filesystem modules |
|
489 |
if(automounter_Loaded) |
|
490 |
{ |
|
491 |
nRes = TheFs.RemoveFileSystem(KAutoMounterFSName); //-- if the FS was used on some drive before test started, It will be KErrInUse |
|
492 |
test(nRes == KErrNone || nRes == KErrInUse); |
|
493 |
automounter_Loaded = EFalse; |
|
494 |
} |
|
495 |
} |
|
496 |
else |
|
497 |
{ |
|
498 |
nRes = RemountFS(TheFs, gDriveNum); |
|
499 |
test(nRes == KErrNone); |
|
500 |
} |
|
501 |
||
502 |
TVolumeInfo v; |
|
503 |
TheFs.Volume(v); |
|
504 |
} |
|
505 |
||
506 |
//------------------------------------------------------------------- |
|
507 |
||
508 |
/* |
|
509 |
Testing basic automounter functionality. Format media with different file systems FS1/FS2, mount automounter and |
|
510 |
ensure that it recognised and successfully mounts appropriate child file system. |
|
511 |
||
512 |
||
513 |
1.1 mount "filesystem1" / format volume |
|
514 |
1.2 check file system name / subtype / functionality |
|
515 |
1.3 corrupt "filesystem1" |
|
516 |
1.4 check file system name / subtype |
|
517 |
||
518 |
||
519 |
2.1 mount "automounter" |
|
520 |
2.2 check file system name / subtype / functionality (this must correspond to the filesystem1) The "filesystem1" must be recognised |
|
521 |
||
522 |
3.1 mount "filesystem2" / format volume |
|
523 |
3.2 check file system name / subtype / functionality |
|
524 |
3.3 corrupt "filesystem2" |
|
525 |
3.4 check file system name / subtype |
|
526 |
3.5 format volume (it will be filesystem2) |
|
527 |
||
528 |
4.1 mount "automounter" |
|
529 |
4.2 check file system name / subtype / functionality (this must correspond to the filesystem2) The "filesystem2" must be recognised |
|
530 |
||
531 |
||
532 |
5. check the list of supported file systems on the drive |
|
533 |
||
534 |
6.1 corrupt the volume |
|
535 |
6.2 check that automounter can't recognise it |
|
536 |
||
537 |
7. restore "filesystem1" / format volume |
|
538 |
*/ |
|
539 |
void TestAutomounterBasics() |
|
540 |
{ |
|
541 |
||
542 |
test.Next(_L("Testing automounter basic functionality \n")); |
|
543 |
||
544 |
TVolumeInfo v; |
|
271 | 545 |
TFSName fsName(0); |
546 |
TFSName fsSubType(0); |
|
0 | 547 |
TInt nRes; |
548 |
||
549 |
//================================================================================ |
|
550 |
//-- 1. mount "filesystem1" / format volume |
|
551 |
test.Printf(_L("Mounting FileSystem1...\n")); |
|
552 |
Mount_FileSystem1(); |
|
553 |
||
554 |
FormatVolume(); |
|
555 |
||
556 |
nRes = TheFs.Volume(v); |
|
557 |
test_KErrNone(nRes); |
|
558 |
||
559 |
//-- check file system name / subtype etc. |
|
560 |
nRes = TheFs.FileSystemName(fsName, gDriveNum); |
|
561 |
test_KErrNone(nRes); |
|
562 |
test(fsName.CompareF(KFSName1) == 0); |
|
563 |
||
564 |
||
565 |
nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType); |
|
566 |
test_KErrNone(nRes); |
|
567 |
CheckSubtype_FS1(fsSubType); |
|
568 |
||
569 |
//-- check the list of supported file systems on this drive (there is only 1 FS supported). |
|
570 |
nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, -1); |
|
571 |
test(nRes == KErrArgument); |
|
572 |
||
573 |
fsName.SetLength(0); |
|
574 |
nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, RFs::KRootFileSystem); //-- "root" filesystem |
|
575 |
test(nRes == KErrNone && fsName.CompareF(KFSName1) == 0); |
|
576 |
||
577 |
fsName.SetLength(0); |
|
578 |
nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, 0); //-- 1st "child" filesystem |
|
579 |
test(nRes == KErrNone && fsName.CompareF(KFSName1) == 0); |
|
580 |
||
581 |
fsName.SetLength(0); |
|
582 |
nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, 1); //-- there are no more supported FSs |
|
583 |
test(nRes == KErrNotFound); |
|
584 |
||
585 |
//-- perform some operation |
|
586 |
CheckFsOperations(); |
|
587 |
||
588 |
||
589 |
//================================================================================ |
|
590 |
//-- 2. Now we have volume formatted for "filesystem1"; Mount "automounter" and check that the |
|
591 |
//-- file system on the volume is recognised OK. |
|
592 |
test.Printf(_L("Mounting Automounter FS and checking its functionality ...\n")); |
|
593 |
Mount_AutomounterFS(); |
|
594 |
||
595 |
nRes = TheFs.Volume(v); |
|
596 |
test_KErrNone(nRes); |
|
597 |
||
598 |
//-- check file system name / subtype etc. |
|
599 |
nRes = TheFs.FileSystemName(fsName, gDriveNum); |
|
600 |
test_KErrNone(nRes); |
|
601 |
||
602 |
//-- the FS Subtype must be the subtype of the recognised child FS |
|
603 |
nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType); |
|
604 |
test_KErrNone(nRes); |
|
605 |
||
606 |
test.Printf(_L("FS name:'%S', FS Subtype:'%S'\n") ,&fsName, &fsSubType); |
|
607 |
||
608 |
test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS |
|
609 |
CheckSubtype_FS1(fsSubType); |
|
610 |
||
611 |
||
612 |
||
613 |
//================================================================================ |
|
614 |
//-- dismount current file system |
|
615 |
test.Printf(_L("Dismomounting FileSystem1...\n")); |
|
616 |
DismountFS(); |
|
617 |
nRes = TheFs.FileSystemName(fsName, gDriveNum); |
|
618 |
test(nRes == KErrNotFound); |
|
619 |
||
620 |
nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, RFs::KRootFileSystem); //-- "root" filesystem |
|
621 |
test(nRes == KErrNotFound); |
|
622 |
||
623 |
nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, 0); //-- 1st "child" filesystem |
|
624 |
test(nRes == KErrNotFound); |
|
625 |
||
626 |
nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType); |
|
627 |
test(nRes == KErrNotReady); |
|
628 |
||
629 |
||
630 |
//================================================================================ |
|
631 |
//-- 3. mount "filesystem2" / format volume |
|
632 |
test.Printf(_L("Mounting FileSystem2...\n")); |
|
633 |
Mount_FileSystem2(); |
|
634 |
||
635 |
FormatVolume(); |
|
636 |
||
637 |
nRes = TheFs.Volume(v); |
|
638 |
test_KErrNone(nRes); |
|
639 |
||
640 |
//-- check file system name / subtype etc. |
|
641 |
nRes = TheFs.FileSystemName(fsName, gDriveNum); |
|
642 |
test_KErrNone(nRes); |
|
643 |
test(fsName.CompareF(KFSName2) == 0); |
|
644 |
||
645 |
nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType); |
|
646 |
test_KErrNone(nRes); |
|
647 |
CheckSubtype_FS2(fsSubType); |
|
648 |
||
649 |
//-- check the list of supported file systems on this drive (there is only 1 FS supported). |
|
650 |
fsName.SetLength(0); |
|
651 |
nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, RFs::KRootFileSystem); //-- "root" filesystem |
|
652 |
test(nRes == KErrNone && fsName.CompareF(KFSName2) == 0); |
|
653 |
||
654 |
fsName.SetLength(0); |
|
655 |
nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, 0); //-- 1st "child" filesystem |
|
656 |
test(nRes == KErrNone && fsName.CompareF(KFSName2) == 0); |
|
657 |
||
658 |
fsName.SetLength(0); |
|
659 |
nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, 1); //-- there are no more supported FSs |
|
660 |
test(nRes == KErrNotFound); |
|
661 |
||
662 |
//-- perform some operation |
|
663 |
CheckFsOperations(); |
|
664 |
||
665 |
||
666 |
//================================================================================ |
|
667 |
//-- 4. Now we have volume formatted for "filesystem2"; Mount "automounter" and check that the |
|
668 |
//-- file system on the volume is recognised OK. |
|
669 |
test.Printf(_L("Mounting Automounter FS and checking its functionality ...\n")); |
|
670 |
Mount_AutomounterFS(); |
|
671 |
||
672 |
nRes = TheFs.Volume(v); |
|
673 |
test_KErrNone(nRes); |
|
674 |
||
675 |
//-- check file system name / subtype etc. |
|
676 |
nRes = TheFs.FileSystemName(fsName, gDriveNum); |
|
677 |
test_KErrNone(nRes); |
|
678 |
||
679 |
//-- the FS Subtype must be the subtype of the recognised child FS |
|
680 |
nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType); |
|
681 |
test_KErrNone(nRes); |
|
682 |
||
683 |
test.Printf(_L("FS name:'%S', FS Subtype:'%S'\n") ,&fsName, &fsSubType); |
|
684 |
||
685 |
test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS |
|
686 |
CheckSubtype_FS2(fsSubType); |
|
687 |
||
688 |
//================================================================================ |
|
689 |
//-- 5. check the list of supported file systems on this drive (there must be 2 child FS supported). |
|
690 |
test.Printf(_L("Getting list of supported by automounter file systems ...\n")); |
|
691 |
||
692 |
fsName.SetLength(0); |
|
693 |
nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, RFs::KRootFileSystem); //-- "root" filesystem |
|
694 |
test(nRes == KErrNone && fsName.CompareF(KAutoMounterFSName) == 0); |
|
695 |
test.Printf(_L("Root FS:'%S'\n"), &fsName); |
|
696 |
||
697 |
||
698 |
fsName.SetLength(0); |
|
699 |
nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, 0); //-- 1st "child" filesystem |
|
700 |
test(nRes == KErrNone && fsName.CompareF(KFSName1) == 0); |
|
701 |
||
702 |
fsName.SetLength(0); |
|
703 |
nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, 1); //-- 2nd "child" filesystem |
|
704 |
test(nRes == KErrNone && fsName.CompareF(KFSName2) == 0); |
|
705 |
||
706 |
nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, 2); //-- 3rd "child" filesystem |
|
707 |
test(nRes == KErrNotFound); |
|
708 |
||
709 |
//-- get and print out list of all child FS (enumeration example) |
|
710 |
TInt i; |
|
711 |
for(i=0; ;++i) |
|
712 |
{ |
|
713 |
nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, i); |
|
714 |
if(nRes == KErrNone) |
|
715 |
{ |
|
716 |
test.Printf(_L("child FS[%d]:'%S'\n"), i, &fsName); |
|
717 |
} |
|
718 |
else |
|
719 |
{ |
|
720 |
test(nRes == KErrNotFound); |
|
721 |
break; |
|
722 |
} |
|
723 |
||
724 |
} |
|
725 |
||
726 |
//-- perform some operation. They will happen on currently active child FS |
|
727 |
CheckFsOperations(); |
|
728 |
||
729 |
//================================================================================ |
|
730 |
//-- 6. corrupt the media, mount automounter, check that FS is not recognised. |
|
731 |
test.Printf(_L("Test automounter handling corrupted media.\n")); |
|
732 |
||
733 |
CorruptDrive(); //-- the active child FS will do this and the root FS will be remounted on first access |
|
734 |
||
735 |
//-- check file system name / subtype etc. |
|
736 |
nRes = TheFs.FileSystemName(fsName, gDriveNum); |
|
737 |
test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS |
|
738 |
test_KErrNone(nRes); |
|
739 |
||
740 |
//-- the FS Subtype query requires mounted and recognised file system. this shall fail |
|
741 |
nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType); |
|
742 |
test(nRes == KErrCorrupt); |
|
743 |
||
744 |
nRes = TheFs.MkDir(_L("\\dir1\\")); |
|
745 |
test(nRes == KErrCorrupt); |
|
746 |
||
747 |
||
748 |
//================================================================================ |
|
749 |
//-- 7. restore filesystem on the drive |
|
750 |
test.Printf(_L("Restoring FileSystem1.\n")); |
|
751 |
Mount_FileSystem1(); |
|
752 |
FormatVolume(); |
|
753 |
||
754 |
nRes = TheFs.Volume(v); |
|
755 |
test_KErrNone(nRes); |
|
756 |
||
757 |
} |
|
758 |
||
759 |
//------------------------------------------------------------------- |
|
760 |
/** |
|
761 |
||
762 |
1.1 mount "filesystem1" / format volume |
|
763 |
1.2 create and open a file on the volume. |
|
764 |
1.3 dismount the file system with opened file on it. |
|
765 |
||
766 |
2. mount "automounter" The "filesystem1" must be recognised |
|
767 |
2.1 open previously created file (it is still opened by dismounted FS1) |
|
768 |
||
769 |
3. forcedly dismount the current file system (automounter) |
|
770 |
4. mount the automounter FS again. check file system name / subtype; The "filesystem1" must be recognised |
|
771 |
5. try to read a file (see 2.1), using already dismounted mount; it shall result in KErrDismounted. |
|
772 |
*/ |
|
773 |
void TestDismounting() |
|
774 |
{ |
|
775 |
test.Next(_L("Testing media dismounting/remounting with automounter FS \n")); |
|
776 |
||
777 |
TInt nRes; |
|
271 | 778 |
TFSName fsName(0); |
779 |
TFSName fsSubType(0); |
|
0 | 780 |
TBuf8<40> buf; |
781 |
||
782 |
//================================================================================ |
|
783 |
//-- 1. mount "filesystem1" / format volume |
|
784 |
test.Printf(_L("Mounting FileSystem1 and opening a file.\n")); |
|
785 |
Mount_FileSystem1(); |
|
786 |
FormatVolume(); |
|
787 |
||
788 |
//-- create a file, open it and try to dismount FS |
|
789 |
_LIT(KTestFile, "\\test_file"); |
|
790 |
nRes = CreateEmptyFile(TheFs, KTestFile, 100); |
|
791 |
test(nRes == KErrNone); |
|
792 |
||
793 |
RFile file; |
|
794 |
||
795 |
nRes = file.Open(TheFs, KTestFile, 0); |
|
796 |
test(nRes == KErrNone); |
|
797 |
||
798 |
//TheFs.SetDebugRegister(KFSERV); |
|
799 |
||
800 |
test.Printf(_L("dismounting FileSystem1 with a file opened.\n")); |
|
801 |
nRes = DoDismountFS(); |
|
802 |
test(nRes == KErrInUse); |
|
803 |
||
804 |
file.Close(); |
|
805 |
||
806 |
//================================================================================ |
|
807 |
//-- 2. mount "automounter", previous FS must be recognised and set as an active child |
|
808 |
Mount_AutomounterFS(); |
|
809 |
||
810 |
//-- check file system name / subtype etc. |
|
811 |
nRes = TheFs.FileSystemName(fsName, gDriveNum); |
|
812 |
test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS |
|
813 |
test_KErrNone(nRes); |
|
814 |
||
815 |
//-- the FS Subtype must be the subtype of the recognised child FS |
|
816 |
nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType); |
|
817 |
test_KErrNone(nRes); |
|
818 |
CheckSubtype_FS1(fsSubType); |
|
819 |
||
820 |
//-- open the previously created file |
|
821 |
nRes = file.Open(TheFs, KTestFile, 0); |
|
822 |
test(nRes == KErrNone); |
|
823 |
||
824 |
//TheFs.SetDebugRegister(KFSERV); |
|
825 |
||
826 |
nRes = DoDismountFS(); |
|
827 |
test(nRes == KErrInUse); //-- opened file belongs to the child FS, actually. |
|
828 |
||
829 |
||
830 |
//================================================================================ |
|
831 |
//-- 3. force dismounting the file system, this will leave hanging dismounted mount associated with this drive. |
|
832 |
test.Printf(_L("Force dismounting the file system.\n")); |
|
833 |
ForceDismountFS(); |
|
834 |
||
835 |
//TheFs.SetDebugRegister(KFSERV); |
|
836 |
||
837 |
//================================================================================ |
|
838 |
//-- 4. mount "automounter" again, this will create another instance of mount corresponding to the filesystem1 |
|
839 |
Mount_AutomounterFS(); |
|
840 |
||
841 |
//-- check file system name / subtype etc. |
|
842 |
nRes = TheFs.FileSystemName(fsName, gDriveNum); |
|
843 |
test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS |
|
844 |
test_KErrNone(nRes); |
|
845 |
||
846 |
//-- the FS Subtype must be the subtype of the recognised child FS |
|
847 |
nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType); |
|
848 |
test_KErrNone(nRes); |
|
849 |
CheckSubtype_FS1(fsSubType); |
|
850 |
||
851 |
//================================================================================ |
|
852 |
//-- 5. try to read a file using already dead mount |
|
853 |
nRes = file.Read(0, buf, 2); |
|
854 |
test(nRes == KErrDisMounted); |
|
855 |
||
856 |
//-- this will cause the forcedly dismounted hanging mount to self-destruct |
|
857 |
file.Close(); |
|
858 |
||
859 |
||
860 |
//-- open the previously created file using current alive mount. |
|
861 |
nRes = file.Open(TheFs, KTestFile, 0); |
|
862 |
test(nRes == KErrNone); |
|
863 |
nRes = file.Read(0, buf, 2); |
|
864 |
test(nRes == KErrNone); |
|
865 |
||
866 |
file.Close(); |
|
867 |
||
868 |
||
869 |
//TheFs.SetDebugRegister(0x00); |
|
870 |
} |
|
871 |
||
872 |
//------------------------------------------------------------------- |
|
873 |
/** |
|
874 |
Testing legacy RFormat API in the case when the volume has "automounter" file system bound. |
|
875 |
The formatting is performed without specifying any parameters, i.e. "all by default" |
|
876 |
||
877 |
If the automounter recognises file system on the volume and successfully mounts it, the |
|
878 |
default formatting must be transparent, i.e. the appropriate child FS will perform it. |
|
879 |
||
880 |
If the automounter can't recognise the filesystem on the volume because of volume corruption or if this FS is unknown to it, |
|
881 |
the "default" formatting will fail with "KErrNotFound" |
|
882 |
*/ |
|
883 |
void TestAutomounterDefaultFormatting() |
|
884 |
{ |
|
885 |
test.Next(_L("Testing media formatting with default parameters. Automounter FS\n")); |
|
886 |
||
887 |
TInt nRes; |
|
271 | 888 |
TFSName fsName(0); |
889 |
TFSName fsSubType(0); |
|
0 | 890 |
|
891 |
||
892 |
//================================================================================ |
|
893 |
//-- 1. mount "filesystem1" / format volume |
|
894 |
Mount_FileSystem1(); |
|
895 |
FormatVolume(); |
|
896 |
||
897 |
//================================================================================ |
|
898 |
//-- 2. mount "automounter", previous FS must be recognised and set as an active child |
|
899 |
Mount_AutomounterFS(); |
|
900 |
||
901 |
//-- check file system name / subtype etc. |
|
902 |
nRes = TheFs.FileSystemName(fsName, gDriveNum); |
|
903 |
test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS |
|
904 |
test_KErrNone(nRes); |
|
905 |
||
906 |
//-- the FS Subtype must be the subtype of the recognised child FS |
|
907 |
nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType); |
|
908 |
test_KErrNone(nRes); |
|
909 |
CheckSubtype_FS1(fsSubType); |
|
910 |
||
911 |
//================================================================================ |
|
912 |
//-- 3. format the drive with all default parameters; the current active child FS shall be used |
|
913 |
//-- check that we still have automounter as "root" FS and the same active child |
|
914 |
FormatVolume(); |
|
915 |
||
916 |
//-- check file system name / subtype etc. |
|
917 |
nRes = TheFs.FileSystemName(fsName, gDriveNum); |
|
918 |
test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS |
|
919 |
test_KErrNone(nRes); |
|
920 |
||
921 |
//-- the FS Subtype must be the subtype of the recognised child FS |
|
922 |
nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType); |
|
923 |
test_KErrNone(nRes); |
|
924 |
CheckSubtype_FS1(fsSubType); |
|
925 |
||
926 |
//-- perform some operations |
|
927 |
CheckFsOperations(); |
|
928 |
test.Printf(_L("default formatting for FS:'%S', subtype:'%S' OK!\n"), &fsName, &fsSubType); |
|
929 |
||
930 |
//================================================================================ |
|
931 |
//-- 3. mount "filesystem2" / format volume |
|
932 |
Mount_FileSystem2(); |
|
933 |
FormatVolume(); |
|
934 |
||
935 |
//================================================================================ |
|
936 |
//-- 4. mount "automounter", previous FS must be recognised and set as an active child |
|
937 |
Mount_AutomounterFS(); |
|
938 |
||
939 |
//-- check file system name / subtype etc. |
|
940 |
nRes = TheFs.FileSystemName(fsName, gDriveNum); |
|
941 |
test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS |
|
942 |
test_KErrNone(nRes); |
|
943 |
||
944 |
//-- the FS Subtype must be the subtype of the recognised child FS |
|
945 |
nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType); |
|
946 |
test_KErrNone(nRes); |
|
947 |
CheckSubtype_FS2(fsSubType); |
|
948 |
||
949 |
//================================================================================ |
|
950 |
//-- 5. format the drive with all default parameters; the current active child FS shall be used |
|
951 |
//-- check that we still have automounter as "root" FS and the same active child |
|
952 |
FormatVolume(); |
|
953 |
||
954 |
//-- check file system name / subtype etc. |
|
955 |
nRes = TheFs.FileSystemName(fsName, gDriveNum); |
|
956 |
test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS |
|
957 |
test_KErrNone(nRes); |
|
958 |
||
959 |
//-- the FS Subtype must be the subtype of the recognised child FS |
|
960 |
nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType); |
|
961 |
test_KErrNone(nRes); |
|
962 |
CheckSubtype_FS2(fsSubType); |
|
963 |
||
964 |
//-- perform some operations |
|
965 |
CheckFsOperations(); |
|
966 |
test.Printf(_L("default formatting for FS:'%S', subtype:'%S' OK!\n"), &fsName, &fsSubType); |
|
967 |
||
968 |
//================================================================================ |
|
969 |
//-- 6. corrupt the media, mount automounter, check that FS is not recognised. |
|
970 |
//-- default formatting shall fail, because automounter can't chose appropriate child FS |
|
971 |
||
972 |
CorruptDrive(); //-- the active child FS will do this and the root FS will be remounted on first access |
|
973 |
||
974 |
//-- check file system name / subtype etc. |
|
975 |
nRes = TheFs.FileSystemName(fsName, gDriveNum); |
|
976 |
test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS |
|
977 |
test_KErrNone(nRes); |
|
978 |
||
979 |
//-- the FS Subtype query requires mounted and recognised file system. this shall fail |
|
980 |
nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType); |
|
981 |
test(nRes == KErrCorrupt); |
|
982 |
||
983 |
//-- try default formatting; this shall fail with a special error code |
|
984 |
nRes = FormatDrive(TheFs, CurrentDrive(), ETrue); |
|
985 |
test(nRes == KErrNotFound); |
|
986 |
||
987 |
//-- try special formatting without any parameters, it shall also fail. |
|
988 |
RFormat format; |
|
989 |
TUint fmtMode = EQuickFormat | ESpecialFormat; |
|
990 |
TInt fmtCnt; |
|
991 |
TBuf<10> drivePath; |
|
992 |
drivePath.Format(_L("%C:\\"), gDriveNum+'A'); |
|
993 |
||
994 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt); |
|
995 |
test(nRes==KErrNotFound); |
|
996 |
format.Close(); |
|
997 |
||
998 |
||
999 |
||
1000 |
//================================================================================ |
|
1001 |
//-- 7. restore filesystem on the drive, try formatting with specifying ESpecialFormat flag, but without any formatting parameters |
|
1002 |
//-- just to check that it works (it will not work on SD cards that do not allow ESpecialFormat) |
|
1003 |
test.Printf(_L("Restoring FileSystem1 and use special format without any parameters\n")); |
|
1004 |
||
1005 |
Mount_FileSystem1(); |
|
1006 |
//FormatVolume(); |
|
1007 |
||
1008 |
||
1009 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt); |
|
1010 |
test(nRes==KErrNone); |
|
1011 |
||
1012 |
nRes = DoFormatSteps(format, fmtCnt); |
|
1013 |
test(nRes==KErrNone); |
|
1014 |
||
1015 |
format.Close(); |
|
1016 |
||
1017 |
||
1018 |
||
1019 |
//-- check file system name / subtype etc. |
|
1020 |
nRes = TheFs.FileSystemName(fsName, gDriveNum); |
|
1021 |
test_KErrNone(nRes); |
|
1022 |
test(fsName.CompareF(KFSName1) == 0); |
|
1023 |
||
1024 |
||
1025 |
nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType); |
|
1026 |
test_KErrNone(nRes); |
|
1027 |
CheckSubtype_FS1(fsSubType); |
|
1028 |
||
1029 |
||
1030 |
} |
|
1031 |
||
1032 |
||
1033 |
||
1034 |
//------------------------------------------------------------------- |
|
1035 |
/** |
|
1036 |
Testing the use case when there is "automounter" FS bound to the drive and RFormat API that allows specifying |
|
1037 |
the file system name that we want to put on the volume. |
|
1038 |
||
1039 |
It must be possible: |
|
1040 |
- format the volume without specifying FS name at all (the currently active child FS will be used) |
|
1041 |
- format the volume with specifying FS name that belongs to one of the supported child FS. The volume shall be formatted with this FS. |
|
1042 |
- format the volume with specifying incorrect FS name (not supported) the RFormat::Open() must fail with KErrNotSupported. |
|
1043 |
||
1044 |
- If the file system on the volume is damaged or not recognisable, the RFormat::Open() shall with KErrNotFound if the concrete file system name is not specified. |
|
1045 |
- If the file system on the volume is damaged or not recognisable, if shall be possible to format such a volume by specifying the child FS name. |
|
1046 |
*/ |
|
1047 |
void TestAutomounterFormatting_FsNameSpecified() |
|
1048 |
{ |
|
1049 |
test.Next(_L("Testing formatting API that allows specifying particular FS. Automounter FS.\n")); |
|
1050 |
||
1051 |
||
1052 |
TInt nRes; |
|
271 | 1053 |
TFSName fsName(0); |
1054 |
TFSName fsSubType(0); |
|
0 | 1055 |
|
1056 |
TBuf<10> drivePath; |
|
1057 |
drivePath.Format(_L("%C:\\"), gDriveNum+'A'); |
|
1058 |
||
1059 |
RFormat format; |
|
1060 |
TUint fmtMode = EQuickFormat | ESpecialFormat; |
|
1061 |
TInt fmtCnt; |
|
1062 |
||
1063 |
TVolFormatParamBuf fmtParamBuf; |
|
1064 |
TVolFormatParam& fmtParam = fmtParamBuf(); |
|
1065 |
||
1066 |
//_LIT(KTestFile, "\\this is a test file"); |
|
1067 |
||
1068 |
//================================================================================ |
|
1069 |
//-- 0. prepare the volume |
|
1070 |
Mount_FileSystem1(); |
|
1071 |
FormatVolume(); //-- old API, formatting with all parameters by default |
|
1072 |
||
1073 |
||
1074 |
//================================================================================ |
|
1075 |
//-- 0.1 mount "automounter", previous FS must be recognised and set as an active child |
|
1076 |
Mount_AutomounterFS(); |
|
1077 |
||
1078 |
//-- check file system name / subtype etc. |
|
1079 |
nRes = TheFs.FileSystemName(fsName, gDriveNum); |
|
1080 |
test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS |
|
1081 |
test_KErrNone(nRes); |
|
1082 |
||
1083 |
//-- the FS Subtype must be the subtype of the recognised child FS |
|
1084 |
nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType); |
|
1085 |
test_KErrNone(nRes); |
|
1086 |
CheckSubtype_FS1(fsSubType); |
|
1087 |
||
1088 |
//================================================================================ |
|
1089 |
||
1090 |
//-- 1.1 format the volume without specifying any parameters at all, the currently active child FS shall be used |
|
1091 |
test.Printf(_L("format the volume without specifying any parameters at all\n")); |
|
1092 |
||
1093 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt); |
|
1094 |
test(nRes==KErrNone); |
|
1095 |
||
1096 |
nRes = DoFormatSteps(format, fmtCnt); |
|
1097 |
test(nRes==KErrNone); |
|
1098 |
||
1099 |
format.Close(); |
|
1100 |
||
1101 |
nRes = TheFs.FileSystemName(fsName, gDriveNum); |
|
1102 |
test(fsName.CompareF(KAutoMounterFSName) == 0); |
|
1103 |
||
1104 |
//-- the FS Subtype must be the subtype of the recognised child FS |
|
1105 |
nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType); |
|
1106 |
test_KErrNone(nRes); |
|
1107 |
CheckSubtype_FS1(fsSubType); |
|
1108 |
||
1109 |
||
1110 |
//-- 1.2 format the volume without specifying the FS name, the currently active child FS shall be used |
|
1111 |
test.Printf(_L("format the volume without specifying the FS name\n")); |
|
1112 |
fmtParam.Init(); //-- reset all data |
|
1113 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf); |
|
1114 |
test(nRes==KErrNone); |
|
1115 |
||
1116 |
nRes = DoFormatSteps(format, fmtCnt); |
|
1117 |
test(nRes==KErrNone); |
|
1118 |
||
1119 |
format.Close(); |
|
1120 |
||
1121 |
nRes = TheFs.FileSystemName(fsName, gDriveNum); |
|
1122 |
test(fsName.CompareF(KAutoMounterFSName) == 0); |
|
1123 |
||
1124 |
//-- the FS Subtype must be the subtype of the recognised child FS |
|
1125 |
nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType); |
|
1126 |
test_KErrNone(nRes); |
|
1127 |
CheckSubtype_FS1(fsSubType); |
|
1128 |
||
1129 |
||
1130 |
CheckFsOperations(); |
|
1131 |
||
1132 |
//================================================================================ |
|
1133 |
//-- 2. format the volume specifying _second_ child FS name |
|
1134 |
test.Printf(_L("format the volume specifying second child FS name\n")); |
|
1135 |
fmtParam.Init(); //-- reset all data |
|
1136 |
fmtParam.SetFileSystemName(KFSName2); |
|
1137 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf); |
|
1138 |
test(nRes==KErrNone); |
|
1139 |
||
1140 |
nRes =DoFormatSteps(format, fmtCnt); |
|
1141 |
test(nRes==KErrNone); |
|
1142 |
||
1143 |
format.Close(); |
|
1144 |
||
1145 |
nRes = TheFs.FileSystemName(fsName, gDriveNum); |
|
1146 |
test(fsName.CompareF(KAutoMounterFSName) == 0); |
|
1147 |
||
1148 |
//-- the FS Subtype must be the subtype of the recognised child FS |
|
1149 |
nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType); |
|
1150 |
test_KErrNone(nRes); |
|
1151 |
CheckSubtype_FS2(fsSubType); |
|
1152 |
||
1153 |
CheckFsOperations(); |
|
1154 |
||
1155 |
||
1156 |
//================================================================================ |
|
1157 |
//-- 3. format the volume specifying _first_ child FS name |
|
1158 |
fmtParam.Init(); //-- reset all data |
|
1159 |
fmtParam.SetFileSystemName(KFSName1); |
|
1160 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf); |
|
1161 |
test(nRes==KErrNone); |
|
1162 |
||
1163 |
nRes =DoFormatSteps(format, fmtCnt); |
|
1164 |
test(nRes==KErrNone); |
|
1165 |
||
1166 |
format.Close(); |
|
1167 |
||
1168 |
nRes = TheFs.FileSystemName(fsName, gDriveNum); |
|
1169 |
test(fsName.CompareF(KAutoMounterFSName) == 0); |
|
1170 |
||
1171 |
//-- the FS Subtype must be the subtype of the recognised child FS |
|
1172 |
nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType); |
|
1173 |
test_KErrNone(nRes); |
|
1174 |
CheckSubtype_FS1(fsSubType); |
|
1175 |
||
1176 |
CheckFsOperations(); |
|
1177 |
||
1178 |
||
1179 |
//================================================================================ |
|
1180 |
//-- 4. try formatting the volume specifying wrond child FS name |
|
1181 |
fmtParam.Init(); //-- reset all data |
|
1182 |
||
1183 |
fmtParam.SetFileSystemName(KAutoMounterFSName); //-- it might have some strange consequences :) |
|
1184 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf); |
|
1185 |
test(nRes==KErrNotSupported); |
|
1186 |
format.Close(); |
|
1187 |
||
1188 |
fmtParam.SetFileSystemName(_L("wrong FS")); |
|
1189 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf); |
|
1190 |
test(nRes==KErrNotSupported); |
|
1191 |
format.Close(); |
|
1192 |
||
1193 |
||
1194 |
//================================================================================ |
|
1195 |
//-- 5. corrupt the volume and try formatting without specyfying FS name |
|
1196 |
CorruptDrive(); |
|
1197 |
||
1198 |
fmtParam.Init(); //-- reset all data |
|
1199 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf); |
|
1200 |
test(nRes==KErrNotFound); //-- the meaning: "can't find the appropriate file system to put onto the volume" |
|
1201 |
format.Close(); |
|
1202 |
||
1203 |
//test.Printf(_L("#### T_a #1 res:%d\n"), nRes); |
|
1204 |
||
1205 |
fmtParam.SetFileSystemName(KAutoMounterFSName); //-- it might have some strange consequences :) |
|
1206 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf); |
|
1207 |
//test.Printf(_L("#### T_a #2 res:%d\n"), nRes); |
|
1208 |
||
1209 |
test(nRes == KErrNotSupported || nRes==KErrNotFound); |
|
1210 |
||
1211 |
format.Close(); |
|
1212 |
||
1213 |
fmtParam.SetFileSystemName(_L("wrong FS")); |
|
1214 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf); |
|
1215 |
test(nRes==KErrNotSupported); |
|
1216 |
format.Close(); |
|
1217 |
||
1218 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt); |
|
1219 |
test(nRes==KErrNotFound); //-- the meaning: "can't find the appropriate file system to put onto the volume" |
|
1220 |
format.Close(); |
|
1221 |
||
1222 |
||
1223 |
//-------------------------------------------------------------------------------- |
|
1224 |
//-- 5.1 format the volume with specifying child FS2 explicitly |
|
1225 |
fmtParam.Init(); //-- reset all data |
|
1226 |
fmtParam.SetFileSystemName(KFSName2); |
|
1227 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf); |
|
1228 |
test(nRes==KErrNone); |
|
1229 |
||
1230 |
nRes =DoFormatSteps(format, fmtCnt); |
|
1231 |
test(nRes==KErrNone); |
|
1232 |
||
1233 |
format.Close(); |
|
1234 |
||
1235 |
nRes = TheFs.FileSystemName(fsName, gDriveNum); |
|
1236 |
test(fsName.CompareF(KAutoMounterFSName) == 0); |
|
1237 |
||
1238 |
//-- the FS Subtype must be the subtype of the recognised child FS |
|
1239 |
nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType); |
|
1240 |
test_KErrNone(nRes); |
|
1241 |
CheckSubtype_FS2(fsSubType); |
|
1242 |
||
1243 |
CheckFsOperations(); |
|
1244 |
||
1245 |
//-------------------------------------------------------------------------------- |
|
1246 |
//-- 5.2 corrupt the volume and format with specifying child FS1 explicitly |
|
1247 |
CorruptDrive(); |
|
1248 |
||
1249 |
fmtParam.Init(); //-- reset all data |
|
1250 |
fmtParam.SetFileSystemName(KFSName1); |
|
1251 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf); |
|
1252 |
test(nRes==KErrNone); |
|
1253 |
||
1254 |
nRes =DoFormatSteps(format, fmtCnt); |
|
1255 |
test(nRes==KErrNone); |
|
1256 |
||
1257 |
format.Close(); |
|
1258 |
||
1259 |
nRes = TheFs.FileSystemName(fsName, gDriveNum); |
|
1260 |
test(fsName.CompareF(KAutoMounterFSName) == 0); |
|
1261 |
||
1262 |
//-- the FS Subtype must be the subtype of the recognised child FS |
|
1263 |
nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType); |
|
1264 |
test_KErrNone(nRes); |
|
1265 |
CheckSubtype_FS1(fsSubType); |
|
1266 |
||
1267 |
CheckFsOperations(); |
|
1268 |
} |
|
1269 |
||
1270 |
//------------------------------------------------------------------- |
|
1271 |
/** |
|
1272 |
Testing the use case when we have some rigidly bound FS to the drive (e.g "FAT") |
|
1273 |
and RFormat API that allows specifying the file system name that we want to put on the volume. |
|
1274 |
||
1275 |
It must be possible: |
|
1276 |
- format the volume without specifying FS name at all (the bound FS will be used) |
|
1277 |
- format the volume without specifying FS name at all when the volume is corrupted (the bound FS will be used) |
|
1278 |
- format the volume with specifying FS name that is the same as the bound FS has. |
|
1279 |
||
1280 |
If the specified file system name differs from the name that the bound FS has, the RFormat::Open() fails with KErrNotSupported. |
|
1281 |
||
1282 |
*/ |
|
1283 |
void TestFixedFsFormatting_FsNameSpecified() |
|
1284 |
{ |
|
1285 |
test.Next(_L("Testing RFormat API that allows specifying particular FS name for fixed FS.\n")); |
|
1286 |
||
1287 |
TInt nRes; |
|
271 | 1288 |
TFSName fsName(0); |
0 | 1289 |
|
1290 |
TBuf<10> drivePath; |
|
1291 |
drivePath.Format(_L("%C:\\"), gDriveNum+'A'); |
|
1292 |
||
1293 |
RFormat format; |
|
1294 |
TUint fmtMode = EQuickFormat | ESpecialFormat; |
|
1295 |
TInt fmtCnt; |
|
1296 |
||
1297 |
TVolFormatParamBuf fmtParamBuf; |
|
1298 |
TVolFormatParam& fmtParam = fmtParamBuf(); |
|
1299 |
||
1300 |
_LIT(KTestFile, "\\this is a test file"); |
|
1301 |
||
1302 |
//================================================================================ |
|
1303 |
//-- 0. prepare the volume |
|
1304 |
test.Printf(_L("fmt: ESpecialFormat, no parameters specified\n")); |
|
1305 |
Mount_FileSystem1(); |
|
1306 |
||
1307 |
//-- 0.1 format the volume with ESpecialFormat and without any parameters at all |
|
1308 |
test(fmtMode & ESpecialFormat); |
|
1309 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt); |
|
1310 |
test(nRes==KErrNone); |
|
1311 |
||
1312 |
nRes = DoFormatSteps(format, fmtCnt); |
|
1313 |
test(nRes==KErrNone); |
|
1314 |
||
1315 |
||
1316 |
format.Close(); |
|
1317 |
||
1318 |
//================================================================================ |
|
1319 |
//-- 1. format the volume with default parameters without specifying file system name. The volume is already formatted with FS1 |
|
1320 |
test.Printf(_L("fmt: ESpecialFormat, no FS name specified #1\n")); |
|
1321 |
fmtParam.Init(); //-- reset all data |
|
1322 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf); |
|
1323 |
test(nRes==KErrNone); |
|
1324 |
||
1325 |
nRes =DoFormatSteps(format, fmtCnt); |
|
1326 |
test(nRes==KErrNone); |
|
1327 |
||
1328 |
format.Close(); |
|
1329 |
||
1330 |
nRes = TheFs.FileSystemName(fsName, gDriveNum); |
|
1331 |
test(fsName.CompareF(KFSName1) == 0); |
|
1332 |
CheckFsOperations(); |
|
1333 |
||
1334 |
//-- 1.1 corrupt the media and check formatting without specifying FS name. |
|
1335 |
//-- The file system bount to this drive shall be used. |
|
1336 |
CorruptDrive(); |
|
1337 |
||
1338 |
test.Printf(_L("fmt: ESpecialFormat, no FS name specified #2\n")); |
|
1339 |
||
1340 |
fmtParam.Init(); //-- reset all data |
|
1341 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf); |
|
1342 |
test(nRes==KErrNone); |
|
1343 |
||
1344 |
nRes =DoFormatSteps(format, fmtCnt); |
|
1345 |
test(nRes==KErrNone); |
|
1346 |
||
1347 |
format.Close(); |
|
1348 |
||
1349 |
nRes = TheFs.FileSystemName(fsName, gDriveNum); |
|
1350 |
test(fsName.CompareF(KFSName1) == 0); |
|
1351 |
CheckFsOperations(); |
|
1352 |
||
1353 |
//-- 1.2 the media is already formatted with FS1, try to specify other file system name for formatting. |
|
1354 |
//-- this shall fail with KErrNotSupported, the volume must not be affected |
|
1355 |
test.Printf(_L("fmt: ESpecialFormat, specifying wrong FS name #1\n")); |
|
1356 |
||
1357 |
nRes = CreateCheckableStuffedFile(TheFs, KTestFile, 17384); |
|
1358 |
test(nRes==KErrNone); |
|
1359 |
||
1360 |
fmtParam.Init(); //-- reset all data |
|
1361 |
fmtParam.SetFileSystemName(_L("some filesystem name")); |
|
1362 |
||
1363 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf); |
|
1364 |
test(nRes==KErrNotSupported); |
|
1365 |
format.Close(); |
|
1366 |
||
1367 |
test.Printf(_L("fmt: ESpecialFormat, specifying wrong FS name #2\n")); |
|
1368 |
fmtParam.Init(); //-- reset all data |
|
1369 |
fmtParam.SetFileSystemName(KFSName2); |
|
1370 |
||
1371 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf); |
|
1372 |
test(nRes==KErrNotSupported); |
|
1373 |
format.Close(); |
|
1374 |
||
1375 |
||
1376 |
nRes = TheFs.FileSystemName(fsName, gDriveNum); |
|
1377 |
test(fsName.CompareF(KFSName1) == 0); |
|
1378 |
CheckFsOperations(); |
|
1379 |
||
1380 |
nRes = VerifyCheckableFile(TheFs, KTestFile); |
|
1381 |
test(nRes==KErrNone); |
|
1382 |
||
1383 |
||
1384 |
//-- 1.3 corrupt the media and check formatting with the FS Name that doesn't match the FS bound to this drive |
|
1385 |
//-- this shall fail |
|
1386 |
test.Printf(_L("fmt: ESpecialFormat, specifying wrong FS name #3\n")); |
|
1387 |
CorruptDrive(); |
|
1388 |
||
1389 |
fmtParam.Init(); //-- reset all data |
|
1390 |
fmtParam.SetFileSystemName(_L("some filesystem name")); |
|
1391 |
||
1392 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf); |
|
1393 |
test(nRes==KErrNotSupported); |
|
1394 |
format.Close(); |
|
1395 |
||
1396 |
test.Printf(_L("fmt: ESpecialFormat, specifying wrong FS name #4\n")); |
|
1397 |
fmtParam.Init(); //-- reset all data |
|
1398 |
fmtParam.SetFileSystemName(KFSName2); |
|
1399 |
||
1400 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf); |
|
1401 |
test(nRes==KErrNotSupported); |
|
1402 |
format.Close(); |
|
1403 |
||
1404 |
//-- 1.4 specify the correct file system name (bound to this drive) formatting must succeed |
|
1405 |
test.Printf(_L("fmt: ESpecialFormat, specifying correct FS name\n")); |
|
1406 |
fmtParam.Init(); //-- reset all data |
|
1407 |
fmtParam.SetFileSystemName(KFSName1); |
|
1408 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf); |
|
1409 |
test(nRes==KErrNone); |
|
1410 |
||
1411 |
nRes = DoFormatSteps(format, fmtCnt); |
|
1412 |
test(nRes==KErrNone); |
|
1413 |
||
1414 |
format.Close(); |
|
1415 |
||
1416 |
nRes = TheFs.FileSystemName(fsName, gDriveNum); |
|
1417 |
test(fsName.CompareF(KFSName1) == 0); |
|
1418 |
CheckFsOperations(); |
|
1419 |
||
1420 |
||
1421 |
} |
|
1422 |
||
1423 |
//------------------------------------------------------------------- |
|
1424 |
/** |
|
1425 |
Test formatting FAT file system with some specific parameters, like sector per cluster etc. |
|
1426 |
Note that some media types (like SD cards) do not support such type of formatting. |
|
1427 |
*/ |
|
1428 |
void TestFormatting_FsName_Parameters_FAT() |
|
1429 |
{ |
|
1430 |
using namespace FileSystem_FAT; |
|
1431 |
||
1432 |
test.Next(_L("Testing TVolFormatParam_FAT formatting API\n")); |
|
1433 |
||
1434 |
TInt nRes; |
|
271 | 1435 |
TFSName fsName(0); |
0 | 1436 |
|
1437 |
TBuf<10> drivePath; |
|
1438 |
drivePath.Format(_L("%C:\\"), gDriveNum+'A'); |
|
1439 |
||
1440 |
RFormat format; |
|
1441 |
TUint fmtMode = EQuickFormat | ESpecialFormat; |
|
1442 |
TInt fmtCnt; |
|
1443 |
||
1444 |
//================================================================================ |
|
1445 |
//-- 0. prepare the volume |
|
1446 |
Mount_FileSystem1(); |
|
1447 |
FormatVolume(); //-- old API, formatting with all parameters by default |
|
1448 |
||
1449 |
//================================================================================ |
|
1450 |
//-- 1.0 simple unit test for TVolFormatParam_FAT |
|
1451 |
TVolFormatParam_FATBuf fmtParamBuf_FAT; |
|
1452 |
TVolFormatParam_FAT& fmtParam_FAT = fmtParamBuf_FAT(); |
|
1453 |
||
1454 |
fmtParam_FAT.SetFatSubType(EFat32); |
|
1455 |
test(fmtParam_FAT.FatSubType() == EFat32); |
|
1456 |
||
1457 |
fmtParam_FAT.SetFatSubType(EFat12); |
|
1458 |
test(fmtParam_FAT.FatSubType() == EFat12); |
|
1459 |
||
1460 |
fmtParam_FAT.SetFatSubType(EFat16); |
|
1461 |
test(fmtParam_FAT.FatSubType() == EFat16); |
|
1462 |
||
1463 |
fmtParam_FAT.SetFatSubType(ENotSpecified); |
|
1464 |
test(fmtParam_FAT.FatSubType() == ENotSpecified); |
|
1465 |
||
1466 |
fmtParam_FAT.SetFatSubType(KFSSubType_FAT32); |
|
1467 |
test(fmtParam_FAT.FatSubType() == EFat32); |
|
1468 |
||
1469 |
fmtParam_FAT.SetFatSubType(KFSSubType_FAT12); |
|
1470 |
test(fmtParam_FAT.FatSubType() == EFat12); |
|
1471 |
||
1472 |
fmtParam_FAT.SetFatSubType(KFSSubType_FAT16); |
|
1473 |
test(fmtParam_FAT.FatSubType() == EFat16); |
|
1474 |
||
1475 |
||
1476 |
fmtParam_FAT.SetSectPerCluster(64); |
|
1477 |
test(fmtParam_FAT.SectPerCluster()==64); |
|
1478 |
||
1479 |
fmtParam_FAT.SetNumFATs(1); |
|
1480 |
test(fmtParam_FAT.NumFATs()==1); |
|
1481 |
||
1482 |
fmtParam_FAT.SetReservedSectors(13); |
|
1483 |
test(fmtParam_FAT.ReservedSectors()==13); |
|
1484 |
||
1485 |
||
1486 |
fmtParam_FAT.Init(); |
|
1487 |
test(fmtParam_FAT.FatSubType() == ENotSpecified); |
|
1488 |
test(fmtParam_FAT.SectPerCluster() == 0); |
|
1489 |
test(fmtParam_FAT.NumFATs()==0); |
|
1490 |
test(fmtParam_FAT.ReservedSectors()==0); |
|
1491 |
||
1492 |
||
1493 |
//--- formatting FAT without specifying any parameters. This shall always succeed |
|
1494 |
test.Printf(_L("fmt: using TVolFormatParam_FAT, no parameters.\n")); |
|
1495 |
||
1496 |
fmtParam_FAT.Init(); |
|
1497 |
||
1498 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf_FAT); |
|
1499 |
test(nRes==KErrNone); |
|
1500 |
||
1501 |
nRes = DoFormatSteps(format, fmtCnt); |
|
1502 |
test(nRes==KErrNone); |
|
1503 |
||
1504 |
format.Close(); |
|
1505 |
||
1506 |
//-- formatting FAT with specifying some parameters. This may fail because the media doesn't support overriding FAT parameters |
|
1507 |
//-- or because this parameters combination isn't compatible with the volume geometry. |
|
1508 |
||
1509 |
test.Printf(_L("fmt: using TVolFormatParam_FAT, some FAT specific parameters.\n")); |
|
1510 |
fmtParam_FAT.SetFatSubType(EFat32); |
|
1511 |
fmtParam_FAT.SetSectPerCluster(1); |
|
1512 |
fmtParam_FAT.SetNumFATs(1); |
|
1513 |
fmtParam_FAT.SetReservedSectors(13); |
|
1514 |
||
1515 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf_FAT); |
|
1516 |
test(nRes==KErrNone); |
|
1517 |
||
1518 |
nRes = DoFormatSteps(format, fmtCnt); |
|
1519 |
if(nRes != KErrNone) |
|
1520 |
{ |
|
1521 |
test.Printf(_L("formatting failed. reason code:%d\n"), nRes); |
|
1522 |
} |
|
1523 |
||
1524 |
format.Close(); |
|
1525 |
||
1526 |
nRes = TheFs.FileSystemName(fsName, gDriveNum); |
|
1527 |
test(fsName.CompareF(KFSName1) == 0); |
|
1528 |
||
1529 |
CheckFsOperations(); |
|
1530 |
||
1531 |
} |
|
1532 |
||
1533 |
//------------------------------------------------------------------- |
|
1534 |
/** |
|
1535 |
Test formatting FAT file system with some specific parameters, like sector per cluster etc. |
|
1536 |
Note that some media types (like SD cards) do not support such type of formatting. |
|
1537 |
*/ |
|
1538 |
||
1539 |
void TestFormatting_FsName_Parameters_exFAT() |
|
1540 |
{ |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1541 |
|
0 | 1542 |
|
1543 |
test.Next(_L("Testing TVolFormatParam_exFAT formatting API\n")); |
|
1544 |
||
1545 |
TInt nRes; |
|
271 | 1546 |
TFSName fsName(0); |
0 | 1547 |
|
1548 |
TBuf<10> drivePath; |
|
1549 |
drivePath.Format(_L("%C:\\"), gDriveNum+'A'); |
|
1550 |
||
1551 |
RFormat format; |
|
1552 |
TUint fmtMode = EQuickFormat | ESpecialFormat; |
|
1553 |
TInt fmtCnt; |
|
1554 |
||
1555 |
||
1556 |
//================================================================================ |
|
1557 |
//-- 0. prepare the volume |
|
1558 |
Mount_FileSystem2(); |
|
1559 |
FormatVolume(); //-- old API, formatting with all parameters by default |
|
1560 |
||
1561 |
//================================================================================ |
|
1562 |
//-- 1.0 simple unit test for TVolFormatParam_FAT |
|
1563 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1564 |
#ifndef EXFAT_MIGHT_NOT_BE_PRESENT |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1565 |
TVolFormatParam_exFATBuf fmtParamBuf; |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1566 |
TVolFormatParam_exFAT& fmtParam = fmtParamBuf(); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1567 |
#else |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1568 |
//-- see the comments to "EXFAT_MIGHT_NOT_BE_PRESENT" macro definition |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1569 |
TVolFormatParam_FATBuf fmtParamBuf; |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1570 |
TVolFormatParam_FAT& fmtParam= fmtParamBuf(); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1571 |
#endif |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1572 |
|
0 | 1573 |
|
1574 |
fmtParam.SetSectPerCluster(64); |
|
1575 |
test(fmtParam.SectPerCluster()==64); |
|
1576 |
||
1577 |
fmtParam.SetSectPerCluster(14); |
|
1578 |
test(fmtParam.SectPerCluster()==14); |
|
1579 |
||
1580 |
fmtParam.SetNumFATs(1); |
|
1581 |
test(fmtParam.NumFATs()==1); |
|
1582 |
||
1583 |
fmtParam.SetNumFATs(2); |
|
1584 |
test(fmtParam.NumFATs()==2); |
|
1585 |
||
1586 |
fmtParam.Init(); |
|
1587 |
test(fmtParam.SectPerCluster() == 0); |
|
1588 |
test(fmtParam.NumFATs()==0); |
|
1589 |
||
1590 |
||
1591 |
//--- formatting exFAT without specifying any parameters. This shall always succeed |
|
1592 |
test.Printf(_L("fmt: using TVolFormatParam_exFAT, no parameters.\n")); |
|
1593 |
fmtParam.Init(); |
|
1594 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1595 |
#ifdef EXFAT_MIGHT_NOT_BE_PRESENT |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1596 |
//-- need to forcedly set exFAT FS name, because fmtParam.Init(); set it to "FAT" |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1597 |
((TVolFormatParam&)fmtParam).SetFileSystemName(KFSName2); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1598 |
#endif |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1599 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1600 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf); |
0 | 1601 |
test(nRes==KErrNone); |
1602 |
||
1603 |
nRes = DoFormatSteps(format, fmtCnt); |
|
1604 |
test(nRes==KErrNone); |
|
1605 |
||
1606 |
format.Close(); |
|
1607 |
||
1608 |
//-- formatting exFAT with specifying some parameters. This may fail because the media doesn't support overriding FAT parameters |
|
1609 |
//-- or because this parameters combination isn't compatible with the volume geometry. |
|
1610 |
||
1611 |
test.Printf(_L("fmt: using TVolFormatParam_exFAT, some exFAT specific parameters.\n")); |
|
1612 |
||
1613 |
fmtParam.SetSectPerCluster(1); |
|
1614 |
fmtParam.SetNumFATs(2); |
|
1615 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1616 |
nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf); |
0 | 1617 |
test(nRes==KErrNone); |
1618 |
||
1619 |
nRes = DoFormatSteps(format, fmtCnt); |
|
1620 |
if(nRes != KErrNone) |
|
1621 |
{ |
|
1622 |
test.Printf(_L("formatting failed. reason code:%d\n"), nRes); |
|
1623 |
} |
|
1624 |
||
1625 |
format.Close(); |
|
1626 |
||
1627 |
nRes = TheFs.FileSystemName(fsName, gDriveNum); |
|
1628 |
test(fsName.CompareF(KFSName2) == 0); |
|
1629 |
||
1630 |
CheckFsOperations(); |
|
1631 |
} |
|
1632 |
||
1633 |
//------------------------------------------------------------------- |
|
271 | 1634 |
/** |
1635 |
A helper method. Unloads and loads back automounter FSY plugin. |
|
1636 |
This makes it re-parse its config either from estart.txt or from the debug property if it is set. |
|
1637 |
*/ |
|
1638 |
void MakeAutomounterReparseConfig() |
|
1639 |
{ |
|
1640 |
//-- make automounter re-parse the config property |
|
1641 |
ForceDismountFS(); |
|
1642 |
||
1643 |
TInt nRes = TheFs.RemoveFileSystem(KAutoMounterFSName); |
|
1644 |
test(nRes == KErrNone); |
|
1645 |
||
1646 |
nRes = TheFs.AddFileSystem(KAutoMounterFsy); |
|
1647 |
test(nRes == KErrNone); |
|
1648 |
} |
|
1649 |
||
1650 |
||
1651 |
//------------------------------------------------------------------- |
|
1652 |
/** |
|
1653 |
Test how the automounter supports only 1 child FS configured. |
|
1654 |
Everything should be the same as in the case with multiple childs, apart from the use case |
|
1655 |
of formatting the unrecognisable media. |
|
1656 |
||
1657 |
In this case such formatting should succeed, because the one and only child FS will be used for this |
|
1658 |
*/ |
|
1659 |
void TestHandlingOneChildFS() |
|
1660 |
{ |
|
1661 |
test.Next(_L("Testing automounter with the only 1 Child FS bound\n")); |
|
1662 |
||
1663 |
TInt nRes; |
|
1664 |
TBuf8<50> cfgBuf(0); |
|
1665 |
||
1666 |
//================================================================================ |
|
1667 |
//-- make automounter configuration property that has only one child FS |
|
1668 |
//-- and this looks like: 'FSNames fat' |
|
1669 |
||
1670 |
cfgBuf.Append(KKey_ChildFsList); |
|
1671 |
||
1672 |
cfgBuf.Append(_L(" ")); |
|
1673 |
cfgBuf.Append(KFSName1); |
|
1674 |
||
1675 |
nRes = RProperty::Set(KThisTestSID, KPropKey, cfgBuf); |
|
1676 |
test_KErrNone(nRes); |
|
1677 |
||
1678 |
//-- make automounter re-parse the config property |
|
1679 |
MakeAutomounterReparseConfig(); |
|
1680 |
||
1681 |
//================================================================================ |
|
1682 |
//-- 1. prepare the volume |
|
1683 |
Mount_FileSystem1(); |
|
1684 |
FormatVolume(); |
|
1685 |
||
1686 |
TFSName fsName; |
|
1687 |
TFSName fsSubType; |
|
1688 |
||
1689 |
||
1690 |
//================================================================================ |
|
1691 |
//-- 2. mount "automounter", previous FS must be recognised and set as an active child |
|
1692 |
Mount_AutomounterFS(); |
|
1693 |
||
1694 |
//-- check file system name / subtype etc. |
|
1695 |
nRes = TheFs.FileSystemName(fsName, gDriveNum); |
|
1696 |
test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS |
|
1697 |
test_KErrNone(nRes); |
|
1698 |
||
1699 |
//-- the FS Subtype must be the subtype of the recognised child FS |
|
1700 |
nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType); |
|
1701 |
test_KErrNone(nRes); |
|
1702 |
CheckSubtype_FS1(fsSubType); |
|
1703 |
||
1704 |
//================================================================================ |
|
1705 |
//-- 3. check the list of supported file system names |
|
1706 |
nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, RFs::KRootFileSystem); //-- "root" filesystem |
|
1707 |
test(nRes == KErrNone && fsName.CompareF(KAutoMounterFSName) == 0); |
|
1708 |
test.Printf(_L("Root FS:'%S'\n"), &fsName); |
|
1709 |
||
1710 |
fsName.SetLength(0); |
|
1711 |
nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, 0); //-- 1st "child" filesystem |
|
1712 |
test(nRes == KErrNone && fsName.CompareF(KFSName1) == 0); |
|
1713 |
||
1714 |
fsName.SetLength(0); |
|
1715 |
nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, 1); //-- 2nd "child" filesystem can't be found, it doesn't exist in config |
|
1716 |
test(nRes == KErrNotFound); |
|
1717 |
||
1718 |
//================================================================================ |
|
1719 |
//-- 4. corrupt the media, check that FS is not recognised. |
|
1720 |
CorruptDrive(); |
|
1721 |
||
1722 |
//-- check file system name / subtype etc. |
|
1723 |
nRes = TheFs.FileSystemName(fsName, gDriveNum); |
|
1724 |
test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS |
|
1725 |
test_KErrNone(nRes); |
|
1726 |
||
1727 |
//-- the FS Subtype query requires mounted and recognised file system. this shall fail |
|
1728 |
nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType); |
|
1729 |
test(nRes == KErrCorrupt); |
|
1730 |
||
1731 |
//================================================================================ |
|
1732 |
//-- 5. format the volume, this must be OK, because there is only 1 child file system |
|
1733 |
FormatVolume(); |
|
1734 |
CheckFsOperations(); |
|
1735 |
||
1736 |
//-- the FS Subtype must be the subtype of the recognised child FS |
|
1737 |
nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType); |
|
1738 |
test_KErrNone(nRes); |
|
1739 |
CheckSubtype_FS1(fsSubType); |
|
1740 |
||
1741 |
||
1742 |
||
1743 |
} |
|
1744 |
||
1745 |
//------------------------------------------------------------------- |
|
1746 |
/** |
|
1747 |
A helper method that does the real job: |
|
1748 |
- makes automounter config in a test property, specifying child FS for formatting unrecognisable media |
|
1749 |
- corrupts the drive |
|
1750 |
- format the drive w/o specifying the child FS |
|
1751 |
- check that the child FS from the config had been used for formatting |
|
1752 |
||
1753 |
||
1754 |
*/ |
|
1755 |
void DoTestDefaultChildForFormatting(TInt aChildIdx) |
|
1756 |
{ |
|
1757 |
||
1758 |
TInt nRes; |
|
1759 |
TBuf8<50> cfgBuf(0); |
|
1760 |
||
1761 |
//================================================================================ |
|
1762 |
//-- make automounter configuration property that 2 child FS and explicitly specifies a child FS for formatting unrecognisable media |
|
1763 |
//-- and this looks like: 'FSNames fat, exfat' |
|
1764 |
//-- DefFmtFsIdx 1 |
|
1765 |
||
1766 |
cfgBuf.Append(KKey_ChildFsList); |
|
1767 |
||
1768 |
cfgBuf.Append(_L(" ")); |
|
1769 |
cfgBuf.Append(KFSName1); |
|
1770 |
cfgBuf.Append(_L(" , ")); |
|
1771 |
cfgBuf.Append(KFSName2); |
|
1772 |
||
1773 |
cfgBuf.AppendFormat(_L8("\n%S %d"), &KProp_DefFmtFsIdx(), aChildIdx); |
|
1774 |
||
1775 |
nRes = RProperty::Set(KThisTestSID, KPropKey, cfgBuf); |
|
1776 |
test_KErrNone(nRes); |
|
1777 |
||
1778 |
//-- make automounter re-parse the config property |
|
1779 |
MakeAutomounterReparseConfig(); |
|
1780 |
||
1781 |
||
1782 |
//================================================================================ |
|
1783 |
//-- 1. mount "automounter" |
|
1784 |
Mount_AutomounterFS(); |
|
1785 |
||
1786 |
TFSName fsName; |
|
1787 |
TFSName fsSubType; |
|
1788 |
||
1789 |
//================================================================================ |
|
1790 |
//-- 2. corrupt the media, check that FS is not recognised. |
|
1791 |
CorruptDrive(); |
|
1792 |
||
1793 |
//-- check file system name / subtype etc. |
|
1794 |
nRes = TheFs.FileSystemName(fsName, gDriveNum); |
|
1795 |
test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS |
|
1796 |
test_KErrNone(nRes); |
|
1797 |
||
1798 |
//-- the FS Subtype query requires mounted and recognised file system. this shall fail |
|
1799 |
nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType); |
|
1800 |
test(nRes == KErrCorrupt); |
|
1801 |
||
1802 |
||
1803 |
//================================================================================ |
|
1804 |
//-- 3. format the volume, this must be OK, because the child FS for corrupting unrecognised media is specified |
|
1805 |
FormatVolume(); |
|
1806 |
CheckFsOperations(); |
|
1807 |
||
1808 |
//-- the FS Subtype must be the subtype of the recognised child FS |
|
1809 |
nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType); |
|
1810 |
test_KErrNone(nRes); |
|
1811 |
||
1812 |
if(aChildIdx == 0) //-- child idx=0, see cfgBuf |
|
1813 |
CheckSubtype_FS1(fsSubType); |
|
1814 |
else if(aChildIdx == 1) //-- child idx=1, see cfgBuf1 |
|
1815 |
CheckSubtype_FS2(fsSubType); |
|
1816 |
else |
|
1817 |
test(0); |
|
1818 |
||
1819 |
||
1820 |
||
1821 |
||
1822 |
} |
|
1823 |
||
1824 |
//------------------------------------------------------------------- |
|
1825 |
/** |
|
1826 |
test a special case of formatting unrecognisable media, when automounter is configured to use |
|
1827 |
some explicit child FS for this |
|
1828 |
*/ |
|
1829 |
void TestDefaultChildForFormatting() |
|
1830 |
{ |
|
1831 |
test.Next(_L("Test automounter formatting unrecognisable media when child FS is explicitly specified\n")); |
|
1832 |
||
1833 |
const TInt KDefFmtChild_FAT = 0; //-- child FS#0 FAT |
|
1834 |
const TInt KDefFmtChild_ExFAT = 1; //-- child FS#1 exFAT |
|
1835 |
||
1836 |
DoTestDefaultChildForFormatting(KDefFmtChild_FAT); |
|
1837 |
DoTestDefaultChildForFormatting(KDefFmtChild_ExFAT); |
|
1838 |
||
1839 |
//-- do this test to check that this particular config hasn't broken automounter functionality |
|
1840 |
TestFixedFsFormatting_FsNameSpecified(); |
|
1841 |
} |
|
1842 |
||
1843 |
//------------------------------------------------------------------- |
|
0 | 1844 |
|
1845 |
void CallTestsL() |
|
1846 |
{ |
|
1847 |
||
1848 |
//-- set up console output |
|
1849 |
Fat_Test_Utils::SetConsole(test.Console()); |
|
1850 |
||
1851 |
#ifndef _DEBUG |
|
1852 |
//-- automounter has a special debug interface allowing to control child file ssytems mounting in _DEBUG mode only |
|
1853 |
test.Printf(_L("Skipping the test in the Release build! \n")); |
|
1854 |
return; |
|
1855 |
#else |
|
1856 |
||
1857 |
TInt nRes=TheFs.CharToDrive(gDriveToTest, gDriveNum); |
|
1858 |
test(nRes==KErrNone); |
|
1859 |
||
1860 |
||
1861 |
//------------------------------------- |
|
1862 |
||
1863 |
PrintDrvInfo(TheFs, gDriveNum); |
|
1864 |
||
1865 |
TVolumeInfo v; |
|
1866 |
nRes = TheFs.Volume(v); |
|
1867 |
test(nRes==KErrNone); |
|
1868 |
if(v.iDrive.iMediaAtt & KMediaAttVariableSize) |
|
1869 |
{ |
|
1870 |
test.Printf(_L("Skipping. Internal ram drive not tested.\n")); |
|
1871 |
return; |
|
1872 |
} |
|
1873 |
||
1874 |
if(v.iDrive.iType != EMediaHardDisk || !(v.iDrive.iDriveAtt & KDriveAttRemovable)) |
|
1875 |
{ |
|
1876 |
test.Printf(_L("The drive shall be removable and the media type EMediaHardDisk. Skipping.\n")); |
|
1877 |
return; |
|
1878 |
} |
|
1879 |
||
1880 |
||
1881 |
//------------------------------------- |
|
1882 |
||
1883 |
if(InitGlobals()) |
|
1884 |
{//-- do tests here |
|
1885 |
||
1886 |
TestAutomounterBasics(); |
|
1887 |
TestDismounting(); |
|
1888 |
TestFixedFsFormatting_FsNameSpecified(); |
|
1889 |
||
1890 |
TestAutomounterDefaultFormatting(); |
|
1891 |
TestAutomounterFormatting_FsNameSpecified(); |
|
1892 |
||
1893 |
TestFormatting_FsName_Parameters_FAT(); |
|
1894 |
TestFormatting_FsName_Parameters_exFAT(); |
|
1895 |
||
271 | 1896 |
//-- these 2 tests must be the last ones before calling DestroyGlobals() |
1897 |
//-- they fiddle with the automounter config and may affect following tests. |
|
1898 |
TestHandlingOneChildFS(); |
|
1899 |
TestDefaultChildForFormatting(); |
|
1900 |
||
0 | 1901 |
} |
1902 |
//------------------------------------- |
|
271 | 1903 |
|
0 | 1904 |
DestroyGlobals(); |
1905 |
#endif |
|
1906 |
} |
|
1907 |
||
1908 |
||
1909 |
||
1910 |
||
1911 |
||
1912 |
||
1913 |
||
1914 |
||
1915 |
||
1916 |
||
1917 |
||
1918 |
||
1919 |
||
1920 |
||
1921 |
||
1922 |
||
1923 |
||
1924 |