os/security/cryptomgmtlibs/securitytestfw/test/captestframework/captestframeworkhelper.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/cryptomgmtlibs/securitytestfw/test/captestframework/captestframeworkhelper.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,107 @@
1.4 +/*
1.5 +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +
1.23 +
1.24 +/**
1.25 + @file
1.26 +*/
1.27 +
1.28 +//This is a dummy source file to be used to create a dummy exe
1.29 +#include <e32base.h>
1.30 +#include <f32file.h>
1.31 +
1.32 +#include "captestframework.h"
1.33 +
1.34 +
1.35 +void MainL();
1.36 +
1.37 +GLDEF_D TInt E32Main()
1.38 + {
1.39 + CTrapCleanup* cleanup = CTrapCleanup::New();
1.40 + if(cleanup == NULL)
1.41 + {
1.42 + return KErrNoMemory;
1.43 + }
1.44 +
1.45 + TRAPD(err,MainL());
1.46 + delete cleanup;
1.47 + return err;
1.48 + }
1.49 +
1.50 +HBufC* GetDesParameterL(TInt aParam)
1.51 + {
1.52 + // Get Dll name
1.53 + TInt length=User::ParameterLength(aParam);
1.54 + User::LeaveIfError(length);
1.55 +
1.56 + HBufC* des=HBufC::NewLC(length);
1.57 + TPtr desPtr=des->Des();
1.58 + User::LeaveIfError(User::GetDesParameter(aParam, desPtr));
1.59 +
1.60 + CleanupStack::Pop(des);
1.61 + return des;
1.62 + }
1.63 +
1.64 +
1.65 +HBufC* GetDllNameL()
1.66 + {
1.67 + return GetDesParameterL(KDllNameTransferSlot);
1.68 + }
1.69 +
1.70 +void MainL()
1.71 + {
1.72 + TInt err=KErrNone;
1.73 +
1.74 + // figure out which test we're supposed to be running
1.75 + HBufC* dllName=GetDllNameL();
1.76 +
1.77 + HBufC* logFileName=GetDesParameterL(KLogFileNameTransferSlot);
1.78 +
1.79 + TBool shouldPass;
1.80 + err = User::GetTIntParameter(KShouldPassTransferSlot, shouldPass);
1.81 + TInt testNumber;
1.82 + err = User::GetTIntParameter(KTestNumberTransferSlot, testNumber);
1.83 +
1.84 + // session
1.85 + RFs fs;
1.86 + User::LeaveIfError(fs.Connect());
1.87 + CleanupClosePushL(fs);
1.88 +
1.89 + //logfile
1.90 + RFile logFile;
1.91 + User::LeaveIfError(logFile.Replace(fs, *logFileName, 0));
1.92 + CleanupClosePushL(logFile);
1.93 +
1.94 + // load library
1.95 + RLibrary lib;
1.96 + User::LeaveIfError(lib.Load(*dllName));
1.97 + CleanupClosePushL(lib);
1.98 +
1.99 + //runtests
1.100 + TLibraryFunction testFactory=lib.Lookup(1);
1.101 + MCapabilityTestFactory* factory=reinterpret_cast<MCapabilityTestFactory*>(testFactory());
1.102 + factory->Test(testNumber)->SetExpectPermissionDenied(!shouldPass);
1.103 +
1.104 + TRAP(err, factory->Test(testNumber)->RunTestL(logFile));
1.105 +
1.106 + delete factory;
1.107 + CleanupStack::PopAndDestroy(3, &fs); // lib, logFile, fs
1.108 +
1.109 + User::LeaveIfError(err);
1.110 + }