os/persistentdata/persistentstorage/sql/TEST/t_sqloom5.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include <e32test.h>
sl@0
    17
#include <bautils.h>
sl@0
    18
#include "SqlSrvMain.h"
sl@0
    19
#include "SqlSrvStartup.h"
sl@0
    20
#include "SqlSrvUtil.h"
sl@0
    21
#include "SqlSrvDatabase.h"
sl@0
    22
#include "SqlSrvFileData.h"
sl@0
    23
sl@0
    24
///////////////////////////////////////////////////////////////////////////////////////
sl@0
    25
sl@0
    26
RTest TheTest(_L("t_sqloom5 test"));
sl@0
    27
RFs TheFs;
sl@0
    28
sl@0
    29
_LIT(KTestDir, "c:\\test\\");
sl@0
    30
_LIT(KDbFile, "c:\\test\\t_sqloom5.db");
sl@0
    31
_LIT(KDbFile2, "c:[10281E17]t_sqloom5.db");
sl@0
    32
_LIT(KDbFile3, "c:[10281E17]t_sqloom5_2.db");
sl@0
    33
_LIT(KDbFile4, "c:[10281E17]t_sqloom5_3.db");
sl@0
    34
sl@0
    35
_LIT8(KConfig, "encoding=UTF-8");
sl@0
    36
sl@0
    37
extern CSqlServer* TheServer;
sl@0
    38
sl@0
    39
static TInt TheProcessHandleCount = 0;
sl@0
    40
static TInt TheThreadHandleCount = 0;
sl@0
    41
static TInt TheAllocatedCellsCount = 0;
sl@0
    42
sl@0
    43
#ifdef _DEBUG
sl@0
    44
static const TInt KBurstRate = 20;
sl@0
    45
#endif
sl@0
    46
sl@0
    47
enum TSqlDbEncoding
sl@0
    48
    {
sl@0
    49
    ESqlDbUtf16,
sl@0
    50
    ESqlDbUtf8
sl@0
    51
    };
sl@0
    52
sl@0
    53
///////////////////////////////////////////////////////////////////////////////////////
sl@0
    54
sl@0
    55
void DestroyTestEnv()
sl@0
    56
	{
sl@0
    57
    (void)TheFs.Delete(KDbFile4);
sl@0
    58
    (void)TheFs.Delete(KDbFile3);
sl@0
    59
    (void)TheFs.Delete(KDbFile2);
sl@0
    60
    (void)TheFs.Delete(KDbFile);
sl@0
    61
	TheFs.Close();
sl@0
    62
	}
sl@0
    63
sl@0
    64
///////////////////////////////////////////////////////////////////////////////////////
sl@0
    65
///////////////////////////////////////////////////////////////////////////////////////
sl@0
    66
//Test macros and functions
sl@0
    67
void Check(TInt aValue, TInt aLine)
sl@0
    68
	{
sl@0
    69
	if(!aValue)
sl@0
    70
		{
sl@0
    71
		DestroyTestEnv();
sl@0
    72
		RDebug::Print(_L("*** Expresssion evaluated to false\r\n"));
sl@0
    73
		TheTest(EFalse, aLine);
sl@0
    74
		}
sl@0
    75
	}
sl@0
    76
void Check(TInt aValue, TInt aExpected, TInt aLine)
sl@0
    77
	{
sl@0
    78
	if(aValue != aExpected)
sl@0
    79
		{
sl@0
    80
		DestroyTestEnv();
sl@0
    81
		RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
sl@0
    82
		TheTest(EFalse, aLine);
sl@0
    83
		}
sl@0
    84
	}
sl@0
    85
#define TEST(arg) ::Check((arg), __LINE__)
sl@0
    86
#define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
sl@0
    87
sl@0
    88
////////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
    89
sl@0
    90
static void MarkHandles()
sl@0
    91
    {
sl@0
    92
    RThread().HandleCount(TheProcessHandleCount, TheThreadHandleCount);
sl@0
    93
    }
sl@0
    94
sl@0
    95
static void MarkAllocatedCells()
sl@0
    96
    {
sl@0
    97
    TheAllocatedCellsCount = User::CountAllocCells();
sl@0
    98
    }
sl@0
    99
sl@0
   100
static void CheckAllocatedCells()
sl@0
   101
    {
sl@0
   102
    TInt allocatedCellsCount = User::CountAllocCells();
sl@0
   103
    TEST2(allocatedCellsCount, TheAllocatedCellsCount);
sl@0
   104
    }
sl@0
   105
sl@0
   106
static void CheckHandles()
sl@0
   107
    {
sl@0
   108
    TInt endProcessHandleCount;
sl@0
   109
    TInt endThreadHandleCount;
sl@0
   110
    
sl@0
   111
    RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
sl@0
   112
sl@0
   113
    TEST2(TheProcessHandleCount, endProcessHandleCount);
sl@0
   114
    TEST2(TheThreadHandleCount, endThreadHandleCount);
sl@0
   115
    }
sl@0
   116
sl@0
   117
static void OomPreStep(TInt
sl@0
   118
                        #ifdef _DEBUG        
sl@0
   119
                            aFailingAllocationNo
sl@0
   120
                        #endif
sl@0
   121
                      )
sl@0
   122
    {
sl@0
   123
    MarkHandles();
sl@0
   124
    MarkAllocatedCells();
sl@0
   125
    __UHEAP_MARK;
sl@0
   126
    __UHEAP_SETBURSTFAIL(RAllocator::EBurstFailNext, aFailingAllocationNo, KBurstRate);
sl@0
   127
    }
sl@0
   128
sl@0
   129
static void OomPostStep()
sl@0
   130
    {
sl@0
   131
    __UHEAP_RESET;
sl@0
   132
    __UHEAP_MARKEND;
sl@0
   133
    CheckAllocatedCells();
sl@0
   134
    CheckHandles();
sl@0
   135
    }
sl@0
   136
sl@0
   137
////////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
   138
////////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
   139
sl@0
   140
void CreateTestEnv()
sl@0
   141
    {
sl@0
   142
    TInt err = TheFs.Connect();
sl@0
   143
    TEST2(err, KErrNone);
sl@0
   144
sl@0
   145
    err = TheFs.MkDir(KTestDir);
sl@0
   146
    TEST(err == KErrNone || err == KErrAlreadyExists);
sl@0
   147
sl@0
   148
    err = TheFs.CreatePrivatePath(EDriveC);
sl@0
   149
    TEST(err == KErrNone || err == KErrAlreadyExists);
sl@0
   150
    }
sl@0
   151
sl@0
   152
