|
1 // Copyright (c) 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 "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 #include <e32test.h> |
|
16 |
|
17 #ifdef _SQLPROFILER |
|
18 |
|
19 #include <bautils.h> |
|
20 #include "FileBuf64.h" |
|
21 |
|
22 /////////////////////////////////////////////////////////////////////////////////////// |
|
23 |
|
24 TBool TheOsCallTimeDetailedProfileEnabled = ETrue;//Needed because the RFileBuf64 source is included directly into this test |
|
25 //nd the sql profiler is enabled (_SQLPROFILER is defined in the MMP file) |
|
26 |
|
27 static RTest TheTest(_L("t_sqlfilebuf64 test")); |
|
28 static RFs TheFs; |
|
29 |
|
30 _LIT(KTestDir, "c:\\test\\"); |
|
31 _LIT(KTestFile, "c:\\test\\t_sqlfilebuf64.bin"); |
|
32 _LIT(KTestFile2, "\\test\\t_sqlfilebuf64_2.bin"); |
|
33 |
|
34 static TBuf8<1024> TheBuf; |
|
35 static TFileName TheDbName; |
|
36 |
|
37 static TInt TheProcessHandleCount = 0; |
|
38 static TInt TheThreadHandleCount = 0; |
|
39 static TInt TheAllocatedCellsCount = 0; |
|
40 |
|
41 #ifdef _DEBUG |
|
42 static const TInt KBurstRate = 100; |
|
43 #endif |
|
44 |
|
45 enum TOomTestType |
|
46 { |
|
47 EOomCreateTest, |
|
48 EOomOpenTest, |
|
49 EOomTempTest |
|
50 }; |
|
51 |
|
52 /////////////////////////////////////////////////////////////////////////////////////// |
|
53 |
|
54 void DeleteTestFiles() |
|
55 { |
|
56 if(TheDbName.Length() > 0) |
|
57 { |
|
58 (void)TheFs.Delete(TheDbName); |
|
59 } |
|
60 (void)TheFs.Delete(KTestFile); |
|
61 } |
|
62 |
|
63 void TestEnvDestroy() |
|
64 { |
|
65 DeleteTestFiles(); |
|
66 TheFs.Close(); |
|
67 } |
|
68 |
|
69 /////////////////////////////////////////////////////////////////////////////////////// |
|
70 /////////////////////////////////////////////////////////////////////////////////////// |
|
71 //Test macros and functions |
|
72 void Check1(TInt aValue, TInt aLine) |
|
73 { |
|
74 if(!aValue) |
|
75 { |
|
76 TestEnvDestroy(); |
|
77 RDebug::Print(_L("*** Line %d\r\n"), aLine); |
|
78 TheTest(EFalse, aLine); |
|
79 } |
|
80 } |
|
81 void Check2(TInt aValue, TInt aExpected, TInt aLine) |
|
82 { |
|
83 if(aValue != aExpected) |
|
84 { |
|
85 TestEnvDestroy(); |
|
86 RDebug::Print(_L("*** Line %d, Expected result: %d, got: %d\r\n"), aLine, aExpected, aValue); |
|
87 TheTest(EFalse, aLine); |
|
88 } |
|
89 } |
|
90 #define TEST(arg) ::Check1((arg), __LINE__) |
|
91 #define TEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__) |
|
92 |
|
93 /////////////////////////////////////////////////////////////////////////////////////// |
|
94 |
|
95 void TestEnvInit() |
|
96 { |
|
97 TInt err = TheFs.Connect(); |
|
98 TEST2(err, KErrNone); |
|
99 |
|
100 err = TheFs.MkDir(KTestDir); |
|
101 TEST(err == KErrNone || err == KErrAlreadyExists); |
|
102 } |
|
103 |
|
104 /////////////////////////////////////////////////////////////////////////////////////// |
|
105 |
|
106 static void MarkHandles() |
|
107 { |
|
108 RThread().HandleCount(TheProcessHandleCount, TheThreadHandleCount); |
|
109 } |
|
110 |
|
111 static void MarkAllocatedCells() |
|
112 { |
|
113 TheAllocatedCellsCount = User::CountAllocCells(); |
|
114 } |
|
115 |
|
116 static void CheckAllocatedCells() |
|
117 { |
|
118 TInt allocatedCellsCount = User::CountAllocCells(); |
|
119 TEST2(allocatedCellsCount, TheAllocatedCellsCount); |
|
120 } |
|
121 |
|
122 static void CheckHandles() |
|
123 { |
|
124 TInt endProcessHandleCount; |
|
125 TInt endThreadHandleCount; |
|
126 |
|
127 RThread().HandleCount(endProcessHandleCount, endThreadHandleCount); |
|
128 |
|
129 TEST2(TheProcessHandleCount, endProcessHandleCount); |
|
130 TEST2(TheThreadHandleCount, endThreadHandleCount); |
|
131 } |
|
132 |
|
133 static void VerifyFileContent(const TDesC8& aPattern) |
|
134 { |
|
135 TheBuf.Zero(); |
|
136 |
|
137 RFile64 file; |
|
138 TInt err = file.Open(TheFs, KTestFile, EFileShareReadersOrWriters); |
|
139 TEST2(err, KErrNone); |
|
140 |
|
141 TInt64 fsize; |
|
142 err = file.Size(fsize); |
|
143 TEST2(err, KErrNone); |
|
144 TEST2((TInt)fsize, aPattern.Length()); |
|
145 |
|
146 err = file.Read(TheBuf, aPattern.Length()); |
|
147 TEST2(err, KErrNone); |
|
148 |
|
149 file.Close(); |
|
150 |
|
151 err = TheBuf.Compare(aPattern); |
|
152 TEST2(err, 0); |
|
153 } |
|
154 |
|
155 static void VerifyFileContent(const TDesC8& aPattern, TInt64 aFilePos) |
|
156 { |
|
157 __ASSERT_DEBUG(aFilePos >= 0, User::Invariant()); |
|
158 |
|
159 TheBuf.Zero(); |
|
160 |
|
161 RFile64 file; |
|
162 TInt err = file.Open(TheFs, KTestFile, EFileShareReadersOrWriters); |
|
163 TEST2(err, KErrNone); |
|
164 |
|
165 err = file.Read(aFilePos, TheBuf, aPattern.Length()); |
|
166 TEST2(err, KErrNone); |
|
167 |
|
168 file.Close(); |
|
169 |
|
170 err = TheBuf.Compare(aPattern); |
|
171 TEST2(err, 0); |
|
172 } |
|
173 |
|
174 /** |
|
175 @SYMTestCaseID PDS-SQL-UT-4132 |
|
176 @SYMTestCaseDesc RFileBuf64 write test 1. |
|
177 The test performs file write operations using RFileBuf64 class. |
|
178 The write positions are inside the buffer or right at the end of the buffer. |
|
179 The purpose of the test: to verify the logic of RFileBuf64::Write(). |
|
180 @SYMTestActions RFileBuf64 write test 1. |
|
181 @SYMTestExpectedResults Test must not fail |
|
182 @SYMTestPriority High |
|
183 @SYMREQ REQ12106 |
|
184 REQ12109 |
|
185 */ |
|
186 void WriteTest1() |
|
187 { |
|
188 RFileBuf64 fbuf(1024); |
|
189 TInt err = fbuf.Create(TheFs, KTestFile, EFileWrite); |
|
190 TEST2(err, KErrNone); |
|
191 fbuf.ProfilerReset(); |
|
192 |
|
193 //Zero write request |
|
194 err = fbuf.Write(0, _L8("")); |
|
195 TEST2(err, KErrNone); |
|
196 TEST2(fbuf.iFileWriteCount, 0); |
|
197 TEST2(fbuf.iFileWriteAmount, 0); |
|
198 TEST2(fbuf.iFileSizeCount, 0); |
|
199 |
|
200 //First write operation. After the operation the file buffer must countain 10 bytes. |
|
201 err = fbuf.Write(0, _L8("A123456789")); |
|
202 TEST2(err, KErrNone); |
|
203 TEST2(fbuf.iFileWriteCount, 0); |
|
204 TEST2(fbuf.iFileWriteAmount, 0); |
|
205 TEST2(fbuf.iFileSizeCount, 1); |
|
206 |
|
207 //Second write operation. The offset is at the middle of the buffer. Data length: 10; |
|
208 err = fbuf.Write(5, _L8("ZZZZZEEEEE")); |
|
209 TEST2(err, KErrNone); |
|
210 TEST2(fbuf.iFileWriteCount, 0); |
|
211 TEST2(fbuf.iFileWriteAmount, 0); |
|
212 |
|
213 //Third write operation. The offset is at the end of the buffer. Data length: 5; |
|
214 err = fbuf.Write(15, _L8("CCCCC")); |
|
215 TEST2(err, KErrNone); |
|
216 TEST2(fbuf.iFileWriteCount, 0); |
|
217 TEST2(fbuf.iFileWriteAmount, 0); |
|
218 |
|
219 err = fbuf.Flush(); |
|
220 TEST2(err, KErrNone); |
|
221 TEST2(fbuf.iFileWriteCount, 1); |
|
222 TEST2(fbuf.iFileFlushCount, 1); |
|
223 TEST2(fbuf.iFileWriteAmount, 20); |
|
224 TEST2(fbuf.iFileSizeCount, 1); |
|
225 |
|
226 fbuf.Close(); |
|
227 |
|
228 VerifyFileContent(_L8("A1234ZZZZZEEEEECCCCC")); |
|
229 |
|
230 (void)TheFs.Delete(KTestFile); |
|
231 } |
|
232 |
|
233 /** |
|
234 @SYMTestCaseID PDS-SQL-UT-4133 |
|
235 @SYMTestCaseDesc RFileBuf64 write test 2. |
|
236 The test performs file write operations using RFileBuf64 class. |
|
237 The write positions are beyound the end of the file but within the buffer capacity. |
|
238 The purpose of the test: to verify the logic of RFileBuf64::Write(). |
|
239 @SYMTestActions RFileBuf64 write test 2. |
|
240 @SYMTestExpectedResults Test must not fail |
|
241 @SYMTestPriority High |
|
242 @SYMREQ REQ12106 |
|
243 REQ12109 |
|
244 */ |
|
245 void WriteTest2() |
|
246 { |
|
247 RFileBuf64 fbuf(1024); |
|
248 TInt err = fbuf.Create(TheFs, KTestFile, EFileWrite); |
|
249 TEST2(err, KErrNone); |
|
250 fbuf.ProfilerReset(); |
|
251 |
|
252 //First write operation. After the operation the file buffer must countain 10 bytes. |
|
253 err = fbuf.Write(0, _L8("A123456789")); |
|
254 TEST2(err, KErrNone); |
|
255 TEST2(fbuf.iFileWriteCount, 0); |
|
256 TEST2(fbuf.iFileWriteAmount, 0); |
|
257 TEST2(fbuf.iFileSizeCount, 1); |
|
258 |
|
259 //Second write operation. After the operation the file buffer must countain 10 + 10 zeros + 10 bytes. |
|
260 err = fbuf.Write(20, _L8("FFGGHHJJKK")); |
|
261 TEST2(err, KErrNone); |
|
262 TEST2(fbuf.iFileWriteCount, 0); |
|
263 TEST2(fbuf.iFileWriteAmount, 0); |
|
264 TEST2(fbuf.iFileSizeCount, 1); |
|
265 |
|
266 err = fbuf.Flush(); |
|
267 TEST2(err, KErrNone); |
|
268 TEST2(fbuf.iFileWriteCount, 1); |
|
269 TEST2(fbuf.iFileFlushCount, 1); |
|
270 TEST2(fbuf.iFileWriteAmount, 30); |
|
271 TEST2(fbuf.iFileSizeCount, 1); |
|
272 |
|
273 fbuf.Close(); |
|
274 |
|
275 TBuf8<30> pattern; |
|
276 pattern.Append(_L8("A123456789")); |
|
277 pattern.AppendFill(TChar(0), 10); |
|
278 pattern.Append(_L8("FFGGHHJJKK")); |
|
279 VerifyFileContent(pattern); |
|
280 |
|
281 (void)TheFs.Delete(KTestFile); |
|
282 } |
|
283 |
|
284 /** |
|
285 @SYMTestCaseID PDS-SQL-UT-4134 |
|
286 @SYMTestCaseDesc RFileBuf64 write test 3. |
|
287 The test performs file write operations using RFileBuf64 class. |
|
288 The write position is before the start of the buffer but there is room for move. |
|
289 The purpose of the test: to verify the logic of RFileBuf64::Write(). |
|
290 @SYMTestActions RFileBuf64 write test 3. |
|
291 @SYMTestExpectedResults Test must not fail |
|
292 @SYMTestPriority High |
|
293 @SYMREQ REQ12106 |
|
294 REQ12109 |
|
295 */ |
|
296 void WriteTest3() |
|
297 { |
|
298 //Iteration 1: The file length is 0, the first operation is "write beyond the end" |
|
299 //Iteration 2: The file length is 30, the first write operation is within the file. |
|
300 for(TInt i=0;i<2;++i) |
|
301 { |
|
302 RFileBuf64 fbuf(1024); |
|
303 TInt err = i == 0 ? fbuf.Create(TheFs, KTestFile, EFileWrite) : fbuf.Open(TheFs, KTestFile, EFileWrite); |
|
304 TEST2(err, KErrNone); |
|
305 fbuf.ProfilerReset(); |
|
306 |
|
307 //First write operation. The offset is not 0. Data length: 10; |
|
308 err = fbuf.Write(20, _L8("A123456789")); |
|
309 TEST2(err, KErrNone); |
|
310 TEST2(fbuf.iFileWriteCount, 0); |
|
311 TEST2(fbuf.iFileWriteAmount, 0); |
|
312 TEST2(fbuf.iFileSizeCount, 1); |
|
313 |
|
314 //Second write operation. The offset is 0. Data length: 20; |
|
315 err = fbuf.Write(0, _L8("AASSDDFFRR**********")); |
|
316 TEST2(err, KErrNone); |
|
317 TEST2(fbuf.iFileWriteCount, 0); |
|
318 TEST2(fbuf.iFileWriteAmount, 0); |
|
319 TEST2(fbuf.iFileSizeCount, 1); |
|
320 |
|
321 err = fbuf.Flush(); |
|
322 TEST2(err, KErrNone); |
|
323 TEST2(fbuf.iFileWriteCount, 1); |
|
324 TEST2(fbuf.iFileFlushCount, 1); |
|
325 TEST2(fbuf.iFileWriteAmount, 30); |
|
326 TEST2(fbuf.iFileSizeCount, 1); |
|
327 |
|
328 fbuf.Close(); |
|
329 |
|
330 VerifyFileContent(_L8("AASSDDFFRR**********A123456789")); |
|
331 } |
|
332 (void)TheFs.Delete(KTestFile); |
|
333 } |
|
334 |
|
335 /** |
|
336 @SYMTestCaseID PDS-SQL-UT-4135 |
|
337 @SYMTestCaseDesc RFileBuf64 write test 4. |
|
338 The test performs file write operations using RFileBuf64 class and verifies that |
|
339 that the pending write data will be stored in the file when the buffer is closed. |
|
340 The purpose of the test: to verify the logic of RFileBuf64::Write(). |
|
341 @SYMTestActions RFileBuf64 write test 4. |
|
342 @SYMTestExpectedResults Test must not fail |
|
343 @SYMTestPriority High |
|
344 @SYMREQ REQ12106 |
|
345 REQ12109 |
|
346 */ |
|
347 void WriteTest4() |
|
348 { |
|
349 RFileBuf64 fbuf(1024); |
|
350 TInt err = fbuf.Create(TheFs, KTestFile, EFileWrite); |
|
351 TEST2(err, KErrNone); |
|
352 fbuf.ProfilerReset(); |
|
353 |
|
354 // Data length: 10; |
|
355 err = fbuf.Write(0, _L8("A123456789")); |
|
356 TEST2(err, KErrNone); |
|
357 TEST2(fbuf.iFileWriteCount, 0); |
|
358 TEST2(fbuf.iFileWriteAmount, 0); |
|
359 TEST2(fbuf.iFileSizeCount, 1); |
|
360 |
|
361 // Data length: 0; |
|
362 err = fbuf.Write(10, _L8("")); |
|
363 TEST2(err, KErrNone); |
|
364 TEST2(fbuf.iFileWriteCount, 0); |
|
365 TEST2(fbuf.iFileWriteAmount, 0); |
|
366 TEST2(fbuf.iFileSizeCount, 1); |
|
367 |
|
368 fbuf.Close(); |
|
369 |
|
370 VerifyFileContent(_L8("A123456789")); |
|
371 |
|
372 (void)TheFs.Delete(KTestFile); |
|
373 } |
|
374 |
|
375 /** |
|
376 @SYMTestCaseID PDS-SQL-UT-4136 |
|
377 @SYMTestCaseDesc RFileBuf64 write test 5. |
|
378 The test performs file write operations using RFileBuf64 class. |
|
379 The data is written before the start of the file buffer and is too big to fit in the buffer. |
|
380 The purpose of the test: to verify the logic of RFileBuf64::Write(). |
|
381 @SYMTestActions RFileBuf64 write test 5. |
|
382 @SYMTestExpectedResults Test must not fail |
|
383 @SYMTestPriority High |
|
384 @SYMREQ REQ12106 |
|
385 REQ12109 |
|
386 */ |
|
387 void WriteTest5() |
|
388 { |
|
389 RFileBuf64 fbuf(20); |
|
390 TInt err = fbuf.Create(TheFs, KTestFile, EFileWrite); |
|
391 TEST2(err, KErrNone); |
|
392 fbuf.ProfilerReset(); |
|
393 |
|
394 //First write operation. The offset is not 0. Data length: 10; |
|
395 err = fbuf.Write(10, _L8("A123456789")); |
|
396 TEST2(err, KErrNone); |
|
397 TEST2(fbuf.iFileWriteCount, 0); |
|
398 TEST2(fbuf.iFileWriteAmount, 0); |
|
399 TEST2(fbuf.iFileSizeCount, 1); |
|
400 |
|
401 //Second write operation. The offset is 0. Data length: 12; |
|
402 err = fbuf.Write(0, _L8("ZZXXCCVVBBNN")); |
|
403 TEST2(err, KErrNone); |
|
404 TEST2(fbuf.iFileWriteCount, 1); |
|
405 TEST2(fbuf.iFileWriteAmount, 20); |
|
406 TEST2(fbuf.iFileSizeCount, 1); |
|
407 |
|
408 err = fbuf.Flush(); |
|
409 TEST2(err, KErrNone); |
|
410 TEST2(fbuf.iFileWriteCount, 2); |
|
411 TEST2(fbuf.iFileFlushCount, 1); |
|
412 TEST2(fbuf.iFileWriteAmount, 20 + 12); |
|
413 TEST2(fbuf.iFileSizeCount, 1); |
|
414 |
|
415 fbuf.Close(); |
|
416 |
|
417 VerifyFileContent(_L8("ZZXXCCVVBBNN23456789")); |
|
418 |
|
419 (void)TheFs.Delete(KTestFile); |
|
420 } |
|
421 |
|
422 /** |
|
423 @SYMTestCaseID PDS-SQL-UT-4137 |
|
424 @SYMTestCaseDesc RFileBuf64 write test 6. |
|
425 The test performs file write operations using RFileBuf64 class. |
|
426 The data is written before the start of the file buffer and is too big to fit in the buffer. |
|
427 The purpose of the test: to verify the logic of RFileBuf64::Write(). |
|
428 @SYMTestActions RFileBuf64 write test 6. |
|
429 @SYMTestExpectedResults Test must not fail |
|
430 @SYMTestPriority High |
|
431 @SYMREQ REQ12106 |
|
432 REQ12109 |
|
433 */ |
|
434 void WriteTest6() |
|
435 { |
|
436 RFileBuf64 fbuf(20); |
|
437 TInt err = fbuf.Create(TheFs, KTestFile, EFileWrite); |
|
438 TEST2(err, KErrNone); |
|
439 |
|
440 err = fbuf.Write(0, _L8("A123456789B123456789C123456789")); |
|
441 TEST2(err, KErrNone); |
|
442 err = fbuf.Flush(); |
|
443 TEST2(err, KErrNone); |
|
444 fbuf.Close(); |
|
445 VerifyFileContent(_L8("A123456789B123456789C123456789")); |
|
446 |
|
447 err = fbuf.Open(TheFs, KTestFile, EFileWrite); |
|
448 TEST2(err, KErrNone); |
|
449 fbuf.ProfilerReset(); |
|
450 |
|
451 //First write operation. The offset is not 0. Data length: 10; |
|
452 err = fbuf.Write(15, _L8("OOOOOOOOOO")); |
|
453 TEST2(err, KErrNone); |
|
454 TEST2(fbuf.iFileWriteCount, 0); |
|
455 TEST2(fbuf.iFileWriteAmount, 0); |
|
456 TEST2(fbuf.iFileSizeCount, 1); |
|
457 |
|
458 //Second write operation. The offset is 0. Data length: 15; |
|
459 err = fbuf.Write(0, _L8("TTTTTTTTTTTTTTT")); |
|
460 TEST2(err, KErrNone); |
|
461 TEST2(fbuf.iFileWriteCount, 1); |
|
462 TEST2(fbuf.iFileWriteAmount, 10); |
|
463 TEST2(fbuf.iFileSizeCount, 1); |
|
464 |
|
465 err = fbuf.Flush(); |
|
466 TEST2(err, KErrNone); |
|
467 TEST2(fbuf.iFileWriteCount, 2); |
|
468 TEST2(fbuf.iFileFlushCount, 1); |
|
469 TEST2(fbuf.iFileWriteAmount, 15 + 10); |
|
470 TEST2(fbuf.iFileSizeCount, 1); |
|
471 |
|
472 fbuf.Close(); |
|
473 |
|
474 VerifyFileContent(_L8("TTTTTTTTTTTTTTTOOOOOOOOOO56789")); |
|
475 |
|
476 (void)TheFs.Delete(KTestFile); |
|
477 } |
|
478 |
|
479 void PrepareReadTest() |
|
480 { |
|
481 RFile64 file; |
|
482 TInt err = file.Create(TheFs, KTestFile, EFileWrite); |
|
483 TEST2(err, KErrNone); |
|
484 err = file.Write(_L8("A123456789ZZZZZZZZZZB-B-B-B-B-Y*Y*Y*Y*Y*")); |
|
485 TEST2(err, KErrNone); |
|
486 err = file.Flush(); |
|
487 TEST2(err, KErrNone); |
|
488 file.Close(); |
|
489 } |
|
490 |
|
491 /** |
|
492 @SYMTestCaseID PDS-SQL-UT-4138 |
|
493 @SYMTestCaseDesc RFileBuf64 read test 1. |
|
494 The test performs file read operations using RFileBuf64 class. |
|
495 Tested "read" operations: |
|
496 - Zero max length request; |
|
497 - Too big read request; |
|
498 - Read beyond the end of the file; |
|
499 The purpose of the test: to verify the logic of RFileBuf64::Read(). |
|
500 @SYMTestActions RFileBuf64 read test 1. |
|
501 @SYMTestExpectedResults Test must not fail |
|
502 @SYMTestPriority High |
|
503 @SYMREQ REQ12106 |
|
504 REQ12109 |
|
505 */ |
|
506 void ReadTest1() |
|
507 { |
|
508 const TInt KBufMaxSize = 20;// This is half the file size |
|
509 RFileBuf64 fbuf(KBufMaxSize); |
|
510 TInt err = fbuf.Open(TheFs, KTestFile, EFileWrite | EFileRead | EFileShareReadersOrWriters); |
|
511 TEST2(err, KErrNone); |
|
512 fbuf.ProfilerReset(); |
|
513 |
|
514 //Zero max length request |
|
515 HBufC8* buf1 = HBufC8::New(0); |
|
516 TEST(buf1 != NULL); |
|
517 TPtr8 ptr1 = buf1->Des(); |
|
518 err = fbuf.Read(0, ptr1); |
|
519 TEST2(err, KErrNone); |
|
520 delete buf1; |
|
521 TEST2(fbuf.iFileReadCount, 0); |
|
522 TEST2(fbuf.iFileReadAmount, 0); |
|
523 TEST2(fbuf.iFileSizeCount, 0); |
|
524 |
|
525 //Too big request |
|
526 TBuf8<KBufMaxSize * 2> buf2; |
|
527 err = fbuf.Read(0, buf2); |
|
528 TEST2(err, KErrNone); |
|
529 TEST2(fbuf.iFileReadCount, 1); |
|
530 TEST2(fbuf.iFileReadAmount, (KBufMaxSize * 2)); |
|
531 TEST2(fbuf.iFileSizeCount, 1); |
|
532 VerifyFileContent(buf2); |
|
533 |
|
534 //Read beyond the end of the file |
|
535 err = fbuf.Read(2000, buf2); |
|
536 TEST2(err, KErrNone); |
|
537 TEST2(buf2.Length(), 0); |
|
538 |
|
539 fbuf.Close(); |
|
540 } |
|
541 |
|
542 /** |
|
543 @SYMTestCaseID PDS-SQL-UT-4139 |
|
544 @SYMTestCaseDesc RFileBuf64 read test 2. |
|
545 The test performs file read operations using RFileBuf64 class. |
|
546 Tested operations: |
|
547 - Non-buffered reads; |
|
548 - Buffered reads; |
|
549 The purpose of the test: to verify the logic of RFileBuf64::Read(). |
|
550 @SYMTestActions RFileBuf64 read test 2. |
|
551 @SYMTestExpectedResults Test must not fail |
|
552 @SYMTestPriority High |
|
553 @SYMREQ REQ12106 |
|
554 REQ12109 |
|
555 */ |
|
556 void ReadTest2() |
|
557 { |
|
558 RFileBuf64 fbuf(1024); |
|
559 TInt err = fbuf.Open(TheFs, KTestFile, EFileWrite | EFileRead | EFileShareReadersOrWriters); |
|
560 TEST2(err, KErrNone); |
|
561 fbuf.ProfilerReset(); |
|
562 |
|
563 //1. Read bytes [0..20] |
|
564 TBuf8<20> buf1; |
|
565 err = fbuf.Read(0, buf1); |
|
566 TEST2(err, KErrNone); |
|
567 TEST2(fbuf.iFileReadCount, 1); |
|
568 TEST2(fbuf.iFileReadAmount, 20); |
|
569 TEST2(fbuf.iFileSizeCount, 1); |
|
570 fbuf.ProfilerReset(); |
|
571 VerifyFileContent(buf1, 0); |
|
572 |
|
573 //2. Read again, bytes [10..20]. They are not buffered. |
|
574 TBuf8<10> buf2; |
|
575 err = fbuf.Read(10, buf2); |
|
576 TEST2(err, KErrNone); |
|
577 TEST2(fbuf.iFileReadCount, 1); |
|
578 TEST2(fbuf.iFileReadAmount, 10); |
|
579 TEST2(fbuf.iFileSizeCount, 0); |
|
580 fbuf.ProfilerReset(); |
|
581 VerifyFileContent(buf2, 10); |
|
582 |
|
583 //3. Read again, bytes [20..30]. They are not buffered. But the file buffer will be populated, |
|
584 // because the file read position matches the guessed file read position from step 2. |
|
585 err = fbuf.Read(20, buf2); |
|
586 TEST2(err, KErrNone); |
|
587 TEST2(fbuf.iFileReadCount, 1); |
|
588 TEST2(fbuf.iFileReadAmount, (10 * 2)); |
|
589 TEST2(fbuf.iFileSizeCount, 0); |
|
590 fbuf.ProfilerReset(); |
|
591 VerifyFileContent(buf2, 20); |
|
592 |
|
593 //4. Read again, bytes [25..35]. This is a buffered read operation. |
|
594 err = fbuf.Read(25, buf2); |
|
595 TEST2(err, KErrNone); |
|
596 TEST2(fbuf.iFileReadCount, 0); |
|
597 TEST2(fbuf.iFileReadAmount, 0); |
|
598 TEST2(fbuf.iFileSizeCount, 0); |
|
599 fbuf.ProfilerReset(); |
|
600 VerifyFileContent(buf2, 25); |
|
601 |
|
602 //5. Read again, bytes [15..25]. This is a non buffered read operation. |
|
603 err = fbuf.Read(15, buf2); |
|
604 TEST2(err, KErrNone); |
|
605 TEST2(fbuf.iFileReadCount, 1); |
|
606 TEST2(fbuf.iFileReadAmount, 10); |
|
607 TEST2(fbuf.iFileSizeCount, 0); |
|
608 fbuf.ProfilerReset(); |
|
609 VerifyFileContent(buf2, 15); |
|
610 |
|
611 //6. Read again, bytes [25..35]. This is a buffered read operation. The buffer from step 3 is still there. |
|
612 err = fbuf.Read(25, buf2); |
|
613 TEST2(err, KErrNone); |
|
614 TEST2(fbuf.iFileReadCount, 0); |
|
615 TEST2(fbuf.iFileReadAmount, 0); |
|
616 TEST2(fbuf.iFileSizeCount, 0); |
|
617 fbuf.ProfilerReset(); |
|
618 VerifyFileContent(buf2, 25); |
|
619 |
|
620 //7. Read again, bytes [35..45] - beyond the end of the file. |
|
621 // This is a buffered read operation. The buffer from step 3 is still there. |
|
622 err = fbuf.Read(35, buf2); |
|
623 TEST2(err, KErrNone); |
|
624 TEST2(fbuf.iFileReadCount, 0); |
|
625 TEST2(fbuf.iFileReadAmount, 0); |
|
626 TEST2(fbuf.iFileSizeCount, 0); |
|
627 TEST2(buf2.Size(), 5); |
|
628 fbuf.ProfilerReset(); |
|
629 VerifyFileContent(buf2, 35); |
|
630 |
|
631 fbuf.Close(); |
|
632 } |
|
633 |
|
634 /** |
|
635 @SYMTestCaseID PDS-SQL-UT-4140 |
|
636 @SYMTestCaseDesc RFileBuf64 read test 3. |
|
637 The test performs file read operations using RFileBuf64 class. |
|
638 Tested operations: |
|
639 - Non-buffered reads; |
|
640 - Buffered reads; |
|
641 - Part- buffered reads; |
|
642 The purpose of the test: to verify the logic of RFileBuf64::Read(). |
|
643 @SYMTestActions RFileBuf64 read test 3. |
|
644 @SYMTestExpectedResults Test must not fail |
|
645 @SYMTestPriority High |
|
646 @SYMREQ REQ12106 |
|
647 REQ12109 |
|
648 */ |
|
649 void ReadTest3() |
|
650 { |
|
651 RFileBuf64 fbuf(1024); |
|
652 TInt err = fbuf.Open(TheFs, KTestFile, EFileWrite | EFileRead | EFileShareReadersOrWriters); |
|
653 TEST2(err, KErrNone); |
|
654 fbuf.ProfilerReset(); |
|
655 |
|
656 //1. Read bytes [0..10]. Non buffered. |
|
657 TBuf8<10> buf1; |
|
658 err = fbuf.Read(0, buf1); |
|
659 TEST2(err, KErrNone); |
|
660 TEST2(fbuf.iFileReadCount, 1); |
|
661 TEST2(fbuf.iFileReadAmount, 10); |
|
662 TEST2(fbuf.iFileSizeCount, 1); |
|
663 fbuf.ProfilerReset(); |
|
664 VerifyFileContent(buf1, 0); |
|
665 |
|
666 //2. Read bytes [10..20]. Non buffered. But the file buffer is populated, bytes [10..40]. |
|
667 err = fbuf.Read(10, buf1); |
|
668 TEST2(err, KErrNone); |
|
669 TEST2(fbuf.iFileReadCount, 1); |
|
670 TEST2(fbuf.iFileReadAmount, 30); |
|
671 TEST2(fbuf.iFileSizeCount, 0); |
|
672 fbuf.ProfilerReset(); |
|
673 VerifyFileContent(buf1, 10); |
|
674 |
|
675 //3. Read bytes [25..35]. Buffered. Because the previous operation [2] performed a read-ahead operation. |
|
676 err = fbuf.Read(25, buf1); |
|
677 TEST2(err, KErrNone); |
|
678 TEST2(fbuf.iFileReadCount, 0); |
|
679 TEST2(fbuf.iFileReadAmount, 0); |
|
680 TEST2(fbuf.iFileSizeCount, 0); |
|
681 fbuf.ProfilerReset(); |
|
682 VerifyFileContent(buf1, 25); |
|
683 |
|
684 //4. Write bytes [20..30]. Buffered. Read buffer is gone, the file buffer contains the [20..30] file area. |
|
685 err = fbuf.Write(20, _L8("IIIIIQQQQQ")); |
|
686 TEST2(err, KErrNone); |
|
687 TEST2(fbuf.iFileReadCount, 0); |
|
688 TEST2(fbuf.iFileReadAmount, 0); |
|
689 TEST2(fbuf.iFileWriteCount, 0); |
|
690 TEST2(fbuf.iFileWriteAmount, 0); |
|
691 TEST2(fbuf.iFileSizeCount, 0); |
|
692 fbuf.ProfilerReset(); |
|
693 |
|
694 //5. Read bytes [25..35]. Part-buffered. Part of pending writes picked up. Then the buffer is flushed. |
|
695 err = fbuf.Read(25, buf1); |
|
696 TEST2(err, KErrNone); |
|
697 TEST2(fbuf.iFileReadCount, 1); |
|
698 TEST2(fbuf.iFileReadAmount, 5); |
|
699 TEST2(fbuf.iFileWriteCount, 1); |
|
700 TEST2(fbuf.iFileWriteAmount, 10); |
|
701 TEST2(fbuf.iFileSizeCount, 0); |
|
702 |
|
703 fbuf.ProfilerReset(); |
|
704 err = fbuf.Flush(); |
|
705 TEST2(err, KErrNone); |
|
706 |
|
707 //All cached data should have been written to the file before the Flush() call. |
|
708 TEST2(fbuf.iFileReadCount, 0); |
|
709 TEST2(fbuf.iFileReadAmount, 0); |
|
710 TEST2(fbuf.iFileWriteCount, 0); |
|
711 TEST2(fbuf.iFileWriteAmount, 0); |
|
712 TEST2(fbuf.iFileSizeCount, 0); |
|
713 TEST2(fbuf.iFileFlushCount, 1); |
|
714 |
|
715 fbuf.ProfilerReset(); |
|
716 VerifyFileContent(buf1, 25); |
|
717 |
|
718 //6. The buffer is empty after the last flush. Write bytes [0..10]. The file buffer contains the [0..10] file area. |
|
719 err = fbuf.Write(0, _L8("PPOOIIUUYY")); |
|
720 TEST2(err, KErrNone); |
|
721 TEST2(fbuf.iFileReadCount, 0); |
|
722 TEST2(fbuf.iFileReadAmount, 0); |
|
723 TEST2(fbuf.iFileWriteCount, 0); |
|
724 TEST2(fbuf.iFileWriteAmount, 0); |
|
725 TEST2(fbuf.iFileSizeCount, 0); |
|
726 fbuf.ProfilerReset(); |
|
727 |
|
728 //7. Read bytes [5..15]. Part buffered. Pending writes picked up. The content is written to the file. |
|
729 err = fbuf.Read(5, buf1); |
|
730 TEST2(err, KErrNone); |
|
731 TEST2(fbuf.iFileReadCount, 1); |
|
732 TEST2(fbuf.iFileReadAmount, 5); |
|
733 TEST2(fbuf.iFileWriteCount, 1); |
|
734 TEST2(fbuf.iFileWriteAmount, 10); |
|
735 TEST2(fbuf.iFileSizeCount, 0); |
|
736 fbuf.ProfilerReset(); |
|
737 VerifyFileContent(buf1, 5); |
|
738 |
|
739 fbuf.Close(); |
|
740 } |
|
741 |
|
742 /** |
|
743 @SYMTestCaseID PDS-SQL-UT-4141 |
|
744 @SYMTestCaseDesc RFileBuf64::SetReadAheadSize() test. |
|
745 The test iterates over all existing drives. |
|
746 For each R/W drive a test file is created using RFileBuf64 class. |
|
747 Then the test collects information regarding the block size, cluster size and |
|
748 read buffer size and calls RFileBuf64::SetReadAheadSize() with these parameters |
|
749 to check how the read-ahead buffer size will be recalculated. |
|
750 @SYMTestActions RFileBuf64::SetReadAheadSize() test. |
|
751 @SYMTestExpectedResults Test must not fail |
|
752 @SYMTestPriority High |
|
753 @SYMREQ REQ12106 |
|
754 REQ12109 |
|
755 */ |
|
756 void SetReadAheadSizeTest() |
|
757 { |
|
758 TheTest.Printf(_L("==================\r\n")); |
|
759 _LIT(KType1, "Not present"); |
|
760 _LIT(KType2, "Unknown"); |
|
761 _LIT(KType3, "Floppy"); |
|
762 _LIT(KType4, "Hard disk"); |
|
763 _LIT(KType5, "CD ROM"); |
|
764 _LIT(KType6, "RAM disk"); |
|
765 _LIT(KType7, "Flash"); |
|
766 _LIT(KType8, "ROM drive"); |
|
767 _LIT(KType9, "Remote drive"); |
|
768 _LIT(KType10,"NAND flash"); |
|
769 _LIT(KType11,"Rotating media"); |
|
770 |
|
771 for(TInt drive=EDriveA;drive<=EDriveZ;++drive) |
|
772 { |
|
773 TDriveInfo driveInfo; |
|
774 TInt err = TheFs.Drive(driveInfo, drive); |
|
775 if(err == KErrNone) |
|
776 { |
|
777 TVolumeInfo vinfo; |
|
778 err = TheFs.Volume(vinfo, drive); |
|
779 if(err == KErrNone) |
|
780 { |
|
781 TVolumeIOParamInfo vparam; |
|
782 err = TheFs.VolumeIOParam(drive, vparam); |
|
783 TEST2(err, KErrNone); |
|
784 TBuf8<128> vinfoex8; |
|
785 err = TheFs.QueryVolumeInfoExt(drive, EFileSystemSubType, vinfoex8); |
|
786 TEST2(err, KErrNone); |
|
787 TPtrC vinfoex((const TUint16*)(vinfoex8.Ptr() + 8), vinfoex8[0]); |
|
788 TPtrC KMediaTypeNames[] = {KType1(), KType2(), KType3(), KType4(), KType5(), KType6(), KType7(), KType8(), KType9(), KType10(), KType11()}; |
|
789 TheTest.Printf(_L("Drive: %C:, Type: %16.16S, File System: %8.8S, Size: %d Mb.\r\n"), 'A' + drive, &KMediaTypeNames[driveInfo.iType], &vinfoex, (TInt)(vinfo.iSize / (1024 * 1024))); |
|
790 TheTest.Printf(_L(" Size: %ld bytes.\r\n"), vinfo.iSize); |
|
791 TheTest.Printf(_L(" Block size=%d, Cluster size=%d, Read buffer size=%d.\r\n"), vparam.iBlockSize, vparam.iClusterSize, vparam.iRecReadBufSize); |
|
792 if(driveInfo.iType == EMediaRam || driveInfo.iType == EMediaHardDisk || driveInfo.iType == EMediaFlash || driveInfo.iType == EMediaNANDFlash) |
|
793 { |
|
794 TDriveUnit drvUnit(drive); |
|
795 TDriveName drvName = drvUnit.Name(); |
|
796 TParse parse; |
|
797 parse.Set(KTestFile2, &drvName, NULL); |
|
798 TheDbName.Copy(parse.FullName()); |
|
799 TRAP(err, BaflUtils::EnsurePathExistsL(TheFs, TheDbName)); |
|
800 TEST(err == KErrNone || err == KErrAlreadyExists); |
|
801 (void)TheFs.Delete(TheDbName); |
|
802 RFileBuf64 fbuf64(8 * 1024); |
|
803 err = fbuf64.Create(TheFs, TheDbName, EFileRead | EFileWrite); |
|
804 TEST2(err, KErrNone); |
|
805 TInt readAhead = fbuf64.SetReadAheadSize(vparam.iBlockSize, vparam.iRecReadBufSize); |
|
806 TheTest.Printf(_L(" Read-ahead size=%d.\r\n"), readAhead); |
|
807 fbuf64.Close(); |
|
808 (void)TheFs.Delete(TheDbName); |
|
809 } |
|
810 } |
|
811 else |
|
812 { |
|
813 TheTest.Printf(_L("Drive %C. RFs::Volume() has failed with err=%d.\r\n"), 'A' + drive, err); |
|
814 } |
|
815 } |
|
816 else |
|
817 { |
|
818 TheTest.Printf(_L("Drive %C. RFs::Drive() has failed with err=%d.\r\n"), 'A' + drive, err); |
|
819 } |
|
820 } |
|
821 TheTest.Printf(_L("==================\r\n")); |
|
822 // |
|
823 RFileBuf64 fbuf64(8 * 1024);//buffer capacity = 8Kb |
|
824 |
|
825 //"ReadRecBufSize" defined and is power of two, the "BlockSize" is also defined and is power of two |
|
826 TInt err2 = fbuf64.Create(TheFs, TheDbName, EFileRead | EFileWrite); |
|
827 TEST2(err2, KErrNone); |
|
828 TInt blockSize = 4096; TInt readRecBufSize = 2048; |
|
829 TInt readAhead2 = fbuf64.SetReadAheadSize(blockSize, readRecBufSize); |
|
830 TEST2(readAhead2, readRecBufSize); |
|
831 fbuf64.Close(); |
|
832 |
|
833 //"ReadRecBufSize" defined and is power of two but is less than the default read-ahead value |
|
834 err2 = fbuf64.Open(TheFs, TheDbName, EFileRead | EFileWrite); |
|
835 TEST2(err2, KErrNone); |
|
836 blockSize = 0; readRecBufSize = 128; |
|
837 readAhead2 = fbuf64.SetReadAheadSize(blockSize, readRecBufSize); |
|
838 TEST2(readAhead2, RFileBuf64::KDefaultReadAheadSize); |
|
839 fbuf64.Close(); |
|
840 |
|
841 //"ReadRecBufSize" defined and is power of two but is bigger than the buffer capacity |
|
842 err2 = fbuf64.Open(TheFs, TheDbName, EFileRead | EFileWrite); |
|
843 TEST2(err2, KErrNone); |
|
844 blockSize = -10; readRecBufSize = fbuf64.iCapacity * 2; |
|
845 readAhead2 = fbuf64.SetReadAheadSize(blockSize, readRecBufSize); |
|
846 TEST2(readAhead2, fbuf64.iCapacity); |
|
847 fbuf64.Close(); |
|
848 |
|
849 //"ReadRecBufSize" defined but is not power of two, "BlockSize" defined but is less than the default read-ahead value |
|
850 err2 = fbuf64.Open(TheFs, TheDbName, EFileRead | EFileWrite); |
|
851 TEST2(err2, KErrNone); |
|
852 blockSize = 512; readRecBufSize = 4000; |
|
853 readAhead2 = fbuf64.SetReadAheadSize(blockSize, readRecBufSize); |
|
854 TEST2(readAhead2, RFileBuf64::KDefaultReadAheadSize); |
|
855 fbuf64.Close(); |
|
856 |
|
857 //"ReadRecBufSize" defined but is not power of two, "BlockSize" defined and is bigger than the default read-ahead value |
|
858 err2 = fbuf64.Open(TheFs, TheDbName, EFileRead | EFileWrite); |
|
859 TEST2(err2, KErrNone); |
|
860 blockSize = 4096; readRecBufSize = 4000; |
|
861 readAhead2 = fbuf64.SetReadAheadSize(blockSize, readRecBufSize); |
|
862 TEST2(readAhead2, blockSize); |
|
863 fbuf64.Close(); |
|
864 |
|
865 //"ReadRecBufSize" defined but is not power of two, "BlockSize" defined and is bigger than the buffer capacity |
|
866 err2 = fbuf64.Open(TheFs, TheDbName, EFileRead | EFileWrite); |
|
867 TEST2(err2, KErrNone); |
|
868 blockSize = fbuf64.iCapacity * 2; readRecBufSize = 1; |
|
869 readAhead2 = fbuf64.SetReadAheadSize(blockSize, readRecBufSize); |
|
870 TEST2(readAhead2, fbuf64.iCapacity); |
|
871 fbuf64.Close(); |
|
872 |
|
873 //"ReadRecBufSize" negative, "BlockSize" defined but is not power of two |
|
874 err2 = fbuf64.Open(TheFs, TheDbName, EFileRead | EFileWrite); |
|
875 TEST2(err2, KErrNone); |
|
876 blockSize = 1000; readRecBufSize = -2; |
|
877 readAhead2 = fbuf64.SetReadAheadSize(blockSize, readRecBufSize); |
|
878 TEST2(readAhead2, RFileBuf64::KDefaultReadAheadSize); |
|
879 fbuf64.Close(); |
|
880 |
|
881 //"ReadRecBufSize" negative, "BlockSize" negative |
|
882 err2 = fbuf64.Open(TheFs, TheDbName, EFileRead | EFileWrite); |
|
883 TEST2(err2, KErrNone); |
|
884 blockSize = -1; readRecBufSize = -2; |
|
885 readAhead2 = fbuf64.SetReadAheadSize(blockSize, readRecBufSize); |
|
886 TEST2(readAhead2, RFileBuf64::KDefaultReadAheadSize); |
|
887 fbuf64.Close(); |
|
888 // |
|
889 (void)TheFs.Delete(TheDbName); |
|
890 } |
|
891 |
|
892 /** |
|
893 @SYMTestCaseID PDS-SQL-UT-4142 |
|
894 @SYMTestCaseDesc RFileBuf64 OOM test. |
|
895 The test calls RFileBuf64:Create(), RFileBuf64:Open() and RFileBuf64:Temp() in an OOM |
|
896 simulation loop and verifies that no memory is leaked. |
|
897 @SYMTestActions RFileBuf64 OOM test. |
|
898 @SYMTestExpectedResults Test must not fail |
|
899 @SYMTestPriority High |
|
900 @SYMREQ REQ12106 |
|
901 REQ12109 |
|
902 */ |
|
903 void OomTest(TOomTestType aOomTestType) |
|
904 { |
|
905 (void)TheFs.Delete(KTestFile); |
|
906 |
|
907 if(aOomTestType == EOomOpenTest) |
|
908 { |
|
909 RFile64 file; |
|
910 TInt err2 = file.Create(TheFs, KTestFile, EFileWrite | EFileRead); |
|
911 file.Close(); |
|
912 TEST2(err2, KErrNone); |
|
913 } |
|
914 |
|
915 TFileName tmpFileName; |
|
916 TInt err = KErrNoMemory; |
|
917 TInt failingAllocationNo = 0; |
|
918 RFileBuf64 fbuf(1024); |
|
919 TheTest.Printf(_L("Iteration:\r\n")); |
|
920 while(err == KErrNoMemory) |
|
921 { |
|
922 TheTest.Printf(_L(" %d"), ++failingAllocationNo); |
|
923 |
|
924 MarkHandles(); |
|
925 MarkAllocatedCells(); |
|
926 |
|
927 __UHEAP_MARK; |
|
928 __UHEAP_SETBURSTFAIL(RAllocator::EBurstFailNext, failingAllocationNo, KBurstRate); |
|
929 |
|
930 switch(aOomTestType) |
|
931 { |
|
932 case EOomCreateTest: |
|
933 err = fbuf.Create(TheFs, KTestFile, EFileWrite | EFileRead); |
|
934 break; |
|
935 case EOomOpenTest: |
|
936 err = fbuf.Open(TheFs, KTestFile, EFileWrite | EFileRead); |
|
937 break; |
|
938 case EOomTempTest: |
|
939 { |
|
940 err = fbuf.Temp(TheFs, KTestDir, tmpFileName, EFileWrite | EFileRead); |
|
941 } |
|
942 break; |
|
943 default: |
|
944 TEST(0); |
|
945 break; |
|
946 } |
|
947 fbuf.Close(); |
|
948 |
|
949 __UHEAP_RESET; |
|
950 __UHEAP_MARKEND; |
|
951 |
|
952 CheckAllocatedCells(); |
|
953 CheckHandles(); |
|
954 |
|
955 TEntry entry; |
|
956 if(err != KErrNoMemory) |
|
957 { |
|
958 TEST2(err, KErrNone); |
|
959 } |
|
960 else if(aOomTestType == EOomCreateTest) |
|
961 { |
|
962 TInt err2 = TheFs.Entry(KTestFile, entry); |
|
963 TEST2(err2, KErrNotFound); |
|
964 } |
|
965 else if(aOomTestType == EOomTempTest) |
|
966 { |
|
967 if(tmpFileName.Size() > 0) |
|
968 { |
|
969 TInt err2 = TheFs.Entry(tmpFileName, entry); |
|
970 TEST2(err2, KErrNotFound); |
|
971 } |
|
972 } |
|
973 } |
|
974 TEST2(err, KErrNone); |
|
975 TheTest.Printf(_L("\r\n=== OOM Test succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo); |
|
976 |
|
977 if(aOomTestType == EOomTempTest) |
|
978 { |
|
979 (void)TheFs.Delete(tmpFileName); |
|
980 } |
|
981 (void)TheFs.Delete(KTestFile); |
|
982 } |
|
983 |
|
984 void DoTests() |
|
985 { |
|
986 TheTest.Start(_L(" @SYMTestCaseID:PDS-SQL-UT-4132 RFileBuf64 write test 1")); |
|
987 WriteTest1(); |
|
988 TheTest.Next( _L(" @SYMTestCaseID:PDS-SQL-UT-4133 RFileBuf64 write test 2")); |
|
989 WriteTest2(); |
|
990 TheTest.Next( _L(" @SYMTestCaseID:PDS-SQL-UT-4134 RFileBuf64 write test 3")); |
|
991 WriteTest3(); |
|
992 TheTest.Next( _L(" @SYMTestCaseID:PDS-SQL-UT-4135 RFileBuf64 write test 4")); |
|
993 WriteTest4(); |
|
994 TheTest.Next( _L(" @SYMTestCaseID:PDS-SQL-UT-4136 RFileBuf64 write test 5")); |
|
995 WriteTest5(); |
|
996 TheTest.Next( _L(" @SYMTestCaseID:PDS-SQL-UT-4137 RFileBuf64 write test 6")); |
|
997 WriteTest6(); |
|
998 TheTest.Next( _L("RFileBuf64 read test - preparation")); |
|
999 PrepareReadTest(); |
|
1000 TheTest.Next( _L(" @SYMTestCaseID:PDS-SQL-UT-4138 RFileBuf64 read test 1")); |
|
1001 ReadTest1(); |
|
1002 TheTest.Next( _L(" @SYMTestCaseID:PDS-SQL-UT-4139 RFileBuf64 read test 2")); |
|
1003 ReadTest2(); |
|
1004 TheTest.Next( _L(" @SYMTestCaseID:PDS-SQL-UT-4140 RFileBuf64 read test 3")); |
|
1005 ReadTest3(); |
|
1006 |
|
1007 TheTest.Next( _L(" @SYMTestCaseID:PDS-SQL-UT-4141 RFileBuf64::SetReadAheadSize() test")); |
|
1008 SetReadAheadSizeTest(); |
|
1009 |
|
1010 (void)TheFs.Delete(KTestFile); |
|
1011 |
|
1012 TheTest.Next( _L(" @SYMTestCaseID:PDS-SQL-UT-4142 RFileBuf64::Create() OOM test")); |
|
1013 OomTest(EOomCreateTest); |
|
1014 TheTest.Next( _L(" @SYMTestCaseID:PDS-SQL-UT-4142 RFileBuf64::Open() OOM test")); |
|
1015 OomTest(EOomOpenTest); |
|
1016 TheTest.Next( _L(" @SYMTestCaseID:PDS-SQL-UT-4142 RFileBuf64::Temp() OOM test")); |
|
1017 OomTest(EOomTempTest); |
|
1018 } |
|
1019 |
|
1020 TInt E32Main() |
|
1021 { |
|
1022 TheTest.Title(); |
|
1023 |
|
1024 CTrapCleanup* tc = CTrapCleanup::New(); |
|
1025 TheTest(tc != NULL); |
|
1026 |
|
1027 __UHEAP_MARK; |
|
1028 |
|
1029 TestEnvInit(); |
|
1030 DeleteTestFiles(); |
|
1031 DoTests(); |
|
1032 TestEnvDestroy(); |
|
1033 |
|
1034 __UHEAP_MARKEND; |
|
1035 |
|
1036 TheTest.End(); |
|
1037 TheTest.Close(); |
|
1038 |
|
1039 delete tc; |
|
1040 |
|
1041 User::Heap().Check(); |
|
1042 return KErrNone; |
|
1043 } |
|
1044 |
|
1045 #else//_SQLPROFILER |
|
1046 |
|
1047 TInt E32Main() |
|
1048 { |
|
1049 TheTest.Title(); |
|
1050 |
|
1051 TheTest.Start(_L("This test works only if the test is built with _SQLPROFILER macro defined!")); |
|
1052 TheTest.End(); |
|
1053 TheTest.Close(); |
|
1054 |
|
1055 return KErrNone; |
|
1056 } |
|
1057 |
|
1058 #endif//_SQLPROFILER |