1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/dbms/pcdbms/tdbms/src/t_fail.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1122 @@
1.4 +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include <d32dbms.h>
1.20 +#include <e32math.h>
1.21 +#include <s32file.h>
1.22 +#include <e32test.h>
1.23 +#include "t_fail.h"
1.24 +
1.25 +#include "crccheck.h"
1.26 +
1.27 +#undef __UHEAP_MARK
1.28 +#define __UHEAP_MARK
1.29 +#undef __UHEAP_MARKEND
1.30 +#define __UHEAP_MARKEND
1.31 +#undef __UHEAP_CHECK
1.32 +#define __UHEAP_CHECK(a)
1.33 +
1.34 +LOCAL_D TDBMS_CRCChecks TheCrcChecker;
1.35 +
1.36 +#ifndef __linux__ //No CRC test on LINUX
1.37 +#ifdef __TOOLS2__
1.38 +const TPtrC KCrcRecord=_L("\\epoc32\\winscw\\c\\dbms-tst\\T_FAIL.CRC");
1.39 +#else
1.40 +const TPtrC KCrcRecord=_L("C:\\dbms-tst\\T_FAIL.CRC");
1.41 +#endif
1.42 +#endif
1.43 +
1.44 +#define CRCCHECK (TheCrcChecker.GenerateCrcL(KTestDatabase))
1.45 +
1.46 +
1.47 +_LIT(KTestTitle,"T_FAIL: DBMS Failure mode test");
1.48 +GLDEF_D RTest test(KTestTitle);
1.49 +GLDEF_D RDbs TheDbs;
1.50 +GLDEF_D RDbNamedDatabase TheDatabase;
1.51 +GLDEF_D TClientHeap KClientHeap;
1.52 +GLDEF_D TServerHeap KServerHeap;
1.53 +
1.54 +
1.55 +LOCAL_D CTrapCleanup* TheTrapCleanup;
1.56 +LOCAL_D RFs TheFs;
1.57 +LOCAL_D RDbView TheView;
1.58 +LOCAL_D RDbTable TheTable;
1.59 +LOCAL_D RDbRowSet::TAccess Access;
1.60 +LOCAL_D CDbColSet* TheColSet;
1.61 +LOCAL_D CDbKey* TheKey;
1.62 +LOCAL_D const TDesC* TheSql;
1.63 +LOCAL_D TBuf<64> TheFormat;
1.64 +
1.65 +const TInt KTestCleanupStack=0x20;
1.66 +
1.67 +#ifndef __TOOLS2__
1.68 +const TPtrC KTestDatabase=_L("C:\\dbms-tst\\t_fail.db");
1.69 +#else
1.70 +const TPtrC KTestDatabase=_L(".\\dbms-tst\\t_fail.db");
1.71 +#endif
1.72 +
1.73 +_LIT(TableName,"Table1");
1.74 +_LIT(TableName2,"Table_two");
1.75 +_LIT(TableNameX,"Bad Table Name");
1.76 +_LIT(IndexName,"Index1");
1.77 +_LIT(IndexName2,"Index2");
1.78 +_LIT(Column1,"column_one");
1.79 +_LIT(Column1Fold,"COLUMN_ONE");
1.80 +_LIT(Column2,"column_2");
1.81 +_LIT(Column2X,"column_2%");
1.82 +_LIT(SimpleSql,"select * from Table1");
1.83 +_LIT(UpdateSql,"update Table1 SET column_2='hello'");
1.84 +
1.85 +//const TPtrC ComplexSql(_S("select * from Table1 where column_one<0 and not column_one is null or column_2 not like '*fred*' and column_2>'m' order by column_one desc"));
1.86 +const TPtrC ComplexSql[]=
1.87 + {
1.88 + _S("select * from Table1 where column_one<0 and column_one is null"),
1.89 + _S("select * from Table1 where column_one<0 and (column_one is null and column_2 like '')"),
1.90 + _S("select * from Table1 where (column_one<0 and column_one is null) and column_2 like ''"),
1.91 + _S("select * from Table1 where (column_one<0 and column_one is null) and (column_2 like '' and column_one>0)"),
1.92 + _S("select * from Table1 where (column_one<0 and column_one is null) and (column_2 like '' and column_one>0 and column_one is null)"),
1.93 + _S("select * from Table1 where (column_one<0 and column_one is null and column_one = 10) and (column_2 like '' and column_one>0 and column_one is null)"),
1.94 + _S("select * from Table1 where column_one<0 and column_one is null and column_one = 10 and column_2 like '' and column_one>0 and column_one is null")
1.95 + };
1.96 +
1.97 +struct SSqlErrors
1.98 + {
1.99 + const TText* iSql;
1.100 + TInt iError;
1.101 + };
1.102 +
1.103 +LOCAL_D SSqlErrors const BadSql[]=
1.104 + {
1.105 + {_S("sponge"),KErrArgument},
1.106 + {_S("select * from widget"),KErrNotFound},
1.107 + {_S("select * from Table1 where x = 0"),KErrNotFound},
1.108 + {_S("select * from Table1 where x 0 like"),KErrArgument},
1.109 + {_S("select * from Table1 where column_2>'a' and column_one<'z'"),KErrGeneral},
1.110 + {_S("select from Table1"),KErrArgument},
1.111 + {_S("select x, from Table1"),KErrArgument},
1.112 + {_S("select x from Table1"),KErrNotFound},
1.113 + {_S("select column_2 column_one from Table1"),KErrArgument},
1.114 + {_S("select * from Table1 order by x"),KErrNotFound},
1.115 + {_S("select * from Table1 order column_one"),KErrArgument},
1.116 + {_S("select * from Table1 order by column_one down"),KErrArgument}
1.117 + };
1.118 +
1.119 +GLDEF_C void Connect()
1.120 + {
1.121 +#ifndef __TOOLS2__
1.122 + TInt r=TheDbs.Connect();
1.123 + test (r==KErrNone);
1.124 + TheDbs.ResourceMark();
1.125 +#endif
1.126 + }
1.127 +
1.128 +GLDEF_C void Disconnect()
1.129 + {
1.130 +#ifndef __TOOLS2__
1.131 + TheDbs.ResourceCheck();
1.132 + TheDbs.Close();
1.133 +#endif
1.134 + }
1.135 +
1.136 +
1.137 +//SYMBIAN_REMOVE_TRIVIAL_ENCRYPTION version
1.138 +LOCAL_C void DbCreateL()
1.139 + {
1.140 + User::LeaveIfError(TheDatabase.Replace(TheFs,KTestDatabase,TheFormat));
1.141 + }
1.142 +
1.143 +//SYMBIAN_REMOVE_TRIVIAL_ENCRYPTION version
1.144 +LOCAL_C void DbOpenL()
1.145 + {
1.146 + User::LeaveIfError(TheDatabase.Open(TheFs,KTestDatabase,TheFormat));
1.147 + CleanupClosePushL(TheDatabase);
1.148 + delete TheDatabase.TableNamesL(); // force a schema load
1.149 + CleanupStack::Pop();
1.150 + }
1.151 +
1.152 +//SYMBIAN_REMOVE_TRIVIAL_ENCRYPTION version
1.153 +LOCAL_C void DbShareL()
1.154 + {
1.155 + User::LeaveIfError(TheDatabase.Open(TheDbs,KTestDatabase,TheFormat));
1.156 + CleanupClosePushL(TheDatabase);
1.157 + delete TheDatabase.TableNamesL(); // force a schema load
1.158 + CleanupStack::Pop();
1.159 + }
1.160 +
1.161 +
1.162 +/**
1.163 +@SYMTestCaseID SYSLIB-DBMS-CT-0612
1.164 +@SYMTestCaseDesc Database validity test
1.165 +@SYMTestPriority Medium
1.166 +@SYMTestActions Tests for opening and closing of database
1.167 +@SYMTestExpectedResults Test must not fail
1.168 +@SYMREQ REQ0000
1.169 +*/
1.170 +LOCAL_C void TestOpen()
1.171 + {
1.172 + _LIT(KFileNotFound,"not a database");
1.173 + TInt r=TheDatabase.Open(TheFs,KFileNotFound);
1.174 + test (r==KErrNotFound || r==KErrPathNotFound);
1.175 +//
1.176 + _LIT(KPathNotFound,"C:\\not a path\\database.db");
1.177 + r=TheDatabase.Open(TheFs,KPathNotFound);
1.178 +#ifndef __TOOLS2__
1.179 + test (r==KErrPathNotFound);
1.180 +#else
1.181 + // Tools2 f32 does not return KErrPathNotFound
1.182 + test( (r==KErrPathNotFound) || (r==KErrNotFound));
1.183 +#endif
1.184 +//
1.185 + _LIT(KNotFormat,"not.a.dbx");
1.186 + r=TheDatabase.Open(TheFs,KFileNotFound,KNotFormat);
1.187 + test (r==KErrNotFound || r==KErrPathNotFound);
1.188 +//
1.189 + DbCreateL();
1.190 + TheDatabase.Close();
1.191 + TInt err = CRCCHECK;
1.192 + test(err == KErrNone);
1.193 + r=TheDatabase.Open(TheFs,KTestDatabase,TUid::Uid(0x01234567).Name());
1.194 + test (r==KErrNone); // New code has no loadable drivers, it is irrelevant to expect error here
1.195 + TheDatabase.Close(); // We have added it here because previous statement does not return error anymore
1.196 + err = CRCCHECK;
1.197 + test(err == KErrNone);
1.198 +//
1.199 + RFile f;
1.200 + r=f.Replace(TheFs,KTestDatabase,EFileWrite);
1.201 + test (r==KErrNone);
1.202 + TCheckedUid type(KDirectFileStoreLayoutUid);
1.203 + r=f.Write(type.Des());
1.204 + test (r==KErrNone);
1.205 + f.Close();
1.206 + r=TheDatabase.Open(TheFs,KTestDatabase);
1.207 + test (r==KErrNotSupported);
1.208 +//
1.209 + _LIT(KDefaultFormat,"epoc");
1.210 + r=TheDatabase.Open(TheFs,KTestDatabase,KDefaultFormat);
1.211 + test (r==KErrNotSupported); // We expect not supported db here
1.212 + }
1.213 +
1.214 +class TClient : public TContext
1.215 + {
1.216 +public:
1.217 + TClient() {}
1.218 +private:
1.219 + void OpenDbL() const
1.220 + {DbOpenL();}
1.221 + };
1.222 +class TServer : public TContext
1.223 + {
1.224 +public:
1.225 + TServer() {}
1.226 +private:
1.227 + void OpenDbL() const
1.228 + {DbShareL();}
1.229 + };
1.230 +
1.231 +const TClient KClient;
1.232 +const TServer KServer;
1.233 +
1.234 +void TFail::Test(const THeapFail& aHeap,const TContext* aContext)
1.235 + {
1.236 + TInt ii;
1.237 + TInt errCode;
1.238 + for (ii=1;;++ii)
1.239 + {
1.240 + if (aContext)
1.241 + {
1.242 + TRAP(errCode, aContext->OpenDbL());
1.243 + if(errCode != KErrNone)
1.244 + return;
1.245 + }
1.246 + aHeap.Fail(ii);
1.247 + aHeap.Mark();
1.248 + TRAPD(r,RunL());
1.249 + aHeap.Reset();
1.250 + if (r==KErrNone)
1.251 + break;
1.252 + test(r==KErrNoMemory);
1.253 + if (aContext)
1.254 + {
1.255 + TheDatabase.Close();
1.256 + TRAPD(lc, errCode = CRCCHECK);
1.257 + test(errCode == KErrNone);
1.258 + test(lc == KErrNone);
1.259 + }
1.260 + aHeap.Check();
1.261 + }
1.262 + End();
1.263 + if (aContext)
1.264 + {
1.265 + TheDatabase.Close();
1.266 + TRAPD(lc, errCode = CRCCHECK);
1.267 + test(errCode == KErrNone);
1.268 + test(lc == KErrNone);
1.269 + }
1.270 + aHeap.Check();
1.271 + }
1.272 +
1.273 +class TFailCreateDatabase : public TFail
1.274 + {
1.275 + void RunL()
1.276 + {DbCreateL();}
1.277 + void End()
1.278 + {
1.279 + TheDatabase.Close();
1.280 + TInt err;
1.281 + TRAPD(lc, err = CRCCHECK);
1.282 + test(err == KErrNone);
1.283 + test(lc == KErrNone);
1.284 + }
1.285 + };
1.286 +
1.287 +class TFailOpenDatabase : public TFail
1.288 + {
1.289 + void RunL()
1.290 + {DbOpenL();}
1.291 + void End()
1.292 + {
1.293 + TheDatabase.Close();
1.294 + TInt err;
1.295 + TRAPD(lc, err = CRCCHECK);
1.296 + test(err == KErrNone);
1.297 + test(lc == KErrNone);
1.298 + }
1.299 + };
1.300 +
1.301 +class TFailShareDatabase : public TFail
1.302 + {
1.303 + void RunL()
1.304 + {DbShareL();}
1.305 + void End()
1.306 + {
1.307 + TheDatabase.Close();
1.308 +// Unfortunately it is not possible to generate CRC checks here. The
1.309 +// database on a number of occasions is still open by another instance.
1.310 +// This causes a KErrInUse in the CRC check code for Symbian, but
1.311 +// works on TOOLS2, thus giving probably spurious mismatches.
1.312 +// TInt err;
1.313 +// TRAPD(lc, err = CRCCHECK);
1.314 +// RDebug::Print(_L("ERROR %d\n"), err);
1.315 +// test(err == KErrNone);
1.316 +// test(lc == KErrNone);
1.317 + }
1.318 + };
1.319 +
1.320 +/**
1.321 +@SYMTestCaseID SYSLIB-DBMS-CT-0613
1.322 +@SYMTestCaseDesc Tests for allocation failures on creating a database
1.323 +@SYMTestPriority Medium
1.324 +@SYMTestActions Tests for allocation failure for differently sourced databases
1.325 +@SYMTestExpectedResults Test must not fail
1.326 +@SYMREQ REQ0000
1.327 +*/
1.328 +LOCAL_C void Origins()
1.329 + {
1.330 + test.Start(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0613 Allocation failures on Creating a database "));
1.331 + TFailCreateDatabase t1;
1.332 + t1.Test(KClientHeap);
1.333 +//
1.334 + test.Next(_L("Fail to create existing database"));
1.335 +#ifndef __TOOLS2__
1.336 + TUint att;
1.337 + TInt r=TheFs.Att(KTestDatabase,att);
1.338 + test (r==KErrNone);
1.339 +#else
1.340 + TInt r;
1.341 +#endif
1.342 + r=TheDatabase.Create(TheFs,KTestDatabase,TheFormat);
1.343 + test (r==KErrAlreadyExists);
1.344 +#ifndef __TOOLS2__
1.345 + r=TheFs.Att(KTestDatabase,att);
1.346 + test (r==KErrNone);
1.347 +#endif
1.348 +//
1.349 + test.Next(_L("Allocation failures on Open"));
1.350 + TFailOpenDatabase t2;
1.351 + t2.Test(KClientHeap);
1.352 +//
1.353 + test.Next(_L("Allocation failures on 1st Share"));
1.354 + Connect();
1.355 + TFailShareDatabase t3;
1.356 + t3.Test(KClientHeap);
1.357 + t3.Test(KServerHeap);
1.358 +//
1.359 + test.Next(_L("Allocation failures on 2nd Share"));
1.360 + DbShareL();
1.361 + RDbNamedDatabase temp=TheDatabase;TheDatabase=RDbNamedDatabase();
1.362 + t3.Test(KClientHeap);
1.363 + t3.Test(KServerHeap);
1.364 + temp.Close();
1.365 + Disconnect();
1.366 + test.End();
1.367 + }
1.368 +
1.369 +
1.370 +class TFailCreateTable : public TFail
1.371 + {
1.372 + void RunL()
1.373 + {User::LeaveIfError(TheDatabase.CreateTable(TableName,*TheColSet));}
1.374 + };
1.375 +
1.376 +class TFailAlterTable : public TFail
1.377 + {
1.378 + void RunL()
1.379 + {User::LeaveIfError(TheDatabase.AlterTable(TableName,*TheColSet));}
1.380 + };
1.381 +
1.382 +class TFailDropTable : public TFail
1.383 + {
1.384 + void RunL()
1.385 + {User::LeaveIfError(TheDatabase.DropTable(TableName));}
1.386 + };
1.387 +
1.388 +class TFailCreateIndex : public TFail
1.389 + {
1.390 + void RunL()
1.391 + {User::LeaveIfError(TheDatabase.CreateIndex(IndexName,TableName,*TheKey));}
1.392 + };
1.393 +
1.394 +class TFailDropIndex : public TFail
1.395 + {
1.396 + void RunL()
1.397 + {User::LeaveIfError(TheDatabase.DropIndex(IndexName,TableName));}
1.398 + };
1.399 +
1.400 +class TFailGetObject : public TFail
1.401 + {
1.402 +protected:
1.403 + void End()
1.404 + {delete iObject;}
1.405 +protected:
1.406 + CBase* iObject;
1.407 + };
1.408 +
1.409 +class TFailDatabaseTables : public TFailGetObject
1.410 + {
1.411 + void RunL()
1.412 + {iObject=TheDatabase.TableNamesL();}
1.413 + };
1.414 +
1.415 +class TFailDatabaseColSet : public TFailGetObject
1.416 + {
1.417 + void RunL()
1.418 + {iObject=TheDatabase.ColSetL(TableName);}
1.419 + };
1.420 +
1.421 +class TFailDatabaseIndexes : public TFailGetObject
1.422 + {
1.423 + void RunL()
1.424 + {iObject=TheDatabase.IndexNamesL(TableName);}
1.425 + };
1.426 +
1.427 +class TFailDatabaseKeys : public TFailGetObject
1.428 + {
1.429 + void RunL()
1.430 + {iObject=TheDatabase.KeyL(IndexName,TableName);}
1.431 + };
1.432 +
1.433 +const TInt KRowCount=60;
1.434 +
1.435 +LOCAL_C void WriteTableL()
1.436 + {
1.437 + DbOpenL();
1.438 + TInt r=TheTable.Open(TheDatabase,TableName);
1.439 + test (r==KErrNone);
1.440 + TheDatabase.Begin();
1.441 + for (TInt ii=0;ii<KRowCount;++ii)
1.442 + {
1.443 + TheTable.InsertL();
1.444 + TheTable.SetColL(1,TUint((ii*17)%KRowCount));
1.445 + TheTable.PutL();
1.446 + }
1.447 + r=TheDatabase.Commit();
1.448 + test (r==KErrNone);
1.449 + TheTable.Close();
1.450 + TheDatabase.Close();
1.451 + TInt err = CRCCHECK;
1.452 + test(err == KErrNone);
1.453 + }
1.454 +
1.455 +LOCAL_C void Database()
1.456 + {
1.457 + test.Start(_L("Adding and dropping tables"));
1.458 + DbCreateL();
1.459 +// ensure the database locking list has been allocated
1.460 + TheDatabase.Begin();
1.461 + TheDatabase.Commit();
1.462 +//
1.463 + CDbColSet *col=CDbColSet::NewLC();
1.464 +//
1.465 + test.Next(_L("Empty Column Set"));
1.466 + __UHEAP_MARK;
1.467 + test(TheDatabase.CreateTable(TableName,*col)!=KErrNone);
1.468 + __UHEAP_MARKEND;
1.469 +//
1.470 + test.Next(_L("Invalid table name"));
1.471 + col->AddL(TDbCol(Column1,EDbColInt32));
1.472 + __UHEAP_MARK;
1.473 + test(TheDatabase.CreateTable(TableNameX,*col)!=KErrNone);
1.474 + __UHEAP_MARKEND;
1.475 +//
1.476 + test.Next(_L("Invalid column name"));
1.477 + col->AddL(TDbCol(Column2X,EDbColBit));
1.478 + __UHEAP_MARK;
1.479 + test(TheDatabase.CreateTable(TableName,*col)!=KErrNone);
1.480 + __UHEAP_MARKEND;
1.481 +//
1.482 + test.Next(_L("Duplicate column name"));
1.483 + col->Remove(Column2X);
1.484 + col->AddL(TDbCol(Column1Fold,EDbColBit));
1.485 + __UHEAP_MARK;
1.486 + test(TheDatabase.CreateTable(TableName,*col)!=KErrNone);
1.487 + __UHEAP_MARKEND;
1.488 +//
1.489 + test.Next(_L("Invalid column type"));
1.490 + col->Remove(Column1);
1.491 + col->AddL(TDbCol(Column2,TDbColType(-1)));
1.492 + __UHEAP_MARK;
1.493 + test(TheDatabase.CreateTable(TableName,*col)!=KErrNone);
1.494 + __UHEAP_MARKEND;
1.495 +//
1.496 + test.Next(_L("Invalid maximum length"));
1.497 + col->Remove(Column2);
1.498 + col->AddL(TDbCol(Column2,EDbColInt32,0));
1.499 + __UHEAP_MARK;
1.500 + test(TheDatabase.CreateTable(TableName,*col)!=KErrNone);
1.501 + __UHEAP_MARKEND;
1.502 +//
1.503 + test.Next(_L("Invalid attributes"));
1.504 + col->Remove(Column2);
1.505 + TDbCol cc(Column2,EDbColInt32);
1.506 + cc.iAttributes=13;
1.507 + col->AddL(cc);
1.508 + __UHEAP_MARK;
1.509 + test(TheDatabase.CreateTable(TableName,*col)!=KErrNone);
1.510 + __UHEAP_MARKEND;
1.511 +//
1.512 + test.Next(_L("Adding/dropping a table name twice"));
1.513 + col->Remove(Column2);
1.514 + col->AddL(TDbCol(Column2,EDbColText8));
1.515 + __UHEAP_MARK;
1.516 + test(TheDatabase.CreateTable(TableName,*col)==KErrNone);
1.517 + test(TheDatabase.CreateTable(TableName,*col)==KErrAlreadyExists);
1.518 + test(TheDatabase.DropTable(TableNameX)!=KErrNone);
1.519 + test(TheDatabase.DropTable(TableName)==KErrNone);
1.520 + test(TheDatabase.DropTable(TableName)==KErrNotFound);
1.521 + __UHEAP_MARKEND;
1.522 +//
1.523 + test.Next(_L("Adding and dropping indexes"));
1.524 + test(TheDatabase.CreateTable(TableName,*col)==KErrNone);
1.525 + TheDatabase.Close();
1.526 + TInt err = CRCCHECK;
1.527 + test(err == KErrNone);
1.528 + CDbKey *key=CDbKey::NewLC();
1.529 + __UHEAP_MARK;
1.530 + DbOpenL();
1.531 + test(TheDatabase.CreateIndex(IndexName,TableName,*key)!=KErrNone);
1.532 + TheDatabase.Close();
1.533 + err = CRCCHECK;
1.534 + test(err == KErrNone);
1.535 + __UHEAP_MARKEND;
1.536 + key->AddL(Column2X());
1.537 + __UHEAP_MARK;
1.538 + DbOpenL();
1.539 + test(TheDatabase.CreateIndex(IndexName,TableName,*key)!=KErrNone);
1.540 + TheDatabase.Close();
1.541 + err = CRCCHECK;
1.542 + test(err == KErrNone);
1.543 + __UHEAP_MARKEND;
1.544 + key->Clear();
1.545 + key->AddL(Column1());
1.546 + __UHEAP_MARK;
1.547 + DbOpenL();
1.548 + test(TheDatabase.CreateIndex(TableNameX,TableName,*key)!=KErrNone);
1.549 + TheDatabase.Close();
1.550 + err = CRCCHECK;
1.551 + test(err == KErrNone);
1.552 + __UHEAP_CHECK(0);
1.553 + DbOpenL();
1.554 + test(TheDatabase.CreateIndex(IndexName,TableNameX,*key)!=KErrNone);
1.555 + TheDatabase.Close();
1.556 + err = CRCCHECK;
1.557 + test(err == KErrNone);
1.558 + __UHEAP_MARKEND;
1.559 + __UHEAP_MARK;
1.560 + DbOpenL();
1.561 + test(TheDatabase.CreateIndex(IndexName,TableName,*key)==KErrNone);
1.562 + test(TheDatabase.CreateIndex(IndexName,TableName,*key)==KErrAlreadyExists);
1.563 + test(TheDatabase.DropIndex(TableNameX,TableName)!=KErrNone);
1.564 + test(TheDatabase.DropIndex(IndexName,TableNameX)!=KErrNone);
1.565 + test(TheDatabase.DropIndex(IndexName,TableName)==KErrNone);
1.566 + test(TheDatabase.DropIndex(IndexName,TableName)==KErrNotFound);
1.567 + test(TheDatabase.DropTable(TableName)==KErrNone);
1.568 + test(TheDatabase.DropIndex(IndexName,TableName)==KErrNotFound);
1.569 + TheDatabase.Close();
1.570 + err = CRCCHECK;
1.571 + test(err == KErrNone);
1.572 + __UHEAP_MARKEND;
1.573 +//
1.574 + test.Next(_L("Allocation failure during DDL"));
1.575 + TFailCreateTable fct;
1.576 + TFailAlterTable fat;
1.577 + TFailDropTable fdt;
1.578 + TFailCreateIndex fci;
1.579 + TFailDropIndex fdi;
1.580 + TheColSet=CDbColSet::NewL();
1.581 + TheColSet->AddL(TDbCol(Column1,EDbColUint16));
1.582 + TheKey=CDbKey::NewL();
1.583 + TheKey->AddL(Column1());
1.584 + fct.Test(KClientHeap,KClient);
1.585 + WriteTableL();
1.586 + TheColSet->AddL(TDbCol(Column2,EDbColText));
1.587 + fat.Test(KClientHeap,KClient);
1.588 + fci.Test(KClientHeap,KClient);
1.589 + fdi.Test(KClientHeap,KClient);
1.590 + fdt.Test(KClientHeap,KClient);
1.591 +//
1.592 + test.Next(_L("Allocation failure during server DDL"));
1.593 + Connect();
1.594 + TheColSet->Remove(Column2);
1.595 + fct.Test(KClientHeap,KServer);
1.596 + WriteTableL();
1.597 + TheColSet->AddL(TDbCol(Column2,EDbColText));
1.598 + fat.Test(KClientHeap,KServer);
1.599 + fci.Test(KClientHeap,KServer);
1.600 + fdi.Test(KClientHeap,KServer);
1.601 + fdt.Test(KClientHeap,KServer);
1.602 +//
1.603 + TheColSet->Remove(Column2);
1.604 + fct.Test(KServerHeap,KServer);
1.605 + WriteTableL();
1.606 + TheColSet->AddL(TDbCol(Column2,EDbColText));
1.607 + fat.Test(KServerHeap,KServer);
1.608 + fci.Test(KServerHeap,KServer);
1.609 + fdi.Test(KServerHeap,KServer);
1.610 + fdt.Test(KServerHeap,KServer);
1.611 + Disconnect();
1.612 +//
1.613 + delete TheColSet;
1.614 + delete TheKey;
1.615 +
1.616 +//
1.617 + test.Next(_L("Allocation failure on schema enquiry"));
1.618 + DbCreateL();
1.619 + test(TheDatabase.CreateTable(TableName,*col)==KErrNone);
1.620 + test(TheDatabase.CreateIndex(IndexName,TableName,*key)==KErrNone);
1.621 + CleanupStack::PopAndDestroy(2); // columns set and key
1.622 + TheDatabase.Close();
1.623 + err = CRCCHECK;
1.624 + test(err == KErrNone);
1.625 + TFailDatabaseTables t4;
1.626 + TFailDatabaseColSet t5;
1.627 + TFailDatabaseIndexes t6;
1.628 + TFailDatabaseKeys t7;
1.629 + t4.Test(KClientHeap,KClient);
1.630 + t5.Test(KClientHeap,KClient);
1.631 + t6.Test(KClientHeap,KClient);
1.632 + t7.Test(KClientHeap,KClient);
1.633 +//
1.634 + test.Next(_L("Allocation failure on server schema enquiry"));
1.635 + Connect();
1.636 + t4.Test(KClientHeap,KServer);
1.637 + t4.Test(KServerHeap,KServer);
1.638 + t5.Test(KClientHeap,KServer);
1.639 + t5.Test(KServerHeap,KServer);
1.640 + t6.Test(KClientHeap,KServer);
1.641 + t6.Test(KServerHeap,KServer);
1.642 + t7.Test(KClientHeap,KServer);
1.643 + t7.Test(KServerHeap,KServer);
1.644 + Disconnect();
1.645 + test.End();
1.646 + }
1.647 +
1.648 +class TFailOpenTable : public TFail
1.649 + {
1.650 + void RunL()
1.651 + {User::LeaveIfError(TheTable.Open(TheDatabase,TableName,Access));}
1.652 + void End()
1.653 + {TheTable.Close();}
1.654 + };
1.655 +
1.656 +/**
1.657 +@SYMTestCaseID SYSLIB-DBMS-CT-0614
1.658 +@SYMTestCaseDesc Tests for allocation failure on opening and closing of database
1.659 +@SYMTestPriority Medium
1.660 +@SYMTestActions Tests for opening and closing of database
1.661 +@SYMTestExpectedResults Test must not fail
1.662 +@SYMREQ REQ0000
1.663 +*/
1.664 +LOCAL_C void TestTable(const THeapFail& aHeap,const TContext& aContext)
1.665 + {
1.666 + test.Start(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0614 Allocation failure on Open "));
1.667 + TFailOpenTable fot;
1.668 + Access=RDbRowSet::EUpdatable;
1.669 + fot.Test(aHeap,aContext);
1.670 + Access=RDbRowSet::EReadOnly;
1.671 + fot.Test(aHeap,aContext);
1.672 + Access=RDbRowSet::EInsertOnly;
1.673 + fot.Test(aHeap,aContext);
1.674 +//
1.675 + test.Next(_L("Open invalid table"));
1.676 + aContext.OpenDbL();
1.677 + __UHEAP_MARK;
1.678 + TInt r=TheTable.Open(TheDatabase,TableNameX);
1.679 + test (r!=KErrNone);
1.680 + __UHEAP_MARKEND;
1.681 +//
1.682 + test.Next(_L("Set invalid index"));
1.683 + r=TheTable.Open(TheDatabase,TableName);
1.684 + test (r==KErrNone);
1.685 + __UHEAP_MARK;
1.686 + r=TheTable.SetIndex(IndexName2);
1.687 + test (r!=KErrNone);
1.688 + __UHEAP_MARKEND;
1.689 +//
1.690 + test.Next(_L("Allocation failure on 2nd Open"));
1.691 + RDbTable table(TheTable);
1.692 + Access=RDbRowSet::EUpdatable;
1.693 + fot.Test(aHeap);
1.694 + Access=RDbRowSet::EReadOnly;
1.695 + fot.Test(aHeap);
1.696 + Access=RDbRowSet::EInsertOnly;
1.697 + fot.Test(aHeap);
1.698 + table.Close();
1.699 + TheDatabase.Close();
1.700 + r = CRCCHECK;
1.701 + test(r == KErrNone);
1.702 + test.End();
1.703 + }
1.704 +
1.705 +LOCAL_C void TestTableDDL(const TContext& aContext)
1.706 + {
1.707 + test.Start(_L("DDL while open"));
1.708 + aContext.OpenDbL();
1.709 + TInt r=TheTable.Open(TheDatabase,TableName);
1.710 + test (r==KErrNone);
1.711 + CDbColSet* set=CDbColSet::NewLC();
1.712 + set->AddL(TDbCol(Column1,EDbColText));
1.713 + r=TheDatabase.CreateTable(TableName2,*set);
1.714 + test (r==KErrNone);
1.715 + TRAP(r,TheTable.CountL(TheTable.EQuick));
1.716 + test (r==KErrNone);
1.717 + TheTable.Close();
1.718 + r=TheTable.Open(TheDatabase,TableName2);
1.719 + test (r==KErrNone);
1.720 +//
1.721 + set->AddL(TDbCol(Column2,EDbColUint32));
1.722 + r=TheDatabase.AlterTable(TableName2,*set);
1.723 + test (r==KErrNone);
1.724 + CleanupStack::PopAndDestroy(); // set
1.725 + TRAP(r,TheTable.CountL(TheTable.EQuick));
1.726 + test (r==KErrDisconnected);
1.727 + TheTable.Reset();
1.728 + TRAP(r,TheTable.CountL(TheTable.EQuick));
1.729 + test (r==KErrDisconnected);
1.730 + TheTable.Close();
1.731 + r=TheTable.Open(TheDatabase,TableName2);
1.732 + test (r==KErrNone);
1.733 +//
1.734 + CDbKey* key=CDbKey::NewLC();
1.735 + key->AddL(Column2());
1.736 + r=TheDatabase.CreateIndex(IndexName2,TableName,*key);
1.737 + test (r==KErrNone);
1.738 + TRAP(r,TheTable.CountL(TheTable.EQuick));
1.739 + test (r==KErrNone);
1.740 + r=TheDatabase.DropIndex(IndexName2,TableName);
1.741 + test (r==KErrNone);
1.742 + TRAP(r,TheTable.CountL(TheTable.EQuick));
1.743 + test (r==KErrNone);
1.744 +//
1.745 + r=TheDatabase.CreateIndex(IndexName,TableName2,*key);
1.746 + test (r==KErrNone);
1.747 + CleanupStack::PopAndDestroy(); // key
1.748 + TRAP(r,TheTable.CountL(TheTable.EQuick));
1.749 + test (r==KErrDisconnected);
1.750 + TheTable.Close();
1.751 + r=TheTable.Open(TheDatabase,TableName2);
1.752 + test (r==KErrNone);
1.753 +//
1.754 + r=TheDatabase.DropIndex(IndexName,TableName2);
1.755 + test (r==KErrNone);
1.756 + TRAP(r,TheTable.CountL(TheTable.EQuick));
1.757 + test (r==KErrDisconnected);
1.758 + TheTable.Close();
1.759 + r=TheTable.Open(TheDatabase,TableName2);
1.760 + test (r==KErrNone);
1.761 +//
1.762 + r=TheDatabase.DropTable(TableName2);
1.763 + test (r==KErrNone);
1.764 + TRAP(r,TheTable.CountL(TheTable.EQuick));
1.765 + test (r==KErrDisconnected);
1.766 + TheTable.Close();
1.767 + TheDatabase.Close();
1.768 + r = CRCCHECK;
1.769 + test(r == KErrNone);
1.770 + test.End();
1.771 + }
1.772 +
1.773 +LOCAL_C void Table()
1.774 + {
1.775 + test.Start(_L("Testing Client-side"));
1.776 + TestTable(KClientHeap,KClient);
1.777 + TestTableDDL(KClient);
1.778 + test.Next(_L("Testing Client-Server"));
1.779 + Connect();
1.780 + TestTable(KClientHeap,KServer);
1.781 + TestTable(KServerHeap,KServer);
1.782 + TestTableDDL(KServer);
1.783 + Disconnect();
1.784 + test.End();
1.785 + }
1.786 +
1.787 +class TFailExecuteSQL : public TFail
1.788 + {
1.789 + void RunL()
1.790 + {User::LeaveIfError(TheDatabase.Execute(*TheSql));}
1.791 + void End()
1.792 + {}
1.793 + };
1.794 +
1.795 +class TFailPrepareView : public TFail
1.796 + {
1.797 + void RunL()
1.798 + {User::LeaveIfError(TheView.Prepare(TheDatabase,*TheSql,Access));}
1.799 + void End()
1.800 + {TheView.Close();}
1.801 + };
1.802 +
1.803 +/**
1.804 +@SYMTestCaseID SYSLIB-DBMS-CT-0615
1.805 +@SYMTestCaseDesc Tests for allocation failure on prepare
1.806 +@SYMTestPriority Medium
1.807 +@SYMTestActions Tests for error on updating a row set data
1.808 +@SYMTestExpectedResults Test must not fail
1.809 +@SYMREQ REQ0000
1.810 +*/
1.811 +LOCAL_C void TestView(const THeapFail& aHeap,const TContext& aContext)
1.812 + {
1.813 + test.Start(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0615 Allocation failure on Prepare "));
1.814 + TFailPrepareView fpv;
1.815 + TheSql=&SimpleSql;
1.816 + Access=RDbRowSet::EUpdatable;
1.817 + fpv.Test(aHeap,aContext);
1.818 + Access=RDbRowSet::EReadOnly;
1.819 + fpv.Test(aHeap,aContext);
1.820 + Access=RDbRowSet::EInsertOnly;
1.821 + fpv.Test(aHeap,aContext);
1.822 +//
1.823 + test.Next(_L("Allocation failure on Prepare (complex SQL)"));
1.824 + for (TUint ii=0;ii<sizeof(ComplexSql)/sizeof(ComplexSql[0]);++ii)
1.825 + {
1.826 + TheSql=&ComplexSql[ii];
1.827 + Access=RDbRowSet::EUpdatable;
1.828 + fpv.Test(aHeap,aContext);
1.829 + }
1.830 + test.End();
1.831 + }
1.832 +
1.833 +/**
1.834 +@SYMTestCaseID SYSLIB-DBMS-CT-0616
1.835 +@SYMTestCaseDesc Bad SQL query test
1.836 +@SYMTestPriority Medium
1.837 +@SYMTestActions Test for bad query
1.838 +@SYMTestExpectedResults Test must not fail
1.839 +@SYMREQ REQ0000
1.840 +*/
1.841 +LOCAL_C void TestSQL(const TContext& aContext)
1.842 + {
1.843 + test.Start(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0616 Bad SQL "));
1.844 + aContext.OpenDbL();
1.845 + for (TUint ii=0;ii<sizeof(BadSql)/sizeof(BadSql[0]);++ii)
1.846 + test(TheView.Prepare(TheDatabase,TPtrC(BadSql[ii].iSql))==BadSql[ii].iError);
1.847 + TheDatabase.Close();
1.848 + TInt err = CRCCHECK;
1.849 + test(err == KErrNone);
1.850 + test.End();
1.851 + }
1.852 +
1.853 +/**
1.854 +@SYMTestCaseID SYSLIB-DBMS-CT-0617
1.855 +@SYMTestCaseDesc Tests for updation of an SQL statement
1.856 +@SYMTestPriority Medium
1.857 +@SYMTestActions Tests for update SQL statement
1.858 +@SYMTestExpectedResults Test must not fail
1.859 +@SYMREQ REQ0000
1.860 +*/
1.861 +LOCAL_C void TestUpdateSQL(const THeapFail& aHeap,const TContext& aContext)
1.862 + {
1.863 + test.Start(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0617 Test for UPDATE SQL statement "));
1.864 + TFailExecuteSQL fsql;
1.865 + TheSql=&UpdateSql;
1.866 + fsql.Test(aHeap,aContext);
1.867 + test.End();
1.868 + }
1.869 +
1.870 +LOCAL_C void View()
1.871 + {
1.872 + test.Start(_L("Client side"));
1.873 + TestView(KClientHeap,KClient);
1.874 + TestSQL(KClient);
1.875 + test.Next(_L("Client-Server"));
1.876 + Connect();
1.877 + TestView(KClientHeap,KServer);
1.878 + TestView(KServerHeap,KServer);
1.879 + TestSQL(KServer);
1.880 + TestUpdateSQL(KClientHeap,KClient);
1.881 + TestUpdateSQL(KServerHeap,KClient);
1.882 + Disconnect();
1.883 + test.End();
1.884 + }
1.885 +
1.886 +//TFailIncrementalUpdate implements the base class' virtual methods - RunL() and End().
1.887 +//TFailIncrementalUpdate::RunL() is called by the base class' Test() method, which simulates
1.888 +//OOM failures and checks the behaviour of the "incremental update" statement used by RunL().
1.889 +class TFailIncrementalUpdate : public TFail
1.890 + {
1.891 + virtual void RunL()
1.892 + {
1.893 + RDbUpdate dbUpdate;
1.894 + CleanupClosePushL(dbUpdate);
1.895 + User::LeaveIfError(dbUpdate.Execute(TheDatabase, _L("UPDATE A SET Name = 'ModifiedNameString' WHERE Id2 > 10")));
1.896 + TInt step = 0;
1.897 + for(TInt err=1;err>0;++step)
1.898 + {
1.899 + err = dbUpdate.Next();
1.900 + User::LeaveIfError(err);
1.901 + }
1.902 + test(step > 1);//just to be sure that the test executes dbUpdate.Next() more than once
1.903 + CleanupStack::PopAndDestroy(&dbUpdate);
1.904 + }
1.905 + virtual void End()
1.906 + {
1.907 + TheDatabase.Close();
1.908 + TInt err;
1.909 + TRAPD( lc, err = CRCCHECK);
1.910 + test(err == KErrNone);
1.911 + test(lc == KErrNone);
1.912 + }
1.913 + };
1.914 +
1.915 +/**
1.916 +@SYMTestCaseID SYSLIB-DBMS-UT-3414
1.917 +@SYMTestCaseDesc "Incremental update" operations - OOM test.
1.918 +@SYMTestPriority High
1.919 +@SYMTestActions Create a test database with one table and insert some records there (> 100).
1.920 + Run an "incremental update" operation in OOM loop.
1.921 +@SYMTestExpectedResults The test should not fail or panic.
1.922 +@SYMDEF INC101720
1.923 +*/
1.924 +LOCAL_C void IncrementalUpdateTest(const THeapFail& aHeap)
1.925 + {
1.926 + //Create a test shared database with a table
1.927 + TheDatabase.Close();
1.928 + TInt err, lc;
1.929 +#ifndef __TOOLS2__
1.930 + TheDbs.Close();
1.931 +#endif
1.932 + TRAP(lc, err = CRCCHECK);
1.933 + test(err == KErrNone);
1.934 + test(lc == KErrNone);
1.935 +#ifndef __TOOLS2__
1.936 + err = TheDbs.Connect();
1.937 + test(err == KErrNone);
1.938 +#endif
1.939 + err = TheDatabase.Replace(TheFs, KTestDatabase);
1.940 + test(err == KErrNone);
1.941 + TheDatabase.Close();
1.942 + TRAP(lc, err = CRCCHECK);
1.943 + test(err == KErrNone);
1.944 + test(lc == KErrNone);
1.945 + err = TheDatabase.Open(TheDbs, KTestDatabase);
1.946 + test(err == KErrNone);
1.947 + //Create a test table and fill the table with enough test records (> 100)
1.948 + err = TheDatabase.Execute(_L("CREATE TABLE A(Id COUNTER, Id2 INTEGER, Name LONG VARCHAR)"));
1.949 + test(err == KErrNone);
1.950 + const TInt KTestRecCount = 110;
1.951 + err = TheDatabase.Begin();
1.952 + test(err == KErrNone);
1.953 + for(TInt i=0;i<KTestRecCount;++i)
1.954 + {
1.955 + _LIT(KSqlFmtStr, "INSERT INTO A(Id2, Name) VALUES(%d, 'TestNameString')");
1.956 + TBuf<100> sql;
1.957 +// TUint32 id = Math::Random() % KTestRecCount;
1.958 + TUint32 id = (i^0x55555555) % KTestRecCount;
1.959 + sql.Format(KSqlFmtStr, id + 1);
1.960 + err = TheDatabase.Execute(sql);
1.961 + test(err == 1);
1.962 + }
1.963 + err = TheDatabase.Commit();
1.964 + test(err == KErrNone);
1.965 + //The OOM test
1.966 + TFailIncrementalUpdate testObj;
1.967 + testObj.Test(aHeap);
1.968 + //Cleanup
1.969 + TheDatabase.Close();
1.970 +#ifndef __TOOLS2__
1.971 + TheDbs.Close();
1.972 +#endif
1.973 + TRAP(lc, err = CRCCHECK);
1.974 + test(err == KErrNone);
1.975 + test(lc == KErrNone);
1.976 + }
1.977 +
1.978 +//
1.979 +// Testing the DBMS for failure modes
1.980 +//
1.981 +LOCAL_C void doMain()
1.982 + {
1.983 + test.Start(_L("Class RDbNamedDatabase"));
1.984 + __UHEAP_MARK;
1.985 + Origins();
1.986 + __UHEAP_CHECK(0);
1.987 + __UHEAP_MARK;
1.988 +// secure shared, not supported on tools2.
1.989 +// Origins2();
1.990 +
1.991 + __UHEAP_CHECK(0);
1.992 + test.Next(_L("Class RDbDatabase"));
1.993 + Database();
1.994 + __UHEAP_CHECK(0);
1.995 + test.Next(_L("Class RDbTable"));
1.996 + Table();
1.997 + __UHEAP_CHECK(0);
1.998 + test.Next(_L("Class RDbView"));
1.999 + View();
1.1000 + __UHEAP_MARKEND;
1.1001 + test.End();
1.1002 + }
1.1003 +
1.1004 +//
1.1005 +// Prepare the test directory.
1.1006 +//
1.1007 +LOCAL_C void setupTestDirectory()
1.1008 + {
1.1009 + TInt r=TheFs.Connect();
1.1010 + test(r==KErrNone);
1.1011 +//
1.1012 + r=TheFs.MkDir(KTestDatabase);
1.1013 + test(r==KErrNone || r==KErrAlreadyExists);
1.1014 + }
1.1015 +
1.1016 +//
1.1017 +// Initialise the cleanup stack.
1.1018 +//
1.1019 +LOCAL_C void setupCleanup()
1.1020 + {
1.1021 + TheTrapCleanup=CTrapCleanup::New();
1.1022 + test(TheTrapCleanup!=NULL);
1.1023 + TRAPD(r,\
1.1024 + {\
1.1025 + for (TInt i=KTestCleanupStack;i>0;i--)\
1.1026 + CleanupStack::PushL((TAny*)0);\
1.1027 + CleanupStack::Pop(KTestCleanupStack);\
1.1028 + });
1.1029 + test(r==KErrNone);
1.1030 + }
1.1031 +
1.1032 +LOCAL_C void DeleteDataFile(const TDesC& aFullName)
1.1033 + {
1.1034 + RFs fsSession;
1.1035 + TInt err = fsSession.Connect();
1.1036 + if(err == KErrNone)
1.1037 + {
1.1038 + TEntry entry;
1.1039 + if(fsSession.Entry(aFullName, entry) == KErrNone)
1.1040 + {
1.1041 + RDebug::Print(_L("Deleting \"%S\" file.\n"), &aFullName);
1.1042 + err = fsSession.SetAtt(aFullName, 0, KEntryAttReadOnly);
1.1043 + if(err != KErrNone)
1.1044 + {
1.1045 + RDebug::Print(_L("Error %d changing \"%S\" file attributes.\n"), err, &aFullName);
1.1046 + }
1.1047 + err = fsSession.Delete(aFullName);
1.1048 + if(err != KErrNone)
1.1049 + {
1.1050 + RDebug::Print(_L("Error %d deleting \"%S\" file.\n"), err, &aFullName);
1.1051 + }
1.1052 + }
1.1053 + fsSession.Close();
1.1054 + }
1.1055 + else
1.1056 + {
1.1057 + RDebug::Print(_L("Error %d connecting file session. File: %S.\n"), err, &aFullName);
1.1058 + }
1.1059 + }
1.1060 +
1.1061 +GLDEF_C TInt E32Main()
1.1062 + {
1.1063 + test.Title();
1.1064 + setupTestDirectory();
1.1065 + setupCleanup();
1.1066 + __UHEAP_MARK;
1.1067 +//
1.1068 + test.Start(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0612 Locating a database "));
1.1069 + TRAPD(r,TestOpen());
1.1070 + test(r==KErrNone);
1.1071 +
1.1072 +// These are in t_fail2, secure shared tests, unsupported.
1.1073 +// PrepareDbFmtString();
1.1074 +// TRAP(r,TestOpen2());
1.1075 +// test(r==KErrNone);
1.1076 +
1.1077 + test.Next(_L("Standard database"));
1.1078 + TRAP(r,doMain());
1.1079 + test(r==KErrNone);
1.1080 + test.Next(_L("Secure database"));
1.1081 + TRAP(r,doMain());
1.1082 + test(r==KErrNone);
1.1083 + test.Next(_L("ISAM database"));
1.1084 + TheFormat=_S("epoc[12345678]");
1.1085 + TRAP(r,Origins());
1.1086 + test(r==KErrNone);
1.1087 +
1.1088 +// TRAP(r,Origins2());
1.1089 +// test(r==KErrNone);
1.1090 + test.Start(_L(" @SYMTestCaseID:SYSLIB-DBMS-UT-3414 \"Incremental update\" - client test "));
1.1091 + IncrementalUpdateTest(KClientHeap);
1.1092 + test.End();
1.1093 + test.Start(_L(" @SYMTestCaseID:SYSLIB-DBMS-UT-3414 \"Incremental update\" - client-server test "));
1.1094 + IncrementalUpdateTest(KServerHeap);
1.1095 + test.End();
1.1096 + test.Printf(_L("Waiting for server exit\n"));
1.1097 + const TUint KExitDelay=6*0x100000; // ~6 seconds
1.1098 + User::After(KExitDelay);
1.1099 +
1.1100 + ::DeleteDataFile(KTestDatabase); // clean up data file used by this test - must be done before call to End() - DEF047652
1.1101 +
1.1102 +#ifndef __linux__
1.1103 + TInt err;
1.1104 +#ifndef __TOOLS2__
1.1105 + TRAPD(lc, err = TheCrcChecker.DumpCrcRecordsL(KCrcRecord));
1.1106 + test(err==KErrNone);
1.1107 + test(lc==KErrNone);
1.1108 +#else
1.1109 + TRAPD(lc, err = TheCrcChecker.ValidateCrcRecordsL(KCrcRecord));
1.1110 + TPtrC errmsg;
1.1111 + TheCrcChecker.ErrorReportL(err, errmsg);
1.1112 + RDebug::Print(errmsg);
1.1113 + test(err==KErrNone || err==TDBMS_CRCChecks::ECrcCheckOk);
1.1114 +#endif
1.1115 +#endif
1.1116 +
1.1117 + test.End();
1.1118 +
1.1119 + __UHEAP_MARKEND;
1.1120 +
1.1121 + delete TheTrapCleanup;
1.1122 + TheFs.Close();
1.1123 + test.Close();
1.1124 + return 0;
1.1125 + }