resourcemgmt/hwresourcesmgr/test/TestCapsHWRMPolicing/src/CSuite.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // @file
       
    15 // for (WINS && !EKA2) versions will be xxxServer.Dll and require a thread to be started
       
    16 // in the process of the client. The client initialises the server by calling the
       
    17 // one and only ordinal.
       
    18 // 
       
    19 //
       
    20 
       
    21 // EPOC includes
       
    22 #include <e32base.h>
       
    23 #include <e32cmn.h>
       
    24 
       
    25 // Type definitions
       
    26 #define UNUSED_VAR(a) a = a
       
    27 
       
    28 #if (!defined TS_HWRM_API_PPLICING_SERVER_H_)
       
    29 	#include "CSuite.h"
       
    30 #endif
       
    31 
       
    32 
       
    33 //ADD TEST STEP HEADERS HERE
       
    34 #include "HWRMFmTxOn_CStep.h"
       
    35 #include "HWRMFmTxAutoFreqOff_CStep.h"
       
    36 #include "HWRMFmTxAutoFreqOn_CStep.h"
       
    37 #include "HWRMFmTxCancelGetNextClearFreq_CStep.h"
       
    38 #include "HWRMFmTxCancelSetNextClearFreq_CStep.h"
       
    39 #include "HWRMFmTxCleanup_CStep.h"
       
    40 #include "HWRMFmTxClearRdsData_CStep.h"
       
    41 #include "HWRMFmTxClearRtData_CStep.h"
       
    42 #include "HWRMFmTxGetFreqRange_CStep.h"
       
    43 #include "HWRMFmTxGetNextClearFreq_CStep.h"
       
    44 #include "HWRMFmTxGetNextClearFreqArray_CStep.h"
       
    45 #include "HWRMFmTxOff_CStep.h"
       
    46 #include "HWRMFmTxOn_CStep.h"
       
    47 #include "HWRMFmTxRelease_CStep.h"
       
    48 #include "HWRMFmTxReserve_CStep.h"
       
    49 #include "HWRMFmTxSetFreq_CStep.h"
       
    50 #include "HWRMFmTxSetNextClearFreq_CStep.h"
       
    51 #include "HWRMFmTxSetRadiotext_CStep.h"
       
    52 #include "HWRMFmTxSetRadiotextPlus1_CStep.h"
       
    53 #include "HWRMFmTxSetRadiotextPlus2_CStep.h"
       
    54 #include "HWRMFmTxSetRadiotextPlus3_CStep.h"
       
    55 #include "HWRMFmTxSetRdsLanguageId_CStep.h"
       
    56 #include "HWRMFmTxSetRdsMs_CStep.h"
       
    57 #include "HWRMFmTxSetRdsPty_CStep.h"
       
    58 #include "HWRMFmTxSetRdsPtyn_CStep.h"
       
    59 
       
    60 
       
    61 
       
    62 // __EDIT_ME__ - Substitute the name of your test server 
       
    63 _LIT(KServerName,"Cap_HWRM_API_Policing_sc");
       
    64 // __EDIT_ME__ - Use your own server class name
       
    65 
       
    66 CTestHWRM_API_PolicingServer* CTestHWRM_API_PolicingServer::NewL()
       
    67 /**
       
    68  * @return - Instance of the test server
       
    69  * Same code for Secure and non-secure variants
       
    70  * Called inside the MainL() function to create and start the
       
    71  * CTestServer derived server.
       
    72  */
       
    73 	{
       
    74 // __EDIT_ME__ - Use your own server class name
       
    75 	CTestHWRM_API_PolicingServer * server = new (ELeave) CTestHWRM_API_PolicingServer();
       
    76 	CleanupStack::PushL(server);
       
    77 	// CServer base class call
       
    78 	server->StartL(KServerName);
       
    79 	CleanupStack::Pop(server);
       
    80 	return server;
       
    81 	}
       
    82 
       
    83 CTestStep* CTestHWRM_API_PolicingServer::CreateTestStep(const TDesC& aStepName)
       
    84 /**
       
    85  * @return - A CTestStep derived instance
       
    86  * Secure and non-secure variants
       
    87  * Implementation of CTestServer pure virtual
       
    88  */
       
    89 	{
       
    90 	 CTestStep* testStep = NULL;
       
    91 	// add test steps
       
    92 
       
    93 		if (aStepName == _L("CHWRMFmTxOnStep"))
       
    94 			{
       
    95 			testStep =  new(ELeave) CHWRMFmTxOnStep  ;
       
    96 			return testStep;
       
    97 			}
       
    98 		else if (aStepName == _L("CHWRMFmTxOffStep"))
       
    99 			{
       
   100 			testStep =  new(ELeave) CHWRMFmTxOffStep  ;
       
   101 			return testStep;
       
   102 			}
       
   103 		else if (aStepName == _L("CHWRMFmTxSetFreqStep"))
       
   104 			{
       
   105 			testStep =  new(ELeave) CHWRMFmTxSetFreqStep  ;
       
   106 			return testStep;
       
   107 			}
       
   108 		else if (aStepName == _L("CHWRMFmTxSetNextClearFreqStep"))
       
   109 			{
       
   110 			testStep =  new(ELeave) CHWRMFmTxSetNextClearFreqStep  ;
       
   111 			return testStep;
       
   112 			}
       
   113 		else if (aStepName == _L("CHWRMFmTxAutoFreqOnStep"))
       
   114 			{
       
   115 			testStep =  new(ELeave) CHWRMFmTxAutoFreqOnStep  ;
       
   116 			return testStep;
       
   117 			}
       
   118 		else if (aStepName == _L("CHWRMFmTxSetRdsPtyStep"))
       
   119 			{
       
   120 			testStep =  new(ELeave) CHWRMFmTxSetRdsPtyStep  ;
       
   121 			return testStep;
       
   122 			}
       
   123 		else if (aStepName == _L("CHWRMFmTxSetRdsPtynStep"))
       
   124 			{
       
   125 			testStep =  new(ELeave) CHWRMFmTxSetRdsPtynStep  ;
       
   126 			return testStep;
       
   127 			}
       
   128 		else if (aStepName == _L("CHWRMFmTxSetRdsMsStep"))
       
   129 			{
       
   130 			testStep =  new(ELeave) CHWRMFmTxSetRdsMsStep  ;
       
   131 			return testStep;
       
   132 			}
       
   133 		else if (aStepName == _L("CHWRMFmTxSetRdsLanguageIdStep"))
       
   134 			{
       
   135 			testStep =  new(ELeave) CHWRMFmTxSetRdsLanguageIdStep  ;
       
   136 			return testStep;
       
   137 			}
       
   138 		else if (aStepName == _L("CHWRMFmTxClearRdsDataStep"))
       
   139 			{
       
   140 			testStep =  new(ELeave) CHWRMFmTxClearRdsDataStep  ;
       
   141 			return testStep;
       
   142 			}
       
   143 		else if (aStepName == _L("CHWRMFmTxSetRadiotextStep"))
       
   144 			{
       
   145 			testStep =  new(ELeave) CHWRMFmTxSetRadiotextStep  ;
       
   146 			return testStep;
       
   147 			}
       
   148 		else if (aStepName == _L("CHWRMFmTxSetRadiotextPlus1Step"))
       
   149 			{
       
   150 			testStep =  new(ELeave) CHWRMFmTxSetRadiotextPlus1Step  ;
       
   151 			return testStep;
       
   152 			}
       
   153 		else if (aStepName == _L("CHWRMFmTxSetRadiotextPlus2Step"))
       
   154 			{
       
   155 			testStep =  new(ELeave) CHWRMFmTxSetRadiotextPlus2Step  ;
       
   156 			return testStep;
       
   157 			}
       
   158 		else if (aStepName == _L("CHWRMFmTxSetRadiotextPlus3Step"))
       
   159 			{
       
   160 			testStep =  new(ELeave) CHWRMFmTxSetRadiotextPlus3Step  ;
       
   161 			return testStep;
       
   162 			}
       
   163 		else if (aStepName == _L("CHWRMFmTxClearRtDataStep"))
       
   164 			{
       
   165 			testStep =  new(ELeave) CHWRMFmTxClearRtDataStep  ;
       
   166 			return testStep;
       
   167 			}
       
   168 		else if (aStepName == _L("CHWRMFmTxReserveStep"))
       
   169 			{
       
   170 			testStep =  new(ELeave) CHWRMFmTxReserveStep  ;
       
   171 			return testStep;
       
   172 			}
       
   173 		else if (aStepName == _L("CHWRMFmTxReleaseStep"))
       
   174 			{
       
   175 			testStep =  new(ELeave) CHWRMFmTxReleaseStep  ;
       
   176 			return testStep;
       
   177 			}
       
   178 		else if (aStepName == _L("CHWRMFmTxGetFreqRangeStep"))
       
   179 			{
       
   180 			testStep =  new(ELeave) CHWRMFmTxGetFreqRangeStep  ;
       
   181 			return testStep;
       
   182 			}
       
   183 		else if (aStepName == _L("CHWRMFmTxGetNextClearFreqStep"))
       
   184 			{
       
   185 			testStep =  new(ELeave) CHWRMFmTxGetNextClearFreqStep  ;
       
   186 			return testStep;
       
   187 			}
       
   188 		else if (aStepName == _L("CHWRMFmTxGetNextClearFreqArrayStep"))
       
   189 			{
       
   190 			testStep =  new(ELeave) CHWRMFmTxGetNextClearFreqArrayStep  ;
       
   191 			return testStep;
       
   192 			}
       
   193 		else if (aStepName == _L("CHWRMFmTxCancelGetNextClearFreqStep"))
       
   194 			{
       
   195 			testStep =  new(ELeave) CHWRMFmTxCancelGetNextClearFreqStep  ;
       
   196 			return testStep;
       
   197 			}
       
   198 		else if (aStepName == _L("CHWRMFmTxCancelSetNextClearFreqStep"))
       
   199 			{
       
   200 			testStep =  new(ELeave) CHWRMFmTxCancelSetNextClearFreqStep  ;
       
   201 			return testStep;
       
   202 			}
       
   203 		else if (aStepName == _L("CHWRMFmTxCleanupStep"))
       
   204 			{
       
   205 			testStep =  new(ELeave) CHWRMFmTxCleanupStep  ;
       
   206 			return testStep;
       
   207 			}
       
   208 		else if (aStepName == _L("CHWRMFmTxAutoFreqOffStep"))
       
   209 			{
       
   210 			testStep =  new(ELeave) CHWRMFmTxAutoFreqOffStep  ;
       
   211 			return testStep;
       
   212 			}
       
   213 
       
   214 		return testStep;
       
   215 	 }
       
   216 
       
   217 	
       
   218 
       
   219 // Secure variants much simpler
       
   220 // Just an E32Main and a MainL()
       
   221 LOCAL_C void MainL()
       
   222 /**
       
   223  * Secure variant
       
   224  * Much simpler, uses the new Rendezvous() call to sync with the client
       
   225  */
       
   226 	{
       
   227 #if (defined __DATA_CAGING__)
       
   228 	RProcess().DataCaging(RProcess::EDataCagingOn);
       
   229 	RProcess().DataCaging(RProcess::ESecureApiOn);
       
   230 #endif
       
   231 	CActiveScheduler* sched=NULL;
       
   232 	sched=new(ELeave) CActiveScheduler;
       
   233 	CActiveScheduler::Install(sched);
       
   234 // __EDIT_ME__ - Use your own server class name
       
   235 	CTestHWRM_API_PolicingServer* server = NULL;
       
   236 	// Create the CTestServer derived server
       
   237 	TRAPD(err,server = CTestHWRM_API_PolicingServer::NewL());
       
   238 	if(!err)
       
   239 		{
       
   240 		// Sync with the client and enter the active scheduler
       
   241 		RProcess::Rendezvous(KErrNone);
       
   242 		sched->Start();
       
   243 		}
       
   244 	delete server;
       
   245 	delete sched;
       
   246 	}
       
   247 
       
   248 
       
   249 GLDEF_C TInt E32Main()
       
   250 /**
       
   251  * @return - Standard Epoc error code on process exit
       
   252  * Secure variant only
       
   253  * Process entry point. Called by client using RProcess API
       
   254  */
       
   255 	{
       
   256 	__UHEAP_MARK;
       
   257 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
   258 	if(cleanup == NULL)
       
   259 		{
       
   260 		return KErrNoMemory;
       
   261 		}
       
   262 	TRAPD(err,MainL());
       
   263 	UNUSED_VAR(err); //Used to supress build warnings
       
   264 	delete cleanup;
       
   265 	__UHEAP_MARKEND;
       
   266 	return KErrNone;
       
   267     }
       
   268 
       
   269 
       
   270 TVerdict CCapabilityTestStep::doTestStepPreambleL( void )
       
   271 	{
       
   272 	//If Preamble is not required just pass a success value
       
   273 	TVerdict testResult = CTestStep::doTestStepPreambleL();
       
   274 	
       
   275 	
       
   276 	return TestStepResult();
       
   277 	
       
   278 	}
       
   279 TVerdict CCapabilityTestStep::doTestStepPostambleL( void )
       
   280 	{
       
   281 	//If Postamble is not required just pass a success value
       
   282 	TVerdict testResult = CTestStep::doTestStepPostambleL();
       
   283 
       
   284 	return TestStepResult();
       
   285 	
       
   286 	}
       
   287 
       
   288 // Moved from CStep.cpp
       
   289 
       
   290 enum TVerdict CCapabilityTestStep::doTestStepL()
       
   291 	{
       
   292 	//DEF! INFO_PRINTF2(_L("%S - Starting ..."), &iTestStepName);
       
   293 
       
   294 	//The MainThread()creates a separate thread that executes SendReceive
       
   295 	TVerdict vResult = MainThread();
       
   296 	
       
   297 	SetTestStepResult(vResult);
       
   298 	return TestStepResult();
       
   299 	}
       
   300 
       
   301 /*
       
   302 ThreadStartFn:
       
   303 Called by:	The Child thread
       
   304 Function:	Calls the Exec_SendReceive
       
   305 */
       
   306 static TInt ThreadStartFn( TAny * ptr )
       
   307 	{
       
   308 	return(((CCapabilityTestStep *)ptr)->Exec_SendReceive());
       
   309 	}
       
   310 
       
   311 /*
       
   312 TVerdict GetVerdict(TInt aAPIretValue)
       
   313 
       
   314 Called by: "MainThread" for returning verdict
       
   315 
       
   316 Parameters(TInt aRetValue) :	0 if API call gets thru without any rejection
       
   317 								1 if API call is rejected for capability error	
       
   318 */
       
   319 enum TVerdict CCapabilityTestStep::GetVerdict(TInt aAPIretValue)
       
   320 	{
       
   321 	TVerdict vVerdict[] = {EPass, EFail};
       
   322 
       
   323 	//please leave the following if/else block as the information printed by INFO_PRINTF1 is used bu CapTestSumm
       
   324 	if(iExpect_Rejection)//[Inverse Test] EPass for 1 while EFail for 0
       
   325 		{
       
   326 		INFO_PRINTF1(_L("Test Expected to Fail due to lack of capabilities"));
       
   327 		return vVerdict[(aAPIretValue)?0:1];
       
   328 		
       
   329 		}
       
   330 	else //[Direct Test] EPass for 0 while EFail for 1
       
   331 		{
       
   332 		INFO_PRINTF1(_L("Test Expected to Pass with correct capabilities"));
       
   333 		return vVerdict[(aAPIretValue)?1:0];
       
   334 		}
       
   335 	}
       
   336 
       
   337 
       
   338 /*
       
   339 TVerdict MainThread()
       
   340 
       
   341 Called by: "doTestStepL"
       
   342 
       
   343 Purpose:	Creates the child thread(which calls the respective function with regard
       
   344 			to the server and also implements the Message Call). Then this fn.waits for the
       
   345 			completion of the childthread( doesnt matter how the thread did die!)
       
   346 
       
   347 Return Value(Verdict of the TestStep):
       
   348 
       
   349 			A.Reporting PASS/FAIL
       
   350 				Direct Test:
       
   351 						When a message call gets thru. Please note that in such cases
       
   352 						actually the implementation of the message has started. As we
       
   353 						are passing "0" Parameters, server may panic, though our botheration
       
   354 						stops once the call gets thru.
       
   355 						NOTE:	The style is the same when CONNECTION capabilities
       
   356 								are tested, the only diff is you dont have to expect a 
       
   357 								panic from server
       
   358 				Inverse Test:
       
   359 						The call should be either failed or panicked with
       
   360 						"KErrPermissionDenied" flag. 
       
   361 
       
   362 				General Case:
       
   363 						If a thread creation failed or if the server couldnt be connected
       
   364 						apart from the above two cases, then a FAIL is reported
       
   365 			
       
   366 			B.Reporting INCONCLUSIVE
       
   367 						Any panic say from unexpected source (eg:KERN-EXEC) will be
       
   368 						reported INCONCLUSIVE														
       
   369 */
       
   370 TVerdict CCapabilityTestStep::MainThread()
       
   371 	{
       
   372 
       
   373 	TBuf<100>	tExitCategory;
       
   374 	TInt		tExitReason = 0;		
       
   375 	TBuf<100>	TestStyle;
       
   376 
       
   377 	iExpect_Rejection?TestStyle = _L("Inverse"):TestStyle = _L("Direct");
       
   378 	TCapabilitySet theCaps =  TSecurityInfo(RProcess()).iCaps ;
       
   379 	const TInt KMaxTestThreadHeapSize = 0x10000;
       
   380 
       
   381 	//Initialize return values
       
   382 	iResult_SR = iResult_Server = KErrNone;	
       
   383 		
       
   384 
       
   385 	// Create a child thread, with a new heap
       
   386 	TInt nRes_Thread =	tChildThread.Create(
       
   387 						ChildThread_SR,
       
   388 						ThreadStartFn,
       
   389 						KDefaultStackSize,
       
   390 						KMinHeapSize,
       
   391 						KMaxTestThreadHeapSize,
       
   392 						this,			
       
   393 						EOwnerProcess);
       
   394 
       
   395 
       
   396 	if(nRes_Thread == KErrNone)//Thread Created
       
   397 		{
       
   398 
       
   399 		//Let me know when the thread is dead
       
   400 		TRequestStatus ThreadStatus;
       
   401 		tChildThread.Logon(ThreadStatus);
       
   402 		tChildThread.Resume(); 
       
   403 		//Is the thread dead?
       
   404 		User::WaitForRequest( ThreadStatus );
       
   405 		
       
   406 		//yes, he is dead. RIP!  Now the Killer's profile
       
   407 		tExitCategory	=	tChildThread.ExitCategory();
       
   408 		tExitReason		=	tChildThread.ExitReason();
       
   409 
       
   410 	
       
   411 		//Somebody Please say what are we testing!!		
       
   412 		if(iSessionCreated && (SR_MESSAGE_ID >=0))//Flag set by Child thread when connected to Server
       
   413 		{
       
   414 			//DEF INFO_PRINTF5(_L("Connected to Server(%S) for %S Test [MessageID: %d,Req.Cap: 0x%x,Present.Cap: 0x%x]"),&SR_ServerName,&TestStyle,SR_MESSAGE_ID,iStepCap,TSecurityInfo(RProcess()));			
       
   415 		}
       
   416 		else if(SR_MESSAGE_ID < 0)
       
   417 		{
       
   418 			//DEF INFO_PRINTF5(_L("Testing Connection capabilities[%S Test] for Server(%S)  [Req.Cap: 0x%x,Present.Cap: 0x%x]"),&TestStyle,
       
   419 			//&SR_ServerName,TSecurityInfo(RProcess()));			
       
   420 		}
       
   421 		else if(!iSessionCreated)// NO Connection
       
   422 			{
       
   423 			INFO_PRINTF4(_L("Couldnt connect to the Server(%S) ErrorCode - ServerRet: %d C32ret: %d"),&SR_ServerName,iResult_Server,iResult_C32);
       
   424 			//INFO_PRINTF3(_L("Child Thread: ExitCategory : %S ExitReason : %d"),&tExitCategory,tExitReason);
       
   425   			return EFail;
       
   426  			}
       
   427 
       
   428 
       
   429 
       
   430 		switch(tChildThread.ExitType())
       
   431 			{			
       
   432 			case EExitPanic:
       
   433 				//1.A Panic from the connected Server 
       
   434 				//2.A CServer Panic normally for capability rejection
       
   435 				//3.A kernel Panic (consider yourself doomed!)
       
   436 				if((tExitReason == KErrPermissionDenied) ||
       
   437 					//DEF ? 	it's old version (tExitReason == CServer::EClientDoesntHaveRequiredCaps))//Rejected for Insufficient Cap.
       
   438 					// is it correct ?
       
   439 					(tExitReason == CServer2::EClientDoesntHaveRequiredCaps))//Rejected for Insufficient Cap.
       
   440 					{
       
   441 					INFO_PRINTF2(_L("Rejected for insufficient capabilities [Return Value : %d] "),tExitReason);
       
   442 					return(GetVerdict(API_RetValue_PermissionDenied));
       
   443 					}
       
   444 				else if(tExitCategory == iServer_Panic) //Panic from Server
       
   445 					{
       
   446 					INFO_PRINTF2(_L("Server(%S) Panic to child thread"),&tExitCategory);	
       
   447 					INFO_PRINTF3(_L("Child Thread: ExitCategory : %S ExitReason : %d"),&tExitCategory,tExitReason);
       
   448 					return(GetVerdict(API_RetValue_ServerPanic));
       
   449 					}
       
   450 				else//A kernel Panic possibly
       
   451 					{
       
   452 					INFO_PRINTF3(_L("Child Thread: Panic from unexpected source (ExitCategory: %S ExitReason : %d)!"),&tExitCategory,tExitReason);
       
   453 					return EInconclusive;
       
   454 					}
       
   455 			case EExitKill:
       
   456 				if(iResult_SR != KErrPermissionDenied)
       
   457 					{
       
   458 					INFO_PRINTF2(_L("A Successfull call (Return Value : %d)"),((SR_MESSAGE_ID >=0)?iResult_SR:iResult_Server));
       
   459 					return(GetVerdict(API_RetValue_NoCapError));
       
   460 					}
       
   461 				else 
       
   462 					{
       
   463 					INFO_PRINTF2(_L("Rejected for insufficient capabilities [Return Value : %d] "),((SR_MESSAGE_ID >=0)?iResult_SR:iResult_Server));
       
   464 					return(GetVerdict(API_RetValue_PermissionDenied));			
       
   465 					}
       
   466 			default:
       
   467 					break;
       
   468 			}
       
   469 		}
       
   470 	else //Our thread couldnt start	:o(
       
   471 		{
       
   472 		INFO_PRINTF2(_L("ERROR: Failed to create Child thread,  ErrorCode:(%d)"),nRes_Thread);
       
   473 		return EFail;
       
   474 		}
       
   475 
       
   476 	return EInconclusive;
       
   477 	}
       
   478 
       
   479 TInt CCapabilityTestStep::StartServer()
       
   480 	{
       
   481 	TInt err =  KErrNone ;
       
   482 	
       
   483 	// EKA2 is simple No path required
       
   484 	TBuf<32> serverFile;
       
   485 	serverFile.Copy(_L("hwrmserver"));
       
   486 	_LIT(KExe,".exe");
       
   487 	serverFile.Append(KExe);
       
   488 	RProcess server;
       
   489 	err = server.Create(serverFile,_L(""));
       
   490 		    
       
   491 	if(err != KErrNone)
       
   492 		{
       
   493 		return err;
       
   494 		}
       
   495 	
       
   496 	// Synchronise with the server
       
   497 	TRequestStatus reqStatus;
       
   498 	server.Rendezvous(reqStatus);
       
   499 	server.Resume();
       
   500 	
       
   501 	// Server will call the reciprocal static synchronise call
       
   502 	User::WaitForRequest(reqStatus);
       
   503 	
       
   504 	if(reqStatus.Int() != KErrNone)
       
   505 		{
       
   506 		return reqStatus.Int();
       
   507 		}
       
   508 	return err;
       
   509 	}
       
   510 
       
   511 TInt CCapabilityTestStep::TestDebugHeap(TInt* aDbgIPCNo)
       
   512 	{
       
   513      
       
   514 	//TDbgFns  {MarkHeapStart, MarkHeapEnd, CheckHeap, FailNext, ResetFailNext};
       
   515 	TInt aFnToTest= aDbgIPCNo[5];
       
   516      
       
   517 	TInt iResult_SR [6] ={0};
       
   518     TInt i = 1;
       
   519 	TInt testedFn = 0;
       
   520 
       
   521 	TInt dbgTestSequence[5][6]  =   {   {MarkHeapStart  ,2,0,1,-1,-1}, 
       
   522 										{MarkHeapEnd    ,2,0,1,-1,-1},
       
   523 										{CheckHeap      ,3,0,2, 1,-1},
       
   524 										{FailNext       ,4,0,3, 4, 1},
       
   525 										{ResetFailNext  ,4,0,3, 4, 1}
       
   526 									};
       
   527      
       
   528 	TInt aCount = dbgTestSequence[aFnToTest][i];
       
   529 
       
   530 	while(aCount--  )
       
   531 		{
       
   532 		testedFn =  dbgTestSequence[aFnToTest][(++i)];
       
   533      
       
   534 		iResult_SR[testedFn ]= SendReceive( aDbgIPCNo[testedFn],TIpcArgs(((aDbgIPCNo[testedFn]==3 )?4:0),0,0,0));
       
   535     
       
   536 		if( ((testedFn !=aFnToTest)?iResult_SR[testedFn]:KErrNone) == KErrPermissionDenied)             
       
   537         	User::Panic(_L("Failed at Initialization"),iResult_SR[testedFn]);       
       
   538 
       
   539 		}
       
   540 
       
   541 	return iResult_SR[aFnToTest];
       
   542 	}