author | William Roberts <williamr@symbian.org> |
Fri, 23 Jul 2010 10:28:58 +0100 | |
changeset 224 | da1922ac85fb |
parent 109 | b3a1d9898418 |
child 247 | d8d70de2bd36 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 2007-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 |
// N.B. Before running this test on WINS, ensure that the estart.txt file contains |
|
15 |
// nothing but EFAT32 i.e. no EFAT - otherwise the FAT16 file system will be used |
|
16 |
// On target ensure that the FAT32 filesystem is in the ROM instead of the FAT16 file system |
|
17 |
// This test expects the following files to be present before running the test: |
|
18 |
// size name |
|
19 |
// 2147483647 \F32-TST\File2GBMinusOne.txt |
|
20 |
// 2147483648 \F32-TST\File2GB.txt |
|
21 |
// 3221225472 \F32-TST\File3GB.txt |
|
22 |
// 4294967295 \F32-TST\File4GBMinusOne.txt // may be absent on an 8GB disk |
|
23 |
// For verification purposes, Every 4 bytes of each file contains the current position, e.g. |
|
24 |
// 0000: 00 00 00 00 |
|
25 |
// 0004: 04 00 00 00 |
|
26 |
// 0008: 08 00 00 00 |
|
27 |
// .. etc |
|
28 |
// These files can be created using the BigFileWriter tool in f32test/tool |
|
29 |
// If this test is run on the emulator and the __MOUNT_RAW_EXT__ macro is defined (see below) then |
|
30 |
// the T_RAWEXT file system extension will be loaded; this extension allows reading and writing to |
|
31 |
// a windows disk in "raw" format, thus allowing direct access to a windows disk. see f32test/ext/t_rawext |
|
32 |
// for more details. |
|
33 |
// |
|
34 |
// |
|
35 |
||
36 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
37 |
#define __E32TEST_EXTENSION__ |
0 | 38 |
#include <f32file.h> |
39 |
#include <e32test.h> |
|
40 |
#include <e32svr.h> |
|
41 |
#include "t_server.h" |
|
42 |
||
43 |
||
44 |
GLDEF_D RTest test(_L("T_BIGFILE")); |
|
45 |
||
46 |
#ifdef __WINS__ |
|
47 |
// enable this macro to mount the RAWEXT.FXT file system extension to test on a particular windows drive |
|
48 |
#define __MOUNT_RAW_EXT__ |
|
49 |
#endif |
|
50 |
||
51 |
#ifdef __MOUNT_RAW_EXT__ |
|
52 |
_LIT(KExtName,"RAWEXT"); |
|
53 |
||
54 |
_LIT(KFAT32FName,"EFAT32"); |
|
55 |
_LIT(KFATName,"FAT"); |
|
56 |
||
57 |
TFullName gOldFsName; |
|
58 |
#endif |
|
59 |
||
60 |
TInt gDrive; |
|
61 |
TBool gNTFS=EFalse; |
|
62 |
||
63 |
const TUint K1Kb = 1 << 10; |
|
64 |
//const TUint K1Mb = 1 << 20; |
|
65 |
const TUint K1Gb = 1 << 30; |
|
66 |
const TUint K2Gb = 0x80000000; |
|
67 |
const TUint K2GbMinusOne = 0x7FFFFFFF; |
|
68 |
const TUint K3Gb = 0xC0000000; |
|
69 |
const TUint K4GbMinusOne = 0xFFFFFFFF; |
|
70 |
const TUint KPosMask = 0xFFFFFFFC; |
|
71 |
||
72 |
//const TUint KBigFileSizeSigned = KMaxTInt32; // 2Gb -1 |
|
73 |
//const TUint KBigFileSizeUnsigned = KMaxTUint32; // 4Gb -1 |
|
74 |
||
75 |
const TInt KBufSize = (256 * K1Kb); |
|
76 |
HBufC8* gBuf = NULL; |
|
77 |
TPtr8 gBufPtr(NULL, 0, 0); |
|
78 |
||
79 |
||
80 |
_LIT(KFile2GBMinusOne, "File2GBMinusOne.txt"); |
|
81 |
_LIT(KFile2GB, "File2GB.txt"); |
|
82 |
_LIT(KFile3GB, "File3GB.txt"); |
|
83 |
_LIT(KFile4GBMinusOne, "File4GBMinusOne.txt"); |
|
84 |
TInt gFilesInDirectory = 4; |
|
85 |
||
86 |
||
87 |
// return ETrue if the specifiled file is present |
|
88 |
TBool FilePresent(const TDesC& aFileName) |
|
89 |
{ |
|
90 |
TEntry entry; |
|
91 |
TInt r = TheFs.Entry(aFileName, entry); |
|
92 |
return (r == KErrNone ? (TBool)ETrue : (TBool)EFalse); |
|
93 |
} |
|
94 |
||
95 |
class CFileManObserver : public CBase, public MFileManObserver |
|
96 |
{ |
|
97 |
public: |
|
98 |
CFileManObserver(CFileMan* aFileMan); |
|
99 |
||
100 |
TControl NotifyFileManStarted(); |
|
101 |
TControl NotifyFileManOperation(); |
|
102 |
TControl NotifyFileManEnded(); |
|
103 |
private: |
|
104 |
CFileMan* iFileMan; |
|
105 |
public: |
|
106 |
TInt iNotifyEndedSuccesses; |
|
107 |
TInt iNotifyEndedFailures; |
|
108 |
}; |
|
109 |
||
110 |
CFileManObserver::CFileManObserver(CFileMan* aFileMan) |
|
111 |
{ |
|
112 |
__DECLARE_NAME(_S("CFileManObserver")); |
|
113 |
iFileMan=aFileMan; |
|
114 |
} |
|
115 |
||
116 |
MFileManObserver::TControl CFileManObserver::NotifyFileManStarted() |
|
117 |
{ |
|
118 |
TInt lastError = iFileMan->GetLastError(); |
|
119 |
TFileName fileName = iFileMan->CurrentEntry().iName; |
|
120 |
test.Printf(_L("NotifyFileManStarted(): Error %d File %S\n"),lastError, &fileName); |
|
121 |
return(MFileManObserver::EContinue); |
|
122 |
} |
|
123 |
||
124 |
MFileManObserver::TControl CFileManObserver::NotifyFileManOperation() |
|
125 |
{ |
|
126 |
TInt lastError = iFileMan->GetLastError(); |
|
127 |
TFileName fileName = iFileMan->CurrentEntry().iName; |
|
128 |
test.Printf(_L("NotifyFileManOperation(): Error %d File %S\n"),lastError, &fileName); |
|
129 |
return(MFileManObserver::EContinue); |
|
130 |
} |
|
131 |
||
132 |
MFileManObserver::TControl CFileManObserver::NotifyFileManEnded() |
|
133 |
{ |
|
134 |
TInt lastError = iFileMan->GetLastError(); |
|
135 |
TFileName fileName = iFileMan->CurrentEntry().iName; |
|
136 |
test.Printf(_L("NotifyFileManEnded(): Error %d File %S\n"),lastError, &fileName); |
|
137 |
if (lastError == KErrNone) |
|
138 |
iNotifyEndedSuccesses++; |
|
139 |
else |
|
140 |
iNotifyEndedFailures++; |
|
141 |
return(MFileManObserver::EContinue); |
|
142 |
} |
|
143 |
||
144 |
||
145 |
||
146 |
//---------------------------------------------------------------------------------------------- |
|
147 |
//! @SYMTestCaseID PBASE-T_BIGFILE-0001 |
|
148 |
//! @SYMTestType CIT |
|
149 |
//! @SYMTestCaseDesc Test that 2GB-1 file can be opened and read |
|
150 |
//! @SYMTestActions Open the file, seek to end-1K and read some data. Verify the results |
|
151 |
//! @SYMTestExpectedResults Should succeed |
|
152 |
//! @SYMTestPriority High |
|
153 |
//! @SYMTestStatus Implemented |
|
154 |
//---------------------------------------------------------------------------------------------- |
|
155 |
void OpenAndRead2GBMinusOne() |
|
156 |
{ |
|
157 |
RFile f; |
|
158 |
TEntry entry; |
|
159 |
TUint testSize; |
|
160 |
TUint size; |
|
161 |
TUint testPos; |
|
162 |
TInt r; |
|
163 |
||
164 |
TPtr8 bufPtr = gBuf->Des(); |
|
165 |
bufPtr.SetLength(bufPtr.MaxLength()); |
|
166 |
||
167 |
const TFileName fname = KFile2GBMinusOne(); |
|
168 |
||
169 |
test.Next(_L("2GBMinusOne File: Open")); |
|
170 |
||
171 |
r = f.Open(TheFs, fname, EFileRead); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
172 |
test_KErrNone(r); |
0 | 173 |
|
174 |
testSize = K2GbMinusOne; |
|
175 |
||
176 |
test.Next(_L("2GBMinusOne File: Read")); |
|
177 |
||
178 |
r=f.Size((TInt&) size); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
179 |
test_KErrNone(r); |
0 | 180 |
test(size == testSize); |
181 |
||
182 |
r = TheFs.Entry(fname, entry); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
183 |
test_KErrNone(r); |
0 | 184 |
test ((TUint) entry.iSize == testSize); |
185 |
||
186 |
// seek to just below 2GB |
|
187 |
testPos = (K2GbMinusOne - K1Kb) & KPosMask; |
|
188 |
r = f.Seek(ESeekStart, (TInt&) testPos); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
189 |
test_KErrNone(r); |
0 | 190 |
|
191 |
r = f.Read(bufPtr); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
192 |
test_KErrNone(r); |
0 | 193 |
|
194 |
TUint posRead = * ((TUint*) &bufPtr[0]); |
|
195 |
test.Printf(_L("position read %08X, expected %08X\n"), posRead, testPos); |
|
196 |
test(posRead == testPos); |
|
197 |
||
198 |
f.Close(); |
|
199 |
} |
|
200 |
||
201 |
//---------------------------------------------------------------------------------------------- |
|
202 |
//! @SYMTestCaseID PBASE-T_BIGFILE-0002 |
|
203 |
//! @SYMTestType CIT |
|
204 |
//! @SYMTestCaseDesc Test that attempting to open a 2GB file fails |
|
205 |
//! @SYMTestActions Open the file |
|
206 |
//! @SYMTestExpectedResults KErrToBig |
|
207 |
//! @SYMTestPriority High |
|
208 |
//! @SYMTestStatus Implemented |
|
209 |
//---------------------------------------------------------------------------------------------- |
|
210 |
void Open2GB() |
|
211 |
{ |
|
212 |
RFile f; |
|
213 |
TEntry entry; |
|
214 |
TUint testSize; |
|
215 |
TInt r; |
|
216 |
||
217 |
TPtr8 bufPtr = gBuf->Des(); |
|
218 |
bufPtr.SetLength(bufPtr.MaxLength()); |
|
219 |
||
220 |
const TFileName fname = KFile2GB(); |
|
221 |
testSize = K2Gb; |
|
222 |
||
223 |
test.Next(_L("2GB File: Test the size with RFs::Entry")); |
|
224 |
r = TheFs.Entry(fname, entry); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
225 |
test_KErrNone(r); |
0 | 226 |
test ((TUint) entry.iSize == testSize); |
227 |
||
228 |
test.Next(_L("2GB File: Attempt to open (should fail with KErrToBig)")); |
|
229 |
||
230 |
r = f.Open(TheFs, fname, EFileRead); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
231 |
test_Value(r, r == KErrTooBig); |
0 | 232 |
} |
233 |
||
234 |
//---------------------------------------------------------------------------------------------- |
|
235 |
//! @SYMTestCaseID PBASE-T_BIGFILE-0003 |
|
236 |
//! @SYMTestType CIT |
|
237 |
//! @SYMTestCaseDesc Test that attempting to open a 2GB file fails |
|
238 |
//! @SYMTestActions Open the file |
|
239 |
//! @SYMTestExpectedResults KErrToBig |
|
240 |
//! @SYMTestPriority High |
|
241 |
//! @SYMTestStatus Implemented |
|
242 |
//---------------------------------------------------------------------------------------------- |
|
243 |
void Open3GB() |
|
244 |
{ |
|
245 |
RFile f; |
|
246 |
TEntry entry; |
|
247 |
TUint testSize; |
|
248 |
TInt r; |
|
249 |
||
250 |
TPtr8 bufPtr = gBuf->Des(); |
|
251 |
bufPtr.SetLength(bufPtr.MaxLength()); |
|
252 |
||
253 |
const TFileName fname = KFile3GB(); |
|
254 |
testSize = K3Gb; |
|
255 |
||
256 |
test.Next(_L("3GB File: Test the size with RFs::Entry")); |
|
257 |
r = TheFs.Entry(fname, entry); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
258 |
test_KErrNone(r); |
0 | 259 |
test ((TUint) entry.iSize == testSize); |
260 |
||
261 |
test.Next(_L("3GB File: Attempt to open (should fail with KErrToBig)")); |
|
262 |
||
263 |
r = f.Open(TheFs, fname, EFileRead); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
264 |
test_Value(r, r == KErrTooBig); |
0 | 265 |
} |
266 |
||
267 |
//---------------------------------------------------------------------------------------------- |
|
268 |
//! @SYMTestCaseID PBASE-T_BIGFILE-0004 |
|
269 |
//! @SYMTestType CIT |
|
270 |
//! @SYMTestCaseDesc Test that attempting to open a 4GB file fails |
|
271 |
//! @SYMTestActions Open the file |
|
272 |
//! @SYMTestExpectedResults KErrToBig |
|
273 |
//! @SYMTestPriority High |
|
274 |
//! @SYMTestStatus Implemented |
|
275 |
//---------------------------------------------------------------------------------------------- |
|
276 |
void Open4GB() |
|
277 |
{ |
|
278 |
RFile f; |
|
279 |
TEntry entry; |
|
280 |
TUint testSize; |
|
281 |
TInt r; |
|
282 |
||
283 |
TPtr8 bufPtr = gBuf->Des(); |
|
284 |
bufPtr.SetLength(bufPtr.MaxLength()); |
|
285 |
||
286 |
const TFileName fname = KFile4GBMinusOne(); |
|
287 |
testSize = K4GbMinusOne; |
|
288 |
||
289 |
test.Next(_L("4GB File: Test the size with RFs::Entry")); |
|
290 |
r = TheFs.Entry(fname, entry); |
|
291 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
292 |
test_KErrNone(r); |
0 | 293 |
test ((TUint) entry.iSize == testSize); |
294 |
||
295 |
test.Next(_L("4GB File: Attempt to open (should fail with KErrToBig)")); |
|
296 |
||
297 |
r = f.Open(TheFs, fname, EFileRead); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
298 |
test_Value(r, r == KErrTooBig); |
0 | 299 |
} |
300 |
||
301 |
//---------------------------------------------------------------------------------------------- |
|
302 |
//! @SYMTestCaseID PBASE-T_BIGFILE-0005 |
|
303 |
//! @SYMTestType CIT |
|
304 |
//! @SYMTestCaseDesc Attempt to append to the end of a 2GB-1 file |
|
305 |
//! @SYMTestActions Open the file, seek to end and write one byte |
|
306 |
//! @SYMTestExpectedResults RFile::Write(0 returns KErrToBig |
|
307 |
//! @SYMTestPriority High |
|
308 |
//! @SYMTestStatus Implemented |
|
309 |
//---------------------------------------------------------------------------------------------- |
|
310 |
void Extend2GBMinusOne() |
|
311 |
{ |
|
312 |
RFile f; |
|
313 |
TEntry entry; |
|
314 |
TUint testSize; |
|
315 |
TUint size; |
|
316 |
TUint testPos; |
|
317 |
TInt r; |
|
318 |
||
319 |
TPtr8 bufPtr = gBuf->Des(); |
|
320 |
bufPtr.SetLength(bufPtr.MaxLength()); |
|
321 |
||
322 |
const TFileName fname = KFile2GBMinusOne(); |
|
323 |
testSize = K2GbMinusOne; |
|
324 |
||
325 |
test.Next(_L("2GBMinusOne File: Open")); |
|
326 |
||
327 |
r = f.Open(TheFs, fname, EFileRead | EFileWrite); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
328 |
test_KErrNone(r); |
0 | 329 |
|
330 |
||
331 |
test.Next(_L("2GBMinusOne File: Attempt to extend")); |
|
332 |
||
333 |
r=f.Size((TInt&) size); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
334 |
test_KErrNone(r); |
0 | 335 |
test(size == testSize); |
336 |
||
337 |
r = TheFs.Entry(fname, entry); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
338 |
test_KErrNone(r); |
0 | 339 |
test ((TUint) entry.iSize == testSize); |
340 |
||
341 |
// seek to end |
|
342 |
testPos = 0; |
|
343 |
r = f.Seek(ESeekEnd, (TInt&) testPos); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
344 |
test_KErrNone(r); |
0 | 345 |
|
346 |
bufPtr.SetLength(1); |
|
347 |
r = f.Write(bufPtr); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
348 |
test_Value(r, r == KErrTooBig); |
0 | 349 |
|
350 |
f.Close(); |
|
351 |
} |
|
352 |
||
353 |
//---------------------------------------------------------------------------------------------- |
|
354 |
//! @SYMTestCaseID PBASE-T_BIGFILE-0006 |
|
355 |
//! @SYMTestType CIT |
|
356 |
//! @SYMTestCaseDesc Check that deleting a large file frees cluster properly |
|
357 |
//! @SYMTestActions Delete the passed file name, call RFs::CheckDisk |
|
358 |
//! On windows, we could run chkdsk utility |
|
359 |
//! @SYMTestExpectedResults RFs::CheckDisk returns success |
|
360 |
//! @SYMTestPriority High |
|
361 |
//! @SYMTestStatus Implemented |
|
362 |
//---------------------------------------------------------------------------------------------- |
|
363 |
void DeleteLargeFile(const TDesC& aFileName) |
|
364 |
{ |
|
365 |
test.Next(_L("Delete large file")); |
|
366 |
test.Printf(_L("Deleting %S\n"), &aFileName); |
|
367 |
||
368 |
TInt r = TheFs.Delete(aFileName); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
369 |
test_KErrNone(r); |
0 | 370 |
|
371 |
CheckDisk(); |
|
372 |
} |
|
373 |
||
374 |
||
375 |
//---------------------------------------------------------------------------------------------- |
|
376 |
//! @SYMTestCaseID PBASE-T_BIGFILE-0007 |
|
377 |
//! @SYMTestType CIT |
|
378 |
//! @SYMTestCaseDesc Check that we can get a valid directory listing of a directory |
|
379 |
//! containing large files using RDir and then CDir |
|
380 |
//! @SYMTestActions Open the directory using RDir and examine the results |
|
381 |
//! On windows, we could run chkdsk utility |
|
382 |
//! @SYMTestExpectedResults The expected number of files should exist with the correct sizes |
|
383 |
//! @SYMTestPriority High |
|
384 |
//! @SYMTestStatus Implemented |
|
385 |
//---------------------------------------------------------------------------------------------- |
|
386 |
void ReadDirectory() |
|
387 |
{ |
|
388 |
test.Next(_L("Read a directory containing large files using RDir")); |
|
389 |
||
390 |
RDir dir; |
|
391 |
TInt r = dir.Open(TheFs, _L("*.*"), KEntryAttNormal); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
392 |
test_KErrNone(r); |
0 | 393 |
|
394 |
TEntryArray entryArray; |
|
395 |
r = dir.Read(entryArray); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
396 |
test_Value(r, r == KErrEof); |
0 | 397 |
|
398 |
test(entryArray.Count() == gFilesInDirectory); |
|
399 |
||
400 |
TInt n; |
|
401 |
for (n=0; n<entryArray.Count(); n++) |
|
402 |
{ |
|
403 |
const TEntry& entry = entryArray[n]; |
|
404 |
if (entry.iName.MatchF(KFile2GBMinusOne()) == 0) |
|
405 |
{ |
|
406 |
test((TUint) entry.iSize == K2GbMinusOne); |
|
407 |
} |
|
408 |
else if (entry.iName.MatchF(KFile2GB()) == 0) |
|
409 |
{ |
|
410 |
test((TUint) entry.iSize == K2Gb); |
|
411 |
} |
|
412 |
else if (entry.iName.MatchF(KFile3GB()) == 0) |
|
413 |
{ |
|
414 |
test((TUint) entry.iSize == K3Gb); |
|
415 |
} |
|
416 |
else if (entry.iName.MatchF(KFile4GBMinusOne()) == 0) |
|
417 |
{ |
|
418 |
test((TUint) entry.iSize == K4GbMinusOne); |
|
419 |
} |
|
420 |
else |
|
421 |
test(EFalse); |
|
422 |
} |
|
423 |
||
424 |
dir.Close(); |
|
425 |
||
426 |
test.Next(_L("Read a directory containing large files using CDir & sort by size")); |
|
427 |
CDir* dirList; |
|
428 |
r=TheFs.GetDir(_L("*.*"), KEntryAttMaskSupported, ESortBySize, dirList); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
429 |
test_KErrNone(r); |
0 | 430 |
test(dirList->Count() == gFilesInDirectory); |
431 |
for (n=0; n<dirList->Count(); n++) |
|
432 |
{ |
|
433 |
TEntry entry; |
|
434 |
entry=(*dirList)[n]; |
|
435 |
// test.Printf(_L("#%d: %08X %d %S"), n, entry.iSize, entry.iSize, &entry.iName); |
|
436 |
if (entry.iName.MatchF(KFile2GBMinusOne()) == 0) |
|
437 |
{ |
|
438 |
test((TUint) entry.iSize == K2GbMinusOne); |
|
439 |
test(n == 0); // test entry has been sorted correctly (i.e. according to size) |
|
440 |
} |
|
441 |
else if (entry.iName.MatchF(KFile2GB()) == 0) |
|
442 |
{ |
|
443 |
test((TUint) entry.iSize == K2Gb); |
|
444 |
test(n == 1); |
|
445 |
} |
|
446 |
else if (entry.iName.MatchF(KFile3GB()) == 0) |
|
447 |
{ |
|
448 |
test((TUint) entry.iSize == K3Gb); |
|
449 |
test(n == 2); |
|
450 |
} |
|
451 |
else if (entry.iName.MatchF(KFile4GBMinusOne()) == 0) |
|
452 |
{ |
|
453 |
test((TUint) entry.iSize == K4GbMinusOne); |
|
454 |
test(n == 3); |
|
455 |
} |
|
456 |
else |
|
457 |
test(EFalse); |
|
458 |
} |
|
459 |
||
460 |
delete dirList; |
|
461 |
||
462 |
||
463 |
} |
|
464 |
||
465 |
//---------------------------------------------------------------------------------------------- |
|
466 |
//! @SYMTestCaseID PBASE-T_BIGFILE-0008 |
|
467 |
//! @SYMTestType CIT |
|
468 |
//! @SYMTestCaseDesc Check that we can a move a directory containing large files |
|
469 |
//! Using CFileMan::Move() |
|
470 |
//! @SYMTestActions Use CFileMan::Move() to move files from one directory to another |
|
471 |
//! @SYMTestExpectedResults The files should be moved correctly |
|
472 |
//! @SYMTestPriority High |
|
473 |
//! @SYMTestStatus Implemented |
|
474 |
//---------------------------------------------------------------------------------------------- |
|
475 |
void MoveDirectory() |
|
476 |
{ |
|
477 |
test.Next(_L("Move a directory containing large files")); |
|
478 |
||
479 |
CFileMan* fileMan = CFileMan::NewL(TheFs); |
|
480 |
test(fileMan != NULL); |
|
481 |
||
482 |
TPath filePathOld = gSessionPath; |
|
483 |
filePathOld+= _L("*.*"); |
|
484 |
TPath filePathNew = _L("?:\\TEST\\"); |
|
485 |
TChar driveLetter; |
|
486 |
TInt r=TheFs.DriveToChar(gDrive,driveLetter); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
487 |
test_KErrNone(r); |
0 | 488 |
filePathNew[0] = (TText) driveLetter; |
489 |
||
490 |
// move to new directory |
|
491 |
r = fileMan->Move(filePathOld, filePathNew, CFileMan::ERecurse | CFileMan::EOverWrite); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
492 |
test_KErrNone(r); |
0 | 493 |
|
494 |
// then move back again |
|
495 |
r = fileMan->Move(filePathNew, filePathOld); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
496 |
test_KErrNone(r); |
0 | 497 |
|
498 |
delete fileMan; |
|
499 |
} |
|
500 |
||
501 |
||
502 |
//---------------------------------------------------------------------------------------------- |
|
503 |
//! @SYMTestCaseID PBASE-T_BIGFILE-0009 |
|
504 |
//! @SYMTestType CIT |
|
505 |
//! @SYMTestCaseDesc Check that we can copy a directory containing large file(s) |
|
506 |
//! Using CFileMan::Copy() |
|
507 |
//! @SYMTestActions Use CFileMan::Copy() to copy files from one directory to another |
|
508 |
//! @SYMTestExpectedResults The files should be copied correctly |
|
509 |
//! @SYMTestPriority High |
|
510 |
//! @SYMTestStatus Implemented |
|
511 |
//---------------------------------------------------------------------------------------------- |
|
512 |
void CopyDirectory() |
|
513 |
{ |
|
514 |
test.Next(_L("Copy a directory containing large files")); |
|
515 |
CFileMan* fileMan = CFileMan::NewL(TheFs); |
|
516 |
test(fileMan != NULL); |
|
517 |
||
518 |
CFileManObserver* observer = new CFileManObserver(fileMan); |
|
519 |
test(observer != NULL); |
|
520 |
||
521 |
TPath filePathOld = gSessionPath; |
|
522 |
filePathOld+= _L("*.*"); |
|
523 |
TPath filePathNew = _L("?:\\TEST\\"); |
|
524 |
TChar driveLetter; |
|
525 |
TInt r = TheFs.DriveToChar(gDrive,driveLetter); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
526 |
test_KErrNone(r); |
0 | 527 |
filePathNew[0] = (TText) driveLetter; |
528 |
||
529 |
// create some small files in the source directory |
|
530 |
// so that there is a combination of small files and one large files |
|
531 |
RFile file; |
|
532 |
_LIT(KFileSmall1, "FileSmallOne.txt"); |
|
533 |
_LIT(KFileSmall2, "FileSmallTwo.txt"); |
|
534 |
_LIT(KFileSmall3, "FileSmallThree.txt"); |
|
535 |
r = file.Create(TheFs, KFileSmall1(), EFileWrite | EFileShareAny); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
536 |
test_KErrNone(r); |
0 | 537 |
r = file.Write(_L8("1")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
538 |
test_KErrNone(r); |
0 | 539 |
file.Close(); |
540 |
||
541 |
r = file.Create(TheFs, KFileSmall2(), EFileWrite | EFileShareAny); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
542 |
test_KErrNone(r); |
0 | 543 |
r = file.Write(_L8("12")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
544 |
test_KErrNone(r); |
0 | 545 |
file.Close(); |
546 |
||
547 |
r = file.Create(TheFs, KFileSmall3(), EFileWrite | EFileShareAny); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
548 |
test_KErrNone(r); |
0 | 549 |
r = file.Write(_L8("123")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
550 |
test_KErrNone(r); |
0 | 551 |
file.Close(); |
552 |
||
553 |
// copy to new directory |
|
554 |
r = fileMan->Copy(filePathOld, filePathNew, CFileMan::ERecurse | CFileMan::EOverWrite); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
555 |
test_Value(r, r == KErrNone || r == KErrTooBig); |
0 | 556 |
|
557 |
||
558 |
// check SMALL files have been copied |
|
559 |
RDir dir; |
|
560 |
r = dir.Open(TheFs, filePathNew, KEntryAttNormal); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
561 |
test_KErrNone(r); |
0 | 562 |
TEntryArray entryArray; |
563 |
r = dir.Read(entryArray); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
564 |
test_Value(r, r == KErrEof); |
0 | 565 |
test(entryArray.Count() == 3); |
566 |
dir.Close(); |
|
567 |
||
568 |
// then delete the new directory |
|
569 |
r = fileMan->Delete(filePathNew); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
570 |
test_KErrNone(r); |
0 | 571 |
|
572 |
||
573 |
// attempt to copy to new directory again - this time with an observer |
|
574 |
fileMan->SetObserver(observer); |
|
575 |
r = fileMan->Copy(filePathOld, filePathNew, CFileMan::ERecurse | CFileMan::EOverWrite); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
576 |
test_Value(r, r == KErrNone || r == KErrTooBig); |
0 | 577 |
|
578 |
// test that 3 small files were copied and 1 or 2 large files failed to copy |
|
579 |
// (For 8 GB disk, the 4GB file is missing) |
|
580 |
test(observer->iNotifyEndedSuccesses == 3); |
|
581 |
test(observer->iNotifyEndedFailures == 1 || observer->iNotifyEndedFailures == 2); |
|
582 |
||
583 |
// check SMALL files have been copied |
|
584 |
r = dir.Open(TheFs, filePathNew, KEntryAttNormal); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
585 |
test_KErrNone(r); |
0 | 586 |
r = dir.Read(entryArray); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
587 |
test_Value(r, r == KErrEof); |
0 | 588 |
test(entryArray.Count() == 3); |
589 |
dir.Close(); |
|
590 |
||
591 |
// then delete the new directory |
|
592 |
r = fileMan->Delete(filePathNew); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
593 |
test_KErrNone(r); |
0 | 594 |
|
595 |
delete observer; |
|
596 |
delete fileMan; |
|
597 |
} |
|
598 |
||
599 |
||
600 |
//---------------------------------------------------------------------------------------------- |
|
601 |
//! @SYMTestCaseID PBASE-T_BIGFILE-000A |
|
602 |
//! @SYMTestType CIT |
|
603 |
//! @SYMTestCaseDesc Check that CDirScan works correctly with a directory containing large file(s) |
|
604 |
//! @SYMTestActions Use CFileMan::Copy() to copy files from one directory to another |
|
605 |
//! @SYMTestExpectedResults The files should be copied correctly |
|
606 |
//! @SYMTestPriority High |
|
607 |
//! @SYMTestStatus Implemented |
|
608 |
//---------------------------------------------------------------------------------------------- |
|
609 |
TInt ScanDir(const TDesC& aName, CDirScan::TScanDirection aDirection, TInt aError) |
|
610 |
{ |
|
611 |
TInt r; |
|
612 |
TFileName dirName; |
|
613 |
||
614 |
CDirScan* scanner = NULL; |
|
615 |
TRAP(r, scanner = CDirScan::NewL(TheFs)); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
616 |
test_Value(r, r == KErrNone && scanner); |
0 | 617 |
|
618 |
TRAP(r, scanner->SetScanDataL(aName,KEntryAttDir,ESortByName|EAscending,aDirection)); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
619 |
test_KErrNone(r); |
0 | 620 |
|
621 |
CDir *entryList=NULL; |
|
622 |
TInt filesFound = 0; |
|
623 |
for (;;) |
|
624 |
{ |
|
625 |
TRAP(r, scanner->NextL(entryList)); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
626 |
test_Value(r, r == aError); |
0 | 627 |
if (entryList==NULL) |
628 |
break; |
|
629 |
TInt count = entryList->Count(); |
|
630 |
while (count--) |
|
631 |
{ |
|
632 |
TEntry data=(*entryList)[count]; |
|
633 |
TBuf<KMaxFileName> path=scanner->AbbreviatedPath(); |
|
634 |
dirName = path; |
|
635 |
dirName.Append(data.iName); |
|
636 |
test.Printf(_L(" %S\n"),&dirName); |
|
637 |
filesFound++; |
|
638 |
} |
|
639 |
||
640 |
delete entryList; |
|
641 |
entryList=NULL; |
|
642 |
} |
|
643 |
delete scanner; |
|
644 |
||
645 |
return filesFound; |
|
646 |
} |
|
647 |
||
648 |
||
649 |
||
650 |
GLDEF_C void CallTestsL() |
|
651 |
// |
|
652 |
// Do tests relative to the session path |
|
653 |
// |
|
654 |
{ |
|
655 |
||
656 |
#if defined(__WINS__) |
|
657 |
if (gSessionPath[0]=='C') |
|
658 |
gNTFS=ETrue; |
|
659 |
else |
|
660 |
gNTFS=EFalse; |
|
661 |
#endif |
|
662 |
||
663 |
// don't test on NTFS |
|
664 |
if (gNTFS) |
|
665 |
{ |
|
666 |
test.Printf(_L("Skipping test: Drive is NTFS\n")); |
|
667 |
return; |
|
668 |
} |
|
669 |
||
670 |
TInt r; |
|
671 |
||
672 |
r = TheFs.CharToDrive(gDriveToTest, gDrive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
673 |
test_KErrNone(r); |
0 | 674 |
|
675 |
#ifdef __MOUNT_RAW_EXT__ |
|
676 |
r=TheFs.FileSystemName(gOldFsName, gDrive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
677 |
test_KErrNone(r); |
0 | 678 |
|
679 |
if (gOldFsName.CompareF(KFATName) != 0) |
|
680 |
{ |
|
681 |
test.Printf(_L("Skipping test: Not a FAT drive\n")); |
|
682 |
return; |
|
683 |
} |
|
684 |
||
685 |
r = TheFs.AddExtension(KExtName); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
686 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
0 | 687 |
r = TheFs.MountExtension(KExtName, gDrive); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
688 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
0 | 689 |
#endif |
690 |
||
691 |
TVolumeInfo vi; |
|
692 |
test((r = TheFs.Volume(vi, gDrive)) == KErrNone); |
|
693 |
test.Printf(_L("vi.iSize = %ld\n"), vi.iSize); |
|
694 |
||
695 |
// don't test if media sise is less than 7GB |
|
696 |
if (vi.iSize < TInt64(K1Gb) * TInt64(7)) |
|
697 |
{ |
|
698 |
test.Printf(_L("Skipping test: Drive is not big enough\n")); |
|
699 |
} |
|
700 |
if (!FilePresent(KFile2GB())) |
|
701 |
{ |
|
702 |
test.Printf(_L("Skipping test: Test files not present on drive\n")); |
|
703 |
} |
|
704 |
else |
|
705 |
{ |
|
706 |
gBuf = HBufC8::NewL(KBufSize); |
|
707 |
if (gBuf == NULL) |
|
708 |
User::Leave(KErrNoMemory); |
|
709 |
gBufPtr = gBuf->Des(); |
|
710 |
||
711 |
||
712 |
TInt r; |
|
713 |
||
714 |
// Test that RFs::CheckDisk() succeeds with large files present |
|
715 |
CheckDisk(); |
|
716 |
||
717 |
test.Next(_L("Scan Drive")); |
|
718 |
r = TheFs.ScanDrive(gSessionPath); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
719 |
test_KErrNone(r); |
0 | 720 |
|
721 |
// NB the 4GB file will not be present unless the disk is > 8GB (because it doesn't fit) |
|
722 |
if (!FilePresent(KFile4GBMinusOne())) |
|
723 |
gFilesInDirectory--; |
|
724 |
||
725 |
// test CDirScan |
|
726 |
// the number of files & directories found should be 5 or 4 |
|
727 |
TInt filesFound = ScanDir(_L("\\"), CDirScan::EScanUpTree, KErrNone); |
|
728 |
test (filesFound == gFilesInDirectory+1); |
|
729 |
filesFound = ScanDir(_L("\\"), CDirScan::EScanDownTree, KErrNone); |
|
730 |
test (filesFound == gFilesInDirectory+1); |
|
731 |
||
732 |
OpenAndRead2GBMinusOne(); |
|
733 |
Open2GB(); |
|
734 |
Open3GB(); |
|
735 |
||
736 |
// the 4GB file will not be present unless the disk is > 8GB |
|
737 |
if (FilePresent(KFile4GBMinusOne())) |
|
738 |
Open4GB(); |
|
739 |
||
740 |
Extend2GBMinusOne(); |
|
741 |
||
742 |
ReadDirectory(); |
|
743 |
||
744 |
MoveDirectory(); |
|
745 |
||
746 |
||
747 |
// delete the 2 smaller files to make some space |
|
748 |
DeleteLargeFile(KFile2GB()); |
|
749 |
DeleteLargeFile(KFile2GBMinusOne()); |
|
750 |
||
751 |
CopyDirectory(); |
|
752 |
||
753 |
// delete the 3GB file and check the disk |
|
754 |
DeleteLargeFile(KFile3GB()); |
|
755 |
||
756 |
if (FilePresent(KFile4GBMinusOne())) |
|
757 |
DeleteLargeFile(KFile4GBMinusOne()); |
|
758 |
||
759 |
// Finally check that we can format the drive... |
|
760 |
Format (gDrive); |
|
761 |
} |
|
762 |
||
763 |
#ifdef __MOUNT_RAW_EXT__ |
|
764 |
r = TheFs.DismountExtension(KExtName, gDrive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
765 |
test_KErrNone(r); |
0 | 766 |
|
767 |
r = TheFs.RemoveExtension(KExtName); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
768 |
test_KErrNone(r); |
0 | 769 |
|
770 |
#endif |
|
771 |
||
772 |
delete gBuf; gBuf = NULL; |
|
773 |
} |
|
774 |