188 while(err == KErrNoMemory) |
188 while(err == KErrNoMemory) |
189 { |
189 { |
190 TheTest.Printf(_L(" %d"), ++failingAllocationNo); |
190 TheTest.Printf(_L(" %d"), ++failingAllocationNo); |
191 OomPreStep(failingAllocationNo); |
191 OomPreStep(failingAllocationNo); |
192 const TUid KDbUd = {0x98765432}; |
192 const TUid KDbUd = {0x98765432}; |
193 RArray<TParse> files; |
193 RArray<HBufC*> files; |
194 TRAP(err, server->GetBackUpListL(KDbUd, files)); |
194 TRAP(err, server->GetBackUpListL(KDbUd, EDriveC, files)); |
195 fileCnt = files.Count(); |
195 fileCnt = files.Count(); |
196 if(err == KErrNone) |
196 if(err == KErrNone) |
197 { |
197 { |
198 //No directories should be returned in the list of files for backup |
198 //No directories should be returned in the list of files for backup |
199 for(TInt i=0;i<fileCnt;++i) |
199 for(TInt i=0;i<fileCnt;++i) |
200 { |
200 { |
201 const TParse& parse = files[i]; |
201 TPtrC fname = files[i]->Des(); |
202 TPtrC fname = parse.FullName(); |
202 TInt rc = KPrivateSubDir().CompareF(fname); |
203 TInt rc = KPrivateSubDir().CompareF(parse.FullName()); |
|
204 TEST(rc != 0); |
203 TEST(rc != 0); |
205 } |
204 } |
|
205 } |
|
206 for(TInt j=0;j<files.Count();++j) |
|
207 { |
|
208 delete files[j]; |
206 } |
209 } |
207 files.Close(); |
210 files.Close(); |
208 OomPostStep(); |
211 OomPostStep(); |
209 } |
212 } |
210 |
213 |
277 while(err<KErrNone) |
280 while(err<KErrNone) |
278 { |
281 { |
279 TheTest.Printf(_L("%d "), cnt); |
282 TheTest.Printf(_L("%d "), cnt); |
280 (void)server->Fs().SetErrorCondition(fsError, cnt); |
283 (void)server->Fs().SetErrorCondition(fsError, cnt); |
281 const TUid KDbUd = {0x98765432}; |
284 const TUid KDbUd = {0x98765432}; |
282 RArray<TParse> files; |
285 RArray<HBufC*> files; |
283 TRAP(err, server->GetBackUpListL(KDbUd, files)); |
286 TRAP(err, server->GetBackUpListL(KDbUd, EDriveC, files)); |
284 fileCnt = files.Count(); |
287 fileCnt = files.Count(); |
285 if(err == KErrNone) |
288 if(err == KErrNone) |
286 { |
289 { |
287 //No directories should be returned in the list of files for backup |
290 //No directories should be returned in the list of files for backup |
288 for(TInt i=0;i<fileCnt;++i) |
291 for(TInt i=0;i<fileCnt;++i) |
289 { |
292 { |
290 const TParse& parse = files[i]; |
293 TPtrC fname = files[i]->Des(); |
291 TPtrC fname = parse.FullName(); |
294 TInt rc = KPrivateSubDir().CompareF(fname); |
292 TInt rc = KPrivateSubDir().CompareF(parse.FullName()); |
|
293 TEST(rc != 0); |
295 TEST(rc != 0); |
294 } |
296 } |
|
297 } |
|
298 for(TInt j=0;j<files.Count();++j) |
|
299 { |
|
300 delete files[j]; |
295 } |
301 } |
296 files.Close(); |
302 files.Close(); |
297 (void)server->Fs().SetErrorCondition(KErrNone); |
303 (void)server->Fs().SetErrorCondition(KErrNone); |
298 if(err != KErrNone) |
304 if(err != KErrNone) |
299 { |
305 { |
304 TheTest.Printf(_L("\r\n===File I/O error simulation test succeeded on iteration %d===\r\nFile count: %d\r\n"), cnt, fileCnt); |
310 TheTest.Printf(_L("\r\n===File I/O error simulation test succeeded on iteration %d===\r\nFile count: %d\r\n"), cnt, fileCnt); |
305 } |
311 } |
306 |
312 |
307 delete server; |
313 delete server; |
308 } |
314 } |
|
315 |
|
316 /** |
|
317 @SYMTestCaseID PDS-SQL-UT-4224 |
|
318 @SYMTestCaseDesc CSqlServer::GetBackUpListL() functional test |
|
319 @SYMTestPriority High |
|
320 @SYMTestActions Calls CSqlServer::GetBackUpListL() and tests the output, when the drive is read-only, |
|
321 when there is a sub-directory which name is matching the search pattern. |
|
322 @SYMTestExpectedResults Test must not fail |
|
323 */ |
|
324 void GetBackupListFunctionalTest() |
|
325 { |
|
326 CSqlServer* server = NULL; |
|
327 TRAPD(err, server = CreateSqlServerL()); |
|
328 TEST2(err, KErrNone); |
|
329 //Case 1: database with specified uid bellow do exist (on drive C). There will be one subdirectory matching the search pattern. |
|
330 const TDriveNumber KTestDrvNum1 = EDriveC; |
|
331 const TUid KDbUid = {0x98765432}; |
|
332 TDriveUnit testDrive(KTestDrvNum1); |
|
333 TDriveName testDriveName = testDrive.Name(); |
|
334 testDriveName.LowerCase(); |
|
335 //One test directory will be created, which name will be matching the search pattern. |
|
336 //The directory name should not be included in the list with the file names. |
|
337 TFileName testFileName; |
|
338 err = server->Fs().PrivatePath(testFileName); |
|
339 TEST2(err, KErrNone); |
|
340 testFileName.Append(KDbUid.Name()); |
|
341 _LIT(KTestPath, "t_startup\\"); |
|
342 testFileName.Append(KTestPath); |
|
343 testFileName.Append(_L("t_startup.db")); |
|
344 TParse parse; |
|
345 err = parse.Set(testFileName, &testDriveName, 0); |
|
346 TEST2(err, KErrNone); |
|
347 err = server->Fs().MkDirAll(parse.FullName()); |
|
348 TEST(err == KErrNone || err == KErrAlreadyExists); |
|
349 // |
|
350 RArray<HBufC*> files; |
|
351 TRAP(err, server->GetBackUpListL(KDbUid, KTestDrvNum1, files)); |
|
352 TEST2(err, KErrNone); |
|
353 TInt fileCnt = files.Count(); |
|
354 for(TInt i=0;i<fileCnt;++i) |
|
355 { |
|
356 TPtrC fname = files[i]->Des(); |
|
357 TheTest.Printf(_L("Db: %S\r\n"), &fname); |
|
358 TEST(fname.FindF(KTestPath) < 0); |
|
359 //The name should include the full path + the drive |
|
360 err = parse.Set(fname, 0, 0); |
|
361 TEST2(err, KErrNone); |
|
362 TEST(parse.DrivePresent()); |
|
363 TEST(parse.PathPresent()); |
|
364 TDriveName driveName(parse.Drive()); |
|
365 driveName.LowerCase(); |
|
366 delete files[i]; |
|
367 TEST(driveName == testDriveName); |
|
368 } |
|
369 files.Close(); |
|
370 //Case 2: drive Z:. No files should be returned. |
|
371 const TDriveNumber KTestDrvNum2 = EDriveZ; |
|
372 TRAP(err, server->GetBackUpListL(KDbUid, KTestDrvNum2, files)); |
|
373 TEST2(err, KErrNone); |
|
374 fileCnt = files.Count(); |
|
375 TEST2(fileCnt, 0); |
|
376 //Case 3: drive A:. The drive does not exist. No files should be returned. |
|
377 const TDriveNumber KTestDrvNum3 = EDriveA; |
|
378 TRAP(err, server->GetBackUpListL(KDbUid, KTestDrvNum3, files)); |
|
379 TheTest.Printf(_L("Drive %d, err=%d\r\n"), KTestDrvNum3, err); |
|
380 fileCnt = files.Count(); |
|
381 TEST2(fileCnt, 0); |
|
382 // |
|
383 delete server; |
|
384 } |
309 |
385 |
310 /** |
386 /** |
311 @SYMTestCaseID PDS-SQL-UT-4163 |
387 @SYMTestCaseID PDS-SQL-UT-4163 |
312 @SYMTestCaseDesc Test for DEF144196: SQL, server code coverage can be improved |
388 @SYMTestCaseDesc Test for DEF144196: SQL, server code coverage can be improved |
313 @SYMTestPriority High |
389 @SYMTestPriority High |
427 SqlServerStartupFileIoErrorTest(); |
503 SqlServerStartupFileIoErrorTest(); |
428 |
504 |
429 TheTest.Next (_L(" @SYMTestCaseID:PDS-SQL-UT-4162 CSqlServer::GetBackUpListL() file I/O error simulation test")); |
505 TheTest.Next (_L(" @SYMTestCaseID:PDS-SQL-UT-4162 CSqlServer::GetBackUpListL() file I/O error simulation test")); |
430 GetBackupListFileIoErrorTest(); |
506 GetBackupListFileIoErrorTest(); |
431 |
507 |
|
508 TheTest.Next (_L(" @SYMTestCaseID:PDS-SQL-UT-4224 CSqlServer::GetBackUpListL() functional test")); |
|
509 GetBackupListFunctionalTest(); |
|
510 |
432 TheTest.Next (_L(" @SYMTestCaseID:PDS-SQL-UT-4163 SQL server, UTF conversion test")); |
511 TheTest.Next (_L(" @SYMTestCaseID:PDS-SQL-UT-4163 SQL server, UTF conversion test")); |
433 UtfConversionTest(); |
512 UtfConversionTest(); |
434 |
513 |
435 TheTest.Next (_L(" @SYMTestCaseID:PDS-SQL-UT-4175 Reserve drive space tests")); |
514 TheTest.Next (_L(" @SYMTestCaseID:PDS-SQL-UT-4175 Reserve drive space tests")); |
436 ReserveDriveSpaceTest(); |
515 ReserveDriveSpaceTest(); |