static CSqlServer* CreateSqlServerL()
sl@0
   153
    {
sl@0
   154
    CSqlServer* server = CSqlServer::NewLC();
sl@0
   155
    CleanupStack::Pop(server);
sl@0
   156
    return server;
sl@0
   157
    }
sl@0
   158
sl@0
   159
void CreateDatabaseOomTest(TSqlDbEncoding aEncoding)
sl@0
   160
    {
sl@0
   161
    (void)TheFs.Delete(KDbFile);
sl@0
   162
    TInt failingAllocationNo = 0;
sl@0
   163
    TheTest.Printf(_L("Iteration:\r\n"));
sl@0
   164
    
sl@0
   165
    TheServer = NULL; 
sl@0
   166
    TRAPD(err, TheServer = CreateSqlServerL());
sl@0
   167
    TEST2(err, KErrNone);
sl@0
   168
    
sl@0
   169
    err = KErrNoMemory;
sl@0
   170
    while(err == KErrNoMemory)
sl@0
   171
        {
sl@0
   172
        TheTest.Printf(_L(" %d"), ++failingAllocationNo);
sl@0
   173
        OomPreStep(failingAllocationNo);
sl@0
   174
        
sl@0
   175
        TSqlSrvFileData& fdata = TheServer->FileData();
sl@0
   176
        RMessage2 msg;
sl@0
   177
        TRAP(err, fdata.SetL(msg, KDbFile().Length(), 0, KDbFile, aEncoding == ESqlDbUtf8 ? &KConfig : NULL));
sl@0
   178
        if(err == KErrNone)
sl@0
   179
            {
sl@0
   180
            CSqlSrvDatabase* db = NULL;
sl@0
   181
            TRAP(err, db = CSqlSrvDatabase::CreateL(fdata));
sl@0
   182
            delete db;
sl@0
   183
            }
sl@0
   184
        OomPostStep();
sl@0
   185
        }
sl@0
   186
sl@0
   187
    delete TheServer;
sl@0
   188
    TheServer = NULL;
sl@0
   189
    
sl@0
   190
    TEST2(err, KErrNone);   
sl@0
   191
    TheTest.Printf(_L("\r\n===CSqlSrvDatabase::CreateL() OOM test succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo);
sl@0
   192
    }
sl@0
   193
sl@0
   194
/**
sl@0
   195
@SYMTestCaseID          PDS-SQL-UT-4167
sl@0
   196
@SYMTestCaseDesc        CSqlSrvDatabase::CreateL() OOM test.
sl@0
   197
@SYMTestPriority        High
sl@0
   198
@SYMTestActions         The test runs CSqlSrvDatabase::CreateL() in an OOM loop.
sl@0
   199
                        UTF16 encoded database is used.
sl@0
   200
@SYMTestExpectedResults Test must not fail
sl@0
   201
@SYMDEF                 DEF144577
sl@0
   202
*/  
sl@0
   203
void Utf16CreateDatabaseOomTest()
sl@0
   204
    {
sl@0
   205
    CreateDatabaseOomTest(ESqlDbUtf16);
sl@0
   206
    }
sl@0
   207
sl@0
   208
/**
sl@0
   209
@SYMTestCaseID          PDS-SQL-UT-4182
sl@0
   210
@SYMTestCaseDesc        CSqlSrvDatabase::CreateL() OOM test.
sl@0
   211
@SYMTestPriority        High
sl@0
   212
@SYMTestActions         The test runs CSqlSrvDatabase::CreateL() in an OOM loop.
sl@0
   213
                        UTF8 encoded database is used.
sl@0
   214
@SYMTestExpectedResults Test must not fail
sl@0
   215
@SYMDEF                 DEF145047
sl@0
   216
*/  
sl@0
   217
void Utf8CreateDatabaseOomTest()
sl@0
   218
    {
sl@0
   219
    CreateDatabaseOomTest(ESqlDbUtf8);
sl@0
   220
    }
sl@0
   221
sl@0
   222
void OpenDatabaseOomTest()
sl@0
   223
    {
sl@0
   224
    //The database is created by the previous test: CreateDatabaseOomTest().
sl@0
   225
    
sl@0
   226
    TInt failingAllocationNo = 0;
sl@0
   227
    TheTest.Printf(_L("Iteration:\r\n"));
sl@0
   228
    
sl@0
   229
    TheServer = NULL; 
sl@0
   230
    TRAPD(err, TheServer = CreateSqlServerL());
sl@0
   231
    TEST2(err, KErrNone);
sl@0
   232
    
sl@0
   233
    err = KErrNoMemory;
sl@0
   234
    while(err == KErrNoMemory)
sl@0
   235
        {
sl@0
   236
        TheTest.Printf(_L(" %d"), ++failingAllocationNo);
sl@0
   237
        OomPreStep(failingAllocationNo);
sl@0
   238
        
sl@0
   239
        TSqlSrvFileData& fdata = TheServer->FileData();
sl@0
   240
        RMessage2 msg;
sl@0
   241
        TRAP(err, fdata.SetL(msg, KDbFile().Length(), 0, KDbFile));
sl@0
   242
        if(err == KErrNone)
sl@0
   243
            {
sl@0
   244
            CSqlSrvDatabase* db = NULL;
sl@0
   245
            TRAP(err, db = CSqlSrvDatabase::OpenL(fdata));
sl@0
   246
            delete db;
sl@0
   247
            }
sl@0
   248
        
sl@0
   249
        OomPostStep();
sl@0
   250
        }
sl@0
   251
    
sl@0
   252
    delete TheServer;
sl@0
   253
    TheServer = NULL;
sl@0
   254
    
sl@0
   255
    TEST2(err, KErrNone);   
sl@0
   256
    TheTest.Printf(_L("\r\n===CSqlSrvDatabase::OpenL() [non-secure db] OOM test succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo);
sl@0
   257
    }
sl@0
   258
sl@0
   259
/**
sl@0
   260
@SYMTestCaseID          PDS-SQL-UT-4168
sl@0
   261
@SYMTestCaseDesc        CSqlSrvDatabase::OpenL() OOM test - non-secure database.
sl@0
   262
@SYMTestPriority        High
sl@0
   263
@SYMTestActions         The test runs CSqlSrvDatabase::OpenL() in an OOM loop.
sl@0
   264
                        UTF16 encoded database is used.
sl@0
   265
@SYMTestExpectedResults Test must not fail
sl@0
   266
@SYMDEF                 DEF144577
sl@0
   267
*/  
sl@0
   268
void Utf16OpenDatabaseOomTest()
sl@0
   269
    {
sl@0
   270
    OpenDatabaseOomTest();
sl@0
   271
    }
sl@0
   272
sl@0
   273
/**
sl@0
   274
@SYMTestCaseID          PDS-SQL-UT-4183
sl@0
   275
@SYMTestCaseDesc        CSqlSrvDatabase::OpenL() OOM test - non-secure database.
sl@0
   276
@SYMTestPriority        High
sl@0
   277
@SYMTestActions         The test runs CSqlSrvDatabase::OpenL() in an OOM loop.
sl@0
   278
                        UTF8 encoded database is used.
sl@0
   279
@SYMTestExpectedResults Test must not fail
sl@0
   280
@SYMDEF                 DEF145047
sl@0
   281
*/  
sl@0
   282
void Utf8OpenDatabaseOomTest()
sl@0
   283
    {
sl@0
   284
    OpenDatabaseOomTest();
sl@0
   285
    }
sl@0
   286
sl@0
   287
void CreateSecureDatabaseOomTest(TSqlDbEncoding aEncoding)
sl@0
   288
    {
sl@0
   289
    (void)TheFs.Delete(KDbFile2);
sl@0
   290
    TInt failingAllocationNo = 0;
sl@0
   291
    TheTest.Printf(_L("Iteration:\r\n"));
sl@0
   292
    
sl@0
   293
    TheServer = NULL; 
sl@0
   294
    TRAPD(err, TheServer = CreateSqlServerL());
sl@0
   295
    TEST2(err, KErrNone);
sl@0
   296
        
sl@0
   297
    err = KErrNoMemory;
sl@0
   298
    while(err == KErrNoMemory)
sl@0
   299
        {
sl@0
   300
        TheTest.Printf(_L(" %d"), ++failingAllocationNo);
sl@0
   301
        OomPreStep(failingAllocationNo);
sl@0
   302
        
sl@0
   303
        TSqlSrvFileData& fdata = TheServer->FileData();
sl@0
   304
        RMessage2 msg;
sl@0
   305
        TRAP(err, fdata.SetL(msg, KDbFile2().Length(), 0, KDbFile2, aEncoding == ESqlDbUtf8 ? &KConfig : NULL));
sl@0
   306
        if(err == KErrNone)
sl@0
   307
            {
sl@0
   308
            TSecurityPolicy defaultPolicy(TSecurityPolicy::EAlwaysPass);
sl@0
   309
            CSqlSecurityPolicy* policy = NULL;
sl@0
   310
            TRAP(err, policy = CSqlSecurityPolicy::NewL(defaultPolicy));
sl@0
   311
            if(err == KErrNone)
sl@0
   312
                {
sl@0
   313
                CSqlSrvDatabase* db = NULL;
sl@0
   314
                TRAP(err, db = CSqlSrvDatabase::CreateSecureL(fdata, policy));
sl@0
   315
                delete db;
sl@0
   316
                }
sl@0
   317
            }
sl@0
   318
        OomPostStep();
sl@0
   319
        }
sl@0
   320
sl@0
   321
    delete TheServer;
sl@0
   322
    TheServer = NULL;
sl@0
   323
    
sl@0
   324
    TEST2(err, KErrNone);   
sl@0
   325
    TheTest.Printf(_L("\r\n===CSqlSrvDatabase::CreateSecureL() OOM test succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo);
sl@0
   326
    }
sl@0
   327
sl@0
   328
/**
sl@0
   329
@SYMTestCaseID          PDS-SQL-UT-4169
sl@0
   330
@SYMTestCaseDesc        CSqlSrvDatabase::CreateSecureL() OOM test.
sl@0
   331
@SYMTestPriority        High
sl@0
   332
@SYMTestActions         The test runs CSqlSrvDatabase::CreateSecureL() in an OOM loop.
sl@0
   333
                        UTF16 encoded database is used.
sl@0
   334
@SYMTestExpectedResults Test must not fail
sl@0
   335
@SYMDEF                 DEF144577
sl@0
   336
*/  
sl@0
   337
void Utf16CreateSecureDatabaseOomTest()
sl@0
   338
    {
sl@0
   339
    CreateSecureDatabaseOomTest(ESqlDbUtf16);
sl@0
   340
    }
sl@0
   341
sl@0
   342
/**
sl@0
   343
@SYMTestCaseID          PDS-SQL-UT-4184
sl@0
   344
@SYMTestCaseDesc        CSqlSrvDatabase::CreateSecureL() OOM test.
sl@0
   345
@SYMTestPriority        High
sl@0
   346
@SYMTestActions         The test runs CSqlSrvDatabase::CreateSecureL() in an OOM loop.
sl@0
   347
                        UTF8 encoded database is used.
sl@0
   348
@SYMTestExpectedResults Test must not fail
sl@0
   349
@SYMDEF                 DEF145047
sl@0
   350
*/  
sl@0
   351
void Utf8CreateSecureDatabaseOomTest()
sl@0
   352
    {
sl@0
   353
    CreateSecureDatabaseOomTest(ESqlDbUtf8);
sl@0
   354
    }
sl@0
   355
sl@0
   356
void OpenSecureDatabaseOomTest()
sl@0
   357
    {
sl@0
   358
    //The database is created by the previous test: CreateSecureDatabaseOomTest().
sl@0
   359
    
sl@0
   360
    TInt failingAllocationNo = 0;
sl@0
   361
    TheTest.Printf(_L("Iteration:\r\n"));
sl@0
   362
    
sl@0
   363
    TheServer = NULL; 
sl@0
   364
    TRAPD(err, TheServer = CreateSqlServerL());
sl@0
   365
    TEST2(err, KErrNone);
sl@0
   366
    
sl@0
   367
    err = KErrNoMemory;
sl@0
   368
    while(err == KErrNoMemory)
sl@0
   369
        {
sl@0
   370
        TheTest.Printf(_L(" %d"), ++failingAllocationNo);
sl@0
   371
        OomPreStep(failingAllocationNo);
sl@0
   372
        
sl@0
   373
        TSqlSrvFileData& fdata = TheServer->FileData();
sl@0
   374
        RMessage2 msg;
sl@0
   375
        TRAP(err, fdata.SetL(msg, KDbFile2().Length(), 0, KDbFile2));
sl@0
   376
        if(err == KErrNone)
sl@0
   377
            {
sl@0
   378
            CSqlSrvDatabase* db = NULL;
sl@0
   379
            TRAP(err, db = CSqlSrvDatabase::OpenL(fdata));
sl@0
   380
            delete db;
sl@0
   381
            }
sl@0
   382
        
sl@0
   383
        OomPostStep();
sl@0
   384
        }
sl@0
   385
    
sl@0
   386
    delete TheServer;
sl@0
   387
    TheServer = NULL;
sl@0
   388
    
sl@0
   389
    TEST2(err, KErrNone);   
sl@0
   390
    TheTest.Printf(_L("\r\n===CSqlSrvDatabase::OpenL() [secure db] OOM test succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo);
sl@0
   391
    }
sl@0
   392
sl@0
   393
/**
sl@0
   394
@SYMTestCaseID          PDS-SQL-UT-4170
sl@0
   395
@SYMTestCaseDesc        CSqlSrvDatabase::OpenL() OOM test - secure database.
sl@0
   396
@SYMTestPriority        High
sl@0
   397
@SYMTestActions         The test runs CSqlSrvDatabase::OpenL() in an OOM loop.
sl@0
   398
                        UTF16 encoded database is used.
sl@0
   399
@SYMTestExpectedResults Test must not fail
sl@0
   400
@SYMDEF                 DEF144577, PDEF44845
sl@0
   401
*/  
sl@0
   402
void Utf16OpenSecureDatabaseOomTest()
sl@0
   403
    {
sl@0
   404
    OpenSecureDatabaseOomTest();
sl@0
   405
    }
sl@0
   406
sl@0
   407
/**
sl@0
   408
@SYMTestCaseID          PDS-SQL-UT-4185
sl@0
   409
@SYMTestCaseDesc        CSqlSrvDatabase::OpenL() OOM test - secure database.
sl@0
   410
@SYMTestPriority        High
sl@0
   411
@SYMTestActions         The test runs CSqlSrvDatabase::OpenL() in an OOM loop.
sl@0
   412
                        UTF8 encoded database is used.
sl@0
   413
@SYMTestExpectedResults Test must not fail
sl@0
   414
@SYMDEF                 DEF145047
sl@0
   415
*/  
sl@0
   416
void Utf8OpenSecureDatabaseOomTest()
sl@0
   417
    {
sl@0
   418
    OpenSecureDatabaseOomTest();
sl@0
   419
    }
sl@0
   420
sl@0
   421
/////////////////////////////////////////////////////////////
sl@0
   422
sl@0
   423
const TInt KDbConnCount = 7; 
sl@0
   424
#ifdef _DEBUG
sl@0
   425
const TInt KDbAttachedCount = 10;
sl@0
   426
#endif
sl@0
   427
TBuf<10> TheAttachedDbName;
sl@0
   428
sl@0
   429
//Declares KDbConnCount "CSqlSrvDatabase*" variables.  
sl@0
   430
#define TEST_DECLARE_DB_VARS() \
sl@0
   431
    CSqlSrvDatabase* db[KDbConnCount]; \
sl@0
   432
    Mem::FillZ(db, sizeof(db));
sl@0
   433
sl@0
   434
//Declares all KDbConnCount "CSqlSrvDatabase*" objects.  
sl@0
   435
#define TEST_DELETE_DB() \
sl@0
   436
    for(TInt i=0;i<KDbConnCount;++i) \
sl@0
   437
        { \
sl@0
   438
        delete db[i]; \
sl@0
   439
        }
sl@0
   440
sl@0
   441
//Creates CSqlSrvDatabase object where the database file is dbFile (the second macro parameter).
sl@0
   442
//The CSqlSrvDatabase pointer db[N - 1] (N is the first macro parameter) will be set to point to 
sl@0
   443
//the created CSqlSrvDatabase object. 
sl@0
   444
//N is the number of the database to be opened, between 1 and KDbConnCount.
sl@0
   445
#define TEST_OPEN_DB(N, dbFile) \
sl@0
   446
    __ASSERT_DEBUG(N > 0 && N <= KDbConnCount, User::Invariant()); \
sl@0
   447
    TRAP(err, fdata.SetL(msg, dbFile.Length(), 0, dbFile)); \
sl@0
   448
    if(err != KErrNone) \
sl@0
   449
        { \
sl@0
   450
        goto Cleanup; \
sl@0
   451
        } \
sl@0
   452
    db[N - 1] = NULL; \
sl@0
   453
    TRAP(err, db[N - 1] = CSqlSrvDatabase::OpenL(fdata)); \
sl@0
   454
    if(err != KErrNone) \
sl@0
   455
        { \
sl@0
   456
        goto Cleanup; \
sl@0
   457
        }
sl@0
   458
sl@0
   459
//Attaches the "dbFile" database to the database number specified by the first macro parameter.
sl@0
   460
//The attached database name is "A<M>", where M is the third macro parameter.
sl@0
   461
//N is the number of the database connection, between 1 and KDbConnCount.
sl@0
   462
//M is the number of the database to be attached, between 1 and KDbAttachedCount.
sl@0
   463
#define TEST_ATTACH_DB(N, dbFile, M) \
sl@0
   464
    __ASSERT_DEBUG(N > 0 && N <= KDbConnCount, User::Invariant()); \
sl@0
   465
    __ASSERT_DEBUG(M > 0 && M <= KDbAttachedCount, User::Invariant()); \
sl@0
   466
    TRAP(err, fdata.SetL(msg, dbFile.Length(), 0, dbFile)); \
sl@0
   467
    if(err != KErrNone) \
sl@0
   468
        { \
sl@0
   469
        goto Cleanup; \
sl@0
   470
        } \
sl@0
   471
    TheAttachedDbName.Copy(_L("A")); \
sl@0
   472
    TheAttachedDbName.AppendNum(M); \
sl@0
   473
    TRAP(err, db[N - 1]->AttachDbL(fdata, TheAttachedDbName)); \
sl@0
   474
    if(err != KErrNone) \
sl@0
   475
        { \
sl@0
   476
        goto Cleanup; \
sl@0
   477
        }
sl@0
   478
sl@0
   479
//Detaches database "A<M>" (M is the second macro parameter) from the database identified
sl@0
   480
//by the number N - the first macro parameter.
sl@0
   481
//N is the number of the database connection, between 1 and KDbConnCount.
sl@0
   482
//M is the number of the database to be detached, between 1 and KDbAttachedCount.
sl@0
   483
#define TEST_DETACH_DB(N, M) \
sl@0
   484
    __ASSERT_DEBUG(N > 0 && N <= KDbConnCount, User::Invariant()); \
sl@0
   485
    __ASSERT_DEBUG(M > 0 && M <= KDbAttachedCount, User::Invariant()); \
sl@0
   486
    if(db[N - 1]) \
sl@0
   487
        { \
sl@0
   488
        TheAttachedDbName.Copy(_L("A")); \
sl@0
   489
        TheAttachedDbName.AppendNum(M); \
sl@0
   490
        TRAP_IGNORE(db[N - 1]->DetachDbL(TheAttachedDbName)); \
sl@0
   491
        }
sl@0
   492
sl@0
   493
/////////////////////////////////////////////////////////////
sl@0
   494
sl@0
   495
void CreateSecureTestDb(const TDesC& aDbFile, TSqlDbEncoding aEncoding)
sl@0
   496
    {
sl@0
   497
    (void)TheFs.Delete(aDbFile);
sl@0
   498
    
sl@0
   499
    TSecurityPolicy defaultPolicy(TSecurityPolicy::EAlwaysPass);
sl@0
   500
    CSqlSecurityPolicy* policy = NULL;
sl@0
   501
    TRAPD(err, policy = CSqlSecurityPolicy::NewL(defaultPolicy));
sl@0
   502
    TEST2(err, KErrNone);
sl@0
   503
    
sl@0
   504
    TSqlSrvFileData& fdata = TheServer->FileData();
sl@0
   505
    RMessage2 msg;
sl@0
   506
    TRAP(err, fdata.SetL(msg, aDbFile.Length(), 0, aDbFile, aEncoding == ESqlDbUtf8 ? &KConfig : NULL));
sl@0
   507
    
sl@0
   508
    CSqlSrvDatabase* db = NULL;
sl@0
   509
    TRAP(err, db = CSqlSrvDatabase::CreateSecureL(fdata, policy));
sl@0
   510
    delete db;
sl@0
   511
    TEST2(err, KErrNone);
sl@0
   512
    }
sl@0
   513
    
sl@0
   514
void OpenAttachDatabaseOomTest(TSqlDbEncoding aEncoding)
sl@0
   515
    {
sl@0
   516
    //Part of the databases are created by the previous tests.
sl@0
   517
        
sl@0
   518
    TInt failingAllocationNo = 0;
sl@0
   519
    TheTest.Printf(_L("Iteration:\r\n"));
sl@0
   520
    
sl@0
   521
    TheServer = NULL; 
sl@0
   522
    TRAPD(err, TheServer = CreateSqlServerL());
sl@0
   523
    TEST2(err, KErrNone);
sl@0
   524
sl@0
   525
    CreateSecureTestDb(KDbFile3, aEncoding);
sl@0
   526
    CreateSecureTestDb(KDbFile4, aEncoding);
sl@0
   527
    
sl@0
   528
    //The following 2 declarations are used by the macros in the OOM loop
sl@0
   529
    RMessage2 msg;
sl@0
   530
    TSqlSrvFileData& fdata = TheServer->FileData();
sl@0
   531
    
sl@0
   532
    err = KErrNoMemory;
sl@0
   533
    while(err == KErrNoMemory)
sl@0
   534
        {
sl@0
   535
        TheTest.Printf(_L(" %d"), ++failingAllocationNo);
sl@0
   536
        OomPreStep(failingAllocationNo);
sl@0
   537
        //Declare KDbConnCount "CSqlSrvDatabase*" variables.
sl@0
   538
        TEST_DECLARE_DB_VARS();
sl@0
   539
        //Create CSqlSrvDatabase object, the database name is the second parameter of the macro. 
sl@0
   540
        //The related db[N - 1] variable will be set to point to the created object.
sl@0
   541
        TEST_OPEN_DB(1, KDbFile2());
sl@0
   542
        TEST_OPEN_DB(2, KDbFile2());
sl@0
   543
        TEST_OPEN_DB(3, KDbFile3());
sl@0
   544
        TEST_OPEN_DB(4, KDbFile3());
sl@0
   545
        TEST_OPEN_DB(5, KDbFile3());
sl@0
   546
        TEST_OPEN_DB(6, KDbFile());
sl@0
   547
        TEST_OPEN_DB(7, KDbFile());
sl@0
   548
        //Attach to the database with the number specified as first macro parameter, the database file, specified
sl@0
   549
        //as second macro parameter. The logical name of the attached database is "A<M>", where M is the third macro parameter.
sl@0
   550
        TEST_ATTACH_DB(1, KDbFile(), 1);
sl@0
   551
        TEST_ATTACH_DB(2, KDbFile(), 2);
sl@0
   552
        TEST_ATTACH_DB(2, KDbFile(), 3);
sl@0
   553
        TEST_ATTACH_DB(5, KDbFile4(), 4);
sl@0
   554
        TEST_ATTACH_DB(2, KDbFile4(), 5);
sl@0
   555
        TEST_ATTACH_DB(2, KDbFile4(), 6);
sl@0
   556
        TEST_ATTACH_DB(5, KDbFile4(), 7);
sl@0
   557
        TEST_ATTACH_DB(5, KDbFile4(), 8);
sl@0
   558
        TEST_ATTACH_DB(1, KDbFile4(), 9);
sl@0
   559
        TEST_ATTACH_DB(1, KDbFile(), 10);
sl@0
   560
Cleanup:
sl@0
   561
        __UHEAP_SETBURSTFAIL(RAllocator::ENone, 0, 0);
sl@0
   562
        //Detach from the database with the number specified as first macro parameter, the database         
sl@0
   563
        //with name "A<M>", where M is the second macro parameter.
sl@0
   564
        TEST_DETACH_DB(1, 9);
sl@0
   565
        TEST_DETACH_DB(1, 1);
sl@0
   566
        TEST_DETACH_DB(1, 10);
sl@0
   567
        TEST_DETACH_DB(2, 2);
sl@0
   568
        TEST_DETACH_DB(2, 3);
sl@0
   569
        TEST_DETACH_DB(2, 5);
sl@0
   570
        TEST_DETACH_DB(2, 6);
sl@0
   571
        TEST_DETACH_DB(5, 4);
sl@0
   572
        TEST_DETACH_DB(5, 7);
sl@0
   573
        TEST_DETACH_DB(5, 8);
sl@0
   574
        //Delete all created CSqlSrvDatabase objects.
sl@0
   575
        TEST_DELETE_DB();        
sl@0
   576
        
sl@0
   577
        OomPostStep();
sl@0
   578
        }
sl@0
   579
    
sl@0
   580
    delete TheServer;
sl@0
   581
    TheServer = NULL;
sl@0
   582
    
sl@0
   583
    (void)TheFs.Delete(KDbFile4);
sl@0
   584
    (void)TheFs.Delete(KDbFile3);
sl@0
   585
    
sl@0
   586
    TEST2(err, KErrNone);   
sl@0
   587
    TheTest.Printf(_L("\r\n===CSqlSrvDatabase::OpenL() & CSqlSrvDatabase::AttachDbL() OOM test succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo);
sl@0
   588
    }
sl@0
   589
sl@0
   590
/**
sl@0
   591
@SYMTestCaseID          PDS-SQL-UT-4171
sl@0
   592
@SYMTestCaseDesc        CSqlSrvDatabase::OpenL() & CSqlSrvDatabase::AttachDbL() OOM test.
sl@0
   593
@SYMTestPriority        High
sl@0
   594
@SYMTestActions         The test runs CSqlSrvDatabase::OpenL() and CSqlSrvDatabase::AttachDbL() in an OOM test.
sl@0
   595
                        The test is a complex one - 7 (KDbConnCount constant) databases opened 
sl@0
   596
                        (secure and non-secure), 10 (KDbAttachedCount constant) databases
sl@0
   597
                        attached (secure and non-secure).
sl@0
   598
                        UTF16 encoded database is used.
sl@0
   599
@SYMTestExpectedResults Test must not fail
sl@0
   600
@SYMDEF                 DEF144577, DEF144603
sl@0
   601
*/  
sl@0
   602
void Utf16OpenAttachDatabaseOomTest()
sl@0
   603
    {
sl@0
   604
    OpenAttachDatabaseOomTest(ESqlDbUtf16);
sl@0
   605
    }
sl@0
   606
sl@0
   607
/**
sl@0
   608
@SYMTestCaseID          PDS-SQL-UT-4186
sl@0
   609
@SYMTestCaseDesc        CSqlSrvDatabase::OpenL() & CSqlSrvDatabase::AttachDbL() OOM test.
sl@0
   610
@SYMTestPriority        High
sl@0
   611
@SYMTestActions         The test runs CSqlSrvDatabase::OpenL() and CSqlSrvDatabase::AttachDbL() in an OOM test.
sl@0
   612
                        The test is a complex one - 7 (KDbConnCount constant) databases opened 
sl@0
   613
                        (secure and non-secure), 10 (KDbAttachedCount constant) databases
sl@0
   614
                        attached (secure and non-secure).
sl@0
   615
                        UTF8 encoded database is used.
sl@0
   616
@SYMTestExpectedResults Test must not fail
sl@0
   617
@SYMDEF                 DEF144603
sl@0
   618
*/  
sl@0
   619
void Utf8OpenAttachDatabaseOomTest()
sl@0
   620
    {
sl@0
   621
    OpenAttachDatabaseOomTest(ESqlDbUtf8);
sl@0
   622
    }
sl@0
   623
sl@0
   624
void OpenAttachDatabaseOomTest2(TSqlDbEncoding aEncoding)
sl@0
   625
    {
sl@0
   626
    TheServer = NULL; 
sl@0
   627
    TRAPD(err, TheServer = CreateSqlServerL());
sl@0
   628
    TEST2(err, KErrNone);
sl@0
   629
    
sl@0
   630
    CreateSecureTestDb(KDbFile3, aEncoding);
sl@0
   631
    CreateSecureTestDb(KDbFile4, aEncoding);
sl@0
   632
    
sl@0
   633
    TInt failingAllocationNo = 0;
sl@0
   634
    TheTest.Printf(_L("Iteration:\r\n"));
sl@0
   635
    
sl@0
   636
    RMessage2 msg;
sl@0
   637
    TSqlSrvFileData& fdata = TheServer->FileData();
sl@0
   638
    
sl@0
   639
    err = KErrNoMemory;
sl@0
   640
    while(err == KErrNoMemory)
sl@0
   641
        {
sl@0
   642
        TheTest.Printf(_L(" %d"), ++failingAllocationNo);
sl@0
   643
        OomPreStep(failingAllocationNo);
sl@0
   644
        
sl@0
   645
        TRAP(err, fdata.SetL(msg, KDbFile3().Length(), 0, KDbFile3));
sl@0
   646
        if(err == KErrNone)
sl@0
   647
            {
sl@0
   648
            CSqlSrvDatabase* db = NULL;
sl@0
   649
            TRAP(err, db = CSqlSrvDatabase::OpenL(fdata));
sl@0
   650
            if(err == KErrNone)
sl@0
   651
                {
sl@0
   652
                TRAP(err, fdata.SetL(msg, KDbFile4().Length(), 0, KDbFile4));
sl@0
   653
                if(err == KErrNone)
sl@0
   654
                    {
sl@0
   655
                    TRAP(err, db->AttachDbL(fdata, _L("db2")));
sl@0
   656
                    if(err == KErrNone)
sl@0
   657
                        {
sl@0
   658
                        TRAP(err, db->DetachDbL(_L("db2")));
sl@0
   659
                        }
sl@0
   660
                    }
sl@0
   661
                delete db;
sl@0
   662
                }
sl@0
   663
            }
sl@0
   664
        OomPostStep();
sl@0
   665
        }
sl@0
   666
    
sl@0
   667
    (void)TheFs.Delete(KDbFile4);
sl@0
   668
    (void)TheFs.Delete(KDbFile3);
sl@0
   669
    
sl@0
   670
    delete TheServer;
sl@0
   671
    TheServer = NULL;
sl@0
   672
     
sl@0
   673
    TEST2(err, KErrNone);   
sl@0
   674
    TheTest.Printf(_L("\r\n===CSqlSrvDatabase::OpenL() & CSqlSrvDatabase::AttachDbL() OOM test 2 succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo);
sl@0
   675
    }
sl@0
   676
sl@0
   677
/**
sl@0
   678
@SYMTestCaseID          PDS-SQL-UT-4172
sl@0
   679
@SYMTestCaseDesc        CSqlSrvDatabase::OpenL() & CSqlSrvDatabase::AttachDbL() OOM test.
sl@0
   680
@SYMTestPriority        High
sl@0
   681
@SYMTestActions         The test runs CSqlSrvDatabase::OpenL() and CSqlSrvDatabase::AttachDbL() in an OOM test.
sl@0
   682
                        Two secure databases are created and then, in an OOM loop, the test executes this sequence of
sl@0
   683
                        commands: open first database, attach the second database, detach the attached database,
sl@0
   684
                        close the first database. 
sl@0
   685
                        UTF16 encoded database is used.
sl@0
   686
@SYMTestExpectedResults Test must not fail
sl@0
   687
@SYMDEF                 DEF144577, PDEF44845
sl@0
   688
*/  
sl@0
   689
void Utf16OpenAttachDatabaseOomTest2()
sl@0
   690
    {
sl@0
   691
    OpenAttachDatabaseOomTest2(ESqlDbUtf16);
sl@0
   692
    }
sl@0
   693
sl@0
   694
/**
sl@0
   695
@SYMTestCaseID          PDS-SQL-UT-4187
sl@0
   696
@SYMTestCaseDesc        CSqlSrvDatabase::OpenL() & CSqlSrvDatabase::AttachDbL() OOM test.
sl@0
   697
@SYMTestPriority        High
sl@0
   698
@SYMTestActions         The test runs CSqlSrvDatabase::OpenL() and CSqlSrvDatabase::AttachDbL() in an OOM test.
sl@0
   699
                        Two secure databases are created and then, in an OOM loop, the test executes this sequence of
sl@0
   700
                        commands: open first database, attach the second database, detach the attached database,
sl@0
   701
                        close the first database. 
sl@0
   702
                        UTF8 encoded database is used.
sl@0
   703
@SYMTestExpectedResults Test must not fail
sl@0
   704
@SYMDEF                 DEF145047
sl@0
   705
*/  
sl@0
   706
void Utf8OpenAttachDatabaseOomTest2()
sl@0
   707
    {
sl@0
   708
    OpenAttachDatabaseOomTest2(ESqlDbUtf8);
sl@0
   709
    }
sl@0
   710
sl@0
   711
void OpenCreateDatabaseOomTest(TSqlDbEncoding aEncoding)
sl@0
   712
    {
sl@0
   713
    TheServer = NULL; 
sl@0
   714
    TRAPD(err, TheServer = CreateSqlServerL());
sl@0
   715
    TEST2(err, KErrNone);
sl@0
   716
    
sl@0
   717
    (void)TheFs.Delete(KDbFile2);
sl@0
   718
    CreateSecureTestDb(KDbFile2, aEncoding);
sl@0
   719
    
sl@0
   720
    TheTest.Printf(_L("Iteration:\r\n"));
sl@0
   721
sl@0
   722
    //Open the database
sl@0
   723
    TInt failingAllocationNo = 0;
sl@0
   724
    err = KErrNoMemory;
sl@0
   725
    while(err == KErrNoMemory)
sl@0
   726
        {
sl@0
   727
        TheTest.Printf(_L(" %d"), ++failingAllocationNo);
sl@0
   728
        OomPreStep(failingAllocationNo);
sl@0
   729
        
sl@0
   730
        RMessage2 msg;
sl@0
   731
        TSqlSrvFileData& fdata = TheServer->FileData();
sl@0
   732
        TRAP(err, fdata.SetL(msg, KDbFile2().Length(), 0, KDbFile2));
sl@0
   733
        if(err == KErrNone)
sl@0
   734
            {
sl@0
   735
            CSqlSrvDatabase* db = NULL;
sl@0
   736
            TRAP(err, db = CSqlSrvDatabase::OpenL(fdata));
sl@0
   737
            if(err == KErrNone)
sl@0
   738
                {
sl@0
   739
                delete db;
sl@0
   740
                }
sl@0
   741
            else
sl@0
   742
                {
sl@0
   743
                TEST(!db);
sl@0
   744
                }
sl@0
   745
            }
sl@0
   746
        OomPostStep();
sl@0
   747
        }
sl@0
   748
    TEST2(err, KErrNone);   
sl@0
   749
    err = TheFs.Delete(KDbFile2);
sl@0
   750
    TEST2(err, KErrNone);   
sl@0
   751
    //Create the database
sl@0
   752
    TInt failingAllocationNo2 = 0;
sl@0
   753
    err = KErrNoMemory;
sl@0
   754
    while(err == KErrNoMemory)
sl@0
   755
        {
sl@0
   756
        TheTest.Printf(_L(" %d"), ++failingAllocationNo2);
sl@0
   757
        OomPreStep(failingAllocationNo2);
sl@0
   758
        RMessage2 msg;
sl@0
   759
        TSqlSrvFileData& fdata = TheServer->FileData();
sl@0
   760
        TRAP(err, fdata.SetL(msg, KDbFile2().Length(), 0, KDbFile2, aEncoding == ESqlDbUtf8 ? &KConfig : NULL));
sl@0
   761
        if(err == KErrNone)
sl@0
   762
            {
sl@0
   763
            TSecurityPolicy defaultPolicy(TSecurityPolicy::EAlwaysPass);
sl@0
   764
            CSqlSecurityPolicy* policy = NULL;
sl@0
   765
            TRAP(err, policy = CSqlSecurityPolicy::NewL(defaultPolicy));
sl@0
   766
            if(err == KErrNone)
sl@0
   767
                {
sl@0
   768
                CSqlSrvDatabase* db = NULL;
sl@0
   769
                TRAP(err, db = CSqlSrvDatabase::CreateSecureL(fdata, policy));
sl@0
   770
                if(err == KErrNone)
sl@0
   771
                    {
sl@0
   772
                    delete db;
sl@0
   773
                    }
sl@0
   774
                else
sl@0
   775
                    {
sl@0
   776
                    TEST(!db);
sl@0
   777
                    }
sl@0
   778
                }
sl@0
   779
            }
sl@0
   780
        OomPostStep();
sl@0
   781
        }
sl@0
   782
    
sl@0
   783
    (void)TheFs.Delete(KDbFile2);
sl@0
   784
    
sl@0
   785
    delete TheServer;
sl@0
   786
    TheServer = NULL;
sl@0
   787
     
sl@0
   788
    TEST2(err, KErrNone);   
sl@0
   789
    TheTest.Printf(_L("\r\n===CSqlSrvDatabase::OpenL() & CSqlSrvDatabase::CreateSecureL() OOM test succeeded at heap failure rate of %d ===\r\n"), 
sl@0
   790
                   failingAllocationNo + failingAllocationNo2);
sl@0
   791
    }
sl@0
   792
sl@0
   793
/**
sl@0
   794
@SYMTestCaseID          PDS-SQL-UT-4173
sl@0
   795
@SYMTestCaseDesc        CSqlSrvDatabase::OpenL() & CSqlSrvDatabase::CreateSecureL() OOM test.
sl@0
   796
@SYMTestPriority        High
sl@0
   797
@SYMTestActions         The test runs CSqlSrvDatabase::OpenL() and CSqlSrvDatabase::CreateSecureL() in an OOM test.
sl@0
   798
                        The test creates a secure database then executes CSqlSrvDatabase::OpenL() in an OOM loop.
sl@0
   799
                        After that the database is deleted and the test executes CSqlSrvDatabase::CreateSecureL() in an OOM loop.
sl@0
   800
                        The purpose of the test is to check that the CSqlSrver maps are properly updated when
sl@0
   801
                        the database is closed.
sl@0
   802
                        UTF16 encoded database is used.
sl@0
   803
@SYMTestExpectedResults Test must not fail
sl@0
   804
@SYMDEF                 DEF144577, PDEF44845
sl@0
   805
*/  
sl@0
   806
void Utf16OpenCreateDatabaseOomTest()
sl@0
   807
    {
sl@0
   808
    OpenCreateDatabaseOomTest(ESqlDbUtf16);
sl@0
   809
    }
sl@0
   810
sl@0
   811
/**
sl@0
   812
@SYMTestCaseID          PDS-SQL-UT-4188
sl@0
   813
@SYMTestCaseDesc        CSqlSrvDatabase::OpenL() & CSqlSrvDatabase::CreateSecureL() OOM test.
sl@0
   814
@SYMTestPriority        High
sl@0
   815
@SYMTestActions         The test runs CSqlSrvDatabase::OpenL() and CSqlSrvDatabase::CreateSecureL() in an OOM test.
sl@0
   816
                        The test creates a secure database then executes CSqlSrvDatabase::OpenL() in an OOM loop.
sl@0
   817
                        After that the database is deleted and the test executes CSqlSrvDatabase::CreateSecureL() in an OOM loop.
sl@0
   818
                        The purpose of the test is to check that the CSqlSrver maps are properly updated when
sl@0
   819
                        the database is closed.
sl@0
   820
                        UTF8 encoded database is used.
sl@0
   821
@SYMTestExpectedResults Test must not fail
sl@0
   822
@SYMDEF                 DEF145047
sl@0
   823
*/  
sl@0
   824
void Utf8OpenCreateDatabaseOomTest()
sl@0
   825
    {
sl@0
   826
    OpenCreateDatabaseOomTest(ESqlDbUtf8);
sl@0
   827
    }
sl@0
   828
sl@0
   829
void DoTests()
sl@0
   830
	{
sl@0
   831
#ifndef _DEBUG
sl@0
   832
    TheTest.Start(_L("This test can be run only in debug mode!"));
sl@0
   833
#else	
sl@0
   834
    CActiveScheduler* scheduler = new CActiveScheduler;
sl@0
   835
    TEST(scheduler != NULL);
sl@0
   836
    CActiveScheduler::Install(scheduler);
sl@0
   837
	
sl@0
   838
    TheTest.Start(_L(" @SYMTestCaseID:PDS-SQL-UT-4167 CSqlSrvDatabase::CreateL() OOM unit test"));
sl@0
   839
    Utf16CreateDatabaseOomTest();
sl@0
   840
sl@0
   841
    TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-UT-4168 CSqlSrvDatabase::OpenL() OOM unit test - non-secure database"));
sl@0
   842
    Utf16OpenDatabaseOomTest();
sl@0
   843
sl@0
   844
    TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-UT-4169 CSqlSrvDatabase::CreateSecureL() OOM unit test"));
sl@0
   845
    Utf16CreateSecureDatabaseOomTest();
sl@0
   846
sl@0
   847
    TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-UT-4170 CSqlSrvDatabase::OpenL() OOM unit test - secure database"));
sl@0
   848
    Utf16OpenSecureDatabaseOomTest();
sl@0
   849
    
sl@0
   850
    TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-UT-4171 CSqlSrvDatabase::OpenL() & CSqlSrvDatabase::AttachDbL() OOM unit test"));
sl@0
   851
    Utf16OpenAttachDatabaseOomTest();
sl@0
   852
sl@0
   853
    TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-UT-4172 CSqlSrvDatabase::OpenL() & CSqlSrvDatabase::AttachDbL() OOM unit test - 2"));
sl@0
   854
    Utf16OpenAttachDatabaseOomTest2();
sl@0
   855
sl@0
   856
    TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-UT-4173 CSqlSrvDatabase::OpenL() & CSqlSrvDatabase::CreateL() OOM unit test"));
sl@0
   857
    Utf16OpenCreateDatabaseOomTest();
sl@0
   858
sl@0
   859
    TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-UT-4182 CSqlSrvDatabase::CreateL() OOM unit test, UTF8 database"));
sl@0
   860
    Utf8CreateDatabaseOomTest();
sl@0
   861
sl@0
   862
    TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-UT-4183 CSqlSrvDatabase::OpenL() OOM unit test - non-secure UTF8 database"));
sl@0
   863
    Utf8OpenDatabaseOomTest();
sl@0
   864
sl@0
   865
    TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-UT-4184 CSqlSrvDatabase::CreateSecureL() OOM unit test, UTF8 database"));
sl@0
   866
    Utf8CreateSecureDatabaseOomTest();
sl@0
   867
sl@0
   868
    TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-UT-4185 CSqlSrvDatabase::OpenL() OOM unit test - secure UTF8 database"));
sl@0
   869
    Utf8OpenSecureDatabaseOomTest();
sl@0
   870
sl@0
   871
    TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-UT-4186 CSqlSrvDatabase::OpenL() & CSqlSrvDatabase::AttachDbL() OOM unit test, UTF8 database"));
sl@0
   872
    Utf8OpenAttachDatabaseOomTest();
sl@0
   873
sl@0
   874
    TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-UT-4187 CSqlSrvDatabase::OpenL() & CSqlSrvDatabase::AttachDbL() OOM unit test 2, UTF8 database"));
sl@0
   875
    Utf8OpenAttachDatabaseOomTest2();
sl@0
   876
sl@0
   877
    TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-UT-4188 CSqlSrvDatabase::OpenL() & CSqlSrvDatabase::CreateL() OOM unit test, UTF8 database"));
sl@0
   878
    Utf8OpenCreateDatabaseOomTest();
sl@0
   879
    
sl@0
   880
    delete scheduler;
sl@0
   881
#endif //_DEBUG    
sl@0
   882
	}
sl@0
   883
sl@0
   884
TInt E32Main()
sl@0
   885
	{
sl@0
   886
	TheTest.Title();
sl@0
   887
	
sl@0
   888
	CTrapCleanup* tc = CTrapCleanup::New();
sl@0
   889
	TheTest(tc != NULL);
sl@0
   890
	
sl@0
   891
	__UHEAP_MARK;
sl@0
   892
	
sl@0
   893
	CreateTestEnv();
sl@0
   894
	DoTests();
sl@0
   895
	DestroyTestEnv();
sl@0
   896
sl@0
   897
	__UHEAP_MARKEND;
sl@0
   898
	
sl@0
   899
	TheTest.End();
sl@0
   900
	TheTest.Close();
sl@0
   901
	
sl@0
   902
	delete tc;
sl@0
   903
sl@0
   904
	User::Heap().Check();
sl@0
   905
	return KErrNone;
sl@0
   906
	}