os/security/cryptoservices/filebasedcertificateandkeystores/source/generic/server/tokenserverdebug.cpp
Update contrib.
2 * Copyright (c) 2004-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.
22 #include "tokenserverdebug.h"
25 TInt TokenServerDebug::iCounter = 0;
26 TInt TokenServerDebug::iStartCount = 0;
27 TInt TokenServerDebug::iPauseCount = 0;
28 TInt TokenServerDebug::iInitialAllocCount = 0;
30 _LIT(KHeapErrorFile, "\\fsserver_heap_error");
32 void TokenServerDebug::StartOOMTest()
34 iStartCount = User::CountAllocCells();
38 void TokenServerDebug::IncHeapFailPoint()
40 __UHEAP_FAILNEXT(iCounter);
44 void TokenServerDebug::ResetHeapFail()
49 void TokenServerDebug::PauseOOMTest()
51 ASSERT(iPauseCount == 0); // Don't nest
55 iPauseCount = User::CountAllocCells();
59 void TokenServerDebug::ResumeOOMTest()
63 ASSERT(iPauseCount > 0);
64 __UHEAP_FAILNEXT(iCounter - (iPauseCount - iStartCount));
69 void TokenServerDebug::HeapCheckStart()
71 iInitialAllocCount = User::CountAllocCells();
74 void TokenServerDebug::HeapCheckEnd()
76 TInt finalAllocCount = User::CountAllocCells();
77 TRAP_IGNORE(HeapErrorL(finalAllocCount != iInitialAllocCount));
82 * Write or delete a file to signify to the test code that there's a memory leak
83 * in the server. This is unfortunately the best way of doing it since we can't
84 * trap a panic when the server's shutting down.
86 void TokenServerDebug::HeapErrorL(TBool aError)
89 User::LeaveIfError(fs.Connect());
91 TDriveUnit sysDrive (fs.GetSystemDrive());
92 TDriveName driveName(sysDrive.Name());
93 TFileName heapErrFile (driveName);
94 heapErrFile.Append(KHeapErrorFile);
99 TInt err = file.Create(fs, heapErrFile, EFileWrite | EFileShareExclusive);
100 if (err != KErrNone || err != KErrAlreadyExists)
108 TInt err = fs.Delete(heapErrFile);
109 if (err != KErrNone && err != KErrNotFound)