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