testexecmdw/tef/tef/tefutilities/platsec/src/testplatseccleanup.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 * This contains CTestPlatSecCleanup class functions implementation.
       
    16 * This class sets the capabilities of the executables and libraries.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #include "testplatseccleanup.h"
       
    22 
       
    23 //TEF include
       
    24 #include <test/testexecutelog.h>
       
    25 
       
    26 /*@{*/
       
    27 _LIT(KDestinationPath,		"destinationPath");
       
    28 /*@}*/
       
    29 
       
    30 // Test step name
       
    31 _LIT(KCleanupStep,	"Cleanup");
       
    32 
       
    33 /**
       
    34  Destructor
       
    35 */
       
    36 CTestPlatSecCleanup::~CTestPlatSecCleanup()
       
    37 	{
       
    38 	}
       
    39 
       
    40 /** 
       
    41  Constructor
       
    42 */
       
    43 CTestPlatSecCleanup::CTestPlatSecCleanup()
       
    44 	{
       
    45 	SetTestStepName(KCleanupStep);
       
    46 	}
       
    47 
       
    48 /**
       
    49  The implementation of the CTestPlatSecCleanup::doTestStepL() pure virutal
       
    50  function. Gets the required executable (server) to be deleted. It reads 
       
    51  the  destination executable name  from the ini file and calls DeleteExtraServersL function.
       
    52  @return TVerdict - result of the test step
       
    53  @leave - system wide error codes
       
    54 */
       
    55 TVerdict CTestPlatSecCleanup::doTestStepL()
       
    56 	{
       
    57 	INFO_PRINTF1(_L("Cleaning up the exe"));
       
    58 
       
    59 	TPtrC ServerName(GetServerName());
       
    60 	INFO_PRINTF1(_L("Server Name"));
       
    61 	INFO_PRINTF2(_L("Server Name %S"), &ServerName);
       
    62 	
       
    63 	TPtrC destination;
       
    64 	if(!GetStringFromConfig(ConfigSection(), KDestinationPath, destination))
       
    65 		{
       
    66 		ERR_PRINTF1(_L("Executable/Server name not provided in INI file"));
       
    67 		SetTestStepResult(EFail);
       
    68 		return TestStepResult();	
       
    69 		}
       
    70 	DeleteExtraServersL(destination);
       
    71 	return TestStepResult();
       
    72 	}
       
    73 
       
    74 /**
       
    75 Deletes the extra servers created with limited capabilities. Uses Plattest_Platsec_Cleanup.exe
       
    76   @param aDestination - name of the executable to be deleted
       
    77  @leave - system wide error codes
       
    78  @return None
       
    79 */
       
    80 void CTestPlatSecCleanup::DeleteExtraServersL(const TDesC& aDestination)
       
    81 	{
       
    82 	RProcess process;
       
    83 	CleanupClosePushL(process);
       
    84 	TInt err=KErrNone;
       
    85 	_LIT(KTEFCleanupExe, "TEFCleanup.exe");
       
    86 	err = process.Create(KTEFCleanupExe,aDestination);
       
    87 	if(err!=KErrNone)
       
    88 		{
       
    89 		ERR_PRINTF2(_L("Creating the process failed with error : %D"),err);
       
    90 		SetTestStepResult(EFail);
       
    91 		}
       
    92 	else
       
    93 		{
       
    94 		TRAP(err,process.Resume();)
       
    95 		if(err!=KErrNone)
       
    96 			{
       
    97 			ERR_PRINTF2(_L("Creating the process failed with error : %D"),err);
       
    98 			SetTestStepResult(EFail);
       
    99 			}
       
   100 		}
       
   101 	CleanupStack::PopAndDestroy(1);
       
   102 	}