sl@0: /* sl@0: * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #include "t_filetokens.h" sl@0: #include "t_input.h" sl@0: #include "t_output.h" sl@0: #include sl@0: sl@0: ///////////////////////////////////////////////////////////////////////////////// sl@0: // CCheckServerHeapError sl@0: ///////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: _LIT(KHeapErrorFile, "\\fsserver_heap_error"); sl@0: sl@0: EXPORT_C CTestAction* CCheckServerHeapError::NewL(RFs& aFs, sl@0: CConsoleBase& aConsole, sl@0: Output& aOut, sl@0: const TTestActionSpec& aTestActionSpec) sl@0: { sl@0: CCheckServerHeapError* self = new (ELeave) CCheckServerHeapError(aFs, aConsole, aOut); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(aTestActionSpec); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: CCheckServerHeapError::CCheckServerHeapError(RFs& aFs, CConsoleBase& aConsole, Output& aOut) : sl@0: CTestAction(aConsole, aOut), iFs(aFs) sl@0: { sl@0: } sl@0: sl@0: void CCheckServerHeapError::ConstructL(const TTestActionSpec& aTestActionSpec) sl@0: { sl@0: CTestAction::ConstructL(aTestActionSpec); sl@0: TDriveUnit sysDrive (RFs::GetSystemDrive()); sl@0: TDriveName driveName(sysDrive.Name()); sl@0: TBuf<128> heapErrFile (driveName); sl@0: heapErrFile.Append(KHeapErrorFile); sl@0: TInt err = iFs.Delete(heapErrFile); sl@0: if (err != KErrNone && err != KErrNotFound) sl@0: { sl@0: User::Leave(err); sl@0: } sl@0: } sl@0: sl@0: CCheckServerHeapError::~CCheckServerHeapError() sl@0: { sl@0: } sl@0: sl@0: void CCheckServerHeapError::DoPerformPrerequisite(TRequestStatus& aStatus) sl@0: { sl@0: iActionState = EAction; sl@0: TRequestStatus* status = &aStatus; sl@0: User::RequestComplete(status, KErrNone); sl@0: } sl@0: sl@0: void CCheckServerHeapError::PerformAction(TRequestStatus& aStatus) sl@0: { sl@0: TRequestStatus* status = &aStatus; sl@0: sl@0: RFile file; sl@0: TDriveUnit sysDrive (RFs::GetSystemDrive()); sl@0: TDriveName driveName(sysDrive.Name()); sl@0: TBuf<128> heapErrFile (driveName); sl@0: heapErrFile.Append(KHeapErrorFile); sl@0: sl@0: TInt err = file.Open(iFs, heapErrFile, EFileRead | EFileShareExclusive); sl@0: sl@0: if (err != KErrNone && err != KErrNotFound) sl@0: { sl@0: iResult = EFalse; sl@0: iFinished = ETrue; sl@0: User::RequestComplete(status, err); sl@0: return; sl@0: } sl@0: sl@0: file.Close(); sl@0: sl@0: iResult = (err == KErrNotFound); sl@0: iFinished = ETrue; sl@0: User::RequestComplete(status, KErrNone); sl@0: } sl@0: sl@0: void CCheckServerHeapError::DoPerformPostrequisite(TRequestStatus& aStatus) sl@0: { sl@0: TRequestStatus* status = &aStatus; sl@0: User::RequestComplete(status, KErrNone); sl@0: } sl@0: sl@0: void CCheckServerHeapError::PerformCancel() sl@0: { sl@0: // nothing to cancel sl@0: } sl@0: sl@0: void CCheckServerHeapError::Reset() sl@0: { sl@0: } sl@0: sl@0: void CCheckServerHeapError::DoReportAction() sl@0: { sl@0: iOut.writeString(_L("Checking for server heap error...")); sl@0: iOut.writeNewLine(); sl@0: } sl@0: sl@0: void CCheckServerHeapError::DoCheckResult(TInt /*aError*/) sl@0: { sl@0: if (iFinished) sl@0: { sl@0: if (iResult) sl@0: { sl@0: _LIT(KSuccessful, "No heap error\n"); sl@0: iConsole.Write(KSuccessful); sl@0: iOut.writeString(KSuccessful); sl@0: iOut.writeNewLine(); sl@0: iOut.writeNewLine(); sl@0: } sl@0: else sl@0: { sl@0: _LIT(KFailed, "!!!Server heap error detected!!!\n"); sl@0: iConsole.Write(KFailed); sl@0: iOut.writeString(KFailed); sl@0: iOut.writeNewLine(); sl@0: iOut.writeNewLine(); sl@0: } sl@0: } sl@0: }