os/security/cryptoservices/certificateandkeymgmt/tcertstore/t_concurrentcertstore.cpp
First public contribution.
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
23 #include "t_concurrentcertstore.h"
25 #include "t_certstoredefs.h"
27 _LIT8(KConcurrentTestStart, "<KConcurrentTesting>");
28 _LIT8(KConcurrentTestEnd, "</KConcurrentTesting>");
30 CTestAction* CTestConcurrentCertStore::NewL(RFs& aFs, CConsoleBase& aConsole, Output& aOut,
31 const TTestActionSpec& aTestActionSpec)
33 CTestAction* me = CTestConcurrentCertStore::NewLC(aFs, aConsole, aOut, aTestActionSpec);
34 CleanupStack::Pop(me);
38 CTestAction* CTestConcurrentCertStore::NewLC(RFs& aFs, CConsoleBase& aConsole, Output& aOut,
39 const TTestActionSpec& aTestActionSpec)
41 CTestConcurrentCertStore* me = new (ELeave) CTestConcurrentCertStore(aFs, aConsole, aOut);
42 CleanupStack::PushL(me);
43 me->ConstructL(aTestActionSpec);
47 CTestConcurrentCertStore::~CTestConcurrentCertStore()
50 CTestConcurrentCertStore::CTestConcurrentCertStore(RFs& aFs, CConsoleBase& aConsole, Output& aOut)
51 : CCertStoreTestAction(aFs, aConsole, aOut)
54 void CTestConcurrentCertStore::PerformAction(TRequestStatus& aStatus)
57 TRequestStatus* status = &aStatus;
58 User::RequestComplete(status, KErrNone);
61 void CTestConcurrentCertStore::DoReportAction()
64 void CTestConcurrentCertStore::DoCheckResult(TInt /*aError*/)
69 void CTestConcurrentCertStore::ConstructL(const TTestActionSpec& aTestActionSpec)
71 CTestAction::ConstructL(aTestActionSpec);
73 // Switch on performance testing?
76 TPtrC8 enablePtr = Input::ParseElement(aTestActionSpec.iActionBody, KConcurrentTestStart, KConcurrentTestEnd, pos, err);
78 _LIT8(KTrueVal, "ETrue");
79 _LIT8(KFalseVal, "EFalse");
81 TBool enable = EFalse;
82 if (enablePtr== KTrueVal)
84 else if (enablePtr!=KFalseVal)
85 User::Leave(KErrArgument);
87 CConcurrentTester::SetDoingConcurrentTesting(enable);
89 HBufC* result = HBufC::NewLC(aTestActionSpec.iActionResult.Length());
90 TPtr(result->Des()).Copy(aTestActionSpec.iActionResult);
91 Input::GetExpectedResultL(Input::ParseElement(*result, KReturnStart, KReturnEnd), iExpectedResult);
92 CleanupStack::PopAndDestroy(result);
96 void CTestConcurrentCertStore::DoPerformPrerequisite(TRequestStatus& aStatus)
98 TRequestStatus* status = &aStatus;
99 User::RequestComplete(status, KErrNone);
100 iActionState = CTestAction::EAction;
103 void CTestConcurrentCertStore::DoPerformPostrequisite(TRequestStatus& aStatus)
105 TRequestStatus* status = &aStatus;
107 User::RequestComplete(status, aStatus.Int());
110 ///////////////////////////////////////////////////////////
112 GLDEF_C TBool gMultiThreadTest;
114 void CConcurrentTester::SetDoingConcurrentTesting(TBool aTestConcurrent)
116 gMultiThreadTest=aTestConcurrent;
119 TBool CConcurrentTester::IsDoingConcurrentTesting()
121 return (gMultiThreadTest);
124 void CConcurrentTester::SanitizeTestResult(Output& aOut, TBool& aResult)
125 {// If running tests with multiple threads, failure may be expected
126 // Check if this is the case, and write a message to output
127 if (IsDoingConcurrentTesting())
129 _LIT(KConcurrent, "*** Concurrency testing is expecting failure ***");
130 aOut.writeString(KConcurrent);