os/persistentdata/persistentstorage/store/TSTOR/t_stordictfs.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) 1998-2009 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 <s32file.h>
sl@0
    18
sl@0
    19
const TInt KTestCleanupStack=0x40;
sl@0
    20
sl@0
    21
_LIT(KTitle,"t_stordictfs");
sl@0
    22
LOCAL_D RTest test(KTitle);
sl@0
    23
LOCAL_D CTrapCleanup* TheTrapCleanup;
sl@0
    24
LOCAL_D RFs TheFs;
sl@0
    25
sl@0
    26
// These are path specifications and should not be used as is
sl@0
    27
_LIT(KDicFilePath,"Z:\\stor-tst\\dicfile.ini");
sl@0
    28
const TUid dicFileUid={19445};
sl@0
    29
_LIT(KSystemIniFile,"Z:\\System\\System.ini");
sl@0
    30
_LIT(KBackupSystemIniFile,"Z:\\System\\System.backup");
sl@0
    31
_LIT(KTestIniFile,"Z:\\stor-tst\\Test.ini");
sl@0
    32
_LIT(KThreadTestPath, "Z:\\stor-tst\\Thread Test %d.ini");
sl@0
    33
sl@0
    34
const TInt KNumThreads=20;
sl@0
    35
const TInt KThreadStack=0x2000;
sl@0
    36
const TInt KThreadHeap=0x1000;
sl@0
    37
const TInt KThreadHeapMax=0x100000;
sl@0
    38
sl@0
    39
// some uid's to use for testing
sl@0
    40
const TUid testUid1={1};
sl@0
    41
const TUid testUid2={57};
sl@0
    42
const TUid testUid3={99999};
sl@0
    43
const TUid testUid4={98765};
sl@0
    44
const TUid KTestUid={0xf0000000};
sl@0
    45
//
sl@0
    46
// some data values for testing
sl@0
    47
const TInt value1=42;
sl@0
    48
const TInt value2=147;
sl@0
    49
const TInt value3=6547;
sl@0
    50
sl@0
    51
/**
sl@0
    52
@SYMTestCaseID          SYSLIB-STORE-CT-1183
sl@0
    53
@SYMTestCaseDesc	    Tests for CDictionaryFileStore::IsPresentL(),CDictionaryFileStore::Remove() functions
sl@0
    54
@SYMTestPriority 	    High
sl@0
    55
@SYMTestActions  	    Tests for writing an entry and commit it.
sl@0
    56
                        Tests for reading the entry back.
sl@0
    57
						Tests for rewriting and reading back using LC functions.
sl@0
    58
						Tests for adding one more entry and check for the content.
sl@0
    59
@SYMTestExpectedResults Test must not fail
sl@0
    60
@SYMREQ                 REQ0000
sl@0
    61
*/
sl@0
    62
LOCAL_C void Test1L(CDictionaryFileStore* aDict)
sl@0
    63
	{
sl@0
    64
	// write an entry and commit it
sl@0
    65
	test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1183 "));
sl@0
    66
	RDictionaryWriteStream writeStream;
sl@0
    67
	TRAPD(ret, writeStream.AssignL(*aDict,testUid1));
sl@0
    68
		test(ret==KErrNone);
sl@0
    69
	TRAP(ret, writeStream.WriteInt32L(value1));
sl@0
    70
		test(ret==KErrNone);
sl@0
    71
	TRAP(ret, writeStream.CommitL());
sl@0
    72
		test(ret==KErrNone);
sl@0
    73
	writeStream.Close();
sl@0
    74
	// read that entry back
sl@0
    75
	RDictionaryReadStream readStream;
sl@0
    76
	TRAP(ret, readStream.OpenL(*aDict,testUid1));
sl@0
    77
		test(ret==KErrNone);
sl@0
    78
	TInt val=0;
sl@0
    79
	TRAP(ret, val = readStream.ReadInt32L());
sl@0
    80
		test(ret==KErrNone);
sl@0
    81
		test(val==value1);
sl@0
    82
	readStream.Close();
sl@0
    83
	//
sl@0
    84
	test.Next(_L("Test the stream LC methods"));
sl@0
    85
	// read that entry back using the LC method
sl@0
    86
	readStream.OpenLC(*aDict,testUid1);
sl@0
    87
	TRAP(ret, val = readStream.ReadInt32L());
sl@0
    88
		test(ret==KErrNone);
sl@0
    89
		test(val==value1);
sl@0
    90
	//readStream.Close();
sl@0
    91
	CleanupStack::PopAndDestroy(); // readStream
sl@0
    92
	//
sl@0
    93
	// rewrite that entry using the LC method
sl@0
    94
	writeStream.AssignLC(*aDict,testUid1);
sl@0
    95
	
sl@0
    96
	//do some rading
sl@0
    97
	MStreamBuf* sbuf = writeStream.Sink();
sl@0
    98
	HBufC8* buffer = HBufC8::NewLC(400);
sl@0
    99
	TUint8* buffptr = const_cast<TUint8*>(buffer->Ptr());
sl@0
   100
	sbuf->ReadL(buffptr, 100);
sl@0
   101
	TPtr8 buffDes(buffer->Des());
sl@0
   102
	TRequestStatus rstatus;
sl@0
   103
	sbuf->ReadL(buffDes, 100, rstatus);
sl@0
   104
	User::WaitForRequest(rstatus);
sl@0
   105
	CleanupStack::PopAndDestroy(); //buffer
sl@0
   106
	
sl@0
   107
	TRAP(ret, writeStream.WriteInt32L(value1));
sl@0
   108
		test(ret==KErrNone);
sl@0
   109
	TRAP(ret, writeStream.CommitL());
sl@0
   110
		test(ret==KErrNone);
sl@0
   111
	//writeStream.Close();
sl@0
   112
	CleanupStack::PopAndDestroy(); // writestream
sl@0
   113
	//
sl@0
   114
	test.Next(_L("Test reverting the store"));
sl@0
   115
	// commit the store
sl@0
   116
	TRAP(ret, aDict->CommitL());
sl@0
   117
		test(ret==KErrNone);
sl@0
   118
	// replace the 1st entry, commit it, then revert the store
sl@0
   119
	TRAP(ret, writeStream.AssignL(*aDict,testUid1));
sl@0
   120
		test(ret==KErrNone);
sl@0
   121
	TRAP(ret, writeStream.WriteInt32L(value2));
sl@0
   122
		test(ret==KErrNone);
sl@0
   123
	TRAP(ret, writeStream.CommitL());
sl@0
   124
		test(ret==KErrNone);
sl@0
   125
	writeStream.Close();
sl@0
   126
	TRAP(ret, aDict->RevertL());
sl@0
   127
		test(ret==KErrNone);
sl@0
   128
	// check the value of the entry
sl@0
   129
	TRAP(ret, readStream.OpenL(*aDict,testUid1));
sl@0
   130
		test(ret==KErrNone);
sl@0
   131
	TRAP(ret, val = readStream.ReadInt32L());
sl@0
   132
		test(ret==KErrNone);
sl@0
   133
		test(val==value1);
sl@0
   134
	readStream.Close();
sl@0
   135
	
sl@0
   136
	test.Next(_L("Test reverting the store using alternative Revert method"));
sl@0
   137
	// replace the 1st entry, commit it, then revert the store
sl@0
   138
	TRAP(ret, writeStream.AssignL(*aDict,testUid1));
sl@0
   139
		test(ret==KErrNone);
sl@0
   140
	TRAP(ret, writeStream.WriteInt32L(value2));
sl@0
   141
		test(ret==KErrNone);
sl@0
   142
	TRAP(ret, writeStream.CommitL());
sl@0
   143
		test(ret==KErrNone);
sl@0
   144
	writeStream.Close();
sl@0
   145
	aDict->Revert();
sl@0
   146
	// check the value of the entry
sl@0
   147
	TRAP(ret, readStream.OpenL(*aDict,testUid1));
sl@0
   148
		test(ret==KErrNone);
sl@0
   149
	TRAP(ret, val = readStream.ReadInt32L());
sl@0
   150
		test(ret==KErrNone);
sl@0
   151
		test(val==value1);
sl@0
   152
	readStream.Close();
sl@0
   153
	//
sl@0
   154
	//
sl@0
   155
	test.Next(_L("Test IsPresentL() and Remove()"));
sl@0
   156
	// add another entry
sl@0
   157
	TRAP(ret, writeStream.AssignL(*aDict,testUid2));
sl@0
   158
		test(ret==KErrNone);
sl@0
   159
	TRAP(ret, writeStream.WriteInt32L(value2));
sl@0
   160
		test(ret==KErrNone);
sl@0
   161
	test(!aDict->IsPresentL(testUid2));
sl@0
   162
	TRAP(ret, writeStream.CommitL());
sl@0
   163
		test(ret==KErrNone);
sl@0
   164
	writeStream.Close();
sl@0
   165
	// test IsPresentL()
sl@0
   166
	test(aDict->IsPresentL(testUid1));
sl@0
   167
	test(aDict->IsPresentL(testUid2));
sl@0
   168
	test(!aDict->IsPresentL(testUid3));
sl@0
   169
	// test Remove()
sl@0
   170
	TRAP(ret, aDict->RemoveL(testUid1));
sl@0
   171
		test(!aDict->IsPresentL(testUid1));
sl@0
   172
	//
sl@0
   173
	//
sl@0
   174
	test.Next(_L("Close the store and re-open it"));
sl@0
   175
	// commit the store and close it
sl@0
   176
	TRAP(ret, aDict->CommitL());
sl@0
   177
		test(ret==KErrNone);
sl@0
   178
	//
sl@0
   179
	delete aDict;
sl@0
   180
	}
