Revision: 201013 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 01 Apr 2010 00:19:42 +0300
branchRCL_3
changeset 12 31a8f755b7fe
parent 11 667e88a979d7
child 13 211563e4b919
Revision: 201013 Kit: 201013
featuremgmt/featuremgr/src/clientdll/featurecontrol.cpp
featuremgmt/featuremgr/src/serverexe/featmgrfeatureregistry.cpp
featuremgmt/featuremgr/src/serverexe/featmgrfeatureregistry.h
featuremgmt/featuremgr/src/serverexe/featmgrpluginhandler.cpp
featuremgmt/featuremgr/src/serverexe/featmgrserver.cpp
featuremgmt/featuremgr/src/serverexe/featmgrserver.h
featuremgmt/featuremgr/test/group/bld.inf
featuremgmt/featuremgr/test/group/featmgr_test.iby
featuremgmt/featuremgr/test/rtest/group/featmgr_rtest.iby
featuremgmt/featuremgr/test/rtest/group/t_fmgrbackupmod.mmp
featuremgmt/featuremgr/test/rtest/group/t_fmgrbackupquery.mmp
featuremgmt/featuremgr/test/rtest/group/t_fmgrstartup.mmp
featuremgmt/featuremgr/test/rtest/src/t_fmgrapi.cpp
featuremgmt/featuremgr/test/rtest/src/t_fmgrbackupmod.cpp
featuremgmt/featuremgr/test/rtest/src/t_fmgrbackupquery.cpp
featuremgmt/featuremgr/test/rtest/src/t_fmgrbadclient.cpp
featuremgmt/featuremgr/test/rtest/src/t_fmgrnotify.cpp
featuremgmt/featuremgr/test/rtest/src/t_fmgroom.cpp
featuremgmt/featuremgr/test/rtest/src/t_fmgrperformance.cpp
featuremgmt/featuremgr/test/rtest/src/t_fmgrstartup.cpp
featuremgmt/featuremgr/test/rtest/src/t_fmgrswi.cpp
featuremgmt/featuremgr/test/tef/tef_efm_configured/src/plugin_test_steps.cpp
loggingservices/eventlogger/LogCli/src/LogCliServerShared.cpp
loggingservices/eventlogger/LogServ/inc/LogServSqlStrings.h
loggingservices/eventlogger/test/inc/SecurityPolicy.h
loggingservices/eventlogger/test/inc/TEST.H
loggingservices/eventlogger/test/src/t_OrderById.CPP
loggingservices/eventlogger/test/src/t_logview2.cpp
loggingservices/eventlogger/test/src/t_maxnumberlength.CPP
loggingservices/eventlogger/test/src/test.cpp
loggingservices/eventlogger/test/t_OrderById.MMP
loggingservices/eventlogger/test/t_maxnumberlength.MMP
persistentstorage/centralrepository/cenrepsrv/cachemgr.h
persistentstorage/sql/OsLayer/os_symbian.cpp
persistentstorage/sql/SRC/Server/Compact/SqlCompact.h
persistentstorage/sql/SRC/Server/Compact/SqlCompactConn.cpp
persistentstorage/sql/SRC/Server/Compact/SqlCompactEntry.cpp
persistentstorage/sql/SRC/Server/Compact/SqlCompactTimer.h
persistentstorage/sql/SRC/Server/SqlSrvDatabase.cpp
persistentstorage/sql/SRC/Server/SqlSrvSecurityMap.h
persistentstorage/sql/SRC/Server/SqlSrvSession.cpp
persistentstorage/sql/TEST/t_sqlapi.cpp
persistentstorage/sql/TEST/t_sqldbconfigfile.cpp
persistentstorage/sql/TEST/t_sqloom5.cpp
persistentstorage/sql/TEST/t_sqlstartup.cpp
persistentstorage/sqlite3api/GROUP/sqlite3tests.iby
persistentstorage/sqlite3api/GROUP/tclsqlite3.mmp
persistentstorage/store/HTOOLS/pfsdump.ipr
persistentstorage/store/group/BLD.INF
persistentstorage/store/group/syslibs_store.mrp
--- a/featuremgmt/featuremgr/src/clientdll/featurecontrol.cpp	Mon Mar 15 12:46:30 2010 +0200
+++ b/featuremgmt/featuremgr/src/clientdll/featurecontrol.cpp	Thu Apr 01 00:19:42 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"
@@ -75,7 +75,13 @@
         
         if ( err == KErrNone )
             {
-            Dll::SetTls( tlsData );
+            err = Dll::SetTls( tlsData );
+            if (err != KErrNone)
+                {
+                delete tlsData;
+                ERROR_LOG1( "RFeatureControl::Open SetTls error %d ", err );
+				return err;
+                }
             }
         else
             {
--- a/featuremgmt/featuremgr/src/serverexe/featmgrfeatureregistry.cpp	Mon Mar 15 12:46:30 2010 +0200
+++ b/featuremgmt/featuremgr/src/serverexe/featmgrfeatureregistry.cpp	Thu Apr 01 00:19:42 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"
@@ -550,9 +550,9 @@
     //check that there is at least one DSR 
     if (!iRangeList.Count()) 
     	{
-    	_LIT( KPanicCategory, "FeatMgrServer" );
+    	_LIT(KPanicCategory, "FeatMgrServer");
     	ERROR_LOG( "CFeatMgrFeatureRegistry::ReadFilesFromDirL() - no DSR found in ROM; this indicates a system integration error  - going to panic" );
-    	User::Panic( KPanicCategory, EPanicNoDSR );    
+    	::FmgrFatalErrorL(KErrNotFound, KPanicCategory, EPanicNoDSR);    
     	}
     }
 
@@ -562,7 +562,7 @@
 //
 void CFeatMgrFeatureRegistry::ReadFilesFromDirL( const TDesC& aDirName )
     {
-	_LIT( KPanicCategory, "FEATMGR-READFILE" );
+    _LIT(KPanicCategory, "FEATMGR-READFILE");
 
     CDir* dir = NULL; 
     TInt err( KErrNone );
@@ -581,7 +581,7 @@
         }  
     else if( err == KErrPathNotFound )
     	{
-    	__ASSERT_ALWAYS( EFalse, User::Panic( KPanicCategory, EPanicNoFeatureFiles) );
+    	::FmgrFatalErrorL(err, KPanicCategory, EPanicNoFeatureFiles);
     	}
 	else
         {            
@@ -722,7 +722,7 @@
         	}
         else //File is not as runtime file.
         	{
-        	err = ValidateFeatureFlag(flags);
+        	ValidateFeatureFlagL(flags);
         	}
         
         //If a feature flag defined in system drive (c:) is invalid, it will not be added to Feature Manager 
@@ -1025,7 +1025,7 @@
     for ( TInt i = 0; i < count; i++ )
         {
         //Check for feature flag errors
-        ValidateFeatureFlag(aList[i].FeatureFlags()) ; 
+        ValidateFeatureFlagL(aList[i].FeatureFlags()) ; 
         const TUid uid( aList[i].FeatureUid() );
         TInt index = SearchFeature( uid );
         
@@ -1063,10 +1063,9 @@
 // -----------------------------------------------------------------------------
 //  
    
-TInt CFeatMgrFeatureRegistry::ValidateFeatureFlag(TBitFlags32 aFlags)
+void CFeatMgrFeatureRegistry::ValidateFeatureFlagL(TBitFlags32 aFlags)
 	{
-	_LIT( KPanicCategory, "FEATMGR-FLAGS" );
-
+	_LIT(KPanicCategory, "FEATMGR-FLAGS");
 	
 	if(!aFlags.IsSet(EFeatureRuntime)) //ROM defined feature flag error check
 		{
@@ -1076,8 +1075,7 @@
 	    	 if(aFlags.IsSet(EFeatureModifiable) || aFlags.IsSet(EFeaturePersisted) || aFlags.IsSet(EFeatureUninitialized) )
 	    	 	{
 	    	 	//error 
-	    	 	__ASSERT_ALWAYS(EFalse, User::Panic( KPanicCategory, EFmpInvalidFeatureBitFlagsRule1));
-                return KErrArgument;
+	    	 	::FmgrFatalErrorL(KErrArgument, KPanicCategory, EFmpInvalidFeatureBitFlagsRule1);
 	    	  	}
 	    	}
 	    	
@@ -1087,17 +1085,14 @@
 	       	if (aFlags.IsSet(EFeaturePersisted) || aFlags.IsSet(EFeatureUninitialized) )
 	       	 	{
 	        	//error 
-	        	__ASSERT_ALWAYS(EFalse, User::Panic( KPanicCategory, EFmpInvalidFeatureBitFlagsRule2));
-                return KErrArgument;
+	       	 	::FmgrFatalErrorL(KErrArgument, KPanicCategory, EFmpInvalidFeatureBitFlagsRule2);
 	        	}	
 	        }
 		}
 	else // Runtime feature this should not be in the rom
 		{		
-		__ASSERT_ALWAYS(EFalse, User::Panic( KPanicCategory, EPanicInvalidFeatureInfo));
-		return KErrArgument;
+		::FmgrFatalErrorL(KErrArgument, KPanicCategory, EPanicInvalidFeatureInfo);
 		}
-	return KErrNone;
 	}
 
 /**
--- a/featuremgmt/featuremgr/src/serverexe/featmgrfeatureregistry.h	Mon Mar 15 12:46:30 2010 +0200
+++ b/featuremgmt/featuremgr/src/serverexe/featmgrfeatureregistry.h	Thu Apr 01 00:19:42 2010 +0300
@@ -242,7 +242,7 @@
         const TFeatureServerEntry& aItem );
         void ValidateHeaderL( RFileReadStream& stream, TUint32& count, TUint32& countDSRs );
         void WriteHeaderAndEntriesL( RFileWriteStream &aStream, RFeatureServerArray& aArray );
-        TInt ValidateFeatureFlag(TBitFlags32 aFlags);
+        void ValidateFeatureFlagL(TBitFlags32 aFlags);
         void ValidateRuntimeFeatureFlagL(TBitFlags32 aFlags);
         
      private:
--- a/featuremgmt/featuremgr/src/serverexe/featmgrpluginhandler.cpp	Mon Mar 15 12:46:30 2010 +0200
+++ b/featuremgmt/featuremgr/src/serverexe/featmgrpluginhandler.cpp	Thu Apr 01 00:19:42 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"
@@ -24,7 +24,7 @@
 #include "featmgrserver.h"
 
 // LOCAL CONSTANTS
-_LIT( KPanicCategory, "FeatMgrPluginHandler" );
+_LIT(KPanicCategory, "FeatMgrPluginHandler");
 
 // ============================= LOCAL FUNCTIONS ===============================
 
@@ -192,7 +192,7 @@
         ERROR_LOG2( "CFeatMgrPluginHandler::ProcessFeatureInfoL - pluginhandler %x, error %d - going to panic",
                                      this, aResponse().iErrorCode );
         // This is considered fatal enough reason to panic
-        User::Panic( KPanicCategory, EPanicInvalidFeatureInfo );                       
+        ::FmgrFatalErrorL(aResponse().iErrorCode, KPanicCategory, EPanicInvalidFeatureInfo);                       
         }
     }
 
@@ -243,7 +243,7 @@
         ERROR_LOG2( "CFeatMgrPluginHandler::ProcessFeatureInfoL - pluginhandler %x, error %d - going to panic",
                                      this, aResponse().iErrorCode );
         // This is considered fatal enough reason to panic
-        User::Panic( KPanicCategory, EPanicInvalidFeatureInfo );                       
+        ::FmgrFatalErrorL(aResponse().iErrorCode, KPanicCategory, EPanicInvalidFeatureInfo);                       
         }
     }
 
--- a/featuremgmt/featuremgr/src/serverexe/featmgrserver.cpp	Mon Mar 15 12:46:30 2010 +0200
+++ b/featuremgmt/featuremgr/src/serverexe/featmgrserver.cpp	Thu Apr 01 00:19:42 2010 +0300
@@ -28,12 +28,7 @@
 #include <f32file.h>
 #include <s32file.h>
 
-// LOCAL CONSTANTS AND MACROS
-#ifdef EXTENDED_FEATURE_MANAGER_TEST
-_LIT( KPanicCategory, "EnhancedFeatMgrServer" );
-#else
-_LIT( KPanicCategory, "FeatMgrServer" );
-#endif // EXTENDED_FEATURE_MANAGER_TEST
+_LIT(KPanicCategory, "FeatMgrServer");
 
 // ============================ MEMBER FUNCTIONS ===============================
 
@@ -98,11 +93,11 @@
     	{
     	case KErrNotFound:
     		ERROR_LOG( "CFeatMgrServer::ConstructL() - no feature files found in ROM - going to panic");
-    		User::Panic( KPanicCategory, EPanicNoFeatureFiles );
+    		::FmgrFatalErrorL(err, KPanicCategory, EPanicNoFeatureFiles);
     		break;
     	case KErrCorrupt:
     	    ERROR_LOG( "CFeatMgrServer::ConstructL() - feature information in ROM is invalid - going to panic");
-    	    User::Panic( KPanicCategory, EPanicInvalidFeatureInfo );
+    	    ::FmgrFatalErrorL(err, KPanicCategory, EPanicInvalidFeatureInfo);
     	    break;
     	default:
     		User::LeaveIfError(err);
@@ -342,86 +337,47 @@
     
     // Check if any plugin was found. 
     TInt count = implInfoArray.Count();
-    
-    if ( count > 0 )
+    if(count == 0)
         {
-        
-        for(TInt i = 0; i < count; i ++)
+        iPluginsReady = ETrue; // Plugins not found.
+        INFO_LOG1("CFeatMgrServer::LoadPluginsL - interfaceUid.iUid == 0x%x, return plugins not found", KFeatureInfoPluginInterfaceUid);
+        ret = EFalse;
+        }
+    else
+        {
+        for(TInt i=0;i<count;++i)
             {
             CFeatMgrPluginHandler* pluginHandler = NULL;
-            TInt err( KErrNone );
-        
-            // Create handler
-            TRAP( err, pluginHandler = CFeatMgrPluginHandler::NewL( 
-                  implInfoArray[i]->ImplementationUid(), *this) );
-                
-            LOG_IF_ERROR1( err, "CFeatMgrServer::LoadPluginsL() - pluginHandler creation err %d", err );
-            
-            // Apply first request for plugin to process
-            if ( err == KErrNone )
-                {
-                TRAP( err, pluginHandler->SendCommandL( 
-                    FeatureInfoCommand::ELoadFeatureInfoCmdId ) );
-                }            
-            
-            // Panic if error sth else than not supported        
-            if ( err != KErrNone && err != KErrNotSupported )
+            TRAPD(err, pluginHandler = CFeatMgrPluginHandler::NewL(implInfoArray[i]->ImplementationUid(), *this));
+            if(err == KErrNone)
                 {
-                ERROR_LOG2( "CFeatMgrServer::LoadPluginsL() - implementationUid: 0x%x, error: %d - going to panic",
-                                        implInfoArray[i]->ImplementationUid(), err );
-                User::Panic( KPanicCategory, EPanicLoadPluginError );                           
-                }
-            // If simple features are not supported by the plugin search for enhanced ones
-            else if ( err == KErrNotSupported )
-            	{
-            	// Reset error code
-            	err = KErrNone;
-                TRAP( err, pluginHandler->SendCommandL(
-                    FeatureInfoCommand::ELoadEnhancedFeatureInfoCmdId ) );
-
-                // Panic if error since in this case the plugin does not support any feature
-            	if ( err != KErrNone )
-	            	{
-	                ERROR_LOG2( "CFeatMgrServer::LoadPluginsL() - implementationUid: 0x%x, error: %d - going to panic",
-	                        implInfoArray[i]->ImplementationUid(), err );
-	                User::Panic( KPanicCategory, EPanicLoadPluginError );
-	            	}
-	            }
-            // If a simple or enhanced feature is supported by the plugin then append the plugin to the list
-            if ( err == KErrNone )
-            	{
-                INFO_LOG1( "CFeatMgrServer::LoadPluginsL() - Add info of implementationUid: 0x%x",
-                                        implInfoArray[i]->ImplementationUid() );
-            
-                // Add information of the plugin to the plugin list
-                SFeatMgrPluginInfo plugin;
-                plugin.iPluginHandler = pluginHandler;
-                // Set all plugins as not ready initially
-                plugin.iPluginReady = EFalse;
-
-                TInt err = iPluginList.Append(plugin);
-            
-                if ( err != KErrNone )
+                CleanupStack::PushL(pluginHandler);
+                TRAP(err, pluginHandler->SendCommandL(FeatureInfoCommand::ELoadFeatureInfoCmdId));
+                if(err == KErrNotSupported)
                     {
-                    ERROR_LOG2( "CFeatMgrServer::LoadPluginsL() - Saving plugin info of implementationUid: 0x%x, err %d",
-                                                  implInfoArray[i]->ImplementationUid(), err );
-                    User::Leave( err );
+                    TRAP(err, pluginHandler->SendCommandL(FeatureInfoCommand::ELoadEnhancedFeatureInfoCmdId));
                     }
                 }
+            if(err == KErrNoMemory)
+                {
+                User::Leave(err);
+                }
+            else if(err != KErrNone)
+                {
+                ERROR_LOG2("CFeatMgrServer::LoadPluginsL() - implementationUid: 0x%x, error: %d - going to panic", implInfoArray[i]->ImplementationUid(), err);
+                ::FmgrFatalErrorL(err, KPanicCategory, EPanicLoadPluginError);                           
+                }
+            // Add information of the plugin to the plugin list. Set all plugins as not ready initially.
+            SFeatMgrPluginInfo plugin;
+            plugin.iPluginHandler = pluginHandler;
+            plugin.iPluginReady = EFalse;
+            User::LeaveIfError(iPluginList.Append(plugin));
+            CleanupStack::Pop(pluginHandler);
             }
-        INFO_LOG1( "CFeatMgrServer::LoadPluginsL - interfaceUid.iUid == 0x%x, return plugins found",
-                           KFeatureInfoPluginInterfaceUid );
+        INFO_LOG1("CFeatMgrServer::LoadPluginsL - interfaceUid.iUid == 0x%x, return plugins found", KFeatureInfoPluginInterfaceUid);
         ret = ETrue;
         }
     
-    else
-        {
-        iPluginsReady = ETrue; // Plugins not found.
-        INFO_LOG1( "CFeatMgrServer::LoadPluginsL - interfaceUid.iUid == 0x%x, return plugins not found",
-                           KFeatureInfoPluginInterfaceUid );
-        ret = EFalse;
-        }
-    
     CleanupStack::PopAndDestroy(&implInfoArray);
     
     return ret;
@@ -536,7 +492,7 @@
             if ( err != KErrNone && err != KErrNotSupported )
                 {
                 ERROR_LOG1( "CFeatMgrServer::FeatureInfoL() - panicing due error %d", err );
-                User::Panic( KPanicCategory, EPanicLoadPluginError );
+                ::FmgrFatalErrorL(err, KPanicCategory, EPanicLoadPluginError);
                 }
             // At this point we have simple feature supported by the plugin.
             // If no enhanced feature is supported, but a simple one is, then
@@ -781,7 +737,7 @@
 	if( KErrNotFound == err)
 		{
 		ERROR_LOG( "CFeatMgrServer::ConstructL() & CallReadFeatureFilesL() - no feature files found in ROM - going to panic");
-	    User::Panic( KPanicCategory, EPanicNoFeatureFiles );
+		::FmgrFatalErrorL(err, KPanicCategory, EPanicNoFeatureFiles);
 		}
 	else
 		{
@@ -802,7 +758,7 @@
 	    TRAPD( err, iRegistry->ReadRuntimeFeaturesL( iFeaturesReady ) );
 		if( KErrNotFound == err)
 			{
-		    User::Panic( KPanicCategory, EPanicNoFeatureFiles );
+			::FmgrFatalErrorL(err, KPanicCategory, EPanicNoFeatureFiles);
 			}
 		else
 			{
--- a/featuremgmt/featuremgr/src/serverexe/featmgrserver.h	Mon Mar 15 12:46:30 2010 +0200
+++ b/featuremgmt/featuremgr/src/serverexe/featmgrserver.h	Thu Apr 01 00:19:42 2010 +0300
@@ -31,6 +31,18 @@
 #include "featmgrfeatureregistry.h"
 #include "burstate.h"
 
+#ifdef FEATURE_MANAGER_STARTUP_TEST
+    inline void FmgrFatalErrorL(TInt err, const TDesC&, TInt)
+        {
+        User::Leave(err);
+        }
+#else
+    inline void FmgrFatalErrorL(TInt, const TDesC& aPanicCategory, TInt aPanicCode)
+        {
+        User::Panic(aPanicCategory, aPanicCode);
+        }
+#endif
+
 // FORWARD DECLARATIONS
 class CFeatMgrPluginHandler;
 class CFeatMgrFeatureRegistry;
--- a/featuremgmt/featuremgr/test/group/bld.inf	Mon Mar 15 12:46:30 2010 +0200
+++ b/featuremgmt/featuremgr/test/group/bld.inf	Thu Apr 01 00:19:42 2010 +0300
@@ -31,7 +31,7 @@
 ../rtest/group/t_fmgroom.mmp
 ../rtest/group/t_fmgrstartup.mmp
 ../rtest/group/t_fmgrpanic.mmp
-../rtest/group/t_fmgrbadclient.mmp manual
+../rtest/group/t_fmgrbadclient.mmp
 ../rtest/group/t_fmgrsecurity1.mmp
 ../rtest/group/t_fmgrnotify.mmp
 ../rtest/group/t_fmgrperformance.mmp
--- a/featuremgmt/featuremgr/test/group/featmgr_test.iby	Mon Mar 15 12:46:30 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-// Copyright (c) 2007-2009 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"
-// which accompanies this distribution, and is available
-// at the URL "http://www.eclipse.org/legal/epl-v10.html".
-//
-// Initial Contributors:
-// Nokia Corporation - initial contribution.
-//
-// Contributors:
-//
-// Description:
-//
-
-#ifndef __FEATMGR_TEST_IBY__
-#define __FEATMGR_TEST_IBY__
-
-// Make sure that the feature manager production code is included in the ROM.
-#include "featmgr.iby"
-
-//main efm test script
-data=DATAZ_\test\efm\scripts\tef_featmgr.script		test\efm\scripts\tef_featmgr.script
-
-//rtest tests .iby files
-//#include "featmgr_rtest.iby"
-
-//tef tests .iby files
-#include "efm_configured_testserver.iby"
-#include "efm_normal_testserver.iby"
-#include "efm_unit_testserver.iby"
-#include "tef_feature_generator.iby"
-#include "tef_efm_bursuite.iby"
-
-// helper .iby files
-#include "test_efm.iby"
-#include "pluginhelper.iby"
-#include "test_plugins.iby"
-#include "dummyswi.iby"
-#include "helping_exe.iby" 
-
-#endif //__FEATMGR_TEST_IBY__
--- a/featuremgmt/featuremgr/test/rtest/group/featmgr_rtest.iby	Mon Mar 15 12:46:30 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-// Copyright (c) 2008-2009 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"
-// which accompanies this distribution, and is available
-// at the URL "http://www.eclipse.org/legal/epl-v10.html".
-//
-// Initial Contributors:
-// Nokia Corporation - initial contribution.
-//
-// Contributors:
-//
-// Description:
-//
-
-#ifndef __FEATMGR_RTEST_IBY__
-#define __FEATMGR_RTEST_IBY__
-
-file=ABI_DIR\BUILD_DIR\t_fmgrbackupquery.exe						test\t_fmgrbackupquery.exe
-file=ABI_DIR\BUILD_DIR\t_fmgrbackupmod.exe						test\t_fmgrbackupmod.exe
-
-#endif // __FEATMGR_RTEST_IBY__
--- a/featuremgmt/featuremgr/test/rtest/group/t_fmgrbackupmod.mmp	Mon Mar 15 12:46:30 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-// Copyright (c) 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"
-// which accompanies this distribution, and is available
-// at the URL "http://www.eclipse.org/legal/epl-v10.html".
-//
-// Initial Contributors:
-// Nokia Corporation - initial contribution.
-//
-// Contributors:
-//
-// Description:
-//
-
-TARGET			t_fmgrbackupmod.exe
-TARGETTYPE		EXE
-CAPABILITY  	ReadDeviceData WriteDeviceData AllFiles
-
-USERINCLUDE 	../inc 
-
-OS_LAYER_SYSTEMINCLUDE
-
-SOURCEPATH		../src
-SOURCE			t_fmgrbursim.cpp
-SOURCE			t_fmgrbackupmod.cpp
-
-LIBRARY			euser.lib
-LIBRARY     	bafl.lib
-LIBRARY     	efsrv.lib 
-LIBRARY			featmgr.lib
-
-
-UID				0 0x10281e17
-VENDORID		0x70000001
-
-SMPSAFE
\ No newline at end of file
--- a/featuremgmt/featuremgr/test/rtest/group/t_fmgrbackupquery.mmp	Mon Mar 15 12:46:30 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-// Copyright (c) 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"
-// which accompanies this distribution, and is available
-// at the URL "http://www.eclipse.org/legal/epl-v10.html".
-//
-// Initial Contributors:
-// Nokia Corporation - initial contribution.
-//
-// Contributors:
-//
-// Description:
-//
-
-TARGET			t_fmgrbackupquery.exe
-TARGETTYPE		EXE
-CAPABILITY  	ReadDeviceData WriteDeviceData AllFiles
-
-USERINCLUDE 	../inc 
-
-OS_LAYER_SYSTEMINCLUDE
-
-SOURCEPATH		../src
-SOURCE			t_fmgrbursim.cpp
-SOURCE			t_fmgrbackupquery.cpp
-
-LIBRARY			euser.lib
-LIBRARY     	bafl.lib
-LIBRARY     	efsrv.lib 
-LIBRARY			featdiscovery.lib
-
-UID				0 0x10281e17
-VENDORID		0x70000001
-
-SMPSAFE
\ No newline at end of file
--- a/featuremgmt/featuremgr/test/rtest/group/t_fmgrstartup.mmp	Mon Mar 15 12:46:30 2010 +0200
+++ b/featuremgmt/featuremgr/test/rtest/group/t_fmgrstartup.mmp	Thu Apr 01 00:19:42 2010 +0300
@@ -17,6 +17,7 @@
 TARGETTYPE		exe
 
 MACRO       EXTENDED_FEATURE_MANAGER_TEST
+MACRO       FEATURE_MANAGER_STARTUP_TEST
 
 CAPABILITY      ProtServ ReadDeviceData AllFiles
 
--- a/featuremgmt/featuremgr/test/rtest/src/t_fmgrapi.cpp	Mon Mar 15 12:46:30 2010 +0200
+++ b/featuremgmt/featuremgr/test/rtest/src/t_fmgrapi.cpp	Thu Apr 01 00:19:42 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2009-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"
@@ -307,7 +307,7 @@
     CleanupStack::PopAndDestroy(fdiscovery);
     }
 
-void DoFeatureDiscoveryTest2(TBool aStaticMethodsUsed)
+void DoFeatureDiscoveryTest2L(TBool aStaticMethodsUsed)
     {
     CFeatureDiscovery* fdiscovery = NULL;
     if(!aStaticMethodsUsed)
@@ -398,8 +398,8 @@
 */
 void FeatureDiscoveryTest2L()
     {
-    DoFeatureDiscoveryTest2(ETrue);
-    DoFeatureDiscoveryTest2(EFalse);
+    DoFeatureDiscoveryTest2L(ETrue);
+    DoFeatureDiscoveryTest2L(EFalse);
     }
 
 void DoTestsL()
