os/security/cryptoservices/filebasedcertificateandkeystores/test/tfiletokens/CCheckServerHeapError.cpp
First public contribution.
2 * Copyright (c) 2003-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 "t_filetokens.h"
24 /////////////////////////////////////////////////////////////////////////////////
25 // CCheckServerHeapError
26 /////////////////////////////////////////////////////////////////////////////////
28 _LIT(KHeapErrorFile, "\\fsserver_heap_error");
30 EXPORT_C CTestAction* CCheckServerHeapError::NewL(RFs& aFs,
31 CConsoleBase& aConsole,
33 const TTestActionSpec& aTestActionSpec)
35 CCheckServerHeapError* self = new (ELeave) CCheckServerHeapError(aFs, aConsole, aOut);
36 CleanupStack::PushL(self);
37 self->ConstructL(aTestActionSpec);
38 CleanupStack::Pop(self);
42 CCheckServerHeapError::CCheckServerHeapError(RFs& aFs, CConsoleBase& aConsole, Output& aOut) :
43 CTestAction(aConsole, aOut), iFs(aFs)
47 void CCheckServerHeapError::ConstructL(const TTestActionSpec& aTestActionSpec)
49 CTestAction::ConstructL(aTestActionSpec);
50 TDriveUnit sysDrive (RFs::GetSystemDrive());
51 TDriveName driveName(sysDrive.Name());
52 TBuf<128> heapErrFile (driveName);
53 heapErrFile.Append(KHeapErrorFile);
54 TInt err = iFs.Delete(heapErrFile);
55 if (err != KErrNone && err != KErrNotFound)
61 CCheckServerHeapError::~CCheckServerHeapError()
65 void CCheckServerHeapError::DoPerformPrerequisite(TRequestStatus& aStatus)
67 iActionState = EAction;
68 TRequestStatus* status = &aStatus;
69 User::RequestComplete(status, KErrNone);
72 void CCheckServerHeapError::PerformAction(TRequestStatus& aStatus)
74 TRequestStatus* status = &aStatus;
77 TDriveUnit sysDrive (RFs::GetSystemDrive());
78 TDriveName driveName(sysDrive.Name());
79 TBuf<128> heapErrFile (driveName);
80 heapErrFile.Append(KHeapErrorFile);
82 TInt err = file.Open(iFs, heapErrFile, EFileRead | EFileShareExclusive);
84 if (err != KErrNone && err != KErrNotFound)
88 User::RequestComplete(status, err);
94 iResult = (err == KErrNotFound);
96 User::RequestComplete(status, KErrNone);
99 void CCheckServerHeapError::DoPerformPostrequisite(TRequestStatus& aStatus)
101 TRequestStatus* status = &aStatus;
102 User::RequestComplete(status, KErrNone);
105 void CCheckServerHeapError::PerformCancel()
110 void CCheckServerHeapError::Reset()
114 void CCheckServerHeapError::DoReportAction()
116 iOut.writeString(_L("Checking for server heap error..."));
120 void CCheckServerHeapError::DoCheckResult(TInt /*aError*/)
126 _LIT(KSuccessful, "No heap error\n");
127 iConsole.Write(KSuccessful);
128 iOut.writeString(KSuccessful);
134 _LIT(KFailed, "!!!Server heap error detected!!!\n");
135 iConsole.Write(KFailed);
136 iOut.writeString(KFailed);