sl@0
   181
sl@0
   182
/**
sl@0
   183
@SYMTestCaseID          SYSLIB-STORE-CT-1184
sl@0
   184
@SYMTestCaseDesc	    Tests for CDictionaryFileStore::IsPresentL() function
sl@0
   185
@SYMTestPriority 	    High
sl@0
   186
@SYMTestActions  	    Tests for the specified UID's has an associated stream within the dictionary store.
sl@0
   187
						Tests for KErrNone error flag while opening a dictionary file for read,test the value read from the file.
sl@0
   188
@SYMTestExpectedResults Test must not fail
sl@0
   189
@SYMREQ                 REQ0000
sl@0
   190
*/
sl@0
   191
LOCAL_C void Test2L(CDictionaryFileStore* aDict)
sl@0
   192
	{
sl@0
   193
	test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1184 "));
sl@0
   194
	test(!aDict->IsPresentL(testUid1));
sl@0
   195
	test(aDict->IsPresentL(testUid2));
sl@0
   196
	test(!aDict->IsPresentL(testUid3));
sl@0
   197
	RDictionaryReadStream readStream;
sl@0
   198
	TRAPD(ret, readStream.OpenL(*aDict,testUid2));
sl@0
   199
		test(ret==KErrNone);
sl@0
   200
	TInt val=0;
sl@0
   201
	TRAP(ret, val = readStream.ReadInt32L());
sl@0
   202
		test(ret==KErrNone);
sl@0
   203
		test(val==value2);
sl@0
   204
	readStream.Close();
sl@0
   205
	//
sl@0
   206
	//
sl@0
   207
	test.Next(_L("Close the store without commiting"));
sl@0
   208
	// add a stream, close the store (no commit)
sl@0
   209
	RDictionaryWriteStream writeStream;
sl@0
   210
	TRAP(ret, writeStream.AssignL(*aDict,testUid3));
sl@0
   211
		test(ret==KErrNone);
sl@0
   212
	TRAP(ret, writeStream.WriteInt32L(value3));
sl@0
   213
		test(ret==KErrNone);
sl@0
   214
	TRAP(ret, writeStream.CommitL());
sl@0
   215
		test(ret==KErrNone);
sl@0
   216
	writeStream.Close();
sl@0
   217
	delete aDict;
sl@0
   218
	}
sl@0
   219
sl@0
   220
/**
sl@0
   221
@SYMTestCaseID          SYSLIB-STORE-CT-1185
sl@0
   222
@SYMTestCaseDesc	    Reading from a dictionary file test
sl@0
   223
@SYMTestPriority 	    High
sl@0
   224
@SYMTestActions  	    Tests for the specified UID's has an associated stream within the dictionary store.
sl@0
   225
                        Tests for KErrNone error flag,while opening a dictionary file for read operation
sl@0
   226
@SYMTestExpectedResults Test must not fail
sl@0
   227
@SYMREQ                 REQ0000
sl@0
   228
*/
sl@0
   229
