persistentstorage/dbms/tdbms/t_dbbig.cpp
changeset 0 08ec8eefde2f
child 55 44f437012c90
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 // MSVC++ up to 5.0 has problems with expanding inline functions
       
    17 // This disables the mad warnings for the whole project
       
    18 #if defined(NDEBUG) && defined(__VC32__) && _MSC_VER<=1100
       
    19 #pragma warning(disable : 4710)			// function not expanded. MSVC 5.0 is stupid
       
    20 #endif
       
    21 
       
    22 #include <d32dbms.h>
       
    23 #include <s32file.h>
       
    24 #include <e32test.h>
       
    25 #include <e32math.h>
       
    26 #include <hal.h>
       
    27 
       
    28 class TTimer
       
    29 	{
       
    30 public:
       
    31 	void Start(const TDesC& aDes);
       
    32 	void Stop();
       
    33 private:
       
    34 	TUint iTicks;
       
    35 	};
       
    36 
       
    37 LOCAL_D RTest test(_L("t_dbbig - Test Large DBMS objects"));
       
    38 LOCAL_D CTrapCleanup* TheTrapCleanup;
       
    39 LOCAL_D CFileStore* TheStore;
       
    40 LOCAL_D RDbStoreDatabase TheDatabase;
       
    41 LOCAL_D RDbTable TheTable;
       
    42 LOCAL_D RFs TheFs;
       
    43 
       
    44 const TInt KTestCleanupStack=0x20;
       
    45 const TPtrC KTestDir=_L("C:\\DBMS-TST\\");
       
    46 const TPtrC KTestFile=_L("T_BIG.DB");
       
    47 const TPtrC KTableName(_S("table"));
       
    48 const TPtrC KIndexText=_S("text");
       
    49 const TPtrC KIndexInt=_S("int");
       
    50 const TPtrC KColumnText=_S("text");
       
    51 const TPtrC KColumnInt=_S("int");
       
    52 const TPtrC KIncFormat=_S("%5d\r");
       
    53 const TInt KRecords=1000;
       
    54 const TPtrC KOtherTable=_S("extra");
       
    55 
       
    56 static TTimer TheTimer;
       
    57 
       
    58 void TTimer::Start(const TDesC& aDes)
       
    59 	{
       
    60 	test.Printf(_L("  %S: "),&aDes);
       
    61 	iTicks=User::FastCounter();
       
    62 	}
       
    63 
       
    64 void TTimer::Stop()
       
    65 	{
       
    66 	TUint ticks = User::FastCounter() - iTicks;
       
    67 	TInt freq = 0;
       
    68 	test(HAL::Get(HAL::EFastCounterFrequency, freq) == KErrNone);
       
    69 	const TInt KMicroSecIn1Sec = 1000000;
       
    70 	const TInt KMsIn1Sec = 1000;
       
    71 	double v = ((double)ticks * KMicroSecIn1Sec) / (double)freq; TInt v2 = (TInt)v;
       
    72 	test.Printf(_L("%d ms\r\n"),v2/KMsIn1Sec);
       
    73 	}
       
    74 
       
    75 /**
       
    76 @SYMTestCaseID          SYSLIB-DBMS-CT-1309
       
    77 @SYMTestCaseDesc        Create the database-in-a-store
       
    78 @SYMTestPriority        Medium
       
    79 @SYMTestActions        	Calls up RDbStoreDatabase::CreateL() function
       
    80 @SYMTestExpectedResults Test must not fail
       
    81 @SYMREQ                 REQ0000
       
    82 */
       
    83 LOCAL_C void CreateDatabaseL()
       
    84 	{
       
    85 	test.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-1309 "));
       
    86 	CFileStore* store=CPermanentFileStore::ReplaceLC(TheFs,KTestFile,EFileRead|EFileWrite);
       
    87 	store->SetTypeL(KPermanentFileStoreLayoutUid);
       
    88 	TStreamId id;
       
    89 		id=TheDatabase.CreateL(store);
       
    90 	store->SetRootL(id);
       
    91 	store->CommitL();
       
    92 	CleanupStack::Pop();
       
    93 	TheStore=store;
       
    94 	}
       
    95 
       
    96 /**
       
    97 @SYMTestCaseID          SYSLIB-DBMS-CT-1310
       
    98 @SYMTestCaseDesc        Open the database-in-a-store
       
    99 @SYMTestPriority        Medium
       
   100 @SYMTestActions        	Call up RDbStoreDatabase::OpenL()
       
   101 @SYMTestExpectedResults Test must not fail
       
   102 @SYMREQ                 REQ0000
       
   103 */
       
   104 LOCAL_C void OpenDatabaseL()
       
   105 	{
       
   106 	test.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-1310 "));
       
   107 	CFileStore* store=CPermanentFileStore::OpenLC(TheFs,KTestFile,EFileRead|EFileWrite);
       
   108 		TheDatabase.OpenL(store,store->Root());
       
   109 	CleanupStack::Pop();
       
   110 	TheStore=store;
       
   111 	}
       
   112 
       
   113 /**
       
   114 @SYMTestCaseID          SYSLIB-DBMS-CT-1311
       
   115 @SYMTestCaseDesc        Close the database in store
       
   116 @SYMTestPriority        Medium
       
   117 @SYMTestActions        	Test for RDbStoreDatabase::Close() function
       
   118 @SYMTestExpectedResults Test must not fail
       
   119 @SYMREQ                 REQ0000
       
   120 */
       
   121 LOCAL_C void CloseDatabase()
       
   122 	{
       
   123 	test.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-1311 "));
       
   124 	TheDatabase.Close();
       
   125 	delete TheStore;
       
   126 	}
       
   127 
       
   128 LOCAL_C void CreateTableL()
       
   129 	{
       
   130 	CDbColSet *cs=CDbColSet::NewLC();
       
   131 	TDbCol col1(KColumnInt,EDbColInt32);
       
   132 	col1.iAttributes=TDbCol::ENotNull;
       
   133 	cs->AddL(col1);
       
   134 	TDbCol col2(KColumnText,EDbColText,200/sizeof(TText));
       
   135 	col2.iAttributes=TDbCol::ENotNull;
       
   136 	cs->AddL(col2);
       
   137 	test(TheDatabase.CreateTable(KTableName,*cs)==KErrNone);
       
   138 	CleanupStack::PopAndDestroy();
       
   139 	}
       
   140 
       
   141 LOCAL_C void WriteRecordsL(TInt aCount)
       
   142 	{
       
   143 	TBuf<10> text;
       
   144 	TInt jj=0;
       
   145 	for (TInt ii=0;ii<aCount;++ii)
       
   146 		{
       
   147 		TheTable.InsertL();
       
   148 		jj=(jj+23);
       
   149 		if (jj>=aCount)
       
   150 			jj-=aCount;
       
   151 		TheTable.SetColL(1,jj);
       
   152 		text.Num(jj);
       
   153 		TheTable.SetColL(2,text);
       
   154 		TheTable.PutL();
       
   155 		}
       
   156 	}
       
   157 
       
   158 /**
       
   159 @SYMTestCaseID          SYSLIB-DBMS-CT-1312
       
   160 @SYMTestCaseDesc        Create a table in database
       
   161 @SYMTestPriority        Medium
       
   162 @SYMTestActions        	Build a table and write records into the table.Test for commiting the transactions.
       
   163 @SYMTestExpectedResults Test must not fail
       
   164 @SYMREQ                 REQ0000
       
   165 */
       
   166 LOCAL_C void BuildTableL(TInt aCount)
       
   167 	{
       
   168 	test.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-1312 "));
       
   169 	TheTimer.Start(_L("build"));
       
   170 	CreateTableL();
       
   171 	TheDatabase.Begin();
       
   172 	test(TheTable.Open(TheDatabase,KTableName)==KErrNone);
       
   173 	WriteRecordsL(aCount);
       
   174 	test(TheDatabase.Commit()==KErrNone);
       
   175 	TheTable.Close();
       
   176 	TheTimer.Stop();
       
   177 	}
       
   178 
       
   179 /**
       
   180 @SYMTestCaseID          SYSLIB-DBMS-CT-1313
       
   181 @SYMTestCaseDesc        Tests for total rows in the rowset
       
   182 @SYMTestPriority        Medium
       
   183 @SYMTestActions        	Iterate through the table.Test for the total numbers of rows available
       
   184 @SYMTestExpectedResults Test must not fail
       
   185 @SYMREQ                 REQ0000
       
   186 */
       
   187 LOCAL_C void IterateL(RDbTable::TPosition aDirection)
       
   188 	{
       
   189 	test.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-1313 "));
       
   190 	TheTimer.Start(_L("iterate"));
       
   191 	TInt cc=0;
       
   192 	while (TheTable.GotoL(aDirection))
       
   193 		{
       
   194 		++cc;
       
   195 		TheTable.GetL();
       
   196 		}
       
   197 	TheTimer.Stop();
       
   198 	test(cc=TheTable.CountL());
       
   199 	}
       
   200 
       
   201 /**
       
   202 @SYMTestCaseID          SYSLIB-DBMS-CT-0580
       
   203 @SYMTestCaseDesc        Tests the database definition and enquiry functions
       
   204 @SYMTestPriority        Medium
       
   205 @SYMTestActions        	Tests by setting an active index for the table.
       
   206 @SYMTestExpectedResults Test must not fail
       
   207 @SYMREQ                 REQ0000
       
   208 */
       
   209 LOCAL_C void TestIndexL(const TDesC& aName,const CDbKey& aKey)
       
   210 	{
       
   211 	test.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0580 "));
       
   212 	TheTimer.Start(_L("build"));
       
   213 	test(TheDatabase.CreateIndex(aName,KTableName,aKey)==KErrNone);
       
   214 	TheTimer.Stop();
       
   215 	test(TheTable.Open(TheDatabase,KTableName)==KErrNone);
       
   216 	test(TheTable.SetIndex(aName)==KErrNone);
       
   217 	IterateL(TheTable.ENext);
       
   218 	TheTable.Close();
       
   219 	}
       
   220 
       
   221 /**
       
   222 @SYMTestCaseID          SYSLIB-DBMS-CT-0581
       
   223 @SYMTestCaseDesc        Tests the database definition and enquiry functions
       
   224 @SYMTestPriority        Medium
       
   225 @SYMTestActions        	Tests for bookmark which saves the current location of a rowset.
       
   226 @SYMTestExpectedResults Test must not fail
       
   227 @SYMREQ                 REQ0000
       
   228 */
       
   229 LOCAL_C void TestBookmarkL()
       
   230 	{
       
   231 	test.Start(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0581 creating alien bookmark "));
       
   232 	CDbColSet* cs=CDbColSet::NewLC();
       
   233 	TDbCol col(_L("column"),EDbColUint8);
       
   234 	col.iAttributes=TDbCol::ENotNull+TDbCol::EAutoIncrement;
       
   235 	cs->AddL(col);
       
   236 	test (TheDatabase.CreateTable(KOtherTable,*cs)==KErrNone);
       
   237 	CleanupStack::PopAndDestroy();
       
   238 	RDbTable extra;
       
   239 	test (extra.Open(TheDatabase,KOtherTable)==KErrNone);
       
   240 	extra.InsertL();
       
   241 	extra.PutL();
       
   242 	TDbBookmark alien=extra.Bookmark();
       
   243 	extra.Close();
       
   244 //
       
   245 	test.Next(_L("Alien bookmark"));
       
   246 	test (TheTable.Open(TheDatabase,KTableName)==KErrNone);
       
   247 	TRAPD(r,TheTable.GotoL(alien));
       
   248 	test (r==KErrNotFound);
       
   249 	test (TheTable.SetIndex(KIndexInt)==KErrNone);
       
   250 	TRAP(r,TheTable.GotoL(alien));
       
   251 	test (r==KErrNotFound);
       
   252 	test (TheTable.SetIndex(KIndexText)==KErrNone);
       
   253 	TRAP(r,TheTable.GotoL(alien));
       
   254 	test (r==KErrNotFound);
       
   255 //
       
   256 	test.Next(_L("Cross-view bookmarks"));
       
   257 	TheTable.LastL();	// indexed view
       
   258 	TheTable.PreviousL();
       
   259 	TDbBookmark mark=TheTable.Bookmark();
       
   260 	test (extra.Open(TheDatabase,KTableName)==KErrNone);
       
   261 	TRAP(r,extra.GotoL(mark));
       
   262 	test (r==KErrNone);
       
   263 	test (extra.PreviousL());
       
   264 	TRAP(r,TheTable.GotoL(extra.Bookmark()));
       
   265 	test (r==KErrNone);
       
   266 	extra.Close();
       
   267 //
       
   268 	test.Next(_L("Bookmark persistence"));
       
   269 	TheTable.Close();
       
   270 	test (TheTable.Open(TheDatabase,KTableName)==KErrNone);
       
   271 	TRAP(r,TheTable.GotoL(mark));
       
   272 	test (r==KErrNone);
       
   273 	TheTable.Close();
       
   274 //
       
   275 	test.Next(_L("Delete alien record"));
       
   276 	test (extra.Open(TheDatabase,KOtherTable)==KErrNone);
       
   277 	TRAP(r, extra.GotoL(mark));
       
   278 	test (r==KErrNotFound);
       
   279 	TRAP(r,extra.GotoL(alien));
       
   280 	test (r==KErrNone);
       
   281 	extra.DeleteL();
       
   282 	TRAP(r,extra.GotoL(alien));
       
   283 	test (r==KErrNotFound);
       
   284 	extra.Close();
       
   285 //
       
   286 	test.Next(_L("Delete extra table"));
       
   287 	test (TheDatabase.DropTable(KOtherTable)==KErrNone);
       
   288 	test (TheTable.Open(TheDatabase,KTableName)==KErrNone);
       
   289 	TRAP(r,TheTable.GotoL(alien));
       
   290 	test (r==KErrNotFound);
       
   291 	TheTable.Close();
       
   292 //
       
   293 	test.End();
       
   294 	}
       
   295 
       
   296 /**
       
   297 @SYMTestCaseID          SYSLIB-DBMS-CT-1314
       
   298 @SYMTestCaseDesc        Discarding indexes belonging to the table on database
       
   299 @SYMTestPriority        Medium
       
   300 @SYMTestActions        	Tests for RDbIncremental::DropTable(),RDbIncremental::Next() function.
       
   301 @SYMTestExpectedResults Test must not fail
       
   302 @SYMREQ                 REQ0000
       
   303 */
       
   304 LOCAL_C void BreakIndex()
       
   305 	{
       
   306 	test.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-1314 "));
       
   307 	TheTimer.Start(_L("break"));
       
   308 	TInt step;
       
   309 	RDbIncremental drop;
       
   310 	test(drop.DropTable(TheDatabase,KTableName,step)==KErrNone);
       
   311 	test(drop.Next(step)==KErrNone);
       
   312 	test(step>0);
       
   313 	drop.Close();	// abort the drop
       
   314 	test(TheDatabase.IsDamaged());
       
   315 	TheTimer.Stop();
       
   316 	}
       
   317 
       
   318 /**
       
   319 @SYMTestCaseID          SYSLIB-DBMS-CT-1315
       
   320 @SYMTestCaseDesc        Database recovery test
       
   321 @SYMTestPriority        Medium
       
   322 @SYMTestActions        	Calls up RDbStoreDatabase::Recover() function
       
   323 @SYMTestExpectedResults Test must not fail
       
   324 @SYMREQ                 REQ0000
       
   325 */
       
   326 LOCAL_C void Recover()
       
   327 	{
       
   328 	test.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-1315 "));
       
   329 	TheTimer.Start(_L("recover"));
       
   330 	test(TheDatabase.Recover()==KErrNone);
       
   331 	TheTimer.Stop();
       
   332 	test(!TheDatabase.IsDamaged());
       
   333 	}
       
   334 
       
   335 /**
       
   336 @SYMTestCaseID          SYSLIB-DBMS-CT-1316
       
   337 @SYMTestCaseDesc        Tests for dropping an index
       
   338 @SYMTestPriority        Medium
       
   339 @SYMTestActions        	Drop an integer and text index from the table. Test for damage of database
       
   340 @SYMTestExpectedResults Test must not fail
       
   341 @SYMREQ                 REQ0000
       
   342 */
       
   343 LOCAL_C void DropIndexes()
       
   344 	{
       
   345 	test.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-1316 "));
       
   346 	TheTimer.Start(_L("drop Int[32]"));
       
   347 	test(TheDatabase.DropIndex(KIndexInt,KTableName)==KErrNone);
       
   348 	TheTimer.Stop();
       
   349 	TheTimer.Start(_L("drop Text[200]"));
       
   350 	test(TheDatabase.DropIndex(KIndexText,KTableName)==KErrNone);
       
   351 	TheTimer.Stop();
       
   352 	test(!TheDatabase.IsDamaged());
       
   353 	}
       
   354 
       
   355 /**
       
   356 @SYMTestCaseID          SYSLIB-DBMS-CT-1317
       
   357 @SYMTestCaseDesc        Deleting a table from the database
       
   358 @SYMTestPriority        Medium
       
   359 @SYMTestActions        	Delete the rows from the rowset.Check for empty rows in the rowset.
       
   360 @SYMTestExpectedResults Test must not fail
       
   361 @SYMREQ                 REQ0000
       
   362 */
       
   363 LOCAL_C void DeleteTableL()
       
   364 	{
       
   365 	test.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-1317 "));
       
   366 	const TInt KTenthRecords=KRecords/10;
       
   367 
       
   368 	test (TheTable.Open(TheDatabase,KTableName)==KErrNone);
       
   369 	TheDatabase.Begin();
       
   370 	TInt ii;
       
   371 	for (ii=0;ii<15;++ii)
       
   372 		{
       
   373 		TheTable.NextL();
       
   374 		TheTable.DeleteL();
       
   375 		}
       
   376 	TheTable.NextL();
       
   377 	TDbBookmark mark=TheTable.Bookmark();
       
   378 	TheTable.Close();
       
   379 	TheDatabase.Commit();
       
   380 	CloseDatabase();
       
   381 	OpenDatabaseL();
       
   382 	TheTimer.Start(_L("delete table"));
       
   383 	test (TheTable.Open(TheDatabase,KTableName)==KErrNone);
       
   384 	TheDatabase.Begin();
       
   385 	TheTable.GotoL(mark);
       
   386 	TheTable.DeleteL();
       
   387 	for (ii=0;ii<KTenthRecords*2-16;++ii)
       
   388 		{
       
   389 		TheTable.NextL();
       
   390 		TheTable.DeleteL();
       
   391 		}
       
   392 	TheTable.EndL();
       
   393 	for (ii=0;ii<KTenthRecords*2;++ii)
       
   394 		{
       
   395 		TheTable.PreviousL();
       
   396 		TheTable.DeleteL();
       
   397 		}
       
   398 	TheTable.BeginningL();
       
   399 	for (ii=0;ii<KTenthRecords*3;++ii)
       
   400 		TheTable.NextL();
       
   401 	for (ii=0;ii<KTenthRecords*2;++ii)
       
   402 		{
       
   403 		TheTable.NextL();
       
   404 		TheTable.DeleteL();
       
   405 		}
       
   406 	for (ii=0;ii<KTenthRecords*2;++ii)
       
   407 		{
       
   408 		TheTable.PreviousL();
       
   409 		TheTable.DeleteL();
       
   410 		}
       
   411 	for (ii=0;ii<KTenthRecords;++ii)
       
   412 		{
       
   413 		TheTable.NextL();
       
   414 		TheTable.DeleteL();
       
   415 		}
       
   416 	for (ii=0;ii<KTenthRecords;++ii)
       
   417 		{
       
   418 		TheTable.PreviousL();
       
   419 		TheTable.DeleteL();
       
   420 		}
       
   421 	test (TheTable.CountL()==0);
       
   422 	test (!TheTable.NextL());
       
   423 	test (!TheTable.PreviousL());
       
   424 	test (TheDatabase.Commit()==KErrNone);
       
   425 	TheTable.Close();
       
   426 	TheTimer.Stop();
       
   427 	}
       
   428 
       
   429 /**
       
   430 @SYMTestCaseID          SYSLIB-DBMS-CT-0579
       
   431 @SYMTestCaseDesc        Tests the database definition and enquiry functions
       
   432 @SYMTestPriority        Medium
       
   433 @SYMTestActions        	Executes the index and bookmark tests
       
   434 @SYMTestExpectedResults Test must not fail
       
   435 @SYMREQ                 REQ0000
       
   436 */
       
   437 LOCAL_C void BigTestL()
       
   438 	{
       
   439 	test.Start(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0579 Table "));
       
   440 	CreateDatabaseL();
       
   441 	BuildTableL(KRecords);
       
   442 	test(TheTable.Open(TheDatabase,KTableName)==KErrNone);
       
   443 	TheTable.EndL();
       
   444 	IterateL(TheTable.EPrevious);
       
   445 	TheTable.BeginningL();
       
   446 	IterateL(TheTable.ENext);
       
   447 	TheTable.EndL();
       
   448 	IterateL(TheTable.EPrevious);
       
   449 	TheTable.Close();
       
   450 	test.Next(_L("Int32 Index"));
       
   451 	CDbKey *key=CDbKey::NewLC();
       
   452 	key->AddL(KColumnInt);
       
   453 	key->MakeUnique();
       
   454 	TestIndexL(KIndexInt,*key);
       
   455 	test.Next(_L("Text[200] Index"));
       
   456 	key->Clear();
       
   457 	key->AddL(KColumnText);
       
   458 	key->MakeUnique();
       
   459 	TestIndexL(KIndexText,*key);
       
   460 	test.Next(_L("Bookmarks"));
       
   461 	TestBookmarkL();
       
   462 	test.Next(_L("Int32 Index"));
       
   463 	TheTimer.Start(_L("drop"));
       
   464 	test(TheDatabase.DropIndex(KIndexInt,KTableName)==KErrNone);
       
   465 	TheTimer.Stop();
       
   466 	key->Clear();
       
   467 	key->AddL(KColumnInt);
       
   468 	key->MakeUnique();
       
   469 	TestIndexL(KIndexInt,*key);
       
   470 	CleanupStack::PopAndDestroy();
       
   471 	test.Next(_L("Break & Recover"));
       
   472 	BreakIndex();
       
   473 	Recover();
       
   474 	test.Next(_L("Drop Indexes"));
       
   475 	DropIndexes();
       
   476 	test.Next(_L("Delete all records"));
       
   477 	DeleteTableL();
       
   478 	CloseDatabase();
       
   479 	test.End();
       
   480 	}
       
   481 
       
   482 //
       
   483 // Prepare the test directory.
       
   484 //
       
   485 LOCAL_C void setupTestDirectory()
       
   486     {
       
   487 	TInt r=TheFs.Connect();
       
   488 	test(r==KErrNone);
       
   489 	r=TheFs.MkDir(KTestDir);
       
   490 	test(r==KErrNone || r==KErrAlreadyExists);
       
   491 	r=TheFs.SetSessionPath(KTestDir);
       
   492 	test(r==KErrNone);
       
   493 	}
       
   494 
       
   495 //
       
   496 // Initialise the cleanup stack.
       
   497 //
       
   498 LOCAL_C void setupCleanup()
       
   499     {
       
   500 	TheTrapCleanup=CTrapCleanup::New();
       
   501 	test(TheTrapCleanup!=NULL);
       
   502 	TRAPD(r,\
       
   503 		{\
       
   504 		for (TInt i=KTestCleanupStack;i>0;i--)\
       
   505 			CleanupStack::PushL((TAny*)0);\
       
   506 		CleanupStack::Pop(KTestCleanupStack);\
       
   507 		});
       
   508 	test(r==KErrNone);
       
   509 	}
       
   510 
       
   511 LOCAL_C void DeleteDataFile(const TDesC& aFullName)
       
   512 	{
       
   513 	RFs fsSession;
       
   514 	TInt err = fsSession.Connect();
       
   515 	if(err == KErrNone)
       
   516 		{
       
   517 		TEntry entry;
       
   518 		if(fsSession.Entry(aFullName, entry) == KErrNone)
       
   519 			{
       
   520 			RDebug::Print(_L("Deleting \"%S\" file.\n"), &aFullName);
       
   521 			err = fsSession.SetAtt(aFullName, 0, KEntryAttReadOnly);
       
   522 			if(err != KErrNone)
       
   523 				{
       
   524 				RDebug::Print(_L("Error %d changing \"%S\" file attributes.\n"), err, &aFullName);
       
   525 				}
       
   526 			err = fsSession.Delete(aFullName);
       
   527 			if(err != KErrNone)
       
   528 				{
       
   529 				RDebug::Print(_L("Error %d deleting \"%S\" file.\n"), err, &aFullName);
       
   530 				}
       
   531 			}
       
   532 		fsSession.Close();
       
   533 		}
       
   534 	else
       
   535 		{
       
   536 		RDebug::Print(_L("Error %d connecting file session. File: %S.\n"), err, &aFullName);
       
   537 		}
       
   538 	}
       
   539 
       
   540 //
       
   541 // Test streaming conversions.
       
   542 //
       
   543 GLDEF_C TInt E32Main()
       
   544     {
       
   545 	test.Title();
       
   546 	setupTestDirectory();
       
   547 	setupCleanup();
       
   548 	__UHEAP_MARK;
       
   549 //
       
   550 	test.Start(_L("Standard database"));
       
   551 	TRAPD(r,BigTestL();)
       
   552 	test(r==KErrNone);
       
   553 
       
   554 	// clean up data files used by this test - must be done before call to End() - DEF047652
       
   555 	_LIT(KTestDbName, "C:\\DBMS-TST\\T_BIG.DB");
       
   556 	::DeleteDataFile(KTestDbName);
       
   557 
       
   558 	test.End();
       
   559 //
       
   560 	__UHEAP_MARKEND;
       
   561 	delete TheTrapCleanup;
       
   562 
       
   563 
       
   564 
       
   565 	TheFs.Close();
       
   566 	test.Close();
       
   567 	return 0;
       
   568     }