os/security/crypto/weakcryptospi/test/tcryptospi/src/hashpositiveobjectloadstep.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2007-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 * Example CTestStep derived implementation
    16 *
    17 */
    18 
    19 
    20 /**
    21  @file
    22  @internalTechnology
    23 */
    24 #include "hashpositiveobjectloadstep.h"
    25 
    26 #include <cryptospi/cryptohashapi.h>
    27 
    28 
    29 using namespace CryptoSpi;
    30 
    31 CHashPositiveObjectLoadStep::~CHashPositiveObjectLoadStep()
    32 	{
    33 	}
    34 
    35 
    36 CHashPositiveObjectLoadStep::CHashPositiveObjectLoadStep()
    37 	{
    38 	SetTestStepName(KHashPositiveObjectLoadStep);
    39 	}
    40 
    41 
    42 TVerdict CHashPositiveObjectLoadStep::doTestStepPreambleL()
    43 	{
    44 	SetTestStepResult(EPass);
    45 	return TestStepResult();
    46 	}
    47 
    48 
    49 TVerdict CHashPositiveObjectLoadStep::doTestStepL()
    50 	{
    51 	if (TestStepResult()==EPass)
    52 		{
    53 		
    54 		//Assume faliure, unless all is successful
    55 		SetTestStepResult(EFail);
    56 			
    57 		INFO_PRINTF1(_L("*** Hash - Positive Object Load ***"));
    58 		INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells());
    59 		
    60 		TVariantPtrC algorithmUid;
    61 		TVariantPtrC operationModeUid;
    62 		
    63 		//Extract the Test Case ID parameter from the specified INI file
    64 		if(!GetStringFromConfig(ConfigSection(),KConfigAlgorithmUid,algorithmUid) ||
    65 			!GetStringFromConfig(ConfigSection(),KConfigOperationMode,operationModeUid))
    66 			{
    67 			ERR_PRINTF1(_L("** Error: Failed to Load Configuration Parameters **"));
    68 			SetTestStepResult(EFail);
    69 			}
    70 		else
    71 			{
    72 			//Create and intialise a pointer for the Hash implementation object
    73 			CHash* hashImpl = NULL;
    74 			
    75 			INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells());
    76 			
    77 			//Retrieve a Hash factory object				
    78 			TRAPD(err,CHashFactory::CreateHashL(hashImpl,
    79 												algorithmUid,
    80 												operationModeUid,
    81 												NULL,
    82 												NULL));  
    83 				
    84 			//If there are no errors (KErrNone) creating the Hash factory object, Pass the Test	
    85 			if(hashImpl && (err == KErrNone))
    86 				{
    87 				INFO_PRINTF1(_L("*** Hash - Positive Object Load: PASS ***"));
    88 				delete hashImpl;
    89 				SetTestStepResult(EPass);	
    90 				}
    91 			else
    92 				{
    93 				ERR_PRINTF2(_L("*** FAIL: Failed to Create Hash Object - %d ***"), err);
    94 				SetTestStepResult(EFail);	
    95 				}
    96 			}
    97 		
    98 		INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells());
    99 		
   100 		}
   101 	return TestStepResult();
   102 	}
   103 
   104 
   105 TVerdict CHashPositiveObjectLoadStep::doTestStepPostambleL()
   106 	{
   107 	
   108 	return TestStepResult();
   109 	}