LOCAL_C void Test3L(CDictionaryFileStore* aDict)
sl@0
   230
	{
sl@0
   231
	test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1185 "));
sl@0
   232
	test(!aDict->IsPresentL(testUid1));
sl@0
   233
	test(aDict->IsPresentL(testUid2));
sl@0
   234
	test(!aDict->IsPresentL(testUid3));
sl@0
   235
	RDictionaryReadStream readStream;
sl@0
   236
	TRAPD(ret, readStream.OpenL(*aDict,testUid2));
sl@0
   237
	test(ret==KErrNone);
sl@0
   238
	
sl@0
   239
	TInt val=0;
sl@0
   240
	TRAP(ret, val = readStream.ReadInt32L());
sl@0
   241
	test(ret==KErrNone);
sl@0
   242
	test(val==value2);
sl@0
   243
	
sl@0
   244
	readStream.Close();
sl@0
   245
	delete aDict;
sl@0
   246
	}
sl@0
   247
/**
sl@0
   248
@SYMTestCaseID          PDS-STORE-CT-4022
sl@0
   249
@SYMTestCaseDesc	    Validate IsNUll() API
sl@0
   250
@SYMTestPriority 	    High
sl@0
   251
@SYMTestActions  	    Test that the specified DictionaryStore is not present
sl@0
   252
@SYMTestExpectedResults Test must not fail
sl@0
   253
@SYMDEF                 DEF135804
sl@0
   254
*/
sl@0
   255
LOCAL_C void Test4L(CDictionaryFileStore* aDict)
sl@0
   256
	{
sl@0
   257
	test.Next(_L(" @SYMTestCaseID:PDS-STORE-CT-4022 "));
sl@0
   258
	test(aDict->IsNullL());
sl@0
   259
	}
sl@0
   260
sl@0
   261
/**
sl@0
   262
@SYMTestCaseID          PDS-STORE-CT-4023
sl@0
   263
@SYMTestCaseDesc	    Validate IsNUll() API
sl@0
   264
@SYMTestPriority 	    High
sl@0
   265
@SYMTestActions  	    Test that the specified DictionaryStore is  present
sl@0
   266
@SYMTestExpectedResults Test must not fail
sl@0
   267
@SYMDEF                 DEF135804
sl@0
   268
*/
sl@0
   269
LOCAL_C void Test5L(CDictionaryFileStore* aDict)
sl@0
   270
	{
sl@0
   271
	test.Next(_L(" @SYMTestCaseID:PDS-STORE-CT-4023 "));
sl@0
   272
	test(!aDict->IsNullL());
sl@0
   273
	delete aDict;
sl@0
   274
	}
sl@0
   275
sl@0
   276
/**
sl@0
   277
@SYMTestCaseID          PDS-STORE-CT-4024
sl@0
   278
@SYMTestCaseDesc	    Validate Remove() API
sl@0
   279
@SYMTestPriority 	    High
sl@0
   280
@SYMTestActions  	    Test that the specified UID is  present
sl@0
   281
                        Remove Stream and test that UID is not present
sl@0
   282
@SYMTestExpectedResults Test must not fail
sl@0
   283
@SYMDEF                 DEF135804
sl@0
   284
*/
sl@0
   285
LOCAL_C void Test6L(CDictionaryFileStore* aDict)
sl@0
   286
	{
sl@0
   287
	test.Next(_L(" @SYMTestCaseID:PDS-STORE-CT-4024 "));
sl@0
   288
	test(aDict->IsPresentL(testUid2));
sl@0
   289
	aDict->Remove(testUid2);
sl@0
   290
	test(!aDict->IsPresentL(testUid2));
sl@0
   291
	delete aDict;
sl@0
   292
	}
sl@0
   293
sl@0
   294
sl@0
   295
/**
sl@0
   296
Test the System ini file
sl@0
   297
sl@0
   298
@SYMTestCaseID          SYSLIB-STORE-CT-1186
sl@0
   299
@SYMTestCaseDesc	    Tests for CDictionaryFileStore::SystemL() function
sl@0
   300
@SYMTestPriority 	    High
sl@0
   301
@SYMTestActions  	    Tests for creation of system file.Tests for basic operations on the file
sl@0
   302
@SYMTestExpectedResults Test must not fail
sl@0
   303
@SYMREQ                 REQ0000
sl@0
   304
*/
sl@0
   305
LOCAL_C void systemTestL()
sl@0
   306
	{
sl@0
   307
	TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive()));	
sl@0
   308
	TParse systemIniFile;
sl@0
   309
	TParse backupSystemIniFile;
sl@0
   310
	systemIniFile.Set(drive.Name(), &KSystemIniFile, NULL);
sl@0
   311
	backupSystemIniFile.Set(drive.Name(), &KBackupSystemIniFile, NULL);
sl@0
   312
sl@0
   313
	TheFs.Rename(systemIniFile.FullName(),backupSystemIniFile.FullName());
sl@0
   314
	TParse parse;
sl@0
   315
	parse.Set(systemIniFile.FullName(),NULL,NULL);
sl@0
   316
	TheFs.RmDir(parse.DriveAndPath());
sl@0
   317
//
sl@0
   318
	test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1186 Create system file "));
sl@0
   319
	CDictionaryFileStore* dicFile=NULL;
sl@0
   320
	TRAPD(ret, dicFile = CDictionaryFileStore::SystemL(TheFs));
sl@0
   321
	test(ret==KErrNone);
sl@0
   322
	TEntry entry;
sl@0
   323
	TInt err = TheFs.Entry(systemIniFile.FullName(),entry);
sl@0
   324
	test (err==KErrNone);
sl@0
   325
	Test1L(dicFile);
sl@0
   326
	test.Next(_L("Opening system file"));
sl@0
   327
	TRAP(ret, dicFile = CDictionaryFileStore::SystemL(TheFs));
sl@0
   328
		test(ret==KErrNone);
sl@0
   329
	Test2L(dicFile);
sl@0
   330
	TRAP(ret, dicFile = CDictionaryFileStore::SystemL(TheFs));
sl@0
   331
		test(ret==KErrNone);
sl@0
   332
	Test3L(dicFile);
sl@0
   333
	
sl@0
   334
	TRAP(ret, dicFile = CDictionaryFileStore::SystemL(TheFs));
sl@0
   335
	test(ret==KErrNone);
sl@0
   336
	Test6L(dicFile);
sl@0
   337
	
