Update contrib.
1 // Copyright (c) 2006-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 // f32test\demandpaging\t_pagestress.cpp
15 // Demand Paging Stress Tests
16 // t_pagestress.exe basically attempts to cause large ammounts of paging by calling
17 // functions (256) which are alligned on a page boundary from multiple threads.
18 // There are mulitple versions of t_pagestress installed on a test system to test rom
19 // and code paging from various media types.
21 // t_pagestress and t_pagestress_rom
22 // Common command lines:
23 // t_pagestress lowmem
24 // debug - switch on debugging information
25 // silent - no output to the screen or serial port
26 // check - check the allignments
27 // single - run the tests in a single thread
28 // multiple <numThreads> - run the tests in multiple threads where <numThreads>
29 // interleave - force thread interleaving
30 // prio - each thread reschedules in between each function call, causes lots of context changes
31 // media - perform media access during the tests, very stressful
32 // lowmem - low memory tests
33 // forward - patern in which to execute function calls
34 // backward - patern in which to execute function calls
35 // random - patern in which to execute function calls
36 // all - patern in which to execute function calls (forward, backward and random)
37 // inst - for debugging a parameter passed to a spawned exe to give it an id.
38 // iters <count> - the number of times to loop (a '-' means run forever)
39 // t_pagestress causes a large ammount of paging by repeatedly calling
40 // 256 functions which have been aligned on page boundaries from
42 // 1 - a single thread calling all functions
43 // 2 - Multiple threads calling all functions
44 // 3 - Multiple threads calling all functions with a priority change
45 // after each function call
46 // 4 - Multiple threads calling all functions with background
48 // 5 - Multiple threads calling all functions with media activity and
49 // a priority change after each function call
50 // 6 - Multiple threads calling all functions with process interleave
51 // 7 - Multiple threads calling all functions with process interleave
52 // and a priority change after each function call
53 // 8 - Multiple threads calling all functions with process interleave
54 // media acess and a priority change after each function call
55 // 9 - Multiple threads calling all functions with low available memory
56 // 10 - Multiple threads calling all functions with low available memory,
57 // starting with initial free ram.
61 //! @SYMTestCaseID KBASE-T_PAGESTRESS-0327
64 //! @SYMTestCaseDesc Demand Paging Stress Tests
65 //! @SYMTestActions 0 - Check the alignment of all functions
66 //! @SYMTestExpectedResults All tests should pass.
67 //! @SYMTestPriority High
68 //! @SYMTestStatus Implemented
71 RTest test(_L("T_PAGESTRESS"));
78 #include <e32msgqueue.h>
84 #define TEST_ON_UNPAGED
88 /* The following line will cause t_pagestress.h to declare an array of function
89 * pointers to page boundary aligned functions that we can use in this test...
91 #define TPS_DECLARE_ARRAY
92 #include "t_pagestress.h"
94 TBool TestDebug = EFalse;
95 TBool TestSilent = EFalse;
96 TBool TestExit = EFalse;
98 TBool TestCheck = EFalse;
99 TBool TestSingle = EFalse;
100 TBool TestMultiple = EFalse;
101 TBool TestForever = EFalse;
102 TInt TestMaxLoops = 20;
103 TInt TestMultipleThreadCount = 50;
104 TInt TestInstanceId = 0;
106 #define TEST_INTERLEAVE_PRIO EPriorityMore//EPriorityRealTime //23 // KNandThreadPriority - 1
107 TBool TestInterleave = EFalse;
108 TBool TestWeAreTheTestBase = EFalse;
109 TBool TestBootedFromMmc = EFalse;
110 TInt DriveNumber=-1; // Parameter - Which drive? -1 = autodetect.
111 #define TEST_NONE 0x0
112 #define TEST_FORWARD 0x2
113 #define TEST_BACKWARD 0x4
114 #define TEST_RANDOM 0x8
115 #define TEST_ALL (TEST_RANDOM | TEST_BACKWARD | TEST_FORWARD)
116 TUint32 TestWhichTests = TEST_ALL;
117 TBuf<32> TestNameBuffer;
118 TBool TestPrioChange = ETrue;
119 TBool TestStopMedia = EFalse;
120 TBool TestMediaAccess = EFalse;
121 #define TEST_LM_NUM_FREE 0
122 #define TEST_LM_BLOCKSIZE 1
123 #define TEST_LM_BLOCKS_FREE 4
124 TBool TestLowMem = EFalse;
125 RPageStressTestLdd Ldd;
126 TInt TestPageSize = 4096;
127 RSemaphore TestMultiSem;
128 RMsgQueue<TBuf <64> > TestMsgQueue;
129 TBool TestIsDemandPaged = ETrue;
132 #define TEST_NEXT(__args) \
136 #define DBGS_PRINT(__args)\
140 #define DBGD_PRINT(__args)\
142 test.Printf __args ;\
144 #define DEBUG_PRINT(__args)\
147 if (aMsgQueue && aBuffer && aTheSem)\
150 aBuffer->Format __args ;\
152 aMsgQueue->SendBlocking(*aBuffer);\
157 test.Printf __args ;\
161 #define RUNTEST(__test, __error)\
163 test(__test == __error);\
167 #define RUNTEST1(__test)\
171 #define DEBUG_PRINT1(__args)\
180 // The following functions wanders through the function pointer array
181 // declared in t_pagestress.h and ensures that the alignment has worked,
182 // (a good start!) and then calls each of the functions in turn to
183 // ensure that they work, simple first sanity check test.
186 TInt CheckAlignments()
188 // now it's time to play with the array of function pointers...
193 while (index < (PAGESTRESS_FUNC_COUNT - 1))
195 DBGD_PRINT((_L("\nAddress (%u) 0x%x difference to next %u\n"), index, (TUint32)PagestressFuncPtrs[index], (TUint32)PagestressFuncPtrs[index + 1] - (TUint32)PagestressFuncPtrs[index]));
196 if ((((TUint32)PagestressFuncPtrs[index + 1] - (TUint32)PagestressFuncPtrs[0]) % 4096) != 0)
198 DBGS_PRINT((_L("\nError! Allignment for %u is not offset of 4096 from index 0 0x%x 0x%x\n"), index, (TUint32)PagestressFuncPtrs[index + 1], (TUint32)PagestressFuncPtrs[0]));
201 //seed = PagestressFuncPtrs[index](seed, index);
202 seed = CallTestFunc(seed, index, index);
211 // Walk through the function pointer array (forwards) calling each function
214 void RunThreadForward()
220 while (index < PAGESTRESS_FUNC_COUNT)
224 TThreadPriority originalThreadPriority = thisThread.Priority();
225 thisThread.SetPriority(EPriorityLess);
226 User::AfterHighRes(0);
227 thisThread.SetPriority(originalThreadPriority);
229 //seed = PagestressFuncPtrs[index](seed, index);
230 seed = CallTestFunc(seed, index, index);
238 // Walk through the function pointer array (backwards) calling each function
241 void RunThreadBackward()
244 TInt index = PAGESTRESS_FUNC_COUNT;
251 TThreadPriority originalThreadPriority = thisThread.Priority();
252 thisThread.SetPriority(EPriorityLess);
253 User::AfterHighRes(0);
254 thisThread.SetPriority(originalThreadPriority);
257 //seed = PagestressFuncPtrs[index](seed, index);
258 seed = CallTestFunc(seed, index, index);
265 // Walk through the function pointer array in a random order a number of times calling each function
268 void RunThreadRandom()
275 while (index < (TInt)PAGESTRESS_FUNC_COUNT)
279 TThreadPriority originalThreadPriority = thisThread.Priority();
280 thisThread.SetPriority(EPriorityLess);
281 User::AfterHighRes(0);
282 thisThread.SetPriority(originalThreadPriority);
284 randNum = Math::Random();
285 randNum %= PAGESTRESS_FUNC_COUNT;
286 //seed = PagestressFuncPtrs[randNum](seed, randNum);
287 seed = CallTestFunc(seed, randNum, randNum);
296 // This is the function that actually does the work.
297 // It is complicated a little because test.Printf can only be called from the first thread that calls it
298 // so if we are using multiple threads we need to use a message queue to pass the debug info from the
299 // child threads back to the parent for the parent to then call printf.
303 LOCAL_C void PerformTestThread(TInt aThreadIndex,
304 RMsgQueue<TBuf <64> > *aMsgQueue = NULL,
305 TBuf<64> *aBuffer = NULL,
306 RSemaphore *aTheSem = NULL)
308 TUint start = User::TickCount();
310 DEBUG_PRINT1((_L("%S : thread Starting %d\n"), &TestNameBuffer, aThreadIndex));
312 // now select how we do the test...
315 if (TEST_ALL == (TestWhichTests & TEST_ALL))
317 #define LOCAL_ORDER_INDEX1 6
318 #define LOCAL_ORDER_INDEX2 3
319 TInt order[LOCAL_ORDER_INDEX1][LOCAL_ORDER_INDEX2] = { {TEST_FORWARD, TEST_BACKWARD,TEST_RANDOM},
320 {TEST_FORWARD, TEST_RANDOM, TEST_BACKWARD},
321 {TEST_BACKWARD,TEST_FORWARD, TEST_RANDOM},
322 {TEST_BACKWARD,TEST_RANDOM, TEST_FORWARD},
323 {TEST_RANDOM, TEST_FORWARD, TEST_BACKWARD},
324 {TEST_RANDOM, TEST_BACKWARD,TEST_FORWARD}};
327 for (iterIndex = 0; iterIndex < TestMaxLoops; iterIndex ++)
329 TInt selOrder = ((aThreadIndex + 1) * (iterIndex + 1)) % LOCAL_ORDER_INDEX1;
330 for (whichOrder = 0; whichOrder < LOCAL_ORDER_INDEX2; whichOrder ++)
332 switch (order[selOrder][whichOrder])
335 DEBUG_PRINT1((_L("%S : %d Iter %d Forward\n"), &TestNameBuffer, aThreadIndex, iterIndex));
340 DEBUG_PRINT1((_L("%S : %d Iter %d Backward\n"), &TestNameBuffer, aThreadIndex, iterIndex));
345 DEBUG_PRINT1((_L("%S : %d Iter %d Random\n"), &TestNameBuffer, aThreadIndex, iterIndex));
349 default: // this is really an error.
357 if (TestWhichTests & TEST_FORWARD)
359 for (iterIndex = 0; iterIndex < TestMaxLoops; iterIndex ++)
361 DEBUG_PRINT1((_L("%S : %d Iter %d Forward\n"), &TestNameBuffer, aThreadIndex, iterIndex));
366 if (TestWhichTests & TEST_BACKWARD)
368 for (iterIndex = 0; iterIndex < TestMaxLoops; iterIndex ++)
370 DEBUG_PRINT1((_L("%S : %d Iter %d Backward\n"), &TestNameBuffer, aThreadIndex, iterIndex));
375 if (TestWhichTests & TEST_RANDOM)
377 for (iterIndex = 0; iterIndex < TestMaxLoops; iterIndex ++)
379 DEBUG_PRINT1((_L("%S : %d Iter %d Random\n"), &TestNameBuffer, aThreadIndex, iterIndex));
384 DEBUG_PRINT1((_L("%S : thread Exiting %d (tickcount %u)\n"), &TestNameBuffer, aThreadIndex, User::TickCount() - start));
389 // MultipleTestThread
391 // Thread function, one created for each thread in a multiple thread test.
394 LOCAL_C TInt MultipleTestThread(TAny* aUseTb)
396 TBuf<64> localBuffer;
401 thisThread.SetPriority((TThreadPriority) TEST_INTERLEAVE_PRIO);
404 PerformTestThread((TInt) aUseTb, &TestMsgQueue, &localBuffer, &TestMultiSem);
412 // Perform the single thread test, spawning a number of threads.
415 LOCAL_C void DoSingleTest()
417 PerformTestThread((TInt) TestInstanceId);
423 // Find the first read write drive.
426 TInt FindDriveNumber(RFs fs)
428 TDriveInfo driveInfo;
429 for (TInt drvNum=0; drvNum<KMaxDrives; ++drvNum)
431 TInt r = fs.Drive(driveInfo, drvNum);
434 if (driveInfo.iType == EMediaHardDisk)
444 // Find the NAND drive
447 static TInt FindFsNANDDrive(RFs& aFs)
449 TDriveList driveList;
450 TDriveInfo driveInfo;
451 TInt r=aFs.DriveList(driveList);
454 for (TInt drvNum= (DriveNumber<0)?0:DriveNumber; drvNum<KMaxDrives; ++drvNum)
456 if(!driveList[drvNum])
457 continue; //-- skip unexisting drive
459 if (aFs.Drive(driveInfo, drvNum) == KErrNone)
461 if(driveInfo.iMediaAtt&KMediaAttPageable)
463 TBool readOnly = driveInfo.iMediaAtt & KMediaAttWriteProtected; // skip ROFS partitions
466 if ((drvNum==DriveNumber) || (DriveNumber<0)) // only test if running on this drive
479 // FindMMCDriveNumber
481 // Find the first read write drive.
484 TInt FindMMCDriveNumber(RFs& aFs)
486 TDriveInfo driveInfo;
487 for (TInt drvNum=0; drvNum<KMaxDrives; ++drvNum)
489 TInt r = aFs.Drive(driveInfo, drvNum);
492 if (driveInfo.iType == EMediaHardDisk)
500 // PerformRomAndFileSystemAccess
502 // Access the rom and dump it out to one of the writeable partitions...
503 // really just to make the media server a little busy during the test.
506 TInt PerformRomAndFileSystemAccessThread(RMsgQueue<TBuf <64> > *aMsgQueue = NULL,
507 TBuf<64> *aBuffer = NULL,
508 RSemaphore *aTheSem = NULL)
510 TUint maxBytes = KMaxTUint;
511 TInt startTime = User::TickCount();
515 if (KErrNone != fs.Connect())
517 DEBUG_PRINT(_L("PerformRomAndFileSystemAccessThread : Can't connect to the FS\n"));
521 // get info about the ROM...
522 TRomHeader* romHeader = (TRomHeader*)UserSvr::RomHeaderAddress();
525 if(romHeader->iPageableRomStart)
527 start = (TUint8*)romHeader + romHeader->iPageableRomStart;
528 end = start + romHeader->iPageableRomSize;
532 start = (TUint8*)romHeader;
533 end = start + romHeader->iUncompressedSize;
538 // read all ROM pages in a random order...and write out to file in ROFs,
539 TUint size = end - start - TestPageSize;
547 TInt drvNum = TestBootedFromMmc ? FindMMCDriveNumber(fs) : FindFsNANDDrive(fs);
548 TBuf<32> filename = _L("d:\\Pageldrtst.tmp");
551 filename[0] = 'a' + drvNum;
552 DEBUG_PRINT((_L("%S : Filename %S\n"), &TestNameBuffer, &filename));
555 DEBUG_PRINT((_L("PerformRomAndFileSystemAccessThread : error getting drive num\n")));
557 for(TInt i=size/(TestPageSize); i>0; --i)
559 DEBUG_PRINT1((_L("%S : Opening the file\n"), &TestNameBuffer));
560 if (KErrNone != file.Replace(fs, filename, EFileWrite))
562 DEBUG_PRINT((_L("%S : Opening the file Failed!\n"), &TestNameBuffer));
565 random = random*69069+1;
566 theAddr = (TUint8*)(start+((TInt64(random)*TInt64(size))>>32));
567 if (theAddr + TestPageSize > end)
569 DEBUG_PRINT((_L("%S : address is past the end 0x%x / 0x%x\n"), &TestNameBuffer, (TInt)theAddr, (TInt)end));
571 rom.Set(theAddr,TestPageSize);
572 DEBUG_PRINT1((_L("%S : Writing the file\n"), &TestNameBuffer));
573 TInt ret = file.Write(rom);
576 DEBUG_PRINT1((_L("%S : Write returned error %d\n"), &TestNameBuffer, ret));
578 DEBUG_PRINT1((_L("%S : Closing the file\n"), &TestNameBuffer));
581 DEBUG_PRINT1((_L("%S : Deleting the file\n"), &TestNameBuffer));
582 ret = fs.Delete(filename);
585 DEBUG_PRINT((_L("%S : Delete returned error %d\n"), &TestNameBuffer, ret));
591 DEBUG_PRINT1((_L("Done in %d ticks\n"), User::TickCount() - startTime));
597 // PerformRomAndFileSystemAccess
599 // Thread function, kicks off the file system access.
602 LOCAL_C TInt PerformRomAndFileSystemAccess(TAny* )
604 TBuf<64> localBuffer;
606 PerformRomAndFileSystemAccessThread(&TestMsgQueue, &localBuffer, &TestMultiSem);
614 // Perform the multiple thread test, spawning a number of threads.
615 // It is complicated a little because test.Printf can only be called from the first thread that calls it
616 // so if we are using multiple threads we need to use a message queue to pass the debug info from the
617 // child threads back to the parent for the parent to then call printf.
619 #define DOTEST(__operation, __condition)\
623 while (!__condition)\
625 Ldd.DoReleaseSomeRam(TEST_LM_BLOCKS_FREE);\
628 RUNTEST1(__condition);\
633 RUNTEST1(__condition);\
636 void DoMultipleTest(TBool aLowMem = EFalse)
640 RThread *pTheThreads = (RThread *)User::AllocZ(sizeof(RThread) * TestMultipleThreadCount);
641 TInt *pThreadInUse = (TInt *)User::AllocZ(sizeof(TInt) * TestMultipleThreadCount);
643 TRequestStatus mediaStatus;
647 DOTEST((ret = TestMsgQueue.CreateLocal(TestMultipleThreadCount * 10, EOwnerProcess)),
650 DOTEST((ret = TestMultiSem.CreateLocal(1)),
653 // make sure we have a priority higher than that of the threads we spawn...
655 TThreadPriority savedThreadPriority = thisThread.Priority();
656 const TThreadPriority KMainThreadPriority = EPriorityMuchMore;
657 __ASSERT_COMPILE(KMainThreadPriority>TEST_INTERLEAVE_PRIO);
658 thisThread.SetPriority(KMainThreadPriority);
662 TestStopMedia = EFalse;
663 mediaThread.Create(_L(""),PerformRomAndFileSystemAccess,KDefaultStackSize,NULL,NULL);
664 mediaThread.Logon(mediaStatus);
665 RUNTEST1(mediaStatus == KRequestPending);
666 mediaThread.Resume();
669 // spawn some processes to call the functions....
670 for (index = 0; index < TestMultipleThreadCount; index++)
672 DBGD_PRINT((_L("%S : Starting thread.%d!\n"), &TestNameBuffer, index));
673 DOTEST((ret = pTheThreads[index].Create(_L(""),MultipleTestThread,KDefaultStackSize,NULL,(TAny*) index)),
675 pTheThreads[index].Resume();
676 pThreadInUse[index] = 1;
679 // now process any messages sent from the child threads.
680 TBool anyUsed = ETrue;
681 TBuf<64> localBuffer;
686 // check the message queue and call printf if we get a message.
687 while (KErrNone == TestMsgQueue.Receive(localBuffer))
689 DBGS_PRINT((localBuffer));
692 // walk through the thread list to check which are still alive.
693 for (index = 0; index < TestMultipleThreadCount; index++)
695 if (pThreadInUse[index])
697 if (pTheThreads[index].ExitType() != EExitPending)
699 if (pTheThreads[index].ExitType() == EExitPanic)
701 DBGS_PRINT((_L("%S : Thread Panic'd %d...\n"), &TestNameBuffer, index));
703 pThreadInUse[index] = EFalse;
704 pTheThreads[index].Close();
712 User::AfterHighRes(50000);
717 TestStopMedia = ETrue;
718 DBGD_PRINT((_L("%S : Waiting for media thread to exit...\n"), &TestNameBuffer));
719 User::WaitForRequest(mediaStatus);
723 TestMsgQueue.Close();
724 TestMultiSem.Close();
726 // cleanup the resources and exit.
727 User::Free(pTheThreads);
728 User::Free(pThreadInUse);
730 thisThread.SetPriority(savedThreadPriority);
737 // read the arguments passed from the command line and set global variables to
738 // control the tests.
741 TBool ParseCommandLine()
744 User::CommandLine(args);
746 TBool retVal = ETrue;
748 // initially test for arguments, the parse them, if not apply some sensible defaults.
749 TBool foundArgs = EFalse;
753 TPtrC token=lex.NextToken();
754 if(token.Length()!=0)
756 if ((token == _L("help")) || (token == _L("-h")) || (token == _L("-?")))
758 DBGS_PRINT((_L("\nUsage: %S [debug] [check] [single | multiple <numThreads>] [forward | backward | random | all] [iters <iters>] [media] [lowmem] [interleave]\n'-' indicated infinity.\n\n"), &TestNameBuffer));
761 else if (token == _L("debug"))
766 TestPrioChange = ETrue;
769 else if (token == _L("silent"))
774 else if (token == _L("check"))
778 else if (token == _L("single"))
782 else if (token == _L("multiple"))
784 TPtrC val=lex.NextToken();
788 if (lexv.Val(value)==KErrNone)
790 if ((value <= 0) || (value > 100))
792 TestMultipleThreadCount = 10;
796 TestMultipleThreadCount = value;
801 DBGS_PRINT((_L("Bad value for thread count '%S' was ignored.\n"), &val));
805 TestMultiple = ETrue;
807 else if (token == _L("prio"))
809 TestPrioChange = !TestPrioChange;
811 else if (token == _L("lowmem"))
815 else if (token == _L("media"))
817 TestMediaAccess = ETrue;
819 else if (token == _L("forward"))
821 TestWhichTests = TEST_FORWARD;
823 else if (token == _L("backward"))
825 TestWhichTests = TEST_BACKWARD;
827 else if (token == _L("random"))
829 TestWhichTests = TEST_RANDOM;
831 else if (token == _L("all"))
833 TestWhichTests = TEST_ALL;
835 else if (token == _L("iters"))
837 TPtrC val=lex.NextToken();
844 TestMaxLoops = KMaxTInt;
848 if (lexv.Val(value)==KErrNone)
850 TestMaxLoops = value;
854 DBGS_PRINT((_L("Bad value for thread count '%S' was ignored.\n"), &val));
860 else if (token == _L("interleave"))
862 TestInterleave = ETrue;
864 else if (token == _L("inst"))
866 TPtrC val=lex.NextToken();
870 if (lexv.Val(value)==KErrNone)
872 TestInstanceId = value;
877 if ((foundArgs == EFalse) && (token.Length() == 1))
879 // Single letter argument...only run on MMC drive
880 if (token.CompareF(_L("d")) == 0)
889 test.Start(_L("Skipping non drive 'd' - Test Exiting."));
897 DBGS_PRINT((_L("Unknown argument '%S' was ignored.\n"), &token));
917 // Test whether we are the root of the tests.
920 void AreWeTheTestBase(void)
924 TFileName filename(RProcess().FileName());
927 myParse.Set(filename, NULL, NULL);
928 TestNameBuffer.Zero();
929 TestNameBuffer.Append(myParse.Name());
930 TestNameBuffer.Append(_L(".exe"));
932 TestWeAreTheTestBase = !TestNameBuffer.Compare(_L("t_pagestress.exe"));
935 if (KErrNone != fs.Connect())
938 TInt retVal = fs.Entry(_L("z:\\test\\mmcdemandpaginge32tests.bat"), anEntry);
939 if (retVal == KErrNone)
941 TestBootedFromMmc = ETrue;
945 TestBootedFromMmc = EFalse;
953 TestNameBuffer.Zero();
954 TestNameBuffer.Append(_L("t_pagestress.exe"));
961 // Perform the autotest
963 void PerformAutoTest()
965 SVMCacheInfo tempPages;
967 if (TestIsDemandPaged)
969 UserSvr::HalFunction(EHalGroupVM,EVMHalGetCacheSize,&tempPages,0);
970 DBGS_PRINT((_L("PerformAutoTest : Start cache info: iMinSize %d iMaxSize %d iCurrentSize %d iMaxFreeSize %d\n"),
971 tempPages.iMinSize, tempPages.iMaxSize, tempPages.iCurrentSize ,tempPages.iMaxFreeSize));
973 TestInterleave = EFalse;
974 TestPrioChange = EFalse;
975 TestMediaAccess = EFalse;
977 #if defined __ARMCC__ || defined __X86__
978 // Currently we only build aligned DLLs on ARMV5 and X86 builds.
979 TEST_NEXT((_L("Alignment Check.")));
980 RUNTEST1(CheckAlignments() == KErrNone);
984 TestWhichTests = TEST_RANDOM;
986 TEST_NEXT((_L("Single thread all.")));
989 TEST_NEXT((_L("Multiple threads all.")));
992 TestPrioChange = ETrue;
993 TEST_NEXT((_L("Multiple threads all with prio.")));
996 TestPrioChange = EFalse;
997 TestMediaAccess = ETrue;
998 TEST_NEXT((_L("Multiple threads all with media activity.")));
1001 TestPrioChange = ETrue;
1002 TestMediaAccess = ETrue;
1003 TEST_NEXT((_L("Multiple threads all with media activity and prio.")));
1006 TestInterleave = ETrue;
1007 TestPrioChange = EFalse;
1008 TestMediaAccess = EFalse;
1010 TEST_NEXT((_L("Multiple threads random with interleave.")));
1013 TestPrioChange = ETrue;
1014 TEST_NEXT((_L("Multiple threads random with interleave and prio.")));
1017 TestMediaAccess = ETrue;
1018 TEST_NEXT((_L("Multiple threads random with media interleave and prio.")));
1021 if (TestIsDemandPaged)
1023 UserSvr::HalFunction(EHalGroupVM,EVMHalGetCacheSize,&tempPages,0);
1024 DBGS_PRINT((_L("PerformAutoTest : End cache info: iMinSize %d iMaxSize %d iCurrentSize %d iMaxFreeSize %d\n"),
1025 tempPages.iMinSize, tempPages.iMaxSize, tempPages.iCurrentSize ,tempPages.iMaxFreeSize));
1027 TestInterleave = EFalse;
1028 TestPrioChange = EFalse;
1029 TestMediaAccess = EFalse;
1040 TInt r = User::LoadLogicalDevice(KPageStressTestLddName);
1041 RUNTEST1(r==KErrNone || r==KErrAlreadyExists);
1042 RUNTEST(Ldd.Open(),KErrNone);
1044 SVMCacheInfo tempPages;
1045 memset(&tempPages, 0, sizeof(tempPages));
1047 if (TestIsDemandPaged)
1049 // get the old cache info
1050 UserSvr::HalFunction(EHalGroupVM,EVMHalGetCacheSize,&tempPages,0);
1051 TInt minSize = 8 * 4096;
1052 TInt maxSize = 256 * 4096;
1053 UserSvr::HalFunction(EHalGroupVM,EVMHalSetCacheSize,(TAny*)minSize,(TAny*)maxSize);
1056 // First load some pages onto the page cache
1058 TestWhichTests = TEST_RANDOM;
1061 Ldd.DoConsumeRamSetup(TEST_LM_NUM_FREE, TEST_LM_BLOCKSIZE);
1062 TEST_NEXT((_L("Single thread with Low memory.")));
1063 TestMultipleThreadCount = 25;
1064 TestInterleave = EFalse;
1066 TestPrioChange = EFalse;
1067 TestMediaAccess = EFalse;
1068 TestWhichTests = TEST_ALL;
1072 Ldd.DoConsumeRamFinish();
1074 TEST_NEXT((_L("Multiple thread with Low memory.")));
1075 // First load some pages onto the page cache
1077 TestWhichTests = TEST_RANDOM;
1080 Ldd.DoConsumeRamSetup(TEST_LM_NUM_FREE, TEST_LM_BLOCKSIZE);
1082 TestWhichTests = TEST_ALL;
1084 TestMultipleThreadCount = 25;
1085 DoMultipleTest(ETrue);
1087 Ldd.DoConsumeRamFinish();
1089 TEST_NEXT((_L("Multiple thread with Low memory, with starting free ram.")));
1090 // First load some pages onto the page cache
1092 TestWhichTests = TEST_RANDOM;
1095 Ldd.DoConsumeRamSetup(32, TEST_LM_BLOCKSIZE);
1097 TestWhichTests = TEST_ALL;
1099 TestMultipleThreadCount = 25;
1100 DoMultipleTest(ETrue);
1102 Ldd.DoConsumeRamFinish();
1104 TEST_NEXT((_L("Close test driver")));
1106 RUNTEST(User::FreeLogicalDevice(KPageStressTestLddName), KErrNone);
1107 if (TestIsDemandPaged)
1109 TInt minSize = tempPages.iMinSize;
1110 TInt maxSize = tempPages.iMaxSize;
1111 UserSvr::HalFunction(EHalGroupVM,EVMHalSetCacheSize,(TAny*)minSize,(TAny*)maxSize);
1118 // Main entry point.
1123 #ifndef TEST_ON_UNPAGED
1124 TRomHeader* romHeader = (TRomHeader*)UserSvr::RomHeaderAddress();
1125 if(!romHeader->iPageableRomStart)
1127 TestIsDemandPaged = EFalse;
1130 TUint start = User::TickCount();
1132 TBool parseResult = ParseCommandLine();
1141 TInt minSize = 8 * 4096;
1142 TInt maxSize = 64 * 4096;
1143 SVMCacheInfo tempPages;
1144 memset(&tempPages, 0, sizeof(tempPages));
1145 if (TestIsDemandPaged)
1147 // get the old cache info
1148 UserSvr::HalFunction(EHalGroupVM,EVMHalGetCacheSize,&tempPages,0);
1149 // set the cache to our test value
1150 UserSvr::HalFunction(EHalGroupVM,EVMHalSetCacheSize,(TAny*)minSize,(TAny*)maxSize);
1153 // get the page size.
1154 UserSvr::HalFunction(EHalGroupKernel,EKernelHalPageSizeInBytes,&TestPageSize,0);
1159 test.Start(_L("Demand Paging stress tests..."));
1160 test.Printf(_L("%S\n"), &TestNameBuffer);
1167 extern TInt *CheckLdmiaInstr(void);
1168 test.Printf(_L("%S : CheckLdmiaInstr\n"), &TestNameBuffer);
1169 TInt *theAddr = CheckLdmiaInstr();
1170 test.Printf(_L("%S : CheckLdmiaInstr complete 0x%x...\n"), &TestNameBuffer, (TInt)theAddr);
1195 if (TestWeAreTheTestBase)
1197 RProcess theProcess;
1198 TRequestStatus status;
1200 TInt retVal = theProcess.Create(_L("t_pagestress_rom.exe"),_L(""));
1201 if (retVal != KErrNotFound)
1203 RUNTEST1(retVal == KErrNone);
1204 theProcess.Logon(status);
1205 RUNTEST1(status == KRequestPending);
1206 theProcess.Resume();
1207 User::WaitForRequest(status);
1208 if (theProcess.ExitType() != EExitPending)
1210 RUNTEST1(theProcess.ExitType() != EExitPanic);
1216 if (TestIsDemandPaged)
1218 minSize = tempPages.iMinSize;
1219 maxSize = tempPages.iMaxSize;
1220 // put the cache back to the the original values.
1221 UserSvr::HalFunction(EHalGroupVM,EVMHalSetCacheSize,(TAny*)minSize,(TAny*)maxSize);
1226 test.Printf(_L("%S : Complete (%u ticks)\n"), &TestNameBuffer, User::TickCount() - start);