Update contrib.
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32utils\demandpaging\dptestcons.cpp
21 CConsoleBase* TheConsole;
26 TheConsole->Printf(_L("Usage: dptestcons [-h] [-o] [-f] [-sMIN,MAX]\n"));
27 TheConsole->Printf(_L("\n"));
28 TheConsole->Printf(_L("-h Prints this help information\n"));
29 TheConsole->Printf(_L("-o Prints all DPTest information\n"));
30 TheConsole->Printf(_L("-f Flushes the Demand Paging cache\n"));
31 TheConsole->Printf(_L("-s Sets the Demand Paging cache size (MIN and MAX in bytes)\n"));
34 void doDPTestInformation()
36 TheConsole->Printf(_L("DPTest information\n==================\n"));
37 TUint32 attribs = DPTest::Attributes();
40 TheConsole->Printf(_L("ROM Paging: %S\n"), (attribs&DPTest::ERomPaging) ? &KOn : &KOff);
41 TheConsole->Printf(_L("Code Paging: %S\n"), (attribs&DPTest::ECodePaging) ? &KOn : &KOff);
42 TheConsole->Printf(_L("Data Paging: %S\n"), (attribs&DPTest::EDataPaging) ? &KOn : &KOff);
46 TInt err = DPTest::CacheSize(min, max, current);
49 TheConsole->Printf(_L("CacheSize: Min=%u, Max=%u, Current=%u\n"), min, max, current);
53 TheConsole->Printf(_L("CacheSize failed with err=%d\n"), err);
55 TPckgBuf<DPTest::TEventInfo> eventPckg;
56 err = DPTest::EventInfo(eventPckg);
59 TheConsole->Printf(_L("EventInfo: PageFaultCount=%Lu, PageInCount=%Lu\n"), eventPckg().iPageFaultCount, eventPckg().iPageInReadCount);
63 TheConsole->Printf(_L("EventInfo failed with err=%d\n"), err);
65 TheConsole->Printf(_L("==================\n"));
70 TInt err = DPTest::FlushCache();
71 TheConsole->Printf(_L("FlushCache completed with err=%d\n"), err);
74 void doSetCacheSize(const TDesC& aCacheSizes)
76 TLex lex(aCacheSizes);
78 while (c != 0 && c != ',')
83 TPtrC valDes = lex.MarkedToken();
85 if (TLex(valDes).Val(min) != KErrNone)
87 TheConsole->Printf(_L("Bad minimum value provided for SetCacheSize: %S\n"), &valDes);
94 valDes.Set(lex.Remainder());
96 if (TLex(valDes).Val(max) != KErrNone)
98 TheConsole->Printf(_L("Bad maximum value provided for SetCacheSize: %S\n"), &valDes);
101 TInt err = DPTest::SetCacheSize(min, max);
102 TheConsole->Printf(_L("SetCacheSize (Min=%u, Max=%u) completed with err=%d\n"), min, max, err);
105 void processCommands(RArray<TPtrC> aArgArray)
107 const TInt count = aArgArray.Count();
113 for (TInt ii=0; ii<count; ii++)
115 TPtrC current = aArgArray[ii];
116 if (current.Length() < 2 || current[0] != '-')
118 TheConsole->Printf(_L("Unknown command: %S\n"), ¤t);
126 doDPTestInformation();
132 doSetCacheSize(current.Mid(2));
135 TheConsole->Printf(_L("Unknown command: %S\n"), ¤t);
144 TFileName exeFile = RProcess().FileName();
145 TRAPD(err, TheConsole = Console::NewL(exeFile,TSize(KConsFullScreen,KConsFullScreen)));
146 TheConsole->Printf(_L("---DPTESTCONS---\n"));
151 // get command-line...
153 if (clDes.Create(User::CommandLineLength()+1) != KErrNone)
157 User::CommandLine(clDes);
160 RArray<TPtrC> argArray;
164 err = argArray.Append(lex.NextToken());
170 processCommands(argArray);
172 TheConsole->Printf(_L("Press any key to continue.\n"));