sl@0
   338
	TheFs.Delete(systemIniFile.FullName());
sl@0
   339
	TheFs.Rename(backupSystemIniFile.FullName(),systemIniFile.FullName());
sl@0
   340
	}
sl@0
   341
sl@0
   342
/**
sl@0
   343
@SYMTestCaseID          SYSLIB-STORE-CT-1187
sl@0
   344
@SYMTestCaseDesc	    Tests for creating a new file and adding an entry into it
sl@0
   345
@SYMTestPriority 	    High
sl@0
   346
@SYMTestActions  	    Execute tests for create,open and check the contents and reopening
sl@0
   347
                        Check for ErrNone flag during the open operation.
sl@0
   348
@SYMTestExpectedResults Test must not fail
sl@0
   349
@SYMREQ                 REQ0000
sl@0
   350
*/
sl@0
   351
LOCAL_C void generalTestsL()
sl@0
   352
	{
sl@0
   353
	// set things up...
sl@0
   354
	TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive()));	
sl@0
   355
	TParse dicFilePath;
sl@0
   356
	dicFilePath.Set(drive.Name(), &KDicFilePath, NULL);
sl@0
   357
	
sl@0
   358
	TInt ret = TheFs.MkDirAll(dicFilePath.FullName());
sl@0
   359
	test((ret==KErrNone)||(ret==KErrAlreadyExists));
sl@0
   360
	TheFs.Delete(dicFilePath.FullName()); // delete the file if it already exists
sl@0
   361
	//
sl@0
   362
	//
sl@0
   363
	test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1187 Create a new file and put an entry in it "));
sl@0
   364
	// create a new dictionary file
sl@0
   365
	CDictionaryFileStore* dicFile=NULL;
sl@0
   366
	TRAP(ret, dicFile = CDictionaryFileStore::OpenL(TheFs,dicFilePath.FullName(),dicFileUid));
sl@0
   367
	test(ret==KErrNone);
sl@0
   368
	//Check that file is NULL
sl@0
   369
	Test4L(dicFile);
sl@0
   370
	Test1L(dicFile);
sl@0
   371
	// open it and check the contents
sl@0
   372
	TRAP(ret, dicFile = CDictionaryFileStore::OpenL(TheFs,dicFilePath.FullName(),dicFileUid));
sl@0
   373
	test(ret==KErrNone);
sl@0
   374
	Test2L(dicFile);
sl@0
   375
	// open it again and check the contents
sl@0
   376
	TRAP(ret, dicFile = CDictionaryFileStore::OpenL(TheFs,dicFilePath.FullName(),dicFileUid));
sl@0
   377
	test(ret==KErrNone);
sl@0
   378
	Test3L(dicFile);
sl@0
   379
	//open it again and check that contents is not NUll
sl@0
   380
	TRAP(ret, dicFile = CDictionaryFileStore::OpenL(TheFs,dicFilePath.FullName(),dicFileUid));
sl@0
   381
	test(ret==KErrNone);
sl@0
   382
	Test5L(dicFile);
sl@0
   383
	
sl@0
   384
	}
sl@0
   385
sl@0
   386
/**
sl@0
   387
@SYMTestCaseID          SYSLIB-STORE-CT-1188
sl@0
   388
@SYMTestCaseDesc	    Creation of empty files test
sl@0
   389
@SYMTestPriority 	    High
sl@0
   390
@SYMTestActions  	    Tests by opening empty dictionary file and interrogate it.
sl@0
   391
                        Tests for opening a stream that does not exist.Tests for reading from the empty file
sl@0
   392
@SYMTestExpectedResults Test must not fail
sl@0
   393
@SYMREQ                 REQ0000
sl@0
   394
*/
sl@0
   395
LOCAL_C void emptyFileTestsL()
sl@0
   396
	{
sl@0
   397
	// set things up...
sl@0
   398
	TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive()));	
sl@0
   399
	TParse dicFilePath;
sl@0
   400
	dicFilePath.Set(drive.Name(), &KDicFilePath, NULL);
sl@0
   401
	
sl@0
   402
	TInt ret = TheFs.MkDirAll(dicFilePath.DriveAndPath());
sl@0
   403
		test((ret==KErrNone)||(ret==KErrAlreadyExists));
sl@0
   404
	TheFs.Delete(dicFilePath.FullName()); // delete the file if it already exists
sl@0
   405
	//
sl@0
   406
	//
sl@0
   407
	test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1188 Create a new file, close it while still empty, then open it again "));
sl@0
   408
	// create a new dictionary file and close it immediately
sl@0
   409
	CDictionaryFileStore* dicFile=NULL;
sl@0
   410
	TRAP(ret, dicFile = CDictionaryFileStore::OpenL(TheFs,dicFilePath.FullName(),dicFileUid));
sl@0
   411
		test(ret==KErrNone);
sl@0
   412
	TRAP(ret, dicFile->CommitL());
sl@0
   413
		test(ret==KErrNone);
sl@0
   414
	delete dicFile;
sl@0
   415
	dicFile = NULL;
sl@0
   416
	//
sl@0
   417
	// open the empty dic file and interogate it
sl@0
   418
	TRAP(ret, dicFile = CDictionaryFileStore::OpenL(TheFs,dicFilePath.FullName(),dicFileUid));
sl@0
   419
		test(ret==KErrNone);
sl@0
   420
	test(!dicFile->IsPresentL(testUid1));
sl@0
   421
	test(!dicFile->IsPresentL(testUid2));
sl@0
   422
	test(!dicFile->IsPresentL(testUid3));
sl@0
   423
	//
sl@0
   424
	//
sl@0
   425
	test.Next(_L("Open a stream that doesn't exist"));
sl@0
   426
	// open a stream that does not exist - should get an empty one
sl@0
   427
	RDictionaryReadStream readStream;
sl@0
   428
	TRAP(ret, readStream.OpenL(*dicFile,testUid1));
sl@0
   429
		test(ret==KErrNone);
sl@0
   430
	// try to read from it to check that it's empty
sl@0
   431
	TUint8 b;
sl@0
   432
	test(readStream.Source()->ReadL(&b,1)==0);
sl@0
   433
	readStream.Close();
sl@0
   434
	//
sl@0
   435
	//
sl@0
   436
	// tidy up
sl@0
   437
	delete dicFile;
sl@0
   438
	
sl@0
   439
	}
sl@0
   440
