sl@0
|
1 |
// Copyright (c) 2002-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\ext\t_ext1.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <f32file.h>
|
sl@0
|
19 |
#include <e32test.h>
|
sl@0
|
20 |
#include <e32svr.h>
|
sl@0
|
21 |
#include "t_server.h"
|
sl@0
|
22 |
#include "f32_test_utils.h"
|
sl@0
|
23 |
|
sl@0
|
24 |
using namespace F32_Test_Utils;
|
sl@0
|
25 |
|
sl@0
|
26 |
|
sl@0
|
27 |
GLDEF_D RTest test(_L("T_EXT1"));
|
sl@0
|
28 |
|
sl@0
|
29 |
_LIT(KExtensionLog,"T_LOGEXT");
|
sl@0
|
30 |
_LIT(KExtensionLogName,"Logger");
|
sl@0
|
31 |
_LIT(KExtensionEmpty,"T_EMPTYEXT");
|
sl@0
|
32 |
_LIT(KExtensionEmptyName,"Empty");
|
sl@0
|
33 |
_LIT(KExtensionBit,"T_BITEXT");
|
sl@0
|
34 |
_LIT(KExtensionBitName,"Bitchange");
|
sl@0
|
35 |
_LIT(KExtensionRubbish,"T_RUBBISH");
|
sl@0
|
36 |
_LIT(dir1,"\\dir1\\");
|
sl@0
|
37 |
_LIT(file1Name,"\\dir1\\file1.doc");
|
sl@0
|
38 |
_LIT8(toWrite,"abcdefghijklmnop");
|
sl@0
|
39 |
|
sl@0
|
40 |
void TestSecondaryExtensions()
|
sl@0
|
41 |
//
|
sl@0
|
42 |
// a secondary extension is one that is added to a drive with an existing file system
|
sl@0
|
43 |
// therefore a mount is successful with or without the extension
|
sl@0
|
44 |
//
|
sl@0
|
45 |
{
|
sl@0
|
46 |
test.Next(_L("TestSecondaryExtensions()"));
|
sl@0
|
47 |
TInt drive;
|
sl@0
|
48 |
TInt err=RFs::CharToDrive(gDriveToTest,drive);
|
sl@0
|
49 |
test(err==KErrNone);
|
sl@0
|
50 |
|
sl@0
|
51 |
TPckgBuf<TBool> drvSyncBuf;
|
sl@0
|
52 |
err = TheFs.QueryVolumeInfoExt(drive, EIsDriveSync, drvSyncBuf);
|
sl@0
|
53 |
test(err==KErrNone);
|
sl@0
|
54 |
const TBool bDrvSync = drvSyncBuf();
|
sl@0
|
55 |
|
sl@0
|
56 |
|
sl@0
|
57 |
TFullName fsName;
|
sl@0
|
58 |
TInt r=TheFs.FileSystemName(fsName,drive);
|
sl@0
|
59 |
test(r==KErrNone);
|
sl@0
|
60 |
test.Printf(_L("fsName=%S\n"),&fsName);
|
sl@0
|
61 |
|
sl@0
|
62 |
#if defined(__WINS__)
|
sl@0
|
63 |
if(drive==EDriveC)
|
sl@0
|
64 |
{
|
sl@0
|
65 |
// check that the extension cannot be mounted since not supported by the file system
|
sl@0
|
66 |
r=TheFs.AddExtension(KExtensionLog);
|
sl@0
|
67 |
test(r==KErrNone);
|
sl@0
|
68 |
r=TheFs.MountExtension(KExtensionLogName,drive);
|
sl@0
|
69 |
test(r==KErrNotSupported);
|
sl@0
|
70 |
r=TheFs.RemoveExtension(KExtensionLogName);
|
sl@0
|
71 |
test(r==KErrNone);
|
sl@0
|
72 |
return;
|
sl@0
|
73 |
}
|
sl@0
|
74 |
#endif
|
sl@0
|
75 |
|
sl@0
|
76 |
test.Next(_L("RFs::AddExtension()"));
|
sl@0
|
77 |
r=TheFs.AddExtension(KExtensionLog);
|
sl@0
|
78 |
RDebug::Print(_L("addext=%d"),r);
|
sl@0
|
79 |
test(r==KErrNone);
|
sl@0
|
80 |
r=TheFs.AddExtension(KExtensionLog);
|
sl@0
|
81 |
test(r==KErrAlreadyExists);
|
sl@0
|
82 |
r=TheFs.AddExtension(KExtensionRubbish);
|
sl@0
|
83 |
test(r==KErrNotFound);
|
sl@0
|
84 |
r=TheFs.AddExtension(KExtensionEmpty);
|
sl@0
|
85 |
test(r==KErrNone);
|
sl@0
|
86 |
|
sl@0
|
87 |
test.Next(_L("RFs::MountExtension()"));
|
sl@0
|
88 |
#if !defined(__WINS__)
|
sl@0
|
89 |
// check that the extension cannot be mounted on file system that does not support extensions
|
sl@0
|
90 |
r=TheFs.MountExtension(KExtensionLogName,EDriveZ);
|
sl@0
|
91 |
test(r==KErrNotSupported);
|
sl@0
|
92 |
#endif
|
sl@0
|
93 |
// test mounting on drive with no file system
|
sl@0
|
94 |
r=TheFs.DismountFileSystem(fsName,drive);
|
sl@0
|
95 |
test(r==KErrNone);
|
sl@0
|
96 |
r=TheFs.MountExtension(KExtensionLogName,drive);
|
sl@0
|
97 |
test(r==KErrNotReady);
|
sl@0
|
98 |
r=TheFs.MountFileSystem(fsName,drive,bDrvSync);
|
sl@0
|
99 |
test(r==KErrNone);
|
sl@0
|
100 |
// test with a resource open
|
sl@0
|
101 |
_LIT(KFileName,"testing.doc");
|
sl@0
|
102 |
RFile file;
|
sl@0
|
103 |
r=file.Replace(TheFs,KFileName,EFileShareExclusive);
|
sl@0
|
104 |
test(r==KErrNone);
|
sl@0
|
105 |
r=TheFs.MountExtension(KExtensionLogName,drive);
|
sl@0
|
106 |
test(r==KErrInUse);
|
sl@0
|
107 |
file.Close();
|
sl@0
|
108 |
r=TheFs.Delete(KFileName);
|
sl@0
|
109 |
test(r==KErrNone);
|
sl@0
|
110 |
// test with a format open
|
sl@0
|
111 |
TBuf<4> driveBuf=_L("?:\\");
|
sl@0
|
112 |
driveBuf[0]=(TText)(drive+'A');
|
sl@0
|
113 |
RFormat format;
|
sl@0
|
114 |
TInt count;
|
sl@0
|
115 |
r=format.Open(TheFs,driveBuf,EHighDensity,count);
|
sl@0
|
116 |
test(r==KErrNone);
|
sl@0
|
117 |
r=TheFs.MountExtension(KExtensionLogName,drive);
|
sl@0
|
118 |
test(r==KErrInUse);
|
sl@0
|
119 |
format.Close();
|
sl@0
|
120 |
// get the extension name
|
sl@0
|
121 |
TFullName extName;
|
sl@0
|
122 |
r=TheFs.ExtensionName(extName,drive,0);
|
sl@0
|
123 |
test(r==KErrNotFound);
|
sl@0
|
124 |
// now load the extension
|
sl@0
|
125 |
r=TheFs.MountExtension(KExtensionLogName,drive);
|
sl@0
|
126 |
test(r==KErrNone);
|
sl@0
|
127 |
r=TheFs.ExtensionName(extName,drive,0);
|
sl@0
|
128 |
test(r==KErrNone && extName==KExtensionLogName);
|
sl@0
|
129 |
r=TheFs.ExtensionName(extName,drive,1);
|
sl@0
|
130 |
test(r==KErrNotFound);
|
sl@0
|
131 |
// try remounting the same extension
|
sl@0
|
132 |
r=TheFs.MountExtension(KExtensionLogName,drive);
|
sl@0
|
133 |
test(r==KErrAlreadyExists);
|
sl@0
|
134 |
// mount a second extension
|
sl@0
|
135 |
r=TheFs.MountExtension(KExtensionEmptyName,drive);
|
sl@0
|
136 |
test(r==KErrNone);
|
sl@0
|
137 |
r=TheFs.ExtensionName(extName,drive,0);
|
sl@0
|
138 |
test(r==KErrNone && extName==KExtensionLogName);
|
sl@0
|
139 |
r=TheFs.ExtensionName(extName,drive,1);
|
sl@0
|
140 |
test(r==KErrNone && extName==KExtensionEmptyName);
|
sl@0
|
141 |
|
sl@0
|
142 |
// force a remount on a removable media and check that extensions both exist
|
sl@0
|
143 |
test.Printf(_L("Test forcing remount\n"));
|
sl@0
|
144 |
TDriveInfo info;
|
sl@0
|
145 |
r=TheFs.Drive(info,drive);
|
sl@0
|
146 |
if(info.iDriveAtt&KDriveAttRemovable)
|
sl@0
|
147 |
{
|
sl@0
|
148 |
const TInt KMediaRemountForceMediaChange = 0x00000001;
|
sl@0
|
149 |
|
sl@0
|
150 |
|
sl@0
|
151 |
TRequestStatus changeStatus;
|
sl@0
|
152 |
TheFs.NotifyChange(ENotifyAll, changeStatus);
|
sl@0
|
153 |
|
sl@0
|
154 |
test.Printf(_L("Remounting the drive\n"), r);
|
sl@0
|
155 |
r = TheFs.RemountDrive(drive, NULL, (TUint) KMediaRemountForceMediaChange);
|
sl@0
|
156 |
test(r == KErrNotReady || r == KErrNone);
|
sl@0
|
157 |
|
sl@0
|
158 |
do
|
sl@0
|
159 |
{
|
sl@0
|
160 |
test.Printf(_L("Waiting for media change...\n"));
|
sl@0
|
161 |
User::WaitForRequest(changeStatus);
|
sl@0
|
162 |
|
sl@0
|
163 |
r=TheFs.Drive(info,drive);
|
sl@0
|
164 |
test.Printf(_L("Drive() returned %d\n"), r);
|
sl@0
|
165 |
|
sl@0
|
166 |
TheFs.NotifyChange(ENotifyAll, changeStatus);
|
sl@0
|
167 |
}
|
sl@0
|
168 |
while (r == KErrNotReady);
|
sl@0
|
169 |
TheFs.NotifyChangeCancel(changeStatus);
|
sl@0
|
170 |
|
sl@0
|
171 |
User::After(1000000); //-- don't know why we need this, otherwise for WINS mediadriver returns -18
|
sl@0
|
172 |
|
sl@0
|
173 |
|
sl@0
|
174 |
|
sl@0
|
175 |
/*
|
sl@0
|
176 |
//-- strange, but this variant caused Media Driver to always return -18
|
sl@0
|
177 |
//-- and the media have become inaccessible forever (on H2).
|
sl@0
|
178 |
//-- funny enough, but turning ON heavy logging from the drivers (PBUS & KLOCDRV) helped the problem
|
sl@0
|
179 |
|
sl@0
|
180 |
test.Printf(_L("Force media change\n"));
|
sl@0
|
181 |
RLocalDrive d;
|
sl@0
|
182 |
TBool flag=EFalse;
|
sl@0
|
183 |
r=d.Connect(1,flag);
|
sl@0
|
184 |
test(r==KErrNone);
|
sl@0
|
185 |
d.ForceMediaChange();
|
sl@0
|
186 |
d.Close();
|
sl@0
|
187 |
//#if defined(__WINS__)
|
sl@0
|
188 |
// ??? seems to work, find out why
|
sl@0
|
189 |
//User::After(500000);
|
sl@0
|
190 |
User::After(2000000);
|
sl@0
|
191 |
//#endif
|
sl@0
|
192 |
*/
|
sl@0
|
193 |
}
|
sl@0
|
194 |
|
sl@0
|
195 |
|
sl@0
|
196 |
|
sl@0
|
197 |
r=TheFs.ExtensionName(extName,drive,0);
|
sl@0
|
198 |
test(r==KErrNone && extName==KExtensionLogName);
|
sl@0
|
199 |
r=TheFs.ExtensionName(extName,drive,1);
|
sl@0
|
200 |
test(r==KErrNone && extName==KExtensionEmptyName);
|
sl@0
|
201 |
|
sl@0
|
202 |
test.Printf(_L("Accessing media...\n"));
|
sl@0
|
203 |
// and now do some file system operations
|
sl@0
|
204 |
TBuf8<16> readBuf;
|
sl@0
|
205 |
r=TheFs.MkDir(dir1);
|
sl@0
|
206 |
|
sl@0
|
207 |
test.Printf(_L("res=%d\n"), r);
|
sl@0
|
208 |
|
sl@0
|
209 |
|
sl@0
|
210 |
test(r==KErrNone||r==KErrAlreadyExists);
|
sl@0
|
211 |
RFile file1;
|
sl@0
|
212 |
r=file1.Replace(TheFs,file1Name,EFileShareExclusive);
|
sl@0
|
213 |
test(r==KErrNone);
|
sl@0
|
214 |
r=file1.Write(toWrite);
|
sl@0
|
215 |
test(r==KErrNone);
|
sl@0
|
216 |
r=file1.Read(0,readBuf);
|
sl@0
|
217 |
test(readBuf==toWrite);
|
sl@0
|
218 |
r=file1.SetSize(0);
|
sl@0
|
219 |
test(r==KErrNone);
|
sl@0
|
220 |
file1.Close();
|
sl@0
|
221 |
r=TheFs.Delete(file1Name);
|
sl@0
|
222 |
test(r==KErrNone);
|
sl@0
|
223 |
r=TheFs.RmDir(dir1);
|
sl@0
|
224 |
test(r==KErrNone);
|
sl@0
|
225 |
|
sl@0
|
226 |
test.Next(_L("RFs::DismountExtension()"));
|
sl@0
|
227 |
// test with a resource open
|
sl@0
|
228 |
r=file.Replace(TheFs,KFileName,EFileShareExclusive);
|
sl@0
|
229 |
test(r==KErrNone);
|
sl@0
|
230 |
r=TheFs.DismountExtension(KExtensionLogName,drive);
|
sl@0
|
231 |
test(r==KErrInUse);
|
sl@0
|
232 |
file.Close();
|
sl@0
|
233 |
r=TheFs.Delete(KFileName);
|
sl@0
|
234 |
test(r==KErrNone);
|
sl@0
|
235 |
// test with a format open
|
sl@0
|
236 |
r=format.Open(TheFs,driveBuf,EHighDensity,count);
|
sl@0
|
237 |
test(r==KErrNone);
|
sl@0
|
238 |
r=TheFs.DismountExtension(KExtensionLogName,drive);
|
sl@0
|
239 |
test(r==KErrInUse);
|
sl@0
|
240 |
format.Close();
|
sl@0
|
241 |
// now dismount an extension
|
sl@0
|
242 |
r=TheFs.DismountExtension(KExtensionLogName,drive);
|
sl@0
|
243 |
test(r==KErrNone);
|
sl@0
|
244 |
r=TheFs.ExtensionName(extName,drive,0);
|
sl@0
|
245 |
test(r==KErrNone && extName==KExtensionEmptyName);
|
sl@0
|
246 |
r=TheFs.ExtensionName(extName,drive,1);
|
sl@0
|
247 |
test(r==KErrNotFound);
|
sl@0
|
248 |
// try to dismount an extension that is not mounted
|
sl@0
|
249 |
r=TheFs.DismountExtension(KExtensionLogName,drive);
|
sl@0
|
250 |
test(r==KErrNotFound);
|
sl@0
|
251 |
r=TheFs.ExtensionName(extName,drive,0);
|
sl@0
|
252 |
test(r==KErrNone && extName==KExtensionEmptyName);
|
sl@0
|
253 |
r=TheFs.ExtensionName(extName,drive,1);
|
sl@0
|
254 |
test(r==KErrNotFound);
|
sl@0
|
255 |
// dismount the remaining extension
|
sl@0
|
256 |
r=TheFs.DismountExtension(KExtensionEmptyName,drive);
|
sl@0
|
257 |
test(r==KErrNone);
|
sl@0
|
258 |
r=TheFs.ExtensionName(extName,drive,0);
|
sl@0
|
259 |
test(r==KErrNotFound);
|
sl@0
|
260 |
r=TheFs.ExtensionName(extName,drive,1);
|
sl@0
|
261 |
test(r==KErrNotFound);
|
sl@0
|
262 |
|
sl@0
|
263 |
test.Next(_L("RFs::RemoveExtension()"));
|
sl@0
|
264 |
r=TheFs.RemoveExtension(KExtensionLogName);
|
sl@0
|
265 |
test(r==KErrNone);
|
sl@0
|
266 |
r=TheFs.RemoveExtension(KExtensionEmptyName);
|
sl@0
|
267 |
test(r==KErrNone);
|
sl@0
|
268 |
}
|
sl@0
|
269 |
|
sl@0
|
270 |
void TestPrimaryExtensions()
|
sl@0
|
271 |
//
|
sl@0
|
272 |
// a primary extension is one that is added to a drive before a file system is mounted
|
sl@0
|
273 |
// must be present for the mount to be successful (eg. FTL)
|
sl@0
|
274 |
//
|
sl@0
|
275 |
{
|
sl@0
|
276 |
test.Next(_L("TestPrimaryExtensions()"));
|
sl@0
|
277 |
TInt drive;
|
sl@0
|
278 |
TInt err=RFs::CharToDrive(gDriveToTest,drive);
|
sl@0
|
279 |
test(err==KErrNone);
|
sl@0
|
280 |
|
sl@0
|
281 |
#if defined(__WINS__)
|
sl@0
|
282 |
if(drive==EDriveC)
|
sl@0
|
283 |
return;
|
sl@0
|
284 |
#endif
|
sl@0
|
285 |
|
sl@0
|
286 |
TPckgBuf<TBool> drvSyncBuf;
|
sl@0
|
287 |
err = TheFs.QueryVolumeInfoExt(drive, EIsDriveSync, drvSyncBuf);
|
sl@0
|
288 |
test(err==KErrNone);
|
sl@0
|
289 |
const TBool bDrvSync = drvSyncBuf();
|
sl@0
|
290 |
|
sl@0
|
291 |
// don't test on ram drive since accesses memory directly
|
sl@0
|
292 |
TDriveInfo info;
|
sl@0
|
293 |
TInt r=TheFs.Drive(info,drive);
|
sl@0
|
294 |
if(info.iMediaAtt&KMediaAttVariableSize)
|
sl@0
|
295 |
return;
|
sl@0
|
296 |
|
sl@0
|
297 |
TFullName fsName;
|
sl@0
|
298 |
r=TheFs.FileSystemName(fsName,drive);
|
sl@0
|
299 |
test(r==KErrNone);
|
sl@0
|
300 |
test.Printf(_L("fsName=%S\n"),&fsName);
|
sl@0
|
301 |
|
sl@0
|
302 |
test.Next(_L("RFs::AddExtension()"));
|
sl@0
|
303 |
r=TheFs.AddExtension(KExtensionLog);
|
sl@0
|
304 |
test(r==KErrNone);
|
sl@0
|
305 |
r=TheFs.AddExtension(KExtensionEmpty);
|
sl@0
|
306 |
test(r==KErrNone);
|
sl@0
|
307 |
r=TheFs.AddExtension(KExtensionBit);
|
sl@0
|
308 |
test(r==KErrNone);
|
sl@0
|
309 |
|
sl@0
|
310 |
test.Next(_L("RFs::MountFileSystem()"));
|
sl@0
|
311 |
// test with file system that already exists
|
sl@0
|
312 |
r=TheFs.MountFileSystem(fsName,KExtensionBitName,drive,bDrvSync);
|
sl@0
|
313 |
test(r==KErrAccessDenied);
|
sl@0
|
314 |
// unmount drive and mount primary extension along with file system
|
sl@0
|
315 |
r=TheFs.DismountFileSystem(fsName,drive);
|
sl@0
|
316 |
test(r==KErrNone);
|
sl@0
|
317 |
|
sl@0
|
318 |
//-- !! N.B this extension mangles data read/written ftom/to the media, for some file systems it is OK and mounting succeeds
|
sl@0
|
319 |
//-- for others - this will result in KErrCorrupt
|
sl@0
|
320 |
r=TheFs.MountFileSystem(fsName,KExtensionBitName,drive,bDrvSync);
|
sl@0
|
321 |
test(r==KErrNone||r==KErrCorrupt);
|
sl@0
|
322 |
|
sl@0
|
323 |
// and now format
|
sl@0
|
324 |
Format(drive);
|
sl@0
|
325 |
TFullName extName;
|
sl@0
|
326 |
r=TheFs.ExtensionName(extName,drive,0);
|
sl@0
|
327 |
test(r==KErrNone && extName==KExtensionBitName);
|
sl@0
|
328 |
r=TheFs.ExtensionName(extName,drive,1);
|
sl@0
|
329 |
test(r==KErrNotFound);
|
sl@0
|
330 |
|
sl@0
|
331 |
// and now do some file system operations
|
sl@0
|
332 |
TBuf8<16> readBuf;
|
sl@0
|
333 |
r=TheFs.MkDir(dir1);
|
sl@0
|
334 |
test(r==KErrNone||r==KErrAlreadyExists);
|
sl@0
|
335 |
RFile file1;
|
sl@0
|
336 |
r=file1.Replace(TheFs,file1Name,EFileShareExclusive);
|
sl@0
|
337 |
test(r==KErrNone);
|
sl@0
|
338 |
r=file1.Write(toWrite);
|
sl@0
|
339 |
test(r==KErrNone);
|
sl@0
|
340 |
r=file1.Read(0,readBuf);
|
sl@0
|
341 |
test(readBuf==toWrite);
|
sl@0
|
342 |
r=file1.SetSize(0);
|
sl@0
|
343 |
test(r==KErrNone);
|
sl@0
|
344 |
file1.Close();
|
sl@0
|
345 |
r=TheFs.Delete(file1Name);
|
sl@0
|
346 |
test(r==KErrNone);
|
sl@0
|
347 |
r=TheFs.RmDir(dir1);
|
sl@0
|
348 |
test(r==KErrNone);
|
sl@0
|
349 |
|
sl@0
|
350 |
// add a secondary extension
|
sl@0
|
351 |
test.Printf(_L("RFs::MountExtension()"));
|
sl@0
|
352 |
r=TheFs.MountExtension(KExtensionLogName,drive);
|
sl@0
|
353 |
test(r==KErrNone);
|
sl@0
|
354 |
r=TheFs.ExtensionName(extName,drive,0);
|
sl@0
|
355 |
test(r==KErrNone && extName==KExtensionBitName);
|
sl@0
|
356 |
r=TheFs.ExtensionName(extName,drive,1);
|
sl@0
|
357 |
test(r==KErrNone && extName==KExtensionLogName);
|
sl@0
|
358 |
// try to add the same extension
|
sl@0
|
359 |
r=TheFs.MountExtension(KExtensionBitName,drive);
|
sl@0
|
360 |
test(r==KErrAlreadyExists);
|
sl@0
|
361 |
r=TheFs.ExtensionName(extName,drive,0);
|
sl@0
|
362 |
test(r==KErrNone && extName==KExtensionBitName);
|
sl@0
|
363 |
r=TheFs.ExtensionName(extName,drive,1);
|
sl@0
|
364 |
test(r==KErrNone && extName==KExtensionLogName);
|
sl@0
|
365 |
// try to add a third extension
|
sl@0
|
366 |
r=TheFs.MountExtension(KExtensionEmptyName,drive);
|
sl@0
|
367 |
test(r==KErrAccessDenied);
|
sl@0
|
368 |
r=TheFs.ExtensionName(extName,drive,0);
|
sl@0
|
369 |
test(r==KErrNone && extName==KExtensionBitName);
|
sl@0
|
370 |
r=TheFs.ExtensionName(extName,drive,1);
|
sl@0
|
371 |
test(r==KErrNone && extName==KExtensionLogName);
|
sl@0
|
372 |
|
sl@0
|
373 |
// and now do some file system operations
|
sl@0
|
374 |
r=TheFs.MkDir(dir1);
|
sl@0
|
375 |
test(r==KErrNone||r==KErrAlreadyExists);
|
sl@0
|
376 |
r=file1.Replace(TheFs,file1Name,EFileShareExclusive);
|
sl@0
|
377 |
test(r==KErrNone);
|
sl@0
|
378 |
r=file1.Write(toWrite);
|
sl@0
|
379 |
test(r==KErrNone);
|
sl@0
|
380 |
r=file1.Read(0,readBuf);
|
sl@0
|
381 |
test(readBuf==toWrite);
|
sl@0
|
382 |
r=file1.SetSize(0);
|
sl@0
|
383 |
test(r==KErrNone);
|
sl@0
|
384 |
file1.Close();
|
sl@0
|
385 |
r=TheFs.Delete(file1Name);
|
sl@0
|
386 |
test(r==KErrNone);
|
sl@0
|
387 |
r=TheFs.RmDir(dir1);
|
sl@0
|
388 |
test(r==KErrNone);
|
sl@0
|
389 |
|
sl@0
|
390 |
test.Printf(_L("RFs::DismountExtension()"));
|
sl@0
|
391 |
// test that can't dismount a primary extension via this method
|
sl@0
|
392 |
r=TheFs.DismountExtension(KExtensionLogName,drive);
|
sl@0
|
393 |
test(r==KErrNone);
|
sl@0
|
394 |
r=TheFs.ExtensionName(extName,drive,0);
|
sl@0
|
395 |
test(r==KErrNone && extName==KExtensionBitName);
|
sl@0
|
396 |
r=TheFs.ExtensionName(extName,drive,1);
|
sl@0
|
397 |
test(r==KErrNotFound);
|
sl@0
|
398 |
r=TheFs.DismountExtension(KExtensionBitName,drive);
|
sl@0
|
399 |
test(r==KErrAccessDenied);
|
sl@0
|
400 |
r=TheFs.ExtensionName(extName,drive,0);
|
sl@0
|
401 |
test(r==KErrNone && extName==KExtensionBitName);
|
sl@0
|
402 |
r=TheFs.ExtensionName(extName,drive,1);
|
sl@0
|
403 |
test(r==KErrNotFound);
|
sl@0
|
404 |
|
sl@0
|
405 |
test.Printf(_L("RFs::DismountFileSystem()"));
|
sl@0
|
406 |
r=TheFs.MountExtension(KExtensionLogName,drive);
|
sl@0
|
407 |
test(r==KErrNone);
|
sl@0
|
408 |
r=TheFs.ExtensionName(extName,drive,0);
|
sl@0
|
409 |
test(r==KErrNone && extName==KExtensionBitName);
|
sl@0
|
410 |
r=TheFs.ExtensionName(extName,drive,1);
|
sl@0
|
411 |
test(r==KErrNone && extName==KExtensionLogName);
|
sl@0
|
412 |
// and now dismount
|
sl@0
|
413 |
r=TheFs.DismountFileSystem(fsName,drive);
|
sl@0
|
414 |
test(r==KErrNone);
|
sl@0
|
415 |
r=TheFs.ExtensionName(extName,drive,0);
|
sl@0
|
416 |
test(r==KErrNotReady);
|
sl@0
|
417 |
r=TheFs.ExtensionName(extName,drive,1);
|
sl@0
|
418 |
test(r==KErrNotReady);
|
sl@0
|
419 |
// remount the file system
|
sl@0
|
420 |
r=TheFs.MountFileSystem(fsName,drive,bDrvSync);
|
sl@0
|
421 |
test(r==KErrNone||r==KErrCorrupt);
|
sl@0
|
422 |
r=TheFs.ExtensionName(extName,drive,0);
|
sl@0
|
423 |
test(r==KErrNotFound);
|
sl@0
|
424 |
r=TheFs.ExtensionName(extName,drive,1);
|
sl@0
|
425 |
test(r==KErrNotFound);
|
sl@0
|
426 |
Format(drive);
|
sl@0
|
427 |
|
sl@0
|
428 |
test.Next(_L("RFs::RemoveExtension()"));
|
sl@0
|
429 |
r=TheFs.RemoveExtension(KExtensionLogName);
|
sl@0
|
430 |
test(r==KErrNone);
|
sl@0
|
431 |
r=TheFs.RemoveExtension(KExtensionEmptyName);
|
sl@0
|
432 |
test(r==KErrNone);
|
sl@0
|
433 |
r=TheFs.RemoveExtension(KExtensionBitName);
|
sl@0
|
434 |
test(r==KErrNone);
|
sl@0
|
435 |
}
|
sl@0
|
436 |
|
sl@0
|
437 |
|
sl@0
|
438 |
GLDEF_C void CallTestsL()
|
sl@0
|
439 |
//
|
sl@0
|
440 |
// Do tests relative to the session path
|
sl@0
|
441 |
//
|
sl@0
|
442 |
{
|
sl@0
|
443 |
//-- set up console output
|
sl@0
|
444 |
F32_Test_Utils::SetConsole(test.Console());
|
sl@0
|
445 |
|
sl@0
|
446 |
TInt drive;
|
sl@0
|
447 |
TInt err=RFs::CharToDrive(gDriveToTest,drive);
|
sl@0
|
448 |
test.Start(_L("Starting Test - T_EXT1"));
|
sl@0
|
449 |
test(err==KErrNone);
|
sl@0
|
450 |
|
sl@0
|
451 |
PrintDrvInfo(TheFs, drive);
|
sl@0
|
452 |
|
sl@0
|
453 |
//Do not run this test on the NAND drive, as
|
sl@0
|
454 |
//this has the FTL mounted as a primary extension
|
sl@0
|
455 |
//which causes the test to fail
|
sl@0
|
456 |
#if defined(__WINS__)
|
sl@0
|
457 |
if (drive==EDriveU)
|
sl@0
|
458 |
return;
|
sl@0
|
459 |
#else
|
sl@0
|
460 |
TDriveInfo driveInfo;
|
sl@0
|
461 |
TheFs.Drive(driveInfo,drive);
|
sl@0
|
462 |
if (driveInfo.iType == EMediaNANDFlash)
|
sl@0
|
463 |
{
|
sl@0
|
464 |
return;
|
sl@0
|
465 |
}
|
sl@0
|
466 |
#endif
|
sl@0
|
467 |
TestSecondaryExtensions();
|
sl@0
|
468 |
|
sl@0
|
469 |
//-- the t_bitext extension mangles data from the media, which may make FS mounting fail because of "corrupted" data.
|
sl@0
|
470 |
//-- Then this step formats the media, automounter doesn't support it straightforward way
|
sl@0
|
471 |
if(!Is_Lffs(TheFs, drive) && !Is_Automounter(TheFs, drive))
|
sl@0
|
472 |
{
|
sl@0
|
473 |
TestPrimaryExtensions();
|
sl@0
|
474 |
}
|
sl@0
|
475 |
|
sl@0
|
476 |
test.End();
|
sl@0
|
477 |
test.Close();
|
sl@0
|
478 |
}
|