0
|
1 |
// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// f32test\server\t_misc.cpp
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
123
|
18 |
#define __E32TEST_EXTENSION__
|
0
|
19 |
#include <f32file.h>
|
|
20 |
#include <e32test.h>
|
|
21 |
#include "t_server.h"
|
|
22 |
|
199
|
23 |
#include "f32_test_utils.h"
|
|
24 |
using namespace F32_Test_Utils;
|
|
25 |
|
|
26 |
|
123
|
27 |
// If there is an NFE media driver present, then because of the way EDeleteNotify requests work,
|
|
28 |
// the data retrieved from a deleted file will not be a buffer full of zero's, but instead a buffer
|
|
29 |
// full of decrypted zero's
|
|
30 |
#define __NFE_MEDIA_DRIVER_PRESENT__
|
|
31 |
|
0
|
32 |
#ifdef __VC32__
|
|
33 |
// Solve compilation problem caused by non-English locale
|
|
34 |
#pragma setlocale("english")
|
|
35 |
#endif
|
|
36 |
|
199
|
37 |
RTest test(_L("T_MISC"));
|
0
|
38 |
|
199
|
39 |
|
|
40 |
TInt gDriveNum = -1;
|
123
|
41 |
const TUint KBufLength = 0x100;
|
|
42 |
|
199
|
43 |
static void Test1()
|
0
|
44 |
//
|
|
45 |
// Open, write to and read from a file
|
|
46 |
//
|
|
47 |
{
|
|
48 |
|
|
49 |
test.Next(_L("Open, write to and read from a file"));
|
|
50 |
TInt r=TheFs.SetSessionPath(gSessionPath);
|
123
|
51 |
test_KErrNone(r);
|
0
|
52 |
RFile file;
|
|
53 |
r=file.Create(TheFs,_L("Hello.Wld"),EFileWrite);
|
123
|
54 |
test_KErrNone(r);
|
0
|
55 |
r=file.Write(_L8("Hello World"),11);
|
123
|
56 |
test_KErrNone(r);
|
0
|
57 |
file.Close();
|
|
58 |
|
|
59 |
r=file.Open(TheFs,_L("Hello.Wld"),EFileRead);
|
123
|
60 |
test_KErrNone(r);
|
0
|
61 |
TBuf8<256> buf;
|
|
62 |
r=file.Read(buf);
|
123
|
63 |
test_KErrNone(r);
|
0
|
64 |
test(buf==_L8("Hello World"));
|
|
65 |
file.Close();
|
|
66 |
}
|
|
67 |
|
199
|
68 |
static void Test2()
|
0
|
69 |
//
|
|
70 |
// Open and read from a file
|
|
71 |
//
|
|
72 |
{
|
|
73 |
|
|
74 |
test.Next(_L("Open and read from a file"));
|
|
75 |
TInt r=TheFs.SetSessionPath(gSessionPath);
|
123
|
76 |
test_KErrNone(r);
|
0
|
77 |
RFile file;
|
|
78 |
r=file.Open(TheFs,_L("Hello.Wld"),EFileRead);
|
123
|
79 |
test_KErrNone(r);
|
0
|
80 |
TBuf8<256> buf;
|
|
81 |
r=file.Read(buf);
|
123
|
82 |
test_KErrNone(r);
|
0
|
83 |
test(buf==_L8("Hello World"));
|
|
84 |
file.Close();
|
|
85 |
r=TheFs.Delete(_L("HELLO.WLD"));
|
123
|
86 |
test_KErrNone(r);
|
0
|
87 |
}
|
|
88 |
|
199
|
89 |
static void Test3()
|
0
|
90 |
//
|
|
91 |
// Create nested directories
|
|
92 |
//
|
|
93 |
{
|
|
94 |
|
|
95 |
test.Next(_L("Create nested directories"));
|
|
96 |
TInt r=TheFs.SetSessionPath(gSessionPath);
|
123
|
97 |
test_KErrNone(r);
|
0
|
98 |
TheFs.ResourceCountMarkStart();
|
|
99 |
//
|
|
100 |
r=TheFs.MkDir(_L("\\F32-TST\\LEFT\\A.B"));
|
123
|
101 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists);
|
0
|
102 |
r=TheFs.MkDir(_L("\\F32-TST\\RIGHT\\"));
|
123
|
103 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists);
|
0
|
104 |
//
|
|
105 |
r=TheFs.MkDir(_L("\\F32-TST\\LEFT\\ONE\\"));
|
123
|
106 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists);
|
0
|
107 |
r=TheFs.MkDir(_L("\\F32-TST\\LEFT\\TWO\\"));
|
123
|
108 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists);
|
0
|
109 |
r=TheFs.MkDir(_L("\\F32-TST\\LEFT\\THREE\\"));
|
123
|
110 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists);
|
0
|
111 |
r=TheFs.MkDir(_L("\\F32-TST\\LEFT\\TWO\\BOTTOM\\"));
|
123
|
112 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists);
|
0
|
113 |
//
|
|
114 |
r=TheFs.MkDirAll(_L("\\F32-TST\\RIGHT\\TOP\\MID\\BOT\\"));
|
123
|
115 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists);
|
0
|
116 |
}
|
|
117 |
|
199
|
118 |
static void Test4()
|
0
|
119 |
//
|
|
120 |
// Test returned error values
|
|
121 |
//
|
|
122 |
{
|
|
123 |
|
|
124 |
test.Next(_L("Test returned error values"));
|
|
125 |
TInt r=TheFs.SetSessionPath(gSessionPath);
|
123
|
126 |
test_KErrNone(r);
|
0
|
127 |
TheFs.ResourceCountMarkStart();
|
|
128 |
//
|
|
129 |
r=TheFs.MkDir(_L("\\"));
|
123
|
130 |
test_Value(r, r == KErrAlreadyExists);
|
0
|
131 |
r=TheFs.MkDir(_L("\\LEFT"));
|
123
|
132 |
test_Value(r, r == KErrAlreadyExists);
|
0
|
133 |
r=TheFs.MkDir(_L("\\F32-TST\\LEFT\\"));
|
123
|
134 |
test_Value(r, r == KErrAlreadyExists);
|
0
|
135 |
r=TheFs.MkDir(_L("\\F32-TST\\LEFT\\..\\NEWDIR\\"));
|
123
|
136 |
test_Value(r, r == KErrBadName);
|
0
|
137 |
r=TheFs.MkDir(_L("\\F32-TST\\NEWDIR\\SUBDIR\\"));
|
123
|
138 |
test_Value(r, r == KErrPathNotFound);
|
0
|
139 |
//
|
|
140 |
r=TheFs.RmDir(_L("\\"));
|
123
|
141 |
test_Value(r, r == KErrInUse);
|
0
|
142 |
r=TheFs.RmDir(_L("\\PROG"));
|
123
|
143 |
test_Value(r, r == KErrInUse);
|
0
|
144 |
r=TheFs.RmDir(_L("\\F32-TST\\"));
|
123
|
145 |
test_Value(r, r == KErrInUse);
|
0
|
146 |
|
|
147 |
|
|
148 |
RDir dir;
|
|
149 |
r=dir.Open(TheFs,_L("V:\\asdf"),KEntryAttNormal);
|
123
|
150 |
test_Value(r, r == KErrNone || r==KErrNotReady || r==KErrNotFound);
|
0
|
151 |
if (r==KErrNone)
|
|
152 |
dir.Close();
|
|
153 |
r=dir.Open(TheFs,_L("L:\\asdf"),KEntryAttNormal);
|
123
|
154 |
test_Value(r, r == KErrNone || r==KErrNotReady || r==KErrNotFound);
|
0
|
155 |
dir.Close();
|
|
156 |
//
|
|
157 |
TEntry entry;
|
|
158 |
r=TheFs.Entry(_L("z:\\NOTEXiSTS\\file.txt"),entry);
|
123
|
159 |
test_Value(r, r == KErrPathNotFound);
|
0
|
160 |
r=TheFs.Entry(_L("z:\\NOTEXiSTS\\"),entry);
|
123
|
161 |
test_Value(r, r == KErrNotFound);
|
0
|
162 |
r=TheFs.Entry(_L("z:\\SYSTEM\\"),entry);
|
123
|
163 |
test_KErrNone(r);
|
0
|
164 |
r=TheFs.Entry(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin)?_L("z:\\SYS\\BIN\\ESHELL.EXE"):_L("z:\\SYSTEM\\BIN\\ESHELL.EXE"),entry);
|
123
|
165 |
test_KErrNone(r);
|
0
|
166 |
|
|
167 |
r=dir.Open(TheFs,_L("\\*"),NULL);
|
123
|
168 |
test_KErrNone(r);
|
0
|
169 |
TEntry dirEntry;
|
|
170 |
r=dir.Read(dirEntry);
|
123
|
171 |
test_Value(r, r == KErrNone || r==KErrEof);
|
0
|
172 |
if (r==KErrNone)
|
|
173 |
test.Printf(_L("%S\n"),&dirEntry.iName);
|
|
174 |
dir.Close();
|
|
175 |
|
|
176 |
r=dir.Open(TheFs,_L("A:\\*"),NULL);
|
123
|
177 |
test_Value(r, r == KErrNotReady || r==KErrNone);
|
0
|
178 |
dir.Close();
|
|
179 |
}
|
|
180 |
|
199
|
181 |
static void Test5()
|
0
|
182 |
//
|
|
183 |
// Read files directly from the rom
|
|
184 |
//
|
|
185 |
|
|
186 |
{
|
|
187 |
test.Next(_L("Read Files directly from the rom"));
|
|
188 |
|
|
189 |
TInt pos=0;
|
|
190 |
TInt r;
|
|
191 |
_LIT(KTFileCpp, "Z:\\test\\T_FILE.CPP");
|
|
192 |
_LIT(KTFsrvCpp, "Z:\\test\\T_FSRV.CPP");
|
|
193 |
|
|
194 |
if ( TheFs.IsFileInRom(KTFileCpp) != NULL && TheFs.IsFileInRom(KTFsrvCpp) != NULL )
|
|
195 |
{
|
|
196 |
RFile f;
|
|
197 |
r=f.Open(TheFs,KTFileCpp,EFileRead);
|
123
|
198 |
test_KErrNone(r);
|
0
|
199 |
r=f.Seek(ESeekAddress,pos);
|
|
200 |
TText8* ptrPos=*(TText8**)&pos;
|
123
|
201 |
test_KErrNone(r);
|
0
|
202 |
TBuf8<1024> readBuf;
|
|
203 |
r=f.Read(readBuf);
|
123
|
204 |
test_KErrNone(r);
|
0
|
205 |
test(readBuf.Length()==readBuf.MaxLength());
|
|
206 |
TPtrC8 memBuf(ptrPos,readBuf.Length());
|
|
207 |
test(memBuf==readBuf);
|
|
208 |
|
|
209 |
ptrPos+=9913;
|
|
210 |
pos=9913;
|
|
211 |
r=f.Seek(ESeekStart,pos);
|
123
|
212 |
test_KErrNone(r);
|
0
|
213 |
readBuf.SetLength(0);
|
|
214 |
r=f.Read(readBuf);
|
123
|
215 |
test_KErrNone(r);
|
0
|
216 |
test(readBuf.Length()==readBuf.MaxLength());
|
|
217 |
memBuf.Set(ptrPos,readBuf.Length());
|
|
218 |
test(memBuf==readBuf);
|
|
219 |
|
|
220 |
RFile f2;
|
|
221 |
pos=10;
|
|
222 |
r=f2.Open(TheFs,KTFsrvCpp,EFileRead);
|
|
223 |
|
123
|
224 |
test_KErrNone(r);
|
0
|
225 |
r=f2.Seek(ESeekAddress,pos);
|
|
226 |
ptrPos=*(TText8**)&pos;
|
123
|
227 |
test_KErrNone(r);
|
0
|
228 |
readBuf.SetLength(0);
|
|
229 |
pos=10;
|
|
230 |
r=f2.Seek(ESeekStart,pos);
|
123
|
231 |
test_KErrNone(r);
|
0
|
232 |
r=f2.Read(readBuf);
|
123
|
233 |
test_KErrNone(r);
|
0
|
234 |
test(readBuf.Length()==readBuf.MaxLength());
|
|
235 |
memBuf.Set(ptrPos,readBuf.Length());
|
|
236 |
test(memBuf==readBuf);
|
|
237 |
|
|
238 |
ptrPos+=2445;
|
|
239 |
pos=10+2445;
|
|
240 |
r=f2.Seek(ESeekStart,pos);
|
123
|
241 |
test_KErrNone(r);
|
0
|
242 |
readBuf.SetLength(0);
|
|
243 |
r=f2.Read(readBuf);
|
123
|
244 |
test_KErrNone(r);
|
0
|
245 |
test(readBuf.Length()==readBuf.MaxLength());
|
|
246 |
memBuf.Set(ptrPos,readBuf.Length());
|
|
247 |
test(memBuf==readBuf);
|
|
248 |
|
|
249 |
pos=0;
|
|
250 |
r=f.Seek(ESeekAddress,pos);
|
|
251 |
ptrPos=*(TText8**)&pos;
|
123
|
252 |
test_KErrNone(r);
|
0
|
253 |
readBuf.SetLength(0);
|
|
254 |
pos=0;
|
|
255 |
r=f.Seek(ESeekStart,pos);
|
123
|
256 |
test_KErrNone(r);
|
0
|
257 |
r=f.Read(readBuf);
|
123
|
258 |
test_KErrNone(r);
|
0
|
259 |
test(readBuf.Length()==readBuf.MaxLength());
|
|
260 |
memBuf.Set(ptrPos,readBuf.Length());
|
|
261 |
test(memBuf==readBuf);
|
|
262 |
|
|
263 |
ptrPos+=5245;
|
|
264 |
pos=5245;
|
|
265 |
r=f.Seek(ESeekStart,pos);
|
123
|
266 |
test_KErrNone(r);
|
0
|
267 |
readBuf.SetLength(0);
|
|
268 |
r=f.Read(readBuf);
|
123
|
269 |
test_KErrNone(r);
|
0
|
270 |
test(readBuf.Length()==readBuf.MaxLength());
|
|
271 |
memBuf.Set(ptrPos,readBuf.Length());
|
|
272 |
test(memBuf==readBuf);
|
|
273 |
|
|
274 |
f.Close();
|
|
275 |
f2.Close();
|
|
276 |
}
|
|
277 |
}
|
|
278 |
|
199
|
279 |
static void Test6()
|
0
|
280 |
//
|
|
281 |
// Test rom return values
|
|
282 |
//
|
|
283 |
{
|
|
284 |
test.Next(_L("Test rom return values"));
|
|
285 |
|
|
286 |
RFile f;
|
|
287 |
TInt r=f.Replace(TheFs,_L("Z:\\Test\\T_Fsrv.Cpp"),EFileRead);
|
123
|
288 |
test_Value(r, r == KErrAccessDenied);
|
0
|
289 |
r=f.Create(TheFs,_L("Z:\\Test\\newT_Fsrv.Cpp"),EFileRead);
|
123
|
290 |
test_Value(r, r == KErrAccessDenied);
|
0
|
291 |
r=f.Open(TheFs,_L("Z:\\Test\\T_Fsrv.Cpp"),EFileRead);
|
123
|
292 |
test_KErrNone(r);
|
0
|
293 |
f.Close();
|
|
294 |
r=f.Open(TheFs,_L("Z:\\Test\\T_Fsrv.Cpp"),EFileRead|EFileWrite);
|
123
|
295 |
test_Value(r, r == KErrAccessDenied);
|
0
|
296 |
}
|
|
297 |
|
199
|
298 |
static void Test7()
|
0
|
299 |
//
|
|
300 |
// Test cache
|
|
301 |
//
|
|
302 |
{
|
|
303 |
|
|
304 |
test.Next(_L("Test cache updated when writing to a file"));
|
|
305 |
TUidType uid1(TUid::Uid(1),TUid::Uid(2),TUid::Uid(3));
|
|
306 |
TBuf8<32> contents1=_L8("asdf asdf asdf");
|
|
307 |
TBuf<32> file1=_L("\\TMISC\\CACHE.FILE");
|
|
308 |
MakeFile(file1,uid1,contents1);
|
|
309 |
|
|
310 |
TEntry entry;
|
|
311 |
TInt r=TheFs.Entry(file1,entry);
|
123
|
312 |
test_KErrNone(r);
|
0
|
313 |
test(entry.iType==uid1);
|
|
314 |
|
|
315 |
TUidType uid2(TUid::Uid(4),TUid::Uid(5),TUid::Uid(6));
|
|
316 |
TCheckedUid checkedUid(uid2);
|
|
317 |
TPtrC8 uidData((TUint8*)&checkedUid,sizeof(TCheckedUid));
|
|
318 |
RFile f;
|
|
319 |
r=f.Open(TheFs,file1,EFileRead|EFileWrite);
|
123
|
320 |
test_KErrNone(r);
|
0
|
321 |
r=f.Write(uidData);
|
123
|
322 |
test_KErrNone(r);
|
0
|
323 |
r = f.Flush();
|
123
|
324 |
test_KErrNone(r);
|
0
|
325 |
|
|
326 |
r=TheFs.Entry(file1,entry);
|
123
|
327 |
test_KErrNone(r);
|
0
|
328 |
test(entry.iType==uid2);
|
|
329 |
|
|
330 |
f.Close();
|
|
331 |
r=TheFs.Entry(file1,entry);
|
123
|
332 |
test_KErrNone(r);
|
0
|
333 |
test(entry.iType==uid2);
|
|
334 |
}
|
|
335 |
|
199
|
336 |
static void Test8()
|
0
|
337 |
//
|
|
338 |
// Test IsValidName
|
|
339 |
//
|
|
340 |
{
|
|
341 |
test.Next(_L("Test RFs::IsValidName(TDesC)"));
|
|
342 |
|
|
343 |
// tests calling IsValidName() with invalid name as first call to session
|
|
344 |
// see defect EXT-57KH9K
|
|
345 |
_LIT(KInvalidName, "test\\i1.jpg");
|
|
346 |
RFs fs;
|
|
347 |
test(KErrNone==fs.Connect());
|
|
348 |
test(fs.IsValidName(KInvalidName)==EFalse);
|
|
349 |
fs.Close();
|
|
350 |
|
|
351 |
test(TheFs.IsValidName(_L("*"))==EFalse);
|
|
352 |
test(TheFs.IsValidName(_L("?"))==EFalse);
|
|
353 |
test(TheFs.IsValidName(_L(">"))==EFalse);
|
|
354 |
test(TheFs.IsValidName(_L("<"))==EFalse);
|
|
355 |
test(TheFs.IsValidName(_L(":"))==EFalse);
|
|
356 |
test(TheFs.IsValidName(_L("\""))==EFalse);
|
|
357 |
test(TheFs.IsValidName(_L("/"))==EFalse);
|
|
358 |
test(TheFs.IsValidName(_L("|"))==EFalse);
|
|
359 |
test(TheFs.IsValidName(_L("\\"))==EFalse);
|
|
360 |
|
|
361 |
test(TheFs.IsValidName(_L("xx*yy"))==EFalse);
|
|
362 |
test(TheFs.IsValidName(_L("xx?yy"))==EFalse);
|
|
363 |
test(TheFs.IsValidName(_L("xx>yy"))==EFalse);
|
|
364 |
test(TheFs.IsValidName(_L("xx<yy"))==EFalse);
|
|
365 |
test(TheFs.IsValidName(_L("xx:yy"))==EFalse);
|
|
366 |
test(TheFs.IsValidName(_L("xx\"yy"))==EFalse);
|
|
367 |
test(TheFs.IsValidName(_L("xx/yy"))==EFalse);
|
|
368 |
test(TheFs.IsValidName(_L("xx|yy"))==EFalse);
|
|
369 |
|
|
370 |
test(TheFs.IsValidName(_L("C:\\*\\group\\release.txt"))==EFalse);
|
|
371 |
test(TheFs.IsValidName(_L("C:\\?\\group\\release.txt"))==EFalse);
|
|
372 |
test(TheFs.IsValidName(_L("C:\\>\\group\\release.txt"))==EFalse);
|
|
373 |
test(TheFs.IsValidName(_L("C:\\<\\group\\release.txt"))==EFalse);
|
|
374 |
test(TheFs.IsValidName(_L("C:\\:\\group\\release.txt"))==EFalse);
|
|
375 |
test(TheFs.IsValidName(_L("C:\\\"\\group\\release.txt"))==EFalse);
|
|
376 |
test(TheFs.IsValidName(_L("C:\\/\\group\\release.txt"))==EFalse);
|
|
377 |
test(TheFs.IsValidName(_L("C:\\|\\group\\release.txt"))==EFalse);
|
|
378 |
|
|
379 |
test(TheFs.IsValidName(_L(""))==EFalse); // must be a name or extension present
|
|
380 |
test(TheFs.IsValidName(_L(".ext")));
|
|
381 |
test(TheFs.IsValidName(_L("C:\\asdf.blarg\\"))==EFalse);
|
|
382 |
test(TheFs.IsValidName(_L("\\"))==EFalse);
|
|
383 |
|
|
384 |
test(TheFs.IsValidName(_L("as(){}@~#;!\xA3$%^&()df.blarg"))); // Valid names
|
|
385 |
test(TheFs.IsValidName(_L("C:\\asdf.blarg\\asdf.blarg"))); // Valid names
|
|
386 |
test(TheFs.IsValidName(_L("\'"))); // Valid names
|
|
387 |
|
|
388 |
test.Next(_L("Test RFs::IsValidName(TDesC, TDes) overload"));
|
|
389 |
|
|
390 |
TText testChar;
|
|
391 |
test(TheFs.IsValidName(_L("*"),testChar)==EFalse);
|
|
392 |
test(testChar=='*');
|
|
393 |
test(TheFs.IsValidName(_L("?"),testChar)==EFalse);
|
|
394 |
test(testChar=='?');
|
|
395 |
test(TheFs.IsValidName(_L(">"),testChar)==EFalse);
|
|
396 |
test(testChar=='>');
|
|
397 |
test(TheFs.IsValidName(_L("<"),testChar)==EFalse);
|
|
398 |
test(testChar=='<');
|
|
399 |
test(TheFs.IsValidName(_L(":"),testChar)==EFalse);
|
|
400 |
test(testChar==':');
|
|
401 |
test(TheFs.IsValidName(_L("\""),testChar)==EFalse);
|
|
402 |
test(testChar=='\"'); // Tests that " is illegal
|
|
403 |
test(TheFs.IsValidName(_L("/"),testChar)==EFalse);
|
|
404 |
test(testChar=='/');
|
|
405 |
test(TheFs.IsValidName(_L("|"),testChar)==EFalse);
|
|
406 |
test(testChar=='|');
|
|
407 |
test(TheFs.IsValidName(_L("\\"),testChar)==EFalse);
|
|
408 |
test(testChar==' ');
|
|
409 |
|
|
410 |
test(TheFs.IsValidName(_L("xx*yy"),testChar)==EFalse);
|
|
411 |
test(testChar=='*');
|
|
412 |
test(TheFs.IsValidName(_L("xx?yy"),testChar)==EFalse);
|
|
413 |
test(testChar=='?');
|
|
414 |
test(TheFs.IsValidName(_L("xx>yy"),testChar)==EFalse);
|
|
415 |
test(testChar=='>');
|
|
416 |
test(TheFs.IsValidName(_L("xx<yy"),testChar)==EFalse);
|
|
417 |
test(testChar=='<');
|
|
418 |
test(TheFs.IsValidName(_L("xx:yy"),testChar)==EFalse);
|
|
419 |
test(testChar==':');
|
|
420 |
test(TheFs.IsValidName(_L("xx\"yy"),testChar)==EFalse);
|
|
421 |
test(testChar=='\"'); // Tests that " is illegal
|
|
422 |
test(TheFs.IsValidName(_L("xx/yy"),testChar)==EFalse);
|
|
423 |
test(testChar=='/');
|
|
424 |
test(TheFs.IsValidName(_L("xx|yy"),testChar)==EFalse);
|
|
425 |
test(testChar=='|');
|
|
426 |
|
|
427 |
test(TheFs.IsValidName(_L("C:\\*\\group\\release.txt"),testChar)==EFalse);
|
|
428 |
test(testChar=='*');
|
|
429 |
test(TheFs.IsValidName(_L("C:\\?\\group\\release.txt"),testChar)==EFalse);
|
|
430 |
test(testChar=='?');
|
|
431 |
test(TheFs.IsValidName(_L("C:\\..\\group\\release.txt"),testChar)==EFalse);
|
|
432 |
test(testChar=='.'); // Only one "." returned however many are in filename
|
|
433 |
test(TheFs.IsValidName(_L("C:\\.\\group\\release.txt"),testChar)==EFalse);
|
|
434 |
test(testChar=='.');
|
|
435 |
test(TheFs.IsValidName(_L("C:\\>\\group\\release.txt"),testChar)==EFalse);
|
|
436 |
test(testChar=='>');
|
|
437 |
test(TheFs.IsValidName(_L("C:\\<\\group\\release.txt"),testChar)==EFalse);
|
|
438 |
test(testChar=='<');
|
|
439 |
test(TheFs.IsValidName(_L("C:\\HelloWorld\\:\\group\\release.txt"),testChar)==EFalse);
|
|
440 |
test(testChar==':');
|
|
441 |
|
|
442 |
|
|
443 |
test(TheFs.IsValidName(_L("C::\\group\\release.txt"),testChar)==EFalse);
|
|
444 |
test(testChar==':');
|
|
445 |
test(TheFs.IsValidName(_L(">\\group\\release.txt"),testChar)==EFalse);
|
|
446 |
test(testChar=='>');
|
|
447 |
test(TheFs.IsValidName(_L("C|group\\release.txt"),testChar)==EFalse);
|
|
448 |
test(testChar=='|');
|
|
449 |
test(TheFs.IsValidName(_L("C\\|\\group\\release.txt"),testChar)==EFalse);
|
|
450 |
test(testChar=='|');
|
|
451 |
|
|
452 |
test(TheFs.IsValidName(_L("\\>"),testChar)==EFalse);
|
|
453 |
test(testChar=='>');
|
|
454 |
test(TheFs.IsValidName(_L("C:\\|group\\release.txt"),testChar)==EFalse);
|
|
455 |
test(testChar=='|');
|
|
456 |
|
|
457 |
test(TheFs.IsValidName(_L("C:\\\"\\group\\release.txt"),testChar)==EFalse);
|
|
458 |
test(testChar=='\"');
|
|
459 |
test(TheFs.IsValidName(_L("C:\\/\\group\\release.txt"),testChar)==EFalse);
|
|
460 |
test(testChar=='/');
|
|
461 |
test(TheFs.IsValidName(_L("C:\\|\\group\\release.txt"),testChar)==EFalse);
|
|
462 |
test(testChar=='|');
|
|
463 |
test(TheFs.IsValidName(_L("C:\\ \\group\\release.txt"),testChar)==EFalse); // must be a name or extension present
|
|
464 |
test(testChar==' ');
|
|
465 |
|
|
466 |
// Test that \ is not allowed in filenames
|
|
467 |
TFileName filename;
|
|
468 |
filename=_L("C:\\HelloWorld\\\\\\group\\release.txt");
|
|
469 |
TPtr pChar(&testChar,sizeof(TText),sizeof(TText));
|
|
470 |
test(TheFs.IsValidName(filename,testChar)==EFalse);
|
|
471 |
test(pChar.Find(_L("\\"))!=KErrNotFound);
|
|
472 |
filename=_L("C:\\\\\\group\\release.txt");
|
|
473 |
test(TheFs.IsValidName(filename,testChar)==EFalse);
|
|
474 |
test(pChar.Find(_L("\\"))!=KErrNotFound);
|
|
475 |
filename=_L("C:\\Hello World\\group\\release.txt");
|
|
476 |
filename[8]=KPathDelimiter; // Makes C:\\Hello World\\group\\release.txt
|
|
477 |
test(TheFs.IsValidName(filename,testChar));
|
|
478 |
filename=_L("C:\\HelloWorld\\::\\group\\release.txt");
|
|
479 |
test(TheFs.IsValidName(filename,testChar)==EFalse);
|
|
480 |
test(pChar.Find(_L(":"))!=KErrNotFound);
|
|
481 |
|
|
482 |
filename=_L("C:\\>>\\group\\release.txt");
|
|
483 |
test(TheFs.IsValidName(filename,testChar)==EFalse);
|
|
484 |
test(pChar.Find(_L(">"))!=KErrNotFound);
|
|
485 |
|
|
486 |
test(TheFs.IsValidName(_L(""),testChar)==EFalse); // Must be a name
|
|
487 |
test(testChar==' ');
|
|
488 |
test(TheFs.IsValidName(_L(".ext"),testChar));
|
|
489 |
test(TheFs.IsValidName(_L("C:\\asdf.blarg\\"),testChar)==EFalse);
|
|
490 |
test(testChar==' '); // Must be a name else testChar is set to blank
|
|
491 |
test(TheFs.IsValidName(_L("C:\\asdf.blarg"),testChar));
|
|
492 |
|
|
493 |
test(TheFs.IsValidName(_L("C:\\asdf..blarg\\"),testChar)==EFalse);
|
|
494 |
test(testChar==' '); // Must be a name else testChar is set to blank
|
|
495 |
test(TheFs.IsValidName(_L("C:\\asdf..blarg"),testChar));
|
|
496 |
|
|
497 |
test(TheFs.IsValidName(_L("\\"),testChar)==EFalse);
|
|
498 |
test(testChar==' ');
|
|
499 |
|
|
500 |
// Test multiple evil characters - parsing occurs from right to left
|
|
501 |
// except that wildcarded characters take priority and are picked out first
|
|
502 |
test(TheFs.IsValidName(_L("abc>def|ghi?jkl:mno<pqr*stu"),testChar)==EFalse);
|
|
503 |
test(testChar=='*');
|
|
504 |
test(TheFs.IsValidName(_L("abc>def|ghi<jkl:mno?pqr"),testChar)==EFalse);
|
|
505 |
test(testChar=='?');
|
|
506 |
test(TheFs.IsValidName(_L("abc>def|ghi<jkl:mno"),testChar)==EFalse);
|
|
507 |
test(testChar==':');
|
|
508 |
test(TheFs.IsValidName(_L("abc>def|ghi<jkl"),testChar)==EFalse);
|
|
509 |
test(testChar=='<');
|
|
510 |
test(TheFs.IsValidName(_L("abc>def|ghi"),testChar)==EFalse);
|
|
511 |
test(testChar=='|');
|
|
512 |
test(TheFs.IsValidName(_L("abc>def"),testChar)==EFalse);
|
|
513 |
test(testChar=='>');
|
|
514 |
|
|
515 |
test(!TheFs.IsValidName(_L("C:\\v123456.."),testChar)); // Valid name
|
|
516 |
test(TheFs.IsValidName(_L("abc"),testChar)); // Valid name
|
|
517 |
test(TheFs.IsValidName(_L("as(){}@~#;!\xA3$%^&()df.blarg"),testChar)); // Valid name
|
|
518 |
test(TheFs.IsValidName(_L("C:\\asdf.blarg\\asdf.blarg"),testChar)); // Valid name
|
|
519 |
test(TheFs.IsValidName(_L("\'"),testChar)); // Valid name
|
|
520 |
|
|
521 |
//PDEF133084: The wild character in the extension was not being detected.
|
|
522 |
_LIT( KTestString, "E:\\My Videos\\Downloads\\1\\1\\Name.3gp?" );
|
|
523 |
TBuf<50> path;
|
|
524 |
path = KTestString;
|
|
525 |
TBool validName( EFalse );
|
|
526 |
TText badChar;
|
|
527 |
TInt badCharLoc( KErrNotFound );
|
|
528 |
|
|
529 |
while ( ! validName )
|
|
530 |
{
|
|
531 |
validName = TheFs.IsValidName( path, badChar );
|
|
532 |
|
|
533 |
if ( ! validName )
|
|
534 |
{
|
|
535 |
badCharLoc = path.LocateReverse( badChar );
|
|
536 |
|
|
537 |
if ( KErrNotFound != badCharLoc )
|
|
538 |
{
|
|
539 |
path[badCharLoc] = '_';
|
|
540 |
}
|
|
541 |
}
|
|
542 |
}
|
|
543 |
}
|
|
544 |
|
199
|
545 |
static void Test9()
|
0
|
546 |
//
|
|
547 |
// Test IsFileInRom
|
|
548 |
//
|
|
549 |
{
|
|
550 |
|
|
551 |
test.Next(_L("Test RFs::IsFileInRom"));
|
|
552 |
|
|
553 |
CFileMan* fMan=CFileMan::NewL(TheFs);
|
|
554 |
TInt r=fMan->Copy(_L("Z:\\TEST\\T_FILE.CPP"),_L("C:\\T_FILE.CPP"));
|
123
|
555 |
test_Value(r, r == KErrNone || r==KErrAccessDenied);
|
0
|
556 |
delete fMan;
|
|
557 |
TUint8* addr=TheFs.IsFileInRom(_L("C:\\ESHELL.EXE"));
|
|
558 |
test(addr==NULL);
|
|
559 |
addr=TheFs.IsFileInRom(_L("Z:\\TEST\\T_FILE.CPP"));
|
|
560 |
if (addr!=NULL)
|
|
561 |
{
|
|
562 |
test(addr!=NULL);
|
|
563 |
TPtrC8 startOfFile(addr,12);
|
|
564 |
test(startOfFile==_L8("// Copyright"));
|
|
565 |
}
|
|
566 |
else
|
|
567 |
{
|
|
568 |
test (addr==NULL);
|
|
569 |
}
|
|
570 |
}
|
|
571 |
|
199
|
572 |
static void Test10()
|
0
|
573 |
//
|
|
574 |
// Test drive names
|
|
575 |
//
|
|
576 |
{
|
|
577 |
|
|
578 |
test.Next(_L("Test Drive Names"));
|
|
579 |
TFileName driveName;
|
|
580 |
TInt i;
|
|
581 |
for(i=0;i<KMaxDrives;i++)
|
|
582 |
{
|
|
583 |
TInt r=TheFs.GetDriveName(i,driveName);
|
123
|
584 |
test_KErrNone(r);
|
0
|
585 |
if (driveName.Length())
|
|
586 |
test.Printf(_L("Default name of %c: == %S\n"),'A'+i,&driveName);
|
|
587 |
}
|
|
588 |
|
|
589 |
TBuf<64> drive0=_L("Dilbert");
|
|
590 |
TBuf<64> drive4=_L("Dogbert");
|
|
591 |
TBuf<64> drive17=_L("Flibble");
|
|
592 |
TBuf<64> drive25=_L("RAMDRIVE");
|
|
593 |
TInt r=TheFs.SetDriveName(0,drive0);
|
123
|
594 |
test_KErrNone(r);
|
0
|
595 |
r=TheFs.SetDriveName(4,drive4);
|
123
|
596 |
test_KErrNone(r);
|
0
|
597 |
r=TheFs.SetDriveName(17,drive17);
|
123
|
598 |
test_KErrNone(r);
|
0
|
599 |
r=TheFs.SetDriveName(25,drive25);
|
123
|
600 |
test_KErrNone(r);
|
0
|
601 |
|
|
602 |
r=TheFs.GetDriveName(0,driveName);
|
123
|
603 |
test_KErrNone(r);
|
0
|
604 |
test(driveName==drive0);
|
|
605 |
r=TheFs.GetDriveName(4,driveName);
|
123
|
606 |
test_KErrNone(r);
|
0
|
607 |
test(driveName==drive4);
|
|
608 |
r=TheFs.GetDriveName(17,driveName);
|
123
|
609 |
test_KErrNone(r);
|
0
|
610 |
test(driveName==drive17);
|
|
611 |
r=TheFs.GetDriveName(25,driveName);
|
123
|
612 |
test_KErrNone(r);
|
0
|
613 |
test(driveName==drive25);
|
|
614 |
|
|
615 |
drive0=_L("askdjflsdfourewoqiuroiuaksjdvx,cvsdhwjhjhalsjhfshfkjhslj");
|
|
616 |
r=TheFs.SetDriveName(0,drive0);
|
123
|
617 |
test_KErrNone(r);
|
0
|
618 |
r=TheFs.GetDriveName(0,driveName);
|
123
|
619 |
test_KErrNone(r);
|
0
|
620 |
test(driveName==drive0);
|
|
621 |
|
|
622 |
// Test with illegal characters in drive name
|
|
623 |
drive0=_L("Dil>bert");
|
|
624 |
drive4=_L("Dog?bert");
|
|
625 |
drive17=_L("Fli*bble");
|
|
626 |
drive25=_L("RAMD//RIVE");
|
|
627 |
|
|
628 |
r=TheFs.SetDriveName(0,drive0);
|
123
|
629 |
test_Value(r, r == KErrBadName);
|
0
|
630 |
r=TheFs.SetDriveName(4,drive4);
|
123
|
631 |
test_Value(r, r == KErrBadName);
|
0
|
632 |
r=TheFs.SetDriveName(17,drive17);
|
123
|
633 |
test_Value(r, r == KErrBadName);
|
0
|
634 |
r=TheFs.SetDriveName(25,drive25);
|
123
|
635 |
test_Value(r, r == KErrBadName);
|
0
|
636 |
|
|
637 |
// Test that it is OK to set the name to no characters
|
|
638 |
|
|
639 |
drive0=_L("");
|
|
640 |
drive4=_L("");
|
|
641 |
drive17=_L("");
|
|
642 |
drive25=_L("");
|
|
643 |
|
|
644 |
r=TheFs.SetDriveName(0,drive0);
|
123
|
645 |
test_KErrNone(r);
|
0
|
646 |
r=TheFs.SetDriveName(4,drive4);
|
123
|
647 |
test_KErrNone(r);
|
0
|
648 |
r=TheFs.SetDriveName(17,drive17);
|
123
|
649 |
test_KErrNone(r);
|
0
|
650 |
r=TheFs.SetDriveName(25,drive25);
|
123
|
651 |
test_KErrNone(r);
|
0
|
652 |
|
|
653 |
r=TheFs.GetDriveName(0,driveName);
|
123
|
654 |
test_KErrNone(r);
|
0
|
655 |
test(driveName==drive0);
|
|
656 |
r=TheFs.GetDriveName(4,driveName);
|
123
|
657 |
test_KErrNone(r);
|
0
|
658 |
test(driveName==drive4);
|
|
659 |
r=TheFs.GetDriveName(17,driveName);
|
123
|
660 |
test_KErrNone(r);
|
0
|
661 |
test(driveName==drive17);
|
|
662 |
r=TheFs.GetDriveName(25,driveName);
|
123
|
663 |
test_KErrNone(r);
|
0
|
664 |
test(driveName==drive25);
|
|
665 |
|
|
666 |
|
|
667 |
}
|
|
668 |
|
199
|
669 |
static void Test11()
|
0
|
670 |
//
|
|
671 |
// Miscellaneous tests
|
|
672 |
//
|
|
673 |
{
|
|
674 |
|
|
675 |
test.Next(_L("Miscellaneous tests"));
|
|
676 |
TVolumeInfo vol;
|
|
677 |
TInt r=TheFs.Volume(vol);
|
|
678 |
test.Printf(_L("VolumeName = %S\n"),&vol.iName);
|
123
|
679 |
test_KErrNone(r);
|
0
|
680 |
r=TheFs.RmDir(_L("\\asdfasdf.\\"));
|
123
|
681 |
test_Value(r, r == KErrBadName);
|
0
|
682 |
r=TheFs.MkDir(_L("\\asdfasdf.\\"));
|
123
|
683 |
test_Value(r, r == KErrBadName);
|
0
|
684 |
}
|
|
685 |
|
199
|
686 |
static void Test12()
|
0
|
687 |
//
|
|
688 |
// Test SetNotifyUser and GetNotifyUser
|
|
689 |
//
|
|
690 |
{
|
|
691 |
|
|
692 |
test.Next(_L("Test Set and GetNotifyUser"));
|
|
693 |
TBool notifyState=TheFs.GetNotifyUser();
|
|
694 |
test(notifyState);
|
|
695 |
notifyState=EFalse;
|
|
696 |
TheFs.SetNotifyUser(notifyState);
|
|
697 |
notifyState=TheFs.GetNotifyUser();
|
|
698 |
test(notifyState==EFalse);
|
|
699 |
notifyState=ETrue;
|
|
700 |
TheFs.SetNotifyUser(notifyState);
|
|
701 |
notifyState=TheFs.GetNotifyUser();
|
|
702 |
test(notifyState);
|
|
703 |
}
|
|
704 |
|
199
|
705 |
static void Test13()
|
0
|
706 |
//
|
|
707 |
// Test return values from RFs::Volume on cf-cards
|
|
708 |
//
|
|
709 |
{
|
|
710 |
|
|
711 |
test.Next(_L("Test RFs::Volume"));
|
|
712 |
TVolumeInfo vol;
|
|
713 |
TInt r=TheFs.Volume(vol,EDriveB);
|
123
|
714 |
test_Value(r, r == KErrNotReady || r==KErrNone || r == KErrPathNotFound);
|
0
|
715 |
test.Printf(_L("RFs::Volume EDriveB returned %d\n"),r);
|
|
716 |
|
|
717 |
r=TheFs.Volume(vol,EDriveC);
|
123
|
718 |
test_Value(r, r == KErrNotReady || r==KErrNone || r == KErrPathNotFound);
|
0
|
719 |
test.Printf(_L("RFs::Volume EDriveC returned %d\n"),r);
|
|
720 |
|
|
721 |
r=TheFs.Volume(vol,EDriveD);
|
123
|
722 |
test_Value(r, r == KErrNotReady || r==KErrNone || r == KErrPathNotFound);
|
0
|
723 |
test.Printf(_L("RFs::Volume EDriveD returned %d\n"),r);
|
|
724 |
|
|
725 |
r=TheFs.Volume(vol,EDriveE);
|
123
|
726 |
test_Value(r, r == KErrNotReady || r==KErrNone || r == KErrPathNotFound);
|
0
|
727 |
test.Printf(_L("RFs::Volume EDriveE returned %d\n"),r);
|
|
728 |
|
|
729 |
r=TheFs.Volume(vol,EDriveF);
|
123
|
730 |
test_Value(r, r == KErrNotReady || r==KErrNone || r == KErrPathNotFound);
|
0
|
731 |
test.Printf(_L("RFs::Volume EDriveF returned %d\n"),r);
|
|
732 |
}
|
|
733 |
|
|
734 |
|
|
735 |
void DoTest14(TInt aDrvNum);
|
|
736 |
TInt CreateStuffedFile(RFs& aFs, const TDesC& aFileName, TUint aFileSize);
|
|
737 |
TBool CheckFileContents(RFs& aFs, const TDesC& aFileName);
|
123
|
738 |
#ifndef __NFE_MEDIA_DRIVER_PRESENT__
|
0
|
739 |
TBool CheckBufferContents(const TDesC8& aBuffer, TUint aPrintBaseAddr=0);
|
123
|
740 |
#endif
|
0
|
741 |
|
|
742 |
/**
|
199
|
743 |
Testing unallocated data initialization vulnerability in RFile
|
|
744 |
This test is performed on RAM drives and non-removable media that supports DeleteNotify (KMediaAttDeleteNotify flag)
|
|
745 |
e.g. XSR NAND
|
0
|
746 |
*/
|
199
|
747 |
static void Test14()
|
0
|
748 |
{
|
|
749 |
|
|
750 |
test.Next(_L("Testing unallocated data initialization vulnerability in RFile"));
|
|
751 |
|
199
|
752 |
TDriveInfo driveInfo;
|
|
753 |
|
|
754 |
//-- get drive info
|
|
755 |
test(TheFs.Drive(driveInfo, gDriveNum) == KErrNone);
|
0
|
756 |
|
199
|
757 |
const TBool bMediaSuitable = (driveInfo.iType == EMediaRam) || //-- RAM drives should be tested
|
|
758 |
(driveInfo.iType == EMediaFlash) || //-- NOR FLASH drives should be tested
|
|
759 |
(driveInfo.iType == EMediaNANDFlash && driveInfo.iMediaAtt & KMediaAttDeleteNotify); //-- NAND media with DeleteNotify support
|
|
760 |
|
|
761 |
if(!bMediaSuitable)
|
|
762 |
{
|
|
763 |
test.Printf(_L("This test can't be performed on this type of the media! Skipping.\n"));
|
|
764 |
return;
|
|
765 |
}
|
|
766 |
|
|
767 |
DoTest14(gDriveNum);
|
0
|
768 |
}
|
|
769 |
|
|
770 |
//--------------------------------------------------------
|
|
771 |
|
|
772 |
/**
|
|
773 |
Actually perform the test on a drive aDrvNum.
|
|
774 |
@param aDrvNum drive number
|
|
775 |
*/
|
|
776 |
void DoTest14(TInt aDrvNum)
|
|
777 |
{
|
|
778 |
|
|
779 |
TFileName fileName;
|
|
780 |
fileName.Format(_L("Testing drive %c:"), 'A'+aDrvNum);
|
|
781 |
test.Next(fileName);
|
|
782 |
|
|
783 |
const TInt KFileSize = 0x1000; //-- size of the files t be created
|
|
784 |
TInt nRes;
|
|
785 |
|
|
786 |
fileName.Format(_L("%c:\\TestFile.bin"), aDrvNum+'A');
|
|
787 |
TheFs.Delete(fileName); //-- just in case
|
|
788 |
|
|
789 |
//==============================
|
|
790 |
//== Scenario 1.
|
|
791 |
//== Create an empty file; AllocateSingleClusterL, ExtendClusterListL will be involved.
|
|
792 |
//== Check that the file doesn't contain any meaningful information
|
|
793 |
//==============================
|
|
794 |
test.Printf(_L("Testing scenario 1\n"));
|
|
795 |
|
|
796 |
//-- 1. create an empty file
|
|
797 |
nRes = CreateEmptyFile(TheFs, fileName, KFileSize);
|
123
|
798 |
test_KErrNone(nRes);
|
0
|
799 |
|
123
|
800 |
#ifndef __NFE_MEDIA_DRIVER_PRESENT__ // can't easily check for illegitimate information if drive is encrypted
|
0
|
801 |
//-- 1.1 check that this file doesn't contain illegitimate information.
|
|
802 |
nRes = CheckFileContents(TheFs, fileName);
|
123
|
803 |
test_KErrNone(nRes);
|
|
804 |
#endif
|
0
|
805 |
|
|
806 |
//-- 1.2 delete the empty file
|
|
807 |
nRes = TheFs.Delete(fileName);
|
123
|
808 |
test_KErrNone(nRes);
|
0
|
809 |
|
|
810 |
//==============================
|
|
811 |
//== Scenario 2.
|
|
812 |
//== Create file, filling it with some pattern.
|
|
813 |
//== Delete this file, FreeClusterListL() will be involved.
|
|
814 |
//== Create an empty file supposedly of the place of just deleted one
|
|
815 |
//== Check that the file doesn't contain any meaningful information
|
|
816 |
//==============================
|
|
817 |
test.Printf(_L("Testing scenario 2\n"));
|
|
818 |
|
|
819 |
//-- 2. create file filled with some data pattern
|
|
820 |
nRes = CreateStuffedFile(TheFs, fileName, KFileSize);
|
123
|
821 |
test_KErrNone(nRes);
|
0
|
822 |
|
|
823 |
//-- 2.1 delete this file
|
|
824 |
TheFs.Delete(fileName);
|
|
825 |
|
|
826 |
//-- 2.1 create an empty file on the place of just deleted one (hopefully)
|
|
827 |
nRes = CreateEmptyFile(TheFs, fileName, KFileSize);
|
123
|
828 |
test_KErrNone(nRes);
|
0
|
829 |
|
|
830 |
//-- 2.2 check that this file doesn't contain illegitimate information.
|
|
831 |
nRes = CheckFileContents(TheFs, fileName);
|
123
|
832 |
test_KErrNone(nRes);
|
0
|
833 |
|
|
834 |
//-- 2.3 delete this file
|
|
835 |
TheFs.Delete(fileName);
|
|
836 |
|
|
837 |
}
|
|
838 |
|
199
|
839 |
static void Test15()
|
0
|
840 |
//
|
|
841 |
// Test IsValidName
|
|
842 |
//
|
|
843 |
{
|
|
844 |
test.Next(_L("Test RFs::IsValidName(TDesC& ,RFs::TNameValidParam& )"));
|
|
845 |
TBool useDefaultSessionPath = EFalse;
|
|
846 |
//tests under this loop are run twice
|
|
847 |
//first, when the sessionPath is not used.
|
|
848 |
//second, when the sessionPath is used.
|
|
849 |
for(TInt i = 0; i<2; i++)
|
|
850 |
{
|
|
851 |
RFs::TNameValidParam param(useDefaultSessionPath);
|
|
852 |
test(TheFs.IsValidName(_L("*"),param)==EFalse);
|
|
853 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
854 |
test(param.InvalidCharPos() == 1);
|
|
855 |
|
|
856 |
test(TheFs.IsValidName(_L("?"),param)==EFalse);
|
|
857 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
858 |
test(param.InvalidCharPos() == 1);
|
|
859 |
|
|
860 |
test(TheFs.IsValidName(_L(">"),param)==EFalse);
|
|
861 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
862 |
test(param.InvalidCharPos() == 1);
|
|
863 |
|
|
864 |
test(TheFs.IsValidName(_L("<"),param)==EFalse);
|
|
865 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
866 |
test(param.InvalidCharPos() == 1);
|
|
867 |
|
|
868 |
test(TheFs.IsValidName(_L(":"),param)==EFalse);
|
|
869 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
870 |
test(param.InvalidCharPos() == 1);
|
|
871 |
|
|
872 |
test(TheFs.IsValidName(_L("\""),param)==EFalse);
|
|
873 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
874 |
test(param.InvalidCharPos() == 1);
|
|
875 |
|
|
876 |
test(TheFs.IsValidName(_L("/"),param)==EFalse);
|
|
877 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
878 |
test(param.InvalidCharPos() == 1);
|
|
879 |
|
|
880 |
test(TheFs.IsValidName(_L("|"),param)==EFalse);
|
|
881 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
882 |
test(param.InvalidCharPos() == 1);
|
|
883 |
|
|
884 |
test(TheFs.IsValidName(_L("xx*yy"),param)==EFalse);
|
|
885 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
886 |
test(param.InvalidCharPos() == 3);
|
|
887 |
|
|
888 |
test(TheFs.IsValidName(_L("xx?yy"),param)==EFalse);
|
|
889 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
890 |
test(param.InvalidCharPos() == 3);
|
|
891 |
|
|
892 |
test(TheFs.IsValidName(_L("xx>yy"),param)==EFalse);
|
|
893 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
894 |
test(param.InvalidCharPos() == 3);
|
|
895 |
|
|
896 |
test(TheFs.IsValidName(_L("xx<yy"),param)==EFalse);
|
|
897 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
898 |
test(param.InvalidCharPos() == 3);
|
|
899 |
|
|
900 |
test(TheFs.IsValidName(_L("xx:yy"),param)==EFalse);
|
|
901 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
902 |
test(param.InvalidCharPos() == 3);
|
|
903 |
|
|
904 |
test(TheFs.IsValidName(_L("xx\"yy"),param)==EFalse);
|
|
905 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
906 |
test(param.InvalidCharPos() == 3);
|
|
907 |
|
|
908 |
test(TheFs.IsValidName(_L("xx/yy"),param)==EFalse);
|
|
909 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
910 |
test(param.InvalidCharPos() == 3);
|
|
911 |
|
|
912 |
test(TheFs.IsValidName(_L("xx|yy"),param)==EFalse);
|
|
913 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
914 |
test(param.InvalidCharPos() == 3);
|
|
915 |
|
|
916 |
test(TheFs.IsValidName(_L("C:\\*\\group\\release.txt"),param)==EFalse);
|
|
917 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
918 |
test(param.InvalidCharPos() == 4);
|
|
919 |
|
|
920 |
test(TheFs.IsValidName(_L("C:\\?\\group\\release.txt"),param)==EFalse);
|
|
921 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
922 |
test(param.InvalidCharPos() == 4);
|
|
923 |
|
|
924 |
test(TheFs.IsValidName(_L("C:\\..\\group\\release.txt"),param)==EFalse);
|
|
925 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
926 |
test(param.InvalidCharPos() == 4);
|
|
927 |
|
|
928 |
test(TheFs.IsValidName(_L("C:\\.\\group\\release.txt"),param)==EFalse);
|
|
929 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
930 |
test(param.InvalidCharPos() == 4);
|
|
931 |
|
|
932 |
test(TheFs.IsValidName(_L("C:\\>\\group\\release.txt"),param)==EFalse);
|
|
933 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
934 |
test(param.InvalidCharPos() == 4);
|
|
935 |
|
|
936 |
test(TheFs.IsValidName(_L("C:\\<\\group\\release.txt"),param)==EFalse);
|
|
937 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
938 |
test(param.InvalidCharPos() == 4);
|
|
939 |
|
|
940 |
test(TheFs.IsValidName(_L("C:\\HelloWorld\\:\\group\\release.txt"),param)==EFalse);
|
|
941 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
942 |
test(param.InvalidCharPos() == 15);
|
|
943 |
|
|
944 |
test(TheFs.IsValidName(_L("C::\\group\\release.txt"),param)==EFalse);
|
|
945 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
946 |
test(param.InvalidCharPos() == 3);
|
|
947 |
|
|
948 |
test(TheFs.IsValidName(_L(">\\group\\release.txt"),param)==EFalse);
|
|
949 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
950 |
test(param.InvalidCharPos() == 1);
|
|
951 |
|
|
952 |
test(TheFs.IsValidName(_L("C|group\\release.txt"),param)==EFalse);
|
|
953 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
954 |
test(param.InvalidCharPos() == 2);
|
|
955 |
|
|
956 |
test(TheFs.IsValidName(_L("C\\|\\group\\release.txt"),param)==EFalse);
|
|
957 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
958 |
test(param.InvalidCharPos() == 3);
|
|
959 |
|
|
960 |
test(TheFs.IsValidName(_L("\\>"),param)==EFalse);
|
|
961 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
962 |
test(param.InvalidCharPos() == 2);
|
|
963 |
|
|
964 |
test(TheFs.IsValidName(_L("C:\\|group\\release.txt"),param)==EFalse);
|
|
965 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
966 |
test(param.InvalidCharPos() == 4);
|
|
967 |
|
|
968 |
test(TheFs.IsValidName(_L("C:\\\"\\group\\release.txt"),param)==EFalse);
|
|
969 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
970 |
test(param.InvalidCharPos() == 4);
|
|
971 |
|
|
972 |
test(TheFs.IsValidName(_L("C:\\/\\group\\release.txt"),param)==EFalse);
|
|
973 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
974 |
test(param.InvalidCharPos() == 4);
|
|
975 |
|
|
976 |
test(TheFs.IsValidName(_L("C:\\|\\group\\release.txt"),param)==EFalse);
|
|
977 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
978 |
test(param.InvalidCharPos() == 4);
|
|
979 |
|
|
980 |
test(TheFs.IsValidName(_L("C:\\ \\group\\release.txt"),param)==EFalse);//intermediate directory names cannot be blank
|
|
981 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadName);
|
|
982 |
|
|
983 |
// Test that \ is not allowed in filenames
|
|
984 |
TFileName filename;
|
|
985 |
filename=_L("C:\\HelloWorld\\\\\\group\\release.txt");
|
|
986 |
|
|
987 |
test(TheFs.IsValidName(filename,param)==EFalse);
|
|
988 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
989 |
test(param.InvalidCharPos() == 22);
|
|
990 |
|
|
991 |
filename=_L("C:\\\\\\group\\release.txt");
|
|
992 |
test(TheFs.IsValidName(filename,param)==EFalse);
|
|
993 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
994 |
test(param.InvalidCharPos() == 11);
|
|
995 |
|
|
996 |
filename=_L("C:\\Hello World\\group\\release.txt");
|
|
997 |
filename[8]=KPathDelimiter;
|
|
998 |
test(TheFs.IsValidName(filename,param));
|
|
999 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone);
|
|
1000 |
|
|
1001 |
filename=_L("C:\\HelloWorld\\::\\group\\release.txt");
|
|
1002 |
test(TheFs.IsValidName(filename,param)==EFalse);
|
|
1003 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
1004 |
test(param.InvalidCharPos() == 16);
|
|
1005 |
|
|
1006 |
filename=_L("C:\\>>\\group\\release.txt");
|
|
1007 |
test(TheFs.IsValidName(filename,param)==EFalse);
|
|
1008 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
1009 |
test(param.InvalidCharPos() == 5);
|
|
1010 |
|
|
1011 |
test(TheFs.IsValidName(_L(""),param)==EFalse); // Must be a name
|
|
1012 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadName);
|
|
1013 |
|
|
1014 |
test(TheFs.IsValidName(_L(".ext"),param));
|
|
1015 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone);
|
|
1016 |
|
|
1017 |
test(TheFs.IsValidName(_L("C:\\asdf.blarg"),param));
|
|
1018 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone);
|
|
1019 |
|
|
1020 |
test(TheFs.IsValidName(_L("C:\\asdf..blarg"),param));
|
|
1021 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone);
|
|
1022 |
|
|
1023 |
// Test multiple evil characters - parsing occurs from right to left
|
|
1024 |
// except that wildcarded characters take priority and are picked out first
|
|
1025 |
|
|
1026 |
test(TheFs.IsValidName(_L("abc>def|ghi?jkl:mno<pqr*stu"),param)==EFalse);
|
|
1027 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
1028 |
test(param.InvalidCharPos() == 24);
|
|
1029 |
|
|
1030 |
test(TheFs.IsValidName(_L("abc>def|ghi<jkl:mno?pqr"),param)==EFalse);
|
|
1031 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
1032 |
test(param.InvalidCharPos() == 20);
|
|
1033 |
|
|
1034 |
test(TheFs.IsValidName(_L("abc>def|ghi<jkl:mno"),param)==EFalse);
|
|
1035 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
1036 |
test(param.InvalidCharPos() == 16);
|
|
1037 |
|
|
1038 |
test(TheFs.IsValidName(_L("abc>def|ghi<jkl:mno"),param)==EFalse);
|
|
1039 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
1040 |
test(param.InvalidCharPos() == 16);
|
|
1041 |
|
|
1042 |
test(TheFs.IsValidName(_L("abc>def|ghi<jkl"),param)==EFalse);
|
|
1043 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
1044 |
test(param.InvalidCharPos() == 12);
|
|
1045 |
|
|
1046 |
test(TheFs.IsValidName(_L("abc>def|ghi<jkl"),param)==EFalse);
|
|
1047 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
1048 |
test(param.InvalidCharPos() == 12);
|
|
1049 |
|
|
1050 |
test(TheFs.IsValidName(_L("abc>def|ghi"),param)==EFalse);
|
|
1051 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
1052 |
test(param.InvalidCharPos() == 8);
|
|
1053 |
|
|
1054 |
test(TheFs.IsValidName(_L("abc>def|ghi"),param)==EFalse);
|
|
1055 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
1056 |
test(param.InvalidCharPos() == 8);
|
|
1057 |
|
|
1058 |
test(TheFs.IsValidName(_L("abc>def"),param)==EFalse);
|
|
1059 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
1060 |
test(param.InvalidCharPos() == 4);
|
|
1061 |
|
|
1062 |
test(TheFs.IsValidName(_L("abc>def"),param)==EFalse);
|
|
1063 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
1064 |
test(param.InvalidCharPos() == 4);
|
|
1065 |
|
|
1066 |
test(!TheFs.IsValidName(_L("C:\\v123456.."),param));
|
|
1067 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
1068 |
test(param.InvalidCharPos() == 11);
|
|
1069 |
|
|
1070 |
test(!TheFs.IsValidName(_L("C:\\v123456.."),param));
|
|
1071 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
|
|
1072 |
test(param.InvalidCharPos() == 11);
|
|
1073 |
|
|
1074 |
test(TheFs.IsValidName(_L("abc"),param)); // Valid name
|
|
1075 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone);
|
|
1076 |
|
|
1077 |
test(TheFs.IsValidName(_L("abc"),param)); // Valid name
|
|
1078 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone);
|
|
1079 |
|
|
1080 |
test(TheFs.IsValidName(_L("as(){}@~#;!\xA3$%^&()df.blarg"),param)); // Valid name
|
|
1081 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone);
|
|
1082 |
|
|
1083 |
test(TheFs.IsValidName(_L("as(){}@~#;!\xA3$%^&()df.blarg"),param)); // Valid name
|
|
1084 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone);
|
|
1085 |
|
|
1086 |
test(TheFs.IsValidName(_L("C:\\asdf.blarg\\asdf.blarg"),param)); // Valid name
|
|
1087 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone);
|
|
1088 |
|
|
1089 |
test(TheFs.IsValidName(_L("C:\\asdf.blarg\\asdf.blarg"),param)); // Valid name
|
|
1090 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone);
|
|
1091 |
|
|
1092 |
test(TheFs.IsValidName(_L("\'"),param)); // Valid name
|
|
1093 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone);
|
|
1094 |
|
|
1095 |
test(TheFs.IsValidName(_L("\'"),param)); // Valid name
|
|
1096 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone);
|
|
1097 |
|
|
1098 |
//testing directory names
|
|
1099 |
test(TheFs.IsValidName(_L("\\"),param));
|
|
1100 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); // Valid Name
|
|
1101 |
|
|
1102 |
test(TheFs.IsValidName(_L("C:\\asdf.blarg\\"),param));
|
|
1103 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); // Valid Name
|
|
1104 |
|
|
1105 |
|
|
1106 |
test(TheFs.IsValidName(_L("C:\\asdf..blarg\\"),param));
|
|
1107 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); // Valid Name
|
|
1108 |
|
|
1109 |
test(TheFs.IsValidName(_L("file1.txt\\\\"),param) == EFalse);
|
|
1110 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrBadName);
|
|
1111 |
|
|
1112 |
// test name which exceeds KMaxFileName only on prepending the session path
|
|
1113 |
_LIT(KNameLength250, "AAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAA");
|
|
1114 |
if(useDefaultSessionPath)
|
|
1115 |
{
|
|
1116 |
test(TheFs.IsValidName(KNameLength250, param)==EFalse);
|
|
1117 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNameTooLong);
|
|
1118 |
break;
|
|
1119 |
}
|
|
1120 |
else
|
|
1121 |
{
|
|
1122 |
test(TheFs.IsValidName(KNameLength250, param));
|
|
1123 |
test(param.ErrorCode() == RFs::TNameValidParam::ErrNone);
|
|
1124 |
}
|
|
1125 |
useDefaultSessionPath = ETrue;
|
|
1126 |
}
|
|
1127 |
}
|
|
1128 |
|
|
1129 |
|
|
1130 |
|
|
1131 |
void TestGetMediaSerialNumber()
|
|
1132 |
{
|
|
1133 |
test.Next(_L("Test RFs::GetMediaSerialNumber"));
|
|
1134 |
TInt theDrive;
|
|
1135 |
TInt r = TheFs.CharToDrive(gDriveToTest,theDrive);
|
123
|
1136 |
test_KErrNone(r);
|
0
|
1137 |
TMediaSerialNumber serNum;
|
|
1138 |
r = TheFs.GetMediaSerialNumber(serNum, theDrive);
|
|
1139 |
if (r) test.Printf(_L("RFs::GetMediaSerialNumber returned error %d"), r);
|
123
|
1140 |
test_Value(r, r == KErrNotSupported || r == KErrNotReady || r == KErrNone);
|
0
|
1141 |
if (r == KErrNotSupported)
|
|
1142 |
{
|
|
1143 |
test.Printf(_L("MediaSerialNumber: Not Supported\n"));
|
|
1144 |
}
|
|
1145 |
else
|
|
1146 |
{
|
|
1147 |
test.Printf(_L("MediaSerialNumber: length=%d\n"), serNum.Length());
|
|
1148 |
TBuf<20> str;
|
|
1149 |
_LIT(KNumberString, "%02X");
|
|
1150 |
_LIT(KNewLine, "\n");
|
|
1151 |
TInt i;
|
|
1152 |
for (i = 0; i < serNum.Length(); i++)
|
|
1153 |
{
|
|
1154 |
str.AppendFormat(KNumberString, serNum[i]);
|
|
1155 |
if (i%8 == 7)
|
|
1156 |
{
|
|
1157 |
str.Append(KNewLine);
|
|
1158 |
test.Printf(_L("%S"), &str);
|
|
1159 |
str.SetLength(0);
|
|
1160 |
}
|
|
1161 |
}
|
|
1162 |
if (i%8 != 7)
|
|
1163 |
{
|
|
1164 |
test.Printf(KNewLine);
|
|
1165 |
}
|
|
1166 |
}
|
|
1167 |
}
|
|
1168 |
|
|
1169 |
|
|
1170 |
//--------------------------------------------------------
|
|
1171 |
|
|
1172 |
|
|
1173 |
/**
|
|
1174 |
Create a file of specified size filled with some data pattern.
|
|
1175 |
@param aFs ref. to the FS
|
|
1176 |
@param aFileName name of the file
|
|
1177 |
@param aFileSize size of the file to be created
|
|
1178 |
@return KErrNone on success, system-wide error code otherwise
|
|
1179 |
*/
|
|
1180 |
TInt CreateStuffedFile(RFs& aFs, const TDesC& aFileName, TUint aFileSize)
|
|
1181 |
{
|
|
1182 |
TInt nRes;
|
|
1183 |
RFile file;
|
|
1184 |
|
|
1185 |
//-- create a buffer with some data
|
|
1186 |
TBuf8<KBufLength> buffer;
|
|
1187 |
buffer.SetLength(KBufLength);
|
|
1188 |
|
|
1189 |
TUint i;
|
|
1190 |
|
|
1191 |
for(i = 0; i < KBufLength; i++)
|
|
1192 |
buffer[i] = static_cast<TUint8> (i) ;
|
|
1193 |
|
|
1194 |
//-- create a file
|
|
1195 |
nRes = file.Create(aFs, aFileName, EFileRead|EFileWrite);
|
|
1196 |
if(nRes != KErrNone)
|
|
1197 |
return nRes;
|
|
1198 |
|
|
1199 |
const TUint n1 = aFileSize / KBufLength;
|
|
1200 |
const TUint n2 = aFileSize % KBufLength;
|
|
1201 |
|
|
1202 |
//-- fill the file with the data from buffer
|
|
1203 |
for(i=0; i<n1; ++i)
|
|
1204 |
{
|
|
1205 |
nRes = file.Write(buffer);
|
|
1206 |
if(nRes != KErrNone)
|
|
1207 |
return nRes;
|
|
1208 |
}
|
|
1209 |
|
|
1210 |
if(n2)
|
|
1211 |
{
|
|
1212 |
nRes = file.Write(buffer, n2); //-- write the rest of the data
|
|
1213 |
if(nRes != KErrNone)
|
|
1214 |
return nRes;
|
|
1215 |
}
|
|
1216 |
|
|
1217 |
file.Close();
|
|
1218 |
|
|
1219 |
return KErrNone;
|
|
1220 |
}
|
|
1221 |
|
|
1222 |
//--------------------------------------------------------
|
|
1223 |
|
|
1224 |
/**
|
|
1225 |
Check if the specified file contains illegitimate information i.e. something different from 0x00, 0xff, 0x03, 0xcc
|
|
1226 |
|
|
1227 |
@param aFs ref. to the FS
|
|
1228 |
@param aFileName name of the file
|
|
1229 |
@return KErrNone on success, KErrCorrupt otherwise
|
|
1230 |
*/
|
|
1231 |
TInt CheckFileContents(RFs& aFs, const TDesC& aFileName)
|
|
1232 |
{
|
|
1233 |
TInt nRes = KErrNone;
|
|
1234 |
RFile file;
|
|
1235 |
|
|
1236 |
TBuf8<KBufLength> buffer;
|
|
1237 |
buffer.SetLength(0);
|
|
1238 |
|
|
1239 |
//-- open the file
|
|
1240 |
nRes = file.Open(aFs, aFileName, EFileRead);
|
123
|
1241 |
test_KErrNone(nRes);
|
0
|
1242 |
|
|
1243 |
//-- check file contents
|
|
1244 |
TUint nFilePos=0;
|
|
1245 |
for(;;)
|
|
1246 |
{
|
|
1247 |
//-- read data from the file into the buffer
|
|
1248 |
nRes = file.Read(buffer);
|
123
|
1249 |
test_KErrNone(nRes);
|
0
|
1250 |
|
|
1251 |
if(buffer.Length() == 0)
|
|
1252 |
{
|
|
1253 |
nRes = KErrNone; //-- read all the file, no illegitimate information found
|
|
1254 |
break; //EOF
|
|
1255 |
}
|
|
1256 |
|
123
|
1257 |
#ifdef __NFE_MEDIA_DRIVER_PRESENT__
|
|
1258 |
// check the buffer doesn't contain the same pattern written to it by CreateStuffedFile()
|
|
1259 |
TUint i;
|
|
1260 |
for(i = 0; i < KBufLength; i++)
|
|
1261 |
if (buffer[i] != static_cast<TUint8> (i))
|
|
1262 |
break;
|
|
1263 |
if (i == KBufLength)
|
|
1264 |
{
|
|
1265 |
nRes = KErrCorrupt; //-- indicate that the read buffer contains illegitimate information
|
|
1266 |
break; //-- comment this out if you need a full dump of the file
|
|
1267 |
}
|
|
1268 |
#else
|
0
|
1269 |
//-- check if the buffer contains only allowed data (RAM page initialisation data, etc. e.g. 0x00, 0xff, 0x03, 0xcc)
|
|
1270 |
if(!CheckBufferContents(buffer, nFilePos))
|
|
1271 |
{
|
|
1272 |
test.Printf(_L("\nCheckFileContents failed ! The file contains illegitimate information!\n"));
|
|
1273 |
nRes = KErrCorrupt; //-- indicate that the read buffer contains illegitimate information
|
|
1274 |
break; //-- comment this out if you need a full dump of the file
|
|
1275 |
}
|
123
|
1276 |
#endif
|
0
|
1277 |
|
|
1278 |
nFilePos+=buffer.Length();
|
|
1279 |
}
|
|
1280 |
|
|
1281 |
file.Close();
|
|
1282 |
return nRes;
|
|
1283 |
}
|
|
1284 |
|
|
1285 |
//--------------------------------------------------------
|
|
1286 |
|
|
1287 |
/**
|
|
1288 |
Check if the buffer contains illegitimate information i.e. something different from 0x00, 0xff, 0x03, 0xcc
|
|
1289 |
|
|
1290 |
@param aBuffer buffer descriptor to check
|
|
1291 |
@param aPrintBaseAddr dump base address, used for dumping buffer only
|
|
1292 |
@return ETrue on success
|
|
1293 |
*/
|
|
1294 |
TBool CheckBufferContents(const TDesC8& aBuffer, TUint aPrintBaseAddr/*=0*/)
|
|
1295 |
{
|
|
1296 |
TBool bRes = ETrue;
|
|
1297 |
|
|
1298 |
//-- check if the buffer filled with allowable data (RAM page initialisation data or something similar)
|
|
1299 |
//-- but not something meaningful.
|
199
|
1300 |
//-- Actually, the buffer should be filled with uniformed bytes (most probably, 0x00)
|
0
|
1301 |
for(TInt i=0; i<aBuffer.Size(); ++i)
|
|
1302 |
{
|
|
1303 |
TUint8 byte = aBuffer[i];
|
199
|
1304 |
if(byte != aBuffer[0])
|
0
|
1305 |
{
|
|
1306 |
bRes = EFalse;
|
|
1307 |
break;
|
|
1308 |
}
|
|
1309 |
}
|
|
1310 |
|
|
1311 |
//-- dump the buffer if it contains anything different than allowed data
|
|
1312 |
if (!bRes)
|
|
1313 |
{
|
|
1314 |
for (TInt n=0; n<aBuffer.Size(); )
|
|
1315 |
{
|
|
1316 |
TBuf16<3> byteBuffer;
|
|
1317 |
TBuf16<256> lineBuffer;
|
|
1318 |
lineBuffer.Format(_L("%08X: "), aPrintBaseAddr+n);
|
|
1319 |
for (TInt m=0; m<16 && n<aBuffer.Size(); m++, n++)
|
|
1320 |
{
|
|
1321 |
byteBuffer.Format(_L("%02X "), aBuffer[n]);
|
|
1322 |
lineBuffer.Append(byteBuffer);
|
|
1323 |
}
|
|
1324 |
test.Printf(lineBuffer);
|
|
1325 |
}
|
|
1326 |
}
|
|
1327 |
|
|
1328 |
return bRes;
|
|
1329 |
}
|
|
1330 |
|
199
|
1331 |
//--------------------------------------------------------
|
|
1332 |
/**
|
|
1333 |
Check if the drive aDriveNo is finalised or not.
|
|
1334 |
The "CleanShutDown" is obtained by QueryVolumeInfoExt API which is FS-agnostic.
|
0
|
1335 |
|
199
|
1336 |
@param aDriveNo drive number to query.
|
|
1337 |
@return ETrue if the drive if finalised
|
|
1338 |
*/
|
|
1339 |
static TBool IsVolumeFinalised(TInt aDriveNo)
|
|
1340 |
{
|
|
1341 |
TInt nRes;
|
|
1342 |
TPckgBuf<TBool> boolPckg;
|
|
1343 |
|
|
1344 |
//-- 1. get "Finalised" state by using the API
|
|
1345 |
nRes = TheFs.QueryVolumeInfoExt(aDriveNo, EIsDriveFinalised, boolPckg);
|
|
1346 |
test_KErrNone(nRes);
|
|
1347 |
|
|
1348 |
return boolPckg();
|
|
1349 |
}
|
|
1350 |
|
|
1351 |
|
|
1352 |
//--------------------------------------------------------
|
|
1353 |
/**
|
|
1354 |
This is a file system - agnostic test that verifies RFs::FinaliseDrive() API
|
|
1355 |
There are also file system - specific tests that check similar functionallity (see t_mount for example)
|
|
1356 |
|
|
1357 |
*/
|
|
1358 |
void TestDriveFinalisation()
|
|
1359 |
{
|
|
1360 |
test.Next(_L("TestDriveFinalisation(). Testing RFs::FinaliseDrives() API\n"));
|
|
1361 |
|
|
1362 |
|
|
1363 |
if((!Is_Fat(TheFs, gDriveNum) && !Is_ExFat(TheFs, gDriveNum)) || Is_Fat12(TheFs, gDriveNum) )
|
|
1364 |
{
|
|
1365 |
test.Printf(_L("This test can't be performed on current file system, skipping.\n"));
|
|
1366 |
return;
|
|
1367 |
}
|
|
1368 |
|
|
1369 |
TVolumeInfo v;
|
|
1370 |
TInt nRes;
|
|
1371 |
|
|
1372 |
nRes = TheFs.Volume(v);
|
|
1373 |
test(nRes==KErrNone);
|
|
1374 |
|
|
1375 |
if(v.iDrive.iMediaAtt & KMediaAttVariableSize)
|
|
1376 |
{
|
|
1377 |
test.Printf(_L("Skipping. RAM drive not tested.\n"));
|
|
1378 |
return;
|
|
1379 |
}
|
|
1380 |
|
|
1381 |
|
|
1382 |
TBool bDriveFinalised;
|
|
1383 |
|
|
1384 |
//============= 1. finalise the drive (RW mode) and check the result
|
|
1385 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW);
|
|
1386 |
test_KErrNone(nRes);
|
|
1387 |
|
|
1388 |
bDriveFinalised = IsVolumeFinalised(gDriveNum);
|
|
1389 |
test(bDriveFinalised);
|
|
1390 |
|
|
1391 |
//-- 1.1 finalise the drive second time EFinal_RW -> EFinal_RW shall work
|
|
1392 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW);
|
|
1393 |
test_KErrNone(nRes);
|
|
1394 |
|
|
1395 |
bDriveFinalised = IsVolumeFinalised(gDriveNum);
|
|
1396 |
test(bDriveFinalised);
|
|
1397 |
|
|
1398 |
//============= 2. create a file. Shall succeed (EFinal_RW), the volume shall become unfinalised
|
|
1399 |
|
|
1400 |
RFile file;
|
|
1401 |
_LIT(KFileName, "\\my_file1.dat");
|
|
1402 |
_LIT8(KSomeData, "this is some data");
|
|
1403 |
|
|
1404 |
nRes = CreateEmptyFile(TheFs, KFileName, 128000);
|
|
1405 |
test_KErrNone(nRes);
|
|
1406 |
|
|
1407 |
bDriveFinalised = IsVolumeFinalised(gDriveNum);
|
|
1408 |
test(!bDriveFinalised); //-- the volume has become "unfinalised"
|
|
1409 |
|
|
1410 |
//----------------------------------------------------------------------------------
|
|
1411 |
//-- test volume finalisation with opened objects
|
|
1412 |
|
|
1413 |
//-- 2.1 having opened files should be OK for volume finalisation
|
|
1414 |
|
|
1415 |
//-- 2.1.1 RW finalisation; after the volume finalised it should be possible to write to the opened file
|
|
1416 |
nRes = file.Open(TheFs, KFileName, EFileWrite | EFileWriteDirectIO);
|
|
1417 |
test_KErrNone(nRes);
|
|
1418 |
|
|
1419 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW);
|
|
1420 |
test_KErrNone(nRes);
|
|
1421 |
|
|
1422 |
bDriveFinalised = IsVolumeFinalised(gDriveNum);
|
|
1423 |
test(bDriveFinalised);
|
|
1424 |
|
|
1425 |
nRes = file.Write(0, KSomeData);
|
|
1426 |
test_KErrNone(nRes);
|
|
1427 |
|
|
1428 |
bDriveFinalised = IsVolumeFinalised(gDriveNum);
|
|
1429 |
test(!bDriveFinalised); //-- the volume should become "unfinalised"
|
|
1430 |
|
|
1431 |
//-- 2.1.2 RO finalisation; after the volume finalised it shouldn't be possible to write to the opened file
|
|
1432 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RO);
|
|
1433 |
test_KErrNone(nRes);
|
|
1434 |
|
|
1435 |
bDriveFinalised = IsVolumeFinalised(gDriveNum);
|
|
1436 |
test(bDriveFinalised);
|
|
1437 |
|
|
1438 |
nRes = file.Write(0, KSomeData);
|
|
1439 |
test(nRes == KErrAccessDenied); //-- no write access to the volume
|
|
1440 |
|
|
1441 |
bDriveFinalised = IsVolumeFinalised(gDriveNum);
|
|
1442 |
test(bDriveFinalised); //-- the volume should become "unfinalised"
|
|
1443 |
|
|
1444 |
file.Close();
|
|
1445 |
|
|
1446 |
//-- remount FS, the drive shall become RW
|
|
1447 |
nRes = RemountFS(TheFs, gDriveNum);
|
|
1448 |
test_KErrNone(nRes);
|
|
1449 |
|
|
1450 |
|
|
1451 |
//-- 2.2 having opened directories should be OK for volume finalisation
|
|
1452 |
_LIT(KDirName, "\\Dir11235tt\\");
|
|
1453 |
MakeDir(KDirName);
|
|
1454 |
RDir dir;
|
|
1455 |
|
|
1456 |
//-- 2.2.1 RW finalisation; after the volume finalised it should be possible to have write access to it
|
|
1457 |
nRes = dir.Open(TheFs, KDirName, KEntryAttNormal);
|
|
1458 |
test_KErrNone(nRes);
|
|
1459 |
|
|
1460 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW);
|
|
1461 |
test_KErrNone(nRes);
|
|
1462 |
|
|
1463 |
bDriveFinalised = IsVolumeFinalised(gDriveNum);
|
|
1464 |
test(bDriveFinalised);
|
|
1465 |
|
|
1466 |
nRes = CreateEmptyFile(TheFs, KFileName, 128000);
|
|
1467 |
test_KErrNone(nRes);
|
|
1468 |
|
|
1469 |
bDriveFinalised = IsVolumeFinalised(gDriveNum);
|
|
1470 |
test(!bDriveFinalised);
|
|
1471 |
|
|
1472 |
//-- 2.1.2 RO finalisation; after the volume finalised it shouldn't be possible to write to it
|
|
1473 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RO);
|
|
1474 |
test_KErrNone(nRes);
|
|
1475 |
|
|
1476 |
bDriveFinalised = IsVolumeFinalised(gDriveNum);
|
|
1477 |
test(bDriveFinalised);
|
|
1478 |
|
|
1479 |
nRes = CreateEmptyFile(TheFs, KFileName, 128000);
|
|
1480 |
test(nRes == KErrAccessDenied); //-- no write access to the volume
|
|
1481 |
|
|
1482 |
bDriveFinalised = IsVolumeFinalised(gDriveNum);
|
|
1483 |
test(bDriveFinalised); //-- the volume should become "unfinalised"
|
|
1484 |
|
|
1485 |
dir.Close();
|
|
1486 |
|
|
1487 |
//-- remount FS, the drive shall become RW
|
|
1488 |
nRes = RemountFS(TheFs, gDriveNum);
|
|
1489 |
test_KErrNone(nRes);
|
|
1490 |
|
|
1491 |
//-- 2.3 having opened disk access objects, like formats or raw disks makes finalisation impossible
|
|
1492 |
RFormat format;
|
|
1493 |
RRawDisk rawDisk;
|
|
1494 |
TInt fmtCnt;
|
|
1495 |
|
|
1496 |
//-- 2.3.1 format
|
|
1497 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW);
|
|
1498 |
test_KErrNone(nRes);
|
|
1499 |
|
|
1500 |
nRes = format.Open(TheFs, gSessionPath, EFullFormat, fmtCnt);
|
|
1501 |
test_KErrNone(nRes);
|
|
1502 |
|
|
1503 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW);
|
|
1504 |
test(nRes == KErrInUse);
|
|
1505 |
|
|
1506 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RO);
|
|
1507 |
test(nRes == KErrInUse);
|
|
1508 |
|
|
1509 |
format.Close();
|
|
1510 |
|
|
1511 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW);
|
|
1512 |
test_KErrNone(nRes);
|
|
1513 |
|
|
1514 |
//-- 2.3.2 raw disk
|
|
1515 |
nRes = rawDisk.Open(TheFs, gDriveNum);
|
|
1516 |
test_KErrNone(nRes);
|
|
1517 |
|
|
1518 |
|
|
1519 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW);
|
|
1520 |
test(nRes == KErrInUse);
|
|
1521 |
|
|
1522 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RO);
|
|
1523 |
test(nRes == KErrInUse);
|
|
1524 |
|
|
1525 |
rawDisk.Close();
|
|
1526 |
|
|
1527 |
//-- 2.4 Volume finalisation and file system dismounting
|
|
1528 |
|
|
1529 |
//-- 2.4.1 "graceful" dismounting should finalise the drive correctly
|
|
1530 |
|
|
1531 |
//-- "unfinalise the volume"
|
|
1532 |
nRes = CreateEmptyFile(TheFs, KFileName, 128000);
|
|
1533 |
test_KErrNone(nRes);
|
|
1534 |
|
|
1535 |
bDriveFinalised = IsVolumeFinalised(gDriveNum);
|
|
1536 |
test(!bDriveFinalised);
|
|
1537 |
|
|
1538 |
TFSDescriptor fsDesc;
|
|
1539 |
nRes = GetFileSystemDescriptor(TheFs, gDriveNum, fsDesc);
|
|
1540 |
test_KErrNone(nRes);
|
|
1541 |
|
|
1542 |
//-- gracefully dismount the file system
|
|
1543 |
nRes = TheFs.DismountFileSystem(fsDesc.iFsName, gDriveNum);
|
|
1544 |
test_KErrNone(nRes);
|
|
1545 |
|
|
1546 |
//-- mount it back
|
|
1547 |
nRes = MountFileSystem(TheFs, gDriveNum, fsDesc);
|
|
1548 |
test_KErrNone(nRes);
|
|
1549 |
|
|
1550 |
bDriveFinalised = IsVolumeFinalised(gDriveNum);
|
|
1551 |
test(bDriveFinalised);
|
|
1552 |
|
|
1553 |
//-- 2.4.2 "forced" dismounting, usually happens when "graceful doesn't work, because there are files opened on the volume.
|
|
1554 |
//-- Should also finalise the drive correctly
|
|
1555 |
|
|
1556 |
//-- "unfinalise the volume"
|
|
1557 |
nRes = CreateEmptyFile(TheFs, KFileName, 128000);
|
|
1558 |
test_KErrNone(nRes);
|
|
1559 |
|
|
1560 |
bDriveFinalised = IsVolumeFinalised(gDriveNum);
|
|
1561 |
test(!bDriveFinalised);
|
|
1562 |
|
|
1563 |
//-- open a file on the volume, this will prevent graceful dismounting
|
|
1564 |
nRes = file.Open(TheFs, KFileName, EFileWrite | EFileWriteDirectIO);
|
|
1565 |
test_KErrNone(nRes);
|
|
1566 |
|
|
1567 |
nRes = GetFileSystemDescriptor(TheFs, gDriveNum, fsDesc);
|
|
1568 |
test_KErrNone(nRes);
|
|
1569 |
|
|
1570 |
//-- try gracefully dismount the file system
|
|
1571 |
nRes = TheFs.DismountFileSystem(fsDesc.iFsName, gDriveNum);
|
|
1572 |
test(nRes == KErrInUse); //-- no luck, as expected
|
|
1573 |
|
|
1574 |
//-- now do dismounting by force
|
|
1575 |
TRequestStatus rqStat;
|
|
1576 |
TheFs.NotifyDismount(gDriveNum, rqStat, EFsDismountForceDismount);
|
|
1577 |
User::WaitForRequest(rqStat);
|
|
1578 |
test_KErrNone(rqStat.Int());
|
|
1579 |
|
|
1580 |
nRes = file.Write(0, KSomeData);
|
|
1581 |
test(nRes == KErrNotReady);
|
|
1582 |
|
|
1583 |
file.Close();
|
|
1584 |
|
|
1585 |
//-- mount it back
|
|
1586 |
nRes = MountFileSystem(TheFs, gDriveNum, fsDesc);
|
|
1587 |
test_KErrNone(nRes);
|
|
1588 |
|
|
1589 |
bDriveFinalised = IsVolumeFinalised(gDriveNum);
|
|
1590 |
test(bDriveFinalised);
|
|
1591 |
|
|
1592 |
//============= 3. test "unfinalise API"
|
|
1593 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EForceUnfinalise);
|
|
1594 |
test_KErrNone(nRes);
|
|
1595 |
|
|
1596 |
bDriveFinalised = IsVolumeFinalised(gDriveNum);
|
|
1597 |
test(!bDriveFinalised); //-- the volume has become "unfinalised"
|
|
1598 |
|
|
1599 |
//============= 4. test finalisation into RO mode
|
|
1600 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RO); //-- the volume becomes RO
|
|
1601 |
test_KErrNone(nRes);
|
|
1602 |
|
|
1603 |
//-- try to write a file on RO volume; it shall fail with KErrAccessDenied
|
|
1604 |
nRes = CreateEmptyFile(TheFs, KFileName, 128000);
|
|
1605 |
test(nRes == KErrAccessDenied);
|
|
1606 |
file.Close();
|
|
1607 |
|
|
1608 |
//-- 4.1 try to finalise into EFinal_RW mode, shall fail with KErrAccessDenied
|
|
1609 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW);
|
|
1610 |
test(nRes == KErrAccessDenied);
|
|
1611 |
|
|
1612 |
//-- 4.2 "unfinalise" the volume, it still shall remain RO
|
|
1613 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EForceUnfinalise);
|
|
1614 |
test_KErrNone(nRes);
|
|
1615 |
|
|
1616 |
//-- try to write a file on RO volume; it shall fail with KErrAccessDenied
|
|
1617 |
nRes = CreateEmptyFile(TheFs, KFileName, 128000);
|
|
1618 |
test(nRes == KErrAccessDenied);
|
|
1619 |
file.Close();
|
|
1620 |
|
|
1621 |
//-- remount FS, the drive shall become RW
|
|
1622 |
nRes = RemountFS(TheFs, gDriveNum);
|
|
1623 |
test_KErrNone(nRes);
|
|
1624 |
|
|
1625 |
bDriveFinalised = IsVolumeFinalised(gDriveNum);
|
|
1626 |
test(bDriveFinalised);
|
|
1627 |
|
|
1628 |
//-- try to write a file on RW volume, shall be OK
|
|
1629 |
nRes = CreateEmptyFile(TheFs, KFileName, 128000);
|
|
1630 |
test(nRes == KErrNone);
|
|
1631 |
file.Close();
|
|
1632 |
|
|
1633 |
bDriveFinalised = IsVolumeFinalised(gDriveNum);
|
|
1634 |
test(!bDriveFinalised);
|
|
1635 |
|
|
1636 |
//============= 5. test various finalisation modes
|
|
1637 |
|
|
1638 |
//-- 5.1 Not finalised -> EFinal_RW (KErrNone)
|
|
1639 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW);
|
|
1640 |
test(nRes == KErrNone);
|
|
1641 |
bDriveFinalised = IsVolumeFinalised(gDriveNum);
|
|
1642 |
test(bDriveFinalised);
|
|
1643 |
|
|
1644 |
//-- 5.2 EFinal_RW -> EFinal_RO (KErrNone)
|
|
1645 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RO);
|
|
1646 |
test(nRes == KErrNone);
|
|
1647 |
bDriveFinalised = IsVolumeFinalised(gDriveNum);
|
|
1648 |
test(bDriveFinalised);
|
|
1649 |
|
|
1650 |
//-- 5.2 EFinal_RO -> EFinal_RW (KErrAccessDenied)
|
|
1651 |
nRes =TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW);
|
|
1652 |
test(nRes == KErrAccessDenied);
|
|
1653 |
bDriveFinalised = IsVolumeFinalised(gDriveNum);
|
|
1654 |
test(bDriveFinalised);
|
|
1655 |
|
|
1656 |
//-- 5.3 restore
|
|
1657 |
nRes = RemountFS(TheFs, gDriveNum);
|
|
1658 |
test_KErrNone(nRes);
|
|
1659 |
|
|
1660 |
|
|
1661 |
//============= 6. test old RFs::FinaliseDrives API
|
|
1662 |
|
|
1663 |
nRes = CreateEmptyFile(TheFs, KFileName, 128000);
|
|
1664 |
test(nRes == KErrNone);
|
|
1665 |
|
|
1666 |
bDriveFinalised = IsVolumeFinalised(gDriveNum);
|
|
1667 |
test(!bDriveFinalised);
|
|
1668 |
|
|
1669 |
TheFs.FinaliseDrives(); //-- shall work as TheFs.FinaliseDrive(gDriveNum, RFs::EFinal_RW) but for ALL drives
|
|
1670 |
|
|
1671 |
bDriveFinalised = IsVolumeFinalised(gDriveNum);
|
|
1672 |
test(bDriveFinalised);
|
|
1673 |
|
|
1674 |
nRes = CreateEmptyFile(TheFs, KFileName, 128000);
|
|
1675 |
test(nRes == KErrNone);
|
|
1676 |
|
|
1677 |
|
|
1678 |
|
|
1679 |
}
|
|
1680 |
|
|
1681 |
|
|
1682 |
void CallTestsL()
|
0
|
1683 |
{
|
199
|
1684 |
//-- set up console output
|
|
1685 |
F32_Test_Utils::SetConsole(test.Console());
|
0
|
1686 |
|
199
|
1687 |
TInt nRes=TheFs.CharToDrive(gDriveToTest, gDriveNum);
|
|
1688 |
test_KErrNone(nRes);
|
|
1689 |
|
|
1690 |
PrintDrvInfo(TheFs, gDriveNum);
|
|
1691 |
|
|
1692 |
TestDriveFinalisation();
|
0
|
1693 |
Test1();
|
|
1694 |
Test2();
|
|
1695 |
Test3();
|
|
1696 |
Test4();
|
|
1697 |
Test5();
|
|
1698 |
Test6();
|
|
1699 |
Test7();
|
|
1700 |
Test8();
|
|
1701 |
Test9();
|
|
1702 |
Test10();
|
|
1703 |
Test11();
|
|
1704 |
Test12();
|
|
1705 |
Test13();
|
|
1706 |
Test14();
|
|
1707 |
Test15();
|
|
1708 |
TestGetMediaSerialNumber();
|
199
|
1709 |
|
0
|
1710 |
}
|