sl@0
   441
/**
sl@0
   442
@SYMTestCaseID          SYSLIB-STORE-CT-1189
sl@0
   443
@SYMTestCaseDesc	    Repeatedly opening a dictionary file test
sl@0
   444
@SYMTestPriority 	    High
sl@0
   445
@SYMTestActions  	    Attempt for creating a new dictionary file,write an entry an commit it.
sl@0
   446
                        Attempt for repeatedly opening the dictionary file,interogate it,and delete it without commiting
sl@0
   447
                        Attempt for repeatedly opening the dictionary file and interogate it,commit the file after each read
sl@0
   448
						Attempt for repeatedly opening the dictionary file and re-write a stream, commiting the file after each write
sl@0
   449
@SYMTestExpectedResults Test must not fail
sl@0
   450
@SYMREQ                 REQ0000
sl@0
   451
*/
sl@0
   452
LOCAL_C void repeatedUseTestsL()
sl@0
   453
	{
sl@0
   454
	// set things up...
sl@0
   455
	test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1189 "));
sl@0
   456
sl@0
   457
	TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive()));	
sl@0
   458
	TParse dicFilePath;
sl@0
   459
	dicFilePath.Set(drive.Name(), &KDicFilePath, NULL);
sl@0
   460
	
sl@0
   461
	TInt ret = TheFs.MkDirAll(dicFilePath.DriveAndPath());
sl@0
   462
		test((ret==KErrNone)||(ret==KErrAlreadyExists));
sl@0
   463
	TheFs.Delete(dicFilePath.FullName()); // delete the file if it already exists
sl@0
   464
	//
sl@0
   465
	// create a new dictionary file
sl@0
   466
	CDictionaryFileStore* dicFile=NULL;
sl@0
   467
	TRAP(ret, dicFile = CDictionaryFileStore::OpenL(TheFs,dicFilePath.FullName(),dicFileUid));
sl@0
   468
		test(ret==KErrNone);
sl@0
   469
	// write an entry and commit it
sl@0
   470
	RDictionaryWriteStream writeStream;
sl@0
   471
	TRAP(ret, writeStream.AssignL(*dicFile,testUid1));
sl@0
   472
		test(ret==KErrNone);
sl@0
   473
	TRAP(ret, writeStream.WriteInt32L(value1));
sl@0
   474
		test(ret==KErrNone);
sl@0
   475
	TRAP(ret, writeStream.CommitL());
sl@0
   476
		test(ret==KErrNone);
sl@0
   477
	writeStream.Close();
sl@0
   478
	// close the file
sl@0
   479
	TRAP(ret, dicFile->CommitL());
sl@0
   480
		test(ret==KErrNone);
sl@0
   481
	delete dicFile;
sl@0
   482
	dicFile = NULL;
sl@0
   483
	//
sl@0
   484
	//
sl@0
   485
	test.Next(_L("Repeatedly open a file and interogate it without commiting"));
sl@0
   486
	// repeatedly open the dic file, interogate it, and delete it without commiting
sl@0
   487
	TEntry fileEntry;
sl@0
   488
	ret = TheFs.Entry(dicFilePath.FullName(),fileEntry);
sl@0
   489
		test(ret==KErrNone);
sl@0
   490
	TInt sizeBefore=fileEntry.iSize;
sl@0
   491
	//
sl@0
   492
	TInt i;
sl@0
   493
	for (i=0 ; i<10 ; i++)
sl@0
   494
		{
sl@0
   495
		TRAP(ret, dicFile = CDictionaryFileStore::OpenL(TheFs,dicFilePath.FullName(),dicFileUid));
sl@0
   496
			test(ret==KErrNone);
sl@0
   497
		RDictionaryReadStream readStream;
sl@0
   498
		TRAP(ret, readStream.OpenL(*dicFile,testUid1));
sl@0
   499
			test(ret==KErrNone);
sl@0
   500
		readStream.Close();
sl@0
   501
		delete dicFile;
sl@0
   502
		dicFile = NULL;
sl@0
   503
		}
sl@0
   504
	//
sl@0
   505
	ret = TheFs.Entry(dicFilePath.FullName(),fileEntry);
sl@0
   506
		test(ret==KErrNone);
sl@0
   507
	TInt sizeAfter=fileEntry.iSize;
sl@0
   508
		test(sizeAfter==sizeBefore);
sl@0
   509
	//
sl@0
   510
	//
sl@0
   511
	test.Next(_L("Repeatedly open a file, commiting after each read"));
sl@0
   512
	// repeatedly open the dic file and interogate it, commiting the file after each read
sl@0
   513
	ret = TheFs.Entry(dicFilePath.FullName(),fileEntry);
sl@0
   514
		test(ret==KErrNone);
sl@0
   515
	sizeBefore=fileEntry.iSize;
sl@0
   516
	//
sl@0
   517
	for (i=0 ; i<10 ; i++)
sl@0
   518
		{
sl@0
   519
		TRAP(ret, dicFile = CDictionaryFileStore::OpenL(TheFs,dicFilePath.FullName(),dicFileUid));
sl@0
   520
			test(ret==KErrNone);
sl@0
   521
		RDictionaryReadStream readStream;
sl@0
   522
		TRAP(ret, readStream.OpenL(*dicFile,testUid1));
sl@0
   523
			test(ret==KErrNone);
sl@0
   524
		readStream.Close();
sl@0
   525
		TRAP(ret, dicFile->CommitL());
sl@0
   526
			test(ret==KErrNone);
sl@0
   527
		delete dicFile;
sl@0
   528
		dicFile = NULL;
sl@0
   529
		}
sl@0
   530
	//
sl@0
   531
	ret = TheFs.Entry(dicFilePath.FullName(),fileEntry);
sl@0
   532
		test(ret==KErrNone);
sl@0
   533
	sizeAfter=fileEntry.iSize;
sl@0
   534
		test(sizeAfter==sizeBefore);
sl@0
   535
	//
sl@0
   536
	//
sl@0
   537
	test.Next(_L("Repeatedly open a file and re-write a stream"));
sl@0
   538
	// repeatedly open the dic file and re-write a stream, commiting the file after each write
sl@0
   539
	ret = TheFs.Entry(dicFilePath.FullName(),fileEntry);
sl@0
   540
		test(ret==KErrNone);
sl@0
   541
	sizeBefore=fileEntry.iSize;
sl@0
   542
	//
