os/security/cryptoservices/certificateandkeymgmt/tcertstore/t_concurrentcertstore.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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  @file
    21 */
    22 
    23 #include "t_concurrentcertstore.h"
    24 #include "t_input.h"
    25 #include "t_certstoredefs.h"
    26 
    27 _LIT8(KConcurrentTestStart, "<KConcurrentTesting>");
    28 _LIT8(KConcurrentTestEnd, "</KConcurrentTesting>");
    29 
    30 CTestAction* CTestConcurrentCertStore::NewL(RFs& aFs, CConsoleBase& aConsole, Output& aOut, 
    31 											const TTestActionSpec& aTestActionSpec)
    32 {
    33 	CTestAction* me = CTestConcurrentCertStore::NewLC(aFs, aConsole, aOut, aTestActionSpec);
    34 	CleanupStack::Pop(me);
    35 	return (me);
    36 }
    37 											
    38 CTestAction* CTestConcurrentCertStore::NewLC(RFs& aFs, CConsoleBase& aConsole, Output& aOut, 
    39 											const TTestActionSpec& aTestActionSpec)
    40 {
    41 	CTestConcurrentCertStore* me = new (ELeave) CTestConcurrentCertStore(aFs, aConsole, aOut);
    42 	CleanupStack::PushL(me);
    43 	me->ConstructL(aTestActionSpec);
    44 	return (me);
    45 }
    46 
    47 CTestConcurrentCertStore::~CTestConcurrentCertStore()
    48 {}
    49 
    50 CTestConcurrentCertStore::CTestConcurrentCertStore(RFs& aFs, CConsoleBase& aConsole, Output& aOut)
    51 :	CCertStoreTestAction(aFs, aConsole, aOut)
    52 {}
    53 
    54 void CTestConcurrentCertStore::PerformAction(TRequestStatus& aStatus)
    55 {
    56 	iFinished = ETrue;
    57 	TRequestStatus* status = &aStatus;
    58 	User::RequestComplete(status, KErrNone);	
    59 }
    60 
    61 void CTestConcurrentCertStore::DoReportAction()
    62 {}
    63 
    64 void CTestConcurrentCertStore::DoCheckResult(TInt /*aError*/)
    65 {
    66 	iResult = ETrue;
    67 }
    68 
    69 void CTestConcurrentCertStore::ConstructL(const TTestActionSpec& aTestActionSpec)
    70 {
    71 	CTestAction::ConstructL(aTestActionSpec);
    72 
    73 //	Switch on performance testing?    
    74 	TInt err = KErrNone;
    75 	TInt pos = 0;
    76 	TPtrC8 enablePtr = Input::ParseElement(aTestActionSpec.iActionBody, KConcurrentTestStart, KConcurrentTestEnd, pos, err);
    77     
    78 	_LIT8(KTrueVal, "ETrue");
    79 	_LIT8(KFalseVal, "EFalse");
    80 
    81 	TBool enable = EFalse;
    82     if (enablePtr== KTrueVal)
    83         enable = ETrue;
    84     else if (enablePtr!=KFalseVal)
    85         User::Leave(KErrArgument);
    86 
    87 	CConcurrentTester::SetDoingConcurrentTesting(enable);
    88 	
    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);
    93 
    94 }
    95 
    96 void CTestConcurrentCertStore::DoPerformPrerequisite(TRequestStatus& aStatus)
    97 	{
    98 	TRequestStatus* status = &aStatus;
    99 	User::RequestComplete(status, KErrNone);
   100 	iActionState = CTestAction::EAction;
   101 	}
   102 
   103 void CTestConcurrentCertStore::DoPerformPostrequisite(TRequestStatus& aStatus)
   104 	{
   105 	TRequestStatus* status = &aStatus;
   106 	iFinished = ETrue;
   107 	User::RequestComplete(status, aStatus.Int());
   108 	}
   109 
   110 ///////////////////////////////////////////////////////////
   111 
   112 GLDEF_C TBool gMultiThreadTest;
   113 
   114 void CConcurrentTester::SetDoingConcurrentTesting(TBool aTestConcurrent)
   115 {
   116 	gMultiThreadTest=aTestConcurrent;
   117 }
   118 
   119 TBool CConcurrentTester::IsDoingConcurrentTesting()
   120 {
   121 	return (gMultiThreadTest);
   122 }
   123 
   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())
   128 	{
   129 		_LIT(KConcurrent, "*** Concurrency testing is expecting failure ***");
   130 		aOut.writeString(KConcurrent);
   131 		aOut.writeNewLine();
   132 		aResult = ETrue;
   133 	}
   134 }
   135