--- a/featuremgmt/featuremgr/test/rtest/src/t_fmgrbackupmod.cpp	Mon Mar 15 12:46:30 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,181 +0,0 @@
-// Copyright (c) 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"
-// which accompanies this distribution, and is available
-// at the URL "http://www.eclipse.org/legal/epl-v10.html".
-//
-// Initial Contributors:
-// Nokia Corporation - initial contribution.
-//
-// Contributors:
-//
-// Description:
-//
-
-#include <e32test.h>
-#include <e32debug.h>
-#include <bautils.h>
-#include <featurecontrol.h>
-#include "t_fmgrbursim.h"
-
-///////////////////////////////////////////////////////////////////////////////////////
-
-RTest TheTest(_L("t_fmgrbur test"));
-
-const TUint threadTimeout = 1500000;    // thread timeout = 1.5 second 
-
-static RSemaphore MainThreadCrS;
-static TInt featMgrIsResponsive = 0;
-
-///////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////////////
-//Test macros and functions
-void Check1(TInt aValue, TInt aLine, TBool aPrintThreadName = EFalse)
-    {
-    if(!aValue)
-        {
-        //DeleteTestFiles();
-        if(aPrintThreadName)
-            {
-            RThread th;
-            TName name = th.Name();
-            RDebug::Print(_L("*** Thread %S, Line %d\r\n"), &name, aLine);
-            }
-        else
-            {
-            RDebug::Print(_L("*** Line %d\r\n"), aLine);
-            }
-        TheTest(EFalse, aLine);
-        }
-    }
-
-void Check2(TInt aValue, TInt aExpected, TInt aLine, TBool aPrintThreadName = EFalse)
-    {
-    if(aValue != aExpected)
-        {
-        //DeleteTestFiles();
-        if(aPrintThreadName)
-            {
-            RThread th;
-            TName name = th.Name();
-            RDebug::Print(_L("*** Thread %S, Line %d Expected error: %d, got: %d\r\n"), &name, aLine, aExpected, aValue);
-            }
-        else
-            {
-            RDebug::Print(_L("*** Line %d, Expected error: %d, got: %d\r\n"), aLine, aExpected, aValue);
-            }
-        TheTest(EFalse, aLine);
-        }
-    }
-#define TEST(arg) ::Check1((arg), __LINE__)
-#define TEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__)
-#define TTEST(arg) ::Check1((arg), __LINE__, ETrue)
-#define TTEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__, ETrue)
-
-// ------------------------- ------------------------- 
-// setup and cleanup functions
-
-TInt TestModifyThreadL(void*)
-    {
-        __UHEAP_MARK;
-        
-        CTrapCleanup* tc = CTrapCleanup::New();
-        // Modify a feature. We don't care about its result. 
-        //  It is fine as long as it returns.
-        RFeatureControl rfc;
-        TEST2( rfc.Connect(), KErrNone );
-        rfc.EnableFeature( TUid::Uid(0x00000001) );
-        rfc.Close();
-        featMgrIsResponsive = 1;
-        RDebug::Print(_L("+++:TestModifyThread: Modification completed\r\n"));
-        MainThreadCrS.Signal();
-        delete tc;
-        
-        __UHEAP_MARKEND;
-        
-        return KErrNone;
-    }
-/**
-@SYMTestCaseID          PDS-FEATMGR-CT-XXXX
-@SYMTestCaseDesc        Querying a feature during backup operation. Verify that a 
-                        response is returned from the server during backup.
-@SYMTestPriority        High
-@SYMTestActions         Start simulating backup operation
-                        Create a thread that will query a feature
-                        Verify that a response is received in not more than 1.5 second.
-                        Otherwise the test fail.          
-@SYMTestExpectedResults Test must not fail
-@SYMREQ                 
-*/  
-void TestBackupModificationResponseL()
-    {
-        _LIT(KThreadName, "MdfTh");
-        featMgrIsResponsive = 0;
-        
-        CFeatMgrBURSim* simulate = CFeatMgrBURSim::NewLC();
-        RThread modifyThread;
-        TRequestStatus modifyStatus;
-        
-        CleanupClosePushL( modifyThread );
-        
-        
-        // Simulate a backup
-        RDebug::Print(_L("Simulating Backup of BUR\r\n"));
-        simulate->Simulate_StartBackupL();
-
-        TEST2( modifyThread.Create(KThreadName, &TestModifyThreadL, 0x2000, 0x1000, 0x10000, NULL, EOwnerProcess), KErrNone );
-        modifyThread.Logon(modifyStatus);
-        TEST2( modifyStatus.Int(), KRequestPending );
-        modifyThread.Resume();
-        // Wait for 1.5 second for the query thread to finish. 
-        RDebug::Print(_L("+++:MainThread: Wait for modification completion...\r\n"));
-        MainThreadCrS.Wait(threadTimeout);
-        // The modification request should NOT be responsive within the 1.5 second frame.
-        // It should only be responsive after back up ended.
-        TEST2 (featMgrIsResponsive, 0);
-        simulate->Simulate_EndBackupL();
-        
-        MainThreadCrS.Wait(threadTimeout);
-        
-        // The modification request now must be responsive within the 1.5 second frame.
-        TEST2 (featMgrIsResponsive, 1);
-        
-        CleanupStack::PopAndDestroy(&modifyThread);
-        CleanupStack::PopAndDestroy(simulate);
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////
-
-void DoTestsL()
-	{
-    MainThreadCrS.CreateLocal(0);
-    
-    TheTest.Start(_L(" @SYMTestCaseID:PDS-FEATMGR-CT-XXXX Backup Modification Response"));
-    TestBackupModificationResponseL();
-    
-    MainThreadCrS.Close();
-
-	}
-
-TInt E32Main()
-	{
-	TheTest.Title();
-	
-	CTrapCleanup* tc = CTrapCleanup::New();
-	
-	__UHEAP_MARK;
-	
-	TRAPD(err, DoTestsL());
-	TEST2(err, KErrNone);
-
-	__UHEAP_MARKEND;
-	
-	TheTest.End();
-	TheTest.Close();
-	
-	delete tc;
-	
-	User::Heap().Check();
-	return KErrNone;
-	}
--- a/featuremgmt/featuremgr/test/rtest/src/t_fmgrbackupquery.cpp	Mon Mar 15 12:46:30 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,194 +0,0 @@
-// Copyright (c) 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"
-// which accompanies this distribution, and is available
-// at the URL "http://www.eclipse.org/legal/epl-v10.html".
-//
-// Initial Contributors:
-// Nokia Corporation - initial contribution.
-//
-// Contributors:
-//
-// Description:
-//
-
-#include <e32test.h>
-#include <e32debug.h>
-#include <bautils.h>
-#include <featdiscovery.h>
-#include "t_fmgrbursim.h"
-
-///////////////////////////////////////////////////////////////////////////////////////
-
-RTest TheTest(_L("t_fmgrbur test"));
-
-const TUint threadTimeout = 1500000;    // thread timeout = 1.5 second 
-
-static RSemaphore MainThreadCrS;
-static TInt featMgrIsResponsive = 0;
-
-///////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////////////
-//Test macros and functions
-void Check1(TInt aValue, TInt aLine, TBool aPrintThreadName = EFalse)
-    {
-    if(!aValue)
-        {
-        //DeleteTestFiles();
-        if(aPrintThreadName)
-            {
-            RThread th;
-            TName name = th.Name();
-            RDebug::Print(_L("*** Thread %S, Line %d\r\n"), &name, aLine);
-            }
-        else
-            {
-            RDebug::Print(_L("*** Line %d\r\n"), aLine);
-            }
-        TheTest(EFalse, aLine);
-        }
-    }
-
-void Check2(TInt aValue, TInt aExpected, TInt aLine, TBool aPrintThreadName = EFalse)
-    {
-    if(aValue != aExpected)
-        {
-        //DeleteTestFiles();
-        if(aPrintThreadName)
-            {
-            RThread th;
-            TName name = th.Name();
-            RDebug::Print(_L("*** Thread %S, Line %d Expected error: %d, got: %d\r\n"), &name, aLine, aExpected, aValue);
-            }
-        else
-            {
-            RDebug::Print(_L("*** Line %d, Expected error: %d, got: %d\r\n"), aLine, aExpected, aValue);
-            }
-        TheTest(EFalse, aLine);
-        }
-    }
-#define TEST(arg) ::Check1((arg), __LINE__)
-#define TEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__)
-#define TTEST(arg) ::Check1((arg), __LINE__, ETrue)
-#define TTEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__, ETrue)
-
-// ------------------------- ------------------------- 
-// setup and cleanup functions
-
-/**
- * Creates the direcory structure required for the backup to take place. 
- * Will leave if an error occurs other then KErrNone or KErrAlreadyExists as this 
- * indicates the directory structure has not been created. 
- */
-
-TInt TestQueryThreadL(void*)
-    {
-        __UHEAP_MARK;
-        
-        CTrapCleanup* tc = CTrapCleanup::New();
-        // Query a feature. We don't care about its result. 
-        //  It is fine as long as it returns.
-        CFeatureDiscovery::IsFeatureSupportedL( TUid::Uid(0x00000001) );
-        featMgrIsResponsive = 1;
-        RDebug::Print(_L("+++:TestQueryThread: Query completed\r\n"));
-        MainThreadCrS.Signal();
-        delete tc;
-        
-        __UHEAP_MARKEND;
-        
-        return KErrNone;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////
-
-/**
-@SYMTestCaseID          PDS-FEATMGR-CT-XXXX
-@SYMTestCaseDesc        Querying a feature during backup operation. Verify that a 
-                        response is returned from the server during backup.
-@SYMTestPriority        High
-@SYMTestActions         Start simulating backup operation
-                        Create a thread that will query a feature
-                        Verify that a response is received in not more than 1.5 second.
-                        Otherwise the test fail.          
-@SYMTestExpectedResults Test must not fail
-@SYMREQ                 
-*/  
-void TestBackupQueryResponseL()
-    {
-        _LIT(KThreadName, "QryTh");
-        featMgrIsResponsive = 0;
-        
-        CFeatMgrBURSim* simulate = CFeatMgrBURSim::NewLC();
-        RThread queryThread;
-        TRequestStatus queryStatus;
-        
-        CleanupClosePushL( queryThread );
-        
-        // Simulate a backup
-        RDebug::Print(_L("Simulating Backup of BUR\r\n"));
-        simulate->Simulate_StartBackupL();
-
-        TEST2( queryThread.Create(KThreadName, &TestQueryThreadL, 0x2000, 0x1000, 0x10000, NULL, EOwnerProcess), KErrNone );
-        queryThread.Logon(queryStatus);
-        TEST2( queryStatus.Int(), KRequestPending );
-        queryThread.Resume();
-        // Wait for 1.5 second for the query thread to finish. 
-        RDebug::Print(_L("+++:MainThread: Wait for query completion...\r\n"));
-        MainThreadCrS.Wait(threadTimeout);
-        // If query is responsive within the 1.5 second frame the following check should pass.
-        TEST2 (featMgrIsResponsive, 1);
-        
-        simulate->Simulate_EndBackupL();
-
-        CleanupStack::PopAndDestroy(&queryThread);
-        CleanupStack::PopAndDestroy(simulate);
-    }
-
-/**
-@SYMTestCaseID          PDS-FEATMGR-CT-XXXX
-@SYMTestCaseDesc        Querying a feature during backup operation. Verify that a 
-                        response is returned from the server during backup.
-@SYMTestPriority        High
-@SYMTestActions         Start simulating backup operation
-                        Create a thread that will query a feature
-                        Verify that a response is received in not more than 1.5 second.
-                        Otherwise the test fail.          
-@SYMTestExpectedResults Test must not fail
-@SYMREQ                 
-*/  
-
-///////////////////////////////////////////////////////////////////////////////////////
-
-void DoTestsL()
-	{
-    MainThreadCrS.CreateLocal(0);
-    
-    TheTest.Start(_L(" @SYMTestCaseID:PDS-FEATMGR-CT-XXXX Backup Query Response"));
-    TestBackupQueryResponseL();
-    
-    MainThreadCrS.Close();
-
-	}
-
-TInt E32Main()
-	{
-	TheTest.Title();
-	
-	CTrapCleanup* tc = CTrapCleanup::New();
-	
-	__UHEAP_MARK;
-	
-	TRAPD(err, DoTestsL());
-	TEST2(err, KErrNone);
-
-	__UHEAP_MARKEND;
-	
-	TheTest.End();
-	TheTest.Close();
-	
-	delete tc;
-	
-	User::Heap().Check();
-	return KErrNone;
-	}
--- a/featuremgmt/featuremgr/test/rtest/src/t_fmgrbadclient.cpp	Mon Mar 15 12:46:30 2010 +0200
+++ b/featuremgmt/featuremgr/test/rtest/src/t_fmgrbadclient.cpp	Thu Apr 01 00:19:42 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2009-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"
@@ -85,7 +85,7 @@
             }
         else
             {
-            RDebug::Print(_L("*** Expression evaluated to false. Line %d\r\n"), aLine);
+            TheTest.Printf(_L("*** Expression evaluated to false. Line %d\r\n"), aLine);
             }
         TheTest(EFalse, aLine);
         }
@@ -168,6 +168,7 @@
     void Close();
     TInt SendReceive(TInt aFunction);
     TInt SendReceive(TInt aFunction, const TIpcArgs& aArgs);
+    void SendReceive(TInt aFunction, const TIpcArgs& aArgs, TRequestStatus& aStatus);
 
 private:
     TInt DoCreateSession();
@@ -198,6 +199,11 @@
     return RSessionBase::SendReceive(aFunction, aArgs); 
     }
 
+void RTestFeatMgrSession::SendReceive(TInt aFunction, const TIpcArgs& aArgs, TRequestStatus& aStatus)
+    {
+    RSessionBase::SendReceive(aFunction, aArgs, aStatus); 
+    }
+
 TInt RTestFeatMgrSession::DoCreateSession()
     {
     const TInt KRetry( 2 );
@@ -236,7 +242,7 @@
     return err;
     }
     
-void PrintIterationCount(TInt aIteration)
+void PrintIterationCount(TInt aIteration, TBool aFromThread = EFalse)
     {
     if((aIteration % 100) == 0)
         {
@@ -245,7 +251,14 @@
         TDateTime dt = time.DateTime();
         TBuf<16> tbuf;
         tbuf.Format(_L("%02d:%02d:%02d.%06d"), dt.Hour(), dt.Minute(), dt.Second(), dt.MicroSecond());
-        RDebug::Print(_L("-----[%S] Test iterations: %d\r\n"), &tbuf, aIteration);
+        if(aFromThread)
+            {
+            RDebug::Print(_L("-----[%S] Test iterations: %d\r\n"), &tbuf, aIteration);
+            }
+        else
+            {
+            TheTest.Printf(_L("-----[%S] Test iterations: %d\r\n"), &tbuf, aIteration);
+            }
         }
     }
 
