|
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 #include <e32math.h> |
|
17 #include <bautils.h> |
|
18 #include <sqldb.h> |
|
19 #include <f32file64.h> |
|
20 #include <hal.h> |
|
21 |
|
22 /////////////////////////////////////////////////////////////////////////////////////// |
|
23 |
|
24 RTest TheTest(_L("t_sqldb64 test")); |
|
25 RFs TheFs; |
|
26 RSqlDatabase TheDb; |
|
27 RSqlStatement TheStmt; |
|
28 |
|
29 _LIT(KTestDbName1, "\\test\\t_sqldb64_1.db"); |
|
30 |
|
31 const TInt64 K1Mb = 1024LL * 1024LL; |
|
32 const TInt64 K1Gb = 1024LL * K1Mb; |
|
33 const TInt64 K4Gb = 4LL * K1Gb; |
|
34 |
|
35 TInt64 TheLastInsertedRowid = -1LL; |
|
36 |
|
37 struct TTestDriveInfo |
|
38 { |
|
39 TInt iSizeMb; |
|
40 TBool iWritable; |
|
41 }; |
|
42 |
|
43 TTestDriveInfo TheDriveInfo[KMaxDrives]; |
|
44 TInt TheBiggestDriveNo = -1; |
|
45 TFileName TheDbName; |
|
46 |
|
47 /////////////////////////////////////////////////////////////////////////////////////// |
|
48 |
|
49 void DeleteTestFiles() |
|
50 { |
|
51 TheStmt.Close(); |
|
52 TheDb.Close(); |
|
53 (void)RSqlDatabase::Delete(TheDbName); |
|
54 } |
|
55 |
|
56 /////////////////////////////////////////////////////////////////////////////////////// |
|
57 /////////////////////////////////////////////////////////////////////////////////////// |
|
58 //Test macros and functions |
|
59 void Check(TInt aValue, TInt aLine) |
|
60 { |
|
61 if(!aValue) |
|
62 { |
|
63 DeleteTestFiles(); |
|
64 TheTest(EFalse, aLine); |
|
65 } |
|
66 } |
|
67 void Check(TInt aValue, TInt aExpected, TInt aLine) |
|
68 { |
|
69 if(aValue != aExpected) |
|
70 { |
|
71 DeleteTestFiles(); |
|
72 RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue); |
|
73 TheTest(EFalse, aLine); |
|
74 } |
|
75 } |
|
76 #define TEST(arg) ::Check((arg), __LINE__) |
|
77 #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__) |
|
78 |
|
79 /////////////////////////////////////////////////////////////////////////////////////// |
|
80 |
|
81 void CreateTestEnv() |
|
82 { |
|
83 TInt err = TheFs.Connect(); |
|
84 TEST2(err, KErrNone); |
|
85 } |
|
86 |
|
87 void SqlTimerPrint(const TDesC& aText, TUint32 aStartTicks, TUint32 aEndTicks) |
|
88 { |
|
89 static TInt freq = 0; |
|
90 if(freq == 0) |
|
91 { |
|
92 TEST2(HAL::Get(HAL::EFastCounterFrequency, freq), KErrNone); |
|
93 } |
|
94 TInt64 diffTicks = (TInt64)aEndTicks - (TInt64)aStartTicks; |
|
95 if(diffTicks < 0) |
|
96 { |
|
97 diffTicks = KMaxTUint32 + diffTicks + 1; |
|
98 } |
|
99 const TInt KMicroSecIn1Sec = 1000000; |
|
100 TInt32 us = (diffTicks * KMicroSecIn1Sec) / freq; |
|
101 TheTest.Printf(_L("#### %S. Execution time: %d us\r\n"), &aText, us); |
|
102 } |
|
103 |
|
104 TUint32 SqlTimerTicks() |
|
105 { |
|
106 return User::FastCounter(); |
|
107 } |
|
108 |
|
109 /////////////////////////////////////////////////////////////////////////////////////// |
|
110 |
|
111 /** |
|
112 @SYMTestCaseID PDS-SQL-CT-4129 |
|
113 @SYMTestCaseDesc Creation of a database bigger than 4Gb (KMaxTUint). |
|
114 The test creates a test database with a table and inserts records into the table |
|
115 until the database size gets bigger than 4Gb (KMaxTUint). The purpose of the test is to verify |
|
116 that it is possible to create and manipulate 64-bit databases. |
|
117 @SYMTestActions Creation of a database bigger than 4Gb (KMaxTUint). |
|
118 @SYMTestExpectedResults Test must not fail |
|
119 @SYMTestPriority Medium |
|
120 @SYMREQ REQ12104 |
|
121 REQ12105 |
|
122 */ |
|
123 void CreateBigDbTest(const TDesC& aDbName, TInt64 aDbSize) |
|
124 { |
|
125 __ASSERT_ALWAYS(aDbSize > 0LL, User::Invariant()); |
|
126 (void)RSqlDatabase::Delete(aDbName); |
|
127 _LIT8(KConfig, "encoding=\"UTF-8\""); |
|
128 TInt err = TheDb.Create(aDbName, &KConfig); |
|
129 TEST2(err, KErrNone); |
|
130 // |
|
131 err = TheDb.Exec(_L8("CREATE TABLE A(Id INTEGER PRIMARY KEY AUTOINCREMENT, Data BLOB)")); |
|
132 TEST2(err, 1); |
|
133 TInt64 fsize = 0; |
|
134 TheTest.Printf(_L("==File size:")); |
|
135 while(fsize < aDbSize) |
|
136 { |
|
137 const TInt KRecCnt = 1000; |
|
138 //Insert KRecCnt records in a transaction |
|
139 err = TheDb.Exec(_L8("BEGIN")); |
|
140 if(err < 0) |
|
141 { |
|
142 TheTest.Printf(_L("==='BEGIN' has failed with err %d\r\n"), err); |
|
143 } |
|
144 TEST(err >= 0); |
|
145 err = TheStmt.Prepare(TheDb, _L8("INSERT INTO A(Data) VALUES(zeroblob(32768))"));//32Kb big blob |
|
146 TEST2(err, KErrNone); |
|
147 for(TInt i=0;i<KRecCnt;++i) |
|
148 { |
|
149 err = TheStmt.Exec(); |
|
150 TEST2(err, 1); |
|
151 err = TheStmt.Reset(); |
|
152 TEST2(err, KErrNone); |
|
153 } |
|
154 TheStmt.Close(); |
|
155 err = TheDb.Exec(_L8("COMMIT")); |
|
156 if(err < 0) |
|
157 { |
|
158 TheTest.Printf(_L("==='COMMIT' has failed with err %d\r\n"), err); |
|
159 } |
|
160 TEST(err >= 0); |
|
161 TheLastInsertedRowid = TheDb.LastInsertedRowId(); |
|
162 TEST(TheLastInsertedRowid > 0LL); |
|
163 //Check and print the file size |
|
164 TheDb.Close(); |
|
165 RFile64 file; |
|
166 err = file.Open(TheFs, aDbName, EFileRead | EFileWrite); |
|
167 TEST2(err, KErrNone); |
|
168 err = file.Size(fsize); |
|
169 TEST2(err, KErrNone); |
|
170 file.Close(); |
|
171 TheTest.Printf(_L(" %ldMb"), fsize / K1Mb); |
|
172 err = TheDb.Open(aDbName); |
|
173 TEST2(err, KErrNone); |
|
174 } |
|
175 TheTest.Printf(_L("\r\n")); |
|
176 // |
|
177 TheDb.Close(); |
|
178 } |
|
179 |
|
180 /** |
|
181 @SYMTestCaseID PDS-SQL-CT-4130 |
|
182 @SYMTestCaseDesc SQL operations on a 64-bit database. |
|
183 The test uses the database created in test case PDS-SQL-UT-4129. |
|
184 Simple INSERT, UPDATE, DELETE and SELECT statements are executed on the database. |
|
185 The data in the test SQL statements is such that the manipulated records are beyond the 4Gb |
|
186 file offset. Some other of the test SQL statements will perform sequential scan of the whole |
|
187 database from offset 0 to the end of the database file. |
|
188 The purpose of the test is to verify that there are no problem if the database offset is 64-bit. |
|
189 @SYMTestActions SQL operations on a 64-bit database. |
|
190 @SYMTestExpectedResults Test must not fail |
|
191 @SYMTestPriority Medium |
|
192 @SYMREQ REQ12104 |
|
193 REQ12105 |
|
194 */ |
|
195 void SimpleDbOperationsTestL(const TDesC& aDbName) |
|
196 { |
|
197 __ASSERT_ALWAYS(TheLastInsertedRowid > 0LL, User::Invariant()); |
|
198 TInt err = TheDb.Open(aDbName); |
|
199 TEST2(err, KErrNone); |
|
200 //SELECT-1 |
|
201 TUint32 start = SqlTimerTicks(); |
|
202 err = TheStmt.Prepare(TheDb, _L8("SELECT Id FROM A WHERE ROWID = :Prm")); |
|
203 TEST2(err, KErrNone); |
|
204 err = TheStmt.BindInt64(0, TheLastInsertedRowid - 1LL); |
|
205 TEST2(err, KErrNone); |
|
206 err = TheStmt.Next(); |
|
207 TEST2(err, KSqlAtRow); |
|
208 TInt64 id = TheStmt.ColumnInt64(0); |
|
209 TheTest.Printf(_L("==Id=%ld\r\n"), id); |
|
210 TheStmt.Close(); |
|
211 TUint32 end = SqlTimerTicks(); |
|
212 SqlTimerPrint(_L("SELECT-1"), start, end); |
|
213 //INSERT |
|
214 start = SqlTimerTicks(); |
|
215 err = TheDb.Exec(_L("INSERT INTO A(Data) VALUES('123456')")); |
|
216 TEST2(err, 1); |
|
217 end = SqlTimerTicks(); |
|
218 SqlTimerPrint(_L("INSERT"), start, end); |
|
219 //UPDATE |
|
220 start = SqlTimerTicks(); |
|
221 TBuf<100> sql; |
|
222 sql.Format(_L("UPDATE A SET Data='56789' WHERE Id=%ld"), id); |
|
223 err = TheDb.Exec(sql); |
|
224 TEST2(err, 1); |
|
225 end = SqlTimerTicks(); |
|
226 SqlTimerPrint(_L("UPDATE"), start, end); |
|
227 //SELECT-2 |
|
228 start = SqlTimerTicks(); |
|
229 TSqlScalarFullSelectQuery scalarQuery(TheDb); |
|
230 sql.Format(_L("SELECT Data FROM A WHERE ID = %ld"), id); |
|
231 TBuf<32> buf; |
|
232 err = scalarQuery.SelectTextL(sql, buf); |
|
233 TEST2(err, KErrNone); |
|
234 err = buf.Compare(_L("56789")); |
|
235 TEST2(err, 0); |
|
236 end = SqlTimerTicks(); |
|
237 SqlTimerPrint(_L("SELECT-2"), start, end); |
|
238 //SELECT-3 |
|
239 start = SqlTimerTicks(); |
|
240 sql.Format(_L("SELECT COUNT(*) FROM A")); |
|
241 TInt recCnt = scalarQuery.SelectIntL(sql); |
|
242 TheTest.Printf(_L("==Records count: %d\r\n"), recCnt); |
|
243 end = SqlTimerTicks(); |
|
244 SqlTimerPrint(_L("SELECT-3"), start, end); |
|
245 TEST(recCnt > 0); |
|
246 //SELECT-4 |
|
247 start = SqlTimerTicks(); |
|
248 sql.Format(_L("SELECT MAX(ROWID) FROM A")); |
|
249 TInt rowid = scalarQuery.SelectIntL(sql); |
|
250 TheTest.Printf(_L("==MAX(ROWID): %d\r\n"), rowid); |
|
251 end = SqlTimerTicks(); |
|
252 SqlTimerPrint(_L("SELECT-4"), start, end); |
|
253 TEST(rowid > 0); |
|
254 //DELETE |
|
255 start = SqlTimerTicks(); |
|
256 sql.Format(_L("DELETE FROM A WHERE ID = %ld"), id); |
|
257 err = TheDb.Exec(sql); |
|
258 TEST2(err, 1); |
|
259 end = SqlTimerTicks(); |
|
260 SqlTimerPrint(_L("DELETE"), start, end); |
|
261 // |
|
262 TheDb.Close(); |
|
263 } |
|
264 |
|
265 /** |
|
266 @SYMTestCaseID PDS-SQL-CT-4145 |
|
267 @SYMTestCaseDesc RSqlDatabase::Size() on a 64-bit database. |
|
268 The test uses the database created in test case PDS-SQL-UT-4129, opens the database |
|
269 and calls the Size() methods. The first Size() call should fail with KErrTooBig error, |
|
270 because the database size is over 2Gb and cannot fit in the 32-bit integer result of the call. |
|
271 The second call of the overloaded Size() method should correctly report the database size. |
|
272 @SYMTestActions RSqlDatabase::Size() on a 64-bit database. |
|
273 @SYMTestExpectedResults Test must not fail |
|
274 @SYMTestPriority Medium |
|
275 @SYMREQ REQ12105 |
|
276 */ |
|
277 void SizeTest(const TDesC& aDbName) |
|
278 { |
|
279 __ASSERT_ALWAYS(TheLastInsertedRowid > 0LL, User::Invariant()); |
|
280 TInt err = TheDb.Open(aDbName); |
|
281 TEST2(err, KErrNone); |
|
282 //Size-1 |
|
283 TInt size = TheDb.Size(); |
|
284 TEST2(size, KErrTooBig); |
|
285 //Size-2 |
|
286 RSqlDatabase::TSize size2; |
|
287 err = TheDb.Size(size2); |
|
288 TEST2(err, KErrNone); |
|
289 TEST(size2.iSize > K4Gb); |
|
290 // |
|
291 TheDb.Close(); |
|
292 } |
|
293 |
|
294 /** |
|
295 @SYMTestCaseID PDS-SQL-CT-4146 |
|
296 @SYMTestCaseDesc Background compaction on a 64-bit database. |
|
297 The test uses the database created in test case PDS-SQL-UT-4129 and opens the database. |
|
298 Iteration 1: |
|
299 The test executes a DELETE sql statement that deletes couple of records. The freed disk space |
|
300 is big enough to kick-off the background compaction. The test waits couple of seconds and then |
|
301 checks the database size and free space to verify that the background compaction really compacted |
|
302 the database. |
|
303 Iteration 2: |
|
304 Iteration 2 is the same as iteration 1, but the freed database space is such that the following |
|
305 background compaction will shrink the database size to be less than 4Gb. |
|
306 After iteration 2 the test performs an INSERT transaction and increases the database size to be |
|
307 bigger than 4Gb. |
|
308 @SYMTestActions Background compaction on a 64-bit database. |
|
309 @SYMTestExpectedResults Test must not fail |
|
310 @SYMTestPriority Medium |
|
311 @SYMREQ REQ12105 |
|
312 */ |
|
313 void BackgroundCompactionTest(const TDesC& aDbName) |
|
314 { |
|
315 __ASSERT_ALWAYS(TheLastInsertedRowid > 0LL, User::Invariant()); |
|
316 TInt err = TheDb.Open(aDbName); |
|
317 TEST2(err, KErrNone); |
|
318 const TInt64 KDelRecCnt[2] = {10LL, 2400LL}; |
|
319 for(TInt i=0;i<2;++i) |
|
320 { |
|
321 TheTest.Printf(_L("=========== Iteration %d ===========\r\n"), i + 1); |
|
322 //Size-1 |
|
323 RSqlDatabase::TSize size; |
|
324 err = TheDb.Size(size); |
|
325 TEST2(err, KErrNone); |
|
326 TEST(size.iSize > K4Gb); |
|
327 TheTest.Printf(_L(" ==Before DELETE, database size=%ldKb\r\n"), size.iSize / 1024LL); |
|
328 //Delete records |
|
329 TBuf<100> sql; |
|
330 sql.Format(_L("DELETE FROM A WHERE ROWID > %ld AND ROWID < %ld"), TheLastInsertedRowid - KDelRecCnt[i], TheLastInsertedRowid); |
|
331 err = TheDb.Exec(sql); |
|
332 TEST(err > 0); |
|
333 //Size-2 |
|
334 err = TheDb.Size(size); |
|
335 TEST2(err, KErrNone); |
|
336 TEST(size.iSize > K4Gb); |
|
337 TEST(size.iFree > (50 * 1024)); |
|
338 TheTest.Printf(_L(" ==After DELETE, database size=%ldKb, free space=%ldKb\r\n"), size.iSize / 1024LL, size.iFree / 1024LL); |
|
339 //Wait some time (to allow the background compaction to run) |
|
340 const TInt KOneSecond = 1000000; |
|
341 const TInt KMaxWaitTime = 300 * KOneSecond;//300 sec == 5 min |
|
342 TInt waitTime = 0; |
|
343 while(waitTime < KMaxWaitTime) |
|
344 { |
|
345 const TInt KWaitStep = 5 * KOneSecond; |
|
346 User::After(KWaitStep); |
|
347 //Check the size |
|
348 err = TheDb.Size(size); |
|
349 TEST2(err, KErrNone); |
|
350 if(size.iFree == 0) |
|
351 { |
|
352 break; |
|
353 } |
|
354 waitTime += KWaitStep; |
|
355 TheTest.Printf(_L(" ==After %3d sec, database size=%ldKb, free space=%ldKb\r\n"), waitTime / KOneSecond, size.iSize / 1024LL, size.iFree / 1024LL); |
|
356 } |
|
357 if(i == 0) |
|
358 { |
|
359 TEST(size.iSize > K4Gb); |
|
360 } |
|
361 else |
|
362 { |
|
363 TEST(size.iSize < K4Gb); |
|
364 } |
|
365 TEST2(size.iFree, 0); |
|
366 //Records count |
|
367 sql.Format(_L("SELECT COUNT(*) FROM A")); |
|
368 TSqlScalarFullSelectQuery q(TheDb); |
|
369 TInt recCnt = -1; |
|
370 TRAP(err, recCnt = q.SelectIntL(sql)); |
|
371 TEST2(err, KErrNone); |
|
372 TheTest.Printf(_L(" ==Records count: %d\r\n"), recCnt); |
|
373 TEST(recCnt > 0); |
|
374 } |
|
375 TheTest.Printf(_L("==Increase the database size above 4Gb\r\n")); |
|
376 //Insert KRecCnt records in a transaction |
|
377 const TInt KRecCnt = 2500; |
|
378 err = TheDb.Exec(_L8("BEGIN")); |
|
379 TEST(err >= 0); |
|
380 err = TheStmt.Prepare(TheDb, _L8("INSERT INTO A(Data) VALUES(zeroblob(32768))"));//32Kb big blob |
|
381 TEST2(err, KErrNone); |
|
382 for(TInt i=0;i<KRecCnt;++i) |
|
383 { |
|
384 err = TheStmt.Exec(); |
|
385 TEST2(err, 1); |
|
386 err = TheStmt.Reset(); |
|
387 TEST2(err, KErrNone); |
|
388 } |
|
389 TheStmt.Close(); |
|
390 err = TheDb.Exec(_L8("COMMIT")); |
|
391 TEST(err >= 0); |
|
392 //Size |
|
393 RSqlDatabase::TSize size2; |
|
394 err = TheDb.Size(size2); |
|
395 TEST2(err, KErrNone); |
|
396 TEST(size2.iSize > K4Gb); |
|
397 TheTest.Printf(_L(" ==Database size=%ldKb\r\n"), size2.iSize / 1024LL); |
|
398 // |
|
399 TheDb.Close(); |
|
400 } |
|
401 |
|
402 /** |
|
403 @SYMTestCaseID PDS-SQL-CT-4131 |
|
404 @SYMTestCaseDesc Deleting database bigger than 4Gb (KMaxTUint). |
|
405 The test deletes the database created in test case PDS-SQL-UT-4129. |
|
406 @SYMTestActions Deleting database bigger than 4Gb (KMaxTUint). |
|
407 @SYMTestExpectedResults Test must not fail |
|
408 @SYMTestPriority Medium |
|
409 @SYMREQ REQ12104 |
|
410 REQ12105 |
|
411 */ |
|
412 void DeleteBigDbTest() |
|
413 { |
|
414 TInt err = RSqlDatabase::Delete(TheDbName); |
|
415 TEST2(err, KErrNone); |
|
416 } |
|
417 |
|
418 void CollectDriveInfo() |
|
419 { |
|
420 TheTest.Printf(_L("==================\r\n")); |
|
421 _LIT(KType1, "Not present"); |
|
422 _LIT(KType2, "Unknown"); |
|
423 _LIT(KType3, "Floppy"); |
|
424 _LIT(KType4, "Hard disk"); |
|
425 _LIT(KType5, "CD ROM"); |
|
426 _LIT(KType6, "RAM disk"); |
|
427 _LIT(KType7, "Flash"); |
|
428 _LIT(KType8, "ROM drive"); |
|
429 _LIT(KType9, "Remote drive"); |
|
430 _LIT(KType10,"NAND flash"); |
|
431 _LIT(KType11,"Rotating media"); |
|
432 |
|
433 Mem::FillZ(TheDriveInfo, sizeof(TheDriveInfo)); |
|
434 TheBiggestDriveNo = 0; |
|
435 |
|
436 for(TInt drive=EDriveA;drive<=EDriveZ;++drive) |
|
437 { |
|
438 TDriveInfo driveInfo; |
|
439 TInt err = TheFs.Drive(driveInfo, drive); |
|
440 if(err == KErrNone) |
|
441 { |
|
442 TVolumeInfo vinfo; |
|
443 err = TheFs.Volume(vinfo, drive); |
|
444 if(err == KErrNone) |
|
445 { |
|
446 TVolumeIOParamInfo vparam; |
|
447 err = TheFs.VolumeIOParam(drive, vparam); |
|
448 TEST2(err, KErrNone); |
|
449 TBuf8<128> vinfoex8; |
|
450 err = TheFs.QueryVolumeInfoExt(drive, EFileSystemSubType, vinfoex8); |
|
451 TEST2(err, KErrNone); |
|
452 TPtrC vinfoex((const TUint16*)(vinfoex8.Ptr() + 8), vinfoex8[0]); |
|
453 TPtrC KMediaTypeNames[] = {KType1(), KType2(), KType3(), KType4(), KType5(), KType6(), KType7(), KType8(), KType9(), KType10(), KType11()}; |
|
454 TInt sizeMb = vinfo.iSize / K1Mb; |
|
455 TheTest.Printf(_L("Drive: %C:, Type: %16.16S, File System: %8.8S, Size: %d Mb.\r\n"), 'A' + drive, &KMediaTypeNames[driveInfo.iType], &vinfoex, sizeMb); |
|
456 TheTest.Printf(_L(" Block size=%d, Cluster size=%d, Read buffer size=%d.\r\n"), vparam.iBlockSize, vparam.iClusterSize, vparam.iRecReadBufSize); |
|
457 TheDriveInfo[drive].iSizeMb = sizeMb; |
|
458 if(driveInfo.iType == EMediaRam || driveInfo.iType == EMediaHardDisk || driveInfo.iType == EMediaFlash || driveInfo.iType == EMediaNANDFlash) |
|
459 { |
|
460 TheDriveInfo[drive].iWritable = ETrue; |
|
461 if(sizeMb > TheDriveInfo[TheBiggestDriveNo].iSizeMb) |
|
462 { |
|
463 TheBiggestDriveNo = drive; |
|
464 } |
|
465 } |
|
466 } |
|
467 else |
|
468 { |
|
469 TheTest.Printf(_L("Drive %C. RFs::Volume() has failed with err=%d.\r\n"), 'A' + drive, err); |
|
470 } |
|
471 } |
|
472 else |
|
473 { |
|
474 TheTest.Printf(_L("Drive %C. RFs::Drive() has failed with err=%d.\r\n"), 'A' + drive, err); |
|
475 } |
|
476 } |
|
477 |
|
478 TheTest.Printf(_L("The biggest R/W drive is: %C, Size: %d Mb\r\n"), 'A' + TheBiggestDriveNo, TheDriveInfo[TheBiggestDriveNo].iSizeMb); |
|
479 TDriveUnit drvUnit(TheBiggestDriveNo); |
|
480 TDriveName drvName = drvUnit.Name(); |
|
481 TParse parse; |
|
482 parse.Set(KTestDbName1, &drvName, NULL); |
|
483 TheDbName.Copy(parse.FullName()); |
|
484 |
|
485 TRAPD(err, BaflUtils::EnsurePathExistsL(TheFs, TheDbName)); |
|
486 TEST(err == KErrNone || err == KErrAlreadyExists); |
|
487 |
|
488 TheTest.Printf(_L("==================\r\n")); |
|
489 } |
|
490 |
|
491 void DoTestsL() |
|
492 { |
|
493 TheTest.Start(_L("Collect drive information")); |
|
494 CollectDriveInfo(); |
|
495 |
|
496 TInt64 maxDrvSize = TheDriveInfo[TheBiggestDriveNo].iSizeMb * K1Mb; |
|
497 if(maxDrvSize <= K4Gb) |
|
498 { |
|
499 TheTest.Printf(_L("There is no drive bigger than 4Gb. The tests won't be executed.\r\n")); |
|
500 return; |
|
501 } |
|
502 |
|
503 TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-CT-4129 Create database, bigger than 4Gb")); |
|
504 CreateBigDbTest(TheDbName, K4Gb + 64 * K1Mb); |
|
505 |
|
506 TheTest.Next (_L(" @SYMTestCaseID:PDS-SQL-CT-4130 64-bit database - simple operations test")); |
|
507 SimpleDbOperationsTestL(TheDbName); |
|
508 |
|
509 TheTest.Next (_L(" @SYMTestCaseID:PDS-SQL-CT-4145 64-bit database - Size() test")); |
|
510 SizeTest(TheDbName); |
|
511 |
|
512 TheTest.Next (_L(" @SYMTestCaseID:PDS-SQL-CT-4146 64-bit database - background compaction test")); |
|
513 BackgroundCompactionTest(TheDbName); |
|
514 |
|
515 TheTest.Next (_L(" @SYMTestCaseID:PDS-SQL-CT-4131 Delete 64-bit database test")); |
|
516 DeleteBigDbTest(); |
|
517 } |
|
518 |
|
519 TInt E32Main() |
|
520 { |
|
521 TheTest.Title(); |
|
522 |
|
523 CTrapCleanup* tc = CTrapCleanup::New(); |
|
524 TheTest(tc != NULL); |
|
525 |
|
526 __UHEAP_MARK; |
|
527 |
|
528 CreateTestEnv(); |
|
529 DeleteTestFiles(); |
|
530 TRAPD(err, DoTestsL()); |
|
531 DeleteTestFiles(); |
|
532 TheFs.Close(); |
|
533 TEST2(err, KErrNone); |
|
534 |
|
535 __UHEAP_MARKEND; |
|
536 |
|
537 TheTest.End(); |
|
538 TheTest.Close(); |
|
539 |
|
540 delete tc; |
|
541 |
|
542 User::Heap().Check(); |
|
543 return KErrNone; |
|
544 } |