authenticationservices/authenticationserver/test/tAuthSvr/src/step_oom.cpp
changeset 29 ece3df019add
equal deleted inserted replaced
19:cd501b96611d 29:ece3df019add
       
     1 /*
       
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "tAuthSvrStep.h"
       
    20 
       
    21 #include "authserver/authclient.h"
       
    22 #include "authserver/authmgrclient.h"
       
    23 #include "authrepository.h"
       
    24 #include <scs/cleanuputils.h>
       
    25 
       
    26 using namespace AuthServer;
       
    27 class CAuthOomActive : public CActive
       
    28     {
       
    29     public:
       
    30     CAuthOomActive(RAuthMgrClient& aClient, CAuthExpression* aExpression,
       
    31 				 TInt aFresh, TBool aClientSpecific, TBool aAuthViaAlias, const TDesC& aClientMessage, TBool aStop = ETrue) : 
       
    32          CActive(EPriorityNormal),
       
    33          iClient(aClient),
       
    34 		 iResult(EFail),
       
    35          iRunCount(0),
       
    36          iAe(aExpression),
       
    37          iStop(aStop),
       
    38          iFresh(aFresh),
       
    39          iIdToStore(0), 
       
    40          iClientSpecific(aClientSpecific),
       
    41          iAuthViaAlias(aAuthViaAlias),
       
    42          iClientMessage(aClientMessage)
       
    43         {
       
    44         CActiveScheduler::Add(this);
       
    45         }
       
    46     
       
    47    void doAuth() 
       
    48         {
       
    49         SetActive();		
       
    50 		TRequestStatus* status = &iStatus;
       
    51 		User::RequestComplete(status, KErrNone);
       
    52 		iRunCount = 0;
       
    53         }
       
    54 	void DoCancel() 
       
    55         {
       
    56         }
       
    57         
       
    58     TInt RunError(TInt aError)
       
    59     	{
       
    60     	 TRequestStatus* status = &iStatus;
       
    61     	  if(iStatus.Int() == KErrNoMemory)
       
    62     	 	 {
       
    63     	 	 CActiveScheduler::Stop();
       
    64     	 	 User::Leave(aError);
       
    65     	 	   
       
    66     	 	 }
       
    67     	  else if (iStatus == KRequestPending)
       
    68     	     {   		 
       
    69     	      User::RequestComplete(status, aError);
       
    70     	      CActiveScheduler::Stop();
       
    71     	      User::Leave(aError);
       
    72     	     }
       
    73     	       	
       
    74     	  CActiveScheduler::Stop();
       
    75     	  if(aError == KErrNoMemory)
       
    76     		  {
       
    77     		  User::Leave(aError);
       
    78     		  }
       
    79     	  return KErrNone;
       
    80     	}
       
    81     	
       
    82     void RunL() 
       
    83         {
       
    84         iErr = iStatus.Int();
       
    85         TUid val = TUid::Uid(0);
       
    86 		switch (iRunCount)
       
    87 		  {
       
    88 		  case 0:
       
    89 		  	{
       
    90 		  	iId = 0;
       
    91 
       
    92 			TUid uid = TUid::Uid(0);
       
    93 				
       
    94 	
       
    95 			iClient.AuthenticateL(*iAe, iFresh, iClientSpecific, val, EFalse, iClientMessage, iId, iStatus);
       
    96 		
       
    97 			SetActive();
       
    98 
       
    99 			break;
       
   100 		  	}
       
   101             
       
   102 		  case 1:
       
   103 			if (0 != iId)
       
   104 				{
       
   105 				iIdToStore = iId->Id();
       
   106 				delete iId;
       
   107 				iId = NULL;
       
   108 				}
       
   109 			
       
   110 			iResult = iStatus == KErrNone ? EPass : EFail;
       
   111             iErr = iStatus.Int();
       
   112             if(iErr == KErrNoMemory)
       
   113             	{
       
   114             	User::Leave(KErrNoMemory);
       
   115             	}
       
   116 			if (iStop)
       
   117                 {
       
   118                 CActiveScheduler::Stop();
       
   119                 }
       
   120 
       
   121 			break;
       
   122 			
       
   123      	  default:
       
   124 			iResult = EFail;
       
   125 			
       
   126 			if (iStop)
       
   127 			    {
       
   128 			    CActiveScheduler::Stop();
       
   129 			    }
       
   130 		    }
       
   131 		  ++iRunCount;
       
   132           }
       
   133 
       
   134 	~CAuthOomActive()
       
   135 		{
       
   136 		if(iId != NULL)
       
   137 			delete iId;
       
   138 		}
       
   139           
       
   140    		
       
   141 	RAuthMgrClient& iClient;
       
   142 	TVerdict iResult;
       
   143 	TInt iRunCount;
       
   144 	CAuthExpression* iAe;
       
   145 	CIdentity* iId;
       
   146     TBool iStop;
       
   147     TInt iErr;
       
   148     TInt iFresh;
       
   149     TIdentityId iIdToStore;
       
   150     TBool iClientSpecific;
       
   151     TBool iAuthViaAlias;
       
   152     const TDesC& iClientMessage;
       
   153     };
       
   154 
       
   155 class CRegOomActive : public CActive
       
   156     {
       
   157     public:
       
   158     CRegOomActive(RAuthMgrClient& aClient, CIdentity*& aResult) : 
       
   159          CActive(EPriorityNormal),
       
   160          iFirstTime(true),
       
   161          iClient(aClient), 
       
   162          iResult(aResult),
       
   163          iErr(KErrNone)
       
   164         {
       
   165         CActiveScheduler::Add(this);
       
   166         }
       
   167     void doReg()
       
   168         {
       
   169         SetActive();		
       
   170 		TRequestStatus* status = &iStatus;
       
   171 		User::RequestComplete(status, KErrNone);
       
   172 		iFirstTime = ETrue;
       
   173         }
       
   174         void DoCancel() 
       
   175         {
       
   176         }
       
   177      void RunL() 
       
   178         {
       
   179         iErr = iStatus.Int();
       
   180         if (iFirstTime)
       
   181             {
       
   182 			SetActive();
       
   183             iStatus = KRequestPending;
       
   184             iClient.RegisterIdentityL(iResult, _L("SOMENAME"), iStatus);
       
   185             iFirstTime = false;
       
   186             }
       
   187         else
       
   188             {
       
   189             iErr = iStatus.Int();
       
   190             
       
   191             if (iErr == KErrNoMemory)
       
   192             	{
       
   193             	User::Leave(KErrNoMemory);
       
   194             	}
       
   195             CActiveScheduler::Stop();
       
   196 			}
       
   197         }
       
   198      TInt RunError(TInt error)
       
   199     	 {
       
   200     	 
       
   201     	 TRequestStatus* status = &iStatus;
       
   202     	 if(iStatus.Int() == KErrNoMemory)
       
   203     		 {
       
   204     		 CActiveScheduler::Stop();
       
   205     		 User::Leave(error);
       
   206     		   
       
   207     		 }
       
   208     	 else if (iStatus == KRequestPending)
       
   209     		 {   		 
       
   210     		 User::RequestComplete(status, error);
       
   211     		 CActiveScheduler::Stop();
       
   212     		 User::Leave(error);
       
   213     		 }
       
   214      	
       
   215     	 CActiveScheduler::Stop();
       
   216          User::Leave(error);
       
   217          return KErrNone;
       
   218     	 }
       
   219      
       
   220      ~CRegOomActive()
       
   221     	 {
       
   222     	 Cancel(); 	 
       
   223     	 }
       
   224         
       
   225     TBool iFirstTime;
       
   226     RAuthMgrClient& iClient;
       
   227     CIdentity*& iResult;
       
   228     TInt iErr;
       
   229     };
       
   230 
       
   231 class CTrainOomActive : public CActive
       
   232     {
       
   233     public:    
       
   234     CTrainOomActive(RAuthMgrClient& aClient, TPluginId plugin1IdValue, TIdentityId iIdFromFile, TBool aStop = ETrue) : 
       
   235          CActive(EPriorityNormal),
       
   236          iClient(aClient),
       
   237 		 iResult(EFail),
       
   238          iRunCount(0),
       
   239          iStop(aStop),
       
   240          pluginIdVal(plugin1IdValue),         
       
   241          idToTrain (iIdFromFile)
       
   242         {
       
   243         CActiveScheduler::Add(this);
       
   244         }
       
   245     void doTrain() 
       
   246         {
       
   247 
       
   248         SetActive();		
       
   249 		TRequestStatus* status = &iStatus;		    
       
   250 		User::RequestComplete(status, KErrNone);
       
   251 		iRunCount = 0;
       
   252         }
       
   253         void DoCancel() 
       
   254         {
       
   255         }
       
   256      void RunL() 
       
   257         {
       
   258         iErr = iStatus.Int();
       
   259         if (iStatus.Int() != KErrNone)
       
   260             {
       
   261             }
       
   262 		switch (iRunCount)
       
   263 		  {
       
   264 		  case 0:
       
   265 				iStatus = KRequestPending;
       
   266 	            iClient.TrainPlugin(idToTrain, pluginIdVal, iStatus);
       
   267 				SetActive();
       
   268 			break;
       
   269 
       
   270    		  case 1:
       
   271 			iResult = iStatus.Int() == KErrNone ? EPass : EFail;
       
   272             iErr = iStatus.Int();
       
   273             if (iErr == KErrNoMemory)
       
   274                 {
       
   275                  User::Leave(KErrNoMemory);
       
   276                 }
       
   277 			if (iStop)
       
   278                 {
       
   279                 CActiveScheduler::Stop();
       
   280                 }
       
   281 
       
   282 			break;
       
   283 
       
   284      	  default:
       
   285 			iResult = EFail;
       
   286 			  if (iErr == KErrNoMemory)
       
   287 			    {
       
   288 			    User::Leave(KErrNoMemory);
       
   289 			    }
       
   290 			if (iStop)
       
   291 			    {
       
   292 			    CActiveScheduler::Stop();
       
   293 			    }
       
   294 		    }
       
   295 		  ++iRunCount;
       
   296           }
       
   297      TInt RunError(TInt error)
       
   298     	 {
       
   299 
       
   300     	 TRequestStatus* status = &iStatus;
       
   301     	 if(iStatus.Int() == KErrNoMemory)
       
   302     		 {
       
   303     		 CActiveScheduler::Stop();
       
   304     		 User::Leave(error);
       
   305     		   
       
   306     		 }
       
   307     	 else if (iStatus == KRequestPending)
       
   308     		 {   		 
       
   309     		 User::RequestComplete(status, error);
       
   310     		 CActiveScheduler::Stop();
       
   311     		 User::Leave(error);
       
   312     		 }
       
   313      	
       
   314     	 CActiveScheduler::Stop();
       
   315          User::Leave(error);
       
   316          return KErrNone;
       
   317     	 
       
   318     	 }
       
   319 	RAuthMgrClient& iClient;
       
   320 	TVerdict iResult;
       
   321 	TInt iRunCount;
       
   322     TBool iStop;
       
   323     TInt iErr;
       
   324     TPluginId pluginIdVal;
       
   325     TIdentityId idToTrain;
       
   326     };
       
   327 
       
   328 CAuthSvrOom::~CAuthSvrOom()
       
   329 /**
       
   330   Destructor
       
   331  */
       
   332 	{}
       
   333 
       
   334 CAuthSvrOom::CAuthSvrOom(CTAuthSvrServer& aParent): iParent(aParent)
       
   335 /**
       
   336   Constructor
       
   337  */
       
   338 	{
       
   339 	
       
   340 	SetTestStepName(KTAuthServerOom);
       
   341 	}
       
   342 
       
   343 TVerdict CAuthSvrOom::doTestStepPreambleL()
       
   344 /**
       
   345   @return - TVerdict code
       
   346 
       
   347  */
       
   348 	{
       
   349 	CTStepActSch::doTestStepPreambleL();	
       
   350 	CActiveScheduler::Install(iActSchd);
       
   351 	return TestStepResult();
       
   352 	}
       
   353 
       
   354 
       
   355 TVerdict CAuthSvrOom::doTestStepL()
       
   356 	{
       
   357 	
       
   358 	//Client side/Server side OOM test or Performance test??
       
   359 	
       
   360 	TInt testType(0);
       
   361 	GetIntFromConfig(ConfigSection(), _L("TestType"), testType);
       
   362 	ReadTestConfigurationL();
       
   363 	switch(testType)
       
   364 		{
       
   365 		case 1: doClientOOMTestL();
       
   366 				break;
       
   367 		
       
   368 		case 2: doServerOOMTestL();
       
   369 				break;
       
   370 				
       
   371 		case 3: doPerformanceTestL();
       
   372 				break;
       
   373 				
       
   374 		default:
       
   375 			//Should not reach here !
       
   376 			   break;
       
   377 		}
       
   378 	
       
   379 	return TestStepResult();
       
   380 	}
       
   381 TVerdict CAuthSvrOom::doClientOOMTestL()
       
   382 /**
       
   383  * 	Runs the test step under OOM Conditions checking that each heap allocation is fail safe
       
   384  */
       
   385 	{	
       
   386 	// Pre and Post test heap cell allocation counts
       
   387  	TInt cellCountAfter = 0;
       
   388 	TInt cellCountBefore = 0;
       
   389 	
       
   390 	/**
       
   391 	 * The loop tests each heap allocation under out of memory conditions to determine whether
       
   392 	 * the framework cleans up correctly without leaking memory.
       
   393 	 * 
       
   394 	 * The 'for' loop does not have any completion criteria, so the loop breaks out as soon 
       
   395 	 * as any of the following events occur:
       
   396 	 * a) The pre and post heap cell counts mismatch signalling a memory leakage
       
   397 	 * b) An unexpected leave (any leave with an error code other than 'KErrNoMemory')
       
   398 	 * c) All heap allocations have been tested and the test returns 'KErrNone'
       
   399 	 */
       
   400 	for (TInt testCount = 0; ; ++testCount)
       
   401  		{
       
   402  		__UHEAP_RESET;
       
   403  		__UHEAP_MARK;
       
   404  		
       
   405 __UHEAP_SETFAIL(RHeap::EDeterministic, testCount+1);
       
   406 		cellCountBefore = User::CountAllocCells();
       
   407  		AuthServer::RAuthMgrClient authMgrClient;
       
   408  		CleanupClosePushL(authMgrClient);
       
   409  		authMgrClient.Connect();
       
   410  		
       
   411  		TRAPD(err, doTestL(authMgrClient));
       
   412  		authMgrClient.ShutdownServer();
       
   413  		CleanupStack::PopAndDestroy(&authMgrClient);
       
   414  		
       
   415  		cellCountAfter = User::CountAllocCells();
       
   416  __UHEAP_MARKEND;
       
   417  		
       
   418  		
       
   419  		if (err == KErrNone)
       
   420  			{
       
   421 			INFO_PRINTF1(_L("Client OOM Test Finished"));
       
   422  			break;
       
   423  			}
       
   424  		else if(err == KErrNoMemory)
       
   425  			{
       
   426  			
       
   427  			if (cellCountBefore != cellCountAfter)
       
   428  				{
       
   429  				ERR_PRINTF2(_L("OOM Test Result: Failed - Memory leakage on iteration %d"), testCount);
       
   430  				SetTestStepResult(EFail);
       
   431  				break;
       
   432  				}
       
   433  			else
       
   434  				{
       
   435  				INFO_PRINTF2(_L("OOM Pass %d"), testCount);
       
   436  				}
       
   437  			}
       
   438  		else
       
   439  			{
       
   440  			User::Leave(err);
       
   441  			break;
       
   442  			}
       
   443 		}
       
   444 	
       
   445 	
       
   446 	return TestStepResult();
       
   447 	}
       
   448 
       
   449 TVerdict CAuthSvrOom::doServerOOMTestL()
       
   450 	{
       
   451 
       
   452 	TInt err(0),err2(0);	
       
   453 	AuthServer::RAuthMgrClient authMgrClient;
       
   454 	CleanupClosePushL(authMgrClient);
       
   455 	authMgrClient.Connect();	
       
   456 	// Pre and Post test heap cell allocation counts
       
   457 	for (TInt testCount=0; ; ++testCount)
       
   458  		{
       
   459  		
       
   460  		err = authMgrClient.SetServerHeapFail(testCount+1);
       
   461  		if(KErrNoMemory == err)
       
   462  			{
       
   463  			ERR_PRINTF1(_L("ReInitializing..."));
       
   464  			authMgrClient.ResetServerHeapFail();
       
   465  			continue;
       
   466  			}
       
   467 
       
   468  		TRAPD(retStepVal, doTestL(authMgrClient));
       
   469  		err2 = authMgrClient.ResetServerHeapFail();
       
   470  		if((err == KErrServerTerminated) || (err2 == KErrServerTerminated))
       
   471  			{
       
   472  			INFO_PRINTF1(_L("AuthServer Terminated"));	
       
   473  			SetTestStepResult(EFail);
       
   474  			break;
       
   475  			}
       
   476  			
       
   477  		if(KErrNone != err)
       
   478  			{
       
   479  			SetTestStepResult(EFail);
       
   480  			break;
       
   481  			}
       
   482  		 		
       
   483  	
       
   484  		if(KErrNoMemory == retStepVal)
       
   485  			{
       
   486  			INFO_PRINTF2(_L("OOM Pass %d"), testCount);
       
   487  			}
       
   488  		else if (KErrNone == retStepVal)
       
   489  			{
       
   490  			INFO_PRINTF1(_L("Server OOM Test Finished"));
       
   491  			break;
       
   492  			}
       
   493  		else 
       
   494  			{
       
   495  			// Propagate all errors apart from KErrNoMemory
       
   496  			User::Leave(retStepVal);
       
   497  			}
       
   498  		
       
   499  		
       
   500  		}// for
       
   501 		CleanupStack::PopAndDestroy(&authMgrClient);
       
   502 		WaitForServerToReleaseDb();
       
   503 	return TestStepResult();
       
   504 	}
       
   505 
       
   506 
       
   507 TVerdict CAuthSvrOom::doTestL(AuthServer::RAuthMgrClient& ac)
       
   508 	{
       
   509 	TInt oomValue;
       
   510 	GetIntFromConfig(ConfigSection(), _L("OOMTest"), oomValue);
       
   511 	
       
   512 	switch(oomValue)
       
   513 		{
       
   514 		case 1:
       
   515 			
       
   516 			break;
       
   517 		
       
   518 		case 2:
       
   519 			//Registration API check			
       
   520 			doRegOOMTestL(ac);		
       
   521 			break;
       
   522 		
       
   523 		case 3:
       
   524 			//Synchronous Authenticate API check	
       
   525 			doSyncAuthOOMTestL(ac);
       
   526 			break;
       
   527 		
       
   528 		case 4:
       
   529 			//Asynchronous Authenticate API check
       
   530 			doAsyncAuthOOMTestL(ac);
       
   531 			break;
       
   532 			
       
   533 		case 5:
       
   534 			//Set preffered plugin type check
       
   535 			doSetPreferredTypeL(ac);
       
   536 			break;
       
   537 			
       
   538 		case 6:
       
   539 			//Check Remove Identity API
       
   540 			doRemoveIdentityL(ac);
       
   541 			break;
       
   542 		case 7:
       
   543 			//Check forget plugin API
       
   544 			doForgetPluginL(ac);
       
   545 			break;
       
   546 		case 8:
       
   547 			//Check Retrain Plugin API
       
   548 			doRetrainPluginL(ac);
       
   549 			break;
       
   550 		case 9:
       
   551 			//Check List PluginsL API
       
   552 			doListPluginsL(ac);
       
   553 			break;
       
   554 		case 10:
       
   555 			//Check List Active Plugins API
       
   556 			doListActivePluginsL(ac);
       
   557 			break;
       
   558 		case 11:
       
   559 			//Check List Plugins of type API
       
   560 			doListPluginsOfTypeL(ac);
       
   561 			break;
       
   562 		case 12:
       
   563 			//Check List Plugins With Training status API
       
   564 			doListPluginsWithTrainingStatusL(ac);
       
   565 			break;
       
   566 		case 13:
       
   567 			//Check List Authentication aliases API
       
   568 			doListAuthStrengthAliasesL(ac);
       
   569 			break;
       
   570 		case 14:
       
   571 			// Check the reset API (all plugins)
       
   572 			doResetAll(ac);
       
   573 			break;
       
   574 		case 15:
       
   575 			// Check the reset API (plugins of specified type)
       
   576 			doResetType(ac);
       
   577 			break;
       
   578 		case 16:
       
   579 			// Check the reset API (specified plugins)
       
   580 			doResetList(ac);
       
   581 			break;
       
   582 		default:
       
   583 			//Should never reach here
       
   584 			break;
       
   585 		}
       
   586 	return TestStepResult();
       
   587 	}
       
   588 
       
   589 void CAuthSvrOom::doStartupTestL()
       
   590 	{
       
   591 	RAuthClient r1;
       
   592 	CleanupClosePushL(r1);
       
   593 	r1.Connect();
       
   594 	CleanupStack::PopAndDestroy(&r1);	
       
   595 	}
       
   596 
       
   597 void CAuthSvrOom::doRegOOMTestL(AuthServer::RAuthMgrClient &ac)
       
   598 	{
       
   599 	
       
   600 	CIdentity* identity1 = 0;
       
   601     CRegOomActive active(ac, identity1);
       
   602     active.doReg();
       
   603 	CActiveScheduler::Start();
       
   604 	delete identity1;
       
   605 	}
       
   606 
       
   607 void CAuthSvrOom::doSyncAuthOOMTestL(AuthServer::RAuthMgrClient &ac)
       
   608 	{
       
   609 	TUid val = TUid::Uid(0);
       
   610 	CIdentity* id = 0;
       
   611 	CAuthExpression* expr = CreateAuthExprLC(iExprString);			
       
   612 	id = ac.AuthenticateL(*expr, iFreshnessVal, iClientSpecificKeyVal, val, EFalse, iMessage);
       
   613 	
       
   614 	delete id;
       
   615 	id = 0;
       
   616 	CleanupStack::PopAndDestroy(expr);
       
   617 	}
       
   618 
       
   619 void CAuthSvrOom::doAsyncAuthOOMTestL(AuthServer::RAuthMgrClient &ac)
       
   620 	{
       
   621 	CAuthExpression* expr = ac.CreateAuthExpressionL(iExprString);
       
   622 	CleanupStack::PushL(expr);
       
   623 		
       
   624 	CAuthOomActive active(ac, expr, iFreshnessVal, iClientSpecificKeyVal, EFalse, iMessage);
       
   625 	active.doAuth();		
       
   626 	CActiveScheduler::Start();
       
   627 			
       
   628 	if(expr)
       
   629 		{
       
   630 		CleanupStack::PopAndDestroy(expr);
       
   631 		}
       
   632 	}
       
   633 
       
   634 void CAuthSvrOom::doSetPreferredTypeL(AuthServer::RAuthMgrClient &ac)
       
   635 	{
       
   636 	TInt plugin(0);
       
   637 	GetHexFromConfig(ConfigSection(),KKnowledgePrefsTag, plugin);
       
   638 	TPluginId id = plugin;
       
   639 	ac.SetPreferredTypePluginL(EAuthKnowledge, id);
       
   640 	}
       
   641 
       
   642 void CAuthSvrOom::doRemoveIdentityL(AuthServer::RAuthMgrClient &ac)
       
   643 	{
       
   644 	TInt plugin1IdValue = 0;	
       
   645 	GetHexFromConfig(ConfigSection(),_L("plugin1Id"), plugin1IdValue);
       
   646 	
       
   647 	//Read the identityId to be removed
       
   648 	TIdentityId idToRemove = getLastAuthId();
       
   649 	ac.RemoveIdentityL(idToRemove);
       
   650 	}
       
   651 
       
   652 void CAuthSvrOom::doForgetPluginL(AuthServer::RAuthMgrClient &ac)
       
   653 	{
       
   654 	TInt plugin1IdValue = 0;	
       
   655 	GetHexFromConfig(ConfigSection(),_L("plugin1Id"), plugin1IdValue);
       
   656 	
       
   657 	//Read the identityId to be forgotten
       
   658 	TIdentityId idToForget = getLastAuthId();
       
   659 	ac.ForgetPluginL( idToForget , plugin1IdValue);
       
   660 	}
       
   661 
       
   662 void CAuthSvrOom::doRetrainPluginL(AuthServer::RAuthMgrClient &ac)
       
   663 	{
       
   664 	TInt plugin1IdValue = 0;
       
   665 	GetHexFromConfig(ConfigSection(),_L("plugin1Id"), plugin1IdValue);
       
   666 	
       
   667 	TIdentityId idToTrain = getLastAuthId();
       
   668 	//Train the plugin again with this identity. 	    
       
   669  	CTrainOomActive active(ac, plugin1IdValue, idToTrain);
       
   670 	active.doTrain();		
       
   671 	CActiveScheduler::Start();			
       
   672 	}
       
   673 
       
   674 void CAuthSvrOom::doListPluginsL(AuthServer::RAuthMgrClient &ac)
       
   675 	{
       
   676 	RPluginDescriptions pluginList1;
       
   677 	TCleanupItem cleanup(CleanupEComArray, &pluginList1);
       
   678 	CleanupStack::PushL(cleanup);					
       
   679 	ac.PluginsL(pluginList1);	
       
   680 	CleanupStack::PopAndDestroy(&pluginList1);
       
   681 		
       
   682 	}
       
   683 
       
   684 void CAuthSvrOom::doListActivePluginsL(AuthServer::RAuthMgrClient &ac)
       
   685 	{
       
   686 	RPluginDescriptions pluginList1;
       
   687 	TCleanupItem cleanup(CleanupEComArray, &pluginList1);
       
   688 	CleanupStack::PushL(cleanup);					
       
   689 	ac.ActivePluginsL(pluginList1);	
       
   690 	CleanupStack::PopAndDestroy(&pluginList1);
       
   691 	}
       
   692 
       
   693 void CAuthSvrOom::doListPluginsOfTypeL(AuthServer::RAuthMgrClient &ac)
       
   694 	{
       
   695 	RCPointerArray<const CPluginDesc> pluginsList;
       
   696 	CleanupClosePushL(pluginsList);
       
   697 	TAuthPluginType t1 = EAuthKnowledge;				
       
   698 	ac.PluginsOfTypeL(t1, pluginsList);	
       
   699 	CleanupStack::PopAndDestroy(&pluginsList);
       
   700 	}
       
   701 
       
   702 void CAuthSvrOom::doListPluginsWithTrainingStatusL(AuthServer::RAuthMgrClient &ac)
       
   703 	{
       
   704 	RCPointerArray<const CPluginDesc> pluginsList;
       
   705 	CleanupClosePushL(pluginsList);		
       
   706 	TAuthTrainingStatus t1 = EAuthTrained;
       
   707 	ac.PluginsWithTrainingStatusL(t1, pluginsList);	
       
   708 	CleanupStack::PopAndDestroy(&pluginsList);
       
   709 	}
       
   710 
       
   711 void CAuthSvrOom::doListAuthStrengthAliasesL(AuthServer::RAuthMgrClient &ac)
       
   712 	{
       
   713 	RPointerArray<HBufC> aliasList;
       
   714 	CleanupResetAndDestroyPushL(aliasList);
       
   715 	ac.ListAuthAliasesL(aliasList);
       
   716 	CleanupStack::PopAndDestroy(&aliasList);
       
   717 	}
       
   718 
       
   719 // Check the reset API (all plugins)
       
   720 void CAuthSvrOom::doResetAll(AuthServer::RAuthMgrClient& ac)
       
   721 	{
       
   722 	TIdentityId identity = getLastAuthId(); // Anything but 0 since client does sanity check
       
   723 	ac.ResetIdentityL(identity, _L("1234"));
       
   724 	}
       
   725 
       
   726 // Check the reset API (plugins of specified type)
       
   727 void CAuthSvrOom::doResetType(AuthServer::RAuthMgrClient& ac)
       
   728 	{
       
   729 	TIdentityId identity = getLastAuthId(); // Anything but 0 since client does sanity check
       
   730 	ac.ResetIdentityL(identity, EAuthKnowledge, _L("2342"));
       
   731 	}
       
   732 
       
   733 // Check the reset API (specified plugins)
       
   734 void CAuthSvrOom::doResetList(AuthServer::RAuthMgrClient& ac)
       
   735 	{
       
   736 	TIdentityId identity = getLastAuthId(); // Anything but 0 since client does sanity check
       
   737 	TInt pluginId(0);
       
   738 	GetHexFromConfig(ConfigSection(),_L("plugin1Id"), pluginId);
       
   739 	RArray<TPluginId> pluginList;
       
   740 	CleanupClosePushL(pluginList);
       
   741 	RPointerArray<const HBufC> regDataList;
       
   742 	CleanupResetAndDestroyPushL(regDataList);
       
   743 	pluginList.AppendL(pluginId);
       
   744 	regDataList.AppendL(_L("1344").AllocL());
       
   745 	ac.ResetIdentityL(identity, pluginList, regDataList);
       
   746 	CleanupStack::PopAndDestroy(2, &pluginList);
       
   747 	}
       
   748 
       
   749 void CAuthSvrOom::ReadTestConfigurationL()
       
   750 	{
       
   751 	
       
   752 	TPtrC displayMessage;
       
   753 	TBool messageSent = (GetStringFromConfig(ConfigSection(),_L("DisplayMessage"), displayMessage) != EFalse);
       
   754 	iMessage = displayMessage;
       
   755 	ClientMessage(messageSent, displayMessage);
       
   756 	if(!messageSent)
       
   757 		{
       
   758 		iMessage = KNullDesC();
       
   759 		}
       
   760 	
       
   761 	TPinValue pinValue = GetPinFromOutputFileL();
       
   762 	CreatePinPluginInputFileL(EPinPluginIdentify, pinValue);
       
   763 		
       
   764 
       
   765 	GetStringFromConfig(ConfigSection(),_L("pluginId"), iExprString);
       
   766   	
       
   767 	
       
   768 	//Retrieve the value of 'freshness' from the ini file, but if it's absent use the default value
       
   769 	if(GetIntFromConfig(ConfigSection(),_L("freshness"), iFreshnessVal) == EFalse)
       
   770 		{
       
   771 		iFreshnessVal = 10;
       
   772 		}
       
   773 	 		
       
   774 	iClientSpecificKeyVal = EFalse;	 	
       
   775 	//Retrieve the value of 'clientSpecificKey' from the ini file, but if it's absent use the default value
       
   776 	if(GetBoolFromConfig(ConfigSection(),_L("clientSpecificKey"), iClientSpecificKeyVal) == EFalse)
       
   777 		{
       
   778 		iClientSpecificKeyVal = EFalse;
       
   779 		}
       
   780 	 	
       
   781 	iDefaultpluginusage = EFalse;
       
   782 	if(GetBoolFromConfig(ConfigSection(),_L("defaultpluginusage"), iDefaultpluginusage ) == EFalse)
       
   783 		 {
       
   784 		 iDefaultpluginusage  = EFalse;
       
   785 		 }
       
   786 
       
   787 	}
       
   788 
       
   789 
       
   790 TVerdict CAuthSvrOom::doTestStepPostambleL()
       
   791 /**
       
   792   @return - TVerdict code
       
   793 
       
   794  */
       
   795 	{
       
   796 	
       
   797 	CTStepActSch::doTestStepPostambleL();
       
   798 	return TestStepResult();
       
   799 	}
       
   800 
       
   801 TVerdict CAuthSvrOom::doPerformanceTestL()
       
   802 /**
       
   803  * 	Runs the test step under OOM Conditions checking that each heap allocation is fail safe
       
   804  */
       
   805 	{
       
   806 	TInt oomValue;
       
   807 	GetIntFromConfig(ConfigSection(), _L("OOMTest"), oomValue);
       
   808 	GetIntFromConfig(ConfigSection(), _L("iterationCount"), iIterationCount);	
       
   809 	StartTimer();
       
   810 	
       
   811 	for (TInt i = 0; i < iIterationCount; ++i)
       
   812  		{
       
   813  		
       
   814  		AuthServer::RAuthMgrClient authMgrClient;
       
   815  		CleanupClosePushL(authMgrClient);
       
   816  		authMgrClient.Connect();
       
   817  	
       
   818  		TRAPD(err, doTestL(authMgrClient));
       
   819  		authMgrClient.ShutdownServer();
       
   820  		CleanupStack::PopAndDestroy(&authMgrClient);
       
   821  		if(err != KErrNone)
       
   822  			{
       
   823  			User::Leave(err);
       
   824  			break;
       
   825  			}
       
   826  
       
   827  		ReadTestConfigurationL();
       
   828  		if (oomValue == 2)
       
   829  			{
       
   830  			RemoveExistingDbL();
       
   831  			}
       
   832  		}
       
   833 	
       
   834 	StopTimerAndPrintResultL();
       
   835 	return TestStepResult();
       
   836 	}
       
   837 	
       
   838 void CAuthSvrOom::PrintPerformanceLog(TTime aTime)
       
   839 	{
       
   840 	TDateTime timer = aTime.DateTime();
       
   841 	INFO_PRINTF6(_L("%S,%d:%d:%d:%d"), &KPerformanceTestInfo(), timer.Hour(), timer.Minute(), timer.Second(), timer.MicroSecond());
       
   842 	}
       
   843 
       
   844 void CAuthSvrOom::StartTimer()
       
   845 	{
       
   846 	iStartTime.HomeTime();
       
   847 	PrintPerformanceLog(iStartTime);
       
   848 	}
       
   849 
       
   850 void CAuthSvrOom::StopTimerAndPrintResultL()
       
   851 	{
       
   852 	TTime endTime;
       
   853 	endTime.HomeTime();
       
   854 	PrintPerformanceLog(endTime);
       
   855 	
       
   856 	TTimeIntervalMicroSeconds duration = endTime.MicroSecondsFrom(iStartTime);
       
   857 	TInt actualDuration = (I64INT(duration.Int64())/1000)/iIterationCount; // in millisecond
       
   858 	
       
   859 	INFO_PRINTF3(_L("%S,%d"), &KActualTestCaseDuration(), actualDuration);
       
   860 	}
       
   861