@@ -272,9 +285,7 @@
 
     while(++data.iIteration <= KTestIterCount)
         {
-        RDebug::Print(_L("++++ %d\r\n"), data.iIteration);
-        
-        PrintIterationCount(data.iIteration);
+        PrintIterationCount(data.iIteration, ETrue);
         TIpcArgs args;
         data.iFunction = Math::Rand(data.iSeed) % (EFeatMgrSWIEnd + 1);//EFeatMgrSWIEnd - the last server message number (without resource checking IPCs))
         for(TInt i=0;i<KMaxMessageArguments;++i)
@@ -309,7 +320,23 @@
         //Send arguments
         User::SetJustInTime(EFalse);
         TInt err = KErrNone;
-        err = sess.SendReceive(data.iFunction, args);
+        if(data.iFunction == EFeatMgrReqNotify)
+            {
+            TRequestStatus status;
+            sess.SendReceive(data.iFunction, args, status);
+            if(status == KRequestPending)
+                {
+                err = sess.SendReceive(EFeatMgrReqNotifyCancelAll);
+                }
+            else
+                {
+                err = status.Int();
+                }
+            }
+        else
+            {
+            err = sess.SendReceive(data.iFunction, args);
+            }
         if(err == KErrServerTerminated)
             {
             User::Panic(KPanicCategory, KPanicCode);
@@ -395,7 +422,7 @@
 
 void DoTestsL()
     {
-    //TODO: this test won't pass
+    //This test won't pass
     TheTest.Start(_L("@SYMTestCaseID:PDS-EFM-CT-4065 Bad client test"));
     BadClientTest();
     }
--- a/featuremgmt/featuremgr/test/rtest/src/t_fmgrnotify.cpp	Mon Mar 15 12:46:30 2010 +0200
+++ b/featuremgmt/featuremgr/test/rtest/src/t_fmgrnotify.cpp	Thu Apr 01 00:19:42 2010 +0300
@@ -21,8 +21,8 @@
 
 using namespace NFeature;
 
-const TUid KNewFeatureUid = {0x7888ABCD}; 
-const TUid KNewFeatureUid2 = {0x7888ABCF}; 
+const TUid KNewFeatureUid = {0x7888ABCA}; 
+const TUid KNewFeatureUid2 = {0x7888ABCB}; 
 
 ///////////////////////////////////////////////////////////////////////////////////////
 
--- a/featuremgmt/featuremgr/test/rtest/src/t_fmgroom.cpp	Mon Mar 15 12:46:30 2010 +0200
+++ b/featuremgmt/featuremgr/test/rtest/src/t_fmgroom.cpp	Thu Apr 01 00:19:42 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2009-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"
@@ -24,14 +24,6 @@
 
 using namespace NFeature;
 
-_LIT( KZOrgFeaturesFile, "Z:\\Private\\10205054\\features.dat" );
-#ifdef EXTENDED_FEATURE_MANAGER_TEST
-_LIT( KZFeaturesFile, "C:\\Private\\102836E5\\features.dat" );
-_LIT( KZFeaturesDir, "C:\\Private\\102836E5\\" );
-#else
-_LIT( KZFeaturesFile, "Z:\\Private\\10205054\\features.dat" );
-_LIT( KZFeaturesDir, "Z:\\Private\\10205054\\" );
-#endif // EXTENDED_FEATURE_MANAGER_TEST
 
 const TInt KInvalidFeatureId    = 90901671;
 const TUid KInvalidFeatureUid   = {KInvalidFeatureId};
@@ -39,8 +31,10 @@
 static TInt TheProcessHandleCount = 0;
 static TInt TheThreadHandleCount = 0;
 static TInt TheAllocatedCellsCount = 0;
+
+#ifdef _DEBUG
 static const TInt KBurstRate = 20;
-
+#endif
 
 enum TFeatMgrOomTestMode
     {
@@ -52,12 +46,7 @@
 
 static RTest TheTest(_L("t_fmgroom"));
 
-///////////////////////////////////////////////////////////////////////////////////////
 
-//Deletes all created test files.
-void DestroyTestEnv()
-    {
-    }
 
 ///////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////
@@ -66,7 +55,6 @@
     {
     if(!aValue)
         {
-        DestroyTestEnv();
         RDebug::Print(_L("*** Expression evaluated to false. Line %d\r\n"), aLine);
         TheTest(EFalse, aLine);
         }
@@ -75,7 +63,6 @@
     {
     if(aValue != aExpected)
         {
-        DestroyTestEnv();
         RDebug::Print(_L("*** Expected: %d, got: %d. Line %d\r\n"), aExpected, aValue, aLine);
         TheTest(EFalse, aLine);
         }
@@ -314,7 +301,8 @@
     const TUid KNewFeatureUid = {0x7888ABCE}; 
     TBitFlags32 flags;
     flags.Set(EFeatureSupported);
-    flags.Set(EFeatureModifiable);
+    flags.Set(EFeatureModifiable);    
+    flags.Set(EFeaturePersisted);
     TFeatureEntry fentry(KNewFeatureUid, flags, 0x0);
     
     err = KErrNoMemory;
@@ -529,53 +517,11 @@
     TheTest.Printf(_L("\r\n===OOM test succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo);
     }
 
-void PreTest()
-    {
-    // Connect session
-    RFs fsSession;
-    User::LeaveIfError(fsSession.Connect()); 
-    
-    TEntry entry;
-    TInt err = fsSession.Entry(KZFeaturesDir, entry);
-    if (err == KErrNotFound)
-        {
-        err = fsSession.MkDir(KZFeaturesDir);
-        }
-    TEST2 (err, KErrNone);
-    err = BaflUtils::CopyFile(fsSession, KZOrgFeaturesFile, KZFeaturesDir);
-    TEST2 (err, KErrNone);
-    
-    // close file server session
-    fsSession.Close();
 
-    }
-
-void PostTest()
-    {
-    // Connect session
-    RFs fsSession;
-    User::LeaveIfError(fsSession.Connect()); 
-    
-    TEntry entry;
-    TInt err = fsSession.Entry(KZFeaturesDir, entry);
-    TEST2 (err, KErrNone);
-    if (err == KErrNone)
-        {
-        //if not extended this is attempting to delte from the Z drive
-#ifdef EXTENDED_FEATURE_MANAGER_TEST
-        err = BaflUtils::DeleteFile(fsSession,KZFeaturesFile);
-        TEST2 (err, KErrNone);
-#endif        
-        }
-    // close file server session
-    fsSession.Close();
-    }
 
 void DoTestsL()
     {
-    
     TheTest.Start(_L("@SYMTestCaseID:PDS-EFM-CT-4068 RFeatureControl::Connect() OOM test"));
-    PreTest();
     ControlOpenOomTest(ETrue);
     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4069 RFeatureControl::Open() OOM test"));
     ControlOpenOomTest(EFalse);
@@ -639,8 +585,6 @@
     NotifierNotifyRequestsOomTest(EFeatMgrOomClientTestMode);
     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4093 CFeatureNotifier::NotifyRequest(<array>), valid feature, server side OOM test"));
     NotifierNotifyRequestsOomTest(EFeatMgrOomServerTestMode);
-    
-    PostTest();
     }
 
 TInt E32Main()
@@ -653,7 +597,6 @@
     __UHEAP_MARK;
     
     TRAPD(err, DoTestsL());
-    DestroyTestEnv();
     TEST2(err, KErrNone);
 
     __UHEAP_MARKEND;
--- a/featuremgmt/featuremgr/test/rtest/src/t_fmgrperformance.cpp	Mon Mar 15 12:46:30 2010 +0200
+++ b/featuremgmt/featuremgr/test/rtest/src/t_fmgrperformance.cpp	Thu Apr 01 00:19:42 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2009-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"
@@ -246,7 +246,7 @@
 @SYMTestExpectedResults Test must not fail
 @SYMDEF                 DEF144262
 */
-void FeatureManagerTest()
+void FeatureManagerTestL()
     {
     TUint32 start = User::FastCounter();
     FeatureManager::InitializeLibL();
@@ -271,7 +271,7 @@
     FeatureControlTest();
 
     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4107 FeatureManager performance test"));
-    FeatureManagerTest();
+    FeatureManagerTestL();
     }
 
 TInt E32Main()
--- a/featuremgmt/featuremgr/test/rtest/src/t_fmgrstartup.cpp	Mon Mar 15 12:46:30 2010 +0200
+++ b/featuremgmt/featuremgr/test/rtest/src/t_fmgrstartup.cpp	Thu Apr 01 00:19:42 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2009-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"
@@ -22,27 +22,35 @@
 static TInt TheThreadHandleCount = 0;
 static TInt TheAllocatedCellsCount = 0;
 
-#ifdef EXTENDED_FEATURE_MANAGER_TEST
+#ifdef _DEBUG
 static const TInt KBurstRate = 20;
 #endif
 
 ///////////////////////////////////////////////////////////////////////////////////////
 
 static RTest TheTest(_L("t_fmgrstartup"));
-_LIT( KZOrgFeaturesFile, "Z:\\Private\\10205054\\features.dat" );
+
 #ifdef EXTENDED_FEATURE_MANAGER_TEST
-_LIT( KZFeaturesFile, "C:\\Private\\102836E5\\features.dat" );
-_LIT( KZFeaturesDir, "C:\\Private\\102836E5\\" );
-#else
-_LIT( KZFeaturesFile, "Z:\\Private\\10205054\\features.dat" );
-_LIT( KZFeaturesDir, "Z:\\Private\\10205054\\" );
-#endif // EXTENDED_FEATURE_MANAGER_TEST
+_LIT( KZOrgFeaturesFile, "Z:\\Private\\10205054\\features.dat" );
+_LIT( KFeaturesFile, "C:\\Private\\102836E5\\features.dat" );
+_LIT( KFeaturesDir, "C:\\Private\\102836E5\\" );
+#endif
 
 ///////////////////////////////////////////////////////////////////////////////////////
 
 //Deletes all created test files.
 void DestroyTestEnv()
     {
+    //KFeaturesDir is defined only if EXTENDED_FEATURE_MANAGER_TEST is defined     
+#ifdef EXTENDED_FEATURE_MANAGER_TEST
+    RFs fs;
+    TInt err = fs.Connect();
+    if(err == KErrNone)
+        {
+        (void)fs.Delete(KFeaturesFile);
+        }
+    fs.Close();
+#endif        
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////
@@ -132,7 +140,6 @@
 @SYMDEF                 DEF144262
 */
 void FeatMgrServerStartupOomTest()
-//TODO - panics in CFeatMgrServer::LoadPluginsL() because the error is KErrNoMemory
     {
     TInt err = KErrNoMemory;
     TInt failingAllocationNo = 0;
@@ -171,10 +178,10 @@
         TheTest.Printf(_L("===Iteration %d. Simulated error:\r\n"), cnt);       
         for (TInt fsError=KErrNotFound;fsError>=KErrBadName;--fsError)
             {
-            if(fsError == KErrNotFound || fsError == KErrCorrupt || fsError == KErrPathNotFound || fsError == KErrEof)
-                {
-                continue;//TODO: the server code panics
-                }
+//            if(fsError == KErrNotFound || fsError == KErrCorrupt || fsError == KErrPathNotFound || fsError == KErrEof)
+//                {
+//                continue;//The server code panics
+//                }
             TheTest.Printf(_L("%d "), fsError);
             (void)fs.SetErrorCondition(fsError, cnt);
             TRAP(err, CreateAndDestroyFeatMgrServerL());
@@ -186,45 +193,23 @@
     TheTest.Printf(_L("\r\n===File I/O error simulation test succeeded on iteration %d===\r\n"), cnt);
     }
 
-void PreTest()
+void CreateTestEnv()
     {
-    // Connect session
-    RFs fsSession;
-    User::LeaveIfError(fsSession.Connect()); 
+    //KFeaturesDir is defined only if EXTENDED_FEATURE_MANAGER_TEST is defined     
+#ifdef EXTENDED_FEATURE_MANAGER_TEST    
+    RFs fs;
+    TInt err = fs.Connect();
+    TEST2(err, KErrNone);
     
-    TEntry entry;
-    TInt err = fsSession.Entry(KZFeaturesDir, entry);
-    if (err == KErrNotFound)
-        {
-        err = fsSession.MkDir(KZFeaturesDir);
-        }
-    TEST2 (err, KErrNone);
-    err = BaflUtils::CopyFile(fsSession, KZOrgFeaturesFile, KZFeaturesDir);
+    err = fs.MkDir(KFeaturesDir);
+    TEST (err == KErrNone || err == KErrAlreadyExists);
+    
+    (void)fs.Delete(KFeaturesFile);
+    err = BaflUtils::CopyFile(fs, KZOrgFeaturesFile, KFeaturesDir);
     TEST2 (err, KErrNone);
     
-    // close file server session
-    fsSession.Close();
-
-    }
-
-void PostTest()
-    {
-    // Connect session
-    RFs fsSession;
-    User::LeaveIfError(fsSession.Connect()); 
-    
-    TEntry entry;
-    TInt err = fsSession.Entry(KZFeaturesDir, entry);
-    if (err == KErrNone)
-        {
-        err = BaflUtils::DeleteFile(fsSession,KZFeaturesFile);
-        TEST2 (err, KErrNone);
-        
-        }
-    TEST2 (err, KErrNone);
-    
-    // close file server session
-    fsSession.Close();
+    fs.Close();
+#endif
     }
 
 void DoTestsL()
@@ -234,12 +219,10 @@
     CActiveScheduler::Install(scheduler);
     
     TheTest.Start(_L("@SYMTestCaseID:PDS-EFM-CT-4109 CFeatMgrServer::NewLC() OOM test"));
-    PreTest();
     FeatMgrServerStartupOomTest();
 
     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4110 CFeatMgrServer::NewLC() file I/O error simulation test"));
     FeatMgrServerStartupFileIoTest();
-    PostTest();
     
     delete scheduler;
     }
@@ -253,6 +236,7 @@
     
     __UHEAP_MARK;
     
+    CreateTestEnv();
     TRAPD(err, DoTestsL());
     DestroyTestEnv();
     TEST2(err, KErrNone);
--- a/featuremgmt/featuremgr/test/rtest/src/t_fmgrswi.cpp	Mon Mar 15 12:46:30 2010 +0200
+++ b/featuremgmt/featuremgr/test/rtest/src/t_fmgrswi.cpp	Thu Apr 01 00:19:42 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2009-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"
@@ -99,9 +99,25 @@
 
 /**
 @SYMTestCaseID          PDS-EFM-CT-4111
-@SYMTestCaseDesc        
+@SYMTestCaseDesc        The test demonstrates that there is a problem in the FeatMgr code that processes SWI events.
+                        Test steps:
+                        1) The test sets KSAUidSoftwareInstallKeyValue property in order to simulate that SWI has started.
+                        2) The test calls RFeatureControl::SWIStart() to notify the server that SWI started.
+                        3) The test adds a new feature. Since this happens during the SWI process the new feature
+                           will be cached by the FeatMgr server.
+                        4) The test simulates a file I/O error to happen on iteration #4. The failure should occur
+                           at the moment when the server tries to persist the new feature that is in the cache.
+                        5) The test notifies the server that SWI has completed: KSAUidSoftwareInstallKeyValue value set
+                           and RFeatureControl::SWIEnd() called.
+                           When the server receives the "end of SWI" notification, the server will try to persist
+                           the cached new feature. But because of the simulated file I/O error the server will fail
+                           to store the new feature to the features.dat file. But in accordance with the current
+                           design of the server, no error will be reported back to the client.
+                        6) The test kills the FeatMgr server. The server cache is gone.
+                        7) The test restarts the server and attempts to request the new feature. The new feature
+                           is missing.
 @SYMTestPriority        High
-@SYMTestActions         
+@SYMTestActions         FeatMgr SWI test with simulated file I/O error during SWI.
 @SYMTestExpectedResults Test must not fail
 @SYMDEF                 DEF144262
 */
--- a/featuremgmt/featuremgr/test/tef/tef_efm_configured/src/plugin_test_steps.cpp	Mon Mar 15 12:46:30 2010 +0200
+++ b/featuremgmt/featuremgr/test/tef/tef_efm_configured/src/plugin_test_steps.cpp	Thu Apr 01 00:19:42 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"
@@ -51,7 +51,7 @@
 
 CRefPluginsTest::CRefPluginsTest()
 	{
-	SetTestStepName( KPluginCapabilitiesTest );
+	SetTestStepName( KRefPluginsTest );
 	}
 
 TVerdict CRefPluginsTest::doTestStepL()
--- a/loggingservices/eventlogger/LogCli/src/LogCliServerShared.cpp	Mon Mar 15 12:46:30 2010 +0200
+++ b/loggingservices/eventlogger/LogCli/src/LogCliServerShared.cpp	Thu Apr 01 00:19:42 2010 +0300
@@ -250,8 +250,8 @@
 @return    Format string for this locale. */
 EXPORT_C const TDesC& LogUtils::DateFormatForLocale()
 	{
-	_LIT(KSQLDateFormatColon,"%D%*M%Y%1 %2 %3 %H:%T:%S"); 
-	_LIT(KSQLDateFormatDot,"%D%*M%Y%1 %2 %3 %H.%T.%S"); 
+    _LIT(KSQLDateFormatColon,"%D%*M%Y%1 %2 %3 %H:%T:%S%.%C"); 
+    _LIT(KSQLDateFormatDot,"%D%*M%Y%1 %2 %3 %H.%T.%S%.%C");
 
 	TLocale current; 
 	TBool dateSeparatorIsColon=EFalse;
--- a/loggingservices/eventlogger/LogServ/inc/LogServSqlStrings.h	Mon Mar 15 12:46:30 2010 +0200
+++ b/loggingservices/eventlogger/LogServ/inc/LogServSqlStrings.h	Thu Apr 01 00:19:42 2010 +0300
@@ -52,8 +52,8 @@
 CONST_LIT(KLogSqlUpdateTypeString, "UPDATE Type SET Description = '%S', Enabled = %d WHERE UId = %d") ;
 CONST_LIT(KLogSqlDeleteTypeString, "DELETE FROM Type WHERE UId = %d") ;
 //
-CONST_LIT(KLogSqlSelectOldestString, "SELECT Id FROM Event WHERE ETime <= #%S#") ;
-CONST_LIT(KLogSqlDeleteOldestString, "DELETE FROM Event WHERE ETime <= #%S#") ;
+CONST_LIT(KLogSqlSelectOldestString, "SELECT Id FROM Event WHERE ETime < #%S#") ;
+CONST_LIT(KLogSqlDeleteOldestString, "DELETE FROM Event WHERE ETime < #%S#") ;
 CONST_LIT(KLogSqlSelectAllRecent,    "SELECT Id, Recent, Duplicate FROM Event") ;
 CONST_LIT(KLogSqlSelectDuplicateString, "SELECT Id, Duplicate FROM EVENT WHERE Recent = %d %S AND NOT Id = %d ORDER BY Id DESC") ;
 CONST_LIT(KLogSqlGetRecent, "SELECT Id FROM Event WHERE Recent = %d AND Duplicate IS NULL ORDER BY Id DESC") ;
--- a/loggingservices/eventlogger/test/inc/SecurityPolicy.h	Mon Mar 15 12:46:30 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-// Copyright (c) 2005-2009 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"
-// which accompanies this distribution, and is available
-// at the URL "http://www.eclipse.org/legal/epl-v10.html".
-//
-// Initial Contributors:
-// Nokia Corporation - initial contribution.
-//
-// Contributors:
-//
-// Description:
-//
-
-#ifndef __SECURITYPOLICY_H__
-#define __SECURITYPOLICY_H__
-
-#include <e32std.h>
-
-/**
-TCompiledSecurityPolicy is a test class used for accessing private data members
-of TSecurityPolicy class. It uses the fact that TSecurityPolicy class has a friend class, 
-which name is TCompiledSecurityPolicy.
-@internalComponent
-*/
-class TCompiledSecurityPolicy
-	{
-public:
-	TCompiledSecurityPolicy(const TSecurityPolicy& aSecurityPolicy) :
-		iSecurityPolicy(aSecurityPolicy)
-		{
-		}
-	TSecurityPolicy::TType Type() const
-		{
-		return static_cast <TSecurityPolicy::TType> (iSecurityPolicy.iType);
-		}
-	TUint32 SecureId() const
-		{
-		return iSecurityPolicy.iSecureId;
-		}
-	TUint32 VendorId() const
-		{
-		return iSecurityPolicy.iVendorId;
-		}
-	TCapability Capability(TInt aIndex) const
-		{
-		if(aIndex < 3)
-			{
-			return static_cast <TCapability> (iSecurityPolicy.iCaps[aIndex]);
-			}
-		else if(aIndex < 7)
-			{
-			return static_cast <TCapability> (iSecurityPolicy.iExtraCaps[aIndex - 3]);
-			}
-		User::Invariant();
-		return ECapability_None;
-		}
-
-private:
-	const TSecurityPolicy& iSecurityPolicy;
-
-	};
-
-inline TBool operator==(const TCompiledSecurityPolicy& aLeft, const TCompiledSecurityPolicy& aRight)
-	{
-	return aLeft.Type() == aRight.Type() && 
-	       aLeft.SecureId() == aRight.SecureId() &&
-	       aLeft.VendorId() == aRight.VendorId() &&
-	       aLeft.Capability(0) == aRight.Capability(0) &&
-	       aLeft.Capability(1) == aRight.Capability(1) &&
-	       aLeft.Capability(2) == aRight.Capability(2) &&
-	       aLeft.Capability(3) == aRight.Capability(3) &&
-	       aLeft.Capability(4) == aRight.Capability(4) &&
-	       aLeft.Capability(5) == aRight.Capability(5) &&
-	       aLeft.Capability(6) == aRight.Capability(6);
-	}
-
-#endif//__SECURITYPOLICY_H__
--- a/loggingservices/eventlogger/test/inc/TEST.H	Mon Mar 15 12:46:30 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,347 +0,0 @@
-// Copyright (c) 2002-2009 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"
-// which accompanies this distribution, and is available
-// at the URL "http://www.eclipse.org/legal/epl-v10.html".
-//
-// Initial Contributors:
-// Nokia Corporation - initial contribution.
-//
-// Contributors:
-//
-// Description:
-//
-
-#ifndef __TEST_H__
-#define __TEST_H__
-
-#include <e32test.h>
-#include <s32file.h>
-#include <logcli.h>
-#include <logengdurations.h>
-#include <logengevents.h>
-#include <logwraplimits.h>
-#include <logfilterandeventconstants.hrh>
-#include <e32base.h>
-#include <f32file.h>
-#include <logviewchangeobserver.h>
-#include <logclientchangeobserver.h>
-#include "LogChangeDefinition.h"
-#include "LogServShared.h"
-#include "LogCliServShared.h"
-#include <babackup.h>
-#include "t_logservsession.h"
-#include "logcntdef.h"
-
-#ifdef LOGGING_ENABLED
-
-#include <f32file.h>
-#include <flogger.h>
-
-
-
-_LIT(KLogFileName, "LogEng.txt");
-_LIT(KLogFolder,   "LogEng");
-_LIT(KTimeFormat, "%02d.%02d:%02d:%06d    ");
-_LIT(KTextFormat, "%S");
-const TInt KLogEngLogBufferSize = 256;
-
-class Log : public RFileLogger
-	{
-public:
-	static void New();
-	static void Write(const TDesC& aText);
-	static void WriteFormat(TRefByValue<const TDesC> aFmt, ...);
-private:
-	static void PruneLogFile();
-  };
-
-#define LOGNEW							Log::New()
-#define LOGTEXT(AAA)					{ _LIT(KString, AAA); Log::Write(KString); }
-#define LOGTEXT2(AAA, BBB)				{ _LIT(KString, AAA); Log::WriteFormat(TRefByValue<const TDesC>(KString()), BBB); }
-#define LOGTEXT3(AAA, BBB, CCC)			{ _LIT(KString, AAA); Log::WriteFormat(TRefByValue<const TDesC>(KString()), BBB, CCC); }
-#define LOGTEXT4(AAA, BBB, CCC, DDD)	{ _LIT(KString, AAA); Log::WriteFormat(TRefByValue<const TDesC>(KString()), BBB, CCC, DDD); }
-
-#else//LOGGING_ENABLED
-
-#define LOGNEW
-#define LOGTEXT(AAA)
-#define LOGTEXT2(AAA, BBB)
-#define LOGTEXT3(AAA, BBB, CCC)
-#define LOGTEXT4(AAA, BBB, CCC, DDD)
-
-#endif//LOGGING_ENABLED
-
-//======================================================================================================
-
-#define TEST_STRING(s) _S(s)
-
-//======================================================================================================
-
-//TheTest object must be defined in the main test cpp file.
-GLREF_D RTest test;
-
-void LogTestBoolExpr(TBool aRes, const TText* aFile, TInt aLine);
-void LogCheck(TInt aValue, TInt aExpected, const TText* aFile, TInt aLine);
-void LogCheckU(TUint aValue, TUint aExpected, const TText* aFile, TInt aLine);
-
-#define TEST(arg)                   LogTestBoolExpr(arg, TEST_STRING(__FILE__), __LINE__)
-#define TEST2(aValue, aExpected)    LogCheck(aValue, aExpected, TEST_STRING(__FILE__), __LINE__)
-#define TEST2U(aValue, aExpected)   LogCheckU(aValue, aExpected, TEST_STRING(__FILE__), __LINE__)
-
-//======================================================================================================
-
-void LogLeave(TInt aErr, const TText* aFile, TInt aLine);
-
-#define LEAVE(err)           LogLeave(err, TEST_STRING(__FILE__), __LINE__)
-#define LEAVE_IF_ERROR(err)  do {if(err < KErrNone) LogLeave(err, TEST_STRING(__FILE__), __LINE__);} while(0)
-
-//======================================================================================================
-
-void LogPanic(const TDesC& aCategory, TInt aErr, const TText* aFile, TInt aLine);
-
-#define PANIC(cat, err)     LogPanic(cat, err, TEST_STRING(__FILE__), __LINE__)
-
-//======================================================================================================
-
-// Globals 
-GLREF_D CTrapCleanup* theCleanup;
-GLREF_D CActiveScheduler *testScheduler;
-GLREF_D RFs theFs;
-GLREF_D TFileName theLogName;
-GLREF_D RFile theLog;
-GLREF_D RLogTestSession theLogServ;
-
-#define __FILE_FAILNEXT(X) theFs.SetErrorCondition(KErrGeneral, X)
-#define __FILE_RESET theFs.SetErrorCondition(KErrNone, 0)
-
-#if defined(_UNICODE)
-	_LIT(KLogDatabaseName,"c:\\private\\101f401d\\Logdbu.dat");
-#else
-	_LIT(KLogDatabaseName,"c:\\private\\101f401d\\Logdb.dat");
-#endif
-
-
-//**********************************
-// CTestActive
-//**********************************
-
-class CTestActive : public CActive
-	{
-public:
-	CTestActive(TInt aPriority = EPriorityIdle-100);
-	~CTestActive();
-	void StartL();
-	void StartL(TInt);
-protected:
-	void DoCancel();
-	void RunL();
-private:
-	TBool iDelayCompletion;
-	TRequestStatus iStoredStatus;
-	TInt iDelayTime;
-	};
-
-void doTestsL();
-
-
-//**********************************
-// CTestTimer
-//**********************************
-
-class CTestTimer : public CTimer
-	{
-public:
-	static CTestTimer* NewL();
-private:
-	CTestTimer();
-	void RunL();	
-	};
-
-//**********************************
-// TestUtils
-//**********************************
-
-class TestUtils
-	{
-public:
-	static void Initialize(const TDesC& aName);
-	static void DeleteDatabaseL(TBool aCloseBeforeDelete = ETrue);
-	static HBufC* CreateBufLC(TInt aLength);
-	static HBufC8* CreateBuf8LC(TInt aLength);
-	static TBool FiltersEqual(const CLogFilter& aFilter1, const CLogFilter& aFilter2);
-	static TBool EventsEqual(const CLogEvent& aEvent1, const CLogEvent& aEvent2);
-	static TBool TypesEqual(const CLogEventType& aType1, const CLogEventType& aType2);
-	static TBool WaitForKeyL(TTimeIntervalMicroSeconds32 aDelay, TKeyCode& aKeyCode);
-	static TBool FileExists(const TDesC& aFile);
-	static void SetLogServHeapFailureL(RHeap::TAllocFail aType, TInt aRate);
-	static TBool IsDatabaseOpenL();
-	static TInt DatabaseSizeL();
-	static TInt AddEventL();
-	static void AddViewTestEventsL();
-	static void AddEventTypeL();
-	static void CopyCorruptDbL();
-	static void CopyCorruptDamagedDbL();
-	static void CopyOldDbL();
-	static void TestInvalidSchemaL();
-	static TBool MatchingEnabledL();
-
-private:
-	// starts t_HiCapHelper.exe which has sufficient capability
-    static TInt ExecuteRemoteL(const TDesC& aCommandLineArg);
-	};
-
-#define __LOGSERV_UHEAP_FAILNEXT(X) TestUtils::SetLogServHeapFailureL(RHeap::EFailNext, X)
-#define __LOGSERV_UHEAP_RESET TestUtils::SetLogServHeapFailureL(RHeap::ENone, 0)
-
-//**********************************
-// CLogViewChangeObserver
-//**********************************
-
-class CLogViewChangeObserver : public CActive, public MLogViewChangeObserver
-	{
-public:
-	enum TStopType
-		{
-		EStopOnChanges = 0,
-		EStopOnRunL,
-		EStopOnBoth,
-		EStopOnCount,
-		EDontStopScheduler
-		};
-public:
-	static CLogViewChangeObserver* NewLC();
-	~CLogViewChangeObserver();
-
-protected:
-	CLogViewChangeObserver();
-
-public:
-	inline void StartCollectingChanges() 
-		{ 
-		Reset(); 
-		iType = EDontStopScheduler; 
-		}
-	CLogChangeDefinition* WaitForChangesLC(TStopType aType = EStopOnChanges, TInt aCount = 0);
-	CLogChangeDefinition* WaitForChangesLC(TCallBack aCallBack, TStopType aType, TInt aCount = 0);
-	inline TBool HaveChanges() const 
-		{ 
-		return iChanges != NULL; 
-		}
-	inline const CLogChangeDefinition& Changes() const 
-		{ 
-		__ASSERT_ALWAYS(iChanges, User::Invariant()); 
-		return *iChanges; 
-		}
-	inline void SetActive() 
-		{ 
-		CActive::SetActive(); 
-		iStatus = KRequestPending; 
-		}
-	inline void ResetChanges() 
-		{ 
-		__ASSERT_ALWAYS(iChanges, User::Invariant()); 
-		iChanges->Reset(); 
-		}
-
-public:
-	void HandleLogViewChangeEventAddedL(TLogId aId,   TInt aViewIndex, TInt aChangeIndex, TInt aTotalChangeCount);
-	void HandleLogViewChangeEventChangedL(TLogId aId, TInt aViewIndex, TInt aChangeIndex, TInt aTotalChangeCount);
-	void HandleLogViewChangeEventDeletedL(TLogId aId, TInt aViewIndex, TInt aChangeIndex, TInt aTotalChangeCount);
-
-private:
-	void RunL();
-	void DoCancel();
-
-private:
-	void Reset();	 
-
-protected:
-	void CheckForSchedulerStop();
-	void AddChangeL(TLogDatabaseChangeType aType, TLogId aId, TInt aViewIndex);
- 	
-private:
-	TInt iExpectedChangeCount;
-	TBool iHaveFinishedOperation;
-	TBool iHaveObtainedChanges;
-	TBool iSchedulerStarted;
-	TStopType iType;
-	CLogChangeDefinition* iChanges;
-	TBool iHaveCallBack;
-	TCallBack iCallBack;
-	};
-
-//**********************************
-// CLogViewChangeObserverErrorTest
-//**********************************
-
-class CLogViewChangeObserverErrorTest : public  CLogViewChangeObserver 
-	{
-public:
-	static CLogViewChangeObserverErrorTest* NewLC();
-
-private:
-	CLogViewChangeObserverErrorTest();
-
-public:
-	void HandleLogViewChangeEventAddedL(TLogId aId,   TInt aViewIndex, TInt aChangeIndex, TInt aTotalChangeCount);
-	};
-
-
-//**********************************
-// CLogSchedulerTimer
-//**********************************
-
-class CLogSchedulerTimer : public CTimer
-	{
-public:
-	static CLogSchedulerTimer* NewLC();
-	~CLogSchedulerTimer();
-
-private:
-	CLogSchedulerTimer();
-	void ConstructL();
-
-public:
-	void Wait(TTimeIntervalMicroSeconds32 aTime);
-
-private:
-	void RunL();
-	};
-
-//**********************************
-// CLogChangeNotifier
-//**********************************
-
-class CLogChangeNotifier : public CActive
-	{
-public:
-	static CLogChangeNotifier* NewL();
-	~CLogChangeNotifier();
-	//
-private:
-	CLogChangeNotifier();
-	void ConstructL();
-	//
-	void RunL();
-	void DoCancel();
-	//
-private:
-	CLogClient* iClient;
-	TTime iStart;
-	};
-
-//**********************************
-// Global
-//**********************************
-
-void SetupSchedulerL();
-void CloseScheduler();
-void doMainL();
-TInt E32Main();
-void DeleteDataFile(const TDesC& aFullName);
-void LogCheck(TInt aValue, TInt aExpected, TInt aLine);
-void LogCheckU(TUint aValue, TUint aExpected, TInt aLine);
-
-#endif//__TEST_H__
--- a/loggingservices/eventlogger/test/src/t_OrderById.CPP	Mon Mar 15 12:46:30 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,223 +0,0 @@
-// Copyright (c) 2004-2009 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"
-// which accompanies this distribution, and is available
-// at the URL "http://www.eclipse.org/legal/epl-v10.html".
-//
-// Initial Contributors:
-// Nokia Corporation - initial contribution.
-//
-// Contributors:
-//
-// Description:
-// test code for INC045441 - Log Engine does not return events in sequence order
-// 
-//
-
-#include <s32file.h>
-#include <e32math.h>
-#include <logview.h>
-#include "TEST.H"
-
-RTest test( _L( "Test sequence order of returned events" ) );
-
-_LIT( KTestNumber1, "11111" );
-_LIT( KTestNumber2, "22222" );
-_LIT( KTestNumber3, "33333" );
-
-#undef test  //there is a "test" macro which hides "RTest test" declaration.
-
-/**
-Add an event to the log engine database.
-The event ID assigned by logengine is store in gTheId 
-
-@param  aClient 
-@param  aNumber The number that the event should contain
-@return The index for the event added.
-  
-*/
-LOCAL_C TInt AddEventL( CLogClient& aClient, CLogEvent& aEvent, CTestActive& aActive, TInt aIndex )
-	{
-	TInt returnId = KLogNullId;
-
-	// Reset
-	TTime now;
-	now.UniversalTime();
-
-	aEvent.SetContact( aIndex );
-
-	// load the event with test values
-	switch (aIndex)
-		{
-	case 1:
-		aEvent.SetNumber( KTestNumber1 );
-		break;
-	case 2:
-		aEvent.SetNumber( KTestNumber2 );
-		break;
-	case 3:
-		aEvent.SetNumber( KTestNumber3 );
-		break;
-		}
-
-	// add the event to the logeng database
-	aActive.StartL();
-	aClient.AddEvent( aEvent, aActive.iStatus );
-	CActiveScheduler::Start();
-	TEST2(aActive.iStatus.Int(), KErrNone);
-
-	// check that an ID has been assigned
-	returnId = aEvent.Id();
-	TEST( returnId != KLogNullId );
-	TEST( aEvent.Time() >= now );
-	
-	// return the event id which has been assigned by the 
-	// log engine
-	return returnId;
-	}
-
-
-/**
-Get the event from the log engine database.
- 
-@param aClient 
-@param aTheId Unique id for the event to be fetch
-@param aNumber The number that the event should contain
-*/
-LOCAL_C void TestGetEventL( CLogClient& aClient, TInt aTheId, TInt aIndex )
-
-	{
-	CTestActive* active = new( ELeave )CTestActive();
-	CleanupStack::PushL( active );
-
-	CLogEvent* event = CLogEvent::NewL();
-	CleanupStack::PushL( event );
-
-	event->SetId( aTheId );
-
-	active->StartL();
-	aClient.GetEvent( *event, active->iStatus );
-	CActiveScheduler::Start();
-	TEST2(active->iStatus.Int(), KErrNone);
-
-	// check we got the right one back
-	TEST( event->Contact() == aIndex );
-
-	TPtrC eventNumber = event->Number();
-
-	TBuf<30> dateString;
-	_LIT( KDateString5, "%-B%:0%J%:1%T%:2%S%:3%+B" );
-	event->Time().FormatL( dateString, KDateString5 );
-	TPtrC eventDate = dateString.Ptr();
-	test.Printf( _L( "Id:%d No:%S Time:%S \n" ), event->Id(), &eventNumber, &eventDate );
-	
-	CleanupStack::PopAndDestroy( 2 ); // event, active
-	}
-
-/**
-Test code for INC045441 - Log Engine does not return events in sequence order
-
-@SYMTestCaseID          SYSLIB-LOGENG-CT-1020
-@SYMTestCaseDesc	    Tests for checking the sequence order on events returned by log engine
-@SYMTestPriority 	    High
-@SYMTestActions  	    Test for getting the event in order as they were added to the log
-                        Check for memory and no error
-@SYMTestExpectedResults Test must not fail
-@SYMREQ                 REQ0000
-*/	
-LOCAL_C void TestRecentViewOrderingL( CLogClient& aClient )
-//
-//
-//
-	{
-	test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1020 "));
-	CLogEvent* event = CLogEvent::NewL();
-	CleanupStack::PushL(event);
-
-	CTestActive* active = new( ELeave )CTestActive();
-	CleanupStack::PushL( active );
-
-	CLogViewRecent* view = CLogViewRecent::NewL( aClient );
-	CleanupStack::PushL( view );
-
-	TBuf<KLogMaxDirectionLength> buf;
-	aClient.GetString(buf, R_LOG_DIR_MISSED);
-
-	event->SetEventType( KLogCallEventTypeUid );
-	event->SetDirection( buf );
-
-	TEST( !view->SetRecentListL( KLogRecentMissedCalls, active->iStatus ) );
-	TEST( view->CountL() == 0 );
-
-	TTime time;
-	test.Next( _L( "add new event 1" ) );
-	TInt eventId1 = AddEventL( aClient, *event, *active, 1 );
-	TestGetEventL( aClient, eventId1, 1 );
-
-	test.Next( _L( "time plus 10 mins - add new event 2" ) );
-	time.HomeTime();
-	TTimeIntervalMinutes timeTravelForward( 10 );
-	time += timeTravelForward;
-	User::SetHomeTime( time );
-	TInt eventId2 = AddEventL( aClient, *event, *active, 2 );
-	TestGetEventL( aClient, eventId2, 2 );
-
-	test.Next( _L( "time minus 5 mins - add new event 3" ) );
-	time.HomeTime();
-	TTimeIntervalMinutes timeTravelBackward( 5 );
-	time -= timeTravelBackward;
-	User::SetHomeTime( time );
-	TInt eventId3 = AddEventL( aClient, *event, *active, 3 );
-	TestGetEventL( aClient, eventId3, 3 );
-
-	TEST( view->CountL() == 3 );
-
-	active->StartL();
-	// Get most recent
-	TEST( view->FirstL( active->iStatus ) );
-	CActiveScheduler::Start();
-	TEST2(active->iStatus.Int(), KErrNone);
-
-	TInt id3 = view->Event().Id();
-	// Get the one before that
-	active->StartL();
-	TEST( view->NextL( active->iStatus ) );
-	CActiveScheduler::Start();
-	TEST2(active->iStatus.Int(), KErrNone);
-	TInt id2 = view->Event().Id();
-
-	// Get the one before that
-	active->StartL();
-	TEST( view->NextL( active->iStatus ) );
-	CActiveScheduler::Start();
-	TEST2(active->iStatus.Int(), KErrNone);
-	TInt id1 = view->Event().Id();
-
-	TEST( id1 == eventId1 );
-	TEST( id2 == eventId2 );
-	TEST( id3 == eventId3 );
-
-	CleanupStack::PopAndDestroy( 3 ); // view, active, event
-	theLog.Write( _L8( "Test 1.1 OK\n" ) );
-	}
-
-	
-	
-void doTestsL()
-	{
-	TestUtils::Initialize( _L( "T_OrderById" ) );
-	TestUtils::DeleteDatabaseL();
-
-	CLogClient* client = CLogClient::NewL( theFs );
-	CleanupStack::PushL( client );
-
-	CLogChangeNotifier* notifier = CLogChangeNotifier::NewL();
-	CleanupStack::PushL( notifier );
-
-	test.Start( _L( "Recent view sorts by Id not ETime" ) );
-	TestRecentViewOrderingL( *client );
-	theLog.Write( _L8( "Test 1 OK\n" ) );
-
-	CleanupStack::PopAndDestroy( 2 ); // notifier, client;
-	}
--- a/loggingservices/eventlogger/test/src/t_logview2.cpp	Mon Mar 15 12:46:30 2010 +0200
+++ b/loggingservices/eventlogger/test/src/t_logview2.cpp	Thu Apr 01 00:19:42 2010 +0300
@@ -6785,6 +6785,102 @@
 	CleanupStack::PopAndDestroy(4);	
 }
 
+/**
+@SYMTestCaseID          PDS-LOGENG-CT-4050
+@SYMTestCaseDesc        Tests for the changes made in defect DEF144552 
+@SYMTestPriority        High
+@SYMTestActions         Tests for the sucessful completion of the following operation - 
+                        1)Applying a filter where the event's start time matches the end time.
+                        2)Clearing the log where the clear log time is 1 microsecs after the 
+                        timestamp of the event.
+@SYMTestExpectedResults Test must not fail
+@SYMREQ                 DEF144552
+*/
+LOCAL_C void DEF144552L(CLogClient& aClient)
+    {
+    TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-CT-4050 ")); 
+    TestUtils::DeleteDatabaseL(EFalse);
+    
+    CTestActive* active = new(ELeave)CTestActive();
+    CleanupStack::PushL(active);
+
+    //Setup the database by adding a event and changing the timestamp for the event
+    //Add 1 event
+    CLogEvent* event = CLogEvent::NewL();
+    CleanupStack::PushL(event);
+    event->SetEventType(KLogCallEventTypeUid);
+    event->SetContact(KTestContact1);
+    event->SetNumber(KTestNumber2);
+    event->SetDuration(0);
+    active->StartL();
+    aClient.AddEvent(*event, active->iStatus);
+    CActiveScheduler::Start();
+    TEST2(active->iStatus.Int(), KErrNone);
+    
+    //Change the event
+    TTime now;
+    now.UniversalTime();
+    event->SetTime(now);
+    active->StartL();
+    aClient.ChangeEvent(*event, active->iStatus);
+    CActiveScheduler::Start();
+    TEST2(active->iStatus.Int(), KErrNone);
+    
+    //Test 1: Setup and apply a filter where the start time matches the end time
+    //If the defect is fixed then the view will contain the event previously added,
+    //Otherwise the time parameters will be truncated and the event will not be found
+    
+    //Setup filter so that the start and the end time matches
+    CLogFilter* filter = CLogFilter::NewL();
+    CleanupStack::PushL(filter);
+    filter->SetStartTime(now);
+    filter->SetEndTime(now);
+    
+    //Apply the filter and check that 1 event is in the view
+    CLogViewEvent* view = CLogViewEvent::NewL(aClient);
+    CleanupStack::PushL(view);
+    active->StartL();
+    TEST(view->SetFilterL(*filter, active->iStatus));
+    CActiveScheduler::Start();
+    TEST2(active->iStatus.Int(), KErrNone);
+    TEST2(view->CountL(), 1);
+    
+    //Retrieve and check the event
+    active->StartL();
+    TEST(view->FirstL(active->iStatus));
+    CActiveScheduler::Start();
+    TEST2(active->iStatus.Int(), KErrNone);
+    const CLogEvent& currentEvent(view->Event());
+    TEST2(currentEvent.EventType().iUid, KLogCallEventTypeUid.iUid);
+    TEST2(currentEvent.Duration(), 0);
+    TEST2(currentEvent.Time().Int64(), now.Int64());
+    
+    // Test 2: Clearing a log where the time specified in ClearLog() is just
+    // after the timestamp of the event by 1 microsecond. If the defect is fixed
+    // then the event will be deleted. However if the defect is not fixed then the
+    // time specified in ClearLog() will be truncated and the event will not be 
+    // deleted
+    
+    //Clear the log
+    active->StartL();
+    TTimeIntervalMicroSeconds microsecond(1);
+    now += microsecond;
+    aClient.ClearLog(now, active->iStatus);
+    CActiveScheduler::Start();
+    TEST2(active->iStatus.Int(), KErrNone);
+    
+    //Check that the event has been deleted in the view
+    CleanupStack::PopAndDestroy(2);
+    view = CLogViewEvent::NewL(aClient);
+    CleanupStack::PushL(view);
+    filter = CLogFilter::NewL();
+    CleanupStack::PushL(filter);
+    active->StartL();
+    TEST(!view->SetFilterL(*filter, active->iStatus));
+
+    CleanupStack::PopAndDestroy(4, active); 
+    }
+
 void doTestsL()
 	{
 	TestUtils::Initialize(_L("t_logview2"));
@@ -6910,5 +7006,9 @@
 	TestOtherFieldsINC108225L(*client);
 	theLog.Write(_L8("Test 23 OK\n"));
 
+	TheTest.Next(_L("Test Defect DEF144552: CLogFilter doesn't work when Starttime is the same as EndTime"));
+	DEF144552L(*client);
+	theLog.Write(_L8("Test 24 OK\n"));
+	
 	CleanupStack::PopAndDestroy(2); // client, notifier
 	}
--- a/loggingservices/eventlogger/test/src/t_maxnumberlength.CPP	Mon Mar 15 12:46:30 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,244 +0,0 @@
-// Copyright (c) 2005-2009 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"
-// which accompanies this distribution, and is available
-// at the URL "http://www.eclipse.org/legal/epl-v10.html".
-//
-// Initial Contributors:
-// Nokia Corporation - initial contribution.
-//
-// Contributors:
-//
-// Description:
-// test code for INC041118 - Numberfield in logdatabase/engine is too small
-// 
-//
-
-#include <s32file.h>
-#include <e32math.h>
-#include <bautils.h>
-#include "TEST.H"
-
-#undef test  //there is a "test" macro which hides "RTest test" declaration.
-
-RTest test(_L("Maximum Phone Number Length Check"));
-
-_LIT(KTestEventDesc1, "Event Type Description");
-_LIT(KTestRemoteParty1, "Remote Party");
-_LIT(KTestDirection1, "Direction");
-_LIT(KTestStatus1, "Status");
-_LIT(KTestSubject1, "Subject");
-
-
-// These values are stored in "oldLogdb.dat"
-_LIT(KTestEvent0, "00000");
-_LIT(KTestEvent1, "11111");
-_LIT(KTestEvent2, "22222");
-
-const TUid KTestEventUid = {0x10005393};
-const TLogDurationType KTestDurationType1 = 1;
-const TLogDuration KTestDuration1 = 0x1234;
-const TLogContactItemId KTestContact1 = 0x1234;
-const TLogLink KTestLink1 = 0x1234;
-_LIT8(KTestData1, "ABCDEFGH");
-const TLogFlags KTestFlags1 = 0x5;
-
-
-// with this value the test will ONLY pass with the new database
-_LIT(KTestNumberMax, 
-	"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789");
-
-// This test needs a number > 32 to check that database has been converted
-_LIT(KTestNumber50, "01234567890123456789012345678901234567890123456789");
-_LIT(KTestNumberMin, "0");
-
-// this coresponds to an event already stored in oldLogDb.dat 
-const TInt KoldId = 3;
-_LIT(KTestOldDbNumber, "012345678901234567");
-
-
-/**
-@SYMTestCaseID          SYSLIB-LOGENG-CT-1336
-@SYMTestCaseDesc	    Tests for adding events to the log engine database
-@SYMTestPriority 	    High
-@SYMTestActions  	    Check for event ID assigned by log engine
-@SYMTestExpectedResults Test must not fail
-@SYMREQ                 REQ0000
-*/
-TInt TestAddEventL(CLogClient& aClient, const TDesC &aNumber)
-	{
-	test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1336 "));
-	TInt returnId = KLogNullId;
-
-	CTestActive* active = new(ELeave)CTestActive();
-	CleanupStack::PushL(active);
-
-	// create a new event
-	CLogEvent* event = CLogEvent::NewL();
-	CleanupStack::PushL(event);
-
-	// Reset
-	TTime now;
-	now.UniversalTime();
-
-	// load the event with test values
-	event->SetEventType(KTestEventUid);
-	event->SetRemoteParty(KTestRemoteParty1);
-	event->SetDirection(KTestDirection1);
-	event->SetDurationType(KTestDurationType1);
-	event->SetDuration(KTestDuration1);
-	event->SetStatus(KTestStatus1);
-	event->SetSubject(KTestSubject1);
-	event->SetNumber(aNumber);
-	event->SetContact(KTestContact1);
-	event->SetLink(KTestLink1);
-	event->SetDataL(KTestData1);
-	event->SetFlags(KTestFlags1);
-
-	// add the event to the logeng database
-	active->StartL();
-	aClient.AddEvent(*event, active->iStatus);
-
-	CActiveScheduler::Start();
-	TEST(!active->IsActive());
-	aClient.Cancel();
-	TEST2(active->iStatus.Int(), KErrNone);
-
-	// check that an ID has been assigned
-	returnId = event->Id();
-	TEST(returnId != KLogNullId);
-	
-	TEST(event->Time() >= now);
-	TEST(event->Description() == KTestEventDesc1);
-	
-	CleanupStack::PopAndDestroy(2); // event, active
-	
-	// return the event id which has been assigned by the 
-	// log engine
-	return returnId;
-	}
-
-/**
-@SYMTestCaseID          SYSLIB-LOGENG-CT-1337
-@SYMTestCaseDesc	    Tests for getting the event from the log engine database
-@SYMTestPriority 	    High
-@SYMTestActions  	    Tests for CLogClient::GetEvent() function
-@SYMTestExpectedResults Test must not fail
-@SYMREQ                 REQ0000
-*/
-void TestGetEventL(CLogClient& aClient, TInt aTheId, const TDesC& aNumber)
-
-	{
-	test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1337 "));
-	CTestActive* active = new(ELeave)CTestActive();
-	CleanupStack::PushL(active);
-
-	CLogEvent* event = CLogEvent::NewL();
-	CleanupStack::PushL(event);
-
-	// set the id of the event to be fetched
-	event->SetId(aTheId);
-
-	active->StartL();
-	aClient.GetEvent(*event, active->iStatus);
-	CActiveScheduler::Start();
-	aClient.Cancel();
-	TEST2(active->iStatus.Int(), KErrNone);
-		
-	TEST(event->Id() == aTheId);
-	TEST(event->Time() > TTime(0));
-	TEST(event->Description() == KTestEventDesc1);
-	TEST(event->EventType() == KTestEventUid);
-	TEST(event->RemoteParty() == KTestRemoteParty1);
-	TEST(event->Direction() == KTestDirection1);
-	TEST(event->DurationType() == KTestDurationType1);
-	TEST(event->Duration() == KTestDuration1);
-	TEST(event->Status() == KTestStatus1);
-	TEST(event->Subject() == KTestSubject1);
-	TEST(event->Contact() == KTestContact1);
-	TEST(event->Link() == KTestLink1);
-	TEST(event->Data() == KTestData1);
-	TEST(event->Flags() == KTestFlags1);
-
-	// this is the important test
-	// check the number has not been truncated
-	TEST(event->Number() == aNumber);
-
-	TPtrC eventStatus = event->Subject();
-	TPtrC eventNumber = event->Number();
-	test.Printf(_L("Id:%d No:%S Sub:%S Con:0x%x \n"), 
-		event->Id(), &eventNumber, &eventStatus, event->Contact());
-	
-	CleanupStack::PopAndDestroy(2); // event, active
-	}
-
-
-/**
-Test code for INC041118 - Numberfield in logdatabase/engine is too small
-This is the main part of the test
-
-@SYMTestCaseID          SYSLIB-LOGENG-CT-1019
-@SYMTestCaseDesc	    Tests for number field in logdatabase/engine is too small
-@SYMTestPriority 	    High
-@SYMTestActions  	    Add an event to the log engine database.When the database is opened it should be
-                        converted to new format.Check by reading the event and checking the number length
-                        Check with maximum and minimum number field
-@SYMTestExpectedResults Test must not fail
-@SYMREQ                 REQ0000
-*/
-void TestStartupL()
-	{
-	test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1019 "));
-	TestUtils::CopyOldDbL();
-	
-	// add an event to the log engine database.
-	// When the database is opened it should be checked for the old numberfield length
-	// and converted to the new format if required. (It will be required, as old db has been copied)
-	CLogClient* client = CLogClient::NewL(theFs);
-	CleanupStack::PushL(client);
-	User::After(1000000);
-	test.Next(_L("check database conversion"));
-	TInt eventId = TestAddEventL(*client, KTestNumber50 );
-
-	// check that the database has been converted to the new format
-	// by reading back an event the checking that number is the
-	// correct length
-	TestGetEventL(*client, eventId, KTestNumber50);
-	
-	// check using Max
-	test.Next(_L("check a maxium length number"));
-	eventId = TestAddEventL(*client, KTestNumberMax );
-	TestGetEventL(*client, eventId, KTestNumberMax);
-
-	// check using Min
-	test.Next(_L("check a mimium length number"));
-	eventId = TestAddEventL(*client, KTestNumberMin );
-	TestGetEventL(*client, eventId, KTestNumberMin);
-
-	// When OldLogdbu.dat was created, using TestBuildTestDbL() below,
-	// 4 events were stored.  Check that these can still be accessed.
-	// Note: There was a problem here with old events being purged after 30 days
-	// This was fixed by setting TLogConfig::iMaxEventAge = 0 in OldLogdb.dat 
-	test.Next(_L("check all events in the old database"));
-	TestGetEventL(*client, 0, KTestEvent0);
-	TestGetEventL(*client, 1, KTestEvent1);
-	TestGetEventL(*client, 2, KTestEvent2);
-	TestGetEventL(*client, KoldId, KTestOldDbNumber);
-
-	CleanupStack::PopAndDestroy(); // client
-	}
-
-// Test code for INC041118 - Numberfield in logdatabase/engine is too small
-void doTestsL()
-	{
-	TestUtils::Initialize(_L("T_MAXNUMBERLENGTH"));
-#ifdef _DEBUG	
-	test.Start(_L("T_MaxNumberLength Set/Check Phone Number Maximum Length"));
-
-	TestStartupL();
-	theLog.Write(_L8("Test T_MAXNUMBERLENGTH OK\n"));
-#else
-	test.Start(_L("This test works only in debug mode, otherwise the LogEng server cannot be stopped. See TestUtils::CopyOldDbL()"));
-#endif//_DEBUG	
-	}
--- a/loggingservices/eventlogger/test/src/test.cpp	Mon Mar 15 12:46:30 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1002 +0,0 @@
-// Copyright (c) 2004-2009 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"
-// which accompanies this distribution, and is available
-// at the URL "http://www.eclipse.org/legal/epl-v10.html".
-//
-// Initial Contributors:
-// Nokia Corporation - initial contribution.
-//
-// Contributors:
-//
-// Description:
-//
-
-#include <bautils.h>
-#include "TEST.H"
-
-#undef test  //there is a "test" macro which hides "RTest test" declaration.
-
-_LIT(KHelperExeName, "t_LogHiCapHelper.exe");
-
-//======================================================================================================
-
-TPtrC FileName(const TText* aFile)
-    {
-    TPtrC p(aFile);
-    TInt ix=p.LocateReverse('\\');
-    if (ix<0)
-        ix=p.LocateReverse('/');
-    if (ix>=0)
-        p.Set(p.Mid(1+ix));
-    return p;
-    }
-
-//======================================================================================================
-
-void LogTestBoolExpr(TBool aRes, const TText* aFile, TInt aLine)
-    {
-    if(!aRes)
-        {
-        TPtrC fname(FileName(aFile));
-        RDebug::Print(_L("*** Boolean expression evaluated to false, file: %S-%d\r\n"), &fname, aLine);
-        test(EFalse, aLine);
-        }
-    }
-
-void LogCheck(TInt aValue, TInt aExpected, const TText* aFile, TInt aLine)
-	{
-	if(aValue != aExpected)
-		{
-        TPtrC fname(FileName(aFile));
-		RDebug::Print(_L("*** Expected error: %d, got: %d, file: %S-%d\r\n"), aExpected, aValue, &fname, aLine);
-		test(EFalse, aLine);
-		}
-	}
-
-void LogCheckU(TUint aValue, TUint aExpected, const TText* aFile, TInt aLine)
-	{
-	if(aValue != aExpected)
-		{
-	    TPtrC fname(FileName(aFile));
-		RDebug::Print(_L("*** Expected error: %u, got: %u, file: %S-%d\r\n"), aExpected, aValue, &fname, aLine);
-		test(EFalse, aLine);
-		}
-	}
-
-//======================================================================================================
-
-void LogLeave(TInt aErr, const TText* aFile, const TInt aLine)
-    {
-    TPtrC fname(FileName(aFile));
-    RDebug::Print(_L("*** LogEng test leave, err=%d, file: %S-%d\r\n"), aErr, &fname, aLine);
-    User::Leave(aErr);
-    }
-
-//======================================================================================================
-
-void LogPanic(const TDesC& aCategory, TInt aErr, const TText* aFile, TInt aLine)
-    {
-    TPtrC fname(FileName(aFile));
-    RDebug::Print(_L("*** LogEng test panic'd with err=%d, category=%S, file: %S-%d\r\n"), aErr, &aCategory, &fname, aLine);
-    User::Panic(aCategory, aErr);
-    }
-
-//======================================================================================================
-
-#ifdef LOGGING_ENABLED
-
-void Log::New()
-	{
-	_LIT(KNewLogText, "===== NEW LOG =====");
-	//
-	RFileLogger logger;
-	TInt ret=logger.Connect();
-	if	(ret==KErrNone)
-		{
-		logger.CreateLog(KLogFolder, KLogFileName, EFileLoggingModeOverwrite);
-		logger.Write(KNewLogText);
-		}
-	logger.Close();
-	}
-
-void Log::Write(const TDesC& aText)
-	{
-	PruneLogFile();
-
-	RFileLogger logger;
-	TInt ret=logger.Connect();
-	if (ret==KErrNone)
-		{
-		logger.SetDateAndTime(EFalse,EFalse);
-		logger.CreateLog(KLogFolder, KLogFileName,EFileLoggingModeAppend);
-		TBuf<KLogEngLogBufferSize> buf;
-		TTime now;
-		now.HomeTime();
-		TDateTime dateTime;
-		dateTime = now.DateTime();
-		buf.Format(KTimeFormat,dateTime.Hour(),dateTime.Minute(),dateTime.Second(),dateTime.MicroSecond());
-		buf.AppendFormat(KTextFormat,&aText);
-
-		logger.Write(buf);
-		}
-
-	logger.Close();
-	}
-
-void Log::WriteFormat(TRefByValue<const TDesC> aFmt, ...)
-	{
-	VA_LIST list;
-	VA_START(list,aFmt);
-
-	PruneLogFile();
-
-	TBuf<2*KLogEngLogBufferSize> buf;
-	buf.SetMax();
-	buf.FillZ();
-	TTime now;
-	now.HomeTime();
-	TDateTime dateTime;
-	dateTime = now.DateTime();
-	buf.Format(KTimeFormat,dateTime.Hour(),dateTime.Minute(),dateTime.Second(),dateTime.MicroSecond());
-	buf.AppendFormatList(aFmt, list );
-
-	RFileLogger logger;
-	TInt ret=logger.Connect();
-	if (ret==KErrNone)
-		{
-		logger.SetDateAndTime(EFalse,EFalse);
-		logger.CreateLog(KLogFolder, KLogFileName,EFileLoggingModeAppend);
-		logger.Write(buf);
-		}
-
-	logger.Close();
-	}
-
-void Log::PruneLogFile()
-  	{
-	const TInt KMaxLogSize = 1024 * 500;
-	_LIT(KDriveLetter, "C:\\Logs\\");
-	//
-	TFileName fileName(KDriveLetter);
-	fileName.Append(KLogFolder);
-	fileName.Append(KLogFileName);
-	//
-	RFs fsSession;
-	if	(fsSession.Connect() == KErrNone)
-		{
-		TEntry entry;
-		if	(fsSession.Entry(fileName, entry) == KErrNone)
-			{
-			// Check size and delete if its too big
-			if	(entry.iSize >= KMaxLogSize)
-				fsSession.Delete(fileName); // ignore error
-			}
-		}
-	fsSession.Close();
-	}
-
-#endif
-
-// Globals 
-GLDEF_D CTrapCleanup* theCleanup;
-GLDEF_D CActiveScheduler *testScheduler;
-GLDEF_D RFs theFs;
-GLDEF_D TFileName theLogName;
-GLDEF_D RFile theLog;
-GLDEF_D RLogTestSession theLogServ;
-
-//**********************************
-// CTestActive
-//**********************************
-
-CTestActive::CTestActive(TInt aPriority)
-:	CActive(aPriority)
-	{
-	CActiveScheduler::Add(this);
-	iDelayTime=0;
-	}
-
-CTestActive::~CTestActive()
-	{
-	Cancel();
-	}
-
-void CTestActive::DoCancel()
-	{
-	TRequestStatus* s=&iStatus;
-	User::RequestComplete(s, KErrNone);
-	}
-
-void CTestActive::StartL()
-	{
-	iDelayCompletion=EFalse;
-	iDelayTime=0;
-	iStatus = KRequestPending;
-	SetActive();
-	}
-
-void CTestActive::StartL(TInt aDelay)
-	{
-	iDelayCompletion=ETrue;
-	iDelayTime=aDelay;
-	iStatus = KRequestPending;
-	SetActive();
-	}
-
-void CTestActive::RunL() 
-	{
-	if(iDelayCompletion && iDelayTime)
-		{
-		// Wait for events in other threads to have a go....
-		User::After(iDelayTime);
-		iDelayTime=0;
-		iStoredStatus=iStatus;
-		SetActive();
-		TRequestStatus* s=&iStatus;
-		User::RequestComplete(s, KErrNone);
-		}
-	else
-		{
-		if(iDelayCompletion)
-			iStatus=iStoredStatus;
-
-		LOGTEXT("CTestActive::RunL() - Stopping the scheduler");
-		CActiveScheduler::Stop();
-		}
-	}
-
-//**********************************
-// CTestTimer
-//**********************************
-
-CTestTimer::CTestTimer()
-: CTimer(EPriorityLow)
-	{}
-
-void CTestTimer::RunL()
-	{
-	LOGTEXT("CTestTimer::RunL() - Stopping the scheduler");
-	CActiveScheduler::Stop();
-	}
-
-CTestTimer* CTestTimer::NewL()
-	{
-	CTestTimer* self = new(ELeave) CTestTimer();
-	CleanupStack::PushL(self);
-	self->ConstructL(); // CTimer
-	CActiveScheduler::Add(self);
-	CleanupStack::Pop();
-	return self;
-	}
-
-//**********************************
-// TestUtils
-//**********************************
-
-void TestUtils::Initialize(const TDesC& aName)
-	{
-    test.Title();
-    test.Printf(_L("%S\r\n"), &aName);
-    User::RenameThread(aName);
-	}
-
-TBool TestUtils::FileExists(const TDesC& aFile)
-	{
-	TEntry entry;
-	return theFs.Entry(aFile, entry) == KErrNone;
-	}
-
-//Loads t_loghihelper process and passes for execution to t_loghihelper "aCommandLineArg" command line.
-//t_loghihelper will run, execute the command and die, returning the result of the command execution.
-//TestUtils::ExecuteRemoteL() will leave if error and return the result of the remote cmd execution to the caller.
-TInt TestUtils::ExecuteRemoteL(const TDesC& aCommandLineArg)
-	{
-	RProcess process;
-	LEAVE_IF_ERROR(process.Create(KHelperExeName, aCommandLineArg));
-	
-	TRequestStatus status;
-	process.Logon(status);
-	process.Resume();
-
-	User::WaitForRequest(status);
-	TInt exitReason = process.ExitReason();
-	
-	process.Close();
-	LEAVE_IF_ERROR(exitReason);
-
-	return exitReason;
-	}
-	
-//Runs t_loghihelper. t_loghihelper will execute the "delete LogEng database" command.
-//The "delete LogEng database" is a complex operation. The request is sent via the backup server
-//which will send a request to the LogEng server to release the LogEng database file locks and close the file.
-//After that the database will be deleted. 
-//In the same call the LogEng server will restarted and the LogEng server will re-create the database during the 
-//server startup.
-//
-//If "aCloseBeforeDelete" flag is false, then the database wil be only deleted.
-//The default value of "aCloseBeforeDelete" is true: the database will be closed, deleted and re-created.
-//But some of the LogEng tests create a CBaBackupSessionWrapper object and call CloseFileL() with the logeng
-//database name as a parameter. In this case, if another process, as t_loghicaphelper for example, attempts
-//to call CloseFileL() with the same file name as a parameter, then the caller will get KErrServerBusy error.
-//See how CBaBackupSessionWrapper::CloseFileL() is implemented on the server side.
-void TestUtils::DeleteDatabaseL(TBool aCloseBeforeDelete)
-	{
-    _LIT(KCmdLine1, "-delete_db1");
-    _LIT(KCmdLine2, "-delete_db2");
-    (void)ExecuteRemoteL(aCloseBeforeDelete ? KCmdLine1 : KCmdLine2);
-	}
-	
-//Runs t_loghihelper. t_loghihelper will check and return whether the LogEng database is open or not.  
-TBool TestUtils::IsDatabaseOpenL()
-	{
-	_LIT(KCmdLine, "-db_is_open");
-	TInt result = ExecuteRemoteL(KCmdLine);
-	return result != 0;
-	}
-	
-//Runs t_loghihelper. t_loghihelper will add an event type to the LogEng database.  
-void TestUtils::AddEventTypeL()
-	{
-	_LIT(KCmdLine, "-add_event_type");
-	(void)ExecuteRemoteL(KCmdLine);
-	}
-	
-//Runs t_loghihelper. t_loghihelper will add an event to the LogEng database.  
-TInt TestUtils::AddEventL()
-	{
-	_LIT(KCmdLine, "-add_event");
-	return ExecuteRemoteL(KCmdLine);		
-	}
-	
-//Runs t_loghihelper. t_loghihelper will add events to the LogEng database.  
-void TestUtils::AddViewTestEventsL()
-	{
-	_LIT(KCmdLine, "-add_view_test_events");
-	(void)ExecuteRemoteL(KCmdLine);
-	}
-
-//Runs t_loghihelper. t_loghihelper will return the size of the LogEng database.  
-TInt TestUtils::DatabaseSizeL()
-	{
-	_LIT(KCmdLine, "-db_size");
-	return ExecuteRemoteL(KCmdLine);		
-	}	
-	
-//Runs t_loghihelper. t_loghihelper will replace the LogEng database with a corrupted database (for testing purposes).
-//The LogEng server will be stopped before that. The function can be used only in debug mode.
-#ifdef _DEBUG
-void TestUtils::CopyCorruptDbL()
-	{
-
-	_LIT(KCmdLine, "-copy_corrupt");
-	(void)ExecuteRemoteL(KCmdLine);
-	}
-	
-//Runs t_loghihelper. t_loghihelper will replace the LogEng database with a corrupted database (for testing purposes).
-//The LogEng server will be stopped before that. The function can be used only in debug mode.
-void  TestUtils::CopyCorruptDamagedDbL()
-	{
-
-	_LIT(KCmdLine, "-copy_corrupt_damaged");
-	(void)ExecuteRemoteL(KCmdLine);
-	}
-	
-//Runs t_loghihelper. t_loghihelper will replace the LogEng database with an old format database 
-//(no SimId column, phone number length is different). The LogEng server will be stopped before that.
-//The function can be used only in debug mode.
-void TestUtils::CopyOldDbL()
-	{
-	_LIT(KCmdLine, "-copy_old");
-	(void)ExecuteRemoteL(KCmdLine);
-	}
-#else //_DEBUG
-void TestUtils::CopyCorruptDbL()
-	{
-	RDebug::Print(_L("TestUtils::CopyCorruptDbL() has a meaningfull implementation in debug builds only.\n"));
-	}
-
-void TestUtils::CopyCorruptDamagedDbL()
-	{
-	RDebug::Print(_L("TestUtils::CopyCorruptDamagedDbL() has a meaningfull implementation in debug builds only.\n"));
-	}
-
-void TestUtils::CopyOldDbL()
-	{
-	RDebug::Print(_L("TestUtils::CopyOldDbL() has a meaningfull implementation in debug builds only.\n"));
-	}
-
-#endif//_DEBUG
-
-//Runs t_loghihelper. t_loghihelper will re-create the LogEng database and check whether LogEng client can connect to the server.   
-void TestUtils::TestInvalidSchemaL()
-	{
-	_LIT(KCmdLine, "-invalid_schema");
-	(void)ExecuteRemoteL(KCmdLine);
-	}
-
-//Runs t_loghihelper. t_loghihelper checks whether the phone number mathcing is enabled.   
-TBool TestUtils::MatchingEnabledL()
-	{
-	_LIT(KCmdLine, "-is_matching_enabled");
-	return ExecuteRemoteL(KCmdLine) != 0;
-	}
-
-//Creates HBufC object and puts it on the cleanup stack.
-//The buffer will be filled with (' ' + pos) characters, where pos is the character position in the buffer. 
-HBufC* TestUtils::CreateBufLC(TInt aLength)
-	{
-	HBufC* buf = HBufC::NewLC(aLength);
-	TPtr ptr = buf->Des();
-	for(TInt pos=0;pos<aLength;++pos)
-		{
-		ptr.Append(TChar(' ' + pos));
-		}
-	return buf;
-	}
-
-//Returns whether the two filters are equal or not.
-TBool TestUtils::FiltersEqual(const CLogFilter& aFilter1, const CLogFilter& aFilter2)
-	{
-	return aFilter1.EventType() == aFilter2.EventType() &&
-		   aFilter1.RemoteParty() == aFilter2.RemoteParty() &&
-		   aFilter1.Direction() == aFilter2.Direction() &&
-		   aFilter1.DurationType() == aFilter2.DurationType() &&
-		   aFilter1.Status() == aFilter2.Status() &&
-		   aFilter1.Contact() == aFilter2.Contact() &&
-		   aFilter1.Number() == aFilter2.Number() 
-#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
-		   &&
-		   aFilter1.SimId() == aFilter2.SimId()
-#endif		   
-		   ;
-	}
-
-//Creates HBufC8 object and puts it on the cleanup stack.
-//The buffer will be filled with (' ' + pos % (0xff - 32)) characters, where pos is the character position in the buffer. 
-HBufC8* TestUtils::CreateBuf8LC(TInt aLength)
-	{
-	HBufC8* buf = HBufC8::NewLC(aLength);
-	TPtr8 ptr = buf->Des();
-	for(TInt pos=0;pos<aLength;++pos)
-		{
-		ptr.Append(TChar(' ' + pos % (0xff - 32)));
-		}
-	return buf;
-	}
-
-//Returns whether the two events are equal or not.
-TBool TestUtils::EventsEqual(const CLogEvent& aEvent1, const CLogEvent& aEvent2)
-	{
-	return 	aEvent1.Id() == aEvent2.Id() &&
-			aEvent1.EventType() == aEvent2.EventType() &&
-			aEvent1.RemoteParty() == aEvent2.RemoteParty() &&
-			aEvent1.Direction() == aEvent2.Direction() &&
-			aEvent1.Time() == aEvent2.Time() &&
-			aEvent1.DurationType() == aEvent2.DurationType() &&
-			aEvent1.Duration() == aEvent2.Duration() &&
-			aEvent1.Status() == aEvent2.Status() &&
-			aEvent1.Subject() == aEvent2.Subject() &&
-			aEvent1.Number() == aEvent2.Number() &&
-			aEvent1.Contact() == aEvent2.Contact() &&
-			aEvent1.Link() == aEvent2.Link() &&
-			aEvent1.Description() == aEvent2.Description() &&
-			aEvent1.Data() == aEvent2.Data() 
-#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
-			&& 
-			aEvent1.SimId() == aEvent2.SimId()
-#endif			
-			; 
-	}
-
-//Returns whether the two event types are equal or not.
-TBool TestUtils::TypesEqual(const CLogEventType& aType1, const CLogEventType& aType2)
-	{
-	return	aType1.Uid() == aType2.Uid() &&
-			aType1.Description() == aType2.Description() &&
-			aType1.LoggingEnabled() == aType2.LoggingEnabled();
-	}
-
-//Waits for a key to be pressed.
-TBool TestUtils::WaitForKeyL(TTimeIntervalMicroSeconds32 aDelay, TKeyCode& aKeyCode)
-	{
-	TEST(test.Console() != NULL);
-
-	// Create timer
-	CTestTimer* timer = CTestTimer::NewL();
-	CleanupStack::PushL(timer);
-	timer->After(aDelay);
-
-	CTestActive* wait = new(ELeave)CTestActive;
-	CleanupStack::PushL(wait);
-	wait->StartL();
-
-	// Wait for key press
-	test.Console()->Read(wait->iStatus);
-	CActiveScheduler::Start();
-
-	// If timer still active a key was pressed
-	TBool keyPressed = timer->IsActive();
-
-	if (keyPressed)
-		{
-		// Get the key pressed
-		aKeyCode = test.Console()->KeyCode();
-
-		// Cancel timer
-		timer->Cancel();
-		}
-	else
-		{
-		// Cancel wait for character
-		test.Console()->ReadCancel();
-		User::WaitForRequest(wait->iStatus);
-		}
-
-	CleanupStack::PopAndDestroy(2); // wait, timer
-	return keyPressed;
-	}
-
-//Used for LogEng server side heap failure testing.
-#ifdef _DEBUG
-void TestUtils::SetLogServHeapFailureL(RHeap::TAllocFail aType, TInt aRate)
-	{
-	//this function doesn't have any effect on UREL builds 
- 	//get rid of warnings in release builds
- 	aType = aType;
- 	aRate = aRate;
-	if (!theLogServ.Handle())
-	    LEAVE_IF_ERROR(theLogServ.Connect());
-
-	TIpcArgs  ipcArgs(aType,aRate) ;
-	LEAVE_IF_ERROR(theLogServ.Send(ELogSetHeapFail, ipcArgs));
-	}
-#else
-void TestUtils::SetLogServHeapFailureL(RHeap::TAllocFail, TInt)
-	{
-	}
-#endif//_DEBUG
-
-//**********************************
-// CLogViewChangeObserver
-//**********************************
-
-CLogViewChangeObserver* CLogViewChangeObserver::NewLC()
-	{
-	CLogViewChangeObserver* self = new(ELeave) CLogViewChangeObserver();
-	CleanupStack::PushL(self);
-	return self;
-	}
-
-CLogViewChangeObserver::~CLogViewChangeObserver()
-	{
-	Cancel();
-	delete iChanges;
-	}
-
-CLogViewChangeObserver::CLogViewChangeObserver()
-:	CActive(EPriorityStandard)
-	{
-	CActiveScheduler::Add(this);
-	}
-
-
-CLogChangeDefinition* CLogViewChangeObserver::WaitForChangesLC(TStopType aType, TInt aCount)
-	{
-	__ASSERT_ALWAYS(!iSchedulerStarted, User::Invariant());
-	Reset();
-	//
-	iExpectedChangeCount = aCount;
-	iType = aType;
-	if	(aType != EStopOnChanges)
-		SetActive();
-	//
-	iSchedulerStarted = ETrue;
-	CActiveScheduler::Start();
-	iSchedulerStarted = EFalse;
-	//
-	CLogChangeDefinition* ret = iChanges;
-	TEST(iChanges != NULL);
-	iChanges = NULL;
-	CleanupStack::PushL(ret);
-	return ret;
-	}
-
-CLogChangeDefinition* CLogViewChangeObserver::WaitForChangesLC(TCallBack aCallBack, TStopType aType, TInt aCount)
-	{
-	iHaveCallBack = ETrue;
-	iCallBack = aCallBack;
-	return WaitForChangesLC(aType, aCount);
-	}
-
-void CLogViewChangeObserver::HandleLogViewChangeEventAddedL(TLogId aId, TInt aViewIndex, TInt aChangeIndex, TInt aTotalChangeCount)
-	{
-	AddChangeL(ELogChangeTypeEventAdded, aId, aViewIndex);
-	if	(aChangeIndex == aTotalChangeCount-1)
-		CheckForSchedulerStop();
-	}
-
-void CLogViewChangeObserver::HandleLogViewChangeEventChangedL(TLogId aId, TInt aViewIndex, TInt aChangeIndex, TInt aTotalChangeCount)
-	{
-	AddChangeL(ELogChangeTypeEventChanged, aId, aViewIndex);
-	if	(aChangeIndex == aTotalChangeCount-1)
-		CheckForSchedulerStop();
-	}
-
-void CLogViewChangeObserver::HandleLogViewChangeEventDeletedL(TLogId aId, TInt aViewIndex, TInt aChangeIndex, TInt aTotalChangeCount)
-	{
-	AddChangeL(ELogChangeTypeEventDeleted, aId, aViewIndex);
-	if	(aChangeIndex == aTotalChangeCount-1)
-		CheckForSchedulerStop();
-	}
-
-void CLogViewChangeObserver::RunL()
-	{
-	__ASSERT_ALWAYS(iType == EStopOnRunL || iType == EStopOnBoth, User::Invariant());
-	iHaveFinishedOperation = ETrue;
-	CheckForSchedulerStop();
-	}
-
-void CLogViewChangeObserver::DoCancel()
-	{
-	TRequestStatus* s=&iStatus;
-	User::RequestComplete(s, KErrCancel);
-	}
-
-void CLogViewChangeObserver::Reset()
-	{
-	iExpectedChangeCount = 0;
-	iHaveFinishedOperation = EFalse;
-	iHaveObtainedChanges = EFalse;
-	iSchedulerStarted = EFalse;
-	iType = EStopOnChanges;
-	delete iChanges;
-	iChanges = NULL;
-	}
-
-void CLogViewChangeObserver::CheckForSchedulerStop()
-	{
-	if(iSchedulerStarted)
-		{
-		if	(iHaveCallBack)
-			{
-			iCallBack.CallBack();
-			iCallBack.iFunction = NULL;
-			iCallBack.iPtr = NULL;
-			iHaveCallBack = EFalse;
-			}
-		//
-		TBool stopScheduler = EFalse;
-		switch(iType)
-			{
-		case EStopOnChanges:
-			stopScheduler = iHaveObtainedChanges;
-			break;
-		case EStopOnRunL:
-			stopScheduler = iHaveFinishedOperation;
-			break;
-		case EStopOnBoth:
-			stopScheduler = (iHaveObtainedChanges && iHaveFinishedOperation);
-			break;
-		case EStopOnCount:
-			if	(iChanges)
-				{
-				TEST(iChanges->Count() <= iExpectedChangeCount);
-				stopScheduler = (iChanges->Count() == iExpectedChangeCount);
-				}
-		case EDontStopScheduler:
-			break;
-			}
-
-		if	(stopScheduler)
-			{
-			LOGTEXT("CLogViewChangeObserver::CheckForSchedulerStop() - Stopping the scheduler");
-			CActiveScheduler::Stop();
-			}
-		}
-	}
-
-void CLogViewChangeObserver::AddChangeL(TLogDatabaseChangeType aType, TLogId aId, TInt aViewIndex)
-	{
-	CLogChangeDefinition* changes;
-
-	if	(iChanges)
-		changes = iChanges;
-	else
-		{
-		changes = CLogChangeDefinition::NewL();
-		CleanupStack::PushL(changes);
-		}
-	//
-	changes->AddL(aId, aType, aViewIndex);
-	//
-	if	(!iChanges)
-		{
-		delete iChanges;
-		iChanges = changes;
-		CleanupStack::Pop(changes);
-		}
-	//
-	iHaveObtainedChanges = ETrue;
-	}
-
-//**********************************
-// CLogViewChangeObserverErrorTest
-//**********************************
-CLogViewChangeObserverErrorTest* CLogViewChangeObserverErrorTest::NewLC()
-	{
-	CLogViewChangeObserverErrorTest* self = new(ELeave) CLogViewChangeObserverErrorTest();
-	CleanupStack::PushL(self);
-	return self;
-	}	
-
-CLogViewChangeObserverErrorTest::CLogViewChangeObserverErrorTest()
-	{}
-	 
-void CLogViewChangeObserverErrorTest::HandleLogViewChangeEventAddedL(TLogId aId, TInt aViewIndex, TInt aChangeIndex, TInt aTotalChangeCount)
-	{
-  	// DEF108741L - the error condition tested here is that a leave is dealt with 
-  	// gracefully without any panics.
- 
- 	// Add a new event to the log
-	AddChangeL(ELogChangeTypeEventAdded, aId, aViewIndex);
-	if	(aChangeIndex == aTotalChangeCount-1)
-		CheckForSchedulerStop();
-	
-	// In the test case for DEF108741L this method will be effectively
-	// invoked 3 times. This code forces a leave on the middle event to 
-	// ensure that the leave is dealt with and the rest of the test 
-	// completes successfully.
-	if (aId == 1)
-		{	
-		LEAVE(KErrGeneral);
-		} 
-	}
- 
-//**********************************
-// CLogSchedulerTimer
-//**********************************
-
-CLogSchedulerTimer* CLogSchedulerTimer::NewLC()
-	{
-	CLogSchedulerTimer* self = new(ELeave) CLogSchedulerTimer();
-	CleanupStack::PushL(self);
-	self->ConstructL();
-	return self;
-	}
-
-CLogSchedulerTimer::~CLogSchedulerTimer()
-	{
-	Cancel();
-	}
-
-CLogSchedulerTimer::CLogSchedulerTimer()
-:	CTimer(0)
-	{
-	CActiveScheduler::Add(this);
-	}
-
-void CLogSchedulerTimer::ConstructL()
-	{
-	CTimer::ConstructL();
-	}
-
-void CLogSchedulerTimer::Wait(TTimeIntervalMicroSeconds32 aTime)
-	{
-	After(aTime);
-	CActiveScheduler::Start();
-	}
-
-void CLogSchedulerTimer::RunL()
-	{
-	LOGTEXT("CLogSchedulerTimer::RunL() - Stopping the scheduler");
-	CActiveScheduler::Stop();
-	}
-
-
-
-
-//**********************************
-// CLogChangeNotifier
-//**********************************
-
-CLogChangeNotifier* CLogChangeNotifier::NewL()
-	{
-	CLogChangeNotifier* self = new(ELeave)CLogChangeNotifier();
-	CleanupStack::PushL(self);
-	self->ConstructL();
-	CleanupStack::Pop(self);
-	return self;
-	}
-
-CLogChangeNotifier::~CLogChangeNotifier()
-	{
-	Cancel();
-	delete iClient;
-	}
-
-CLogChangeNotifier::CLogChangeNotifier()
-: CActive(EPriorityStandard)
-	{
-	CActiveScheduler::Add(this);
-	}
-
-void CLogChangeNotifier::ConstructL()
-	{
-	iClient = CLogClient::NewL(theFs);
-
-	iStart.UniversalTime();
-	iClient->NotifyChange(10000000, iStatus);
-	SetActive();
-	}
-
-void CLogChangeNotifier::RunL()
-	{
-	TTime now;
-	now.UniversalTime();
-	TTimeIntervalSeconds seconds;
-	now.SecondsFrom(iStart, seconds);
-
-	TBuf<256> buf;
- 	const TInt error = iStatus.Int();
- 	if (error == KErrServerTerminated)
- 		{
- 		buf.Format(_L("KErrServerTerminated"));
-		User::InfoPrint(buf);
-		return;
- 		}
- 		
-	buf.Format(_L("%d seconds"), seconds.Int());
-	User::InfoPrint(buf);
-	
-	iStart.UniversalTime();
-	iClient->NotifyChange(10000000, iStatus);
-	SetActive();
-	}
-
-void CLogChangeNotifier::DoCancel()
-	{
-	iClient->NotifyChangeCancel();	
-	}
-
-//**********************************
-// Global
-//**********************************
-
-void SetupSchedulerL()
-	{
-	testScheduler = new (ELeave) CActiveScheduler;
-	CleanupStack::PushL( testScheduler );
-	CActiveScheduler::Install( testScheduler );
-	}
-
-void CloseScheduler()
-	{
-    CleanupStack::PopAndDestroy(); // Scheduler
-    testScheduler = NULL;
-	}
-
-static void CreateLogL()
-    {
-    LEAVE_IF_ERROR(theFs.Connect());
-
-    theLogName.Copy(RProcess().FileName());
-    TInt start = theLogName.LocateReverse('\\');
-    TInt end = theLogName.LocateReverse('.');
-    theLogName = theLogName.Mid(start + 1, end - start - 1);
-
-    // create the log filename
-    theLogName.Insert(0, _L("C:\\"));
-#if defined(__WINS__)
-    theLogName.Append(_L(".WINS."));
-#else
-    theLogName.Append(_L(".MARM."));
-#endif
-#if defined(_UNICODE)
-    theLogName.Append(_L("UNICODE."));
-#else
-    theLogName.Append(_L("ASCII."));
-#endif
-#if defined(_DEBUG)
-    theLogName.Append(_L("DEB."));
-#else
-    theLogName.Append(_L("REL."));
-#endif
-    theLogName.Append(_L("LOG"));
-
-    // create the logfile
-    LEAVE_IF_ERROR(theLog.Replace(theFs, theLogName, EFileWrite|EFileShareExclusive));
-    TBuf8<256> text;
-    text.Copy(theLogName);
-    theLog.Write(text);
-    theLog.Write(_L8("\nTest results\n"));
-    }
-
-static void CloseLog()
-    {
-    theLog.Write(_L8("Tests completed\n"));
-    test.Printf(_L("Results saved in %S\n"), &theLogName);
-    theLog.Close();
-    theFs.Close();
-    }
-
-void DeleteDataFile(const TDesC& aFullName)
-	{
-	RFs fsSession;
-	TInt err = fsSession.Connect();
-	if(err == KErrNone)
-		{
-		TEntry entry;
-		if(fsSession.Entry(aFullName, entry) == KErrNone)
-			{
-			RDebug::Print(_L("Deleting \"%S\" file.\n"), &aFullName);
-			err = fsSession.SetAtt(aFullName, 0, KEntryAttReadOnly);
-			if(err != KErrNone) 
-				{
-				RDebug::Print(_L("Error %d changing \"%S\" file attributes.\n"), err, &aFullName);
-				}
-			err = fsSession.Delete(aFullName);
-			if(err != KErrNone) 
-				{
-				RDebug::Print(_L("Error %d deleting \"%S\" file.\n"), err, &aFullName);
-				}
-			}
-		fsSession.Close();
-		}
-	else
-		{
-		RDebug::Print(_L("Error %d connecting file session. File: %S.\n"), err, &aFullName);
-		}
-	}
-
-static void Cleanup(void*)
-	{
-	TRAP_IGNORE(TestUtils::DeleteDatabaseL());
-	_LIT(KCntModelFileName, "c:\\system\\data\\CntModel.ini");
-	::DeleteDataFile(KCntModelFileName);
-	_LIT(KContactsFileName, "c:\\system\\data\\Contacts.cdb");
-	::DeleteDataFile(KContactsFileName);
-	::DeleteDataFile(theLogName);
-	}
-
-static void DoMainL()
-	{
-	::SetupSchedulerL();
-	TCleanupItem cleanup(&Cleanup, NULL);
-	CleanupStack::PushL(cleanup);
-	CreateLogL();
-	::doTestsL();
-	CloseLog();
-    CleanupStack::PopAndDestroy();//cleanup
-	::CloseScheduler();
-	}
-
-TInt E32Main()
-	{	
-	__UHEAP_MARK;
-
-	theCleanup = CTrapCleanup::New();
-    if(!theCleanup)
-       {
-       _LIT(KLogHiCapHelperPanic, "LogTestPanic");
-        User::Panic(KLogHiCapHelperPanic, KErrNoMemory);
-       }
-
-	TRAPD(err, ::DoMainL());	
-	TEST2(err, KErrNone);
-
-	delete theCleanup;	
-
-	test.Console()->SetPos(0, 13);
-
-	test.End();
-	test.Close();
-
-	__UHEAP_MARKEND;
-
-	return KErrNone;
-	}
-
-
--- a/loggingservices/eventlogger/test/t_OrderById.MMP	Mon Mar 15 12:46:30 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-// Copyright (c) 2004-2009 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"
-// which accompanies this distribution, and is available
-// at the URL "http://www.eclipse.org/legal/epl-v10.html".
-//
-// Initial Contributors:
-// Nokia Corporation - initial contribution.
-//
-// Contributors:
-//
-// Description:
-//
-
-TARGET			t_orderbyid.exe
-CAPABILITY	    WriteDeviceData ReadDeviceData WriteUserData ReadUserData 
-TARGETTYPE		exe
-
-SOURCEPATH		src
-SOURCE			t_OrderById.CPP
-SOURCE			test.cpp
-SOURCE			t_logservsession.cpp
-
-USERINCLUDE		../test/inc
-USERINCLUDE		../Shared
-OS_LAYER_SYSTEMINCLUDE_SYMBIAN
-
-LIBRARY			euser.lib
-LIBRARY			efsrv.lib
-LIBRARY			logwrap.lib
-LIBRARY			logcli.lib
-LIBRARY			bafl.lib
-
-
-VENDORID		0x70000001
-
-SMPSAFE
--- a/loggingservices/eventlogger/test/t_maxnumberlength.MMP	Mon Mar 15 12:46:30 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-// Copyright (c) 2004-2009 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"
-// which accompanies this distribution, and is available
-// at the URL "http://www.eclipse.org/legal/epl-v10.html".
-//
-// Initial Contributors:
-// Nokia Corporation - initial contribution.
-//
-// Contributors:
-//
-// Description:
-// T_MAXPHNUMBERLENGTH1.MMP
-// 
-//
-
-TARGET        t_maxnumberlength.exe
-TARGETTYPE    exe
-CAPABILITY	  WriteDeviceData ReadDeviceData WriteUserData ReadUserData 
-SOURCEPATH    src
-SOURCE        t_maxnumberlength.CPP 
-SOURCE		  test.cpp
-SOURCE		  t_logservsession.cpp
-
-USERINCLUDE   ../test/inc
-USERINCLUDE   ../Shared
-OS_LAYER_SYSTEMINCLUDE_SYMBIAN
-LIBRARY       euser.lib efsrv.lib logwrap.lib logcli.lib bafl.lib
-
-
-
-VENDORID 0x70000001
-
-SMPSAFE
--- a/persistentstorage/centralrepository/cenrepsrv/cachemgr.h	Mon Mar 15 12:46:30 2010 +0200
+++ b/persistentstorage/centralrepository/cenrepsrv/cachemgr.h	Thu Apr 01 00:19:42 2010 +0300
@@ -30,7 +30,7 @@
 	The default value is approximately the size needed to cache everything during device boot-up
 	@internalComponent
 	*/
-	#define DEFAULT_CENTREP_CACHE_SIZE 100000
+	#define DEFAULT_CENTREP_CACHE_SIZE 200000
 #else
 	#if DEFAULT_CENTREP_CACHE_SIZE <= 0
 		#error "DEFAULT_CENTREP_CACHE_SIZE macro value must be greater than 0"
--- a/persistentstorage/sql/OsLayer/os_symbian.cpp	Mon Mar 15 12:46:30 2010 +0200
+++ b/persistentstorage/sql/OsLayer/os_symbian.cpp	Thu Apr 01 00:19:42 2010 +0300
@@ -1320,12 +1320,25 @@
 	}
 
 /**
-Replaces all invalid characters in aFileName.
+Removes all invalid characters in aFileName.
 If the file name contains handles (so that's a private secure database related name), the additional
 information (handles, flags, object addresses) has to be excluded from the name in order to make it usable 
-by the file system.
+by the file system. 
+
+The private file name format is (see FhExtractAndStore() comments):
+
+"|<R/O flag><RMessage2 pointer><drive><app SID><file_name><file_ext>|"
 
-@param aFileName Output parameter. The cleaned file name will be copied there.
+Before opening or creating a file, SQLite will call TVfs::FullPathName() passing to the function the name of
+the file and expecting the full file name (including path) as an output from the function.
+After the TVfs::FullPathName() call, the full file name, returned to SQLite, will have the following format:
+
+"|<drive><path><file_name><file_ext>|"
+
+FhConvertToFileName() is called from TVfs::Open() and will remove the leading and trialing '|' characters from
+the file name.
+
+@param aFileName Input/Output parameter. The cleaned file name will be copied there.
 @param aPrivateDir The SQL server private data cage.
 
 @see TVfs::Open()
@@ -1352,7 +1365,7 @@
 	}
 
 /**
-Extracts the read-only flag and RMessage address from aDbFileName and stores them in single COsLayerData instance.
+Extracts the read-only flag and RMessage address from aDbFileName and stores them in the single COsLayerData instance.
 
 @param aDbFileName Input/output parameter. The file name. 
 				   It will be reformatted and won't contain the already extracted data.
@@ -2235,7 +2248,7 @@
 	else
 		{
 		if(fhStrType == EFhStr)
-			{//Not the main db file. Replace invalid characters in the file name
+			{//Not the main db file. Remove invalid characters in the file name
 			::FhConvertToFileName(fname, osLayerData.iSysPrivDir);//If fname does not have a path, iSysPrivDir will be used
 			}
 		TInt fmode = EFileRead;
--- a/persistentstorage/sql/SRC/Server/Compact/SqlCompact.h	Mon Mar 15 12:46:30 2010 +0200
+++ b/persistentstorage/sql/SRC/Server/Compact/SqlCompact.h	Thu Apr 01 00:19:42 2010 +0300
@@ -18,7 +18,7 @@
 * Only one instance of that class should be created by the server.
 * The CSqlCompactor single instance manages a set of reference counted per-database entries and a CTimer compaction object.
 * The MSqlCompactConn interface acts as an abstraction layer between the compaction entries and the 
-* real object which functions are used to perform the compaction.
+* real object with member functions that are used to perform the compaction.
 * 
 *
 */
--- a/persistentstorage/sql/SRC/Server/Compact/SqlCompactConn.cpp	Mon Mar 15 12:46:30 2010 +0200
+++ b/persistentstorage/sql/SRC/Server/Compact/SqlCompactConn.cpp	Thu Apr 01 00:19:42 2010 +0300
@@ -106,11 +106,11 @@
 
 @param aFullName The full database name, including the path.
 @param aFreePageCallback Input/Output parameter. A reference to an object containing the free pages threshold and 
-						 the callback that needs to be called when the free page count reaches ot is above the threshold.
+						 the callback that needs to be called when the free page count reaches or is above the threshold.
 						 aFreePageCallback.iThreshold must be set to be in Kb. 	
 						 If the function call completes successfully and the free pages space is above the threshold,
 						 the aFreePageCallback.iThreshold will be set to contain the free pages count.
-						 Otherwise aFreePageCallback.iThreshold will be initizized with zero.
+						 Otherwise aFreePageCallback.iThreshold will be initialized with zero.
 
 @leave KErrNoMemory, an out of memory condition has occurred,
 	   KErrArgument, invalid data in the aFreePageCallback object;
@@ -199,11 +199,11 @@
 
 @param aFullName The full name of the database to be compacted (including the path).
 @param aFreePageCallback A reference to an object containing the free pages threshold and the callback
-					     that needs to be called when the free page count reaches ot is above the threshold.
+					     that needs to be called when the free page count reaches or is above the threshold.
 						 aFreePageCallback.iThreshold must be set to be in Kb. 	
 						 If the function call completes successfully and the free pages space is above the threshold,
 						 the aFreePageCallback.iThreshold will be set to contain the free pages count.
-						 Otherwise aFreePageCallback.iThreshold will be initizized with zero.
+						 Otherwise aFreePageCallback.iThreshold will be initialized with zero.
 					  
 @return A pointer to the created MSqlCompactConn interface.
 
--- a/persistentstorage/sql/SRC/Server/Compact/SqlCompactEntry.cpp	Mon Mar 15 12:46:30 2010 +0200
+++ b/persistentstorage/sql/SRC/Server/Compact/SqlCompactEntry.cpp	Thu Apr 01 00:19:42 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2008-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"
@@ -32,7 +32,7 @@
 @param aSettings Background compaction settings/thresholds
 @param aTimer The background compaction timer object
 
-When the free pages threshold reach certain the threshold, the background compaction 
+When the free pages threshold is reached, the background compaction 
 for this entry will be kicked-off.
 
 @return A pointer to the created CSqlCompactEntry instance
@@ -210,14 +210,7 @@
 	__SQLASSERT(processedPageCount >= 0, ESqlPanicInternalError);
 	if(err == KErrNone)
 		{
-		if(processedPageCount > 0)
-			{
-			iPageCount -= processedPageCount;
-			}
-		else
-			{
-			iPageCount = 0;
-			}
+		iPageCount -= processedPageCount;
 		__SQLASSERT(iPageCount >= 0, ESqlPanicInternalError);
 		}
 	if(iPageCount <= 0)
--- a/persistentstorage/sql/SRC/Server/Compact/SqlCompactTimer.h	Mon Mar 15 12:46:30 2010 +0200
+++ b/persistentstorage/sql/SRC/Server/Compact/SqlCompactTimer.h	Thu Apr 01 00:19:42 2010 +0300
@@ -36,7 +36,7 @@
 method that can be used to delay the next compaction step, improving this way the SQL server responsiveness to 
 client requests.
 
-The CSqlCompactEntry objects needed compaction will be added at the front of the queue.
+The CSqlCompactEntry objects needing compaction will be added at the front of the queue.
 Every time when timer's RunL() method gets executed, the last element from the queue will be picked-up and one
 compaction step will be performed. When the CSqlCompactEntry object completes the compaction, it will remove
 itself from the queue.
--- a/persistentstorage/sql/SRC/Server/SqlSrvDatabase.cpp	Mon Mar 15 12:46:30 2010 +0200
+++ b/persistentstorage/sql/SRC/Server/SqlSrvDatabase.cpp	Thu Apr 01 00:19:42 2010 +0300
@@ -391,6 +391,7 @@
 	TSqlCompactDbPair compactDbPair;
 	while(compactDbIt.Next(compactDbPair))
 		{
+        __SQLASSERT(compactDbPair.iData, ESqlPanicInvalidObj);
 		::SqlServer().Compactor().ReleaseEntry(*compactDbPair.iData);
 		}
 	iCompactDbMap.Close();
@@ -405,6 +406,37 @@
 		//The security policy map owns iSecureDbName and iSecurityPolicy and is responsible for 
 		//iSecureDbName and iSecurityPolicy destruction.
 		}
+    //The next step of the "resource release" process is to walk over iAttachDbMap entries, get the data part of
+    //the found TSqlAttachDbPair objects, which is secure database name used as a key in iSecurityMap, and remove
+    //the related entry from iSecurityMap. If the database is closed in normal circumstances, the iAttachDbMap
+    //has no entries. But if the database client forgets to detach the used attached databases or if the Detach() call
+    //fails (for example, with KErrNoMemory error), then at this point iAttachDbMap has one or more entries.
+    //That means there are still some attached databases to this connection. This is not a problem, SQLite will take
+    //care of them. The problem is that there are related entries in iSecurityMap map, owned by CSqlServer object,
+    //and they won't be removed from the map till CSqlServer object is alive. This causes problems in OOM tests and in 
+    //real life of the device.
+    //For example, one database client opens "c:[11111111]a.db" and attaches "c:[11111111]b.db":
+    // - c:[11111111]a.db database has been opened successfully. iSecurityMap has 1 entry:
+    //            {"c:[11111111]a.db", <database security policy object>}.
+    // - c:[11111111]b.db is attached to c:[11111111]a.db with name "db2". There will be 1 entry in iAttachDbMap:
+    //            {"db2", "c:[11111111]a.db"} 
+    //        and a new entry will be added to iSecurityMap:
+    //            {"c:[11111111]b.db", <database security policy object>}. 2 entries in total in iSecurityMap.
+    // - The database client attempts to detach the attached database but the opertaion fails during the execution
+    //        of the DETACH sql statement. Both maps are intact.
+    // - The database client attempts to close the database. The previous implementation of CSqlSrvDatabase::~CSqlSrvDatabase()
+    //        would only remove "c:[11111111]a.db" entry from iSecurityMap and close the iAttachDbMap map.
+    // The result: no opened or attached databases but there will be one entry in iSecurityMap: "c:[11111111]b.db".
+    // OOM tests will report a memory leak in this case. On a real device, if "c:[11111111]b.db" gets deleted and
+    // recreated again, unexpected memory leak will occur in CSqlSrvDatabase::ConstructCreateSecureL() because
+    // the code there "expects" that is the first time when a "c:[11111111]b.db" entry is added to iSecurityMap.
+    TSqlAttachDbMapIterator it(iAttachDbMap);
+    TSqlAttachDbPair attachDbPair;
+    while(it.Next(attachDbPair))
+        {
+        __SQLASSERT(attachDbPair.iData, ESqlPanicInvalidObj);
+        ::SqlServer().SecurityMap().Remove(attachDbPair.iData);
+        }
 	iAttachDbMap.Close();
 	::CloseDbHandle(iDbHandle);
 	}
@@ -1042,6 +1074,7 @@
 		aMapKey = ::CreateStrCopyLC(aMapKey);
 		CSqlSecurityPolicy* securityPolicy = aAttachedDb ? ::LoadAttachedDbSecurityPolicyLC(aFileData) :
 		                                                   ::LoadDbSecurityPolicyLC(iDbHandle);
+        __SQLASSERT(!::SqlServer().SecurityMap().Entry(aMapKey), ESqlPanicObjExists);
 		__SQLLEAVE_IF_ERROR(::SqlServer().SecurityMap().Insert(aMapKey, securityPolicy));
 		CleanupStack::Pop(2);//iSecurityMap owns aMapKey and securityPolicy objects
 		aSecurityPolicy = securityPolicy;
@@ -1115,6 +1148,7 @@
 	const TUint8* mapKey = ::CreateStrCopyLC(iFileNameBuf);
 	const TUint8* mapData = SecurityMapKeyL(aDbFileName);
 	mapData = ::CreateStrCopyLC(mapData);
+    __SQLASSERT(!iAttachDbMap.Entry(mapKey), ESqlPanicObjExists);
 	__SQLLEAVE_IF_ERROR(iAttachDbMap.Insert(mapKey, mapData));
 	CleanupStack::Pop(2);//iAttachDbMap owns mapKey amd mapData.
 	}
@@ -1326,6 +1360,7 @@
 	HBufC* data = aDbFileName.Alloc();
 	if(key && data)
 		{
+	    __SQLASSERT(!iCompactDbMap.Entry(key), ESqlPanicObjExists);
 		err = iCompactDbMap.Insert(key, data);//returns the index of the new entry
 		}
 	if(err < 0) //If either "key" or "data" or both is NULL, then "err" is KErrNoMemory and the next "if" will be executed.
@@ -1438,6 +1473,7 @@
 	CleanupStack::PushL(aSecurityPolicy);
 	const TUint8* mapKey = SecurityMapKeyL(aFileData.FileName());
 	mapKey = ::CreateStrCopyLC(mapKey);
+    __SQLASSERT(!::SqlServer().SecurityMap().Entry(mapKey), ESqlPanicObjExists);
 	__SQLLEAVE_IF_ERROR(::SqlServer().SecurityMap().Insert(mapKey, aSecurityPolicy));
 	CleanupStack::Pop(2);//iSecurityMap owns mapKey and aSecurityPolicy.
 	iSecureDbName = mapKey;
--- a/persistentstorage/sql/SRC/Server/SqlSrvSecurityMap.h	Mon Mar 15 12:46:30 2010 +0200
+++ b/persistentstorage/sql/SRC/Server/SqlSrvSecurityMap.h	Thu Apr 01 00:19:42 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2005-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"
@@ -183,6 +183,7 @@
 typedef class TLinearOrder<TSqlCompactDbPair> TSqlCompactDbLinearOrder;
 typedef class RSqlMap<const HBufC*, const HBufC*, TSqlCompactDbRefCounter, TSqlCompactDbDestructor>  RSqlCompactDbMap;
 typedef class TSqlMapIterator<const HBufC*, const HBufC*, TSqlCompactDbRefCounter, TSqlCompactDbDestructor> TSqlCompactDbMapIterator;
+typedef TSqlMapIterator<const TUint8*, const TUint8*, TSqlAttachDbRefCounter, TSqlAttachDbDestructor>  TSqlAttachDbMapIterator;
 
 /////////////////////////////////////////////////////////////////////////////////////////////////////////
 
--- a/persistentstorage/sql/SRC/Server/SqlSrvSession.cpp	Mon Mar 15 12:46:30 2010 +0200
+++ b/persistentstorage/sql/SRC/Server/SqlSrvSession.cpp	Thu Apr 01 00:19:42 2010 +0300
@@ -511,18 +511,20 @@
 Arg 2: [in]  PPPPCCCC, where PPPP is the security policy length, CCCC is the config string length.
 Arg 3: [in]  security policies buffer | config string
 
-@leave KErrArgument If config string length or security policy length is invalid (negative length or too big length)
 @panic SqlDb 1 Client panic. iDatabase is not NULL (it has been created already)
+@panic SqlDb 4 Client panic. Negative or too big config string length
+@panic SqlDb 4 Client panic. Negative security policy length, or zero length if the request is to create a secure database 
 */
 void CSqlSrvSession::DbCreateObjectL(const RMessage2& aMessage, TSqlSrvFunction aFunction)
 	{
 	__SQLPANIC_CLIENT(!iDatabase, aMessage, ESqlPanicObjExists);
 	const TInt KSecurityPolicyLen = (aMessage.Int2() & 0x7fff0000) >> 16;
+    //If the security policy length is negative then this is a programming error.
+    __SQLPANIC_CLIENT(KSecurityPolicyLen >= 0, aMessage, ESqlPanicBadArgument);
 	const TInt KConfigStringLen = aMessage.Int2() & 0xffff;
-	if(KSecurityPolicyLen < 0 || (TUint)KConfigStringLen > KSqlSrvMaxConfigStrLen)
-		{
-		__SQLLEAVE(KErrArgument);	
-		}
+	//If KConfigStringLen is invalid then this is a programming error. 
+	//If the client sends a too big config string - this is handled in the client side session.
+    __SQLPANIC_CLIENT((TUint)KConfigStringLen <= KSqlSrvMaxConfigStrLen, aMessage, ESqlPanicBadArgument);
 	RBuf8 securityAndConfigBuf;
 	CleanupClosePushL(securityAndConfigBuf);
 	if((KSecurityPolicyLen + KConfigStringLen) > 0)
@@ -550,7 +552,8 @@
 			break;
 		case ESqlSrvDbCreateSecure:
 			{
-			if(!fileData.IsSecureFileNameFmt() || KSecurityPolicyLen == 0)
+		    __SQLPANIC_CLIENT(KSecurityPolicyLen > 0, aMessage, ESqlPanicBadArgument);
+			if(!fileData.IsSecureFileNameFmt())
 				{
 				__SQLLEAVE(KErrArgument);	
 				}
@@ -1524,14 +1527,13 @@
 	aStreamBuf->PushL();
 	iIpcStreams.AllocL();
 	TInt size = aStreamBuf->SizeL();
+	__SQLASSERT(size >= 0, ESqlPanicInternalError);
 	TPckgBuf<TIpcStreamBuf> ipcBuf;
-	if(size > 0)						// read the first buffer-full
-		{
-		TInt len = Min(size, KIpcBufSize);
-		aStreamBuf->ReadL(ipcBuf().iData, len);
-		}
+    // read the first buffer-full
+    TInt len = Min(size, KIpcBufSize);
+    aStreamBuf->ReadL(ipcBuf().iData, len);
 	TInt handle = 0;
-	if(size < 0 || size > KIpcBufSize)
+	if(size > KIpcBufSize)
 		{								// create the stream object
 		HIpcStream* ipcStream = new (ELeave) HIpcStream(aStreamBuf, KIpcBufSize);
 		handle = iIpcStreams.Add(ipcStream);
@@ -1542,12 +1544,9 @@
 		{
 		CleanupStack::PopAndDestroy(aStreamBuf);
 		}
-	if(size >= 0)
-		{
-		ipcBuf().iExt = size;
-		aMessage.WriteL(2, ipcBuf);
-		SQLPROFILER_REPORT_IPC(ESqlIpcWrite, size);
-		}
+    ipcBuf().iExt = size;
+    aMessage.WriteL(2, ipcBuf);
+    SQLPROFILER_REPORT_IPC(ESqlIpcWrite, size);
 	return handle;
 	}
 
--- a/persistentstorage/sql/TEST/t_sqlapi.cpp	Mon Mar 15 12:46:30 2010 +0200
+++ b/persistentstorage/sql/TEST/t_sqlapi.cpp	Thu Apr 01 00:19:42 2010 +0300
@@ -1341,7 +1341,7 @@
     TBuf8<1> buf2;
     rc = stmt.ColumnBinary(1, buf2); 
     TEST2(rc, KErrOverflow);
-	
+    
 	stmt.Close();
 	
 	//Deallocate buf
@@ -1355,6 +1355,86 @@
 	}
 
 /**
+@SYMTestCaseID          PDS-SQL-CT-4174
+@SYMTestCaseDesc        Test for DEF144937: SQL, SQL server, the code coverage can be improved in some areas.
+@SYMTestPriority        High
+@SYMTestActions         The test creates a test database with a table with 3 records.
+                        The first record has a BLOB column with 0 length.
+                        The second record has a BLOB column with length less than KSqlMaxDesLen
+                        (in debug mode) in which case no IPC call is needed to be made in order 
+                        to access the column value via stream.
+                        The third record has a BLOB column with length exactly KSqlMaxDesLen 
+                        in which case an IPC call will be made in order to retrieve the column value,
+                        but the column value will be copied directly to the client - no stream object is created. 
+@SYMTestExpectedResults Test must not fail
+@SYMDEF                 DEF144937
+*/  
+void ColumnBinaryStreamTest2()
+    {
+    RSqlDatabase db;    
+    TInt rc = db.Create(KTestDbName1);
+    TEST2(rc, KErrNone);
+
+    enum {KSqlBufSize = 128};
+    
+    //Create a table
+    _LIT8(KSqlStmt1, "CREATE TABLE A(Fld1 INTEGER, Fld2 BLOB);");
+    ExecSqlStmtOnDb<TDesC8, TBuf8<KSqlBufSize> >(db, KSqlStmt1(), KErrNone);
+    
+    //Insert one record where the BLOB length is 0. 
+    //Insert second record where the BLOB length is smaller than the max inline column length - KSqlMaxDesLen.
+    //Insert third record where the BLOB length is exactly the max inline column length - KSqlMaxDesLen.
+    _LIT8(KSqlStmt2, "INSERT INTO A VALUES(1, '');INSERT INTO A VALUES(2, x'0102030405');INSERT INTO A VALUES(3, x'0102030405060708');");
+    ExecSqlStmtOnDb<TDesC8, TBuf8<KSqlBufSize> >(db, KSqlStmt2(), KErrNone);
+    
+    RSqlStatement stmt;
+    rc = stmt.Prepare(db, _L("SELECT Fld2 FROM A"));
+    TEST2(rc, KErrNone);
+
+    TBuf8<16> databuf;
+    
+    rc = stmt.Next();
+    TEST2(rc, KSqlAtRow);
+    //ColumnBinary() does not make an IPC call because the BLOB length is 0.
+    RSqlColumnReadStream strm;
+    rc = strm.ColumnBinary(stmt, 0);
+    TEST2(rc, KErrNone);
+    TRAP(rc, strm.ReadL(databuf, stmt.ColumnSize(0)));
+    strm.Close();
+    TEST2(rc, KErrNone);
+    TEST2(databuf.Length(), 0);
+
+    rc = stmt.Next();
+    TEST2(rc, KSqlAtRow);
+    //ColumnBinary() does not make an IPC call because the BLOB length is less than the max inline 
+    //column length - KSqlMaxDesLen.
+    rc = strm.ColumnBinary(stmt, 0);
+    TEST2(rc, KErrNone);
+    TRAP(rc, strm.ReadL(databuf, stmt.ColumnSize(0)));
+    strm.Close();
+    TEST2(rc, KErrNone);
+    TEST(databuf == _L8("\x1\x2\x3\x4\x5"));
+
+    rc = stmt.Next();
+    TEST2(rc, KSqlAtRow);
+    //ColumnBinary() makes an IPC call  (in _DEBUG mode) because:
+    // - the column length is exactly KSqlMaxDesLen.  
+    // - but at the same time the column length is equal to KIpcBufSize (in debug mode).
+    rc = strm.ColumnBinary(stmt, 0);
+    TEST2(rc, KErrNone);
+    TRAP(rc, strm.ReadL(databuf, stmt.ColumnSize(0)));
+    strm.Close();
+    TEST2(rc, KErrNone);
+    TEST(databuf == _L8("\x1\x2\x3\x4\x5\x6\x7\x8"));
+    
+    stmt.Close();
+    db.Close();
+
+    rc = RSqlDatabase::Delete(KTestDbName1);
+    TEST2(rc, KErrNone);
+    }
+
+/**
 @SYMTestCaseID			SYSLIB-SQL-CT-1608
 @SYMTestCaseDesc		Setting long text parameter values test.
 @SYMTestPriority		High
@@ -2194,6 +2274,9 @@
 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-CT-1621 RSqlColumnReadStream test. Long binary column "));
 	ColumnBinaryStreamTest();
 
+    TheTest.Next (_L(" @SYMTestCaseID:PDS-SQL-CT-4174 CSqlSrvSession::NewOutputStreamL() coverage test"));
+	ColumnBinaryStreamTest2();
+	
 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-CT-1608 RSqlParamWriteStream test. Long text parameter "));
 	TextParameterStreamTest();
 
--- a/persistentstorage/sql/TEST/t_sqldbconfigfile.cpp	Mon Mar 15 12:46:30 2010 +0200
+++ b/persistentstorage/sql/TEST/t_sqldbconfigfile.cpp	Thu Apr 01 00:19:42 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2008-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"
@@ -45,13 +45,6 @@
 RSqlDatabase TheDb;
 sqlite3 *TheDbHandle = NULL;
 
-_LIT(KTestDir, "c:\\test\\");
-_LIT(KSqlSrvName, "sqlsrv.exe");
-
-enum TConfigParamType {EPrmCacheSize, EPrmPageSize, EPrmDbEncoding};
-
-TInt KillProcess(const TDesC& aProcessName);
-
 _LIT(KCfgDb1, "c:[1111C1C1]a.db"); // shared, secure db
 _LIT(KCfgDb2, "c:[1111C1C1]b.db"); // shared, secure db (no config file for it)
 _LIT(KCfgDb3, "c:\\private\\1111C1C1\\c.db"); // private, secure db
@@ -64,14 +57,6 @@
 _LIT(KCfgDb5ConfigFileV01Path, "c:\\private\\10281e17\\cfg[1111C1C1]e.db.01"); // config file v01 for e.db
 _LIT(KCfgDb1CorruptConfigFilePath, "c:\\private\\10281e17\\cfg[1111C1C1]a.db.invalidextension"); // invalid config file name syntax
 
-// config file v01 contents for db1 (also tests that upper and lower case statements are both supported)
-_LIT8(KCfgDb1ConfigFile01Stmts, "CREATE INDEX idx ON table1(i1);CREATE INDEX idx2 ON table1(i2);INSERT INTO table1 (i1,i2,i3) values(5,8,9);DELETE FROM table1;create index multiidx ON TABLE1(i2,i3)");
-// config file v01 contents for db3 (will not be processed as db3 is not a shared, secure db)
-_LIT8(KCfgDb3ConfigFile01Stmts, "CREATE INDEX idx ON table3(i1)");
-// config file v01 contents for db4 (will not be processed as db4 is not a shared, secure db)
-_LIT8(KCfgDb4ConfigFile01Stmts, "CREATE INDEX idx ON table4(i1)");
-// config file v01 contents for db5 (will eventually be processed after db5 itself is created)
-_LIT8(KCfgDb5ConfigFile01Stmts, "CREATE INDEX idx ON table5(i1);\r\n");
 // config file valid contents (used for v02 and others)
 _LIT8(KCfgConfigFileValidStmt, "CREATE INDEX newIdx ON table1(i3)  ;"); 
 // config file v03 empty contents
@@ -104,29 +89,21 @@
 _LIT(KLongCfgName1, "c:\\private\\10281e17\\cfg[1111C1C1]a123456789a123456789a123456789a123456789a123456789a123456789a123456789a123456789a123456789a123456789a123456789a123456789a123456789a123456789a123456789a123456789a123456789a123456789a1234.db.01");
 
 _LIT(KSqlSrvPrivatePath, "\\private\\10281e17\\");
-_LIT(KGetSettingsSql, "SELECT * FROM symbian_settings WHERE Reserved==%d");
 _LIT(KResetCollationDllSql, "UPDATE symbian_settings SET CollationDllName='hjagafsff'");
-_LIT(KGetCollationDllSql, "SELECT CollationDllName FROM symbian_settings");
 
 _LIT(KAttachDb1, "Db1");
 _LIT(KAttachDb2, "Db2");
 _LIT(KAttachDb5, "Db5");
 
-_LIT(KDb1CheckNumRecords, "SELECT * FROM table1");
-_LIT(KDb2CheckNumRecords, "SELECT * FROM table2");
-_LIT(KDb3CheckNumRecords, "SELECT * FROM table3");
-_LIT(KDb4CheckNumRecords, "SELECT * FROM table4");
-_LIT(KDb5CheckNumRecords, "SELECT * FROM table5");
-_LIT(KDbCheckNumIndices, "SELECT name FROM sqlite_master WHERE type = 'index'");
-
 ///////////////////////////////////////////////////////////////////////////////////////
 // Destroy functions
 
-TInt KillProcess(const TDesC& aProcessName)
+void KillSqlServer()
 	{
+	_LIT(KSqlSrvName, "sqlsrv.exe");
 	TFullName name;
 	//RDebug::Print(_L("Find and kill \"%S\" process.\n"), &aProcessName);
-	TBuf<64> pattern(aProcessName);
+	TBuf<64> pattern(KSqlSrvName);
 	TInt length = pattern.Length();
 	pattern += _L("*");
 	TFindProcess procFinder(pattern);
@@ -154,7 +131,6 @@
 			}
 		proc.Close();
 		}
-	return KErrNone;
 	}
 
 void DeleteCfgFilesAndDbs()
@@ -186,7 +162,7 @@
 		TheDbHandle = NULL;
 		}
 	TheDb.Close();
-	(void)KillProcess(KSqlSrvName);
+	KillSqlServer();
 	DeleteCfgFilesAndDbs();
 	TheFs.Close();
 	}
@@ -232,8 +208,8 @@
 
 	RThread().HandleCount(endHandleCount1, endHandleCount2);
 
-	TEST(TheHandleCount1 == endHandleCount1);
-	TEST(TheHandleCount2 == endHandleCount2);
+	TEST2(TheHandleCount1, endHandleCount1);
+	TEST2(TheHandleCount2, endHandleCount2);
 	}
 
 void MarkAllocatedCells()
@@ -244,120 +220,87 @@
 void CheckAllocatedCells()
 	{
 	TInt allocatedCellsCount = User::CountAllocCells();
-	TEST(allocatedCellsCount == TheAllocatedCellsCount);
+	TEST2(allocatedCellsCount, TheAllocatedCellsCount);
 	}
 
 ///////////////////////////////////////////////////////////////////////////////////////
 // Set up functions
 
-TInt DoCreateSecurityPolicy(RSqlSecurityPolicy& securityPolicy)
+RSqlSecurityPolicy CreateSecurityPolicy()
 	{
 	const TSecurityPolicy KDefaultPolicy(TSecurityPolicy::EAlwaysPass);
-	if((KErrNone != securityPolicy.Create(KDefaultPolicy))
-	   ||
-	   (KErrNone != securityPolicy.SetDbPolicy(RSqlSecurityPolicy::ESchemaPolicy, KDefaultPolicy))
-	   ||
-	   (KErrNone != securityPolicy.SetDbPolicy(RSqlSecurityPolicy::EWritePolicy, KDefaultPolicy))
-	   ||
-	   (KErrNone != securityPolicy.SetDbPolicy(RSqlSecurityPolicy::EReadPolicy, KDefaultPolicy)))
-		{
-		return KErrGeneral;
-		}
-		
-	return KErrNone;
+	RSqlSecurityPolicy policy;
+	TInt err = policy.Create(KDefaultPolicy);
+	TEST2(err, KErrNone);
+	err = policy.SetDbPolicy(RSqlSecurityPolicy::ESchemaPolicy, KDefaultPolicy);
+    TEST2(err, KErrNone);
+    err = policy.SetDbPolicy(RSqlSecurityPolicy::EWritePolicy, KDefaultPolicy);
+    TEST2(err, KErrNone);
+    err = policy.SetDbPolicy(RSqlSecurityPolicy::EReadPolicy, KDefaultPolicy);
+    TEST2(err, KErrNone);
+    return policy;
 	}
 	
+void DoCreateCfgFile(const TDesC& aFileName, const TDesC8& aData)
+    {
+    RFile file;
+    TInt err = file.Create(TheFs, aFileName, EFileRead | EFileWrite);
+    TEST2(err, KErrNone);
+    err = file.Write(aData); 
+    file.Close();   
+    TEST2(err, KErrNone);
+    }
+
+// Create v01 of the test config files
 void CreateCfgFiles()
 	{
- 	// Create v01 of the test config files
- 	
- 	RFile file;
 	TFileName fileName;
 	TInt v1 = 1;
-	fileName.Format(KCfgDb1ConfigFilePath(), v1);
-	TInt err = file.Create(TheFs, fileName, EFileRead | EFileWrite);
-	TEST2(err, KErrNone);
-	TPtrC8 pDb1((const TUint8*)KCfgDb1ConfigFile01Stmts().Ptr(), KCfgDb1ConfigFile01Stmts().Length());
-	err = file.Write(pDb1);	
-	file.Close();	
-	TEST2(err, KErrNone);
-	
-	fileName.Copy(KCfgDb3ConfigFileV01Path);
-	err = file.Create(TheFs, fileName, EFileRead | EFileWrite);
-	TEST2(err, KErrNone);
-	TPtrC8 pDb3((const TUint8*)KCfgDb3ConfigFile01Stmts().Ptr(), KCfgDb3ConfigFile01Stmts().Length());
-	err = file.Write(pDb3);	
-	file.Close();	
-	TEST2(err, KErrNone);	
-	
-	fileName.Copy(KCfgDb4ConfigFileV01Path);
-	err = file.Create(TheFs, fileName, EFileRead | EFileWrite);
-	TEST2(err, KErrNone);
-	TPtrC8 pDb4((const TUint8*)KCfgDb4ConfigFile01Stmts().Ptr(), KCfgDb4ConfigFile01Stmts().Length());
-	err = file.Write(pDb4);	
-	file.Close();	
-	TEST2(err, KErrNone);
-	
-	fileName.Copy(KCfgDb5ConfigFileV01Path); // create the config file for Db5 before the database has been created
-	err = file.Create(TheFs, fileName, EFileRead | EFileWrite);
-	TEST2(err, KErrNone);
-	TPtrC8 pDb5((const TUint8*)KCfgDb5ConfigFile01Stmts().Ptr(), KCfgDb5ConfigFile01Stmts().Length());
-	err = file.Write(pDb5);	
-	file.Close();	
-	TEST2(err, KErrNone);	
+	fileName.Format(KCfgDb1ConfigFilePath, v1);
+
+	// config file v01 contents for db1 (also tests that upper and lower case statements are both supported)
+	_LIT8(KCfgDb1ConfigFile01Stmts, "CREATE INDEX idx ON table1(i1);CREATE INDEX idx2 ON table1(i2);INSERT INTO table1 (i1,i2,i3) values(5,8,9);DELETE FROM table1;create index multiidx ON TABLE1(i2,i3)");
+    DoCreateCfgFile(fileName, KCfgDb1ConfigFile01Stmts);
+    
+    // config file v01 contents for db3 (will not be processed as db3 is not a shared, secure db)
+    _LIT8(KCfgDb3ConfigFile01Stmts, "CREATE INDEX idx ON table3(i1)");
+    DoCreateCfgFile(KCfgDb3ConfigFileV01Path, KCfgDb3ConfigFile01Stmts);
+    
+    // config file v01 contents for db4 (will not be processed as db4 is not a shared, secure db)
+    _LIT8(KCfgDb4ConfigFile01Stmts, "CREATE INDEX idx ON table4(i1)");
+    DoCreateCfgFile(KCfgDb4ConfigFileV01Path, KCfgDb4ConfigFile01Stmts);
+    
+    // create the config file for Db5 before the database has been created
+    // config file v01 contents for db5 (will eventually be processed after db5 itself is created)
+    _LIT8(KCfgDb5ConfigFile01Stmts, "CREATE INDEX idx ON table5(i1);\r\n");
+    DoCreateCfgFile(KCfgDb5ConfigFileV01Path, KCfgDb5ConfigFile01Stmts);
 	}
 
+void DoCreateCfgDb(const TDesC& aFileName, const TDesC& aCreateTblSql, const TDesC& aInsertSql, 
+                   RSqlSecurityPolicy* aPolicy = NULL)
+    {
+    TInt err = aPolicy ? TheDb.Create(aFileName, *aPolicy) : TheDb.Create(aFileName);
+    TEST2(err, KErrNone);
+    err = TheDb.Exec(aCreateTblSql);
+    TEST(err >= 0);
+    err = TheDb.Exec(aInsertSql);
+    TEST(err == 1);
+    TheDb.Close();
+    }
+
+// Create the test databases
 void CreateCfgDbs()
 	{
-	// Create the test databases
-	
- 	TBuf<100> sql;
- 		
- 	RSqlSecurityPolicy securityPolicy;
- 	TInt err = DoCreateSecurityPolicy(securityPolicy);
- 	TEST2(err, KErrNone);
- 	
- 	err = TheDb.Create(KCfgDb1, securityPolicy);
- 	TEST2(err, KErrNone);
- 	sql.Copy(_L("CREATE TABLE table1(i1 INTEGER, i2 INTEGER, i3 INTEGER)"));
- 	err = TheDb.Exec(sql);
- 	TEST(err >= 0);
- 	sql.Copy(_L("INSERT INTO table1 (i1,i2,i3) values(1,2,3)"));
- 	err = TheDb.Exec(sql);
- 	TEST(err == 1);
- 	TheDb.Close();
- 	
- 	err = TheDb.Create(KCfgDb2, securityPolicy);
- 	TEST2(err, KErrNone);
- 	sql.Copy(_L("CREATE TABLE table2(i1 INTEGER, i2 INTEGER, i3 INTEGER)"));
- 	err = TheDb.Exec(sql);
- 	TEST(err >= 0);
- 	sql.Copy(_L("INSERT INTO table2 (i1,i2,i3) values(4,5,6)"));
- 	err = TheDb.Exec(sql);
- 	TEST(err == 1);
- 	TheDb.Close();
- 	
- 	securityPolicy.Close();
- 
- 	err = TheDb.Create(KCfgDb3);
- 	TEST2(err, KErrNone);
- 	sql.Copy(_L("CREATE TABLE table3(i1 INTEGER, i2 INTEGER)"));
- 	err = TheDb.Exec(sql);
- 	TEST(err >= 0);
- 	sql.Copy(_L("INSERT INTO table3 (i1,i2) values(7,8)"));
- 	err = TheDb.Exec(sql);
- 	TEST(err == 1);
- 	TheDb.Close();	
- 
- 	err = TheDb.Create(KCfgDb4);
- 	TEST2(err, KErrNone);
- 	sql.Copy(_L("CREATE TABLE table4(i1 INTEGER, i2 INTEGER, i3 INTEGER)"));
- 	err = TheDb.Exec(sql);
- 	TEST(err >= 0);
- 	sql.Copy(_L("INSERT INTO table4 (i1,i2,i3) values(9,10,11)"));
- 	err = TheDb.Exec(sql);
- 	TEST(err == 1);
- 	TheDb.Close();
+    RSqlSecurityPolicy securityPolicy = CreateSecurityPolicy();
+    DoCreateCfgDb(KCfgDb1, _L("CREATE TABLE table1(i1 INTEGER, i2 INTEGER, i3 INTEGER)"),
+                           _L("INSERT INTO table1 (i1,i2,i3) values(1,2,3)"), &securityPolicy);
+    DoCreateCfgDb(KCfgDb2, _L("CREATE TABLE table2(i1 INTEGER, i2 INTEGER, i3 INTEGER)"),
+                           _L("INSERT INTO table2 (i1,i2,i3) values(4,5,6)"), &securityPolicy);
+    securityPolicy.Close();
+    DoCreateCfgDb(KCfgDb3, _L("CREATE TABLE table3(i1 INTEGER, i2 INTEGER)"),
+                           _L("INSERT INTO table3 (i1,i2) values(7,8)"));
+    DoCreateCfgDb(KCfgDb4, _L("CREATE TABLE table4(i1 INTEGER, i2 INTEGER, i3 INTEGER)"),
+                           _L("INSERT INTO table4 (i1,i2,i3) values(9,10,11)"));
  	}
 
 void CreateCfgFilesAndDbs()
@@ -367,29 +310,15 @@
 	
 	// Must now kill the SQL Server so that the config files 
 	// created above are found and processed when it restarts
-	(void)KillProcess(KSqlSrvName);
+	KillSqlServer();
  	}
  	
+// Create the Db5 test database (a config file for it already exists)
  void CreateDb5()
 	{
-	// Create the Db5 test database (a config file for it already exists)
-	
- 	TBuf<100> sql;
- 		
- 	RSqlSecurityPolicy securityPolicy;
- 	TInt err = DoCreateSecurityPolicy(securityPolicy);
- 	TEST2(err, KErrNone);
- 	
- 	err = TheDb.Create(KCfgDb5, securityPolicy);
- 	TEST2(err, KErrNone);
- 	sql.Copy(_L("CREATE TABLE table5(i1 INTEGER, i2 INTEGER, i3 INTEGER)"));
- 	err = TheDb.Exec(sql);
- 	TEST(err >= 0);
- 	sql.Copy(_L("INSERT INTO table5 (i1,i2,i3) values(1,2,3)"));
- 	err = TheDb.Exec(sql);
- 	TEST(err == 1);
- 	
- 	TheDb.Close();
+ 	RSqlSecurityPolicy securityPolicy = CreateSecurityPolicy();
+    DoCreateCfgDb(KCfgDb5, _L("CREATE TABLE table5(i1 INTEGER, i2 INTEGER, i3 INTEGER)"),
+                           _L("INSERT INTO table5 (i1,i2,i3) values(1,2,3)"), &securityPolicy);
  	securityPolicy.Close();
 	}
 
@@ -398,6 +327,7 @@
 	TInt err = TheFs.Connect();
 	TEST2(err, KErrNone);
 
+	_LIT(KTestDir, "c:\\test\\");
 	err = TheFs.MkDir(KTestDir);
 	TEST(err == KErrNone || err == KErrAlreadyExists);
 
@@ -431,421 +361,218 @@
 ///////////////////////////////////////////////////////////////////////////////////////
 // Config file replacement functions
 
-void UpgradeDbConfigFile(const TInt aCurrentVersion)
+void UpgradeDbConfigFile(TInt aCurrentVersion)
 	{
-	(void)KillProcess(KSqlSrvName);
-	TFileName oldFile;
-	oldFile.Format(KCfgDb1ConfigFilePath(), aCurrentVersion);
-	TInt err = TheFs.Delete(oldFile);
-	TEST2(err, KErrNone);
-	RFile file;
-	TFileName newFile;
-	TInt newVersion = aCurrentVersion+1;
-	newFile.Format(KCfgDb1ConfigFilePath(), newVersion);
-	err = file.Create(TheFs, newFile, EFileRead | EFileWrite);
+    TInt newVersion = aCurrentVersion + 1;
+    TEST(newVersion != 0 && newVersion != 1 && newVersion != 10 && newVersion != 11 && newVersion < 15);
+	
+    KillSqlServer();
+		
+	TFileName fname;
+	fname.Format(KCfgDb1ConfigFilePath, aCurrentVersion);
+	TInt err = TheFs.Delete(fname);
 	TEST2(err, KErrNone);
 	
-	switch(newVersion)
-		{
-			case 2:
-				{
-				TPtrC8 p((const TUint8*)KCfgConfigFileValidStmt().Ptr(), KCfgConfigFileValidStmt().Length());
-				err = file.Write(p);
-				break;
-				}
-			case 3:
-				{
-				TPtrC8 p((const TUint8*)KCfgDb1ConfigFileV03EmptyStmt().Ptr(), KCfgDb1ConfigFileV03EmptyStmt().Length());
-				err = file.Write(p);
-				break;
-				}
-			case 4:
-				{
-				TPtrC8 p((const TUint8*)KCfgDb1ConfigFileV04UnsupportedStmt().Ptr(), KCfgDb1ConfigFileV04UnsupportedStmt().Length());
-				err = file.Write(p);
-				break;	
-				}
-			case 5:
-				{
-				TPtrC8 p((const TUint8*)KCfgDb1ConfigFileV05OnlyWhitespaceStmt().Ptr(), KCfgDb1ConfigFileV05OnlyWhitespaceStmt().Length());
-				err = file.Write(p);
-				break;
-				}	
-			case 6:
-				{
-				TPtrC8 p((const TUint8*)KCfgDb1ConfigFileV06InvalidSchemaStmt().Ptr(), KCfgDb1ConfigFileV06InvalidSchemaStmt().Length());
-				err = file.Write(p);
-				break;
-				}
-			case 7:
-				{
-				TPtrC8 p((const TUint8*)KCfgDb1ConfigFileV07InvalidCommentedStmt().Ptr(), KCfgDb1ConfigFileV07InvalidCommentedStmt().Length());
-				err = file.Write(p);	
-				break;
-				}
-			case 8:
-				{
-				TPtrC8 p((const TUint8*)KCfgDb1ConfigFileV08SeqStmt().Ptr(), KCfgDb1ConfigFileV08SeqStmt().Length());
-				err = file.Write(p);	
-				break;
-				}
-			case 9:
-				{
-				TPtrC8 p((const TUint8*)KCfgDb1ConfigFileV09WhitespacePreAndPostStmt().Ptr(), KCfgDb1ConfigFileV09WhitespacePreAndPostStmt().Length());
-				err = file.Write(p);	
-				break;
-				}
-			case 12:
-				{
-				// also delete version 10 of file
-				oldFile.Format(KCfgDb1ConfigFilePath(), 10);
-				err = TheFs.Delete(oldFile);
-				TEST2(err, KErrNone);	
-				
-				TPtrC8 p((const TUint8*)KCfgDb1ConfigFileV12InvalidPlusValidStmt().Ptr(), KCfgDb1ConfigFileV12InvalidPlusValidStmt().Length());
-				err = file.Write(p);
-				break;
-				}
-			case 13:
-				{
-				TPtrC8 p((const TUint8*)KCfgDb1ConfigFileV13SQLCommentStmt().Ptr(), KCfgDb1ConfigFileV13SQLCommentStmt().Length());
-				err = file.Write(p);	
-				break;
-				}
-			case 14:
-				{
-				TPtrC8 p((const TUint8*)KCfgDb1ConfigFileV14CCommentStmt().Ptr(), KCfgDb1ConfigFileV14CCommentStmt().Length());
-				err = file.Write(p);	
-				break;
-				}
-			default:
-				{
-				err = KErrArgument;
-				break;
-				}		
-		}
-	file.Close();
-	TEST2(err, KErrNone);
+	if(newVersion == 12)
+	    {
+        // also delete version 10 of file
+	    fname.Format(KCfgDb1ConfigFilePath, 10);
+        err = TheFs.Delete(fname);
+        TEST2(err, KErrNone);   
+	    }
+
+	const TPtrC8 stmts[] = {KNullDesC8(), KNullDesC8(), 
+	        KCfgConfigFileValidStmt(), 
+	        KCfgDb1ConfigFileV03EmptyStmt(),
+	        KCfgDb1ConfigFileV04UnsupportedStmt(),
+	        KCfgDb1ConfigFileV05OnlyWhitespaceStmt(),
+	        KCfgDb1ConfigFileV06InvalidSchemaStmt(),
+	        KCfgDb1ConfigFileV07InvalidCommentedStmt(),
+	        KCfgDb1ConfigFileV08SeqStmt(),
+	        KCfgDb1ConfigFileV09WhitespacePreAndPostStmt(),
+	        KNullDesC8(), KNullDesC8(),
+	        KCfgDb1ConfigFileV12InvalidPlusValidStmt(),
+	        KCfgDb1ConfigFileV13SQLCommentStmt(),
+	        KCfgDb1ConfigFileV14CCommentStmt()};
+
+    fname.Format(KCfgDb1ConfigFilePath, newVersion);
+	DoCreateCfgFile(fname, stmts[newVersion]);
 	}	
 	
-void DowngradeDbConfigFile(const TInt aCurrentVersion)
+void DowngradeDbConfigFile(TInt aCurrentVersion)
 	{
-	(void)KillProcess(KSqlSrvName);
-	TFileName oldFile;
-	oldFile.Format(KCfgDb1ConfigFilePath(), aCurrentVersion);
-	TInt err = TheFs.Delete(oldFile);
+	TEST(aCurrentVersion > 1);
+	
+	KillSqlServer();
+	
+	TFileName fname;
+	fname.Format(KCfgDb1ConfigFilePath, aCurrentVersion);
+	TInt err = TheFs.Delete(fname);
 	TEST2(err, KErrNone);
-	RFile file;
-	TFileName newFile;
-	TInt previousVersion = aCurrentVersion-1;
-	TEST(previousVersion > 0);
-	newFile.Format(KCfgDb1ConfigFilePath(), previousVersion);
-	err = file.Create(TheFs, newFile, EFileRead | EFileWrite);
-	TEST2(err, KErrNone);
-	TPtrC8 p((const TUint8*)KCfgConfigFileValidStmt().Ptr(), KCfgConfigFileValidStmt().Length());
-	err = file.Write(p);
-	file.Close();
-	TEST2(err, KErrNone);
+	
+    fname.Format(KCfgDb1ConfigFilePath, aCurrentVersion - 1);
+    DoCreateCfgFile(fname, KCfgConfigFileValidStmt);
 	}
 	
-void CreateCorruptDbConfigFile(const TInt aCurrentVersion)
+void CreateCorruptDbConfigFile(TInt aCurrentVersion)
 	{
-	(void)KillProcess(KSqlSrvName);
-	TFileName oldFile;
-	oldFile.Format(KCfgDb1ConfigFilePath(), aCurrentVersion);
-	TInt err = TheFs.Delete(oldFile);
+	KillSqlServer();
+	
+	TFileName fname;
+	fname.Format(KCfgDb1ConfigFilePath, aCurrentVersion);
+	TInt err = TheFs.Delete(fname);
 	TEST2(err, KErrNone);
-	RFile file;
-	err = file.Create(TheFs, KCfgDb1CorruptConfigFilePath(), EFileRead | EFileWrite);
-	TEST2(err, KErrNone);
-	TPtrC8 p((const TUint8*)KCfgConfigFileValidStmt().Ptr(), KCfgConfigFileValidStmt().Length());
-	err = file.Write(p);
-	file.Close();
-	TEST2(err, KErrNone);
+
+    DoCreateCfgFile(KCfgDb1CorruptConfigFilePath, KCfgConfigFileValidStmt);
 	}	
 	
 void CreateTwoVersionsOfConfigFile()
 	{
-	(void)KillProcess(KSqlSrvName);
+	KillSqlServer();
+	
 	TInt err = TheFs.Delete(KCfgDb1CorruptConfigFilePath);
 	TEST2(err, KErrNone);
-	RFile file;
-	TFileName newFile;
-	TInt nextVersion = 10;
-	newFile.Format(KCfgDb1ConfigFilePath(), nextVersion);
-	err = file.Create(TheFs, newFile, EFileRead | EFileWrite);
-	TEST2(err, KErrNone);
-	TPtrC8 p10((const TUint8*)KCfgDb1ConfigFileV10ValidStmt().Ptr(), KCfgDb1ConfigFileV10ValidStmt().Length());
-	err = file.Write(p10);
-	file.Close();
-	TEST2(err, KErrNone);
+
+    TInt nextVersion = 10;
+    TFileName fname;
+    fname.Format(KCfgDb1ConfigFilePath, nextVersion);
+    DoCreateCfgFile(fname, KCfgDb1ConfigFileV10ValidStmt);
+	
 	++nextVersion;
-	newFile.Format(KCfgDb1ConfigFilePath(), nextVersion);
-	err = file.Create(TheFs, newFile, EFileRead | EFileWrite);
-	TEST2(err, KErrNone);
-	TPtrC8 p11((const TUint8*)KCfgDb1ConfigFileV11ValidStmt().Ptr(), KCfgDb1ConfigFileV11ValidStmt().Length());
-	err = file.Write(p11);
-	file.Close();
-	TEST2(err, KErrNone);	
+    fname.Format(KCfgDb1ConfigFilePath, nextVersion);
+    DoCreateCfgFile(fname, KCfgDb1ConfigFileV11ValidStmt);
 	}
  
 ///////////////////////////////////////////////////////////////////////////////////////
 // DoDbCfgTests() functions
 
+TInt GetDbCfgVersion(const TDesC& aDbName)
+    {
+    // Note: We have to use SQLite directly to access the settings
+    // table as the SQL Server denies permission to access this table
+    // as it is in a shared, secure database
+    
+    TParse parse;
+    TInt err = parse.Set(aDbName, &KSqlSrvPrivatePath, 0);
+    TEST2(err, KErrNone);
+    
+    TBuf8<KMaxFileName + 1> dbFileName;
+    dbFileName.Copy(parse.FullName());
+    
+    sqlite3 *dbHandle = NULL;
+    TInt rc = sqlite3_open((const char*)dbFileName.PtrZ(), &dbHandle);
+    TEST2(rc, SQLITE_OK);
+    
+    _LIT(KGetDbCfgVersionSql, "SELECT Reserved AS DbCfgVersion FROM symbian_settings");
+    TBuf<100> queryBuf;
+    queryBuf.Copy(KGetDbCfgVersionSql);
+    
+    sqlite3_stmt* stmtHandle = NULL;
+    const void* stmtTailZ = NULL;
+    rc = sqlite3_prepare16_v2(dbHandle, queryBuf.PtrZ(), -1, &stmtHandle, &stmtTailZ);
+    TEST2(rc, SQLITE_OK);
+    
+    rc = sqlite3_step(stmtHandle);
+    TEST2(rc, SQLITE_ROW);
+    
+    TInt version = sqlite3_column_int(stmtHandle, 0);
+    
+    rc = sqlite3_step(stmtHandle);
+    TEST2(rc, SQLITE_DONE);
+    
+    sqlite3_finalize(stmtHandle);
+    sqlite3_close(dbHandle);
+    
+    return version;
+    }
+
 TBool GuessSystemSettingsTable(const TDesC& aDbName, TInt aVersion)
 	{
-	// Note: We have to use SQLite directly to access the settings
-	// table as the SQL Server denies permission to access this table
-	// as it is in a shared, secure database
-	
-	TBool guessIsCorrect = EFalse;
-	
-	TParse parse;
-	parse.Set(aDbName, &KSqlSrvPrivatePath, 0);
-	
-	TBuf8<KMaxFileName + 1> dbFileName;
-	dbFileName.Copy(parse.FullName());
-	
-	TheDbHandle = NULL;
-	TInt rc = sqlite3_open((const char*)dbFileName.PtrZ(), &TheDbHandle);
-	TEST2(rc, SQLITE_OK);
-	
-	TBuf<100> queryBuf;
-	queryBuf.Format(KGetSettingsSql(), aVersion);	
-	
-	sqlite3_stmt* stmtHandle = NULL;
-	const void* stmtTailZ = NULL;
-	rc = sqlite3_prepare16_v2(TheDbHandle, queryBuf.PtrZ(), -1, &stmtHandle, &stmtTailZ);
-	TEST2(rc, SQLITE_OK);
-	
-	rc = sqlite3_step(stmtHandle);
-	if(SQLITE_ROW == rc)
-		{
-		guessIsCorrect = ETrue;
-		rc = sqlite3_step(stmtHandle);
-		TEST2(rc, SQLITE_DONE);
-		}
-	
-	sqlite3_finalize(stmtHandle);
-	sqlite3_close(TheDbHandle);
-	TheDbHandle = NULL;
-	
-	return guessIsCorrect;
+	TInt dbCfgVersion = GetDbCfgVersion(aDbName);
+	return dbCfgVersion == aVersion; 
 	}
 
 void CheckSystemSettingsTable(const TDesC& aDbName, TInt aVersion)
 	{
-	// Note: We have to use SQLite directly to access the settings
-	// table as the SQL Server denies permission to access this table
-	// as it is in a shared, secure database
-	
-	TParse parse;
-	parse.Set(aDbName, &KSqlSrvPrivatePath, 0);
-	
-	TBuf8<KMaxFileName + 1> dbFileName;
-	dbFileName.Copy(parse.FullName());
-	
-	sqlite3 *dbHandle = NULL;
-	TInt rc = sqlite3_open((const char*)dbFileName.PtrZ(), &dbHandle);
-	TEST2(rc, SQLITE_OK);
-	
-	TBuf<100> queryBuf;
-	queryBuf.Format(KGetSettingsSql(), aVersion);	
-	
-	sqlite3_stmt* stmtHandle = NULL;
-	const void* stmtTailZ = NULL;
-	rc = sqlite3_prepare16_v2(dbHandle, queryBuf.PtrZ(), -1, &stmtHandle, &stmtTailZ);
-	TEST2(rc, SQLITE_OK);
-	
-	rc = sqlite3_step(stmtHandle);
-	TEST2(rc, SQLITE_ROW);
-	
-	rc = sqlite3_step(stmtHandle);
-	TEST2(rc, SQLITE_DONE);
-	
-	sqlite3_finalize(stmtHandle);
-	sqlite3_close(dbHandle);
+    TInt dbCfgVersion = GetDbCfgVersion(aDbName);
+    TEST2(dbCfgVersion, aVersion); 
 	}
 
-void CheckNumberRecordsL(const TDesC& aStmt)
+void CheckRecordCount(const TDesC& aTable)
 	{
 	// There should always be only 1 record in the table
 	// in each database as INSERT and DELETE statements are
 	// not supported in the config files
-	
-	// Prepare stmt
-	RSqlStatement stmt;
-	stmt.PrepareL(TheDb, aStmt);
-	
-	// Get each row
-	TUint numRows = 0;
-	TInt err = stmt.Next();
-	while(KSqlAtRow == err)
-		{
-		numRows++;
-		err = stmt.Next();
-		}
-
-	if (KSqlAtEnd != err)
-		{
-		User::Leave(KErrCorrupt);
-		}
-		
-	if (numRows != 1)
-		{
-		User::Leave(KErrArgument);
-		}
-
-	// Close stmt
-	stmt.Close();	
+	TBuf<50> sql;
+	sql.Format(_L("SELECT COUNT(*) FROM %S"), &aTable);
+	TSqlScalarFullSelectQuery q(TheDb);
+	TInt count = 0;
+    TRAPD(err, count = q.SelectIntL(sql));
+    TEST2(err, KErrNone);
+    TEST2(count, 1);
 	}
 	
-TInt NumberIndicesExpectedInDb1(const TInt aExpectedStoredVersion)
+TInt ExpectedDb1IndexCount(TInt aExpectedStoredVersion)
 	{
-	TInt numIndices = -1;
-	
-	switch(aExpectedStoredVersion)
-		{
-     	// Only files 01 - 04, 09 and 11 will be successfully processed and so stored in the settings table
-		case 1:
-			{
-			numIndices = 3; // 3 indices should be added to db1 based on config file 01
-			break;
-			}
-		case 2:
-			{
-			numIndices = 4; // 1 more index should be added to db1 based on config file 02
-			break;
-			}
-		case 3:
-		case 4:
-		case 5:
-		case 6:
-		case 7:
-			{
-			numIndices = 4; // no more indices should be added to db1 based on config file 03 - 07
-			break;
-			}
-		case 8:
-			{
-			numIndices = 6; // 2 more indices should be added to db1 based on config file 08
-			break;
-			}
-		case 9:
-			{
-			numIndices = 7; // 1 more index should be added to db1 based on config file 09
-			break;
-			}
-		case 11:
-			{
-			numIndices = 9; // 2 more indices should be added to db1 based on config file 11
-			break;
-			}	
-		case 12:
-			{
-			numIndices = 10; // 1 more index should be added to db1 based on config file 12
-			break;
-			}
-		case 13:
-			{
-			numIndices = 11; // 1 more index should be added to db1 based on config file 13
-			break;
-			}	
-		case 14:
-			{
-			numIndices = 12; // 1 more index should be added to db1 based on config file 14
-			break;
-			}		
-		}
-		
-	return numIndices;	
+	TEST(aExpectedStoredVersion >= 0 && aExpectedStoredVersion < 15);
+	const TInt KIdxCnt[] = {
+	       -1, 
+	        3,             // Only files 01 - 04, 09 and 11 will be successfully processed and so stored in the settings table
+	        4,             // 1 more index should be added to db1 based on config file 02
+	        4, 4, 4, 4, 4, // no more indices should be added to db1 based on config file 03 - 07 
+	        6,             // 2 more indices should be added to db1 based on config file 08 
+	        7,             // 1 more index should be added to db1 based on config file 09 
+	        -1, 
+	        9,             // 2 more indices should be added to db1 based on config file 11 
+	        10,            // 1 more index should be added to db1 based on config file 12
+	        11,            // 1 more index should be added to db1 based on config file 13
+	        12};           // 1 more index should be added to db1 based on config file 14
+	return KIdxCnt[aExpectedStoredVersion];
 	}
 
-void CheckNumberIndicesL(const TInt aNumIndicesExpected)
+void CheckIndexCount(TInt aExpectedIndexCount)
 	{
-	// Prepare stmt
-	RSqlStatement stmt;
-	stmt.PrepareL(TheDb, KDbCheckNumIndices);
-	
-	// Get each entry of type 'index' in the 'sqlite_master' table
-	TUint numEntries = 0;
-	TInt err = stmt.Next();
-	while(KSqlAtRow == err)
-		{
-		numEntries++;
-		err = stmt.Next();
-		}
-
-	if (KSqlAtEnd != err)
-		{
-		User::Leave(KErrCorrupt);
-		}
-		
-	if (numEntries != aNumIndicesExpected)
-		{
-		User::Leave(KErrArgument);
-		}
-
-	// Close stmt
-	stmt.Close();	
+	_LIT(KDbCheckNumIndices, "SELECT COUNT(*) FROM sqlite_master WHERE type = 'index'");
+    TSqlScalarFullSelectQuery q(TheDb);
+    TInt count = 0;
+    TRAPD(err, count = q.SelectIntL(KDbCheckNumIndices));
+    TEST2(err, KErrNone);
+    TEST2(count, aExpectedIndexCount);
 	}
 
-void DoCfgOpenTests(TInt aExpectedStoredVersion = 1)
+void DoCfgOpenTest(TInt aExpectedStoredVersion, const TDesC& aDbFileName, const TDesC& aTblName, TInt aExpectedIndexCnt)
+    {
+    TInt err = TheDb.Open(aDbFileName);
+    TEST2(err, KErrNone);
+    CheckRecordCount(aTblName);
+    CheckIndexCount(aExpectedIndexCnt);
+    TheDb.Close();
+    // Check that the ops in the specified config file have been applied.
+    CheckSystemSettingsTable(aDbFileName, aExpectedStoredVersion);
+    }
+
+void DoCfgOpenTests(TInt aExpectedStoredVersion)
 	{	
-	// Open a shared, secure database - config ops should be applied on it
+	// Open a shared, secure database - config ops should be applied on it.
+    // There should still be only 1 record and 3 indices in the table.
 	TheTest.Printf(_L("===CfgOpen: Open shared, secure database\r\n"));
-	TInt err = TheDb.Open(KCfgDb1);
-	TEST2(err, KErrNone);
-	TRAP(err, CheckNumberRecordsL(KDb1CheckNumRecords)); // there should still be only 1 record in the table
-	TEST2(err, KErrNone);
-	TRAP(err, CheckNumberIndicesL(NumberIndicesExpectedInDb1(aExpectedStoredVersion))); // there should now be 3 indices in the table
-	TEST2(err, KErrNone);
-	TheDb.Close();
-	CheckSystemSettingsTable(KCfgDb1, aExpectedStoredVersion); // check that the ops in the specified config file have been applied
+	DoCfgOpenTest(aExpectedStoredVersion, KCfgDb1, _L("table1"), ExpectedDb1IndexCount(aExpectedStoredVersion));
 		
-	// Open again the same shared, secure database - no config should occur (it has already been done)
+	// Open again the same shared, secure database - no config should occur (it has already been done).
 	TheTest.Printf(_L("===CfgOpen: Open shared, secure database again\r\n"));
-	err = TheDb.Open(KCfgDb1);
-	TEST2(err, KErrNone);
-	TRAP(err, CheckNumberRecordsL(KDb1CheckNumRecords)); 
-	TEST2(err, KErrNone);
-	TRAP(err, CheckNumberIndicesL(NumberIndicesExpectedInDb1(aExpectedStoredVersion)));
-	TEST2(err, KErrNone);
-	TheDb.Close();
-	CheckSystemSettingsTable(KCfgDb1, aExpectedStoredVersion);
+    DoCfgOpenTest(aExpectedStoredVersion, KCfgDb1, _L("table1"), ExpectedDb1IndexCount(aExpectedStoredVersion));
 	
 	// Open a shared, secure database - no config should occur (there is no config file for this database)
 	TheTest.Printf(_L("===CfgOpen: Open shared, secure database (that has no config file)\r\n"));
-	err = TheDb.Open(KCfgDb2);
-	TEST2(err, KErrNone);
-	TRAP(err, CheckNumberRecordsL(KDb2CheckNumRecords));
-	TEST2(err, KErrNone);
-	TRAP(err, CheckNumberIndicesL(0)); 
-	TEST2(err, KErrNone);
-	TheDb.Close();
-	CheckSystemSettingsTable(KCfgDb2, 0);
+    DoCfgOpenTest(0, KCfgDb2, _L("table2"), 0);
 	
 	// Open a private, secure database - no config should occur
 	TheTest.Printf(_L("===CfgOpen: Open private, secure database\r\n"));
-	err = TheDb.Open(KCfgDb3);
-	TEST2(err, KErrNone);
-	TRAP(err, CheckNumberRecordsL(KDb3CheckNumRecords));
-	TEST2(err, KErrNone);
-	TRAP(err, CheckNumberIndicesL(0)); 
-	TEST2(err, KErrNone);
-	TheDb.Close();
-	CheckSystemSettingsTable(KCfgDb3, 0);
+    DoCfgOpenTest(0, KCfgDb3, _L("table3"), 0);
 	
 	// Open a public database - no config should occur
 	TheTest.Printf(_L("===CfgOpen: Open public database\r\n"));
-	err = TheDb.Open(KCfgDb4);
-	TEST2(err, KErrNone);
-	TRAP(err, CheckNumberRecordsL(KDb4CheckNumRecords));
-	TEST2(err, KErrNone);
-	TRAP(err, CheckNumberIndicesL(0)); 
-	TEST2(err, KErrNone);
-	TheDb.Close();
-	CheckSystemSettingsTable(KCfgDb4, 0);
+    DoCfgOpenTest(0, KCfgDb4, _L("table4"), 0);
 	}
 	
 void DoUpgradedCfgOpenTest()
@@ -915,27 +642,14 @@
 	// Create Db5 - a config file already exists for this database
 	CreateDb5();
 	
-	// Open the shared, secure database Db5 - config ops should be applied on it
+	// Open the shared, secure database Db5 - config ops should be applied on it.
+	// There should now be 1 index in the table.
 	TheTest.Printf(_L("===NewDbCfg: Open shared, secure database\r\n"));
-	TInt err = TheDb.Open(KCfgDb5);
-	TEST2(err, KErrNone);
-	TRAP(err, CheckNumberRecordsL(KDb5CheckNumRecords)); // there should still be only 1 record in the table
-	TEST2(err, KErrNone);
-	TRAP(err, CheckNumberIndicesL(1)); // there should now be 1 index in the table
-	TEST2(err, KErrNone);
-	TheDb.Close();
-	CheckSystemSettingsTable(KCfgDb5, 1); // check that the ops in the specified config file have been applied
+    DoCfgOpenTest(1, KCfgDb5, _L("table5"), 1);
 		
 	// Open again the same shared, secure database - no config should occur (it has already been done)
 	TheTest.Printf(_L("===NewDbCfg: Open shared, secure database again\r\n"));
-	err = TheDb.Open(KCfgDb5);
-	TEST2(err, KErrNone);
-	TRAP(err, CheckNumberRecordsL(KDb5CheckNumRecords)); 
-	TEST2(err, KErrNone);
-	TRAP(err, CheckNumberIndicesL(1));
-	TEST2(err, KErrNone);
-	TheDb.Close();
-	CheckSystemSettingsTable(KCfgDb5, 1);
+    DoCfgOpenTest(1, KCfgDb5, _L("table5"), 1);
 	}
 	
 void DoCfgAttachTests(TInt aExpectedStoredVersion = 0)
@@ -1036,19 +750,15 @@
 	TheTest.Printf(_L("===NewDbCfgAttach: Open private, secure database\r\n"));
 	TInt err = TheDb.Open(KCfgDb3);
 	TEST2(err, KErrNone);
-	TRAP(err, CheckNumberRecordsL(KDb3CheckNumRecords));
-	TEST2(err, KErrNone);
-	TRAP(err, CheckNumberIndicesL(0)); 
-	TEST2(err, KErrNone);
+    CheckRecordCount(_L("table3"));
+    CheckIndexCount(0); 
 	
 	// Attach a shared, secure database - the db5 config file should not be processed
 	TheTest.Printf(_L("===NewDbCfgAttach: Attach shared, secure database\r\n"));
 	err = TheDb.Attach(KCfgDb5, KAttachDb5);
 	TEST2(err, KErrNone);
-	TRAP(err, CheckNumberRecordsL(KDb5CheckNumRecords)); // there should still be only 1 record in the table
-	TEST2(err, KErrNone);
-	TRAP(err, CheckNumberIndicesL(0)); // there should still be no indices in the table
-	TEST2(err, KErrNone);
+    CheckRecordCount(_L("table5"));
+    CheckIndexCount(0); // there should still be no indices in the table
 	TheDb.Close();
 	CheckSystemSettingsTable(KCfgDb5, 1); // check that the config file has been processed for db1
 	CheckSystemSettingsTable(KCfgDb3, 0);
@@ -1101,7 +811,8 @@
 	TInt rc = sqlite3_open((const char*)dbFileName.PtrZ(), &dbHandle);
 	TEST2(rc, SQLITE_OK);
 	
-	TBuf<100> queryBuf;
+	_LIT(KGetCollationDllSql, "SELECT CollationDllName FROM symbian_settings");
+    TBuf<100> queryBuf;
 	queryBuf.Append(KGetCollationDllSql());	
 	
 	sqlite3_stmt* stmtHandle = NULL;
@@ -1146,10 +857,8 @@
 */
 void DoDbCfgTests()
 	{
-	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-4010 DoDbCfgTests "));
-		
 	// Do 'open' tests for new db config file feature
-	DoCfgOpenTests();         // open the test databases
+	DoCfgOpenTests(1);         // open the test databases
  	DoUpgradedCfgOpenTest();  // upgrade the config file for db1 and reopen the test databases
  	DoBadCfgOpenTests();      // corrupt the config file for db1 (in a variety of ways) and reopen the test databases
  	DoNewDbCfgOpenTest();		  // create a db for which a config file already exists and then open the db
@@ -1170,7 +879,7 @@
  	
  	// Do the test that causes both reindexing and db configuration to occur when db1 is opened
 	ResetStoredCollationDll();
-	DoCfgOpenTests();
+	DoCfgOpenTests(1);
 	CheckCollationDllUpdated();
 	
 	// Recreate the original dbs and config files
@@ -1200,8 +909,6 @@
 */
 void DoDbCfgOOMTests()
 	{
-	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-4013 DoDbCfgOOMTests "));
-
 	// Recreate the original dbs and config files
 	DeleteCfgFilesAndDbs();
 	CreateCfgFilesAndDbs();
@@ -1277,8 +984,6 @@
 */
 void DoDbCfgFileIOFailuresTests()
 	{
-	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-4014 DoDbCfgFileIOFailuresTests "));
-
 	// Recreate the original dbs and config files
 	DeleteCfgFilesAndDbs();
 	CreateCfgFilesAndDbs();
@@ -1355,12 +1060,10 @@
 */
 void DoDbCfgPerfTests()
 	{
-	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-4015 DoDbCfgPerfTests "));
-
 	// Recreate the original dbs
 	DeleteCfgFilesAndDbs();
 	CreateCfgDbs(); 
-	(void)KillProcess(KSqlSrvName); // stop the server
+	KillSqlServer();
 
 	// Measure the start up time of the server when
 	// there are no database configuration files to be cached.
@@ -1371,10 +1074,8 @@
 	TInt err = TheDb.Open(KCfgDb4);
 	TUint32 end = User::FastCounter();
 	TEST2(err, KErrNone);
-	TRAP(err, CheckNumberRecordsL(KDb4CheckNumRecords));
-	TEST2(err, KErrNone);
-	TRAP(err, CheckNumberIndicesL(0));
-	TEST2(err, KErrNone);
+    CheckRecordCount(_L("table4"));
+    CheckIndexCount(0);
 	TheDb.Close();
 	CheckSystemSettingsTable(KCfgDb4, 0);
 	TInt ms = CalcTimeMs(start, end);
@@ -1389,10 +1090,8 @@
 	err = TheDb.Open(KCfgDb1);
 	end = User::FastCounter();
 	TEST2(err, KErrNone);
-	TRAP(err, CheckNumberRecordsL(KDb1CheckNumRecords));
-	TEST2(err, KErrNone);
-	TRAP(err, CheckNumberIndicesL(0));
-	TEST2(err, KErrNone);
+    CheckRecordCount(_L("table1"));
+    CheckIndexCount(0);
 	TheDb.Close();
 	CheckSystemSettingsTable(KCfgDb1, 0);
 	ms = CalcTimeMs(start, end);
@@ -1416,7 +1115,7 @@
 	
 	// Create the 4 version 01 config files now
 	CreateCfgFiles(); 
-	(void)KillProcess(KSqlSrvName); // stop the server so that the files are found when it is restarted
+	KillSqlServer(); // stop the server so that the files are found when it is restarted
 	
 	// Measure the start up time of the server when
 	// there are 4 database configuration files to be cached.
@@ -1427,10 +1126,8 @@
 	err = TheDb.Open(KCfgDb4);
 	end = User::FastCounter();
 	TEST2(err, KErrNone);
-	TRAP(err, CheckNumberRecordsL(KDb4CheckNumRecords));
-	TEST2(err, KErrNone);
-	TRAP(err, CheckNumberIndicesL(0));
-	TEST2(err, KErrNone);
+    CheckRecordCount(_L("table4"));
+    CheckIndexCount(0);
 	TheDb.Close();
 	CheckSystemSettingsTable(KCfgDb4, 0);
 	ms = CalcTimeMs(start, end);
@@ -1445,10 +1142,8 @@
 	err = TheDb.Open(KCfgDb1);
 	end = User::FastCounter();
 	TEST2(err, KErrNone);
-	TRAP(err, CheckNumberRecordsL(KDb1CheckNumRecords));
-	TEST2(err, KErrNone);
-	TRAP(err, CheckNumberIndicesL(3));
-	TEST2(err, KErrNone);
+    CheckRecordCount(_L("table1"));
+    CheckIndexCount(3);
 	TheDb.Close();
 	CheckSystemSettingsTable(KCfgDb1, 1);
 	ms = CalcTimeMs(start, end);
@@ -1463,10 +1158,8 @@
 	err = TheDb.Open(KCfgDb1);
 	end = User::FastCounter();
 	TEST2(err, KErrNone);
-	TRAP(err, CheckNumberRecordsL(KDb1CheckNumRecords));
-	TEST2(err, KErrNone);
-	TRAP(err, CheckNumberIndicesL(3));
-	TEST2(err, KErrNone);
+    CheckRecordCount(_L("table1"));
+    CheckIndexCount(3);
 	TheDb.Close();
 	CheckSystemSettingsTable(KCfgDb1, 1);
 	ms = CalcTimeMs(start, end);
@@ -1489,28 +1182,21 @@
 	TheTest.Printf(_L("Execution time: Attach shared, secure Db1 - database config is not considered: %d ms\r\n"), ms);
 	}
 
-void TestStatementsL()
+void TestStatements()
 	{
-	_LIT(KDbName,					"attachDb");
-	_LIT(KCreateIndex,				"CREATE INDEX idx ON tbl(ColA)");
-	_LIT(KCreateIndexIfNotExists,   "CREATE INDEX IF NOT EXISTS idx ON tbl(ColA)");
-	_LIT(KCreateUniqueIndex,		"CREATE UNIQUE INDEX idx ON tbl(ColA)");
-	_LIT(KNonSupported,				"CREATE idx ON tbl(ColA)");
+	_LIT(KDbName, "attachDb");
 	TBuf<200> buf;
 
 	// supported statements
-	
-	TBool rc = IsStatementSupported(KCreateIndex, KDbName, buf); 
+	TBool rc = IsStatementSupported(_L("CREATE INDEX idx ON tbl(ColA)"), KDbName, buf); 
 	TEST(rc);
-	
-	rc = IsStatementSupported(KCreateIndexIfNotExists, KDbName, buf); 
+	rc = IsStatementSupported(_L("CREATE INDEX IF NOT EXISTS idx ON tbl(ColA)"), KDbName, buf); 
 	TEST(rc);
 
 	// unsupported statements
-	rc = IsStatementSupported(KCreateUniqueIndex, KDbName, buf); 
+	rc = IsStatementSupported(_L("CREATE UNIQUE INDEX idx ON tbl(ColA)"), KDbName, buf); 
 	TEST(!rc);
-
-	rc = IsStatementSupported(KNonSupported, KDbName, buf); 
+	rc = IsStatementSupported(_L("CREATE idx ON tbl(ColA)"), KDbName, buf); 
 	TEST(!rc);
 	}
 
@@ -1527,20 +1213,15 @@
 */
 void DoIsStatementSupportedTests()
 	{
-	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-4030 DoIsStatementSupportedTests "));
-	TInt err = KErrNone;
-	TRAP(err, TestStatementsL());
-	TEST2(err, KErrNone);
+	TestStatements();
 	}
 
 void DoLongDbNameTest()
 	{
-	TheTest.Next(_L("'Long database name' tests"));
 	//Create the database	
- 	RSqlSecurityPolicy securityPolicy;
- 	TInt err = DoCreateSecurityPolicy(securityPolicy);
- 	TEST2(err, KErrNone);
- 	err = TheDb.Create(KLongDbName1, securityPolicy);
+ 	RSqlSecurityPolicy securityPolicy = CreateSecurityPolicy();
+ 	
+ 	TInt err = TheDb.Create(KLongDbName1, securityPolicy);
  	TEST2(err, KErrNone);
  	err = TheDb.Exec(_L("CREATE TABLE table1(i1 INTEGER, i2 INTEGER, i3 INTEGER)"));
  	TEST(err >= 0);
@@ -1548,7 +1229,7 @@
  	TEST(err == 1);
  	TheDb.Close();
  	//Kill the server (to reload config file names at the server startup)
-	(void)KillProcess(KSqlSrvName);
+ 	KillSqlServer();
 	///////////////////////////////////////////////////////////////////////
 	TheTest.Printf(_L("Open a database with a long name\r\n"));
 	//Create cfg file
@@ -1563,10 +1244,8 @@
 	//Open the database
 	err = TheDb.Open(KLongDbName1);
 	TEST2(err, KErrNone);
-	TRAP(err, CheckNumberRecordsL(KDb1CheckNumRecords)); // there should still be only 1 record in the table
-	TEST2(err, KErrNone);
-	TRAP(err, CheckNumberIndicesL(1)); // there should now be 1 index in the table
-	TEST2(err, KErrNone);
+    CheckRecordCount(_L("table1"));
+    CheckIndexCount(1); // there should now be 1 index in the table
 	TheDb.Close();
 	const TInt KVersion = 1;
 	CheckSystemSettingsTable(KLongDbName1, KVersion); // check that the ops in the specified config file have been applied
@@ -1583,7 +1262,7 @@
  	TEST(err == 1);
  	TheDb.Close();
  	//Kill the server (to reload config file names at the server startup)
-	(void)KillProcess(KSqlSrvName);
+ 	KillSqlServer();
 	//Open the main database
  	err = TheDb.Open(KCfgDb1);
  	securityPolicy.Close();
@@ -1602,6 +1281,27 @@
  	(void)RSqlDatabase::Delete(KLongDbName1);
 	}
 
+void DoTests()
+    {
+    TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-4010 Database config files test"));
+    DoDbCfgTests();
+    
+    TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-4013 Database config files OOM test"));
+    DoDbCfgOOMTests();
+    
+    TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-4014 Database config files file I/O error simulation test"));
+    DoDbCfgFileIOFailuresTests();
+    
+    TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-4015 Database config files performance test"));
+    DoDbCfgPerfTests();
+
+    TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-4030 Database config files - supported SQl statements test"));
+    DoIsStatementSupportedTests();
+
+    TheTest.Next(_L("'Long database name' tests"));
+    DoLongDbNameTest();
+    }
+
 #endif	//SYSLIBS_TEST
 
 TInt E32Main()
@@ -1614,36 +1314,13 @@
 	__UHEAP_MARK;
 
 #ifdef SYSLIBS_TEST	
-	TheTest.Start(_L("t_sqldbconfigfile tests"));
-
-	// Set up the test environment
+	TheTest.Start(_L("Setting up the test environment"));
 	SetupTestEnv();
-	//Init sqlite library
 	sqlite3SymbianLibInit();
-
-	// Do tests for database config files
-	DoDbCfgTests();
-	
-	// Do OOM tests for database config files
-	DoDbCfgOOMTests();
-	
-	// Do file I/O failure tests for database config files
-	DoDbCfgFileIOFailuresTests();
-
-	// Do performance tests for database config files
-	DoDbCfgPerfTests();
-
-	// Test IsStatementSupportedLC function
-	DoIsStatementSupportedTests();
-
-	//Test with a very long database file (and config file) name
-	DoLongDbNameTest();
- 
-  	// Destroy the test environment
+	DoTests();
  	DestroyTestEnv();
 	sqlite3SymbianLibFinalize();
 	CloseSTDLIB();
-	
 	TheTest.End();
 #else
  	TheTest.Start(_L("This test works only if the whole SQL component is built with SYSLIBS_TEST macro defined!"));
--- a/persistentstorage/sql/TEST/t_sqloom5.cpp	Mon Mar 15 12:46:30 2010 +0200
+++ b/persistentstorage/sql/TEST/t_sqloom5.cpp	Thu Apr 01 00:19:42 2010 +0300
@@ -187,10 +187,7 @@
     delete TheServer;
     TheServer = NULL;
     
-    if(err != KErrNoMemory)
-        {
-        TEST2(err, KErrNone);   
-        }
+    TEST2(err, KErrNone);   
     TheTest.Printf(_L("\r\n===CSqlSrvDatabase::CreateL() OOM test succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo);
     }
 
@@ -235,10 +232,7 @@
     delete TheServer;
     TheServer = NULL;
     
-    if(err != KErrNoMemory)
-        {
-        TEST2(err, KErrNone);   
-        }
+    TEST2(err, KErrNone);   
     TheTest.Printf(_L("\r\n===CSqlSrvDatabase::OpenL() [non-secure db] OOM test succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo);
     }
 
@@ -287,10 +281,7 @@
     delete TheServer;
     TheServer = NULL;
     
-    if(err != KErrNoMemory)
-        {
-        TEST2(err, KErrNone);   
-        }
+    TEST2(err, KErrNone);   
     TheTest.Printf(_L("\r\n===CSqlSrvDatabase::CreateSecureL() OOM test succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo);
     }
 
@@ -335,10 +326,7 @@
     delete TheServer;
     TheServer = NULL;
     
-    if(err != KErrNoMemory)
-        {
-        TEST2(err, KErrNone);   
-        }
+    TEST2(err, KErrNone);   
     TheTest.Printf(_L("\r\n===CSqlSrvDatabase::OpenL() [secure db] OOM test succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo);
     }
 
@@ -515,11 +503,169 @@
     delete TheServer;
     TheServer = NULL;
     
-    if(err != KErrNoMemory)
+    (void)TheFs.Delete(KDbFile4);
+    (void)TheFs.Delete(KDbFile3);
+    
+    TEST2(err, KErrNone);   
+    TheTest.Printf(_L("\r\n===CSqlSrvDatabase::OpenL() & CSqlSrvDatabase::AttachDbL() OOM test succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo);
+    }
+
+/**
+@SYMTestCaseID          PDS-SQL-UT-4172
+@SYMTestCaseDesc        CSqlSrvDatabase::OpenL() & CSqlSrvDatabase::AttachDbL() OOM test.
+@SYMTestPriority        High
+@SYMTestActions         The test runs CSqlSrvDatabase::OpenL() and CSqlSrvDatabase::AttachDbL() in an OOM test.
+                        Two secure databases are created and then, in an OOM loop, the test executes this sequence of
+                        commands: open first database, attach the second database, detach the attached database,
+                        close the first database. 
+@SYMTestExpectedResults Test must not fail
+@SYMDEF                 DEF144577, PDEF44845
+*/  
+void OpenAttachDatabaseOomTest2()
+    {
+    TheServer = NULL; 
+    TRAPD(err, TheServer = CreateSqlServerL());
+    TEST2(err, KErrNone);
+    
+    CreateSecureTestDb(KDbFile3);
+    CreateSecureTestDb(KDbFile4);
+    
+    TInt failingAllocationNo = 0;
+    TheTest.Printf(_L("Iteration:\r\n"));
+    
+    RMessage2 msg;
+    TSqlSrvFileData& fdata = TheServer->FileData();
+    
+    err = KErrNoMemory;
+    while(err == KErrNoMemory)
         {
-        TEST2(err, KErrNone);   
+        TheTest.Printf(_L(" %d"), ++failingAllocationNo);
+        OomPreStep(failingAllocationNo);
+        
+        TRAP(err, fdata.SetL(msg, KDbFile3().Length(), 0, (const TDesC8*)&KDbFile3));
+        if(err == KErrNone)
+            {
+            CSqlSrvDatabase* db = NULL;
+            TRAP(err, db = CSqlSrvDatabase::OpenL(fdata));
+            if(err == KErrNone)
+                {
+                TRAP(err, fdata.SetL(msg, KDbFile4().Length(), 0, (const TDesC8*)&KDbFile4));
+                if(err == KErrNone)
+                    {
+                    TRAP(err, db->AttachDbL(fdata, _L("db2")));
+                    if(err == KErrNone)
+                        {
+                        TRAP(err, db->DetachDbL(_L("db2")));
+                        }
+                    }
+                delete db;
+                }
+            }
+        OomPostStep();
         }
-    TheTest.Printf(_L("\r\n===CSqlSrvDatabase::OpenL() & CSqlSrvDatabase::AttachDbL() OOM test succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo);
+    
+    (void)TheFs.Delete(KDbFile4);
+    (void)TheFs.Delete(KDbFile3);
+    
+    delete TheServer;
+    TheServer = NULL;
+     
+    TEST2(err, KErrNone);   
+    TheTest.Printf(_L("\r\n===CSqlSrvDatabase::OpenL() & CSqlSrvDatabase::AttachDbL() OOM test 2 succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo);
+    }
+
+/**
+@SYMTestCaseID          PDS-SQL-UT-4173
+@SYMTestCaseDesc        CSqlSrvDatabase::OpenL() & CSqlSrvDatabase::CreateSecureL() OOM test.
+@SYMTestPriority        High
+@SYMTestActions         The test runs CSqlSrvDatabase::OpenL() and CSqlSrvDatabase::CreateSecureL() in an OOM test.
+                        The test creates a secure database then executes CSqlSrvDatabase::OpenL() in an OOM loop.
+                        After that the database is deleted and the test executes CSqlSrvDatabase::CreateSecureL() in an OOM loop.
+                        The purpose of the test is to check that the CSqlSrver maps are properly updated when
+                        the database is closed.
+@SYMTestExpectedResults Test must not fail
+@SYMDEF                 DEF144577, PDEF44845
+*/  
+void OpenCreateDatabaseOomTest()
+    {
+    TheServer = NULL; 
+    TRAPD(err, TheServer = CreateSqlServerL());
+    TEST2(err, KErrNone);
+    
+    (void)TheFs.Delete(KDbFile2);
+    CreateSecureTestDb(KDbFile2);
+    
+    TheTest.Printf(_L("Iteration:\r\n"));
+
+    //Open the database
+    TInt failingAllocationNo = 0;
+    err = KErrNoMemory;
+    while(err == KErrNoMemory)
+        {
+        TheTest.Printf(_L(" %d"), ++failingAllocationNo);
+        OomPreStep(failingAllocationNo);
+        
+        RMessage2 msg;
+        TSqlSrvFileData& fdata = TheServer->FileData();
+        TRAP(err, fdata.SetL(msg, KDbFile2().Length(), 0, (const TDesC8*)&KDbFile2));
+        if(err == KErrNone)
+            {
+            CSqlSrvDatabase* db = NULL;
+            TRAP(err, db = CSqlSrvDatabase::OpenL(fdata));
+            if(err == KErrNone)
+                {
+                delete db;
+                }
+            else
+                {
+                TEST(!db);
+                }
+            }
+        OomPostStep();
+        }
+    TEST2(err, KErrNone);   
+    err = TheFs.Delete(KDbFile2);
+    TEST2(err, KErrNone);   
+    //Create the database
+    TInt failingAllocationNo2 = 0;
+    err = KErrNoMemory;
+    while(err == KErrNoMemory)
+        {
+        TheTest.Printf(_L(" %d"), ++failingAllocationNo2);
+        OomPreStep(failingAllocationNo2);
+        RMessage2 msg;
+        TSqlSrvFileData& fdata = TheServer->FileData();
+        TRAP(err, fdata.SetL(msg, KDbFile2().Length(), 0, (const TDesC8*)&KDbFile2));
+        if(err == KErrNone)
+            {
+            TSecurityPolicy defaultPolicy(TSecurityPolicy::EAlwaysPass);
+            CSqlSecurityPolicy* policy = NULL;
+            TRAP(err, policy = CSqlSecurityPolicy::NewL(defaultPolicy));
+            if(err == KErrNone)
+                {
+                CSqlSrvDatabase* db = NULL;
+                TRAP(err, db = CSqlSrvDatabase::CreateSecureL(fdata, policy));
+                if(err == KErrNone)
+                    {
+                    delete db;
+                    }
+                else
+                    {
+                    TEST(!db);
+                    }
+                }
+            }
+        OomPostStep();
+        }
+    
+    (void)TheFs.Delete(KDbFile2);
+    
+    delete TheServer;
+    TheServer = NULL;
+     
+    TEST2(err, KErrNone);   
+    TheTest.Printf(_L("\r\n===CSqlSrvDatabase::OpenL() & CSqlSrvDatabase::CreateSecureL() OOM test succeeded at heap failure rate of %d ===\r\n"), 
+                   failingAllocationNo + failingAllocationNo2);
     }
 
 void DoTests()
@@ -545,7 +691,13 @@
     
     TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-UT-4171 CSqlSrvDatabase::OpenL() & CSqlSrvDatabase::AttachDbL() OOM unit test"));
     OpenAttachDatabaseOomTest();
-    
+
+    TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-UT-4172 CSqlSrvDatabase::OpenL() & CSqlSrvDatabase::AttachDbL() OOM unit test - 2"));
+    OpenAttachDatabaseOomTest2();
+
+    TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-UT-4173 CSqlSrvDatabase::OpenL() & CSqlSrvDatabase::CreateL() OOM unit test"));
+    OpenCreateDatabaseOomTest();
+
     delete scheduler;
 #endif //_DEBUG    
 	}
--- a/persistentstorage/sql/TEST/t_sqlstartup.cpp	Mon Mar 15 12:46:30 2010 +0200
+++ b/persistentstorage/sql/TEST/t_sqlstartup.cpp	Thu Apr 01 00:19:42 2010 +0300
@@ -19,10 +19,15 @@
 #include "SqlSrvStartup.h"
 #include "SqlSrvUtil.h"
 
+_LIT(KCfgDb1ConfigFilePath, "c:\\private\\10281e17\\cfg[10281E17]t_sqlstartup1.db.02"); // config file version 2 for t_sqlstartup1.db
+_LIT(KCfgDb2ConfigFilePath, "c:\\private\\10281e17\\cfg[10281E17]t_sqlstartup2.db.05"); // config file version 5 for t_sqlstartup2.db
+
 ///////////////////////////////////////////////////////////////////////////////////////
 
 RTest TheTest(_L("t_sqlstartup test"));
 
+RFs TheFs;
+
 static TInt TheProcessHandleCount = 0;
 static TInt TheThreadHandleCount = 0;
 static TInt TheAllocatedCellsCount = 0;
@@ -35,6 +40,9 @@
 
 void DeleteTestFiles()
 	{
+	(void)TheFs.Delete(KCfgDb2ConfigFilePath);
+	(void)TheFs.Delete(KCfgDb1ConfigFilePath);
+	TheFs.Close();
 	}
 
 ///////////////////////////////////////////////////////////////////////////////////////
@@ -116,6 +124,9 @@
 static void CreateAndDestroySqlServerL()
     {
     CSqlServer* server = CSqlServer::NewLC();
+    //Drive C: to the RSqlDriveSpaceCol object. This will allow "reserve drive space" construct/destroy code to be tested.  
+    RSqlDriveSpaceCol& drvcol = server->DriveSpaceCol();
+    drvcol.AddL(EDriveC);
     CleanupStack::PopAndDestroy(server);
     }
 
@@ -318,12 +329,69 @@
     TEST(!rc);
     }
 
+/**
+@SYMTestCaseID          PDS-SQL-UT-4175
+@SYMTestCaseDesc        Test for DEF144937: SQL, SQL server, the code coverage can be improved in some areas. 
+@SYMTestPriority        High
+@SYMTestActions         The test creates a SQL server instance and performs some basic operations with
+                        RSqlDriveSpaceCol object owned by the server, such as: adding a new drive,
+                        getting an access to the reserved drive space, releasing the access.
+@SYMTestExpectedResults Test must not fail
+@SYMDEF                 DEF144937
+*/  
+void ReserveDriveSpaceTest()
+    {
+    CSqlServer* srv = NULL;
+    TRAPD(err, srv = CreateSqlServerL());
+    TEST2(err, KErrNone);
+    
+    RSqlDriveSpaceCol& drvcol = srv->DriveSpaceCol();
+    TRAP(err, drvcol.AddL(EDriveC));
+    TEST2(err, KErrNone);
+
+    CSqlDriveSpace* drvspace = drvcol.Find(EDriveZ);
+    TEST(!drvspace);
+    drvspace = drvcol.Find(EDriveC);
+    TEST(drvspace != NULL);
+    
+    TDriveNumber drvnum = drvspace->Drive();
+    TEST2(drvnum, EDriveC);
+    //It is safe to call GetAccessL() more than once. The access is reference counted.
+    TRAP(err, drvspace->GetAccessL());
+    TEST2(err, KErrNone);
+    TRAP(err, drvspace->GetAccessL());
+    TEST2(err, KErrNone);
+    //It is safe if ReleaseAccess() call count do not match GetAccessL() call count.
+    drvspace->ReleaseAccess();
+    drvspace->ReleaseAccess();
+    drvspace->ReleaseAccess();
+    //
+    drvcol.ResetAndDestroy();
+    delete srv;
+    }
+
+void DoCreateCfgFile(const TDesC& aFileName, const TDesC8& aData)
+    {
+    RFile file;
+    TInt err = file.Create(TheFs, aFileName, EFileRead | EFileWrite);
+    TEST2(err, KErrNone);
+    err = file.Write(aData); 
+    file.Close();   
+    TEST2(err, KErrNone);
+    }
+
 void DoTests()
 	{
     CActiveScheduler* scheduler = new CActiveScheduler;
     TEST(scheduler != NULL);
     CActiveScheduler::Install(scheduler);
-	
+
+    //Adding two db config files will allow CDbConfigFiles construct/destroy code also to be tested in the OOM tests.
+    TInt err = TheFs.Connect();
+    TEST2(err, KErrNone);
+    DoCreateCfgFile(KCfgDb1ConfigFilePath, _L8("CREATE INDEX idx ON table1(i1);"));
+    DoCreateCfgFile(KCfgDb2ConfigFilePath, _L8("CREATE INDEX idx1 ON table1(i1);CREATE INDEX idx2 ON table2(i2)"));
+    
     TheTest.Start(_L(" @SYMTestCaseID:PDS-SQL-UT-4159 SQL server startup OOM test"));
     SqlServerStartupOomTest();
 
@@ -339,6 +407,9 @@
     TheTest.Next (_L(" @SYMTestCaseID:PDS-SQL-UT-4163 SQL server, UTF conversion test"));
     UtfConversionTest();
 
+    TheTest.Next (_L(" @SYMTestCaseID:PDS-SQL-UT-4175 Reserve drive space tests"));
+    ReserveDriveSpaceTest();
+    
     delete scheduler;
 	}
 
--- a/persistentstorage/sqlite3api/GROUP/sqlite3tests.iby	Mon Mar 15 12:46:30 2010 +0200
+++ b/persistentstorage/sqlite3api/GROUP/sqlite3tests.iby	Thu Apr 01 00:19:42 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2009-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"
@@ -429,6 +429,10 @@
 data=ZPRIVATE\10285A82\where6.test			\PRIVATE\10285A82\where6.test
 data=ZPRIVATE\10285A82\zeroblob.test			\PRIVATE\10285A82\zeroblob.test
 
+//The next line to be uncommented if the testing is performed locally. Otherwise tests will fail - 
+//the following file is missing and needed by the timezone server.
+//data=ZPRIVATE\10202BE9\1020383e.txt     	\PRIVATE\10202be9\1020383e.txt
+
 file=ABI_DIR\BUILD_DIR\t_sqliteapi.exe		\TEST\t_sqliteapi.exe
 file=ABI_DIR\BUILD_DIR\t_sqlitewsd.exe		\TEST\t_sqlitewsd.exe
 file=ABI_DIR\BUILD_DIR\t_sqlitewsd2.exe		\TEST\t_sqlitewsd2.exe
--- a/persistentstorage/sqlite3api/GROUP/tclsqlite3.mmp	Mon Mar 15 12:46:30 2010 +0200
+++ b/persistentstorage/sqlite3api/GROUP/tclsqlite3.mmp	Thu Apr 01 00:19:42 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"
@@ -11,9 +11,9 @@
 // Contributors:
 //
 // Description:
-// SQLite C API test application
-// The "buildrom" command:
-// buildrom -D_SERIAL_DOWNLOAD -DRVCT -D_EABI=ARMV5 -D_NAND2 -fm=/epoc32/rom/include/featuredatabase.xml h4hrp.oby textshell.oby syslibs_utils.oby sqlite3.iby sqlite3tests.iby openenv.iby bluetooth.iby ups.iby -orombld.img
+// SQLite C API test application (used to run the TCL test suite)
+// The "buildrom" command (uncomment before that the line in sqlite3tests.iby file that copies "1020383e.txt" file):
+// buildrom -D_SERIAL_DOWNLOAD -DRVCT -D_EABI=ARMV5 -fm=/epoc32/rom/include/featuredatabase.xml h4hrp.oby textshell.oby sqlite3.iby sqlite3tests.iby openenv.iby bluetooth.iby ups.iby timezonelocalization.iby -orombld.img
 // 
 //
 
@@ -37,6 +37,9 @@
 EPOCSTACKSIZE 81920  //max 80kb
 EPOCHEAPSIZE 0x00100000 0x02000000
 
+// Need this otherwise get a lot of mismatched IMPORT_C/EXPORT_C even though this is an exe
+MACRO SQLITE_DLL
+
 //////////////////////////////////////////////////////////////////////////////////////////////////////////
 /////////////////  RVCT compiler warning & optimization options  /////////////////////////////////////////
 
--- a/persistentstorage/store/HTOOLS/pfsdump.ipr	Mon Mar 15 12:46:30 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-[purpose]
-
-Display contents of EPOC permanent filestores
-
-[categories]
-development
-
-[files]
-tools\pfsdump.exe
-
-[owner]
-Base: Peripherals & Data		# STORE
-
-[IPR]
-Copyright (c) 2000 Symbian Ltd. All rights reserved.
--- a/persistentstorage/store/group/BLD.INF	Mon Mar 15 12:46:30 2010 +0200
+++ b/persistentstorage/store/group/BLD.INF	Thu Apr 01 00:19:42 2010 +0300
@@ -26,8 +26,6 @@
 
 PRJ_EXPORTS
 
-../HTOOLS/pfsdump.ipr	/epoc32/engdoc/tools/pfsdump.ipr
-
 ../INC/S32BTREE.H SYMBIAN_OS_LAYER_PUBLIC_EXPORT_PATH(s32btree.h)
 ../INC/S32BTREE.INL SYMBIAN_OS_LAYER_PUBLIC_EXPORT_PATH(s32btree.inl)
 ../INC/S32BUF.H SYMBIAN_OS_LAYER_PUBLIC_EXPORT_PATH(s32buf.h)
--- a/persistentstorage/store/group/syslibs_store.mrp	Mon Mar 15 12:46:30 2010 +0200
+++ b/persistentstorage/store/group/syslibs_store.mrp	Thu Apr 01 00:19:42 2010 +0300
@@ -19,8 +19,6 @@
 binary	\sf\os\persistentdata\persistentstorage\store\group	all
 exports	\sf\os\persistentdata\persistentstorage\store\group
 
--export_file	\sf\os\persistentdata\persistentstorage\store\HTOOLS\pfsdump.ipr	\epoc32\engdoc\tools\pfsdump.ipr
-
 #MattD: This doesn't get registered, as it's an 'intermediate' file.
 binary	\epoc32\release\tools\rel\pfsdump.exe