testexecmdw/tef/tef/test/regressiontest/performancetest/src/te_regperformancesetlowmemteststep.cpp
branchRCL_3
changeset 3 9397a16b6eb8
parent 1 6edeef394eb7
equal deleted inserted replaced
1:6edeef394eb7 3:9397a16b6eb8
     1 /*
       
     2 * Copyright (c) 2005-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 "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 * Example CTestStep derived implementation
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 /**
       
    22  @file te_regperformancesetlowmemteststep.cpp
       
    23  @internalTechnology
       
    24 */
       
    25 #include <hal.h>
       
    26 #include "te_regperformancesetlowmemteststep.h"
       
    27 
       
    28 _LIT(KFreeRamSize, "FreeRamSize");
       
    29 _LIT(KChunkName, "ChunkName");
       
    30 const TInt KDefaultFreeRamSize = 8196;
       
    31 
       
    32 CTe_RegPerformanceSetLowMemTestStep::~CTe_RegPerformanceSetLowMemTestStep()
       
    33 /**
       
    34  * Destructor
       
    35  */
       
    36 	{
       
    37 	
       
    38 	}
       
    39 
       
    40 CTe_RegPerformanceSetLowMemTestStep::CTe_RegPerformanceSetLowMemTestStep(RChunk& aChunk) : iChunk(aChunk)
       
    41 /**
       
    42  * Constructor
       
    43  */
       
    44 	{
       
    45 	// **MUST** call SetTestStepName in the constructor as the controlling
       
    46 	// framework uses the test step name immediately following construction to set
       
    47 	// up the step's unique logging ID.
       
    48 	SetTestStepName(KTe_RegPerformanceSetLowMemTestStep);
       
    49 	}
       
    50 
       
    51 TVerdict CTe_RegPerformanceSetLowMemTestStep::doTestStepPreambleL()
       
    52 /**
       
    53  * @return - TVerdict code
       
    54  * Override of base class virtual
       
    55  */
       
    56 	{
       
    57 	SetTestStepResult(EPass);
       
    58 	return TestStepResult();
       
    59 	}
       
    60 
       
    61 
       
    62 TVerdict CTe_RegPerformanceSetLowMemTestStep::doTestStepL()
       
    63 /**
       
    64  * @return - TVerdict code
       
    65  * Override of base class pure virtual
       
    66  * Our implementation only gets called if the base class doTestStepPreambleL() did
       
    67  * not leave. That being the case, the current test result value will be EPass.
       
    68  */
       
    69 	{
       
    70 	INFO_PRINTF1(_L("Set Low Ram Condition"));
       
    71 	
       
    72 	TInt	freeRamSize=0;
       
    73 	
       
    74 	if(GetIntFromConfig(ConfigSection(), KFreeRamSize, freeRamSize))
       
    75 		{
       
    76 		INFO_PRINTF2(_L("The value of freeramsize is %D bytes"), freeRamSize);
       
    77 		}
       
    78 	else
       
    79 		{
       
    80 		freeRamSize = KDefaultFreeRamSize;
       
    81 		INFO_PRINTF2(_L("No freeramsize value!, default value(freeramsize=%d bytes) is used!"), freeRamSize);
       
    82 		}
       
    83 
       
    84 	TPtrC	chunkNamePtr;
       
    85 	if(GetStringFromConfig(ConfigSection(), KChunkName, chunkNamePtr))
       
    86 		{
       
    87 		INFO_PRINTF2(_L("ChunkName = %S"),&chunkNamePtr);
       
    88 		}
       
    89 	else
       
    90 		{
       
    91 		INFO_PRINTF1(_L("No Chunk Name!"));
       
    92 		SetTestStepResult(EFail);
       
    93 		}
       
    94 
       
    95 	iChunk.Close();
       
    96 	TInt totalFree = 0;
       
    97 	User::LeaveIfError(HAL::Get(HALData::EMemoryRAMFree, totalFree));
       
    98 	INFO_PRINTF2(_L("RAM status before stress condition: Total Free RAM:%D bytes"), totalFree);
       
    99 
       
   100 	TInt maxHeapSize = totalFree-freeRamSize;
       
   101 	if(TestStepResult() == EPass)
       
   102 		{
       
   103 		TInt err = KErrNone;
       
   104 		err = iChunk.CreateGlobal(chunkNamePtr, maxHeapSize, maxHeapSize);
       
   105 		if(err != KErrNone)
       
   106 			{
       
   107 			ERR_PRINTF1(_L("Create global chunk error!"));
       
   108 			SetTestStepResult(EFail);
       
   109 			}
       
   110 		}
       
   111 
       
   112 	if(TestStepResult() == EPass)
       
   113 		{
       
   114 		User::LeaveIfError(HAL::Get(HALData::EMemoryRAMFree, totalFree));
       
   115 		INFO_PRINTF2(_L("RAM status after stress condition: Total Free RAM:%D bytes"), totalFree);
       
   116 		}
       
   117 
       
   118 	return TestStepResult();
       
   119 	}
       
   120 
       
   121 
       
   122 
       
   123 TVerdict CTe_RegPerformanceSetLowMemTestStep::doTestStepPostambleL()
       
   124 /**
       
   125  * @return - TVerdict code
       
   126  * Override of base class virtual
       
   127  */
       
   128 	{
       
   129 	return TestStepResult();
       
   130 	}