Update contrib.
2 * Copyright (c) 1998-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.
19 #include "tvectortest.h"
22 #include <asymmetric.h>
25 #include "tvectorutils.h"
26 #include "performancetest.h"
27 #include <securityerr.h>
29 _LIT8(KKeyBitsStart, "<keybits>");
30 _LIT8(KKeyBitsEnd, "</keybits>");
31 _LIT8(KResultStart, "<result>");
32 _LIT8(KResultEnd, "</result>");
34 ////////////////////////////////////////////////////////////////////////////////
36 ////////////////////////////////////////////////////////////////////////////////
38 CVectorTest::CVectorTest(CConsoleBase& aConsole, Output& aOut)
39 : CTestAction(aConsole, aOut), iPerfTestIterations(100)
43 CVectorTest::~CVectorTest()
47 void CVectorTest::ConstructL(const TTestActionSpec& aTestActionSpec)
49 CTestAction::ConstructL(aTestActionSpec);
51 if (CPerformance::PerformanceTester()->IsTestingPerformance())
52 {// Number of test iterations
53 TPtrC8 itsPtr = Input::ParseElement(aTestActionSpec.iActionBody, KIterationsStart, KIterationsEnd);
54 if (itsPtr!=KNullDesC8)
58 User::LeaveIfError(lex.Val(iPerfTestIterations));
59 if (iPerfTestIterations > KMaxIterations)
60 User::Panic(_L("AsymmetricPerformance.exe"), KErrArgument);
64 TPtrC8 keyBitsPtr = Input::ParseElement(aTestActionSpec.iActionBody, KKeyBitsStart, KKeyBitsEnd);
65 if (keyBitsPtr!=KNullDesC8)
68 lex.Assign(keyBitsPtr);
69 User::LeaveIfError(lex.Val(iKeyBits));
72 TPtrC8 resultIn = Input::ParseElement(aTestActionSpec.iActionResult, KResultStart, KResultEnd);
73 iExpectedResult = VectorUtils::ParseBoolL(resultIn);
76 void CVectorTest::PerformAction(TRequestStatus& aStatus)
78 TRequestStatus* status = &aStatus;
80 if (CPerformance::PerformanceTester()->IsTestingPerformance())
82 iConsole.Printf(_L(">")); // Indicates start of test
83 TRAP(iActionResult, DoPerformanceTestActionL());
87 TRAP(iActionResult, DoPerformActionL());
90 if (iActionResult==KErrNoMemory)
92 User::Leave(iActionResult); // For OOM testing
94 if (iActionResult==KErrKeyNotWeakEnough)
97 iConsole.Printf(_L("Crypto libraries returned KErrKeyNotWeakEnough! Passing test automatically.\n\r"));
98 iOut.writeString(_L("Crypto libraries returned KErrKeyNotWeakEnough! Passing test automatically.\n\r"));
101 User::RequestComplete(status, iActionResult);
103 iActionState = CTestAction::EPostrequisite;
107 void CVectorTest::DoPerformPrerequisite(TRequestStatus& aStatus)
109 TRequestStatus* status = &aStatus;
110 User::RequestComplete(status, KErrNone);
111 iActionState = CTestAction::EAction;
114 void CVectorTest::DoPerformPostrequisite(TRequestStatus& aStatus)
116 TRequestStatus* status = &aStatus;
118 User::RequestComplete(status, KErrNone);
121 void CVectorTest::DoReportAction(void)
125 void CVectorTest::DoCheckResult(TInt /*aError*/)
127 // If using Keith's fixed up testframework for testing failures, iResult will
128 // have already been corrected for a deliberate fail result.
129 // If not using Keith's testframework iResult is still a fail result at this
130 // point, so now's the time to adjust for deliberate failure.
133 iResult = (iResult && iExpectedResult) || (!iResult && !iExpectedResult);
136 iConsole.Printf(_L("."));
138 iConsole.Printf(_L("X"));