diff -r d6ef85bc5971 -r a7ba600cb39d persistentstorage/sql/TEST/t_sqlfserr.cpp --- a/persistentstorage/sql/TEST/t_sqlfserr.cpp Fri May 14 17:36:33 2010 +0300 +++ b/persistentstorage/sql/TEST/t_sqlfserr.cpp Thu May 27 14:29:47 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -165,7 +165,7 @@ TEST(err >= 0); TheDb.Close(); err = KErrNotFound; - for(TInt cnt=1;err=KErrDied;--fsError) @@ -225,7 +225,7 @@ TEST(err >= 0); TheDb.Close(); err = KErrNotFound; - for(TInt cnt=1;err=KErrDied;--fsError) @@ -284,6 +284,35 @@ TEST2(err, KErrNone); } +//Creates public shared, private secure and public secure databases. +void DoCreateTestDatabases(const TPtrC aDbName[], TInt aCount) + { + TEST(aCount > 0); + for(TInt i=0;i= 0); + err = TheDb.Exec(_L("INSERT INTO A(Id,Name) VALUES(1,'Name')")); + TEST2(err, 1); + TheDb.Close(); + } + } + /** @SYMTestCaseID SYSLIB-SQL-UT-3421 @SYMTestCaseDesc Test for DEF103859 "SQLITE panic, _DEBUG mode, persistent file I/O error simulation". @@ -300,31 +329,12 @@ { TPtrC dbName[] = {KTestDbName(), KPrivateTestDbName(), KSecureTestDbName()}; const TInt KDbNameCnt = sizeof(dbName) / sizeof(dbName[0]); + DoCreateTestDatabases(dbName, KDbNameCnt); for(TInt k=0;k= 0); - err = TheDb.Exec(_L("INSERT INTO A(Id,Name) VALUES(1,'Name')")); - TEST2(err, 1); - TheDb.Close(); - - err = KErrNotFound; - for(TInt cnt=1;err=KErrDied;--fsError) @@ -354,7 +364,7 @@ err = RSqlDatabase::Delete(dbName[k]); TEST2(err, KErrNone); TheTest.Printf(_L("\r\n")); - } + }//end of: for(TInt k=0;k=KErrDied;--fsError) @@ -413,6 +423,78 @@ } /** +@SYMTestCaseID PDS-SQL-UT-4189 +@SYMTestCaseDesc Test for DEF145125 "SQL, low code coverage". + The test creates public shared, private secure and public secure test databases. + Then the test opens the publich shared database and attempts to attach one of the other two + in a file I/O error simulation loop. +@SYMTestPriority High +@SYMTestActions Test for DEF145125 - "SQL, low code coverage". +@SYMTestExpectedResults The test must not fail +@SYMDEF DEF145125 +*/ +void AttachDatabaseTest() + { + TPtrC dbName[] = {KTestDbName(), KPrivateTestDbName(), KSecureTestDbName()}; + const TInt KDbNameCnt = sizeof(dbName) / sizeof(dbName[0]); + DoCreateTestDatabases(dbName, KDbNameCnt); + for(TInt k=1;k=KErrDied;--fsError) + { + err = TheDb.Open(KTestDbName); + TEST2(err, KErrNone); + (void)TheFs.SetErrorCondition(fsError, cnt); + err = TheDb.Attach(dbName[k], _L("DB2")); + (void)TheFs.SetErrorCondition(KErrNone); + (void)TheDb.Detach(_L("DB2")); + TheDb.Close();//close the database to recover from the last error + } + } + TEST2(err, KErrNone); + err = RSqlDatabase::Delete(dbName[k]); + TEST2(err, KErrNone); + TheTest.Printf(_L("\r\n")); + } + } + +/** +@SYMTestCaseID PDS-SQL-UT-4190 +@SYMTestCaseDesc Test for DEF145125 "SQL, low code coverage". + The tests attempts to delete a database in a file I/O error simulation loop. +@SYMTestPriority High +@SYMTestActions Test for DEF145125 - "SQL, low code coverage". +@SYMTestExpectedResults The test must not fail +@SYMDEF DEF145125 +*/ +void DeleteDatabaseTest() + { + TPtrC dbName[] = {KTestDbName(), KPrivateTestDbName(), KSecureTestDbName()}; + const TInt KDbNameCnt = sizeof(dbName) / sizeof(dbName[0]); + DoCreateTestDatabases(dbName, KDbNameCnt); + for(TInt k=0;k dbFileName8; dbFileName8.Copy(TheRmvMediaDbFileName); - for(TInt cnt=1;rc!=SQLITE_OK;++cnt) + for(TInt cnt=0;rc!=SQLITE_OK;++cnt) { TheTest.Printf(_L("%d \r"), cnt); sqlite3* dbHandle = NULL; @@ -818,7 +900,7 @@ TheDb.Close(); //"File I/O" error simulation loop err = KErrCorrupt; - for(TInt cnt=1;err 0); //"File I/O" error simulation loop err = KErrCorrupt; - for(TInt cnt=1;errDes(); err = KErrCorrupt; - for(TInt cnt=1;err