os/kernelhwsrv/kerneltest/e32test/hcr/d_hcrsim.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 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 the License "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 // e32test/hcr/d_hcrsim.cpp
    15 //
    16 
    17 #include "d_hcrsim.h"
    18 #include <kernel/kernel.h>
    19 #include <plat_priv.h>
    20 #include "hcr_debug.h"
    21 #include "hcr_uids.h"
    22 #ifdef HCRTEST_USERSIDE_INTERFACE
    23 #include "d_hcrsim_testdata.h"
    24 #endif // HCRTEST_USERSIDE_INTERFACE
    25 
    26 #define TEST(a)				CheckPoint(a, __LINE__)
    27 #define TEST_KERRNONE(a)	CheckPointError(a, __LINE__)
    28 
    29 #ifndef HCRTEST_USERSIDE_INTERFACE
    30 TInt InitExtension();
    31 extern TUint32 PslConfigurationFlags;
    32 #endif // HCRTEST_USERSIDE_INTERFACE
    33 
    34 #ifdef HCRTEST_CLIENT_THREAD
    35 #define TEST_ENTERCS()			NKern::ThreadEnterCS()
    36 #define TEST_LEAVECS()			NKern::ThreadLeaveCS()
    37 #define TEST_MEMGET(s, d, l)	kumemget(d, s, l)
    38 #define TEST_MEMPUT(d, s, l)	kumemput(d, s, l)
    39 #define TEST_DESGET(s, d)		Kern::KUDesGet(d, *(TDes8*) s)
    40 #define TEST_DESPUT(d, s)		Kern::KUDesPut(*(TDes8*) d, s)
    41 #else
    42 #define TEST_ENTERCS()
    43 #define TEST_LEAVECS()
    44 #define TEST_MEMGET(s, d, l)	Kern::ThreadRawRead(iClient, s, d, l)
    45 #define TEST_MEMPUT(d, s, l)	Kern::ThreadRawWrite(iClient, d, s, l)
    46 #define TEST_DESGET(s, d)		Kern::ThreadDesRead(iClient, s, d, 0)
    47 #define TEST_DESPUT(d, s)		Kern::ThreadDesWrite(iClient, d, s, 0)
    48 #endif // HCRTEST_CLIENT_THREAD
    49 
    50 // Test results for the Kernel Extension initialisation routine
    51 TInt TestKernExtensionTestLine = -1;
    52 TInt TestKernExtensionTestError = -1;
    53 
    54 const TUint KTestBenchmarkIterations = 10000;
    55 const TUint KTestGetMultipleBenchmarkIterations = 100;
    56 
    57 class DHcrSimTestDrvFactory : public DLogicalDevice
    58 	{
    59 public:
    60 	DHcrSimTestDrvFactory();
    61 	~DHcrSimTestDrvFactory();
    62 	virtual TInt Install();
    63 	virtual void GetCaps(TDes8& aDes) const;
    64 	virtual TInt Create(DLogicalChannelBase*& aChannel);
    65 public:
    66 #ifndef HCRTEST_CLIENT_THREAD
    67 	TDynamicDfcQue* iDfcQ;
    68 #endif
    69 	};
    70 
    71 #ifdef HCRTEST_CLIENT_THREAD
    72 class DHcrSimTestDrvChannel : public DLogicalChannelBase
    73 #else
    74 class DHcrSimTestDrvChannel : public DLogicalChannel
    75 #endif
    76 	{
    77 public:
    78 	DHcrSimTestDrvChannel();
    79 	~DHcrSimTestDrvChannel();
    80 	// Inherited from DLogicalChannel
    81 	virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
    82 #ifdef HCRTEST_CLIENT_THREAD
    83 	// Inherited from DLogicalChannelBase: process all DoControl in the user's context
    84 	virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2);
    85 #else
    86 	TInt DoControl(TInt aReqNo, TAny* a1, TAny* a2);
    87 	virtual void HandleMsg(TMessageBase* aMsg);
    88 public:
    89 	DThread* iClient;
    90 #endif // HCRTEST_CLIENT_THREAD
    91 	};
    92 
    93 void CheckPoint(TInt aCondition, TInt aLine)
    94 	{
    95 	if (!aCondition)
    96 		{
    97 		Kern::Printf("Device driver test failed (line %d)", aLine);
    98 		}
    99 	}
   100 
   101 void CheckPointError(TInt aErrorCode, TInt aLine)
   102 	{
   103 	if (aErrorCode != KErrNone)
   104 		{
   105 		Kern::Printf("Device driver error %d (line %d)", aErrorCode, aLine);
   106 		}
   107 	}
   108 
   109 void HasRepositoryInSmr(TBool& aHasSmr, TBool& aHasSmrHcr)
   110 	{
   111 	aHasSmr = EFalse;
   112 	aHasSmrHcr = EFalse;
   113 
   114 	// Note: the SMR feature by which we obtain the address of the override
   115 	// repository is only supported in the ARM bootstrap, not X86 or WINS so 
   116 	// this test code needs conditional compilation.
   117 #if !defined(__WINS__) && !defined(__X86__)
   118 	const TSuperPage& superpage = Kern::SuperPage();
   119 	TUint32* smrib = (TUint32*) superpage.iSmrData;
   120 	SSmrBank* smrbank = (SSmrBank*) smrib;
   121 	if((smrib != NULL) && (smrib != (TUint32*)KSuperPageAddressFieldUndefined))
   122 		{
   123 		aHasSmr = ETrue;
   124 		while (smrbank->iBase)
   125 			{
   126 			if (smrbank->iPayloadUID == KHCRUID_SMRPayloadUID)
   127 				{
   128 				// We have a HCR repository - assuming it is the test one...
   129 				aHasSmrHcr = ETrue;
   130 				break;
   131 				}
   132 			++smrbank;
   133 			}
   134 		}
   135 #endif // !__WINS__ && !__X86__
   136 	}
   137 
   138 #ifdef HCRTEST_USERSIDE_INTERFACE
   139 #define KEXT_TESTKERRNONE(_r)						\
   140 	{												\
   141 	TInt _s = _r;									\
   142 	if ((_s) && !TestKernExtensionTestLine)			\
   143 		{											\
   144 		TestKernExtensionTestError = (_r);			\
   145 		TestKernExtensionTestLine = __LINE__;		\
   146 		}											\
   147 	}
   148 #define KEXT_TEST(_r)								\
   149 	{												\
   150 	if (!(_r) && !TestKernExtensionTestLine)		\
   151 		{											\
   152 		TestKernExtensionTestError = 1;				\
   153 		TestKernExtensionTestLine = __LINE__;		\
   154 		}											\
   155 	}
   156 
   157 void KextInitTests()
   158 	{
   159 	TInt r;
   160 	// Get last Setting in Reference Compiled Repository
   161 	TUint32 value1;
   162 	TSettingId setting1(0xFFFFFFFF, 0xFFFFFFFF);
   163 	r = GetUInt(setting1, value1);
   164 	KEXT_TESTKERRNONE(r);
   165 	KEXT_TEST(value1==0x4C415354); // 'L', 'A', 'S', 'T'
   166 
   167 	// Determine what test repositories the HCR has loaded
   168 	// Make sure we have the file repository
   169 	const TRomHeader& romheader = Epoc::RomHeader();
   170 	KEXT_TEST(romheader.iHcrFileAddress != NULL); // Assuming this is the test repository (hcr.dat)
   171 	// Find the nand repository
   172 	TBool smr;
   173 	TBool smrrep;
   174 	SSettingC* repos = NULL;
   175 	TInt nosettings = 0;
   176 	HasRepositoryInSmr(smr, smrrep);
   177 	if (smrrep)
   178 		{
   179 		repos = SettingsList6; // File+Nand
   180 		nosettings = sizeof(SettingsList6) / sizeof(SSettingC);
   181 		}
   182 	else if (!smr)
   183 		{
   184 		repos = SettingsList7; // File Only
   185 		nosettings = sizeof(SettingsList7) / sizeof(SSettingC);
   186 		}
   187 	else
   188 		{
   189 		// SMR partitions found but no HCR repository
   190 		KEXT_TEST(0);
   191 		return;
   192 		}
   193 
   194 	// Simple word setting Get
   195 	for (SSettingC* setting = repos; setting < repos + nosettings; setting++)
   196 		{
   197 // Note: these macros are irrelevant here, it is just so the two test kernel
   198 // extensions do something different
   199 #ifdef HCRTEST_CLIENT_THREAD
   200 		if (setting->iName.iType == ETypeInt32)
   201 			{
   202 			TSettingId id(setting->iName.iId.iCat, setting->iName.iId.iKey);
   203 			TInt32 val;
   204 			r = GetInt(id, val);
   205 			KEXT_TESTKERRNONE(r);
   206 			KEXT_TEST(setting->iValue.iLit.iInt32 == val);
   207 			}
   208 #else // !HCRTEST_CLIENT_THREAD
   209 		if (setting->iName.iType == ETypeUInt32)
   210 			{
   211 			TSettingId id(setting->iName.iId.iCat, setting->iName.iId.iKey);
   212 			TUint32 val;
   213 			r = GetUInt(id, val);
   214 			KEXT_TESTKERRNONE(r);
   215 			KEXT_TEST(setting->iValue.iLit.iUInt32 == val);
   216 			}
   217 #endif // !HCRTEST_CLIENT_THREAD
   218 		}
   219 
   220 	// Large setting Get
   221 	for (SSettingC* setting = repos; setting < repos + nosettings; setting++)
   222 		{
   223 // Note: these macros are irrelevant here, it is just so the two test kernel
   224 // extensions do something different
   225 #ifdef HCRTEST_CLIENT_THREAD
   226 		if (setting->iName.iType == ETypeBinData)
   227 			{
   228 			TSettingId id(setting->iName.iId.iCat, setting->iName.iId.iKey);
   229 			TBuf8<KMaxSettingLength> val;
   230 			TPtrC8 aval(setting->iValue.iPtr.iData, setting->iName.iLen);
   231 			r = GetData(id, val);
   232 			KEXT_TESTKERRNONE(r);
   233 			KEXT_TEST(0 == val.Compare(aval));
   234 			}
   235 #else // !HCRTEST_CLIENT_THREAD
   236 		if (setting->iName.iType == ETypeText8)
   237 			{
   238 			TSettingId id(setting->iName.iId.iCat, setting->iName.iId.iKey);
   239 			TBuf8<KMaxSettingLength> val;
   240 			TPtrC8 aval(setting->iValue.iPtr.iString8, setting->iName.iLen);
   241 			r = GetString(id, val);
   242 			KEXT_TESTKERRNONE(r);
   243 			KEXT_TEST(0 == val.Compare(aval));
   244 			}
   245 #endif // !HCRTEST_CLIENT_THREAD
   246 		}
   247 
   248 	// Some other API calls
   249 	TUint i;
   250 	for (i = 0; i < sizeof(KTestCategories) / sizeof(TCategoryUid); i++)
   251 		{
   252 		r = FindNumSettingsInCategory(KTestCategories[i]);
   253 		KEXT_TEST(r >= 0);
   254 		}
   255 	}
   256 
   257 DECLARE_EXTENSION_WITH_PRIORITY(KExtensionMaximumPriority)
   258 	{
   259 	// Set these to 0 so we know we've been here
   260 	TestKernExtensionTestLine = 0;
   261 	TestKernExtensionTestError = 0;
   262 	KextInitTests();
   263 	return KErrNone;
   264 	}
   265 #endif // HCRTEST_USERSIDE_INTERFACE
   266 
   267 DECLARE_EXTENSION_LDD()
   268 	{
   269 	return new DHcrSimTestDrvFactory;
   270 	}
   271 
   272 DHcrSimTestDrvFactory::DHcrSimTestDrvFactory()
   273 	{
   274 	iParseMask = 0;
   275 	iUnitsMask = 0;
   276 	iVersion = TVersion(1,0,KE32BuildVersionNumber);
   277 	}
   278 
   279 DHcrSimTestDrvFactory::~DHcrSimTestDrvFactory()
   280 	{
   281 #ifndef HCRTEST_CLIENT_THREAD
   282 	if (iDfcQ)
   283 		iDfcQ->Destroy();
   284 #endif
   285 	}
   286 
   287 #ifndef HCRTEST_CLIENT_THREAD
   288 const TInt KHcrSimTestThreadPriority = 1;
   289 _LIT(KHcrSimTestThread,"HcrSimTestThread");
   290 #endif
   291 
   292 TInt DHcrSimTestDrvFactory::Install()
   293 	{
   294 	TInt r;
   295 #ifndef HCRTEST_CLIENT_THREAD
   296 	r = Kern::DynamicDfcQCreate(iDfcQ, KHcrSimTestThreadPriority, KHcrSimTestThread);
   297 	if (r != KErrNone)
   298 		return r;
   299 #ifdef HCRTEST_USERSIDE_INTERFACE
   300 	r = SetName(&KTestHcrRealOwn);
   301 #else
   302 	r = SetName(&KTestHcrSimOwn);
   303 #endif // HCRTEST_USERSIDE_INTERFACE
   304 #else
   305 #ifdef HCRTEST_USERSIDE_INTERFACE
   306 	r = SetName(&KTestHcrRealClient);
   307 #else
   308 	r = SetName(&KTestHcrSimClient);
   309 #endif // HCRTEST_USERSIDE_INTERFACE
   310 #endif // HCRTEST_CLIENT_THREAD
   311 	return r;
   312 	}
   313 
   314 void DHcrSimTestDrvFactory::GetCaps(TDes8& /*aDes*/) const
   315 	{
   316 	// Get capabilities - overriding pure virtual
   317 	}
   318 
   319 TInt DHcrSimTestDrvFactory::Create(DLogicalChannelBase*& aChannel)
   320 	{
   321 	aChannel=new DHcrSimTestDrvChannel;
   322 	return aChannel?KErrNone:KErrNoMemory;
   323 	}
   324 
   325 // ----------------------------------------------------------------------------
   326 
   327 DHcrSimTestDrvChannel::DHcrSimTestDrvChannel()
   328 	{
   329 #ifndef HCRTEST_CLIENT_THREAD
   330 	iClient=&Kern::CurrentThread();
   331 	iClient->Open();
   332 #endif
   333 	}
   334 
   335 DHcrSimTestDrvChannel::~DHcrSimTestDrvChannel()
   336 	{
   337 #ifndef HCRTEST_CLIENT_THREAD
   338 	Kern::SafeClose((DObject*&)iClient, NULL);
   339 #endif
   340 	}
   341 
   342 TInt DHcrSimTestDrvChannel::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/)
   343 	{
   344 #ifndef HCRTEST_CLIENT_THREAD
   345 	SetDfcQ(((DHcrSimTestDrvFactory*)iDevice)->iDfcQ);
   346 	iMsgQ.Receive();
   347 #endif
   348 	return KErrNone;
   349 	}
   350 
   351 #ifndef HCRTEST_CLIENT_THREAD
   352 void DHcrSimTestDrvChannel::HandleMsg(TMessageBase* aMsg)
   353 	{
   354 	TInt r=KErrNone;
   355 	TThreadMessage& m=*(TThreadMessage*)aMsg;
   356 	TInt id=m.iValue;
   357 	if (id==(TInt)ECloseMsg)
   358 		{
   359 		m.Complete(KErrNone,EFalse);
   360 		return;
   361 		}
   362 	else
   363 		{
   364 		r=DoControl(id,m.Ptr0(),m.Ptr1());
   365 		}
   366 	m.Complete(r,ETrue);
   367 	}
   368 #endif // HCRTEST_CLIENT_THREAD
   369 
   370 #ifdef HCRTEST_CLIENT_THREAD
   371 TInt DHcrSimTestDrvChannel::Request(TInt aReqNo, TAny* a1, TAny* a2)
   372 #else
   373 TInt DHcrSimTestDrvChannel::DoControl(TInt aReqNo, TAny* a1, TAny* a2)
   374 #endif
   375 	{
   376 	TInt r=KErrNotSupported;
   377 	switch (aReqNo)
   378 		{
   379 		case RHcrSimTestChannel::EHcrGetLinAddr:
   380 			{
   381 			TSettingId setting;
   382 			TLinAddr value;
   383 			TEST_MEMGET(a1, &setting, sizeof(TSettingId));
   384 			r = GetLinAddr(setting, value);
   385 			TEST_MEMPUT(a2, &value, sizeof(value));
   386 			break;
   387 			}
   388 		case RHcrSimTestChannel::EHcrFindNumSettingsInCategory:
   389 			{
   390 			r = FindNumSettingsInCategory((TCategoryUid) a1);
   391 			break;
   392 			}
   393 		case RHcrSimTestChannel::EHcrFindSettingsCategory:
   394 			{
   395 			// Get list of pointers
   396 			TAny* args[6];
   397 			TEST_MEMGET(a1, args, sizeof(args));
   398 			TInt aMaxNum = (TInt) args[1];
   399 				
   400 			TElementId* ids = NULL;
   401 			TSettingType* types = NULL;
   402 			TUint16* lens = NULL;
   403 			if(args[3])
   404 			    {
   405 			    TEST_ENTERCS();
   406 			    ids = (TElementId*) Kern::Alloc(_ABS(aMaxNum) * sizeof(TElementId));
   407 			    TEST_LEAVECS();
   408 			    }
   409 			
   410 			if (args[4]) // aTypes
   411 			    {
   412 			    TEST_ENTERCS();
   413 			    types = (TSettingType*) Kern::Alloc(_ABS(aMaxNum) * sizeof(TSettingType));
   414 			    TEST_LEAVECS();
   415 			    }
   416 			if (types == NULL && args[4])
   417 			    {
   418 			    r = KErrNoMemory;
   419 			    }
   420 			else
   421 			    {
   422 			    if (args[5]) // aLens
   423 			        {
   424 			        TEST_ENTERCS();
   425 			        lens = (TUint16*) Kern::Alloc(_ABS(aMaxNum) * sizeof(TUint16));
   426 			        TEST_LEAVECS();
   427 			        }
   428 			    if (lens == NULL && args[5])
   429 			        {
   430 			        r = KErrNoMemory;
   431 			        }
   432 			    else
   433 			        {
   434 			        // Actual API call
   435 			        r = FindSettings((TCategoryUid) args[0],
   436 			                aMaxNum, ids, types, lens);
   437 
   438 			        // Send values back to client
   439 			        if (r >= 0)
   440 			            {
   441 			            if(args[3])
   442 			                {
   443 			                TEST_MEMPUT(args[3], ids, _ABS(aMaxNum) * sizeof(TElementId));
   444 
   445 			                if (args[4])
   446 			                    {
   447 			                    TEST_MEMPUT(args[4], types, _ABS(aMaxNum) * sizeof(TSettingType));
   448 			                    }
   449 			                if (args[5])
   450 			                    {
   451 			                    TEST_MEMPUT(args[5], lens, _ABS(aMaxNum) * sizeof(TUint16));
   452 			                    }
   453 			                }
   454 			            }
   455 
   456 			        if (args[5])
   457 			            {
   458 			            TEST_ENTERCS();
   459 			            Kern::Free(lens);
   460 			            TEST_LEAVECS();
   461 			            }
   462 			        }
   463 			    if (args[4])
   464 			        {
   465 			        TEST_ENTERCS();
   466 			        Kern::Free(types);
   467 			        TEST_LEAVECS();
   468 			        }
   469 			    }
   470 			
   471 			if(args[3])
   472 			    {
   473 			    TEST_ENTERCS();
   474 			    Kern::Free(ids);
   475 			    TEST_LEAVECS();
   476 			    }
   477 
   478 			break;
   479 			}
   480 			
   481 		case RHcrSimTestChannel::EHcrFindSettingsPattern:
   482 			{
   483 			// Get list of pointers
   484 			TAny* args[8];
   485 			TEST_MEMGET(a1, args, sizeof(args));
   486 			TInt aMaxNum = (TInt) args[1];
   487 			// Allocate temporary memory
   488 			
   489 			TElementId* ids = NULL;
   490 			TSettingType* types = NULL;
   491 			TUint16* lens = NULL;
   492 						
   493 			if(args[5])
   494 			    {
   495 			    TEST_ENTERCS();
   496 			    ids = (TElementId*) Kern::Alloc(_ABS(aMaxNum) * sizeof(TElementId));
   497 			    if(!ids)
   498 			        return KErrNoMemory;
   499 			    TEST_LEAVECS();    
   500 			    }
   501 
   502 			if (args[6]) // aTypes
   503 			    {
   504 			    TEST_ENTERCS();
   505 			    types = (TSettingType*) Kern::Alloc(_ABS(aMaxNum) * sizeof(TSettingType));
   506 			    TEST_LEAVECS();
   507 			    }
   508 			
   509 			if (types == NULL && args[6])
   510 			    {
   511 			    r = KErrNoMemory;
   512 			    }
   513 			else
   514 			    {
   515 			    if (args[7]) // aLens
   516 			        {
   517 			        TEST_ENTERCS();
   518 			        lens = (TUint16*) Kern::Alloc(_ABS(aMaxNum) * sizeof(TUint16));
   519 			        TEST_LEAVECS();
   520 			        }
   521 			    if (lens == NULL && args[7])
   522 			        {
   523 			        r = KErrNoMemory;
   524 			        }
   525 			    else
   526 			        {
   527 			       
   528 			        // Actual API call
   529 			        r = FindSettings((TCategoryUid) args[0],
   530 			                aMaxNum, (TUint32) args[2], (TUint32) args[3],
   531 			                ids, types, lens);
   532 			       
   533 			        // Send values back to client
   534 			        if (r > 0)
   535 			            {
   536 
   537 			            TEST_MEMPUT(args[5], ids, _ABS(aMaxNum) * sizeof(TElementId));
   538 			            if (args[6])
   539 			                {
   540 			                TEST_MEMPUT(args[6], types, _ABS(aMaxNum) * sizeof(TSettingType));
   541 			                }
   542 			            if (args[7])
   543 			                {
   544 			                TEST_MEMPUT(args[7], lens, _ABS(aMaxNum) * sizeof(TUint16));
   545 			                }
   546 			            }
   547 			        if (args[7])
   548 			            {
   549 			            TEST_ENTERCS();
   550 			            Kern::Free(lens);
   551 			            TEST_LEAVECS();
   552 			            }
   553 			        }
   554 			    if (args[6])
   555 			        {
   556 			        TEST_ENTERCS();
   557 			        Kern::Free(types);
   558 			        TEST_LEAVECS();
   559 			        }
   560 			    }
   561 			
   562 			if(args[5])
   563 			    {
   564 			    TEST_ENTERCS();
   565 			    Kern::Free(ids);
   566 			    TEST_LEAVECS();
   567 			    }
   568 			
   569 			
   570 			break;
   571 			}
   572 		case RHcrSimTestChannel::EHcrGetTypeAndSize:
   573 			{
   574 			// Get list of pointers
   575 			TAny* args[3];
   576 			TEST_MEMGET(a1, args, sizeof(args));
   577 			TSettingId id;
   578 			TEST_MEMGET(args[0], &id, sizeof(TSettingId));
   579 			TSettingType type;
   580 			TUint16 len;
   581 			r = GetTypeAndSize(id, type, len);
   582 			TEST_MEMPUT(args[1], &type, sizeof(TSettingType));
   583 			TEST_MEMPUT(args[2], &len, sizeof(TUint16));
   584 			break;
   585 			}
   586 		case RHcrSimTestChannel::EHcrGetWordSettings:
   587 			{
   588 			// Get list of pointers
   589 			TAny* args[5];
   590 			TEST_MEMGET(a1, args, sizeof(args));
   591 			TInt aNum = (TInt) args[0];
   592 			// Allocate temporary memory
   593 			SSettingId* ids;
   594 			SSettingId* inIds = (SSettingId*)args[1];
   595 			TInt32* vals;
   596 			TSettingType* types= NULL;
   597 			TInt* errors = NULL;
   598 			
   599 			TEST_ENTERCS();
   600 			if(inIds)
   601 			    {
   602 			    ids = (SSettingId*) Kern::Alloc((aNum>=0?aNum:-aNum) * sizeof(SSettingId));
   603 			    //Read data from the user side
   604 			    if (ids == NULL)
   605 			        {
   606 			        r = KErrNoMemory;
   607 			        break;
   608 			        }
   609 
   610 			    TEST_MEMGET(inIds, ids, (aNum>=0?aNum:-aNum) * sizeof(SSettingId));
   611 			    }
   612 			else
   613 			    ids = NULL;
   614 			TEST_LEAVECS();
   615 
   616 			if (args[2]) //values
   617 			    {
   618                 TEST_ENTERCS();
   619                 vals = (TInt32*) Kern::Alloc((aNum>=0?aNum:-aNum) * sizeof(TInt32));
   620                 TEST_LEAVECS();
   621                 if (vals == NULL)
   622                     {
   623                     r = KErrNoMemory;
   624                     break;
   625                     }
   626 			    }
   627 			else
   628 			    vals = NULL;
   629 			
   630 			if (args[3]) // aTypes
   631 			    {
   632 			    TEST_ENTERCS();
   633 			    types = (TSettingType*) Kern::Alloc((aNum>=0?aNum:-aNum) * 
   634                             sizeof(TSettingType));
   635 			    TEST_LEAVECS();
   636 			    }
   637 			if (types == NULL && args[3])
   638 			    {
   639 			    r = KErrNoMemory;
   640 			    }
   641 			else
   642 			    {
   643 			    if (args[4]) // aErrors
   644 			        {
   645 			        TEST_ENTERCS();
   646 			        errors = (TInt*) Kern::Alloc((aNum>=0?aNum:-aNum) * sizeof(TInt));
   647 			        TEST_LEAVECS();
   648 			        }
   649 			    if (errors == NULL && args[4])
   650 			        {
   651 			        r = KErrNoMemory;
   652 			        }
   653 			    else
   654 			        {
   655 			        // Actual API call
   656 			        r = GetWordSettings(aNum, ids, vals, types, errors);
   657 			        // Send values back to client
   658 			        if (r >= 0)
   659 			            {
   660 			            TEST_MEMPUT(args[1], ids, aNum * sizeof(SSettingId));
   661 			            TEST_MEMPUT(args[2], vals, aNum * sizeof(TInt32));
   662 			            if (args[3])
   663 			                {
   664 			                TEST_MEMPUT(args[3], types,(aNum>=0?aNum:-aNum) * sizeof(TSettingType));
   665 			                }
   666 			            if (args[4])
   667 			                {
   668 			                TEST_MEMPUT(args[4], errors, (aNum>=0?aNum:-aNum) * sizeof(TInt));
   669 			                }
   670 			            }
   671 			        if (args[4])
   672 			            {
   673 			            TEST_ENTERCS();
   674 			            Kern::Free(errors);
   675 			            TEST_LEAVECS();
   676 			            }
   677 			        }
   678 			    if (args[3])
   679 			        {
   680 			        TEST_ENTERCS();
   681 			        Kern::Free(types);
   682 			        TEST_LEAVECS();
   683 			        }
   684 			    }
   685 			if (args[2])
   686 			    {
   687                 TEST_ENTERCS();
   688                 Kern::Free(vals);
   689                 TEST_LEAVECS();
   690 			    }
   691 			TEST_ENTERCS();
   692 			if(inIds)
   693 			    Kern::Free(ids);
   694 			TEST_LEAVECS();
   695 
   696 			break;
   697 			}
   698 		case RHcrSimTestChannel::EHcrGetInt64:
   699 			{
   700 			TSettingId setting;
   701 			TInt64 value;
   702 			TEST_MEMGET(a1, &setting, sizeof(TSettingId));
   703 			r = GetInt(setting, value);
   704 			TEST_MEMPUT(a2, &value, sizeof(value));
   705 			break;
   706 			}
   707 		case RHcrSimTestChannel::EHcrGetInt32:
   708 			{
   709 			TSettingId setting;
   710 			TInt32 value;
   711 			TEST_MEMGET(a1, &setting, sizeof(TSettingId));
   712 			r = GetInt(setting, value);
   713 			TEST_MEMPUT(a2, &value, sizeof(value));
   714 			break;
   715 			}
   716 		case RHcrSimTestChannel::EHcrGetInt16:
   717 			{
   718 			TSettingId setting;
   719 			TInt16 value;
   720 			TEST_MEMGET(a1, &setting, sizeof(TSettingId));
   721 			r = GetInt(setting, value);
   722 			TEST_MEMPUT(a2, &value, sizeof(value));
   723 			break;
   724 			}
   725 		case RHcrSimTestChannel::EHcrGetInt8:
   726 			{
   727 			TSettingId setting;
   728 			TInt8 value;
   729 			TEST_MEMGET(a1, &setting, sizeof(TSettingId));
   730 			r = GetInt(setting, value);
   731 			TEST_MEMPUT(a2, &value, sizeof(value));
   732 			break;
   733 			}
   734 		case RHcrSimTestChannel::EHcrGetBool:
   735 			{
   736 			TSettingId setting;
   737 			TBool value;
   738 			TEST_MEMGET(a1, &setting, sizeof(TSettingId));
   739 			r = GetBool(setting, value);
   740 			TEST_MEMPUT(a2, &value, sizeof(value));
   741 			break;
   742 			}
   743 		case RHcrSimTestChannel::EHcrGetDataArray:
   744 			{
   745 			// Get list of pointers
   746 			TAny* args[4];
   747 			TEST_MEMGET(a1, args, sizeof(args));
   748 			TUint maxlen = (TUint) args[1];
   749 			// Retrieve structures from client
   750 			TSettingId id;
   751 			TEST_MEMGET(args[0], &id, sizeof(TSettingId));
   752 			// Allocate temporary memory
   753 			TUint16 len;
   754 			TUint8* value;
   755 			TEST_ENTERCS();
   756 			value = (TUint8*) Kern::Alloc(maxlen * sizeof(TUint8));
   757 			TEST_LEAVECS();
   758 			if (value == NULL)
   759 				{
   760 				r = KErrNoMemory;
   761 				}
   762 			else
   763 				{
   764 				// Actual API call
   765 				r = GetData(id, (TUint16) maxlen,
   766 							value, len);
   767 				// Send value back to client
   768 				if (!r)
   769 					{
   770 					TEST_MEMPUT(args[2], value, maxlen * sizeof(TUint8));
   771 					TEST_MEMPUT(args[3], &len, sizeof(TUint16));
   772 					}
   773 				TEST_ENTERCS();
   774 				Kern::Free(value);
   775 				TEST_LEAVECS();
   776 				}
   777 			break;
   778 			}
   779 		case RHcrSimTestChannel::EHcrGetDataDes:
   780 			{
   781 			TSettingId setting;
   782 			TEST_MEMGET(a1, &setting, sizeof(TSettingId));
   783 			TInt userdes[sizeof(TDes8) / sizeof(TInt) + 1];
   784 			TEST_MEMGET(a2, userdes, sizeof(TDes8));
   785 			HBuf8* value;
   786 			TEST_ENTERCS();
   787 			value = HBuf8::New(userdes[1]);
   788 			TEST_LEAVECS();
   789 			if (value == NULL)
   790 				{
   791 				r = KErrNoMemory;
   792 				}
   793 			else
   794 				{
   795 				r = GetData(setting, *value);
   796 				TEST_DESPUT(a2, *value);
   797 				TEST_ENTERCS();
   798 				delete value;
   799 				TEST_LEAVECS();
   800 				}
   801 			break;
   802 			}
   803 		case RHcrSimTestChannel::EHcrGetUInt64:
   804 			{
   805 			TSettingId setting;
   806 			TUint64 value;
   807 			TEST_MEMGET(a1, &setting, sizeof(TSettingId));
   808 			r = GetUInt(setting, value);
   809 			TEST_MEMPUT(a2, &value, sizeof(value));
   810 			break;
   811 			}
   812 		case RHcrSimTestChannel::EHcrGetUInt32:
   813 			{
   814 			TSettingId setting;
   815 			TUint32 value;
   816 			TEST_MEMGET(a1, &setting, sizeof(TSettingId));
   817 			r = GetUInt(setting, value);
   818 			TEST_MEMPUT(a2, &value, sizeof(value));
   819 			break;
   820 			}
   821 		case RHcrSimTestChannel::EHcrGetUInt16:
   822 			{
   823 			TSettingId setting;
   824 			TUint16 value;
   825 			TEST_MEMGET(a1, &setting, sizeof(TSettingId));
   826 			r = GetUInt(setting, value);
   827 			TEST_MEMPUT(a2, &value, sizeof(value));
   828 			break;
   829 			}
   830 		case RHcrSimTestChannel::EHcrGetUInt8:
   831 			{
   832 			TSettingId setting;
   833 			TUint8 value;
   834 			TEST_MEMGET(a1, &setting, sizeof(TSettingId));
   835 			r = GetUInt(setting, value);
   836 			TEST_MEMPUT(a2, &value, sizeof(value));
   837 			break;
   838 			}
   839 		case RHcrSimTestChannel::EHcrGetArrayInt:
   840 			{
   841 			// Get list of pointers
   842 			TAny* args[4];
   843 			TEST_MEMGET(a1, args, sizeof(args));
   844 			TUint maxlen = (TUint) args[1];
   845 			// Retrieve structures from client
   846 			TSettingId id;
   847 			TEST_MEMGET(args[0], &id, sizeof(TSettingId));
   848 			// Allocate temporary memory
   849 			TUint16 len;
   850 			TInt32* value;
   851 			TEST_ENTERCS();
   852 			value = (TInt32*) Kern::Alloc(maxlen);
   853 			TEST_LEAVECS();
   854 			if (value == NULL)
   855 				{
   856 				r = KErrNoMemory;
   857 				}
   858 			else
   859 				{
   860 				// Actual API call
   861 				r = GetArray(id, (TUint16) maxlen,
   862 							value, len);
   863 				// Send value back to client
   864 				if (!r)
   865 					{
   866 					TEST_MEMPUT(args[2], value, maxlen);
   867 					TEST_MEMPUT(args[3], &len, sizeof(TUint16));
   868 					}
   869 				TEST_ENTERCS();
   870 				Kern::Free(value);
   871 				TEST_LEAVECS();
   872 				}
   873 			break;
   874 			}
   875 		case RHcrSimTestChannel::EHcrGetArrayUInt:
   876 			{
   877 			// Get list of pointers
   878 			TAny* args[4];
   879 			TEST_MEMGET(a1, args, sizeof(args));
   880 			TUint maxlen = (TUint) args[1];
   881 			// Retrieve structures from client
   882 			TSettingId id;
   883 			TEST_MEMGET(args[0], &id, sizeof(TSettingId));
   884 			// Allocate temporary memory
   885 			TUint16 len;
   886 			TUint32* value;
   887 			TEST_ENTERCS();
   888 			value = (TUint32*) Kern::Alloc(maxlen);
   889 			TEST_LEAVECS();
   890 			if (value == NULL)
   891 				{
   892 				r = KErrNoMemory;
   893 				}
   894 			else
   895 				{
   896 				// Actual API call
   897 				r = GetArray(id, (TUint16) maxlen,
   898 							value, len);
   899 				// Send value back to client
   900 				if (!r)
   901 					{
   902 					TEST_MEMPUT(args[2], value, maxlen);
   903 					TEST_MEMPUT(args[3], &len, sizeof(TUint16));
   904 					}
   905 				TEST_ENTERCS();
   906 				Kern::Free(value);
   907 				TEST_LEAVECS();
   908 				}
   909 			break;
   910 			}
   911 		case RHcrSimTestChannel::EHcrGetStringArray:
   912 			{
   913 			// Get list of pointers
   914 			TAny* args[4];
   915 			TEST_MEMGET(a1, args, sizeof(args));
   916 			TUint maxlen = (TUint) args[1];
   917 			// Retrieve structures from client
   918 			TSettingId id;
   919 			TEST_MEMGET(args[0], &id, sizeof(TSettingId));
   920 			// Allocate temporary memory
   921 			TUint16 len;
   922 			TText8* value;
   923 			TEST_ENTERCS();
   924 			value = (TText8*) Kern::Alloc(maxlen * sizeof(TText8));
   925 			TEST_LEAVECS();
   926 			if (value == NULL)
   927 				{
   928 				r = KErrNoMemory;
   929 				}
   930 			else
   931 				{
   932 				// Actual API call
   933 				r = GetString(id, (TUint16) maxlen,
   934 							value, len);
   935 				// Send value back to client
   936 				if (!r)
   937 					{
   938 					TEST_MEMPUT(args[2], value, maxlen * sizeof(TText8));
   939 					TEST_MEMPUT(args[3], &len, sizeof(TUint16));
   940 					}
   941 				TEST_ENTERCS();
   942 				Kern::Free(value);
   943 				TEST_LEAVECS();
   944 				}
   945 			break;
   946 			}
   947 		case RHcrSimTestChannel::EHcrGetStringDes:
   948 			{
   949 			TSettingId setting;
   950 			TEST_MEMGET(a1, &setting, sizeof(TSettingId));
   951 			TInt userdes[sizeof(TDes8) / sizeof(TInt) + 1];
   952 			TEST_MEMGET(a2, userdes, sizeof(TDes8));
   953 			HBuf8* value;
   954 			TEST_ENTERCS();
   955 			value = HBuf8::New(userdes[1]);
   956 			TEST_LEAVECS();
   957 			if (value == NULL)
   958 				{
   959 				r = KErrNoMemory;
   960 				}
   961 			else
   962 				{
   963 				r = GetString(setting, *value);
   964 				TEST_DESPUT(a2, *value);
   965 				TEST_ENTERCS();
   966 				delete value;
   967 				TEST_LEAVECS();
   968 				}
   969 			break;
   970 			}
   971 #ifndef HCRTEST_USERSIDE_INTERFACE
   972 		case RHcrSimTestChannel::EHcrInitExtension:
   973 			{
   974 			PslConfigurationFlags = (TInt) a1;
   975 			TEST_ENTERCS();
   976 			r = InitExtension();
   977 			TEST_LEAVECS();
   978 			break;
   979 			}
   980 		case RHcrSimTestChannel::EHcrSwitchRepository:
   981 			{
   982 			TBuf8<80> filename;
   983 			TEST_DESGET(a1, filename);
   984 			TText8 filestr[81];
   985 			memcpy(filestr, filename.Ptr(), filename.Length());
   986 			filestr[filename.Length()] = 0; // Zero-terminate string
   987 			TText8* pfile = filestr;
   988 			if (filename.Length() == 0)
   989 				{
   990 				pfile = NULL;
   991 				}
   992 			if ((TUint) a2 == HCRInternal::ECoreRepos)
   993 				{
   994 				r = HCRSingleton->SwitchRepository(pfile, HCRInternal::ECoreRepos);
   995 				}
   996 			else if ((TUint) a2 == HCRInternal::EOverrideRepos)
   997 				{
   998 				r = HCRSingleton->SwitchRepository(pfile, HCRInternal::EOverrideRepos);
   999 				}
  1000 			break;
  1001 			}
  1002 		case RHcrSimTestChannel::EHcrCheckIntegrity:
  1003 			{
  1004 			r = HCRSingleton->CheckIntegrity();
  1005 			break;
  1006 			}
  1007 #endif // HCRTEST_USERSIDE_INTERFACE
  1008 		case RHcrSimTestChannel::EHcrGetInitExtensionTestResults:
  1009 			{
  1010 			r = KErrNone;
  1011 			TEST_MEMPUT(a1, (TAny*) &TestKernExtensionTestLine, sizeof(TInt));
  1012 			TEST_MEMPUT(a2, (TAny*) &TestKernExtensionTestError, sizeof(TInt));
  1013 			}
  1014 			break;
  1015 		case RHcrSimTestChannel::EHcrHasRepositoryInSmr:
  1016 			{
  1017 			r = KErrNone;
  1018 			TBool smr;
  1019 			TBool smrrep;
  1020 			HasRepositoryInSmr(smr, smrrep);
  1021 			TEST_MEMPUT(a1, (TAny*) &smr, sizeof(TBool));
  1022 			TEST_MEMPUT(a2, (TAny*) &smrrep, sizeof(TBool));
  1023 			}
  1024 			break;
  1025 		case RHcrSimTestChannel::EHcrBenchmarkGetSettingInt:
  1026 			{
  1027 			r = KErrNone;
  1028 			TUint i;
  1029 			TSettingId setting;
  1030 			TInt32 value;
  1031 			TEST_MEMGET(a1, &setting, sizeof(TSettingId));
  1032 			//
  1033 			TUint32 start = NKern::TickCount();
  1034 			for (i = 0; i < KTestBenchmarkIterations; i++)
  1035 				{
  1036 				r |= GetInt(setting, value);
  1037 				}
  1038 			TUint32 end = NKern::TickCount();
  1039 			//
  1040 			TUint32 ms;
  1041 			ms = ((end - start) * NKern::TickPeriod()) / 1000;
  1042 			TEST_MEMPUT(a2, (TAny*) &ms, sizeof(TUint32));
  1043 			}
  1044 			break;
  1045 		case RHcrSimTestChannel::EHcrBenchmarkGetSettingArray:
  1046 			{
  1047 			r = KErrNone;
  1048 			TUint i;
  1049 			TSettingId setting;
  1050 			TText8* value;
  1051 			TEST_MEMGET(a1, &setting, sizeof(TSettingId));
  1052 			// Allocate temporary memory
  1053 			TEST_ENTERCS();
  1054 			value = (TText8*) Kern::Alloc(KMaxSettingLength);
  1055 			TEST_LEAVECS();
  1056 			if (value == NULL)
  1057 				{
  1058 				r = KErrNoMemory;
  1059 				}
  1060 			else
  1061 				{
  1062 				TUint16 len;
  1063 				TUint32 start = NKern::TickCount();
  1064 				for (i = 0; i < KTestBenchmarkIterations; i++)
  1065 					{
  1066 					r |= GetString(setting, (TUint16) KMaxSettingLength, value, len);
  1067 					}
  1068 				TUint32 end = NKern::TickCount();
  1069 				//
  1070 				TUint32 ms;
  1071 				ms = ((end - start) * NKern::TickPeriod()) / 1000;
  1072 				TEST_MEMPUT(a2, (TAny*) &ms, sizeof(TUint32));
  1073 				TEST_ENTERCS();
  1074 				Kern::Free(value);
  1075 				TEST_LEAVECS();
  1076 				}
  1077 			}
  1078 			break;
  1079 		case RHcrSimTestChannel::EHcrBenchmarkGetSettingDes:
  1080 			{
  1081 			r = KErrNone;
  1082 			TUint i;
  1083 			TSettingId setting;
  1084 			TBuf8<KMaxSettingLength> value;
  1085 			TEST_MEMGET(a1, &setting, sizeof(TSettingId));
  1086 			TUint32 start = NKern::TickCount();
  1087 			for (i = 0; i < KTestBenchmarkIterations; i++)
  1088 				{
  1089 				r |= GetString(setting, value);
  1090 				}
  1091 			TUint32 end = NKern::TickCount();
  1092 			//
  1093 			TUint32 ms;
  1094 			ms = ((end - start) * NKern::TickPeriod()) / 1000;
  1095 			TEST_MEMPUT(a2, (TAny*) &ms, sizeof(TUint32));
  1096 			}
  1097 			break;
  1098 		case RHcrSimTestChannel::EHcrBenchmarkFindNumSettingsInCategory:
  1099 			{
  1100 			r = 0;
  1101 			TUint i;
  1102 			TUint32 start = NKern::TickCount();
  1103 			for (i = 0; i < KTestBenchmarkIterations; i++)
  1104 				{
  1105 				r |= FindNumSettingsInCategory((TCategoryUid) a1);
  1106 				}
  1107 			TUint32 end = NKern::TickCount();
  1108 			//
  1109 			TUint32 ms;
  1110 			ms = ((end - start) * NKern::TickPeriod()) / 1000;
  1111 			TEST_MEMPUT(a2, (TAny*) &ms, sizeof(TUint32));
  1112 			}
  1113 			break;
  1114 		case RHcrSimTestChannel::EHcrBenchmarkFindSettings:
  1115 			{
  1116 			r = 0;
  1117 			TUint i;
  1118 
  1119 			TElementId* ids;
  1120 			TSettingType* types;
  1121 			TUint16* lens;
  1122 			TEST_ENTERCS();
  1123 			ids = (TElementId*) Kern::Alloc(KTestBenchmarkNumberOfSettingsInCategory * sizeof(TElementId));
  1124 			TEST_LEAVECS();
  1125 			if (!ids)
  1126 				{
  1127 				TEST(EFalse);
  1128 				r = KErrNoMemory;
  1129 				}
  1130 			else
  1131 				{
  1132 				
  1133 				TEST_ENTERCS();
  1134 				types = (TSettingType*) Kern::Alloc(KTestBenchmarkNumberOfSettingsInCategory * sizeof(TSettingType));
  1135 				TEST_LEAVECS();
  1136 				if (!types)
  1137 					{
  1138 					TEST(EFalse);
  1139 					r = KErrNoMemory;
  1140 					}
  1141 				else
  1142 					{
  1143 					TEST_ENTERCS();
  1144 					lens = (TUint16*) Kern::Alloc(KTestBenchmarkNumberOfSettingsInCategory * sizeof(TUint16));
  1145 					TEST_LEAVECS();
  1146 					if (!lens)
  1147 						{
  1148 						TEST(EFalse);
  1149 						r = KErrNoMemory;
  1150 						}
  1151 					else
  1152 						{
  1153 
  1154 						TUint32 start = NKern::TickCount();
  1155 						for (i = 0; i < KTestBenchmarkIterations; i++)
  1156 							{
  1157 							r |= FindSettings((TCategoryUid) a1,
  1158 										KTestBenchmarkNumberOfSettingsInCategory,
  1159 										ids, types, lens);
  1160 							}
  1161 						TUint32 end = NKern::TickCount();
  1162 						//
  1163 						
  1164 						TUint32 ms;
  1165 						ms = ((end - start) * NKern::TickPeriod()) / 1000;
  1166 						TEST_MEMPUT(a2, (TAny*) &ms, sizeof(TUint32));
  1167 						TEST_ENTERCS();
  1168 						Kern::Free(lens);
  1169 						TEST_LEAVECS();
  1170 						}
  1171 					TEST_ENTERCS();
  1172 					Kern::Free(types);
  1173 					TEST_LEAVECS();
  1174 					}
  1175 				TEST_ENTERCS();
  1176 				Kern::Free(ids);
  1177 				TEST_LEAVECS();
  1178 				}
  1179 			}
  1180 			break;
  1181 		case RHcrSimTestChannel::EHcrBenchmarkGetTypeAndSize:
  1182 			{
  1183 			r = KErrNone;
  1184 			TUint i;
  1185 			TSettingId setting;
  1186 			TSettingType type;
  1187 			TUint16 len;
  1188 			TEST_MEMGET(a1, &setting, sizeof(TSettingId));
  1189 			//
  1190 			TUint32 start = NKern::TickCount();
  1191 			for (i = 0; i < KTestBenchmarkIterations; i++)
  1192 				{
  1193 				r |= GetTypeAndSize(setting, type, len);
  1194 				}
  1195 			TUint32 end = NKern::TickCount();
  1196 			//
  1197 			TUint32 ms;
  1198 			ms = ((end - start) * NKern::TickPeriod()) / 1000;
  1199 			TEST_MEMPUT(a2, (TAny*) &ms, sizeof(TUint32));
  1200 			}
  1201 			break;
  1202 		case RHcrSimTestChannel::EHcrBenchmarkGetWordSettings:
  1203 			{
  1204 			r = 0;
  1205 			TUint i;
  1206 			SSettingId* ids;
  1207 			TSettingType* types;
  1208 			TCategoryUid catId = (TCategoryUid)a1;
  1209 			TInt32* values;
  1210 			TInt* errors;
  1211 			TEST_ENTERCS();
  1212 			//We allocate here KTestBenchmarkNumberOfSettingsInCategory - 1 because
  1213 			//last element in the category is a large setting
  1214 			ids = (SSettingId*) Kern::Alloc((KTestBenchmarkNumberOfSettingsInCategory - 1) * sizeof(SSettingId));
  1215 			TEST_LEAVECS();
  1216 			if (!ids)
  1217 				{
  1218 				TEST(EFalse);
  1219 				r = KErrNoMemory;
  1220 				}
  1221 			else
  1222 				{
  1223 				for(TUint eId =0; eId < KTestBenchmarkNumberOfSettingsInCategory - 1; eId++ )
  1224 				    {
  1225 				    ids[eId].iCat = catId;
  1226 				    //First element has value 1, second 2, third 3 and so on
  1227 				    ids[eId].iKey = eId + 1;
  1228 				    }
  1229 				TEST_ENTERCS();
  1230 				types = (TSettingType*) Kern::Alloc((KTestBenchmarkNumberOfSettingsInCategory - 1) * sizeof(TSettingType));
  1231 				TEST_LEAVECS();
  1232 				if (!types)
  1233 					{
  1234 					TEST(EFalse);
  1235 					r = KErrNoMemory;
  1236 					}
  1237 				else
  1238 					{
  1239 					TEST_ENTERCS();
  1240 					values = (TInt32*) Kern::Alloc((KTestBenchmarkNumberOfSettingsInCategory - 1) * sizeof(TInt32));
  1241 					TEST_LEAVECS();
  1242 					if (!values)
  1243 						{
  1244 						TEST(EFalse);
  1245 						r = KErrNoMemory;
  1246 						}
  1247 					else
  1248 						{
  1249 						TEST_ENTERCS();
  1250 						errors = (TInt*) Kern::Alloc((KTestBenchmarkNumberOfSettingsInCategory - 1) * sizeof(TInt));
  1251 						TEST_LEAVECS();
  1252 						if (!errors)
  1253 							{
  1254 							TEST(EFalse);
  1255 							r = KErrNoMemory;
  1256 							}
  1257 						else
  1258 							{
  1259 							TUint32 start = NKern::TickCount();
  1260 							for (i = 0; i < KTestGetMultipleBenchmarkIterations; i++)
  1261 								{
  1262 								r |= GetWordSettings(KTestBenchmarkNumberOfSettingsInCategory - 1, ids, values, types, errors);
  1263 								}
  1264 							TUint32 end = NKern::TickCount();
  1265 							//
  1266 							TUint32 ms;
  1267 							ms = ((end - start) * NKern::TickPeriod()) / 1000;
  1268 							TEST_MEMPUT(a2, (TAny*) &ms, sizeof(TUint32));
  1269 							TEST_ENTERCS();
  1270 							Kern::Free(errors);
  1271 							TEST_LEAVECS();
  1272 							}
  1273 						TEST_ENTERCS();
  1274 						Kern::Free(values);
  1275 						TEST_LEAVECS();
  1276 						}
  1277 					TEST_ENTERCS();
  1278 					Kern::Free(types);
  1279 					TEST_LEAVECS();
  1280 					}
  1281 				TEST_ENTERCS();
  1282 				Kern::Free(ids);
  1283 				TEST_LEAVECS();
  1284 				}
  1285 			}
  1286 			break;
  1287 		}
  1288 	return r;
  1289 	}