diff -r 000000000000 -r a41df078684a kerneltest/e32test/misc/t_ramuse.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/kerneltest/e32test/misc/t_ramuse.cpp Mon Oct 19 15:55:17 2009 +0100 @@ -0,0 +1,144 @@ +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// e32test\misc\t_ramuse.cpp +// +// + +#include + +struct SThread + { + TUint iId; + HBufC* iFullName; + TInt iHandles; + }; + +struct SProcess + { + TUint iId; + HBufC* iFullName; + TInt iHandles; + }; + +LOCAL_D RTest test(_L("T_RAMUSE")); +LOCAL_D RArray Threads; +LOCAL_D RArray Processes; + +LOCAL_C void GetProcessInfo() + { + TFindProcess fp(_L("*")); + TFullName fn; + while (fp.Next(fn)==KErrNone) + { + RProcess p; + TInt r=p.Open(fp); + if (r!=KErrNone) + continue; + SProcess pInfo; + TProcessId pid=p.Id(); + pInfo.iId=*((TUint*)&pid); + pInfo.iFullName=fn.Alloc(); + pInfo.iHandles=-1; + p.Close(); + Processes.InsertInUnsignedKeyOrder(pInfo); + } + } + +LOCAL_C void GetThreadInfo() + { + TFindThread ft(_L("*")); + TFullName fn; + while (ft.Next(fn)==KErrNone) + { + RThread t; + TInt r=t.Open(ft); + if (r!=KErrNone) + continue; + SThread tInfo; + TThreadId tid=t.Id(); + tInfo.iId=*((TUint*)&tid); + tInfo.iFullName=fn.Alloc(); + TInt tHandles; + TInt pHandles; + t.HandleCount(pHandles,tHandles); + tInfo.iHandles=tHandles; + RProcess p; + r=t.Process(p); + if (r==KErrNone) + { + TProcessId pid=p.Id(); + SProcess pInfo; + pInfo.iId=*((TUint*)&pid); + TInt i; + r=Processes.FindInUnsignedKeyOrder(pInfo,i); + if (r==KErrNone) + { + if (Processes[i].iHandles<0) + Processes[i].iHandles=pHandles; + } + p.Close(); + } + t.Close(); + Threads.InsertInUnsignedKeyOrder(tInfo); + } + } + +LOCAL_C void DisplayProcessInfo() + { + TInt n=Processes.Count(); + TInt i; + test.Printf(_L("%d Processes:\n"),n); + for (i=0; i