1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/lowlevellibsandfws/apputils/bsul/test/t_iniparser/T_IniParser8.CPP Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,971 @@
1.4 +// Copyright (c) 2005-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 +// @internalComponent
1.18 +//
1.19 +//
1.20 +
1.21 +#include <e32std.h>
1.22 +#include <e32base.h>
1.23 +#include <e32test.h>
1.24 +#include <f32file.h>
1.25 +#include <bsul/inifile.h> // CIniDocument8, CIniDocument16
1.26 +
1.27 +RTest test(_L("Ini File Parser and Generator"));
1.28 +
1.29 +RFs TheRFs;
1.30 +
1.31 +using namespace BSUL;
1.32 +#define UNUSED_VAR(a) a=a
1.33 +
1.34 +_LIT(KIniFile8,"z:\\resource\\testconfig8.ini") ;
1.35 +
1.36 +void LeaveIfNoMemory(TInt ret)
1.37 + {
1.38 + if (ret==KErrNoMemory)
1.39 + User::LeaveNoMemory();
1.40 + }
1.41 +
1.42 +void CheckResources(RFs& aFs, TInt aOriginalHandleCount)
1.43 + {
1.44 + UNUSED_VAR(aOriginalHandleCount);
1.45 + //check we haven't leaked any handles
1.46 + TInt processHandleCount = 0;
1.47 + TInt threadHandleCount = 0;
1.48 + RThread().HandleCount(processHandleCount, threadHandleCount);
1.49 + test(threadHandleCount == aOriginalHandleCount);
1.50 + //check we haven't leaked any files
1.51 + aFs.ResourceCountMarkEnd();
1.52 + }
1.53 +
1.54 +TBool CompareFilesL(RFs& aFs,const TDesC& aFileNameA,const TDesC& aFileNameB)
1.55 + {
1.56 + TBool filesAreSame=FALSE;
1.57 + //open the file for reading
1.58 + RFile fileA;
1.59 + User::LeaveIfError(fileA.Open(aFs,aFileNameA,EFileShareReadersOrWriters ));
1.60 + CleanupClosePushL(fileA);
1.61 + RFile fileB;
1.62 + User::LeaveIfError(fileB.Open(aFs,aFileNameB,EFileShareReadersOrWriters ));
1.63 + CleanupClosePushL(fileB);
1.64 +
1.65 + //only process the file if it exists
1.66 + TInt filesizeA=0;
1.67 + TInt filesizeB=0;
1.68 + fileA.Size(filesizeA);
1.69 + fileB.Size(filesizeB);
1.70 + if (filesizeA == filesizeB)
1.71 + {
1.72 + HBufC8* aBufferPtrA=HBufC8::NewLC(filesizeA);
1.73 + HBufC8* aBufferPtrB=HBufC8::NewLC(filesizeB);
1.74 + TPtr8 asWriteableBufferA(aBufferPtrA->Des());
1.75 + User::LeaveIfError(fileA.Read(0,asWriteableBufferA,filesizeA));
1.76 + TPtr8 asWriteableBufferB(aBufferPtrB->Des());
1.77 + User::LeaveIfError(fileB.Read(0,asWriteableBufferB,filesizeB));
1.78 + if (asWriteableBufferA.Compare(asWriteableBufferB) == 0)
1.79 + {
1.80 + filesAreSame=TRUE;
1.81 + }
1.82 + //pop the buffers
1.83 + CleanupStack::PopAndDestroy(2);
1.84 + }
1.85 + //close the files
1.86 + CleanupStack::PopAndDestroy(2);
1.87 + return filesAreSame;
1.88 + }
1.89 +
1.90 +class CIniParser8Test :public CBase
1.91 +{
1.92 +typedef void (CIniParser8Test::*ClassFuncPtr8L) (void);
1.93 +
1.94 +public:
1.95 + static CIniParser8Test* NewL();
1.96 + ~CIniParser8Test()
1.97 + {
1.98 + if (iIniDocument)
1.99 + {
1.100 + delete iIniDocument;
1.101 + iIniDocument=NULL;
1.102 + }
1.103 + }
1.104 +
1.105 + //simple create and delete
1.106 + //heavy
1.107 + static void CreateDeleteTest1L();
1.108 + static void CreateDeleteOOMTestL();
1.109 + //light
1.110 + static void CreateDeleteTest2L();
1.111 + static void CreateDeleteOOMTest2L();
1.112 +
1.113 + //List of tests
1.114 + //heavy weight
1.115 + void DoTest1L();
1.116 + void DoTest2L();
1.117 + void DoTest3L();
1.118 + void DoTest4L();
1.119 + void DoTest5L();
1.120 + void DoTest6L();
1.121 + void DoTest7L();
1.122 + void DoTest8L();
1.123 + void DoTest9L();
1.124 + //light weight
1.125 + void DoTest10L();
1.126 +
1.127 + //Consistency check
1.128 + void DoTest11L();
1.129 +
1.130 + //Defect 127618
1.131 + void DoTest12L();
1.132 +
1.133 + //class function utilities
1.134 + static void DoBasicTestL(ClassFuncPtr8L testFuncL, const TDesC& aTestDesc);
1.135 + static void DoOOMTestL(ClassFuncPtr8L testFuncL, const TDesC& aTestDesc);
1.136 + static void DoOOMWithConsistencyCheckTestL(ClassFuncPtr8L testFuncL, const TDesC& aTestDesc, const TBool aShouldBeDifferent);
1.137 +
1.138 +private:
1.139 + CIniParser8Test():iIniDocument(NULL){}
1.140 + CIniDocument8* iIniDocument;
1.141 +};
1.142 +
1.143 +CIniParser8Test* CIniParser8Test::NewL()
1.144 + {
1.145 + CIniParser8Test* self=new (ELeave)CIniParser8Test();
1.146 + CleanupStack::PushL(self);
1.147 + self->iIniDocument=CIniDocument8::NewL(TheRFs,KIniFile8);
1.148 + CleanupStack::Pop();
1.149 + return self;
1.150 + }
1.151 +
1.152 +void CIniParser8Test::DoBasicTestL(ClassFuncPtr8L testFuncL, const TDesC& aTestDesc)
1.153 + {
1.154 + test.Next(aTestDesc);
1.155 +
1.156 + __UHEAP_MARK;
1.157 + // find out the number of open handles
1.158 + TInt startProcessHandleCount;
1.159 + TInt startThreadHandleCount;
1.160 + RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
1.161 +
1.162 + CIniParser8Test* iniTest=CIniParser8Test::NewL();
1.163 +
1.164 + CleanupStack::PushL(iniTest);
1.165 +
1.166 + (iniTest->*testFuncL)();
1.167 +
1.168 + CleanupStack::PopAndDestroy();
1.169 +
1.170 + // check that no handles have leaked
1.171 + TInt endProcessHandleCount;
1.172 + TInt endThreadHandleCount;
1.173 + RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
1.174 +
1.175 + test(startProcessHandleCount == endProcessHandleCount);
1.176 + test(startThreadHandleCount == endThreadHandleCount);
1.177 +
1.178 + __UHEAP_MARKEND;
1.179 + }
1.180 +
1.181 +void CIniParser8Test::DoOOMTestL(ClassFuncPtr8L testFuncL, const TDesC& aTestDesc)
1.182 + {
1.183 + test.Next(aTestDesc);
1.184 +
1.185 + TInt err;
1.186 + TInt tryCount = 0;
1.187 + do
1.188 + {
1.189 + __UHEAP_MARK;
1.190 + // find out the number of open handles
1.191 + TInt startProcessHandleCount;
1.192 + TInt startThreadHandleCount;
1.193 + RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
1.194 +
1.195 + CIniParser8Test* iniTest=CIniParser8Test::NewL();
1.196 + CleanupStack::PushL(iniTest);
1.197 +
1.198 + __UHEAP_SETFAIL(RHeap::EDeterministic, ++tryCount);
1.199 + TRAP(err, (iniTest->*testFuncL)());
1.200 + __UHEAP_SETFAIL(RHeap::ENone, 0);
1.201 +
1.202 + CleanupStack::PopAndDestroy(iniTest);
1.203 + iniTest=NULL;
1.204 + // check that no handles have leaked
1.205 + TInt endProcessHandleCount;
1.206 + TInt endThreadHandleCount;
1.207 + RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
1.208 +
1.209 + test(startProcessHandleCount == endProcessHandleCount);
1.210 + test(startThreadHandleCount == endThreadHandleCount);
1.211 +
1.212 + __UHEAP_MARKEND;
1.213 + } while(err == KErrNoMemory);
1.214 +
1.215 + test(err==KErrNone);
1.216 + test.Printf(_L("- succeeded at heap failure rate of %i\n"), tryCount);
1.217 + }
1.218 +
1.219 +void CIniParser8Test::DoOOMWithConsistencyCheckTestL(ClassFuncPtr8L testFuncL, const TDesC& aTestDesc, const TBool aShouldBeSame)
1.220 + {
1.221 + test.Next(aTestDesc);
1.222 +
1.223 + // find out the number of open handles
1.224 + TInt startProcessHandleCount = 0;
1.225 + TInt startThreadHandleCount = 0;
1.226 + RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
1.227 +
1.228 + //Compare the results against this instance.
1.229 + TInt err;
1.230 + CIniDocument8* referenceDoc=NULL;
1.231 + TRAP(err,referenceDoc=CIniDocument8::NewL(TheRFs,KIniFile8));
1.232 + User::LeaveIfError(err);
1.233 + CleanupStack::PushL(referenceDoc);
1.234 +
1.235 + //Open a file and Externalise the reference oom to it.
1.236 + User::LeaveIfError(referenceDoc->Externalise(_L("c:\\initest\\oom_ref.ini")));
1.237 + CIniParser8Test* iniTest=NULL;
1.238 +
1.239 + for (TInt i = 1;;i++)
1.240 + {
1.241 + __UHEAP_MARK;
1.242 + __UHEAP_FAILNEXT(i);
1.243 +
1.244 + TRAP(err, iniTest=CIniParser8Test::NewL());
1.245 + if (err != KErrNone)
1.246 + continue;
1.247 +
1.248 + CleanupStack::PushL(iniTest);
1.249 +
1.250 + TRAP(err, (iniTest->*testFuncL)());
1.251 + if (err != KErrNone)
1.252 + {
1.253 + test(iniTest->iIniDocument->CompareDocs(*referenceDoc));
1.254 + CleanupStack::PopAndDestroy(iniTest);
1.255 + __UHEAP_SETFAIL(RHeap::ENone, 0);
1.256 + __UHEAP_MARKEND;
1.257 + continue;
1.258 + }
1.259 + else
1.260 + {
1.261 + //Open a file and Externalise to it.
1.262 + TRAP(err, iniTest->iIniDocument->Externalise(_L("c:\\initest\\oom.ini")));
1.263 + if (err != KErrNone)
1.264 + {
1.265 + CleanupStack::PopAndDestroy(iniTest);
1.266 + __UHEAP_SETFAIL(RHeap::ENone, 0);
1.267 + __UHEAP_MARKEND;
1.268 + continue;
1.269 + }
1.270 + else
1.271 + {
1.272 + TBool result=EFalse;
1.273 + TRAP(err, result=CompareFilesL(TheRFs,_L("c:\\initest\\oom_ref.ini"), _L("c:\\initest\\oom.ini")));
1.274 + if (err != KErrNone)
1.275 + {
1.276 + CleanupStack::PopAndDestroy(iniTest);
1.277 + __UHEAP_SETFAIL(RHeap::ENone, 0);
1.278 + __UHEAP_MARKEND;
1.279 + continue;
1.280 + }
1.281 + test(result == aShouldBeSame);
1.282 + }
1.283 + }
1.284 + CleanupStack::PopAndDestroy(iniTest);
1.285 + //check we haven't leaked any heap memory
1.286 + __UHEAP_MARKEND;
1.287 + CheckResources(TheRFs, startThreadHandleCount);
1.288 +
1.289 + if (err != KErrNoMemory)
1.290 + {
1.291 + test(err == KErrNone);
1.292 + break; // we reach here if we are unable to create the OOM condition.
1.293 + }
1.294 +
1.295 + __UHEAP_SETFAIL(RHeap::ENone, 0);
1.296 + }
1.297 +
1.298 + __UHEAP_RESET;
1.299 + CleanupStack::PopAndDestroy(referenceDoc);
1.300 +
1.301 + test.Printf(_L("Completed consistency check."));
1.302 + }
1.303 +
1.304 +void CIniParser8Test::CreateDeleteOOMTestL()
1.305 + {
1.306 + TInt err;
1.307 + TInt tryCount = 0;
1.308 + do
1.309 + {
1.310 + __UHEAP_MARK;
1.311 +
1.312 + // find out the number of open handles
1.313 + TInt startProcessHandleCount;
1.314 + TInt startThreadHandleCount;
1.315 + RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
1.316 +
1.317 + __UHEAP_SETFAIL(RHeap::EDeterministic, ++tryCount);
1.318 +
1.319 + CIniDocument8* ini=NULL;
1.320 + TRAP(err,ini=CIniDocument8::NewL(TheRFs,KIniFile8));
1.321 +
1.322 + delete ini;
1.323 +
1.324 + __UHEAP_SETFAIL(RHeap::ENone, 0);
1.325 +
1.326 + // check that no handles have leaked
1.327 + TInt endProcessHandleCount;
1.328 + TInt endThreadHandleCount;
1.329 + RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
1.330 + test(startProcessHandleCount == endProcessHandleCount);
1.331 + test(startThreadHandleCount == endThreadHandleCount);
1.332 +
1.333 + __UHEAP_MARKEND;
1.334 + } while(err == KErrNoMemory);
1.335 +
1.336 + test(err==KErrNone);
1.337 + test.Printf(_L("- succeeded at heap failure rate of %i\n"), tryCount);
1.338 + }
1.339 +
1.340 +
1.341 +void CIniParser8Test::CreateDeleteTest1L()
1.342 + {
1.343 + __UHEAP_MARK;
1.344 +
1.345 + CIniDocument8* ini=NULL;
1.346 + //note only support 16 bit Little Endian ini file
1.347 + ini=CIniDocument8::NewL(TheRFs,KIniFile8);
1.348 +
1.349 + delete ini;
1.350 +
1.351 + __UHEAP_MARKEND;
1.352 + }
1.353 +
1.354 +void CIniParser8Test::CreateDeleteOOMTest2L()
1.355 + {
1.356 + TInt err;
1.357 + TInt tryCount = 0;
1.358 + do
1.359 + {
1.360 + __UHEAP_MARK;
1.361 +
1.362 + // find out the number of open handles
1.363 + TInt startProcessHandleCount;
1.364 + TInt startThreadHandleCount;
1.365 + RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
1.366 +
1.367 + __UHEAP_SETFAIL(RHeap::EDeterministic, ++tryCount);
1.368 +
1.369 + CIniFile8* ini=NULL;
1.370 + TRAP(err,ini=CIniFile8::NewL(TheRFs,KIniFile8));
1.371 +
1.372 + delete ini;
1.373 +
1.374 + __UHEAP_SETFAIL(RHeap::ENone, 0);
1.375 +
1.376 + // check that no handles have leaked
1.377 + TInt endProcessHandleCount;
1.378 + TInt endThreadHandleCount;
1.379 + RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
1.380 + test(startProcessHandleCount == endProcessHandleCount);
1.381 + test(startThreadHandleCount == endThreadHandleCount);
1.382 +
1.383 + __UHEAP_MARKEND;
1.384 + } while(err == KErrNoMemory);
1.385 +
1.386 + test(err==KErrNone);
1.387 + test.Printf(_L("- succeeded at heap failure rate of %i\n"), tryCount);
1.388 + }
1.389 +
1.390 +
1.391 +void CIniParser8Test::CreateDeleteTest2L()
1.392 + {
1.393 + __UHEAP_MARK;
1.394 +
1.395 + CIniFile8* ini=NULL;
1.396 + //note only support 16 bit Little Endian ini file
1.397 + ini=CIniFile8::NewL(TheRFs,KIniFile8);
1.398 +
1.399 + delete ini;
1.400 +
1.401 + __UHEAP_MARKEND;
1.402 + }
1.403 +
1.404 +void CIniParser8Test::DoTest1L()
1.405 + {
1.406 + //Testing GetSectionList API
1.407 + RArray<TPtrC8> sectionNames;
1.408 + User::LeaveIfError(iIniDocument->GetSectionList(sectionNames));
1.409 + test(sectionNames.Count()==8);
1.410 +
1.411 + //Testing the sectionNames in name order
1.412 + test(sectionNames[0].Compare(_L8("1"))==0);
1.413 + test(sectionNames[1].Compare(_L8("MAPPINGS"))==0);
1.414 + test(sectionNames[2].Compare(_L8("MEDIA"))==0);
1.415 + test(sectionNames[3].Compare(_L8("OUTPUT_CHANNELS"))==0);
1.416 + test(sectionNames[4].Compare(_L8("SERVERS"))==0);
1.417 + test(sectionNames[5].Compare(_L8("SWTRACER"))==0);
1.418 + test(sectionNames[6].Compare(_L8("test_section"))==0);
1.419 + test(sectionNames[7].Compare(_L8("test_twosection"))==0);
1.420 + sectionNames.Reset();
1.421 + }
1.422 +
1.423 +void CIniParser8Test::DoTest2L()
1.424 + {
1.425 + //Test GetKeyValue API
1.426 + TPtrC8 value;
1.427 + User::LeaveIfError(iIniDocument->GetKeyValue(_L8("MEDIA"),_L8("RDebug"),value));
1.428 + test(value.Compare(_L8("SwtRDebugPlugin.dll"))==0);
1.429 + User::LeaveIfError(iIniDocument->GetKeyValue(_L8("OUTPUT_CHANNELS"),_L8("1"),value));
1.430 + test(value.Compare(_L8("RDebug"))==0);
1.431 + User::LeaveIfError(iIniDocument->GetKeyValue(_L8("1"),_L8("new_setting"),value));
1.432 + test(value.Compare(_L8("value \\n value1\\t value2"))==0);
1.433 +
1.434 + //unknown section
1.435 + TInt ret=KErrNone;
1.436 + ret=iIniDocument->GetKeyValue(_L8("mySection"),_L8("mykey"),value);
1.437 + LeaveIfNoMemory(ret);
1.438 + test(ret==KErrNotFound);
1.439 + //unknown key
1.440 + ret=iIniDocument->GetKeyValue(_L8("MEDIA"),_L8("mykey"),value);
1.441 + LeaveIfNoMemory(ret);
1.442 + test(ret==KErrNotFound);
1.443 + //empty value
1.444 + ret=iIniDocument->GetKeyValue(_L8("SERVERS"),_L8("SWTRACER"),value);
1.445 + LeaveIfNoMemory(ret);
1.446 + test(value.Length()==0);
1.447 + }
1.448 +
1.449 +void CIniParser8Test::DoTest3L()
1.450 + {
1.451 + //Test AddSection API
1.452 + RArray<TPtrC8> sectionNames;
1.453 + CleanupClosePushL(sectionNames);
1.454 + User::LeaveIfError(iIniDocument->AddSection(_L8("NEW-SECTION")));
1.455 + User::LeaveIfError(iIniDocument->GetSectionList(sectionNames));
1.456 + test(sectionNames.Count()==9);
1.457 +
1.458 + //case sensitive
1.459 + User::LeaveIfError(iIniDocument->AddSection(_L8("NeW-SECTION")));
1.460 + User::LeaveIfError(iIniDocument->GetSectionList(sectionNames));
1.461 + test(sectionNames.Count()==10);
1.462 + //adding existing section, no duplicate allowed
1.463 + TInt ret=iIniDocument->AddSection(_L8("NEW-SECTION"));
1.464 + LeaveIfNoMemory(ret);
1.465 + test(ret==KErrAlreadyExists);
1.466 + CleanupStack::PopAndDestroy();
1.467 + }
1.468 +
1.469 +void CIniParser8Test::DoTest4L()
1.470 + {
1.471 + //Test RemoveSection API
1.472 + RArray<TPtrC8> sectionNames;
1.473 + CleanupClosePushL(sectionNames);
1.474 +
1.475 + //known section at start of file.
1.476 + User::LeaveIfError(iIniDocument->RemoveSection(_L8("SERVERS")));
1.477 + User::LeaveIfError(iIniDocument->GetSectionList(sectionNames));
1.478 + test(sectionNames.Count()==7);
1.479 +
1.480 + //check key inside section is also deleted
1.481 + TPtrC8 value;
1.482 + TInt ret=iIniDocument->GetKeyValue(_L8("SERVERS"),_L8("SWTRACER"),value);
1.483 + LeaveIfNoMemory(ret);
1.484 + //Any section
1.485 + test(ret==KErrNotFound);
1.486 +
1.487 + //unknown section
1.488 + ret=iIniDocument->RemoveSection(_L8("AnySection"));
1.489 + LeaveIfNoMemory(ret);
1.490 + test(ret==KErrNotFound);
1.491 +
1.492 + //nonexist section should be created at end
1.493 + User::LeaveIfError(iIniDocument->SetKey(_L8("unknown_section3"),_L8("unknown_key3"),_L8("unknown_value3")));
1.494 + User::LeaveIfError(iIniDocument->GetKeyValue(_L8("unknown_section3"),_L8("unknown_key3"),value));
1.495 + test(value.Compare(_L8("unknown_value3"))==0);
1.496 +
1.497 + //unknown section
1.498 + ret=iIniDocument->RemoveSection(_L8("unknown_section3"));
1.499 + LeaveIfNoMemory(ret);
1.500 + test(ret==KErrNone);
1.501 +
1.502 + //Open a file and Externalise to it.
1.503 + User::LeaveIfError(iIniDocument->Externalise(_L("c:\\initest\\unknown8_3.ini")));
1.504 + CleanupStack::PopAndDestroy();
1.505 +
1.506 + // Read it back in and find the additions put in above.
1.507 + CIniDocument8* iniReRead=NULL;
1.508 + iniReRead=CIniDocument8::NewL(TheRFs,_L("c:\\initest\\unknown8_3.ini"));
1.509 + CleanupStack::PushL(iniReRead);
1.510 +
1.511 + ret=iniReRead->GetKeyValue(_L8("unknown_section3"),_L8("unknown_key3"),value);
1.512 + LeaveIfNoMemory(ret);
1.513 + test(ret==KErrNotFound);
1.514 + CleanupStack::PopAndDestroy(iniReRead);
1.515 + }
1.516 +
1.517 +void CIniParser8Test::DoTest5L()
1.518 + {
1.519 + //Testing SetKey API
1.520 + TPtrC8 value;
1.521 + //Modifying existing value
1.522 + User::LeaveIfError(iIniDocument->SetKey(_L8("MEDIA"),_L8("RDebug"),_L8("NewPlugin.dll")));
1.523 + User::LeaveIfError(iIniDocument->GetKeyValue(_L8("MEDIA"),_L8("RDebug"),value));
1.524 + test(value.Compare(_L8("NewPlugin.dll"))==0);
1.525 +
1.526 + //nonexist key should be created
1.527 + User::LeaveIfError(iIniDocument->SetKey(_L8("MEDIA"),_L8("newplug"),_L8("")));
1.528 + User::LeaveIfError(iIniDocument->GetKeyValue(_L8("MEDIA"),_L8("newplug"),value));
1.529 + test(value.Compare(_L8(""))==0);
1.530 +
1.531 + //nonexist section should be created
1.532 + User::LeaveIfError(iIniDocument->SetKey(_L8("unknown_section"),_L8("unknown_key"),_L8("unknown_value")));
1.533 + User::LeaveIfError(iIniDocument->GetKeyValue(_L8("unknown_section"),_L8("unknown_key"),value));
1.534 + test(value.Compare(_L8("unknown_value"))==0);
1.535 +
1.536 + //nonexist key should be created
1.537 + User::LeaveIfError(iIniDocument->SetKey(_L8("SERVERS"),_L8("host"),_L8("newhost")));
1.538 + User::LeaveIfError(iIniDocument->GetKeyValue(_L8("SERVERS"),_L8("host"),value));
1.539 + test(value.Compare(_L8("newhost"))==0);
1.540 +
1.541 + //create a second key in first section
1.542 + User::LeaveIfError(iIniDocument->SetKey(_L8("SERVERS"),_L8("host2"),_L8("newhost2")));
1.543 + User::LeaveIfError(iIniDocument->GetKeyValue(_L8("SERVERS"),_L8("host2"),value));
1.544 + test(value.Compare(_L8("newhost2"))==0);
1.545 +
1.546 + //alter existing key value again
1.547 + User::LeaveIfError(iIniDocument->SetKey(_L8("unknown_section"),_L8("unknown_key"),_L8("unknown_value2")));
1.548 + User::LeaveIfError(iIniDocument->GetKeyValue(_L8("unknown_section"),_L8("unknown_key"),value));
1.549 + test(value.Compare(_L8("unknown_value2"))==0);
1.550 +
1.551 + //Open a file and Externalise to it.
1.552 + User::LeaveIfError(iIniDocument->Externalise(_L("c:\\initest\\unknown8_1.ini")));
1.553 +
1.554 + // Read it back in and find the additions put in above.
1.555 + CIniDocument8* iniReRead=NULL;
1.556 + iniReRead=CIniDocument8::NewL(TheRFs,_L("c:\\initest\\unknown8_1.ini"));
1.557 + CleanupStack::PushL(iniReRead);
1.558 +
1.559 + User::LeaveIfError(iniReRead->GetKeyValue(_L8("unknown_section"),_L8("unknown_key"),value));
1.560 + test(value.Compare(_L8("unknown_value2"))==0);
1.561 + User::LeaveIfError(iniReRead->GetKeyValue(_L8("SERVERS"),_L8("host2"),value));
1.562 + test(value.Compare(_L8("newhost2"))==0);
1.563 + User::LeaveIfError(iniReRead->GetKeyValue(_L8("MEDIA"),_L8("RDebug"),value));
1.564 + test(value.Compare(_L8("NewPlugin.dll"))==0);
1.565 + User::LeaveIfError(iniReRead->GetKeyValue(_L8("MEDIA"),_L8("newplug"),value));
1.566 + test(value.Compare(_L8(""))==0);
1.567 + CleanupStack::PopAndDestroy(iniReRead);
1.568 +
1.569 + }
1.570 +
1.571 +void CIniParser8Test::DoTest6L()
1.572 + {
1.573 + //Testing RemoveKey API
1.574 + TPtrC8 value;
1.575 + //remove existing key in middle of file.
1.576 + User::LeaveIfError(iIniDocument->RemoveKey(_L8("OUTPUT_CHANNELS"),_L8("1")));
1.577 + TInt ret=iIniDocument->GetKeyValue(_L8("OUTPUT_CHANNELS"),_L8("1"),value);
1.578 + LeaveIfNoMemory(ret);
1.579 + test(ret==KErrNotFound);
1.580 +
1.581 + //remove non-exist key
1.582 + ret=iIniDocument->RemoveKey(_L8("OUTPUT_CHANNELS"),_L8("1"));
1.583 + LeaveIfNoMemory(ret);
1.584 + test(ret==KErrNotFound);
1.585 +
1.586 + //remove non-exist section
1.587 + ret=iIniDocument->RemoveKey(_L8("Non-existSection"),_L8("1"));
1.588 + LeaveIfNoMemory(ret);
1.589 + test(ret==KErrNotFound);
1.590 +
1.591 + //remove existing key at start of file
1.592 + User::LeaveIfError(iIniDocument->RemoveKey(_L8("SERVERS"),_L8("SWTRACER")));
1.593 + ret=iIniDocument->GetKeyValue(_L8("SERVERS"),_L8("SWTRACER"),value);
1.594 + LeaveIfNoMemory(ret);
1.595 + test(ret==KErrNotFound);
1.596 +
1.597 + //nonexist section should be created at end
1.598 + User::LeaveIfError(iIniDocument->SetKey(_L8("unknown_section"),_L8("unknown_key"),_L8("unknown_value")));
1.599 + User::LeaveIfError(iIniDocument->GetKeyValue(_L8("unknown_section"),_L8("unknown_key"),value));
1.600 + test(value.Compare(_L8("unknown_value"))==0);
1.601 +
1.602 + //remove existing key at end of section
1.603 + User::LeaveIfError(iIniDocument->RemoveKey(_L8("unknown_section"),_L8("unknown_key")));
1.604 + ret=iIniDocument->GetKeyValue(_L8("unknown_section"),_L8("unknown_key"),value);
1.605 + LeaveIfNoMemory(ret);
1.606 + test(ret==KErrNotFound);
1.607 +
1.608 + //Open a file and Externalise to it.
1.609 + User::LeaveIfError(iIniDocument->Externalise(_L("c:\\initest\\unknown8_2.ini")));
1.610 +
1.611 + // Read it back in and find the additions put in above.
1.612 + CIniDocument8* iniReRead=NULL;
1.613 + iniReRead=CIniDocument8::NewL(TheRFs,_L("c:\\initest\\unknown8_2.ini"));
1.614 + CleanupStack::PushL(iniReRead);
1.615 +
1.616 + ret=iniReRead->GetKeyValue(_L8("unknown_section"),_L8("unknown_key"),value);
1.617 + LeaveIfNoMemory(ret);
1.618 + test(ret==KErrNotFound);
1.619 +
1.620 + ret=iniReRead->GetKeyValue(_L8("SERVERS"),_L8("SWTRACER"),value);
1.621 + LeaveIfNoMemory(ret);
1.622 + test(ret==KErrNotFound);
1.623 + CleanupStack::PopAndDestroy(iniReRead);
1.624 + }
1.625 +
1.626 +void CIniParser8Test::DoTest7L()
1.627 + {
1.628 + //Testing iterator class
1.629 + CIniSecIter8* iIniSecIter=NULL;
1.630 + TInt ret=KErrNone;
1.631 +
1.632 + //unknown section
1.633 + TRAP(ret,iIniSecIter=CIniSecIter8::NewL(_L8("Unknown"),iIniDocument));
1.634 + LeaveIfNoMemory(ret);
1.635 + test(ret==KErrNotFound);
1.636 +
1.637 + //null document
1.638 + TRAP(ret,iIniSecIter=CIniSecIter8::NewL(_L8("Unknown"),NULL));
1.639 + LeaveIfNoMemory(ret);
1.640 + test(ret==KErrArgument);
1.641 +
1.642 + //known section
1.643 + iIniSecIter=CIniSecIter8::NewL(_L8("test_section"),iIniDocument);
1.644 + TPtrC8 key;
1.645 + TPtrC8 value;
1.646 + //test Next() and End();
1.647 + test(!iIniSecIter->End());
1.648 + test(iIniSecIter->Next(key,value));
1.649 + test(key.Compare(_L8("key1"))==0);
1.650 + test(value.Compare(_L8("value1"))==0);
1.651 + test(!iIniSecIter->End());
1.652 + test(iIniSecIter->Next(key,value));
1.653 + test(key.Compare(_L8("key2"))==0);
1.654 + test(value.Compare(_L8("value2"))==0);
1.655 + test(!iIniSecIter->End());
1.656 + test(iIniSecIter->Next(key,value));
1.657 + test(key.Compare(_L8("key3"))==0);
1.658 + test(value.Compare(_L8("value3"))==0);
1.659 + test(!iIniSecIter->End());
1.660 + test(iIniSecIter->Next(key,value));
1.661 + test(key.Compare(_L8("key4"))==0);
1.662 + test(value.Compare(_L8("value4"))==0);
1.663 + test(!iIniSecIter->End());
1.664 + test(iIniSecIter->Next(key,value));
1.665 + test(key.Compare(_L8("key5"))==0);
1.666 + test(value.Compare(_L8("value value value"))==0);
1.667 + test(iIniSecIter->End());
1.668 + test(iIniSecIter->Next(key,value)==EFalse);
1.669 +
1.670 + //test Reset()
1.671 + iIniSecIter->Reset();
1.672 + test(!iIniSecIter->End());
1.673 + test(iIniSecIter->Next(key,value));
1.674 + test(key.Compare(_L8("key1"))==0);
1.675 + test(value.Compare(_L8("value1"))==0);
1.676 +
1.677 + delete iIniSecIter;
1.678 + iIniSecIter=NULL;
1.679 + }
1.680 +
1.681 +void CIniParser8Test::DoTest8L()
1.682 + {
1.683 + //Testing Externalise to ROM drive
1.684 + TInt ret=iIniDocument->Externalise(_L("z:\\output.ini"));
1.685 + LeaveIfNoMemory(ret);
1.686 + test(ret==KErrAccessDenied);
1.687 +
1.688 + //Testing Externalise to a New file
1.689 + User::LeaveIfError(iIniDocument->Externalise(_L("c:\\initest\\output8.ini")));
1.690 +
1.691 + test(CompareFilesL(TheRFs,_L("z:\\resource\\testconfig8.ini"), _L("c:\\initest\\output8.ini")));
1.692 +
1.693 + //Try opening the written ini file now to ensure no corruption in writing
1.694 + CIniDocument8* output=CIniDocument8::NewL(TheRFs,_L("c:\\initest\\output8.ini"));
1.695 + CleanupStack::PushL(output);
1.696 + User::LeaveIfError(output->SetKey(_L8("Test"),_L8("Test"),_L8("Test")));
1.697 +
1.698 + //Testing Externaliseing to the already exist file
1.699 + User::LeaveIfError(output->Externalise(_L("c:\\initest\\output8.ini")));
1.700 + CleanupStack::PopAndDestroy();
1.701 +
1.702 + //Opening an empty file and Externaliseing an empty file
1.703 + output=CIniDocument8::NewL(TheRFs,_L("c:\\initest\\unknown8.ini"));
1.704 + CleanupStack::PushL(output);
1.705 + User::LeaveIfError(output->Externalise(_L("c:\\initest\\unknown8.ini")));
1.706 + CleanupStack::PopAndDestroy();
1.707 + }
1.708 +
1.709 +void CIniParser8Test::DoTest9L()
1.710 +{
1.711 + //Test for no leakage when handling corrupt file
1.712 + CIniDocument8* ini=NULL;
1.713 + TRAPD(err,ini=CIniDocument8::NewL(TheRFs,_L("z:\\resource\\corruptconfig8.ini")));
1.714 + LeaveIfNoMemory(err);
1.715 + test(err==KErrCorrupt);
1.716 + delete ini;
1.717 +}
1.718 +
1.719 +void CIniParser8Test::DoTest10L()
1.720 +{
1.721 + TPtrC8 value;
1.722 + //open existing ini file
1.723 + CIniFile8* ini=CIniFile8::NewL(TheRFs,_L("z:\\resource\\testconfig8.ini"));
1.724 + CleanupStack::PushL(ini);
1.725 +
1.726 + //mid section
1.727 + User::LeaveIfError(ini->FindVar(_L8("test_section"),_L8("key1"),value));
1.728 + test(value.Compare(_L8("value1"))==0);
1.729 + User::LeaveIfError(ini->FindVar(_L8("test_section"),_L8("key2"),value));
1.730 + test(value.Compare(_L8("value2"))==0);
1.731 + User::LeaveIfError(ini->FindVar(_L8("test_section"),_L8("key3"),value));
1.732 + test(value.Compare(_L8("value3"))==0);
1.733 + User::LeaveIfError(ini->FindVar(_L8("test_section"),_L8("key4"),value));
1.734 + test(value.Compare(_L8("value4"))==0);
1.735 + User::LeaveIfError(ini->FindVar(_L8("test_section"),_L8("key5"),value));
1.736 + test(value.Compare(_L8("value value value"))==0);
1.737 +
1.738 + //first section
1.739 + User::LeaveIfError(ini->FindVar(_L8("SERVERS"),_L8("SWTRACER"),value));
1.740 + test(value.Compare(_L8(""))==0);
1.741 +
1.742 + //last section
1.743 + User::LeaveIfError(ini->FindVar(_L8("1"),_L8("timestamps"),value));
1.744 + test(value.Compare(_L8("0"))==0);
1.745 + User::LeaveIfError(ini->FindVar(_L8("1"),_L8("setting"),value));
1.746 + test(value.Compare(_L8("value"))==0);
1.747 +
1.748 + CleanupStack::PopAndDestroy();
1.749 +
1.750 + //open a non existing file
1.751 + TInt ret=KErrNone;
1.752 + TRAP(ret,ini=CIniFile8::NewL(TheRFs,_L("z:\\resource\\nonexist.ini")));
1.753 + LeaveIfNoMemory(ret);
1.754 + test(ret==KErrNotFound);
1.755 +
1.756 + //open an empty ini file
1.757 + ini=CIniFile8::NewL(TheRFs,_L("z:\\resource\\empty8.ini"));
1.758 + CleanupStack::PushL(ini);
1.759 +
1.760 + ret=ini->FindVar(_L8("empty"),_L8("empty"),value);
1.761 + LeaveIfNoMemory(ret);
1.762 + test(ret==KErrNotFound);
1.763 +
1.764 + CleanupStack::PopAndDestroy();
1.765 +}
1.766 +
1.767 +void CIniParser8Test::DoTest11L()
1.768 + {
1.769 + TPtrC8 value;
1.770 + // We are trying to invoke an OOM condition for a single operation to test that the operation is atomic.
1.771 + // Under that condition the object should be rolled back to the original state. The resulting document should be the same
1.772 + // as before the condition was invoked. If the test succeeded, a new section should be created at end
1.773 + // (which is nice but not the real focus of the test).
1.774 + User::LeaveIfError(iIniDocument->SetKey(_L8("unknown_section3"),_L8("unknown_key3"),_L8("unknown_value3")));
1.775 + }
1.776 +
1.777 +void CIniParser8Test::DoTest12L()
1.778 +{
1.779 + __UHEAP_MARK;
1.780 +
1.781 + CIniDocument8* Ori_ini = NULL;
1.782 + CIniDocument8* Com_ini = NULL;
1.783 + CIniDocument8* Cre_ini = NULL;
1.784 +
1.785 +
1.786 + RFs rfs;
1.787 + rfs.Connect();
1.788 +
1.789 + TRAPD( err1, Ori_ini = CIniDocument8::NewL(rfs, _L("z:\\resource\\OriConfig8.ini")) );
1.790 + test(err1 == KErrNone);
1.791 + TRAPD( err2, Com_ini = CIniDocument8::NewL(rfs, _L("z:\\resource\\ComConfig8.ini")) );
1.792 + test(err2 == KErrNone);
1.793 +
1.794 + Ori_ini->SetKey(_L8("DEFECT"), _L8("Number"), _L8("127618"));
1.795 + Ori_ini->Externalise( _L("c:\\initest\\CreateConfig8.ini") );
1.796 +
1.797 + TRAPD( err3, Cre_ini = CIniDocument8::NewL(rfs, _L("c:\\initest\\CreateConfig8.ini")) );
1.798 + test(err3 == KErrNone);
1.799 +
1.800 + bool result = Cre_ini->CompareDocs(*Com_ini);
1.801 + test(result==true);
1.802 +
1.803 + rfs.Close();
1.804 + delete Ori_ini;
1.805 + delete Com_ini;
1.806 + delete Cre_ini;
1.807 +
1.808 + __UHEAP_MARKEND;
1.809 +}
1.810 +
1.811 +static void DeleteFilesL()
1.812 + {
1.813 + CFileMan* fileman=CFileMan::NewL(TheRFs);
1.814 +
1.815 + fileman->Delete(_L("c:\\initest\\*"));
1.816 +
1.817 + delete fileman;
1.818 + }
1.819 +
1.820 +/**
1.821 +@SYMTestCaseID SYSLIB-BAFL-CT-1558
1.822 +@SYMTestCaseDesc Test CIniParser8Test
1.823 +@SYMTestPriority High
1.824 +@SYMTestActions Perform various component tests on CIniParser8Test (includes OOM)
1.825 + Testing all the exported APis
1.826 +@SYMTestExpectedResults The test must not fail.
1.827 +@SYMREQ PREQ505
1.828 +*/
1.829 +static void DoTestL()
1.830 + {
1.831 + test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-1558 "));
1.832 + DeleteFilesL();
1.833 +
1.834 + //8 bit basic testing
1.835 +
1.836 + CIniParser8Test::CreateDeleteTest1L();
1.837 + CIniParser8Test::DoBasicTestL(&CIniParser8Test::DoTest1L,_L("GetSectionList8"));
1.838 + CIniParser8Test::DoBasicTestL(&CIniParser8Test::DoTest2L,_L("GetKeyValue8"));
1.839 + CIniParser8Test::DoBasicTestL(&CIniParser8Test::DoTest3L,_L("AddSection8"));
1.840 + CIniParser8Test::DoBasicTestL(&CIniParser8Test::DoTest4L,_L("RemoveSection8"));
1.841 + CIniParser8Test::DoBasicTestL(&CIniParser8Test::DoTest5L,_L("SetKeyValue8"));
1.842 + CIniParser8Test::DoBasicTestL(&CIniParser8Test::DoTest6L,_L("RemoveKey8"));
1.843 + CIniParser8Test::DoBasicTestL(&CIniParser8Test::DoTest7L,_L("IniSecIter8"));
1.844 + CIniParser8Test::DoBasicTestL(&CIniParser8Test::DoTest8L,_L("Externalise"));
1.845 + CIniParser8Test::DoBasicTestL(&CIniParser8Test::DoTest9L,_L("Corrupt file"));
1.846 +
1.847 + //Defect 127618
1.848 + CIniParser8Test::DoBasicTestL(&CIniParser8Test::DoTest12L,_L("New Line Missing"));
1.849 +
1.850 +
1.851 + //8 bit OOM testing
1.852 + CIniParser8Test::CreateDeleteOOMTestL();
1.853 + CIniParser8Test::DoOOMTestL(&CIniParser8Test::DoTest1L,_L("GetSectionList8-OOM"));
1.854 + CIniParser8Test::DoOOMTestL(&CIniParser8Test::DoTest2L,_L("GetKeyValue8-OOM"));
1.855 + CIniParser8Test::DoOOMTestL(&CIniParser8Test::DoTest3L,_L("AddSection8-OOM"));
1.856 + CIniParser8Test::DoOOMTestL(&CIniParser8Test::DoTest4L,_L("RemoveSection8-OOM"));
1.857 + CIniParser8Test::DoOOMTestL(&CIniParser8Test::DoTest5L,_L("SetKeyValue8-OOM"));
1.858 + CIniParser8Test::DoOOMTestL(&CIniParser8Test::DoTest6L,_L("RemoveKey8-OOM"));
1.859 + CIniParser8Test::DoOOMTestL(&CIniParser8Test::DoTest7L,_L("IniSecIter8-OOM"));
1.860 + CIniParser8Test::DoOOMTestL(&CIniParser8Test::DoTest8L,_L("Externalise-OOM"));
1.861 + CIniParser8Test::DoOOMTestL(&CIniParser8Test::DoTest9L,_L("Corrupt file-OOM"));
1.862 +
1.863 + //8 bit light basic testing
1.864 + CIniParser8Test::CreateDeleteTest2L();
1.865 + CIniParser8Test::DoBasicTestL(&CIniParser8Test::DoTest10L,_L("Light FindVar"));
1.866 + //8 bit light OOM testing
1.867 + CIniParser8Test::CreateDeleteOOMTest2L();
1.868 + CIniParser8Test::DoOOMTestL(&CIniParser8Test::DoTest10L,_L("Light FindVar-OOM"));
1.869 +
1.870 + //Light weight temporary testing
1.871 + TInt ret=KErrNone;
1.872 + TTime startTime(0), stopTime(0);
1.873 +
1.874 + TPtrC8 value;
1.875 + startTime.UniversalTime();
1.876 +for (TInt i=0;i<1000;i++)
1.877 + {
1.878 + CIniFile8* ini=CIniFile8::NewL(TheRFs,_L("z:\\resource\\testconfig8.ini"));
1.879 + ret=ini->FindVar(_L8("test_section"),_L8("key1"),value);
1.880 + test(value.Compare(_L8("value1"))==0);
1.881 + test(ret==KErrNone);
1.882 + ret=ini->FindVar(_L8("test_section"),_L8("key2"),value);
1.883 + test(value.Compare(_L8("value2"))==0);
1.884 + test(ret==KErrNone);
1.885 + ret=ini->FindVar(_L8("test_section"),_L8("key3"),value);
1.886 + test(value.Compare(_L8("value3"))==0);
1.887 + test(ret==KErrNone);
1.888 + ret=ini->FindVar(_L8("test_section"),_L8("key4"),value);
1.889 + test(value.Compare(_L8("value4"))==0);
1.890 + test(ret==KErrNone);
1.891 + ret=ini->FindVar(_L8("test_section"),_L8("key5"),value);
1.892 + test(value.Compare(_L8("value value value"))==0);
1.893 + test(ret==KErrNone);
1.894 + ret=ini->FindVar(_L8("SERVERS"),_L8("SWTRACER"),value);
1.895 + test(value.Compare(_L8(""))==0);
1.896 + test(ret==KErrNone);
1.897 + ret=ini->FindVar(_L8("1"),_L8("timestamps"),value);
1.898 + test(value.Compare(_L8("0"))==0);
1.899 + test(ret==KErrNone);
1.900 + ret=ini->FindVar(_L8("1"),_L8("setting"),value);
1.901 + test(value.Compare(_L8("value"))==0);
1.902 + test(ret==KErrNone);
1.903 + delete ini;
1.904 + }
1.905 + stopTime.UniversalTime();
1.906 + TTimeIntervalMicroSeconds timeTaken = stopTime.MicroSecondsFrom(startTime);
1.907 + test.Printf(_L("Time taken for Light= %d microseconds\n"), timeTaken.Int64() );
1.908 +
1.909 + //heavy weight
1.910 +
1.911 + startTime.UniversalTime();
1.912 +for (TInt j=0;j<1000;j++)
1.913 + {
1.914 + CIniDocument8* dom=CIniDocument8::NewL(TheRFs,KIniFile8);
1.915 + ret=dom->GetKeyValue(_L8("test_section"),_L8("key1"),value);
1.916 + test(value.Compare(_L8("value1"))==0);
1.917 + test(ret==KErrNone);
1.918 + ret=dom->GetKeyValue(_L8("test_section"),_L8("key2"),value);
1.919 + test(value.Compare(_L8("value2"))==0);
1.920 + test(ret==KErrNone);
1.921 + ret=dom->GetKeyValue(_L8("test_section"),_L8("key3"),value);
1.922 + test(value.Compare(_L8("value3"))==0);
1.923 + test(ret==KErrNone);
1.924 + ret=dom->GetKeyValue(_L8("test_section"),_L8("key4"),value);
1.925 + test(value.Compare(_L8("value4"))==0);
1.926 + test(ret==KErrNone);
1.927 + ret=dom->GetKeyValue(_L8("test_section"),_L8("key5"),value);
1.928 + test(value.Compare(_L8("value value value"))==0);
1.929 + test(ret==KErrNone);
1.930 + ret=dom->GetKeyValue(_L8("SERVERS"),_L8("SWTRACER"),value);
1.931 + test(value.Compare(_L8(""))==0);
1.932 + test(ret==KErrNone);
1.933 + ret=dom->GetKeyValue(_L8("1"),_L8("timestamps"),value);
1.934 + test(value.Compare(_L8("0"))==0);
1.935 + test(ret==KErrNone);
1.936 + ret=dom->GetKeyValue(_L8("1"),_L8("setting"),value);
1.937 + test(value.Compare(_L8("value"))==0);
1.938 + test(ret==KErrNone);
1.939 + delete dom;
1.940 + }
1.941 +
1.942 + stopTime.UniversalTime();
1.943 + timeTaken = stopTime.MicroSecondsFrom(startTime);
1.944 + test.Printf(_L("Time taken for Heavy= %d microseconds\n"), timeTaken.Int64() );
1.945 +
1.946 + startTime.UniversalTime();
1.947 + // Consistency checks
1.948 + CIniParser8Test::DoOOMWithConsistencyCheckTestL(&CIniParser8Test::DoTest11L,_L("Consistency8-OOMC"), FALSE);
1.949 +
1.950 + stopTime.UniversalTime();
1.951 + timeTaken = stopTime.MicroSecondsFrom(startTime);
1.952 + test.Printf(_L("Time taken for consistency checks= %d microseconds\n"), timeTaken.Int64() );
1.953 + DeleteFilesL();
1.954 + }
1.955 +
1.956 +GLDEF_C TInt E32Main()
1.957 + {
1.958 + __UHEAP_MARK;
1.959 + CTrapCleanup* trapCleanup=CTrapCleanup::New();
1.960 + test(TheRFs.Connect()==KErrNone);
1.961 + test.Start(_L("MyTest"));
1.962 +
1.963 + TRAPD(error, DoTestL());
1.964 + test(error == KErrNone);
1.965 +
1.966 +
1.967 + TheRFs.Close();
1.968 + test.End();
1.969 + test.Close();
1.970 + delete trapCleanup;
1.971 + __UHEAP_MARKEND;
1.972 + return error;
1.973 + }
1.974 +