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