sl@0
   543
	for (i=0 ; i<10 ; i++)
sl@0
   544
		{
sl@0
   545
		TRAP(ret, dicFile = CDictionaryFileStore::OpenL(TheFs,dicFilePath.FullName(),dicFileUid));
sl@0
   546
			test(ret==KErrNone);
sl@0
   547
		// write an entry and commit it
sl@0
   548
		RDictionaryWriteStream writeStream;
sl@0
   549
		TRAP(ret, writeStream.AssignL(*dicFile,testUid1));
sl@0
   550
			test(ret==KErrNone);
sl@0
   551
		TRAP(ret, writeStream.WriteInt32L(i));
sl@0
   552
			test(ret==KErrNone);
sl@0
   553
		TRAP(ret, writeStream.CommitL());
sl@0
   554
			test(ret==KErrNone);
sl@0
   555
		writeStream.Close();
sl@0
   556
		// close the file
sl@0
   557
		TRAP(ret, dicFile->CommitL());
sl@0
   558
			test(ret==KErrNone);
sl@0
   559
		delete dicFile;
sl@0
   560
		dicFile = NULL;
sl@0
   561
		}
sl@0
   562
	//
sl@0
   563
	ret = TheFs.Entry(dicFilePath.FullName(),fileEntry);
sl@0
   564
		test(ret==KErrNone);
sl@0
   565
	sizeAfter=fileEntry.iSize;
sl@0
   566
		test.Printf(_L("  Size before: %d\n  Size after:  %d\n"),sizeBefore,sizeAfter);
sl@0
   567
	//
sl@0
   568
	//
sl@0
   569
	// tidy up
sl@0
   570
	}
sl@0
   571
sl@0
   572
LOCAL_C void AddEntryL()
sl@0
   573
	{
sl@0
   574
	TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive()));	
sl@0
   575
	TParse dicFilePath;
sl@0
   576
	dicFilePath.Set(drive.Name(), &KDicFilePath, NULL);
sl@0
   577
	
sl@0
   578
	CDictionaryStore* dictionary=CDictionaryFileStore::OpenLC(TheFs,dicFilePath.FullName(),dicFileUid);
sl@0
   579
	RDictionaryWriteStream s;
sl@0
   580
	s.AssignLC(*dictionary,testUid4);
sl@0
   581
	s.WriteInt32L(value1);
sl@0
   582
	s.CommitL();
sl@0
   583
	CleanupStack::PopAndDestroy();	// s
sl@0
   584
   	TInt err = dictionary->Commit(); // changed from CommitL to ensure api coverage
sl@0
   585
	User::LeaveIfError(err);
sl@0
   586
	CleanupStack::PopAndDestroy();	// dictionary
sl@0
   587
	}
sl@0
   588
sl@0
   589
LOCAL_C TBool CheckEntryL()
sl@0
   590
	{
sl@0
   591
	TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive()));	
sl@0
   592
	TParse dicFilePath;
sl@0
   593
	dicFilePath.Set(drive.Name(), &KDicFilePath, NULL);
sl@0
   594
	
sl@0
   595
	CDictionaryStore* dictionary=CDictionaryFileStore::OpenLC(TheFs,dicFilePath.FullName(),dicFileUid);
sl@0
   596
	TBool isPresent=dictionary->IsPresentL(testUid4);
sl@0
   597
	if (isPresent)
sl@0
   598
		{
sl@0
   599
		RDictionaryReadStream s;
sl@0
   600
		s.OpenLC(*dictionary,testUid4);
sl@0
   601
		test (s.ReadInt32L()==value1);
sl@0
   602
		CleanupStack::PopAndDestroy();	// s
sl@0
   603
		}
sl@0
   604
	CleanupStack::PopAndDestroy();	// dictionary
sl@0
   605
	return isPresent;
sl@0
   606
	}
sl@0
   607
sl@0
   608
/**
sl@0
   609
Test CDictionaryFileStore construction, forcing a leave error at each
sl@0
   610
possible stage of the process.
sl@0
   611
sl@0
   612
@SYMTestCaseID          SYSLIB-STORE-CT-1190
sl@0
   613
@SYMTestCaseDesc	    Tests for CDictionaryFileStore construction under low memory conditions.
sl@0
   614
@SYMTestPriority 	    High
sl@0
   615
@SYMTestActions  	    Attempt for construction under low memory conditions.
sl@0
   616
@SYMTestExpectedResults Test must not fail
sl@0
   617
@SYMREQ                 REQ0000
sl@0
   618
*/
sl@0
   619
LOCAL_C void TestOOML()
sl@0
   620
	{
sl@0
   621
	test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1190 Construction under low memory conditions "));
sl@0
   622
sl@0
   623
	TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive()));	
sl@0
   624
	TParse dicFilePath;
sl@0
   625
	dicFilePath.Set(drive.Name(), &KDicFilePath, NULL);
sl@0
   626
	
sl@0
   627
	TheFs.Delete(dicFilePath.FullName()); // delete the file
sl@0
   628
	TInt failRate=0;
sl@0
   629
sl@0
   630
	for (failRate=1;;failRate++)
sl@0
   631
		{
sl@0
   632
		__UHEAP_SETFAIL(RHeap::EDeterministic,failRate);
sl@0
   633
		__UHEAP_MARK;
sl@0
   634
		TRAPD(ret, AddEntryL());
sl@0
   635
		__UHEAP_MARKEND;
sl@0
   636
		if (ret==KErrNone)
sl@0
   637
			break;
sl@0
   638
		test (ret==KErrNoMemory);
sl@0
   639
		__UHEAP_RESET;
sl@0
   640
		test (!CheckEntryL());
sl@0
   641
		}
sl@0
   642
	__UHEAP_RESET;
sl@0
   643
	test (CheckEntryL());
sl@0
   644
	test.Printf(_L("  #allocs for update: %d\n"),failRate-1);
sl@0
   645
	//
sl@0
   646
	// tidy up
sl@0
   647
	}
sl@0
   648
sl@0
   649
sl@0
   650
// Thread contention tests
sl@0
   651
sl@0
   652
sl@0
   653
