os/security/cryptoservices/certificateandkeymgmt/tcertstore/t_concurrentcertstore.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/cryptoservices/certificateandkeymgmt/tcertstore/t_concurrentcertstore.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,135 @@
     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 + @file
    1.24 +*/
    1.25 +
    1.26 +#include "t_concurrentcertstore.h"
    1.27 +#include "t_input.h"
    1.28 +#include "t_certstoredefs.h"
    1.29 +
    1.30 +_LIT8(KConcurrentTestStart, "<KConcurrentTesting>");
    1.31 +_LIT8(KConcurrentTestEnd, "</KConcurrentTesting>");
    1.32 +
    1.33 +CTestAction* CTestConcurrentCertStore::NewL(RFs& aFs, CConsoleBase& aConsole, Output& aOut, 
    1.34 +											const TTestActionSpec& aTestActionSpec)
    1.35 +{
    1.36 +	CTestAction* me = CTestConcurrentCertStore::NewLC(aFs, aConsole, aOut, aTestActionSpec);
    1.37 +	CleanupStack::Pop(me);
    1.38 +	return (me);
    1.39 +}
    1.40 +											
    1.41 +CTestAction* CTestConcurrentCertStore::NewLC(RFs& aFs, CConsoleBase& aConsole, Output& aOut, 
    1.42 +											const TTestActionSpec& aTestActionSpec)
    1.43 +{
    1.44 +	CTestConcurrentCertStore* me = new (ELeave) CTestConcurrentCertStore(aFs, aConsole, aOut);
    1.45 +	CleanupStack::PushL(me);
    1.46 +	me->ConstructL(aTestActionSpec);
    1.47 +	return (me);
    1.48 +}
    1.49 +
    1.50 +CTestConcurrentCertStore::~CTestConcurrentCertStore()
    1.51 +{}
    1.52 +
    1.53 +CTestConcurrentCertStore::CTestConcurrentCertStore(RFs& aFs, CConsoleBase& aConsole, Output& aOut)
    1.54 +:	CCertStoreTestAction(aFs, aConsole, aOut)
    1.55 +{}
    1.56 +
    1.57 +void CTestConcurrentCertStore::PerformAction(TRequestStatus& aStatus)
    1.58 +{
    1.59 +	iFinished = ETrue;
    1.60 +	TRequestStatus* status = &aStatus;
    1.61 +	User::RequestComplete(status, KErrNone);	
    1.62 +}
    1.63 +
    1.64 +void CTestConcurrentCertStore::DoReportAction()
    1.65 +{}
    1.66 +
    1.67 +void CTestConcurrentCertStore::DoCheckResult(TInt /*aError*/)
    1.68 +{
    1.69 +	iResult = ETrue;
    1.70 +}
    1.71 +
    1.72 +void CTestConcurrentCertStore::ConstructL(const TTestActionSpec& aTestActionSpec)
    1.73 +{
    1.74 +	CTestAction::ConstructL(aTestActionSpec);
    1.75 +
    1.76 +//	Switch on performance testing?    
    1.77 +	TInt err = KErrNone;
    1.78 +	TInt pos = 0;
    1.79 +	TPtrC8 enablePtr = Input::ParseElement(aTestActionSpec.iActionBody, KConcurrentTestStart, KConcurrentTestEnd, pos, err);
    1.80 +    
    1.81 +	_LIT8(KTrueVal, "ETrue");
    1.82 +	_LIT8(KFalseVal, "EFalse");
    1.83 +
    1.84 +	TBool enable = EFalse;
    1.85 +    if (enablePtr== KTrueVal)
    1.86 +        enable = ETrue;
    1.87 +    else if (enablePtr!=KFalseVal)
    1.88 +        User::Leave(KErrArgument);
    1.89 +
    1.90 +	CConcurrentTester::SetDoingConcurrentTesting(enable);
    1.91 +	
    1.92 +	HBufC* result = HBufC::NewLC(aTestActionSpec.iActionResult.Length());
    1.93 + 	TPtr(result->Des()).Copy(aTestActionSpec.iActionResult);
    1.94 + 	Input::GetExpectedResultL(Input::ParseElement(*result, KReturnStart, KReturnEnd), iExpectedResult);
    1.95 + 	CleanupStack::PopAndDestroy(result);
    1.96 +
    1.97 +}
    1.98 +
    1.99 +void CTestConcurrentCertStore::DoPerformPrerequisite(TRequestStatus& aStatus)
   1.100 +	{
   1.101 +	TRequestStatus* status = &aStatus;
   1.102 +	User::RequestComplete(status, KErrNone);
   1.103 +	iActionState = CTestAction::EAction;
   1.104 +	}
   1.105 +
   1.106 +void CTestConcurrentCertStore::DoPerformPostrequisite(TRequestStatus& aStatus)
   1.107 +	{
   1.108 +	TRequestStatus* status = &aStatus;
   1.109 +	iFinished = ETrue;
   1.110 +	User::RequestComplete(status, aStatus.Int());
   1.111 +	}
   1.112 +
   1.113 +///////////////////////////////////////////////////////////
   1.114 +
   1.115 +GLDEF_C TBool gMultiThreadTest;
   1.116 +
   1.117 +void CConcurrentTester::SetDoingConcurrentTesting(TBool aTestConcurrent)
   1.118 +{
   1.119 +	gMultiThreadTest=aTestConcurrent;
   1.120 +}
   1.121 +
   1.122 +TBool CConcurrentTester::IsDoingConcurrentTesting()
   1.123 +{
   1.124 +	return (gMultiThreadTest);
   1.125 +}
   1.126 +
   1.127 +void CConcurrentTester::SanitizeTestResult(Output& aOut, TBool& aResult)
   1.128 +{//	If running tests with multiple threads, failure may be expected
   1.129 +//	Check if this is the case, and write a message to output
   1.130 +	if (IsDoingConcurrentTesting())
   1.131 +	{
   1.132 +		_LIT(KConcurrent, "*** Concurrency testing is expecting failure ***");
   1.133 +		aOut.writeString(KConcurrent);
   1.134 +		aOut.writeNewLine();
   1.135 +		aResult = ETrue;
   1.136 +	}
   1.137 +}
   1.138 +