cryptomgmtlibs/securitytestfw/test/captestframework/captestframeworkhelper.cpp
changeset 8 35751d3474b7
child 15 da2ae96f639b
equal deleted inserted replaced
2:675a964f4eb5 8:35751d3474b7
       
     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 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 
       
    20 
       
    21 /**
       
    22  @file
       
    23 */
       
    24 
       
    25 //This is a dummy source file to be used to create a dummy exe
       
    26 #include <e32base.h>
       
    27 #include <f32file.h>
       
    28 
       
    29 #include <captestframework/captestframework.h>
       
    30 
       
    31 
       
    32 void MainL();
       
    33 
       
    34 GLDEF_D TInt E32Main()
       
    35 	{
       
    36 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    37 	if(cleanup == NULL)
       
    38 		{
       
    39 		return KErrNoMemory;
       
    40 		}
       
    41 	
       
    42 	TRAPD(err,MainL());
       
    43 	delete cleanup;
       
    44 	return err;
       
    45 	}
       
    46 
       
    47 HBufC* GetDesParameterL(TInt aParam)
       
    48 	{
       
    49 	// Get Dll name	
       
    50 	TInt length=User::ParameterLength(aParam);
       
    51 	User::LeaveIfError(length);
       
    52 	
       
    53 	HBufC* des=HBufC::NewLC(length);
       
    54 	TPtr desPtr=des->Des();
       
    55 	User::LeaveIfError(User::GetDesParameter(aParam, desPtr));
       
    56 
       
    57 	CleanupStack::Pop(des);
       
    58 	return des;
       
    59 	}
       
    60 
       
    61 
       
    62 HBufC* GetDllNameL()
       
    63 	{
       
    64 	return GetDesParameterL(KDllNameTransferSlot);
       
    65 	}
       
    66 
       
    67 void MainL()
       
    68 	{
       
    69 	TInt err=KErrNone;
       
    70 	
       
    71 	// figure out which test we're supposed to be running
       
    72 	HBufC* dllName=GetDllNameL();
       
    73 	
       
    74 	HBufC* logFileName=GetDesParameterL(KLogFileNameTransferSlot);
       
    75 	
       
    76 	TBool shouldPass;
       
    77 	err = User::GetTIntParameter(KShouldPassTransferSlot, shouldPass);
       
    78 	TInt testNumber;
       
    79 	err = User::GetTIntParameter(KTestNumberTransferSlot, testNumber);
       
    80 
       
    81 	// session
       
    82 	RFs fs;
       
    83 	User::LeaveIfError(fs.Connect());
       
    84 	CleanupClosePushL(fs);
       
    85 		
       
    86 	//logfile
       
    87 	RFile logFile;
       
    88 	User::LeaveIfError(logFile.Replace(fs, *logFileName, 0));
       
    89 	CleanupClosePushL(logFile);
       
    90 	
       
    91 	// load library
       
    92 	RLibrary lib;
       
    93 	User::LeaveIfError(lib.Load(*dllName));
       
    94 	CleanupClosePushL(lib);
       
    95 	
       
    96 	//runtests
       
    97 	TLibraryFunction testFactory=lib.Lookup(1);
       
    98 	MCapabilityTestFactory* factory=reinterpret_cast<MCapabilityTestFactory*>(testFactory());
       
    99 	factory->Test(testNumber)->SetExpectPermissionDenied(!shouldPass);
       
   100 	
       
   101 	TRAP(err, factory->Test(testNumber)->RunTestL(logFile));
       
   102 
       
   103 	delete factory;
       
   104 	CleanupStack::PopAndDestroy(3, &fs); // lib, logFile, fs
       
   105 	
       
   106 	User::LeaveIfError(err);
       
   107 	}