class TIniData
sl@0
   654
	{
sl@0
   655
public:
sl@0
   656
	void LoadL(CDictionaryStore& aStore);
sl@0
   657
	void SaveL(CDictionaryStore& aStore) const;
sl@0
   658
	TStreamId StoreL(CStreamStore& aStore) const;
sl@0
   659
	void RestoreL(CStreamStore& aStore,TStreamId anId);
sl@0
   660
	void InternalizeL(RReadStream& aStream);
sl@0
   661
	void ExternalizeL(RWriteStream& aStream) const;
sl@0
   662
	};
sl@0
   663
sl@0
   664
void TIniData::LoadL(CDictionaryStore& aStore)
sl@0
   665
	{
sl@0
   666
	if (aStore.IsPresentL(KTestUid))
sl@0
   667
		{
sl@0
   668
		RDictionaryReadStream stream;
sl@0
   669
		stream.OpenL(aStore,KTestUid);
sl@0
   670
		CEmbeddedStore* store=CEmbeddedStore::FromLC(stream);
sl@0
   671
		RestoreL(*store,store->Root());
sl@0
   672
		CleanupStack::PopAndDestroy();
sl@0
   673
		}
sl@0
   674
	}
sl@0
   675
sl@0
   676
void TIniData::SaveL(CDictionaryStore& aStore) const
sl@0
   677
	{
sl@0
   678
	RDictionaryWriteStream stream;
sl@0
   679
	stream.AssignL(aStore,KTestUid);
sl@0
   680
	CEmbeddedStore* store=CEmbeddedStore::NewLC(stream);
sl@0
   681
	store->SetRootL(StoreL(*store));
sl@0
   682
	store->CommitL();
sl@0
   683
	CleanupStack::PopAndDestroy();
sl@0
   684
	}
sl@0
   685
sl@0
   686
void TIniData::RestoreL(CStreamStore& aStore,TStreamId anId)
sl@0
   687
	{
sl@0
   688
	RStoreReadStream stream;
sl@0
   689
	stream.OpenLC(aStore,anId);
sl@0
   690
	TStreamId id1,id2;
sl@0
   691
	stream >> id1 >> id2;
sl@0
   692
	CleanupStack::PopAndDestroy();
sl@0
   693
	stream.OpenLC(aStore,id1);
sl@0
   694
	stream >> *this;
sl@0
   695
	CleanupStack::PopAndDestroy();
sl@0
   696
	{
sl@0
   697
	TReal x=0.501;
sl@0
   698
	for (TInt ii=0;ii<200;++ii)
sl@0
   699
		x=4.0*x*(1.0-x);
sl@0
   700
	}
sl@0
   701
	stream.OpenLC(aStore,id2);
sl@0
   702
	stream >> *this;
sl@0
   703
	CleanupStack::PopAndDestroy();
sl@0
   704
	}
sl@0
   705
sl@0
   706
TStreamId TIniData::StoreL(CStreamStore& aStore) const
sl@0
   707
	{
sl@0
   708
	RStoreWriteStream stream;
sl@0
   709
	TStreamId id2=stream.CreateLC(aStore);
sl@0
   710
	stream << *this;
sl@0
   711
	stream.CommitL();
sl@0
   712
	CleanupStack::PopAndDestroy();
sl@0
   713
	TStreamId id1=stream.CreateLC(aStore);
sl@0
   714
	stream << *this;
sl@0
   715
	stream.CommitL();
sl@0
   716
	CleanupStack::PopAndDestroy();
sl@0
   717
	TStreamId id3=stream.CreateLC(aStore);
sl@0
   718
	stream << id1 << id2;
sl@0
   719
	stream.CommitL();
sl@0
   720
	CleanupStack::PopAndDestroy();
sl@0
   721
	return id3;
sl@0
   722
	}
sl@0
   723
sl@0
   724
void TIniData::InternalizeL(RReadStream& aStream)
sl@0
   725
	{
sl@0
   726
	for (TInt ii=0;ii<150;++ii)
sl@0
   727
		aStream.ReadUint32L();
sl@0
   728
	}
sl@0
   729
sl@0
   730
void TIniData::ExternalizeL(RWriteStream& aStream) const
sl@0
   731
	{
sl@0
   732
	for (TInt ii=0;ii<150;++ii)
sl@0
   733
		aStream.WriteUint32L(0);
sl@0
   734
	}
sl@0
   735
sl@0
   736
//
sl@0
   737
sl@0
   738
void ThreadTestL(TInt aThread)
sl@0
   739
	{
sl@0
   740
	RFs fs;
sl@0
   741
	User::LeaveIfError(fs.Connect());
sl@0
   742
	CleanupClosePushL(fs);
sl@0
   743
sl@0
   744
	TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive()));	
sl@0
   745
	TParse testIniFile;
sl@0
   746
	testIniFile.Set(drive.Name(), &KTestIniFile, NULL);
sl@0
   747
	
sl@0
   748
	TIniData data;
sl@0
   749
	CDictionaryStore* dict=CDictionaryFileStore::OpenLC(fs,testIniFile.FullName(),KTestUid);
sl@0
   750
	data.LoadL(*dict);
sl@0
   751
	CleanupStack::PopAndDestroy(); // dict
sl@0
   752
sl@0
   753
	TParse threadTestPath;
sl@0
   754
	threadTestPath.Set(drive.Name(), &KThreadTestPath, NULL);
sl@0
   755
	
sl@0
   756
	TFileName name;
sl@0
   757
	name.Format(threadTestPath.FullName(),aThread);
sl@0
   758
	dict=CDictionaryFileStore::OpenLC(fs,name,KTestUid);
sl@0
   759
	data.SaveL(*dict);
sl@0
   760
	dict->CommitL();
sl@0
   761
	CleanupStack::PopAndDestroy();
sl@0
   762
	TReal x=0.501;
sl@0
   763
	for (TInt ii=0;ii<1000;++ii)
sl@0
   764
		x=4.0*x*(1.0-x);
sl@0
   765
	dict=CDictionaryFileStore::OpenLC(fs,name,KTestUid);
sl@0
   766
	data.LoadL(*dict);
sl@0
   767
	CleanupStack::PopAndDestroy();	// dict
sl@0
   768
	fs.Delete(name);
sl@0
   769
	CleanupStack::PopAndDestroy();	// fs
sl@0
   770
	}
sl@0
   771
sl@0
   772
TInt ThreadTest(TAny* aPtr)
sl@0
   773
	{
sl@0
   774
	CTrapCleanup* cleanup=CTrapCleanup::New();
sl@0
   775
	if (!cleanup)
sl@0
   776
		return KErrNoMemory;
sl@0
   777
	TRAPD(error,ThreadTestL(TInt(aPtr)));
sl@0
   778
	delete cleanup;
sl@0
   779
	return error;
sl@0
   780
	}
sl@0
   781
sl@0
   782
/**
sl@0
   783
@SYMTestCaseID          SYSLIB-STORE-CT-1191
sl@0
   784
@SYMTestCaseDesc	    Lock out of dictionary files test
sl@0
   785
@SYMTestPriority 	    High
sl@0
   786
@SYMTestActions  	    Attempt for opening of same dictionary file.Tests for file in use error
sl@0
   787
@SYMTestExpectedResults Test must not fail
sl@0
   788
@SYMREQ                 REQ0000
sl@0
   789
*/
sl@0
   790
void ContentionTestL()
sl@0
   791
	{
sl@0
   792
	test.Start(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1191 Contention tests "));
sl@0
   793
	
sl@0
   794
	TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive()));	
sl@0
   795
	TParse testIniFile;
sl@0
   796
	testIniFile.Set(drive.Name(), &KTestIniFile, NULL);
sl@0
   797
	
sl@0
   798
	CDictionaryStore* dict=CDictionaryFileStore::OpenLC(TheFs,testIniFile.FullName(),KTestUid);
sl@0
   799
	TIniData data;
sl@0
   800
	data.SaveL(*dict);
sl@0
   801
	CleanupStack::PopAndDestroy(); // dict
sl@0
   802
sl@0
   803
	test.Next(_L("Lock-out test"));
sl@0
   804
	CDictionaryFileStore::OpenLC(TheFs,testIniFile.FullName(),KTestUid);
sl@0
   805
	TUint tick=User::TickCount();
sl@0
   806
	TRAPD(r,CDictionaryFileStore::OpenL(TheFs,testIniFile.FullName(),KTestUid));
sl@0
   807
	tick=User::TickCount()-tick;
sl@0
   808
	test (r==KErrInUse);
sl@0
   809
	test.Printf(_L("Lock-out discovered: %d ticks\r\n"),tick);
sl@0
   810
	CleanupStack::PopAndDestroy();
sl@0
   811
sl@0
   812
	test.Next(_L("Creating threads"));
sl@0
   813
	RThread threads[KNumThreads];
sl@0
   814
	TRequestStatus status[KNumThreads];
sl@0
   815
	TInt ii;
sl@0
   816
	for (ii=0;ii<KNumThreads;++ii)
sl@0
   817
		{
sl@0
   818
		TName name;
sl@0
   819
		name.Format(_L("Test_%d"),ii);
sl@0
   820
		test (threads[ii].Create(name,ThreadTest,KThreadStack,KThreadHeap,KThreadHeapMax,(TAny*)ii,EOwnerThread)==KErrNone);
sl@0
   821
		threads[ii].SetPriority(EPriorityLess);
sl@0
   822
		threads[ii].Logon(status[ii]);
sl@0
   823
		test (status[ii]==KRequestPending);
sl@0
   824
		}
sl@0
   825
sl@0
   826
	for (ii=0;ii<KNumThreads;++ii)
sl@0
   827
		threads[ii].Resume();
sl@0
   828
sl@0
   829
	test.Next(_L("Waiting for completion"));
sl@0
   830
	for (ii=0;ii<KNumThreads;++ii)
sl@0
   831
		User::WaitForAnyRequest();
sl@0
   832
	TInt success=0;
sl@0
   833
	for (ii=0;ii<KNumThreads;++ii)
sl@0
   834
		{
sl@0
   835
		test (status[ii]!=KRequestPending);
sl@0
   836
		if (status[ii].Int()==KErrNone)
sl@0
   837
			++success;
sl@0
   838
		}
sl@0
   839
	test.Printf(_L("Thread success: %d of %d\r\n"),success,KNumThreads);
sl@0
   840
	test.End();
sl@0
   841
	}
sl@0
   842
//
sl@0
   843
sl@0
   844
//
sl@0
   845
// Initialise the cleanup stack.
sl@0
   846
//
sl@0
   847
LOCAL_C void setupCleanup()
sl@0
   848
    {
sl@0
   849
	TheTrapCleanup=CTrapCleanup::New();
sl@0
   850
	TRAPD(r,\
sl@0
   851
		{\
sl@0
   852
		for (TInt i=KTestCleanupStack;i>0;i--)\
sl@0
   853
			CleanupStack::PushL((TAny*)1);\
sl@0
   854
		test(r==KErrNone);\
sl@0
   855
		CleanupStack::Pop(KTestCleanupStack);\
sl@0
   856
		});
sl@0
   857
	}
sl@0
   858
sl@0
   859
GLDEF_C TInt E32Main()
sl@0
   860
	{
sl@0
   861
	setupCleanup();
sl@0
   862
	//
sl@0
   863
	test.Title();
sl@0
   864
	test.Start(_L("Testing CDictionaryFileStore et al..."));
sl@0
   865
	test (TheFs.Connect()==KErrNone);
sl@0
   866
	//
sl@0
   867
	// run the testcode (inside an alloc heaven harness)
sl@0
   868
	__UHEAP_MARK;
sl@0
   869
sl@0
   870
	TRAPD(r,systemTestL());
sl@0
   871
	test(r==KErrNone);
sl@0
   872
sl@0
   873
	TRAP(r,generalTestsL());
sl@0
   874
	test(r==KErrNone);
sl@0
   875
sl@0
   876
	TRAP(r,emptyFileTestsL());
sl@0
   877
	test(r==KErrNone);
sl@0
   878
sl@0
   879
	TRAP(r,repeatedUseTestsL());
sl@0
   880
	test(r==KErrNone);
sl@0
   881
sl@0
   882
	TRAP(r,TestOOML());
sl@0
   883
	test(r==KErrNone);
sl@0
   884
sl@0
   885
	TRAP(r,ContentionTestL());
sl@0
   886
	test(r==KErrNone);
sl@0
   887
	
sl@0
   888
	__UHEAP_MARKEND;
sl@0
   889
sl@0
   890
	TheFs.Close();
sl@0
   891
 	test.End();
sl@0
   892
	test.Close();
sl@0
   893
sl@0
   894
	delete TheTrapCleanup;
sl@0
   895
	return KErrNone;
sl@0
   896
	}
sl@0
   897
sl@0
   898
sl@0
   899