First public contribution.
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\loader\t_pageldrtst.cpp
15 // Demand Paging Loader Stress Tests
16 // Demand Paging Loader stress tests attempt to cause as much paging as possible
17 // whilst putting the system various types of load.
18 // t_pageldrtst.exe is the root of the tests, it in turn will start copies of
19 // itself stored in various types of media (t_pageldrtst_rom.exe for example).
20 // It also loads DLLs from various media, each DLL containing simple functions
21 // that are aligned on page boundaries, so each function call is likely to
22 // cause a page fault.
24 // t_pageldrtst and t_pageldrtst_rom
25 // Common command lines:
26 // t_pageldrtst - run the auto test suite
27 // t_pageldrtst lowmem - run the low memory tests
28 // t_pageldrtst chunks - run the chunk tests
29 // t_pageldrtst chunks+ - run the chunk tests (same as used in autotest)
30 // t_pageldrtst echunks - run the really stressful chunk tests
31 // t_pageldrtst auto debug - run the autotest but with debug output to the serial port
32 // t_pageldrtst d_exc - run the d_exc tests
34 // single - run the tests in a single thread
35 // multiple <numThreads> - run the tests in multiple threads where <numThreads>
36 // auto - dummy param to trick the tests into running the auto test suite with extra params
37 // fullauto - param to make the tests perform the full automatic stress test
38 // interleave - force thread interleaving
39 // prio - each thread reschedules in between each function call, causes lots of context changes
40 // media - perform media access during the tests, very stressful
41 // mmc - only use the mmc media for media access to test file caching
42 // min - min cache size in pages
43 // max - max cache size in pages
44 // chunks - simple chunk stress tests
45 // chunks+ - the chunk auto tests
46 // echunks - extremem chunks tests
47 // nochunkdata - don't check the integrity of the data in the chunks
48 // lowmem - low memory tests
49 // dll - only load dll's
50 // exe - only start exe's (t_pagestress)
51 // self - only start copies of self (t_pageldrtst from various media)
52 // complete - dll, exe and self.
53 // rom - only load from ROM
54 // base - only load the base DLL and exe's (from code)
55 // mixed - rom and base.
56 // all_media - load dlls and exes from all media
57 // debug - switch on debugging information
58 // silent - no output to the screen or serial port
59 // noclean - don't delete copied files on exit
60 // d_exc - run the d_exc tests
61 // global - load dlls once globally
62 // thread - load dlls once per thread
63 // func - load dlls in the test function (default and most stressful)
64 // forward - patern in which to execute function calls
65 // backward - patern in which to execute function calls
66 // random - patern in which to execute function calls
67 // all - patern in which to execute function calls (forward, backward and random)
68 // inst - for debugging a parameter passed to a spawned exe to give it an id.
69 // iters <count> - the number of times to loop (a '-' means run forever)
70 // reaper - test the reaper.
71 // btrace - test the btrace code.
72 // defrag - test the ram defrag code.
73 // stressfree - set the page cache to stress free size and run tests.
74 // t_pageldrtst causes a large ammount of paging by repeatedly calling
75 // functions from multiple DLLs which include 64 functions which have
76 // been aligned on page boundaries from multiple threads, whilst causing
77 // background paging by spawning copies of itself and t_pagestress.
78 // The test also endeavours to stress the loader by loading and unloading
79 // DLLs from multiple threads from various types of media at the same
80 // time as stressing the media, testing chunks, the reaper and changing
82 // 002 Load thrashing, test rapid loading and unloading of DLLs from
83 // multiple threads (DEF100158)
84 // 003 Multiple threads loading DLLs in random pattern
85 // 004 Multiple threads loading EXE, SELF and DLLs in random pattern with
86 // all media, loaded in thread with prio change
87 // 005 Multiple threads loading EXE, SELF and DLLs in random pattern with
88 // all media, loaded globally with prio change
89 // 006 Multiple threads loading EXE, SELF and DLLs in random pattern with
90 // all media, loaded in func with process interleaving
91 // 007 Multiple threads loading EXE, SELF and DLLs in random pattern with
92 // all media, loaded in func with process interleaving, prio change
94 // 008 Low Memory setup test
95 // 009 Low Memory, Multiple threads loading EXE, SELF and DLLs in random
96 // pattern, loaded in func.
97 // 010 Low Memory setup test
98 // 011 Low Memory, Multiple threads loading EXE, SELF and DLLs in random
99 // pattern, loaded in func with process interleaving,
100 // prio change and media access
101 // 012 Close test driver
102 // 013 Chunk tests, Multiple threads loading EXE, SELF and DLLs in random
103 // pattern with ROM / ROFS media, loaded in func with prio change
104 // 014 Reaper tests with Multiple threads loading EXE, SELF and DLLs in random
105 // pattern with all media
106 // 015 Reaper tests with Multiple threads loading EXE, SELF and DLLs in random
107 // pattern with all media, prio change and process interleaving
108 // 016 d_exc check test
112 //! @SYMTestCaseID KBASE-T_PAGELDRTST-0326
114 //! @SYMPREQ PREQ1110
115 //! @SYMTestCaseDesc Demand Paging Loader Stress Tests
116 //! @SYMTestActions 001 Demand Paging loader stress tests...
117 //! @SYMTestExpectedResults All tests should pass.
118 //! @SYMTestPriority High
119 //! @SYMTestStatus Implemented
127 #include <e32msgqueue.h>
129 #include <e32btrace.h>
130 #include <d32btrace.h>
135 #include "paging_info.h"
137 #ifndef TEST_AUTOTEST
138 #define TEST_RUN_REAPERTEST
139 #define TEST_RUN_LOWMEMTEST
140 #define TEST_RUN_DEFRAGTEST
141 #define TEST_RUN_D_EXCTEST
142 #define TEST_RUN_CHUNKTEST
143 #define TEST_RUN_AUTOTEST
144 RTest test(_L("T_PAGELDRTST"));
146 #ifdef TEST_RUN_REAPERTEST
147 RTest test(_L("T_PAGELDRTST_REAPER"));
149 #ifdef TEST_RUN_LOWMEMTEST
150 RTest test(_L("T_PAGELDRTST_LOWMEM"));
152 #ifdef TEST_RUN_DEFRAGTEST
153 RTest test(_L("T_PAGELDRTST_DEFRAG"));
155 #ifdef TEST_RUN_D_EXCTEST
156 RTest test(_L("T_PAGELDRTST_D_EXC"));
158 #ifdef TEST_RUN_CHUNKTEST
159 RTest test(_L("T_PAGELDRTST_CHUNK"));
161 #ifdef TEST_RUN_AUTOTEST
162 RTest test(_L("T_PAGELDRTST_AUTO"));
164 #endif //TEST_AUTOTEST
166 const TInt KMessageBufSize = 80;
167 typedef TBuf<KMessageBufSize> TMessageBuf;
169 //#define TEST_SHORT_TEST
170 //#define TEST_THRASHING_TEST
171 //#define TEST_ADD_FAT_MEDIA
172 #define TEST_DONT_RESET_STATS
173 #define TEST_MINIMAL_STATS
174 //#define TEST_KERN_HEAP
175 #define TEST_ADD_FRAGD_MEDIA
176 #ifdef TEST_ADD_FRAGD_MEDIA
179 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
180 //#define WANT_FS_CACHE_STATS
184 #define TEST_ON_UNPAGED
185 #define TEST_NO_DEXC_IN_AUTO
189 #include "t_pagestress.h"
190 #include "t_pageldrtstdll.h"
192 #include "t_ramstress.h"
194 TBool TestDebug = EFalse;
195 TBool TestSilent = EFalse;
196 TBool TestExit = EFalse;
197 #define TEST_EXE 0x01
198 #define TEST_DLL 0x02
199 #define TEST_SELF 0x04
200 #define TEST_EXE_SELF (TEST_EXE | TEST_SELF)
201 #define TEST_EXE_SELF_DLL (TEST_EXE | TEST_SELF | TEST_DLL)
202 TInt TestLoading = TEST_EXE_SELF_DLL;
204 #define TEST_MEDIA_BASE (1 << KTestMediaBase)
205 #define TEST_MEDIA_ROM (1 << KTestMediaRom)
206 #define TEST_MEDIA_ROFS (1 << KTestMediaRofs)
207 #define TEST_MEDIA_EXT (1 << KTestMediaExt)
208 #define TEST_MEDIA_FAT (1 << KTestMediaFat)
209 #define TEST_MEDIA_MMC (1 << KTestMediaMmc)
210 #define TEST_MEDIA_ROM_BASE (TEST_MEDIA_ROM | TEST_MEDIA_BASE)
211 #define TEST_MEDIA_ALL (TEST_MEDIA_ROM | TEST_MEDIA_BASE | TEST_MEDIA_ROFS | TEST_MEDIA_EXT | TEST_MEDIA_MMC)
219 #ifdef TEST_ADD_FAT_MEDIA
220 KTestMediaFat, // this is the last one that is always present.
223 #ifdef TEST_ADD_FRAGD_MEDIA
229 #ifdef TEST_ADD_FAT_MEDIA
230 #define TEST_MEDIA_COUNT_HACK (KTestMediaFat + 1)
232 #define TEST_MEDIA_COUNT_HACK (KTestMediaRofs + 1)
237 KTestMediaAccessNone = 0,
238 KTestMediaAccessBasic,
239 KTestMediaAccessMultipleThreads,
240 KTestMediaAccessMultiplePattern,
241 KTestMediaAccessMixed,
242 KTestMediaAccessCOUNT,
245 TInt TestWhichMedia = TEST_MEDIA_ROM_BASE;
246 TInt DriveNumber=-1; // Parameter - Which drive? -1 = autodetect.
247 TBool TestSingle = EFalse;
248 TBool TestMultiple = EFalse;
249 TInt TestMaxLoops = 20;
250 #define TEST_2MEDIA_THREADS 20
251 #define TEST_ALLMEDIA_THREADS 20
252 TInt TestMultipleThreadCount = TEST_2MEDIA_THREADS;
253 TInt TestInstanceId = 0;
254 TBool TestWeAreTheTestBase = EFalse;
255 TBool TestBootedFromMmc = EFalse;
256 TBool TestOnlyFromMmc = EFalse;
257 TBool TestD_Exc = EFalse;
258 TBool TestNoClean = EFalse;
259 TBool TestFullAutoTest = EFalse;
260 #define TEST_DLL_GLOBAL 0x01
261 #define TEST_DLL_THREAD 0x02
262 #define TEST_DLL_FUNC 0x04
263 TInt TestLoadDllHow = TEST_DLL_FUNC;
264 TBool TestIsAutomated = EFalse;
266 #define TEST_INTERLEAVE_PRIO EPriorityMore//EPriorityRealTime //23 // KNandThreadPriority - 1
267 TBool TestInterleave = EFalse;
268 TFileName TestNameBuffer;
269 TBool TestPrioChange = EFalse;
271 volatile TBool TestStopMedia = EFalse;
272 ETestMediaAccess TestMediaAccess = KTestMediaAccessNone;
273 #define TEST_NUM_FILES 5
275 RSemaphore TestMultiSem;
276 RMsgQueue<TMessageBuf> TestMsgQueue;
278 #define TEST_LM_NUM_FREE 0
279 #define TEST_LM_BLOCKSIZE 1
280 #define TEST_LM_BLOCKS_FREE 4
281 TBool TestLowMem = EFalse;
282 TBool TestingLowMem = EFalse;
283 RPageStressTestLdd PagestressLdd;
284 RRamStressTestLdd RamstressLdd;
286 TBool TestBtrace = EFalse;
287 TBool TestDefrag = EFalse;
288 TBool TestChunks = EFalse;
289 TBool TestChunksPlus = EFalse;
290 TBool TestExtremeChunks = EFalse;
291 TBool TestChunkData = ETrue;
292 TBool TestingChunks = EFalse;
293 volatile TBool TestDefragTestEnd = EFalse;
294 TBool TestingDefrag = EFalse;
295 volatile TBool TestThreadsExit = EFalse;
296 TInt TestPageSize = 4096;
298 TInt TestCommitEnd = 0;
299 TUint8* TestChunkBase = NULL;
300 #define TEST_NUM_PAGES 64
301 #define TEST_NUM_CHUNK_PAGES (TEST_NUM_PAGES * 2)
302 TBool TestChunkPageState[TEST_NUM_CHUNK_PAGES];
304 TBool TestReaper = EFalse;
305 TBool TestingReaper = EFalse;
306 TBool TestingReaperCleaningFiles = EFalse;
307 #define TEST_REAPER_ITERS 20
308 #define TEST_DOT_PERIOD 30
309 TBool TestStressFree = EFalse;
310 TInt TestMinCacheSize = 64 * 4096;
311 TInt TestMaxCacheSize = 128 * 4096;
312 TBool TestIsDemandPaged = ETrue;
313 #define TEST_MAX_ZONE_THREADS 8
314 TUint TestZoneCount = 0;
315 TInt TickPeriod = 15625;
317 #define TEST_NONE 0x0
318 #define TEST_THRASH 0x1
319 #define TEST_FORWARD 0x2
320 #define TEST_BACKWARD 0x4
321 #define TEST_RANDOM 0x8
322 #define TEST_ALL (TEST_RANDOM | TEST_BACKWARD | TEST_FORWARD)
323 TUint32 TestWhichTests = TEST_ALL;
324 _LIT(KRomPath, "z:\\sys\\bin\\");
325 _LIT(KMmcDefaultPath, "d:\\sys\\bin\\");
327 #define EXISTS(__val) ((__val == KErrNone) ? &KFileExists : &KFileMissing)
328 _LIT(KSysHash,"?:\\Sys\\Hash\\");
329 _LIT(KTestBlank, "");
330 _LIT(KFileExists, "Exists");
331 _LIT(KFileMissing, "Missing");
332 _LIT(KMultipleTest, "Multiple");
333 _LIT(KSingleTest, "Single ");
334 _LIT(KTestExe, "Exe ");
335 _LIT(KTestDll, "Dll ");
336 _LIT(KTestSelf, "Self ");
337 _LIT(KTestBase, "Base ");
338 _LIT(KTestRom, "ROM ");
339 _LIT(KTestAll, "All ");
340 _LIT(KTestGlobal, "Global");
341 _LIT(KTestThread, "Thread");
342 _LIT(KTestFunc, "Func");
343 _LIT(KTestInter, "Interleave ");
344 _LIT(KTestPrio, "Prio ");
345 _LIT(KTestMedia, "Media ");
346 _LIT(KTestLowMem, "LowMem ");
347 _LIT(KTestChunking, "Chunks ");
348 _LIT(KTestEChunking, "EChunks ");
349 _LIT(KTestChunkingPlus, "Chunks+ ");
350 _LIT(KTestReaper, "Reaper ");
351 _LIT(KTestThrash, "Thrash ");
352 _LIT(KTestForward, "Forward ");
353 _LIT(KTestBackward, "Backward ");
354 _LIT(KTestRandom, "Random ");
358 TBool testFullAutoOnly;
363 TInt testMultipleThreadCount;
364 TBool testLoadDllHow;
365 TBool testInterleave;
366 TBool testPrioChange;
367 ETestMediaAccess testMediaAccess;
368 TUint32 testWhichTests;
382 TChunkTestPair unlock;
383 TChunkTestPair decommit;
384 TChunkTestPair commit;
385 TChunkTestPair check;
389 TChunkTestStats TestChunkStats[TEST_NUM_CHUNK_PAGES];
392 TPtrC TestPsExeNames[KTestMediaCOUNT] = { _L("t_pagestress.exe"),
393 _L("t_pagestress_rom.exe"),
394 _L("t_pagestress_ext.exe"),
395 _L("t_pagestress_rofs.exe"),
396 #ifdef TEST_ADD_FAT_MEDIA
397 _L("t_pagestress_fat.exe"),
399 _L("t_pagestress_mmc.exe"),
400 #ifdef TEST_ADD_FRAGD_MEDIA
401 _L("t_pagestress_nfr.exe"),
402 _L("t_pagestress_mfr.exe"),
406 TPtrC TestPlExeNames[KTestMediaCOUNT] = { _L("t_pageldrtst.exe"),
407 _L("t_pageldrtst_rom.exe"),
408 _L("t_pageldrtst_ext.exe"),
409 _L("t_pageldrtst_rofs.exe"),
410 #ifdef TEST_ADD_FAT_MEDIA
411 _L("t_pageldrtst_fat.exe"),
413 _L("t_pageldrtst_mmc.exe"),
414 #ifdef TEST_ADD_FRAGD_MEDIA
415 _L("t_pageldrtst_nfr.exe"),
416 _L("t_pageldrtst_mfr.exe"),
420 _LIT(KDllBaseName, "t_pageldrtst");
422 TPtrC TestPlExtNames[KTestMediaCOUNT] = { _L(".dll"),
426 #ifdef TEST_ADD_FAT_MEDIA
430 #ifdef TEST_ADD_FRAGD_MEDIA
437 TBool TestDllExesExist[KTestMediaCOUNT] = { EFalse,
441 #ifdef TEST_ADD_FAT_MEDIA
445 #ifdef TEST_ADD_FRAGD_MEDIA
450 #define DBGS_PRINT(__args)\
451 if (!TestSilent) test.Printf __args;
453 #define DBGD_PRINT(__args)\
454 if (TestDebug) test.Printf __args;
456 void SendDebugMessage(RMsgQueue<TMessageBuf> *aMsgQueue = NULL,
457 TMessageBuf *aBuffer = NULL,
458 RSemaphore *aTheSem = NULL)
463 TInt r = aMsgQueue->Send(*aBuffer);
465 if (r != KErrOverflow)
471 #define DEBUG_PRINT(__args)\
474 if (aMsgQueue && aBuffer && aTheSem)\
477 aBuffer->Format __args ;\
478 SendDebugMessage(aMsgQueue, aBuffer, aTheSem);\
482 test.Printf __args ;\
486 #define RUNTEST(__test, __error)\
488 test(__test == __error);\
492 #define RUNTEST1(__test)\
497 #define DEBUG_PRINT1(__args)\
503 #define DOTEST(__operation, __condition)\
507 while (!__condition)\
509 DBGD_PRINT((_L("Releasing some memory on line %d\n"), __LINE__));\
512 PagestressLdd.DoReleaseSomeRam(TEST_LM_BLOCKS_FREE);\
517 RUNTEST1(__condition);\
522 RUNTEST1(__condition);\
525 #define DOTEST1(__var, __func, __ok, __fail)\
529 while (__var == __fail)\
531 DBGD_PRINT((_L("Releasing some memory on line %d\n"), __LINE__));\
534 PagestressLdd.DoReleaseSomeRam(TEST_LM_BLOCKS_FREE);\
540 DBGS_PRINT((_L("Failing on line %d with error %d\n"), __LINE__, __var));\
541 RUNTEST1(__var == __ok);\
546 RUNTEST1(__var == __ok);\
549 #define DOLOADALLOC(__numDlls, __pTheLibs, __theSem)\
552 __pTheLibs = (PageLdrRLibrary *)User::AllocZ(sizeof(PageLdrRLibrary) * __numDlls);\
553 while (__pTheLibs == NULL)\
555 DEBUG_PRINT1((_L("Releasing some memory for alloc on line %d\n"), __LINE__));\
558 PagestressLdd.DoReleaseSomeRam(TEST_LM_BLOCKS_FREE);\
561 __pTheLibs = (PageLdrRLibrary *)User::AllocZ(sizeof(PageLdrRLibrary) * __numDlls);\
566 __pTheLibs = (PageLdrRLibrary *)User::AllocZ(sizeof(PageLdrRLibrary) * __numDlls);\
567 if (__pTheLibs == NULL)\
571 #define TEST_NEXT(__args) \
576 void CheckFilePresence(TBool aDoFileCopy);
577 void CleanupFiles(TBool silent);
578 typedef TInt (*TCallFunction)(TUint32 funcIndex, TInt param1, TInt param2);
580 class PageLdrRLibrary : public RLibrary
583 TInt TestLoadLibrary(const TDesC& aFileName, TInt aThreadIndex, RMsgQueue<TMessageBuf> *aMsgQueue, TMessageBuf *aBuffer, RSemaphore *aTheSem);
589 TLibraryFunction iInitFunc;
590 TLibraryFunction iFunctionCountFunc;
591 TCallFunction iCallFunctionFunc;
592 TLibraryFunction iSetCloseFunc;
595 TInt PageLdrRLibrary::CloseLibrary()
604 iFunctionCountFunc = NULL;
605 iCallFunctionFunc = NULL;
606 iSetCloseFunc = NULL;
612 PageLdrRLibrary theGlobalLibs[PAGELDRTST_MAX_DLLS * KTestMediaCOUNT];
614 ////////////////////////////////////////////////////////////
615 // Template functions encapsulating ControlIo magic
617 GLDEF_D template <class C>
618 GLDEF_C TInt controlIo(RFs &fs, TInt drv, TInt fkn, C &c)
620 TPtr8 ptrC((TUint8 *)&c, sizeof(C), sizeof(C));
622 TInt r = fs.ControlIo(drv, fkn, ptrC);
630 // Get available free ram.
635 // wait for any async cleanup in the supervisor to finish first...
636 UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, 0, 0);
638 TMemoryInfoV1Buf meminfo;
639 TInt r=UserHal::MemoryInfo(meminfo);
641 return meminfo().iFreeRamInBytes;
647 // Find the NAND drive
650 static TInt FindFsNANDDrive(RFs& aFs)
652 TDriveList driveList;
653 TDriveInfo driveInfo;
654 TInt r=aFs.DriveList(driveList);
657 for (TInt drvNum= (DriveNumber<0)?0:DriveNumber; drvNum<KMaxDrives; ++drvNum)
659 if(!driveList[drvNum])
660 continue; //-- skip unexisting drive
662 if (aFs.Drive(driveInfo, drvNum) == KErrNone)
664 if(driveInfo.iMediaAtt&KMediaAttPageable)
666 TBool readOnly = driveInfo.iMediaAtt & KMediaAttWriteProtected; // skip ROFS partitions
667 if(!readOnly && (driveInfo.iType != EMediaHardDisk))
669 if ((drvNum==DriveNumber) || (DriveNumber<0)) // only test if running on this drive
682 // FindMMCDriveNumber
684 // Find the first read write drive.
687 TInt FindMMCDriveNumber(RFs& aFs)
689 TDriveInfo driveInfo;
690 for (TInt drvNum=0; drvNum<KMaxDrives; ++drvNum)
692 TInt r = aFs.Drive(driveInfo, drvNum);
695 if (driveInfo.iType == EMediaHardDisk)
704 // PageLdrRLibrary::TestLoadLibrary
706 // Load a library and initialise information about that library
709 TInt PageLdrRLibrary::TestLoadLibrary(const TDesC& aFileName,
711 RMsgQueue<TMessageBuf> *aMsgQueue = NULL,
712 TMessageBuf *aBuffer = NULL,
713 RSemaphore *aTheSem = NULL)
715 TInt retVal = KErrNone;
718 TBool whinged = EFalse;
719 TInt initialFreeRam = 0;
724 initialFreeRam = FreeRam();
725 retVal = Load(aFileName);
727 if (retVal == KErrNoMemory)
729 if (!whinged && (freeRam > (4 * TestPageSize)))
732 DEBUG_PRINT1((_L("Load() %d pages %S\n"), (freeRam / TestPageSize), &aFileName));
733 if (TestIsDemandPaged)
735 SVMCacheInfo tempPages;
736 UserSvr::HalFunction(EHalGroupVM,EVMHalGetCacheSize,&tempPages,0);
738 DEBUG_PRINT1((_L("DPC : min %d max %d curr %d\n"),
739 tempPages.iMinSize, tempPages.iMaxSize, tempPages.iCurrentSize));
740 DEBUG_PRINT1((_L(" : maxFree %d freeRam %d\n"),
741 tempPages.iMaxFreeSize, FreeRam()));
744 DEBUG_PRINT1((_L("Load() releasing some memory for %S (%d)\n"), &aFileName, retVal));
747 PagestressLdd.DoReleaseSomeRam(TEST_LM_BLOCKS_FREE);
755 DEBUG_PRINT((_L("Load() Ok %d pages (%d) %S\n"), ((initialFreeRam - freeRam) / TestPageSize), (freeRam / TestPageSize), &aFileName));
763 DEBUG_PRINT1((_L("Loading %S (%d)\n"), &aFileName, aThreadIndex));
764 retVal = Load(aFileName);
765 if (retVal != KErrNone)
767 DEBUG_PRINT1((_L("Load failed %S (%d)\n"), &aFileName, aThreadIndex));
771 TBool whinged = EFalse;
772 while ( ( (retVal == KErrNotFound)
773 || (retVal == KErrPermissionDenied)
774 || (retVal == KErrCorrupt)
775 || (retVal == KErrInUse))
776 && ( TestingReaperCleaningFiles
777 || (tempIndex < TEST_REAPER_ITERS)))
779 User::After(2000000);
782 DEBUG_PRINT((_L("Load() retrying load for %S (%d)\n"), &aFileName, retVal));
785 retVal = Load(aFileName);
786 if (!TestingReaperCleaningFiles)
791 if (retVal != KErrNone)
793 DEBUG_PRINT((_L("Load() failing for %S (%d) idx %d\n"), &aFileName, retVal, tempIndex));
796 else if (TestingDefrag)
799 TBool whinged = EFalse;
800 while ((retVal == KErrGeneral) && (tempIndex < 10))
805 DEBUG_PRINT((_L("Load() retrying load for %S (%d)\n"), &aFileName, retVal));
808 retVal = Load(aFileName);
811 if (retVal != KErrNone)
813 DEBUG_PRINT((_L("Load() failing for %S (%d) idx %d\n"), &aFileName, retVal, tempIndex));
818 DEBUG_PRINT1((_L("Loaded %S (%d)\n"), &aFileName, aThreadIndex));
819 if (retVal == KErrNone)
822 iInitFunc = Lookup(PAGELDRTST_FUNC_Init);
823 iFunctionCountFunc = Lookup(PAGELDRTST_FUNC_FunctionCount);
824 iCallFunctionFunc = (TCallFunction)Lookup(PAGELDRTST_FUNC_CallFunction);
825 iSetCloseFunc = Lookup(PAGELDRTST_FUNC_SetClose);
826 if ( (iInitFunc != NULL)
827 && (iFunctionCountFunc != NULL)
828 && (iCallFunctionFunc != NULL)
829 && (iSetCloseFunc != NULL))
831 retVal = (iInitFunc)();
832 if (retVal == KErrNone)
834 iFuncCount = (iFunctionCountFunc)();
837 DEBUG_PRINT1((_L("Loaded ok %S (%d)\n"), &aFileName, aThreadIndex));
840 retVal = KErrGeneral;
841 DEBUG_PRINT((_L("!!! bad count %S (%d)\n"), &aFileName, aThreadIndex));
845 DEBUG_PRINT((_L("!!! init failed %S (%d)\n"), &aFileName, aThreadIndex));
846 retVal = KErrGeneral;
851 DEBUG_PRINT((_L("!!! missing %S (%d)\n"), &aFileName, aThreadIndex));
852 retVal = KErrGeneral;
857 DEBUG_PRINT((_L("Load() failed %S %d\n"), &aFileName, retVal));
858 #ifdef WANT_FS_CACHE_STATS
860 if (KErrNone != fs.Connect())
862 DEBUG_PRINT(_L("TestLoadLibrary : Can't connect to the FS\n"));
866 TFileCacheStats stats1;
867 TInt drvNum = FindMMCDriveNumber(fs);
868 controlIo(fs,drvNum, KControlIoFileCacheStats, stats1);
870 DEBUG_PRINT((_L("FSC: drv %d %c free %d used %d locked %d\n"),
871 drvNum, 'a' + drvNum,
874 stats1.iLockedSegmentCount));
875 DEBUG_PRINT((_L(" : alloc %d lock %d closed %d\n"),
876 stats1.iAllocatedSegmentCount,
878 stats1.iFilesOnClosedQueue));
881 #endif //WANT_FS_CACHE_STATS
883 if (TestIsDemandPaged)
885 SVMCacheInfo tempPages;
886 UserSvr::HalFunction(EHalGroupVM,EVMHalGetCacheSize,&tempPages,0);
888 DEBUG_PRINT((_L("DPC : min %d max %d curr %d\n"),
889 tempPages.iMinSize, tempPages.iMaxSize, tempPages.iCurrentSize));
890 DEBUG_PRINT((_L(" : maxFree %d freeRam %d\n"),
891 tempPages.iMaxFreeSize, FreeRam()));
900 // Work out how many Dlls we will play with
906 switch (TestWhichMedia)
909 case TEST_MEDIA_BASE:
911 maxDllIndex = PAGELDRTST_MAX_DLLS;
914 case TEST_MEDIA_ROM_BASE:
915 maxDllIndex = PAGELDRTST_MAX_DLLS * 2;
919 maxDllIndex = PAGELDRTST_MAX_DLLS * KTestMediaCOUNT;
928 // Open DLLs for use in the tests.
931 TInt LoadTheLibs(PageLdrRLibrary *aTheLibs,
934 RMsgQueue<TMessageBuf> *aMsgQueue = NULL,
935 TMessageBuf *aBuffer = NULL,
936 RSemaphore *aTheSem = NULL)
938 TBuf<128> nameBuffer;
940 TInt realDllIndex = 0;
945 memset(aTheLibs, 0, sizeof(*aTheLibs) * aLibCount);
946 for (dllIndex = 0; dllIndex < aLibCount; dllIndex ++)
948 realDllIndex = (dllIndex + aThreadIndex) % PAGELDRTST_MAX_DLLS;
949 // realDllIndex = (dllIndex) % PAGELDRTST_MAX_DLLS;
950 if (realDllIndex == 0)
953 if ((TestWhichMedia & TEST_MEDIA_ALL) == TEST_MEDIA_ALL)
954 testWhich = (dllIndex + dllOffset) % KTestMediaCOUNT;
955 else if ((TestWhichMedia & TEST_MEDIA_ALL) == TEST_MEDIA_ROM_BASE)
956 testWhich = ((dllIndex + dllOffset) & 1) ? KTestMediaBase : KTestMediaRom;
957 else if (TestWhichMedia & TEST_MEDIA_BASE )
958 testWhich = KTestMediaBase;
960 testWhich = KTestMediaRom;
962 if (!TestDllExesExist[testWhich])
963 testWhich = KTestMediaBase;
965 nameBuffer.Format(_L("%S%d%S"), &KDllBaseName, realDllIndex, &TestPlExtNames[testWhich]);
967 DEBUG_PRINT1((_L("LoadTheLibs[%02d] - loading %S\n"), aThreadIndex, &nameBuffer));
968 TInt theErr = aTheLibs[dllIndex].TestLoadLibrary(nameBuffer, aThreadIndex, aMsgQueue, aBuffer, aTheSem);
969 if (theErr != KErrNone)
971 DEBUG_PRINT((_L("LoadTheLibs[%02d] - fail %S %d\n"), aThreadIndex, &nameBuffer, theErr));
976 DEBUG_PRINT1((_L("LoadTheLibs[%02d] - loaded %S OK\n"), aThreadIndex, &nameBuffer));
980 DEBUG_PRINT((_L("LoadTheLibs[%02d] - cancelled\n"), aThreadIndex));
985 TThreadPriority originalThreadPriority = thisThread.Priority();
986 DEBUG_PRINT1((_L("LoadTheLibs[%02d] before priority change\n"), aThreadIndex));
987 thisThread.SetPriority(EPriorityLess);
988 User::AfterHighRes(0);
989 thisThread.SetPriority(originalThreadPriority);
990 DEBUG_PRINT1((_L("LoadTheLibs[%02d] after priority change\n"), aThreadIndex));
993 DEBUG_PRINT((_L("LoadTheLibs[%02d] done\n"), aThreadIndex));
1000 // Close the DLLs that we have previously opened
1003 void CloseTheLibs (PageLdrRLibrary *aTheLibs,
1008 for (dllIndex = 0; dllIndex < aLibCount; dllIndex ++)
1010 aTheLibs[dllIndex].CloseLibrary();
1012 memset(aTheLibs, 0, sizeof(*aTheLibs) * aLibCount);
1018 // Walk through the function pointer array (forwards) calling each function
1021 TInt RunThreadForward(TInt aThreadIndex,
1022 PageLdrRLibrary *aTheLibs,
1024 RMsgQueue<TMessageBuf> *aMsgQueue = NULL,
1025 TMessageBuf *aBuffer = NULL,
1026 RSemaphore *aTheSem = NULL)
1031 PageLdrRLibrary *pTheLibs = NULL;
1034 if (TestLoadDllHow == TEST_DLL_FUNC)
1036 DOLOADALLOC(aMaxDllIndex, pTheLibs, aTheSem);
1039 TInt retVal = LoadTheLibs(pTheLibs, aMaxDllIndex, aThreadIndex, aMsgQueue, aBuffer, aTheSem);
1040 if (retVal != KErrNone)
1042 DEBUG_PRINT((_L("Forward[%d] - load fail\n"), aThreadIndex));
1043 CloseTheLibs (pTheLibs, aMaxDllIndex);
1044 User::Free(pTheLibs);
1050 DEBUG_PRINT((_L("Forward[%d] - alloc fail\n"), aThreadIndex));
1056 pTheLibs = aTheLibs;
1059 for (dllIndex = 0; dllIndex < aMaxDllIndex; dllIndex ++)
1062 while (index < pTheLibs[dllIndex].iFuncCount)
1066 TThreadPriority originalThreadPriority = thisThread.Priority();
1067 thisThread.SetPriority(EPriorityLess);
1068 User::AfterHighRes(0);
1069 thisThread.SetPriority(originalThreadPriority);
1071 if (pTheLibs[dllIndex].iCallFunctionFunc)
1072 seed = pTheLibs[dllIndex].iCallFunctionFunc(index, seed, index);
1074 DEBUG_PRINT((_L("Forward[%d] : dll %d was NULL\n"), aThreadIndex, dllIndex));
1076 if (TestThreadsExit)
1079 if (TestThreadsExit)
1082 if (TestLoadDllHow == TEST_DLL_FUNC)
1084 CloseTheLibs(pTheLibs, aMaxDllIndex);
1085 User::Free(pTheLibs);
1091 // RunThreadBackward
1093 // Walk through the function pointer array (backwards) calling each function
1096 TInt RunThreadBackward(TInt aThreadIndex,
1097 PageLdrRLibrary *aTheLibs,
1099 RMsgQueue<TMessageBuf> *aMsgQueue = NULL,
1100 TMessageBuf *aBuffer = NULL,
1101 RSemaphore *aTheSem = NULL)
1106 PageLdrRLibrary *pTheLibs = NULL;
1109 if (TestLoadDllHow == TEST_DLL_FUNC)
1111 DOLOADALLOC(aMaxDllIndex, pTheLibs, aTheSem);
1114 TInt retVal = LoadTheLibs(pTheLibs, aMaxDllIndex, aThreadIndex, aMsgQueue, aBuffer, aTheSem);
1115 if (retVal != KErrNone)
1117 DEBUG_PRINT((_L("Backward[%d] - load fail\n"), aThreadIndex));
1118 CloseTheLibs (pTheLibs, aMaxDllIndex);
1119 User::Free(pTheLibs);
1125 DEBUG_PRINT((_L("Backward[%d] - alloc fail\n"), aThreadIndex));
1131 pTheLibs = aTheLibs;
1134 for (dllIndex = aMaxDllIndex - 1; dllIndex >= 0; dllIndex --)
1136 index = pTheLibs[dllIndex].iFuncCount;
1141 TThreadPriority originalThreadPriority = thisThread.Priority();
1142 thisThread.SetPriority(EPriorityLess);
1143 User::AfterHighRes(0);
1144 thisThread.SetPriority(originalThreadPriority);
1146 if (pTheLibs[dllIndex].iCallFunctionFunc)
1147 seed = pTheLibs[dllIndex].iCallFunctionFunc(index, seed, index);
1149 DEBUG_PRINT((_L("Backward[%d] : dll %d was NULL\n"), aThreadIndex, dllIndex));
1151 if (TestThreadsExit)
1154 if (TestThreadsExit)
1157 if (TestLoadDllHow == TEST_DLL_FUNC)
1159 CloseTheLibs(pTheLibs, aMaxDllIndex);
1160 User::Free(pTheLibs);
1168 // Walk through the function pointer array in a random order a number of times calling each function
1171 TInt RunThreadRandom(TInt aThreadIndex,
1172 PageLdrRLibrary *aTheLibs,
1174 RMsgQueue<TMessageBuf> *aMsgQueue = NULL,
1175 TMessageBuf *aBuffer = NULL,
1176 RSemaphore *aTheSem = NULL)
1181 PageLdrRLibrary *pTheLibs = NULL;
1184 if (TestLoadDllHow == TEST_DLL_FUNC)
1186 DOLOADALLOC(aMaxDllIndex, pTheLibs, aTheSem);
1189 TInt retVal = LoadTheLibs(pTheLibs, aMaxDllIndex, aThreadIndex, aMsgQueue, aBuffer, aTheSem);
1190 if (retVal != KErrNone)
1192 DEBUG_PRINT((_L("Random[%d] - load fail\n"), aThreadIndex));
1193 CloseTheLibs (pTheLibs, aMaxDllIndex);
1194 User::Free(pTheLibs);
1200 DEBUG_PRINT((_L("Random[%d] - alloc fail\n"), aThreadIndex));
1206 pTheLibs = aTheLibs;
1210 TUint funcCount = (TUint)pTheLibs[0].iFuncCount;
1211 TInt iterCount = aMaxDllIndex * funcCount;
1213 // reduce the time for auto tests by reducing the number of cycles.
1214 if (TestIsAutomated)
1217 while (iterCount > 0)
1221 TThreadPriority originalThreadPriority = thisThread.Priority();
1222 thisThread.SetPriority(EPriorityLess);
1223 User::AfterHighRes(0);
1224 thisThread.SetPriority(originalThreadPriority);
1227 randNum = (TUint)Math::Random();
1228 dllIndex = randNum % (TUint)aMaxDllIndex;
1230 randNum %= funcCount;
1232 if ( (randNum < funcCount)
1233 && ((TInt)dllIndex < aMaxDllIndex))
1235 if (pTheLibs[dllIndex].iCallFunctionFunc)
1237 seed = pTheLibs[dllIndex].iCallFunctionFunc(randNum, seed, randNum);
1240 DEBUG_PRINT((_L("Random[%d] : dll %d was NULL\n"), aThreadIndex, dllIndex));
1244 DEBUG_PRINT((_L("Random[%d] : %d ERROR dllIndex %u rand %u\n"), aThreadIndex, iterCount, dllIndex, randNum));
1248 if (TestThreadsExit)
1252 if (TestLoadDllHow == TEST_DLL_FUNC)
1254 CloseTheLibs(pTheLibs, aMaxDllIndex);
1255 User::Free(pTheLibs);
1264 // Load and unload the DLLs rapidly to show up a timing window in the kernel.
1267 TInt ThrashThreadLoad (TInt aThreadIndex,
1268 PageLdrRLibrary *aTheLibs,
1270 RMsgQueue<TMessageBuf> *aMsgQueue = NULL,
1271 TMessageBuf *aBuffer = NULL,
1272 RSemaphore *aTheSem = NULL)
1274 if (TestLoadDllHow == TEST_DLL_FUNC)
1276 PageLdrRLibrary *pTheLibs = NULL;
1277 DOLOADALLOC(aMaxDllIndex, pTheLibs, aTheSem);
1280 TInt retVal = LoadTheLibs(pTheLibs, aMaxDllIndex, aThreadIndex, aMsgQueue, aBuffer, aTheSem);
1281 if (retVal != KErrNone)
1283 DEBUG_PRINT((_L("Thrash[%d] - load fail\n"), aThreadIndex));
1284 CloseTheLibs (pTheLibs, aMaxDllIndex);
1285 User::Free(pTheLibs);
1291 DEBUG_PRINT((_L("Thrash[%d] - alloc fail\n"), aThreadIndex));
1295 CloseTheLibs(pTheLibs, aMaxDllIndex);
1296 User::Free(pTheLibs);
1303 // PerformTestThread
1305 // This is the function that actually does the work.
1306 // It is complicated a little because test.Printf can only be called from the first thread that calls it
1307 // so if we are using multiple threads we need to use a message queue to pass the debug info from the
1308 // child threads back to the parent for the parent to then call printf.
1312 LOCAL_C TInt PerformTestThread(TInt aThreadIndex,
1313 RMsgQueue<TMessageBuf> *aMsgQueue = NULL,
1314 TMessageBuf *aBuffer = NULL,
1315 RSemaphore *aTheSem = NULL)
1317 TUint start = User::TickCount();
1319 TFullName n(RThread().Name());
1321 DEBUG_PRINT((_L("%S : thread %d Executing %S\n"), &TestNameBuffer, aThreadIndex, &n));
1323 // now select how we do the test...
1326 PageLdrRLibrary *pTheLibs = theGlobalLibs;
1327 TInt maxDllIndex = GetNumDlls();
1329 switch (TestLoadDllHow)
1331 case TEST_DLL_THREAD:
1333 DOLOADALLOC(maxDllIndex, pTheLibs, aTheSem);
1336 TInt retVal = LoadTheLibs(pTheLibs, maxDllIndex, aThreadIndex, aMsgQueue, aBuffer, aTheSem);
1337 if (retVal != KErrNone)
1339 DEBUG_PRINT((_L("Perform[%d] - load fail\n"), aThreadIndex));
1340 CloseTheLibs (pTheLibs, maxDllIndex);
1341 User::Free(pTheLibs);
1347 DEBUG_PRINT((_L("Perform[%d] - alloc fail\n"), aThreadIndex));
1352 case TEST_DLL_GLOBAL:
1353 pTheLibs = theGlobalLibs;
1362 TInt retVal = KErrNone;
1363 if (TEST_ALL == (TestWhichTests & TEST_ALL))
1365 #define LOCAL_ORDER_INDEX1 6
1366 #define LOCAL_ORDER_INDEX2 3
1367 TInt order[LOCAL_ORDER_INDEX1][LOCAL_ORDER_INDEX2] = { {TEST_FORWARD, TEST_BACKWARD,TEST_RANDOM},
1368 {TEST_FORWARD, TEST_RANDOM, TEST_BACKWARD},
1369 {TEST_BACKWARD,TEST_FORWARD, TEST_RANDOM},
1370 {TEST_BACKWARD,TEST_RANDOM, TEST_FORWARD},
1371 {TEST_RANDOM, TEST_FORWARD, TEST_BACKWARD},
1372 {TEST_RANDOM, TEST_BACKWARD,TEST_FORWARD}};
1373 TInt whichOrder = 0;
1375 for (iterIndex = 0; ; )
1377 TInt selOrder = ((aThreadIndex + 1) * (iterIndex + 1)) % LOCAL_ORDER_INDEX1;
1378 for (whichOrder = 0; whichOrder < LOCAL_ORDER_INDEX2; whichOrder ++)
1380 switch (order[selOrder][whichOrder])
1383 DEBUG_PRINT((_L("%S : %d Iter %d.%d Forward\n"),
1384 &TestNameBuffer, aThreadIndex, iterIndex, whichOrder));
1385 retVal = RunThreadForward(aThreadIndex, pTheLibs, maxDllIndex, aMsgQueue, aBuffer, aTheSem);
1389 DEBUG_PRINT((_L("%S : %d Iter %d.%d Backward\n"),
1390 &TestNameBuffer, aThreadIndex, iterIndex, whichOrder));
1391 retVal = RunThreadBackward(aThreadIndex, pTheLibs, maxDllIndex, aMsgQueue, aBuffer, aTheSem);
1395 DEBUG_PRINT((_L("%S : %d Iter %d.%d Random\n"),
1396 &TestNameBuffer, aThreadIndex, iterIndex, whichOrder));
1397 retVal = RunThreadRandom(aThreadIndex, pTheLibs, maxDllIndex, aMsgQueue, aBuffer, aTheSem);
1400 default: // this is really an error.
1403 DEBUG_PRINT((_L("%S : %d Iter %d.%d finished %d\n"),
1404 &TestNameBuffer, aThreadIndex, iterIndex, whichOrder, retVal));
1405 if ((retVal == KErrCancel) && iterIndex > 0)
1407 if ((retVal != KErrNone) || TestThreadsExit)
1410 if ((retVal != KErrNone) || TestThreadsExit)
1412 if (++iterIndex >= TestMaxLoops)
1414 User::AfterHighRes(TEST_DOT_PERIOD/3*1000000);
1419 if (TestWhichTests & TEST_FORWARD)
1421 for (iterIndex = 0; ; )
1423 DEBUG_PRINT((_L("%S : %d Iter %d Forward\n"), &TestNameBuffer, aThreadIndex, iterIndex));
1424 retVal = RunThreadForward(aThreadIndex, pTheLibs, maxDllIndex, aMsgQueue, aBuffer, aTheSem);
1425 DEBUG_PRINT((_L("%S : %d Iter %d finished %d\n"), &TestNameBuffer, aThreadIndex, iterIndex, retVal));
1426 if ((retVal == KErrCancel) && iterIndex > 0)
1428 if ((retVal != KErrNone) || TestThreadsExit)
1430 if (++iterIndex >= TestMaxLoops)
1432 User::AfterHighRes(TEST_DOT_PERIOD/3*1000000);
1436 if (TestWhichTests & TEST_BACKWARD)
1438 for (iterIndex = 0; ; )
1440 DEBUG_PRINT((_L("%S : %d Iter %d Backward\n"), &TestNameBuffer, aThreadIndex, iterIndex));
1441 retVal = RunThreadBackward(aThreadIndex, pTheLibs, maxDllIndex, aMsgQueue, aBuffer, aTheSem);
1442 DEBUG_PRINT((_L("%S : %d Iter %d finished %d\n"), &TestNameBuffer, aThreadIndex, iterIndex, retVal));
1443 if ((retVal == KErrCancel) && iterIndex > 0)
1445 if ((retVal != KErrNone) || TestThreadsExit)
1447 if (++iterIndex >= TestMaxLoops)
1449 User::AfterHighRes(TEST_DOT_PERIOD/3*1000000);
1453 if (TestWhichTests & TEST_RANDOM)
1455 for (iterIndex = 0; ; )
1457 DEBUG_PRINT((_L("%S : %d Iter %d Random\n"), &TestNameBuffer, aThreadIndex, iterIndex));
1458 retVal = RunThreadRandom(aThreadIndex, pTheLibs, maxDllIndex, aMsgQueue, aBuffer, aTheSem);
1459 DEBUG_PRINT((_L("%S : %d Iter %d finished %d\n"), &TestNameBuffer, aThreadIndex, iterIndex, retVal));
1460 if ((retVal == KErrCancel) && iterIndex > 0)
1462 if ((retVal != KErrNone) || TestThreadsExit)
1464 if (++iterIndex >= TestMaxLoops)
1466 User::AfterHighRes(TEST_DOT_PERIOD/3*1000000);
1470 if (TestWhichTests & TEST_THRASH)
1472 for (iterIndex = 0; ; )
1474 DEBUG_PRINT((_L("%S : %d Iter %d Thrash Load\n"), &TestNameBuffer, aThreadIndex, iterIndex));
1475 retVal = ThrashThreadLoad(aThreadIndex, pTheLibs, maxDllIndex, aMsgQueue, aBuffer, aTheSem);
1476 DEBUG_PRINT((_L("%S : %d Iter %d finished %d\n"), &TestNameBuffer, aThreadIndex, iterIndex, retVal));
1477 if ((retVal == KErrCancel) && iterIndex > 0)
1479 if ((retVal != KErrNone) || TestThreadsExit)
1481 if (++iterIndex >= TestMaxLoops)
1483 User::AfterHighRes(TEST_DOT_PERIOD/3*1000000);
1488 if (TestLoadDllHow == TEST_DLL_THREAD)
1490 CloseTheLibs(pTheLibs, maxDllIndex);
1491 User::Free(pTheLibs);
1494 DEBUG_PRINT((_L("%S : thread %d Exit (tick %u)\n"), &TestNameBuffer, aThreadIndex, User::TickCount() - start));
1500 // MultipleTestThread
1502 // Thread function, one created for each thread in a multiple thread test.
1505 LOCAL_C TInt MultipleTestThread(TAny* aUseTb)
1508 TMessageBuf localBuffer;
1513 thisThread.SetPriority((TThreadPriority) TEST_INTERLEAVE_PRIO);
1516 ret = PerformTestThread((TInt) aUseTb, &TestMsgQueue, &localBuffer, &TestMultiSem);
1519 if (ret != KErrNone)
1520 User::Panic(_L("LOAD"), KErrGeneral);
1528 // Start an executable.
1531 TInt StartExe(RProcess& aTheProcesses, TRequestStatus* aPrStatus, TInt aIndex, TBool aLoadSelf, TBool aLowMem, RSemaphore *pTheSem = NULL)
1534 TInt testWhich = KTestMediaRom;
1535 //y_LIT(KTestDebug, "debug");
1536 _LIT(KTestSilent, "silent");
1538 if ((TestWhichMedia & TEST_MEDIA_ALL) == TEST_MEDIA_ALL)
1539 testWhich = aIndex % KTestMediaCOUNT;
1540 else if ((TestWhichMedia & TEST_MEDIA_ALL) == TEST_MEDIA_ROM_BASE)
1541 testWhich = (aIndex & 1) ? KTestMediaBase : KTestMediaRom;
1542 else if (TestWhichMedia & TEST_MEDIA_BASE )
1543 testWhich = KTestMediaBase;
1545 testWhich = KTestMediaRom;
1547 if (!TestDllExesExist[testWhich])
1548 testWhich = KTestMediaBase;
1554 buffer.Format(_L("single random dll %S iters %d inst %d"),
1555 /* TestDebug ? &KTestDebug : */ &KTestSilent, TestMaxLoops, aIndex);
1556 if (TestExtremeChunks)
1557 buffer.Append(_L(" echunks"));
1558 else if (TestChunksPlus)
1559 buffer.Append(_L(" chunks prio"));
1560 if (TestChunkData == EFalse)
1561 buffer.Append(_L(" nochunkdata"));
1562 DBGS_PRINT((_L("%S : Starting Process %d %S %S\n"),
1563 &TestNameBuffer, aIndex, &TestPlExeNames[testWhich], &buffer));
1564 DOTEST1(ret,aTheProcesses.Create(TestPlExeNames[testWhich],buffer),KErrNone, KErrNoMemory);
1568 buffer.Format(_L("single random %S iters %d inst %d"),
1569 /* TestDebug ? &KTestDebug : */ &KTestSilent, TestMaxLoops, aIndex);
1570 DBGS_PRINT((_L("%S : Starting Process %d %S %S\n"),
1571 &TestNameBuffer, aIndex, &TestPsExeNames[testWhich], &buffer));
1572 DOTEST1(ret,aTheProcesses.Create(TestPsExeNames[testWhich],buffer),KErrNone, KErrNoMemory);
1574 if (ret == KErrNone)
1578 aTheProcesses.Logon(*aPrStatus);
1579 RUNTEST1(*aPrStatus == KRequestPending);
1581 aTheProcesses.Resume();
1587 // PerformRomAndFileSystemAccessThread
1589 // Access the rom and dump it out to one of the writeable partitions...
1590 // really just to make the media server a little busy during the test.
1592 TInt PerformRomAndFileSystemAccessThread(TInt aThreadId,
1593 RMsgQueue<TMessageBuf> *aMsgQueue,
1594 TMessageBuf *aBuffer,
1595 RSemaphore *aTheSem,
1599 TUint maxBytes = KMaxTUint;
1600 TInt startTime = User::TickCount();
1601 RSemaphore *pTheSem = aTheSem;
1605 if (KErrNone != fs.Connect())
1607 DEBUG_PRINT(_L("PerformRomAndFileSystemAccessThread : Can't connect to the FS\n"));
1611 // get info about the ROM...
1612 TRomHeader* romHeader = (TRomHeader*)UserSvr::RomHeaderAddress();
1615 if(romHeader->iPageableRomStart)
1617 start = (TUint8*)romHeader + romHeader->iPageableRomStart;
1618 end = start + romHeader->iPageableRomSize;
1622 start = (TUint8*)romHeader;
1623 end = start + romHeader->iUncompressedSize;
1628 // read all ROM pages in a random order...and write out to file in ROFs
1630 UserSvr::HalFunction(EHalGroupKernel,EKernelHalPageSizeInBytes,&pageSize,0);
1632 TUint size = end - start - pageSize;
1636 TUint32 random = 1 + aThreadId;
1641 DOTEST((checkData = HBufC8::New(pageSize + 10)),
1642 (checkData != NULL));
1646 DEBUG_PRINT((_L("RomAndFSThread %S : failed to alloc read buffer\n"), &TestNameBuffer));
1649 TInt drvNum = (TestBootedFromMmc || TestOnlyFromMmc) ? FindMMCDriveNumber(fs) : FindFsNANDDrive(fs);
1652 filename.Format(_L("?:\\Pageldrtst%d.tmp"), aThreadId);
1655 DEBUG_PRINT((_L("%S : Filename %S\n"), &TestNameBuffer, &filename));
1659 DEBUG_PRINT((_L("RomAndFSThread : error getting drive num\n")));
1660 drvNum = 3; //make it 'd' by default.
1662 filename[0] = 'a' + drvNum;
1664 #ifdef WANT_FS_CACHE_STATS
1665 TInt allocatedSegmentCount = 0;
1666 TInt filesOnClosedQueue = 0;
1671 for(TInt i = size / (pageSize); i>0; --i)
1673 DEBUG_PRINT1((_L("%S : Opening the file\n"), &TestNameBuffer));
1674 DOTEST((ret = file.Replace(fs, filename, EFileWrite)),
1677 random = random * 69069 + 1;
1678 theAddr = (TUint8 *)(start + ((TInt64(random) * TInt64(size - pageSize)) >> 32));
1679 sourceData.Set(theAddr,pageSize);
1680 DEBUG_PRINT1((_L("%S : Writing the file\n"), &TestNameBuffer));
1681 ret = file.Write(sourceData);
1682 if (ret != KErrNone)
1684 DEBUG_PRINT((_L("%S : Write returned error %d\n"), &TestNameBuffer, ret));
1686 DEBUG_PRINT1((_L("%S : Closing the file\n"), &TestNameBuffer));
1691 TPtr8 theBuf = checkData->Des();
1693 #ifdef WANT_FS_CACHE_STATS
1695 TFileCacheStats stats1;
1696 TFileCacheStats stats2;
1697 ret = controlIo(fs,drvNum, KControlIoFileCacheStats, stats1);
1698 if ((ret != KErrNone) && (ret != KErrNotSupported))
1700 DEBUG_PRINT((_L("%S : KControlIoFileCacheStats 1 failed %d\n"), &TestNameBuffer, ret));
1705 // flush closed files queue
1706 ret = fs.ControlIo(drvNum, KControlIoFlushClosedFiles);
1707 if (ret != KErrNone)
1709 DEBUG_PRINT((_L("%S : KControlIoFlushClosedFiles failed %d\n"), &TestNameBuffer, ret));
1713 #endif //WANT_FS_CACHE_STATS
1715 // rename file to make sure it has cleared the cache.
1717 newname.Format(_L("d:\\Pageldrtst%d.temp"), aThreadId);
1720 newname[0] = 'a' + drvNum;
1722 fs.Rename(filename, newname);
1725 #ifdef WANT_FS_CACHE_STATS
1726 ret = controlIo(fs,drvNum, KControlIoFileCacheStats, stats2);
1727 if (ret != KErrNone && ret != KErrNotSupported)
1729 DEBUG_PRINT((_L("%S : KControlIoFileCacheStats2 failed %d\n"), &TestNameBuffer, ret));
1732 allocatedSegmentCount = (allocatedSegmentCount > stats1.iAllocatedSegmentCount) ? allocatedSegmentCount : stats1.iAllocatedSegmentCount;
1733 filesOnClosedQueue = (filesOnClosedQueue > stats1.iFilesOnClosedQueue) ? filesOnClosedQueue : stats1.iFilesOnClosedQueue;
1734 #endif //WANT_FS_CACHE_STATS
1736 DOTEST((ret = file.Open(fs, filename, EFileRead)),
1738 // now read back the page that we wrote and compare with the source.
1739 ret = file.Read(0, theBuf, pageSize);
1740 if (ret == KErrNone)
1742 ret = sourceData.Compare(theBuf);
1745 DEBUG_PRINT((_L("%S : read compare error %d\n"), &TestNameBuffer, ret));
1750 DEBUG_PRINT((_L("%S : failed read compare, error %d\n"), &TestNameBuffer, ret));
1754 DEBUG_PRINT1((_L("%S : Deleting the file\n"), &TestNameBuffer));
1755 ret = fs.Delete(filename);
1756 if (KErrNone != ret)
1758 DEBUG_PRINT((_L("%S [%d] Delete %S Failed %d!\n"), &TestNameBuffer, aThreadId, &filename, ret));
1763 TThreadPriority originalThreadPriority = thisThread.Priority();
1764 DEBUG_PRINT1((_L("%S [%d] media thread before priority change, stop = %d\n"), &TestNameBuffer, aThreadId, TestStopMedia));
1765 thisThread.SetPriority(EPriorityLess);
1766 User::AfterHighRes(0);
1767 thisThread.SetPriority(originalThreadPriority);
1768 DEBUG_PRINT1((_L("%S [%d] media thread after priority change, stop = %d\n"), &TestNameBuffer, aThreadId, TestStopMedia));
1777 #ifdef WANT_FS_CACHE_STATS
1778 DEBUG_PRINT((_L("%S : [%d] allocPageCount %d filesClosedQueue %d \n"),&TestNameBuffer, aThreadId,allocatedSegmentCount,filesOnClosedQueue));
1779 #endif //WANT_FS_CACHE_STATS
1786 DEBUG_PRINT1((_L("Done in %d ticks\n"), User::TickCount() - startTime));
1791 // PerformFileSystemAccessThread
1793 // Access the rom and dump it out to one of the writeable partitions...
1794 // really just to make the media server a little busy during the test.
1796 TInt PerformFileSystemAccessThread(TInt aThreadId,
1797 RMsgQueue<TMessageBuf> *aMsgQueue,
1798 TMessageBuf *aBuffer,
1799 RSemaphore *aTheSem,
1803 TInt startTime = User::TickCount();
1804 RSemaphore *pTheSem = aTheSem;
1807 if (KErrNone != fs.Connect())
1809 DEBUG_PRINT(_L("PerformFileSystemAccessThread : Can't connect to the FS\n"));
1813 // read all ROM pages in a random order...and write out to file in ROFs
1815 UserSvr::HalFunction(EHalGroupKernel,EKernelHalPageSizeInBytes,&pageSize,0);
1819 TUint32 random = 1 + aThreadId;
1820 TInt dataSize = pageSize + (pageSize / 2);
1822 DOTEST((sourceData = HBufC8::New(dataSize)),
1823 (sourceData != NULL));
1826 DEBUG_PRINT((_L("RomAndFSThread %S : failed to alloc read buffer\n"), &TestNameBuffer));
1831 DOTEST((checkData = HBufC8::New(dataSize)),
1832 (checkData != NULL));
1835 DEBUG_PRINT((_L("RomAndFSThread %S : failed to alloc read buffer\n"), &TestNameBuffer));
1838 TInt drvNum = (TestBootedFromMmc || TestOnlyFromMmc) ? FindMMCDriveNumber(fs) : FindFsNANDDrive(fs);
1843 drvNum = 3; //make it 'd' by default.
1844 DEBUG_PRINT((_L("FSAccessThread : error getting drive num\n")));
1847 #ifdef WANT_FS_CACHE_STATS
1848 TInt allocatedSegmentCount = 0;
1849 TInt filesOnClosedQueue = 0;
1854 TPtr8 pBuf = sourceData->Des();
1858 TUint32 randomStart = random;
1860 for (fileIndex = 0; fileIndex < TEST_NUM_FILES; fileIndex ++)
1862 filename.Format(_L("%c:\\pldrtst%d_%d.tmp"), 'a' + drvNum, aThreadId, fileIndex);
1864 DEBUG_PRINT1((_L("%S : Opening the file\n"), &TestNameBuffer));
1866 DOTEST ((ret = file.Replace(fs, filename, EFileWrite)),
1872 TInt fillSize = dataSize / sizeof(TUint32);
1873 while (fillSize > 0)
1875 random = random * 69069 + 1;
1876 pBuf.Append((const TUint8 *) &random, sizeof(random));
1882 pBuf.Fill('x',dataSize);
1886 DEBUG_PRINT1((_L("%S : Writing the file\n"), &TestNameBuffer));
1887 ret = file.Write(sourceData->Des());
1888 if (ret != KErrNone)
1890 DEBUG_PRINT((_L("%S : Write returned error %d\n"), &TestNameBuffer, ret));
1892 DEBUG_PRINT1((_L("%S : Closing the file\n"), &TestNameBuffer));
1896 random = randomStart;
1898 for (fileIndex = 0; fileIndex < TEST_NUM_FILES; fileIndex ++)
1900 filename.Format(_L("%c:\\pldrtst%d_%d.tmp"), 'a' + drvNum, aThreadId, fileIndex);
1904 TPtr8 theBuf = checkData->Des();
1906 #ifdef WANT_FS_CACHE_STATS
1908 TFileCacheStats stats1;
1909 TFileCacheStats stats2;
1910 ret = controlIo(fs,drvNum, KControlIoFileCacheStats, stats1);
1911 if ((ret != KErrNone) && (ret != KErrNotSupported))
1913 DEBUG_PRINT((_L("%S : KControlIoFileCacheStats 1 failed %d\n"), &TestNameBuffer, ret));
1918 // flush closed files queue
1919 ret = fs.ControlIo(drvNum, KControlIoFlushClosedFiles);
1920 if (ret != KErrNone)
1922 DEBUG_PRINT((_L("%S : KControlIoFlushClosedFiles failed %d\n"), &TestNameBuffer, ret));
1926 #endif //WANT_FS_CACHE_STATS
1928 // rename file to make sure it has cleared the cache.
1930 newname.Format(_L("%c:\\pldrtst%d_%d.temp"), 'a' + drvNum, aThreadId, fileIndex);
1931 fs.Rename(filename, newname);
1934 #ifdef WANT_FS_CACHE_STATS
1935 ret = controlIo(fs,drvNum, KControlIoFileCacheStats, stats2);
1936 if (ret != KErrNone && ret != KErrNotSupported)
1938 DEBUG_PRINT((_L("%S : KControlIoFileCacheStats2 failed %d\n"), &TestNameBuffer, ret));
1940 allocatedSegmentCount = (allocatedSegmentCount > stats1.iAllocatedSegmentCount) ? allocatedSegmentCount : stats1.iAllocatedSegmentCount;
1941 filesOnClosedQueue = (filesOnClosedQueue > stats1.iFilesOnClosedQueue) ? filesOnClosedQueue : stats1.iFilesOnClosedQueue;
1942 #endif //WANT_FS_CACHE_STATS
1944 DOTEST((ret = file.Open(fs, filename, EFileRead)),
1946 // now read back the page that we wrote and compare with the source.
1947 ret = file.Read(0, theBuf, dataSize);
1948 if (ret == KErrNone)
1953 TInt fillSize = dataSize / sizeof(TUint32);
1954 while (fillSize > 0)
1956 random = random * 69069 + 1;
1957 pBuf.Append((const TUint8 *) &random, sizeof(random));
1963 pBuf.Fill('x',dataSize);
1966 ret = sourceData->Des().Compare(theBuf);
1969 DEBUG_PRINT((_L("%S :compare error %S %d\n"), &TestNameBuffer, &filename, ret));
1974 DEBUG_PRINT((_L("%S : failed read compare, error %d\n"), &TestNameBuffer, ret));
1978 DEBUG_PRINT1((_L("%S : Deleting the file\n"), &TestNameBuffer));
1979 ret = fs.Delete(filename);
1980 if (KErrNone != ret)
1982 DEBUG_PRINT((_L("%S [%d] Delete %S Failed %d!\n"), &TestNameBuffer, aThreadId, &filename, ret));
1986 TThreadPriority originalThreadPriority = thisThread.Priority();
1987 thisThread.SetPriority(EPriorityLess);
1988 User::AfterHighRes(0);
1989 thisThread.SetPriority(originalThreadPriority);
1997 #ifdef WANT_FS_CACHE_STATS
1998 DEBUG_PRINT((_L("%S : [%d] allocPageCount %d filesClosedQueue %d \n"),&TestNameBuffer, aThreadId,allocatedSegmentCount,filesOnClosedQueue));
1999 #endif //WANT_FS_CACHE_STATS
2007 DEBUG_PRINT1((_L("Done in %d ticks\n"), User::TickCount() - startTime));
2012 // PerformRomAndFileSystemAccess
2014 // Thread function, kicks off the file system access.
2017 LOCAL_C TInt PerformRomAndFileSystemAccess(TAny* aParam)
2019 TMessageBuf localBuffer;
2020 TInt threadId = (TInt) aParam;
2021 TInt retVal = KErrGeneral;
2026 thisThread.SetPriority((TThreadPriority) TEST_INTERLEAVE_PRIO);
2029 switch (TestMediaAccess)
2034 case KTestMediaAccessBasic:
2035 case KTestMediaAccessMultipleThreads:
2036 retVal = PerformRomAndFileSystemAccessThread(threadId, &TestMsgQueue, &localBuffer, &TestMultiSem, TestingLowMem);
2039 case KTestMediaAccessMultiplePattern:
2040 retVal = PerformFileSystemAccessThread(threadId, &TestMsgQueue, &localBuffer, &TestMultiSem, TestingLowMem);
2043 case KTestMediaAccessMixed:
2044 if (threadId < ((TestMultipleThreadCount + 1) / 2))
2045 retVal = PerformRomAndFileSystemAccessThread(threadId, &TestMsgQueue, &localBuffer, &TestMultiSem, TestingLowMem);
2047 retVal = PerformFileSystemAccessThread(threadId, &TestMsgQueue, &localBuffer, &TestMultiSem, TestingLowMem);
2055 // DisplayTestBanner
2057 // Output a header showing the test parameters.
2060 void DisplayTestBanner(TBool aMultiple)
2062 DBGS_PRINT((_L("%S : what = %S%S%S(0x%x), media = %S%S%S(0x%x)\n"),
2063 aMultiple ? &KMultipleTest : &KSingleTest,
2064 TestLoading & TEST_EXE ? &KTestExe : &KTestBlank,
2065 TestLoading & TEST_DLL ? &KTestDll : &KTestBlank,
2066 TestLoading & TEST_SELF ? &KTestSelf : &KTestBlank,
2068 TestWhichMedia & TEST_MEDIA_BASE ? &KTestBase : &KTestBlank,
2069 TestWhichMedia & TEST_MEDIA_ROM ? &KTestRom : &KTestBlank,
2070 (TestWhichMedia & TEST_MEDIA_ALL) == TEST_MEDIA_ALL ? &KTestAll : &KTestBlank,
2072 DBGS_PRINT((_L(" : maxLoops = %d, threads = %d, loadHow = %S (0x%x)\n"),
2074 TestMultipleThreadCount,
2075 TestLoadDllHow == TEST_DLL_GLOBAL ? &KTestGlobal : TestLoadDllHow == TEST_DLL_THREAD ? &KTestThread : &KTestFunc, TestLoadDllHow));
2076 DBGS_PRINT((_L(" : options = %S%S%S%S%S%S, which = %S%S%S%S (0x%x)\n"),
2077 TestInterleave ? &KTestInter : &KTestBlank,
2078 TestPrioChange ? &KTestPrio: &KTestBlank,
2079 (TestMediaAccess == KTestMediaAccessNone) ? &KTestBlank : &KTestMedia,
2080 TestingLowMem ? &KTestLowMem : &KTestBlank,
2081 TestExtremeChunks ? &KTestEChunking : TestChunksPlus ? &KTestChunkingPlus : TestingChunks ? &KTestChunking : &KTestBlank,
2082 TestingReaper ? &KTestReaper : &KTestBlank,
2083 TestWhichTests & TEST_THRASH ? &KTestThrash : &KTestBlank,
2084 TestWhichTests & TEST_FORWARD ? &KTestForward : &KTestBlank,
2085 TestWhichTests & TEST_BACKWARD ? &KTestBackward : &KTestBlank,
2086 TestWhichTests & TEST_RANDOM ? &KTestRandom : &KTestBlank,
2093 // Perform the single thread test, spawning a number of threads.
2096 LOCAL_C TInt DoSingleTest(TBool aLowMem = EFalse)
2098 TUint start = User::TickCount();
2099 RSemaphore *pTheSem = NULL;
2100 TInt ret = KErrNone;
2101 DisplayTestBanner(EFalse);
2105 DOTEST1(ret,TestMultiSem.CreateLocal(1),KErrNone, KErrNoMemory);
2106 pTheSem = &TestMultiSem;
2108 if (TestLoading & TEST_EXE)
2110 RProcess theProcess;
2111 TRequestStatus status;
2113 if (StartExe(theProcess, &status, 0, EFalse, aLowMem, pTheSem) == KErrNone)
2115 User::WaitForRequest(status);
2116 if (theProcess.ExitType() == EExitPanic)
2118 DBGS_PRINT((_L("%S : Process Panic'd...\n"), &TestNameBuffer));
2124 if (TestLoading & TEST_SELF)
2126 RProcess theProcess;
2127 TRequestStatus status;
2129 if (StartExe(theProcess, &status, 0, ETrue, aLowMem,pTheSem) == KErrNone)
2131 User::WaitForRequest(status);
2132 if (theProcess.ExitType() == EExitPanic)
2134 DBGS_PRINT((_L("%S : Process Panic'd...\n"), &TestNameBuffer));
2140 if (TestLoading & TEST_DLL)
2142 TInt maxDlls = GetNumDlls();
2143 if (TestLoadDllHow == TEST_DLL_GLOBAL)
2145 TInt retVal = LoadTheLibs(theGlobalLibs, maxDlls, TestInstanceId, NULL, NULL, pTheSem);
2146 if (retVal != KErrNone)
2148 DBGS_PRINT((_L("DoSingleTest - unable to load libs\n") ));
2149 CloseTheLibs (theGlobalLibs, PAGELDRTST_MAX_DLLS);
2152 TestMultiSem.Close();
2158 ret = PerformTestThread((TInt) TestInstanceId, NULL, NULL, pTheSem);
2160 if (TestLoadDllHow == TEST_DLL_GLOBAL)
2162 CloseTheLibs(theGlobalLibs, maxDlls);
2167 TestMultiSem.Close();
2172 TInt end = User::TickCount();
2173 TInt time = TUint((TUint64)(end-start)*(TUint64)TickPeriod/(TUint64)1000000);
2174 DBGS_PRINT((_L("\n%S : Single Test : (%u seconds)\n"), &TestNameBuffer, time));
2183 // Fill a page with test data
2186 void FillPage(TUint aOffset)
2190 TUint32* ptr = (TUint32 *)((TUint8 *)TestChunkBase+aOffset);
2191 TUint32* ptrEnd = (TUint32 *)((TUint8 *)ptr + TestPageSize);
2194 *ptr = 0x55000000 + aOffset;
2205 // Check a page matches test data....
2208 TBool CheckPage(TUint index, TUint aOffset)
2213 TUint32* ptr = (TUint32 *)((TUint8 *)TestChunkBase+aOffset);
2214 TUint32* ptrEnd = (TUint32 *)((TUint8 *)ptr + TestPageSize);
2217 if (*ptr != (0x55000000 + aOffset))
2225 TestChunkStats[index].check.ok ++;
2229 TestChunkStats[index].check.fail ++;
2239 // Lock and unlock various pages in a chunk...
2241 TUint TestChunkingIndex = 0;
2242 TUint TestChunkingIndexFails = 0;
2244 void DoSomeChunking()
2246 TUint iters = TEST_NUM_CHUNK_PAGES / 4;
2247 TBool lockit = EFalse;
2248 TBool decomit = EFalse;
2255 TestChunkingIndex = TestChunkingIndex * 69069 + 1;
2256 index = TUint64((TUint64)TestChunkingIndex*(TUint64)TEST_NUM_CHUNK_PAGES)>>32;
2257 if (index >= TEST_NUM_CHUNK_PAGES)
2258 TestChunkingIndexFails ++;
2260 theOffset = index * TestPageSize;
2261 if (theOffset < TestCommitEnd)
2267 ret = TestChunk.Decommit(theOffset,TestPageSize);
2268 if (KErrNone == ret)
2269 TestChunkStats[index].decommit.ok ++;
2271 TestChunkStats[index].decommit.fail ++;
2272 ret = TestChunk.Commit(theOffset,TestPageSize);
2273 if (KErrNone == ret)
2275 TestChunkStats[index].commit.ok ++;
2276 FillPage(theOffset);
2277 TestChunkPageState[index] = ETrue;
2281 TestChunkStats[index].commit.fail ++;
2282 TestChunkPageState[index] = EFalse;
2288 ret = TestChunk.Lock(theOffset,TestPageSize);
2289 if (KErrNone == ret)
2291 TestChunkStats[index].lock.ok ++;
2292 if (!CheckPage(index, theOffset))
2293 FillPage(theOffset);
2294 TestChunkPageState[index] = ETrue;
2298 TestChunkStats[index].lock.fail ++;
2299 TestChunkPageState[index] = EFalse;
2306 if (TestChunkPageState[index])
2308 // this one should still be locked so the data should be ok.
2309 if (KErrNone == TestChunk.Lock(theOffset,TestPageSize))
2311 TestChunkStats[index].lock.ok ++;
2312 CheckPage(index, theOffset);
2315 TestChunkStats[index].lock.fail ++;
2317 ret = TestChunk.Unlock(theOffset,TestPageSize);
2318 if (KErrNone == ret)
2319 TestChunkStats[index].unlock.ok ++;
2321 TestChunkStats[index].unlock.fail ++;
2322 TestChunkPageState[index] = EFalse;
2324 if (KErrNone != ret)
2326 // so now we need to commit another page in this pages place.
2327 ret = TestChunk.Commit(theOffset,TestPageSize);
2328 if (KErrNone != ret)
2330 TestChunkStats[index].commit.fail ++;
2331 //DBGS_PRINT((_L("%S : DoSomeChunking[%03d] index %03d failed to commit a page %d\n"), &TestNameBuffer, iters, index, ret));
2332 TestChunkPageState[index] = EFalse;
2336 TestChunkStats[index].commit.ok ++;
2337 FillPage(theOffset);
2338 TestChunkPageState[index] = ETrue;
2345 RDebug::Printf("DoSomeChunking - offset was bad %d / %d", theOffset, TestCommitEnd);
2354 // Perform the multiple thread test, spawning a number of threads.
2355 // It is complicated a little because test.Printf can only be called from the first thread that calls it
2356 // so if we are using multiple threads we need to use a message queue to pass the debug info from the
2357 // child threads back to the parent for the parent to then call printf.
2360 TInt DoMultipleTest(TBool aLowMem = EFalse)
2363 TUint start = User::TickCount();
2364 RThread *pTheThreads = NULL;
2365 TInt *pThreadInUse = NULL;
2367 RProcess *pTheProcesses = NULL;
2368 TInt *pProcessInUse = NULL;
2370 RThread *pMedThreads = NULL;
2371 TInt *pMedInUse = NULL;
2373 TRequestStatus mediaStatus;
2374 RThread mediaThread;
2377 RSemaphore *pTheSem = NULL;
2379 DisplayTestBanner(ETrue);
2381 TestThreadsExit = EFalse;
2383 DOTEST1(ret,TestMultiSem.CreateLocal(1),KErrNone, KErrNoMemory);
2385 pTheSem = &TestMultiSem;
2386 if (TestLoading & TEST_DLL)
2388 DOTEST((pTheThreads = (RThread *)User::AllocZ(sizeof(RThread) * TestMultipleThreadCount)),
2389 (pTheThreads != NULL))
2390 DOTEST((pThreadInUse = (TInt *)User::AllocZ(sizeof(TInt) * TestMultipleThreadCount)),
2391 (pThreadInUse != NULL));
2392 RUNTEST1(pTheThreads && pThreadInUse);
2393 if (!(pTheThreads && pThreadInUse))
2397 if (TestLoading & TEST_EXE_SELF)
2399 DOTEST((pTheProcesses = (RProcess *)User::AllocZ(sizeof(RProcess) * TestMultipleThreadCount)),
2400 (pTheProcesses != NULL));
2401 DOTEST((pProcessInUse = (TInt *)User::AllocZ(sizeof(TInt) * TestMultipleThreadCount)),
2402 (pProcessInUse != NULL));
2403 RUNTEST1(pTheProcesses && pProcessInUse);
2404 if (!(pTheProcesses && pProcessInUse))
2410 DOTEST1(ret,TestMsgQueue.CreateLocal(TestMultipleThreadCount * 10, EOwnerProcess),KErrNone, KErrNoMemory);
2411 if (ret != KErrNone)
2415 if (TestMediaAccess != KTestMediaAccessNone)
2417 if (TestMediaAccess != KTestMediaAccessBasic)
2419 TestStopMedia = EFalse;
2420 DOTEST((pMedThreads = (RThread *)User::AllocZ(sizeof(RThread) * TestMultipleThreadCount)),
2421 (pMedThreads != NULL))
2422 DOTEST((pMedInUse = (TInt *)User::AllocZ(sizeof(TInt) * TestMultipleThreadCount)),
2423 (pMedInUse != NULL));
2424 RUNTEST1(pMedThreads && pMedInUse);
2425 if (!(pMedThreads && pMedInUse))
2428 for (index = 0; index < TestMultipleThreadCount; index++)
2430 DBGS_PRINT((_L("%S : Starting Media Thread %d\n"), &TestNameBuffer, index));
2431 DOTEST1(ret,pMedThreads[index].Create(KTestBlank,PerformRomAndFileSystemAccess,KDefaultStackSize,NULL,(TAny*) index),KErrNone, KErrNoMemory);
2432 if (ret == KErrNone)
2434 pMedThreads[index].Resume();
2435 pMedInUse[index] = 1;
2437 User::AfterHighRes(0);
2442 TestStopMedia = EFalse;
2443 DOTEST1(ret,mediaThread.Create(KTestBlank,PerformRomAndFileSystemAccess,KDefaultStackSize,NULL,(TAny *) 0),KErrNone, KErrNoMemory);
2444 if (ret == KErrNone)
2446 mediaThread.Logon(mediaStatus);
2447 RUNTEST1(mediaStatus == KRequestPending);
2448 mediaThread.Resume();
2453 TInt maxDlls = GetNumDlls();
2454 if (TestLoadDllHow == TEST_DLL_GLOBAL)
2456 TInt retVal = LoadTheLibs(theGlobalLibs, maxDlls, 0, NULL, NULL, NULL);
2457 if (retVal != KErrNone)
2459 DBGS_PRINT((_L("DoMultipleTest - unable to load libs\n")));
2460 CloseTheLibs (theGlobalLibs, maxDlls);
2463 TestMsgQueue.Close();
2465 TestMultiSem.Close();
2470 // make sure we have a priority higher than that of the threads we spawn...
2472 TThreadPriority savedThreadPriority = thisThread.Priority();
2473 const TThreadPriority KMainThreadPriority = EPriorityMuchMore;
2474 __ASSERT_COMPILE(KMainThreadPriority>TEST_INTERLEAVE_PRIO);
2475 thisThread.SetPriority(KMainThreadPriority);
2478 for (index = 0; index < TestMultipleThreadCount; index++)
2480 if (TestLoading & TEST_EXE_SELF)
2482 if (KErrNone == StartExe(pTheProcesses[index], 0, index + ((TestLoading & TEST_DLL) ? TestMultipleThreadCount : 0), ((TestLoading & TEST_EXE_SELF) == TEST_EXE_SELF) ? (index & 2) : (TestLoading & TEST_SELF), aLowMem, pTheSem))
2484 User::AfterHighRes(0);
2485 pProcessInUse[index] = 1;
2490 if (TestLoading & TEST_DLL)
2492 DBGS_PRINT((_L("%S : Starting Thread %d\n"), &TestNameBuffer, index));
2493 DOTEST1(ret,pTheThreads[index].Create(KTestBlank,MultipleTestThread,KDefaultStackSize,NULL,(TAny*) index),KErrNone, KErrNoMemory);
2494 if (ret == KErrNone)
2496 pTheThreads[index].Resume();
2497 User::AfterHighRes(0);
2498 pThreadInUse[index] = 1;
2503 // wait for any child threads to exit and process any debug messages they pass back to the parent.
2504 TBool anyUsed = ETrue;
2505 TMessageBuf localBuffer;
2509 TInt processPanic = 0;
2510 TInt threadPanic = 0;
2516 TUint maxDots = (10*60)/TEST_DOT_PERIOD; // No individual test should take longer than 10 minutes!
2517 // Most have been tuned to take between 2 and 8 minutes.
2518 // The autotests should not take more than 120 minutes total.
2522 TInt threadCount = 0;
2523 TInt processCount = 0;
2526 // check the message queue and call printf if we get a message.
2529 while (KErrNone == TestMsgQueue.Receive(localBuffer))
2531 DBGS_PRINT((localBuffer));
2535 // walk through the thread list to check which are still alive.
2536 for (index = 0; index < TestMultipleThreadCount; index++)
2538 if (TestLoading & TEST_DLL)
2540 if (pThreadInUse[index])
2542 if (pTheThreads[index].ExitType() != EExitPending)
2544 if (pTheThreads[index].ExitType() == EExitPanic)
2546 DBGS_PRINT((_L("%S : Thread %d Panic'd after %u ticks \n"),
2547 &TestNameBuffer, index, User::TickCount() - start));
2552 DBGS_PRINT((_L("%S : Thread %d Exited after %u ticks \n"),
2553 &TestNameBuffer, index, User::TickCount() - start));
2556 pTheThreads[index].Close();
2557 pThreadInUse[index] = EFalse;
2563 if (TestThreadsExit)
2565 now = User::TickCount();
2566 time = TUint((TUint64)(now-end)*(TUint64)TickPeriod/(TUint64)1000000);
2567 if (time > TEST_DOT_PERIOD)
2569 DBGS_PRINT((_L("%S : Thread %d still running\n"), &TestNameBuffer, index));
2571 time = TUint((TUint64)(now-killNext)*(TUint64)TickPeriod/(TUint64)1000000);
2572 const TUint killTimeStep = (TEST_DOT_PERIOD+9)/10; // 1/10th of a dot
2573 if(time>TEST_DOT_PERIOD+killTimeStep)
2575 killNext += killTimeStep*1000000/TickPeriod;
2576 DBGS_PRINT((_L("%S : killing Thread %d\n"), &TestNameBuffer, index));
2577 pTheThreads[index].Kill(KErrNone);
2578 pTheThreads[index].Close();
2579 pThreadInUse[index] = EFalse;
2585 if (TestLoading & TEST_EXE_SELF)
2587 if (pProcessInUse[index])
2589 if (pTheProcesses[index].ExitType() != EExitPending)
2591 if (pTheProcesses[index].ExitType() == EExitPanic)
2593 DBGS_PRINT((_L("%S : Process %d Panic'd after %u ticks \n"),
2595 index + ((TestLoading & TEST_DLL) ? TestMultipleThreadCount : 0),
2596 User::TickCount() - start));
2601 DBGS_PRINT((_L("%S : Process %d Exited after %u ticks \n"),
2603 index + ((TestLoading & TEST_DLL) ? TestMultipleThreadCount : 0),
2604 User::TickCount() - start));
2608 pTheProcesses[index].Close();
2609 pProcessInUse[index] = EFalse;
2615 if (TestThreadsExit)
2617 now = User::TickCount();
2618 time = TUint((TUint64)(now-end)*(TUint64)TickPeriod/(TUint64)1000000);
2619 if (time > TEST_DOT_PERIOD)
2621 DBGS_PRINT((_L("%S : Process %d still running; killing it.\n"),
2622 &TestNameBuffer, index));
2623 pTheProcesses[index].Kill(EExitKill);
2624 pTheProcesses[index].Close();
2625 pProcessInUse[index] = EFalse;
2634 now = User::TickCount();
2635 time = TUint((TUint64)(now-end)*(TUint64)TickPeriod/(TUint64)1000000);
2637 DBGD_PRINT((_L("%S : %d seconds (%d ticks) %d threads, %d processes still alive\n"),
2638 &TestNameBuffer, time, now, threadCount, processCount));
2640 if (time > TEST_DOT_PERIOD)
2642 DBGS_PRINT((_L(".")));
2644 end += TEST_DOT_PERIOD*1000000/TickPeriod;
2647 TestingReaperCleaningFiles = ETrue;
2648 CleanupFiles(EFalse);
2649 CheckFilePresence(ETrue);
2650 TestingReaperCleaningFiles = EFalse;
2652 if ((numDots >= maxDots) && (!TestThreadsExit))
2654 DBGS_PRINT((_L("Taking longer than %d dots...exiting test case."), maxDots));
2655 TestThreadsExit = ETrue;
2665 #ifdef TEST_THRASHING_TEST
2666 User::AfterHighRes(1000);
2668 User::AfterHighRes(TickPeriod);
2672 DBGD_PRINT((_L("%S : all test threads presumably gone now\n"), &TestNameBuffer));
2674 if (TestMediaAccess != KTestMediaAccessNone)
2676 if (TestMediaAccess != KTestMediaAccessBasic)
2678 TBool killMedia = EFalse;
2679 TestStopMedia = ETrue;
2681 DBGS_PRINT((_L("%S : Waiting for media threads to exit...\n"), &TestNameBuffer));
2682 end = User::TickCount();
2687 // check the message queue and call printf if we get a message.
2690 while (KErrNone == TestMsgQueue.Receive(localBuffer))
2692 DBGS_PRINT((localBuffer));
2696 for (index = 0; index < TestMultipleThreadCount; index++)
2698 if (pMedInUse[index])
2700 if (pMedThreads[index].ExitType() != EExitPending)
2702 if (pMedThreads[index].ExitType() == EExitPanic)
2704 DBGS_PRINT((_L("%S : Media Thread %d Panic'd after %u ticks \n"),
2705 &TestNameBuffer, index, User::TickCount() - start));
2710 DBGS_PRINT((_L("%S : Media Thread %d Exited after %u ticks \n"),
2711 &TestNameBuffer, index, User::TickCount() - start));
2714 pMedInUse[index] = EFalse;
2721 DBGS_PRINT((_L("%S : Media Thread %d still going after %u ticks; killing it!\n"),
2722 &TestNameBuffer, index, User::TickCount() - start));
2723 pMedThreads[index].Kill(EExitKill);
2728 now = User::TickCount();
2729 time = TUint((TUint64)(now-end)*(TUint64)TickPeriod/(TUint64)1000000);
2730 if (time > TEST_DOT_PERIOD)
2732 DBGS_PRINT((_L(".")));
2733 end += TEST_DOT_PERIOD*1000000/TickPeriod;
2737 User::AfterHighRes(50000);
2740 DBGS_PRINT((_L("%S : Media threads exited...\n"), &TestNameBuffer));
2741 User::Free(pMedThreads);
2742 User::Free(pMedInUse);
2746 TestStopMedia = ETrue;
2747 DBGS_PRINT((_L("%S : Waiting for media thread to exit...\n"), &TestNameBuffer));
2748 end = User::TickCount();
2749 while (mediaThread.ExitType() == EExitPending)
2751 now = User::TickCount();
2752 time = TUint((TUint64)(now-end)*(TUint64)TickPeriod/(TUint64)1000000);
2753 if (time > TEST_DOT_PERIOD)
2755 DBGS_PRINT((_L("%S : Media thread still going after %u seconds; killing it!\n"),
2756 &TestNameBuffer, time));
2757 mediaThread.Kill(EExitKill);
2759 User::AfterHighRes(50000);
2761 User::WaitForRequest(mediaStatus);
2762 mediaThread.Close();
2763 DBGS_PRINT((_L("%S : Media thread exited...\n"), &TestNameBuffer));
2767 DBGD_PRINT((_L("%S : all media threads presumably gone now\n"), &TestNameBuffer));
2771 TestMsgQueue.Close();
2773 TestMultiSem.Close();
2775 DBGD_PRINT((_L("%S : about to close the libraries\n"), &TestNameBuffer));
2777 if (TestLoadDllHow == TEST_DLL_GLOBAL)
2779 CloseTheLibs(theGlobalLibs, maxDlls);
2782 TestThreadsExit = EFalse;
2784 DBGD_PRINT((_L("%S : cleaning up\n"), &TestNameBuffer));
2786 // cleanup the resources and exit.
2787 if (TestLoading & TEST_EXE_SELF)
2789 User::Free(pTheProcesses);
2790 User::Free(pProcessInUse);
2793 // cleanup the resources and exit.
2794 if (TestLoading & TEST_DLL)
2796 User::Free(pTheThreads);
2797 User::Free(pThreadInUse);
2802 end = User::TickCount();
2803 time = TUint((TUint64)(end-start)*(TUint64)TickPeriod/(TUint64)1000000);
2804 DBGS_PRINT((_L("\n%S : Multiple Test : (%u seconds)\n\tThreads panic'd = %d Ok = %d\n\tProcess panic'd = %d Ok = %d\n"), &TestNameBuffer, time, threadPanic, threadOk, processPanic, processOk));
2807 thisThread.SetPriority(savedThreadPriority);
2809 return (threadPanic | processPanic) ? KErrGeneral : KErrNone;
2815 // Allocate a chunk and assign some pages to it...
2816 // Then do a multiple test.
2821 SVMCacheInfo tempPages;
2822 memset(&tempPages, 0, sizeof(tempPages));
2823 if (TestIsDemandPaged)
2825 // Shrink the page cache down to the minimum.
2826 UserSvr::HalFunction(EHalGroupVM,EVMHalGetCacheSize,&tempPages,0);
2828 DBGS_PRINT((_L("Start : min %d max %d current %d maxFree %d freeRam %d\n"),
2829 tempPages.iMinSize, tempPages.iMaxSize, tempPages.iCurrentSize ,tempPages.iMaxFreeSize, FreeRam()));
2831 // set the cache small
2832 TInt minSize = 16 * TestPageSize;
2833 TInt maxSize = TEST_NUM_PAGES * TestPageSize;
2834 UserSvr::HalFunction(EHalGroupVM,EVMHalSetCacheSize,(TAny*)minSize,(TAny*)maxSize);
2837 if (KErrNone != TestChunk.CreateDisconnectedLocal(0,0,TEST_NUM_CHUNK_PAGES *TestPageSize))
2839 DBGS_PRINT((_L("DoChunkTests - create failed.\n")));
2842 TestChunkBase = TestChunk.Base();
2843 if (TestChunkBase == NULL)
2845 RDebug::Printf("DoChunkTests - TestChunkBase was NULL");
2849 TInt retVal = KErrNone;
2852 memset(TestChunkPageState, 0, sizeof(TestChunkPageState));
2853 memset(TestChunkStats,0,sizeof(TestChunkStats));
2854 while(index < TEST_NUM_CHUNK_PAGES)
2856 retVal = TestChunk.Commit(TestCommitEnd,TestPageSize);
2857 if (KErrNone != retVal)
2859 DBGS_PRINT((_L("%S : TestChunk.Commit returned %d for 0x%08x...\n"), &TestNameBuffer, retVal, TestCommitEnd));
2862 TestChunkPageState[index] = ETrue;
2863 FillPage(TestCommitEnd);
2864 TestCommitEnd += TestPageSize;
2867 RUNTEST1(retVal == KErrNone);
2869 // now do some testing....
2870 TestingChunks = ETrue;
2871 TestInterleave = EFalse;
2872 TestPrioChange = ETrue;
2873 TestMediaAccess = KTestMediaAccessNone;
2875 TestWhichMedia = TEST_MEDIA_ROM_BASE;
2880 TestMultipleThreadCount = 40;
2882 else if (TestExtremeChunks)
2885 TestMultipleThreadCount = 12;
2890 TestMultipleThreadCount = 20;
2892 TestWhichTests = TEST_RANDOM;
2894 TestLoading = TEST_EXE_SELF_DLL;
2895 TestLoadDllHow = TEST_DLL_FUNC;
2896 TestChunkingIndexFails = 0;
2898 TEST_NEXT((_L("Multiple threads random with chunks.")));
2899 RUNTEST(DoMultipleTest(), KErrNone);
2901 TestingChunks = EFalse;
2904 UserSvr::HalFunction(EHalGroupVM,EVMHalFlushCache,0,0);
2907 if (TestIsDemandPaged)
2909 // put the cache back to the the original values.
2910 TInt minSize = tempPages.iMinSize;
2911 TInt maxSize = tempPages.iMaxSize;
2913 UserSvr::HalFunction(EHalGroupVM,EVMHalSetCacheSize,(TAny*)minSize,(TAny*)maxSize);
2915 UserSvr::HalFunction(EHalGroupVM,EVMHalGetCacheSize,&tempPages,0);
2917 DBGS_PRINT((_L("Finish : min %d max %d current %d maxFree %d freeRam %d\n"),
2918 tempPages.iMinSize, tempPages.iMaxSize, tempPages.iCurrentSize ,tempPages.iMaxFreeSize, FreeRam()));
2920 TChunkTestStats stats;
2922 memset(&stats, 0, sizeof(stats));
2923 DBGS_PRINT((_L("Stats : (pass/fail) \nindex\t\tlock\t\tunlock\t\tcommit\t\tdecommit\t\tcheck\n")));
2924 for (index = 0; index < TEST_NUM_CHUNK_PAGES; index ++)
2926 DBGS_PRINT((_L("%u\t\t%d/%d\t\t%d/%d\t\t%d/%d\t\t%d/%d\t\t%d/%d\n"),
2928 TestChunkStats[index].lock.ok, TestChunkStats[index].lock.fail,
2929 TestChunkStats[index].unlock.ok, TestChunkStats[index].unlock.fail,
2930 TestChunkStats[index].commit.ok, TestChunkStats[index].commit.fail,
2931 TestChunkStats[index].decommit.ok, TestChunkStats[index].decommit.fail,
2932 TestChunkStats[index].check.ok, TestChunkStats[index].check.fail));
2934 stats.lock.ok += TestChunkStats[index].lock.ok;
2935 stats.lock.fail += TestChunkStats[index].lock.fail;
2936 stats.unlock.ok += TestChunkStats[index].unlock.ok;
2937 stats.unlock.fail += TestChunkStats[index].unlock.fail;
2938 stats.decommit.ok += TestChunkStats[index].decommit.ok;
2939 stats.decommit.fail += TestChunkStats[index].decommit.fail;
2940 stats.commit.ok += TestChunkStats[index].commit.ok;
2941 stats.commit.fail += TestChunkStats[index].commit.fail;
2942 stats.check.ok += TestChunkStats[index].check.ok;
2943 stats.check.fail += TestChunkStats[index].check.fail;
2946 DBGS_PRINT((_L("Total Stats (p/f): \n\t lock %d / %d\n\t unlock %d / %d\n\t commit %d / %d\n\t decommit %d / %d\n\t check %d / %d\n"),
2947 stats.lock.ok, stats.lock.fail,
2948 stats.unlock.ok, stats.unlock.fail,
2949 stats.commit.ok, stats.commit.fail,
2950 stats.decommit.ok, stats.decommit.fail,
2951 stats.check.ok, stats.check.fail));
2952 DBGS_PRINT((_L("TestChunkingIndexFails %d\n"), TestChunkingIndexFails));
2959 // Test the reaper by deleting the transient files and re-creating them.
2962 void DoReaperTests(void)
2964 // make sure we have the full complement of files.
2965 CheckFilePresence(ETrue);
2967 // now do some testing....
2968 TestInterleave = EFalse;
2969 TestPrioChange = EFalse;
2970 TestMediaAccess = KTestMediaAccessNone;
2972 TestWhichMedia = TEST_MEDIA_ALL;
2974 TestMultipleThreadCount = 12;
2975 TestWhichTests = TEST_RANDOM;
2977 TestLoading = TEST_EXE_SELF_DLL;
2978 TestLoadDllHow = TEST_DLL_FUNC;
2980 TestingReaper = ETrue;
2982 TEST_NEXT((_L("Reaper tests.")));
2983 RUNTEST(DoMultipleTest(), KErrNone);
2984 TestInterleave = ETrue;
2985 TestPrioChange = ETrue;
2986 TEST_NEXT((_L("Reaper tests 2.")));
2987 RUNTEST(DoMultipleTest(), KErrNone);
2989 TestingReaper = EFalse;
2995 // Test the paging BTrace function.
2998 void DoBtraceTest(void)
3000 #define LE4(a) ((*((a) + 3) << 24) + (*((a) + 2) << 16) + (*((a) + 1) << 8) + *(a))
3002 RBTrace bTraceHandle;
3004 TInt r = bTraceHandle.Open();
3005 test(r == KErrNone);
3007 r = bTraceHandle.ResizeBuffer(0x200000);
3008 test(r == KErrNone);
3009 bTraceHandle.SetFilter(BTrace::EPaging, ETrue);
3012 bTraceHandle.Empty();
3013 bTraceHandle.SetMode(RBTrace::EEnable);
3015 TestLoading = TEST_EXE_SELF_DLL;
3016 TestWhichMedia = TEST_MEDIA_ROM_BASE;
3018 TestMultipleThreadCount = 10;
3019 TestLoadDllHow = TEST_DLL_FUNC;
3020 TestInterleave = ETrue;
3021 TestPrioChange = ETrue;
3022 TestMediaAccess = KTestMediaAccessNone;
3023 TestWhichTests = TEST_RANDOM;
3024 TestingLowMem = EFalse;
3026 RUNTEST(DoMultipleTest(TestingLowMem), KErrNone);
3028 bTraceHandle.SetMode(0);
3030 // analyse the btrace logs and display on the serial port.
3039 dataSize = bTraceHandle.GetData(pDataStart);
3044 pEnd = pDataStart + dataSize;
3046 while (pTemp < pEnd)
3048 TUint8 recSize = pTemp[BTrace::ESizeIndex];
3049 TUint8 recFlags = pTemp[BTrace::EFlagsIndex];
3050 TUint8 recCat = pTemp[BTrace::ECategoryIndex];
3051 TUint8 recSub = pTemp[BTrace::ESubCategoryIndex];
3056 // step over the header.
3057 data.Format(_L("size %d cat %d sub %d flg 0x%02x "), recSize, recCat, recSub, recFlags);
3060 if (recFlags & BTrace::EHeader2Present)
3062 data.AppendFormat(_L("h2 0x%08x "), LE4(pTemp));
3065 if (recFlags & BTrace::ETimestampPresent)
3067 data.AppendFormat(_L("ts 0x%08x "), LE4(pTemp));
3070 if (recFlags & BTrace::ETimestamp2Present)
3072 data.AppendFormat(_L("ts2 0x%08x "), LE4(pTemp));
3075 if (recFlags & BTrace::EContextIdPresent)
3077 data.AppendFormat(_L("cId 0x%08x "), LE4(pTemp));
3081 for (index = 0; index < 4; index ++)
3083 if (recSize > pTemp - pThis)
3085 addr[index] = LE4(pTemp);
3094 case BTrace::EPaging:
3098 case BTrace::EPagingPageInBegin:
3100 - 4 bytes containing the virtual address which was accessed, causing this paging event.
3101 - 4 bytes containing the virtual address of the instuction which caused this paging event.
3104 test.Printf(_L("PageInBegin : %S addr 0x%08x inst 0x%08x\n"), &data, addr[0], addr[1]);
3108 - 0 bytes. (No extra data.)
3110 case BTrace::EPagingPageInUnneeded:
3111 test.Printf(_L("PageInUnneeded : %S\n"), &data);
3115 - 4 bytes containing the physical address of the page 'paged in'.
3116 - 4 bytes containing the virtual address of the page 'paged in'.
3118 case BTrace::EPagingPageInROM:
3119 test.Printf(_L("PageInROM : %S phys 0x%08x virt 0x%08x\n"), &data, addr[0], addr[1]);
3123 - 4 bytes containing the physical address of the page being 'paged out'.
3124 - 4 bytes containing the virtual address of the page being 'paged out'.
3126 case BTrace::EPagingPageOutROM:
3127 test.Printf(_L("PageOutROM : %S phys 0x%08x virt 0x%08x\n"), &data, addr[0], addr[1]);
3131 - 4 bytes containing the physical address of the page being 'paged in'.
3133 case BTrace::EPagingPageInFree:
3134 test.Printf(_L("PageInFree : %S phys 0x%08x\n"), &data, addr[0]);
3138 - 4 bytes containing the physical address of the page being 'paged out'.
3140 case BTrace::EPagingPageOutFree:
3141 test.Printf(_L("PageOutFree : %S phys 0x%08x\n"), &data, addr[0]);
3145 - 4 bytes containing the physical address of the page being rejuvenated, (made young).
3146 - 4 bytes containing the virtual address which was accessed, causing this paging event.
3147 - 4 bytes containing the virtual address of the instuction which caused this paging event.
3150 case BTrace::EPagingRejuvenate:
3151 test.Printf(_L("Rejuvenate : %S phys 0x%08x virt 0x%08x inst 0x%08x\n"), &data, addr[0], addr[1], addr[2]);
3155 - 4 bytes containing the physical address of the page accessed.
3156 - 4 bytes containing the virtual address which was accessed, causing this paging event.
3157 - 4 bytes containing the virtual address of the instuction which caused this paging event.
3160 case BTrace::EPagingPageNop:
3161 test.Printf(_L("PageNop : %S phys 0x%08x virt 0x%08x inst 0x%08x\n"), &data, addr[0], addr[1], addr[2]);
3165 - 4 bytes containing the physical address of the page being locked.
3166 - 4 bytes containing the value of the lock count after the paged was locked.
3168 case BTrace::EPagingPageLock:
3169 test.Printf(_L("PageLock : %S phys 0x%08x lock 0x%08x\n"), &data, addr[0], addr[1]);
3173 - 4 bytes containing the physical address of the page being unlocked.
3174 - 4 bytes containing the value of the lock count before the paged was unlocked.
3176 case BTrace::EPagingPageUnlock:
3177 test.Printf(_L("PageUnlock : %S phys 0x%08x lock 0x%08x\n"), &data, addr[0], addr[1]);
3181 - 4 bytes containing the physical address of the page being 'paged out'.
3182 - 4 bytes containing the virtual address of the page being 'paged out'.
3184 case BTrace::EPagingPageOutCache:
3185 test.Printf(_L("PageOutCache : %S phys 0x%08x virt 0x%08x\n"), &data, addr[0], addr[1]);
3189 - 4 bytes containing the physical address of the page 'paged in'.
3190 - 4 bytes containing the virtual address of the page 'paged in'.
3192 case BTrace::EPagingPageInCode:
3193 test.Printf(_L("PageInCode : %S phys 0x%08x virt 0x%08x\n"), &data, addr[0], addr[1]);
3197 - 4 bytes containing the physical address of the page being 'paged out'.
3198 - 4 bytes containing the virtual address of the page being 'paged out'.
3200 case BTrace::EPagingPageOutCode:
3201 test.Printf(_L("PageOutCode : %S phys 0x%08x virt 0x%08x\n"), &data, addr[0], addr[1]);
3205 - 4 bytes containing the physical address of the page 'paged in'.
3206 - 4 bytes containing the virtual address of the page 'paged in'.
3208 case BTrace::EPagingMapCode:
3209 test.Printf(_L("MapCode : %S phys 0x%08x virt 0x%08x\n"), &data, addr[0], addr[1]);
3213 - 4 bytes containing the physical address of the page being aged, (made old).
3215 case BTrace::EPagingAged:
3216 test.Printf(_L("Aged : %S phys 0x%08x\n"), &data, addr[0]);
3226 pTemp = BTrace::NextRecord(pThis);
3228 bTraceHandle.DataUsed();
3230 bTraceHandle.Close();
3236 // read the arguments passed from the command line and set global variables to
3237 // control the tests.
3240 TBool ParseCommandLine()
3243 User::CommandLine(args);
3245 TBool retVal = ETrue;
3247 // initially test for arguments, the parse them, if not apply some sensible defaults.
3248 TBool foundArgs = EFalse;
3252 TPtrC token=lex.NextToken();
3253 if(token.Length()!=0)
3255 if ((token == _L("help")) || (token == _L("-h")) || (token == _L("-?")))
3257 DBGS_PRINT((_L("\nUsage: [ single | multiple <numThreads>] [ dll | exe | self | complete ] [func | thread | global ] [ rom | base | mixed | mall ] [reaper] [chunks|echunks|chunks+ {nochunkdata}] [prio] [media] [lowmem] [forward | backward | random | all] [loadGlobal | loadThread | loadFunc] [interleave] [d_exc] [btrace] [defrag] [noclean] [min <pages>] [max <pages>] [stressfree] [iters <iters>]\n'-' indicated infinity.\n\n")));
3260 else if (token == _L("mmc"))
3262 TestOnlyFromMmc = ETrue;
3264 else if (token == _L("min"))
3266 TPtrC val=lex.NextToken();
3270 TestMinCacheSize = value * 4096;
3272 else if (token == _L("max"))
3274 TPtrC val=lex.NextToken();
3278 TestMaxCacheSize = value * 4096;
3280 else if (token == _L("interleave"))
3282 TestInterleave = ETrue;
3284 else if (token == _L("auto"))
3286 TestFullAutoTest = EFalse;
3289 else if (token == _L("stressfree"))
3291 TestStressFree = !TestStressFree;
3294 else if (token == _L("fullauto"))
3296 TestFullAutoTest = ETrue;
3299 else if (token == _L("prio"))
3301 TestPrioChange = !TestPrioChange;
3303 else if (token == _L("media"))
3305 TestMediaAccess = KTestMediaAccessBasic;
3307 else if (token == _L("reaper"))
3311 else if (token == _L("btrace"))
3315 else if (token == _L("defrag"))
3319 else if (token == _L("echunks"))
3322 TestExtremeChunks = ETrue;
3324 else if (token == _L("chunks+"))
3327 TestChunksPlus = ETrue;
3329 else if (token == _L("chunks"))
3333 else if (token == _L("nochunkdata"))
3335 TestChunkData = EFalse;
3337 else if (token == _L("lowmem"))
3341 else if (token == _L("dll"))
3343 TestLoading = TEST_DLL;
3345 else if (token == _L("exe"))
3347 TestLoading = TEST_EXE;
3349 else if (token == _L("self"))
3351 TestLoading = TEST_SELF;
3353 else if (token == _L("complete"))
3355 TestLoading |= TEST_EXE_SELF_DLL;
3357 else if (token == _L("rom"))
3359 TestWhichMedia = TEST_MEDIA_ROM;
3361 else if (token == _L("base"))
3363 TestWhichMedia = TEST_MEDIA_BASE;
3365 else if (token == _L("mixed"))
3367 TestWhichMedia |= TEST_MEDIA_ROM_BASE;
3369 else if (token == _L("all_media"))
3371 TestWhichMedia |= TEST_MEDIA_ALL;
3373 else if (token == _L("debug"))
3378 TestPrioChange = ETrue;
3381 else if (token == _L("silent"))
3386 else if (token == _L("noclean"))
3388 TestNoClean = ETrue;
3390 else if (token == _L("d_exc"))
3394 else if (token == _L("global"))
3396 TestLoadDllHow = TEST_DLL_GLOBAL;
3398 else if (token == _L("thread"))
3400 TestLoadDllHow = TEST_DLL_THREAD;
3402 else if (token == _L("func"))
3404 TestLoadDllHow = TEST_DLL_FUNC;
3406 else if (token == _L("single"))
3410 else if (token == _L("multiple"))
3412 TPtrC val=lex.NextToken();
3416 if (lexv.Val(value)==KErrNone)
3418 if ((value <= 0) || (value > 100))
3420 TestMultipleThreadCount = 10;
3424 TestMultipleThreadCount = value;
3429 DBGS_PRINT((_L("Bad value for thread count '%S' was ignored.\n"), &val));
3433 TestMultiple = ETrue;
3435 else if (token == _L("forward"))
3437 TestWhichTests = TEST_FORWARD;
3439 else if (token == _L("backward"))
3441 TestWhichTests = TEST_BACKWARD;
3443 else if (token == _L("random"))
3445 TestWhichTests = TEST_RANDOM;
3447 else if (token == _L("all"))
3449 TestWhichTests = TEST_ALL;
3451 else if (token == _L("inst"))
3453 TPtrC val=lex.NextToken();
3457 if (lexv.Val(value)==KErrNone)
3459 TestInstanceId = value;
3462 else if (token == _L("iters"))
3464 TPtrC val=lex.NextToken();
3470 TestMaxLoops = KMaxTInt;
3474 if (lexv.Val(value)==KErrNone)
3476 TestMaxLoops = value;
3480 DBGS_PRINT((_L("Bad value for thread count '%S' was ignored.\n"), &val));
3488 if ((foundArgs == EFalse) && (token.Length() == 1))
3490 // Single letter argument...only run on 'd'
3491 if (token.CompareF(_L("d")) == 0)
3494 TestFullAutoTest = EFalse;
3495 TestIsAutomated = ETrue;
3503 test.Start(_L("Skipping non drive 'd' - Test Exiting."));
3511 DBGS_PRINT((_L("Unknown argument '%S' was ignored.\n"), &token));
3531 // Test whether we are the root of the tests.
3533 void AreWeTheTestBase()
3537 TFileName filename(RProcess().FileName());
3540 myParse.Set(filename, NULL, NULL);
3541 TestNameBuffer.Zero();
3542 TestNameBuffer.Append(myParse.Name());
3543 TestNameBuffer.Append(_L(".exe"));
3545 TestWeAreTheTestBase = !TestNameBuffer.Compare(TestPlExeNames[KTestMediaBase]);
3548 if (KErrNone == fs.Connect())
3551 TInt retVal = fs.Entry(_L("z:\\test\\mmcdemandpaginge32tests.bat"), anEntry);
3552 if (retVal == KErrNone)
3554 TestBootedFromMmc = ETrue;
3558 TestBootedFromMmc = EFalse;
3565 TestNameBuffer.Zero();
3566 TestNameBuffer.Append(_L("t_pageldrtst.exe"));
3569 #define MEDNONE KTestMediaAccessNone
3570 #define MEDBASIC KTestMediaAccessBasic
3571 #define MEDMTHRE KTestMediaAccessMultipleThreads
3572 #define MEDMPATT KTestMediaAccessMultiplePattern
3573 #define MEDMIX KTestMediaAccessMixed
3575 TTheTests TheAutoTests[] =
3576 {// fullOnly, loading, media, multi, loops, threads, loadHow, inter, prio, media, whichTests, lowmem, free, testName
3577 #ifdef TEST_SHORT_TEST
3578 { EFalse, TEST_DLL, TEST_MEDIA_ALL, ETrue, 2, 24, TEST_DLL_FUNC, EFalse, EFalse, MEDNONE, TEST_RANDOM, EFalse, 0, }, //_L("DLL Load (ALL Media) Multiple thread all."), },
3580 { EFalse, TEST_DLL, TEST_MEDIA_BASE, ETrue, 5, 24, TEST_DLL_FUNC, EFalse, EFalse, MEDNONE, TEST_THRASH, EFalse, 0, }, //_L("DLL Load (ROM) Multiple thread Thrash."), },
3581 { ETrue, TEST_DLL, TEST_MEDIA_ROM_BASE, EFalse, 5, 20, TEST_DLL_FUNC, EFalse, EFalse, MEDNONE, TEST_ALL, EFalse, 0, }, //_L("DLL Load (ROM/ROFS) Single thread all."), },
3582 { ETrue, TEST_EXE, TEST_MEDIA_ROM_BASE, EFalse, 5, 20, TEST_DLL_FUNC, EFalse, EFalse, MEDNONE, TEST_ALL, EFalse, 0, }, //_L("Exe Load (ROM/ROFS) Single thread."), },
3583 { ETrue, TEST_SELF, TEST_MEDIA_ROM_BASE, EFalse, 5, 20, TEST_DLL_FUNC, EFalse, EFalse, MEDNONE, TEST_ALL, EFalse, 0, }, //_L("Self Load (ROM/ROFS) Single thread."), },
3584 { ETrue, TEST_DLL, TEST_MEDIA_ROM_BASE, ETrue, 5, 20, TEST_DLL_FUNC, EFalse, EFalse, MEDNONE, TEST_RANDOM, EFalse, 0, }, //_L("DLL Load (ROM/ROFS) Multiple thread all."), },
3585 { EFalse, TEST_DLL, TEST_MEDIA_ALL, ETrue, 3, 20, TEST_DLL_FUNC, EFalse, EFalse, MEDNONE, TEST_RANDOM, EFalse, 0, }, //_L("DLL Load (ALL Media) Multiple thread all."), },
3586 { ETrue, TEST_EXE_SELF_DLL, TEST_MEDIA_ALL, ETrue, 2, 16, TEST_DLL_FUNC, EFalse, EFalse, MEDNONE, TEST_RANDOM, EFalse, 0, }, //_L("DLL/EXE/SELF Load (All Media) Multiple threads."), },
3587 { EFalse, TEST_EXE_SELF_DLL, TEST_MEDIA_ALL, ETrue, 2, 16, TEST_DLL_FUNC, EFalse, ETrue, MEDNONE, TEST_RANDOM, EFalse, 0, }, //_L("DLL/EXE/SELF Load (All Media) Multiple threads with prio."), },
3588 { EFalse, TEST_EXE_SELF_DLL, TEST_MEDIA_ALL, ETrue, 2, 10, TEST_DLL_FUNC, EFalse, EFalse, MEDBASIC, TEST_RANDOM, EFalse, 0, }, //_L("DLL/EXE/SELF Load (All Media) Multiple threads with media access."), },
3589 { EFalse, TEST_EXE_SELF_DLL, TEST_MEDIA_ALL, ETrue, 2, 12, TEST_DLL_FUNC, EFalse, ETrue, MEDBASIC, TEST_RANDOM, EFalse, 0, }, //_L("DLL/EXE/SELF Load (All Media) Multiple threads with media access and prio."), },
3590 { ETrue, TEST_EXE_SELF_DLL, TEST_MEDIA_ALL, ETrue, 2, 16, TEST_DLL_THREAD, EFalse, EFalse, MEDNONE, TEST_RANDOM, EFalse, 0, }, //_L("DLL/EXE/SELF Load thread (All Media) Multiple threads."), },
3591 { EFalse, TEST_EXE_SELF_DLL, TEST_MEDIA_ALL, ETrue, 2, 16, TEST_DLL_THREAD, EFalse, ETrue, MEDNONE, TEST_RANDOM, EFalse, 0, }, //_L("DLL/EXE/SELF Load thread (All Media) Multiple threads with prio."), },
3592 { ETrue, TEST_EXE_SELF_DLL, TEST_MEDIA_ALL, ETrue, 2, 12, TEST_DLL_THREAD, EFalse, ETrue, MEDBASIC, TEST_RANDOM, EFalse, 0, }, //_L("DLL/EXE/SELF Load thread (All Media) Multiple threads with media access and prio."), },
3593 { ETrue, TEST_EXE_SELF_DLL, TEST_MEDIA_ALL, ETrue, 2, 16, TEST_DLL_GLOBAL, EFalse, EFalse, MEDNONE, TEST_RANDOM, EFalse, 0, }, //_L("DLL/EXE/SELF Load global (All Media) Multiple threads."), },
3594 { EFalse, TEST_EXE_SELF_DLL, TEST_MEDIA_ALL, ETrue, 2, 16, TEST_DLL_GLOBAL, EFalse, ETrue, MEDNONE, TEST_RANDOM, EFalse, 0, }, //_L("DLL/EXE/SELF Load global (All Media) Multiple threads with prio."), },
3595 { ETrue, TEST_EXE_SELF_DLL, TEST_MEDIA_ALL, ETrue, 2, 12, TEST_DLL_GLOBAL, EFalse, ETrue, MEDBASIC, TEST_RANDOM, EFalse, 0, }, //_L("DLL/EXE/SELF Load global (All Media) Multiple threads with media access and prio."), },
3596 { EFalse, TEST_EXE_SELF_DLL, TEST_MEDIA_ALL, ETrue, 2, 16, TEST_DLL_FUNC, ETrue, EFalse, MEDNONE, TEST_RANDOM, EFalse, 0, }, //_L("DLL/EXE/SELF Load (All Media) Multiple threads with interleave."), },
3597 { ETrue, TEST_EXE_SELF_DLL, TEST_MEDIA_ALL, ETrue, 2, 16, TEST_DLL_FUNC, ETrue, ETrue, MEDNONE, TEST_RANDOM, EFalse, 0, }, //_L("DLL/EXE/SELF Load (All Media) Multiple threads with interleave, prio."), },
3599 { ETrue, TEST_EXE_SELF_DLL, TEST_MEDIA_ALL, ETrue, 2, 16, TEST_DLL_FUNC, ETrue, ETrue, MEDBASIC, TEST_RANDOM, EFalse, 0, }, //_L("DLL/EXE/SELF Load (All Media) Multiple threads with interleave, media and prio."), },
3600 { ETrue, TEST_EXE_SELF_DLL, TEST_MEDIA_ALL, ETrue, 2, 12, TEST_DLL_FUNC, ETrue, ETrue, MEDMTHRE, TEST_RANDOM, EFalse, 0, }, //_L("DLL/EXE/SELF Load (All Media) Multiple threads with interleave, multi media and prio."), },
3601 { ETrue, TEST_EXE_SELF_DLL, TEST_MEDIA_ALL, ETrue, 2, 12, TEST_DLL_FUNC, ETrue, ETrue, MEDMPATT, TEST_RANDOM, EFalse, 0, }, //_L("DLL/EXE/SELF Load (All Media) Multiple threads with interleave, media and prio."), },
3602 { ETrue, TEST_EXE_SELF_DLL, TEST_MEDIA_ALL, ETrue, 2, 12, TEST_DLL_FUNC, ETrue, ETrue, MEDMIX, TEST_RANDOM, EFalse, 0, }, //_L("DLL/EXE/SELF Load (All Media) Multiple threads with interleave, media and prio."), },
3603 { EFalse, TEST_EXE_SELF_DLL, TEST_MEDIA_ROM_BASE, ETrue, 2, 10, TEST_DLL_FUNC, ETrue, ETrue, MEDMIX, TEST_RANDOM, EFalse, 0, }, //_L("DLL/EXE/SELF Load Multiple threads with interleave, media and prio."), },
3604 #endif // TEST_SHORT_TEST
3606 #define NUM_AUTO_TESTS (TInt)(sizeof(TheAutoTests) / sizeof(TTheTests))
3614 void PerformAutoTest(TBool aReduceTime = EFalse)
3617 TTheTests *pTest = &TheAutoTests[0];
3621 for (testIndex = 0; testIndex < NUM_AUTO_TESTS; testIndex ++, pTest++)
3623 if ( ( !TestWeAreTheTestBase
3624 && ( (pTest->testLoadDllHow != TEST_DLL_FUNC)
3625 || !pTest->testMultiple))
3626 || ((TestFullAutoTest == EFalse) && (pTest->testFullAutoOnly)))
3631 TestLoading = pTest->testLoading;
3632 TestWhichMedia = pTest->testWhichMedia;
3633 TestMaxLoops = aReduceTime ? 1 : pTest->testMaxLoops;
3634 TestMultipleThreadCount = aReduceTime ? 10 : pTest->testMultipleThreadCount;
3635 TestLoadDllHow = pTest->testLoadDllHow;
3636 TestInterleave = pTest->testInterleave;
3637 TestPrioChange = pTest->testPrioChange;
3638 TestMediaAccess = pTest->testMediaAccess;
3639 if (aReduceTime && (TestMediaAccess != MEDBASIC) && (TestMediaAccess != MEDNONE))
3643 TestWhichTests = pTest->testWhichTests;
3644 TestingLowMem = pTest->testLowMem;
3647 test.Next(_L("Auto Test"));
3649 if (pTest->testMultiple)
3651 RUNTEST(DoMultipleTest(ETrue), KErrNone);
3655 RUNTEST(DoSingleTest(ETrue), KErrNone);
3660 #ifdef TEST_KERN_HEAP
3666 #ifdef TEST_KERN_HEAP
3673 TTheTests TheLowMemTests[] =
3674 {// fullOnly, loading, media, multi, loops, threads, loadHow, inter, prio, media, whichTests, lowmem, free, testName
3675 #ifndef TEST_SHORT_TEST
3676 { ETrue, TEST_EXE_SELF_DLL, TEST_MEDIA_ROM_BASE, EFalse, 1, 1, TEST_DLL_FUNC, EFalse, EFalse, MEDNONE, TEST_RANDOM, EFalse, 0, }, //_L("Single thread with Low memory (init)."), },
3677 { ETrue, TEST_EXE_SELF_DLL, TEST_MEDIA_ROM_BASE, EFalse, 5, 1, TEST_DLL_FUNC, EFalse, EFalse, MEDNONE, TEST_RANDOM, ETrue, 0, }, //_L("Single thread with Low memory."), },
3678 { ETrue, TEST_DLL, TEST_MEDIA_ROM_BASE, EFalse, 1, 1, TEST_DLL_FUNC, EFalse, EFalse, MEDNONE, TEST_RANDOM, EFalse, 0, }, //_L("Multiple thread with Low memory (init)."), },
3679 { ETrue, TEST_EXE_SELF_DLL, TEST_MEDIA_ROM_BASE, ETrue, 2, 16, TEST_DLL_FUNC, EFalse, EFalse, MEDNONE, TEST_RANDOM, ETrue, 0, }, //_L("Multiple thread with Low memory ."), },
3680 { EFalse, TEST_DLL, TEST_MEDIA_ALL, EFalse, 5, 1, TEST_DLL_FUNC, EFalse, EFalse, MEDNONE, TEST_RANDOM, EFalse, 0, }, //_L("Multiple thread with Low memory and All media(init)."), },
3681 { EFalse, TEST_EXE_SELF_DLL, TEST_MEDIA_ALL, ETrue, 2, 12, TEST_DLL_FUNC, EFalse, EFalse, MEDNONE, TEST_RANDOM, ETrue, 0, }, //_L("Multiple thread with Low memory and All media."), },
3682 { ETrue, TEST_DLL, TEST_MEDIA_ROM_BASE, EFalse, 1, 1, TEST_DLL_FUNC, EFalse, EFalse, MEDNONE, TEST_RANDOM, EFalse, 0, }, //_L("Multiple thread with Low memory, with starting free ram (init)."), },
3683 { ETrue, TEST_EXE_SELF_DLL, TEST_MEDIA_ROM_BASE, ETrue, 2, 16, TEST_DLL_FUNC, EFalse, EFalse, MEDNONE, TEST_RANDOM, ETrue, 32, }, //_L("Multiple thread with Low memory, with starting free ram."), },
3684 { ETrue, TEST_DLL, TEST_MEDIA_ROM_BASE, EFalse, 1, 16, TEST_DLL_FUNC, EFalse, EFalse, MEDNONE, TEST_RANDOM, EFalse, 0, }, //_L("Multiple thread with Low memory and prio and media access(init)."), },
3685 { ETrue, TEST_EXE_SELF_DLL, TEST_MEDIA_ROM_BASE, ETrue, 2, 16, TEST_DLL_FUNC, EFalse, ETrue, MEDBASIC, TEST_RANDOM, ETrue, 0, }, //_L("Multiple thread with Low memory and prio and media access."), },
3686 { ETrue, TEST_DLL, TEST_MEDIA_ROM_BASE, EFalse, 1, 1, TEST_DLL_FUNC, EFalse, EFalse, MEDNONE, TEST_RANDOM, EFalse, 0, }, //_L("Multiple thread with Low memory interleave, prio and media access(init)."), },
3687 { ETrue, TEST_EXE_SELF_DLL, TEST_MEDIA_ROM_BASE, ETrue, 2, 16, TEST_DLL_FUNC, ETrue, ETrue, MEDBASIC, TEST_RANDOM, ETrue, 0, }, //_L("Multiple thread with Low memory interleave, prio and media access."), },
3688 { ETrue, TEST_DLL, TEST_MEDIA_ROM_BASE, EFalse, 1, 1, TEST_DLL_FUNC, EFalse, EFalse, MEDNONE, TEST_RANDOM, EFalse, 0, }, //_L("Multiple thread with Low memory interleave, media access and All media (init)."), },
3689 { ETrue, TEST_EXE_SELF_DLL, TEST_MEDIA_ALL, ETrue, 2, 16, TEST_DLL_FUNC, ETrue, EFalse, MEDBASIC, TEST_RANDOM, ETrue, 0, }, //_L("Multiple thread with Low memory interleave, media access and All media + loading."), },
3690 { EFalse, TEST_DLL, TEST_MEDIA_ROM_BASE, EFalse, 10, 1, TEST_DLL_FUNC, EFalse, EFalse, MEDNONE, TEST_RANDOM, EFalse, 0, }, //_L("Single thread with Low memory (init)."), },
3691 { EFalse, TEST_DLL, TEST_MEDIA_ROM_BASE, EFalse, 5, 1, TEST_DLL_FUNC, EFalse, EFalse, MEDNONE, TEST_RANDOM, ETrue, 0, }, //_L("Single thread with Low memory."), },
3692 #endif //TEST_SHORT_TEST
3693 { EFalse, TEST_DLL, TEST_MEDIA_ROM_BASE, EFalse, 10, 1, TEST_DLL_FUNC, EFalse, EFalse, MEDNONE, TEST_RANDOM, EFalse, 0, }, //_L("Multiple thread with Low memory interleave, prio, media access and All media (init)."), },
3694 { EFalse, TEST_EXE_SELF_DLL, TEST_MEDIA_ROM_BASE, ETrue, 2, 16, TEST_DLL_FUNC, ETrue, ETrue, MEDBASIC, TEST_RANDOM, ETrue, 0, }, //_L("Multiple thread with Low memory interleave, prio, media access and All media + loading."), },
3695 { EFalse, TEST_DLL, TEST_MEDIA_ROM_BASE, EFalse, 5, 1, TEST_DLL_FUNC, EFalse, EFalse, MEDNONE, TEST_RANDOM, EFalse, 0, }, //_L("Multiple thread with Low memory interleave, prio, media access and All media (init)."), },
3696 { EFalse, TEST_EXE_SELF_DLL, TEST_MEDIA_ROM_BASE, ETrue, 2, 10, TEST_DLL_FUNC, ETrue, ETrue, MEDMTHRE, TEST_RANDOM, ETrue, 0, }, //_L("Multiple thread with Low memory interleave, prio, multi media access and All media + loading."), },
3697 { ETrue, TEST_DLL, TEST_MEDIA_ROM_BASE, EFalse, 1, 1, TEST_DLL_FUNC, EFalse, EFalse, MEDNONE, TEST_RANDOM, EFalse, 0, }, //_L("Multiple thread with Low memory interleave, prio, media access and All media (init)."), },
3698 { ETrue, TEST_EXE_SELF_DLL, TEST_MEDIA_ALL, ETrue, 2, 16, TEST_DLL_FUNC, ETrue, ETrue, MEDBASIC, TEST_RANDOM, ETrue, 0, }, //_L("Multiple thread with Low memory interleave, prio, media access and All media + loading."), },
3699 { ETrue, TEST_DLL, TEST_MEDIA_ROM_BASE, EFalse, 1, 1, TEST_DLL_FUNC, EFalse, EFalse, MEDNONE, TEST_RANDOM, EFalse, 0, }, //_L("Multiple thread with Low memory interleave, prio, media access and All media (init)."), },
3700 { ETrue, TEST_EXE_SELF_DLL, TEST_MEDIA_ALL, ETrue, 2, 16, TEST_DLL_FUNC, ETrue, ETrue, MEDMTHRE, TEST_RANDOM, ETrue, 0, }, //_L("Multiple thread with Low memory interleave, prio, multi media access and All media + loading."), },
3703 #define NUM_LOWMEM_TESTS (TInt)(sizeof(TheLowMemTests) / sizeof(TTheTests))
3710 void DoLowMemTest(TBool aEnableAllMedia = EFalse)
3712 TInt r = User::LoadLogicalDevice(KPageStressTestLddName);
3713 RUNTEST1(r==KErrNone || r==KErrAlreadyExists);
3714 RUNTEST(PagestressLdd.Open(),KErrNone);
3715 RUNTEST(PagestressLdd.DoSetDebugFlag((TInt)TestDebug),KErrNone);
3717 SVMCacheInfo tempPages;
3718 memset(&tempPages, 0, sizeof(tempPages));
3719 if (TestIsDemandPaged)
3721 // get the old cache info
3722 UserSvr::HalFunction(EHalGroupVM,EVMHalGetCacheSize,&tempPages,0);
3723 TInt minSize = 8 * 4096;
3724 TInt maxSize = 256 * 4096;
3725 UserSvr::HalFunction(EHalGroupVM,EVMHalSetCacheSize,(TAny*)minSize,(TAny*)maxSize);
3729 TTheTests *pTest = &TheLowMemTests[0];
3730 for (testIndex = 0; testIndex < NUM_LOWMEM_TESTS; testIndex ++, pTest++)
3732 if ( (!aEnableAllMedia && (pTest->testWhichMedia == TEST_MEDIA_ALL))
3733 || ((TestFullAutoTest == EFalse) && (pTest->testFullAutoOnly)))
3738 TestLoading = pTest->testLoading;
3739 TestWhichMedia = pTest->testWhichMedia;
3740 TestMaxLoops = pTest->testMaxLoops;
3741 TestMultipleThreadCount = pTest->testMultipleThreadCount;
3742 TestLoadDllHow = pTest->testLoadDllHow;
3743 TestInterleave = pTest->testInterleave;
3744 TestPrioChange = pTest->testPrioChange;
3745 TestMediaAccess = pTest->testMediaAccess;
3746 TestWhichTests = pTest->testWhichTests;
3747 TestingLowMem = pTest->testLowMem;
3750 test.Next(_L("Low Memory"));
3752 if (pTest->testLowMem)
3754 PagestressLdd.DoConsumeRamSetup(pTest->testFreeRam, TEST_LM_BLOCKSIZE);
3757 if (pTest->testMultiple)
3759 RUNTEST(DoMultipleTest(pTest->testLowMem), KErrNone);
3763 RUNTEST(DoSingleTest(pTest->testLowMem), KErrNone);
3766 if (pTest->testLowMem)
3768 PagestressLdd.DoConsumeRamFinish();
3772 #ifdef TEST_KERN_HEAP
3781 test.Next(_L("Close test driver"));
3783 PagestressLdd.Close();
3784 RUNTEST(User::FreeLogicalDevice(KPageStressTestLddName), KErrNone);
3786 if (TestIsDemandPaged)
3788 TInt minSize = tempPages.iMinSize;
3789 TInt maxSize = tempPages.iMaxSize;
3790 UserSvr::HalFunction(EHalGroupVM,EVMHalSetCacheSize,(TAny*)minSize,(TAny*)maxSize);
3793 #ifdef TEST_KERN_HEAP
3798 TestingLowMem = EFalse;
3803 // MultipleDefragThread
3805 // Thread function, one created for each zone in a multiple thread test.
3808 LOCAL_C TInt MultipleDefragThread(TAny* aUseTb)
3811 TInt zoneId = (TInt)aUseTb;
3813 if (TestZoneCount > TEST_MAX_ZONE_THREADS)
3815 numZones = TestZoneCount / TEST_MAX_ZONE_THREADS;
3822 for (; index < numZones; index ++)
3824 User::AfterHighRes(TEST_MAX_ZONE_THREADS*TickPeriod/4);
3825 tempy = zoneId + (TEST_MAX_ZONE_THREADS * index);
3826 if (tempy < (TInt)TestZoneCount)
3828 RamstressLdd.DoMovePagesInZone(tempy);
3830 if (TestDefragTestEnd)
3833 if (TestDefragTestEnd)
3842 // Call the auto tests whilst defraging in the background.
3845 void DoDefragAutoTest()
3847 TUint localZoneCount = TestZoneCount;
3848 if (TestZoneCount > TEST_MAX_ZONE_THREADS)
3850 localZoneCount = TEST_MAX_ZONE_THREADS;
3852 TInt size = (sizeof(RThread) * localZoneCount)
3853 + (sizeof(TInt) * localZoneCount);
3854 TUint8* pBuf = (TUint8*)User::AllocZ(size);
3857 RThread *pTheThreads = (RThread*)pBuf;
3858 TInt *pThreadInUse = (TInt*)(pTheThreads + localZoneCount);
3861 for (index = 0; index < localZoneCount; index ++)
3863 DBGS_PRINT((_L("%S : Starting Defrag Thread %d\n"), &TestNameBuffer, index));
3864 ret = pTheThreads[index].Create(KTestBlank,MultipleDefragThread,KDefaultStackSize,NULL,(TAny*) index);
3865 if (ret == KErrNone)
3867 pTheThreads[index].Resume();
3868 pThreadInUse[index] = 1;
3872 DBGS_PRINT((_L("%S : Starting Defrag Thread Failed %d\n"), &TestNameBuffer, index));
3876 // Do the full auto tests...
3877 PerformAutoTest(TestIsDemandPaged);
3879 TestDefragTestEnd = ETrue;
3880 RamstressLdd.DoSetEndFlag(1);
3881 TBool anyUsed = ETrue;
3883 DBGS_PRINT((_L("%S : Waiting for Defrag Threads to exit...\n"), &TestNameBuffer));
3884 TUint killNext = User::TickCount();
3889 // walk through the thread list to check which are still alive.
3890 for (index = 0; index < localZoneCount; index++)
3892 if (pThreadInUse[index])
3894 if (pTheThreads[index].ExitType() != EExitPending)
3896 if (pTheThreads[index].ExitType() == EExitPanic)
3898 DBGS_PRINT((_L("%S : Defrag Thread %d Panic'd\n"), &TestNameBuffer, index));
3902 DBGS_PRINT((_L("%S : Defrag Thread %d Exited\n"), &TestNameBuffer, index));
3904 pTheThreads[index].Close();
3905 pThreadInUse[index] = EFalse;
3910 TUint now = User::TickCount();
3911 TUint time = TUint((TUint64)(now-killNext)*(TUint64)TickPeriod/(TUint64)1000000);
3912 const TUint killTimeStep = (TEST_DOT_PERIOD+9)/10; // 1/10th of a dot
3913 if(time>TEST_DOT_PERIOD+killTimeStep)
3915 killNext += killTimeStep*1000000/TickPeriod;
3916 DBGS_PRINT((_L("%S : killing Defrag Thread %d\n"), &TestNameBuffer, index));
3917 pTheThreads[index].Kill(KErrNone);
3918 pTheThreads[index].Close();
3919 pThreadInUse[index] = EFalse;
3924 User::After(500000);
3926 DBGS_PRINT((_L("%S : Defrag Threads exited...\n"), &TestNameBuffer));
3927 RamstressLdd.DoSetEndFlag(0);
3934 // Test the ram defrag code.
3937 void DoDefragTest(void)
3939 SVMCacheInfo tempPages;
3940 memset(&tempPages, 0, sizeof(tempPages));
3942 test.Next(_L("Ram Defrag : Get the number of zones"));
3943 // first get the number of zones
3944 TInt ret = UserSvr::HalFunction(EHalGroupRam,ERamHalGetZoneCount,&TestZoneCount,0);
3945 if(ret==KErrNotSupported)
3947 test.Next(_L("TESTS NOT RUN - Ram Defrag appears to not be supported.\n"));
3950 test(ret == KErrNone);
3951 test(TestZoneCount != 0);
3952 test.Printf(_L("RAM Zones (count=%u)\n"),TestZoneCount);
3954 // now get the config of each of the zones.
3956 struct SRamZoneConfig config;
3957 struct SRamZoneUtilisation util;
3958 test.Next(_L("Ram Defrag : Get info about the zones"));
3959 for (index = 0; index < TestZoneCount; index ++)
3961 ret = UserSvr::HalFunction(EHalGroupRam,ERamHalGetZoneConfig,(TAny*)index, (TAny*)&config);
3962 test(ret == KErrNone);
3963 test.Printf(_L("config : id=%d index=%d base=0x%08x end=0x%08x pages=%d pref=%d flags=0x%x\n"),
3964 config.iZoneId,config.iZoneIndex,config.iPhysBase,config.iPhysEnd,config.iPhysPages,
3965 config.iPref,config.iFlags);
3967 ret = UserSvr::HalFunction(EHalGroupRam,ERamHalGetZoneUtilisation,(TAny*)index, (TAny*)&util);
3968 test(ret == KErrNone);
3969 test.Printf(_L("usage : id=%d index=%d pages=%d free=%d unknown=%d fixed=%d move=%d discard=%d other=%d\n"),
3970 util.iZoneId,util.iZoneIndex,util.iPhysPages,util.iFreePages,
3971 util.iAllocUnknown,util.iAllocFixed,util.iAllocMovable,util.iAllocDiscardable,util.iAllocOther);
3973 // Now test for zones out of range.
3974 test.Next(_L("Ram Defrag : test out of range indexes"));
3975 ret = UserSvr::HalFunction(EHalGroupRam,ERamHalGetZoneConfig,(TAny*)(TestZoneCount + 1), (TAny*)&config);
3976 test(ret != KErrNone);
3977 ret = UserSvr::HalFunction(EHalGroupRam,ERamHalGetZoneUtilisation,(TAny*)(TestZoneCount + 1), (TAny*)&util);
3978 test(ret != KErrNone);
3980 ret = UserSvr::HalFunction(EHalGroupRam,ERamHalGetZoneConfig,(TAny*)-1, (TAny*)&config);
3981 test(ret != KErrNone);
3982 ret = UserSvr::HalFunction(EHalGroupRam,ERamHalGetZoneUtilisation,(TAny*)-1, (TAny*)&util);
3983 test(ret != KErrNone);
3984 test.Next(_L("Ram Defrag : test out of range enums"));
3985 ret = UserSvr::HalFunction(EHalGroupRam,-1, 0, 0);
3986 test(ret != KErrNone);
3987 ret = UserSvr::HalFunction(EHalGroupRam,ERamHalGetZoneUtilisation + 1,0, 0);
3988 test(ret != KErrNone);
3990 TInt r = User::LoadLogicalDevice(KRamStressTestLddName);
3991 RUNTEST1(r==KErrNone || r==KErrAlreadyExists);
3992 RUNTEST(RamstressLdd.Open(),KErrNone);
3993 //TestDebug = ETrue;
3994 RUNTEST(RamstressLdd.DoSetDebugFlag((TInt)TestDebug),KErrNone);
3996 test.Next(_L("Ram Defrag : set VM cache to stress free..."));
3998 if (TestIsDemandPaged)
4000 // get the old cache info
4001 UserSvr::HalFunction(EHalGroupVM,EVMHalGetCacheSize,&tempPages,0);
4003 TInt minSize = 512 * 4096;
4004 TInt maxSize = 32767 * 4096;
4005 UserSvr::HalFunction(EHalGroupVM,EVMHalSetCacheSize,(TAny*)minSize,(TAny*)maxSize);
4008 test.Next(_L("Ram Defrag : move all pages in all zone in 1 thread..."));
4010 for (index = 0; index < TestZoneCount; index ++)
4012 test.Printf(_L("Ram Defrag : moving pages in zone %u\n"),index);
4013 ret = RamstressLdd.DoMovePagesInZone(index);
4014 if (ret != KErrNone)
4016 test.Printf(_L("Ram Defrag : moving pages in zone failed %u err=%d\n"), index, ret);
4021 test.Next(_L("Ram Defrag : Get info after test"));
4022 for (index = 0; index < TestZoneCount; index ++)
4024 ret = UserSvr::HalFunction(EHalGroupRam,ERamHalGetZoneUtilisation,(TAny*)index, (TAny*)&util);
4025 test(ret == KErrNone);
4026 test.Printf(_L("usage : id=%d index=%d pages=%d free=%d unknown=%d fixed=%d move=%d discard=%d other=%d\n"),
4027 util.iZoneId,util.iZoneIndex,util.iPhysPages,util.iFreePages,
4028 util.iAllocUnknown,util.iAllocFixed,util.iAllocMovable,util.iAllocDiscardable,util.iAllocOther);
4031 test.Next(_L("Ram Defrag : Page moving on multiple threads with auto test running."));
4033 TestingDefrag = ETrue;
4034 TestDefragTestEnd = EFalse;
4037 TestingDefrag = EFalse;
4039 * End of test cleanup.
4042 test.Next(_L("Ram Defrag : reset VM cache back to stressed."));
4043 if (TestIsDemandPaged)
4045 TInt minSize = tempPages.iMinSize;
4046 TInt maxSize = tempPages.iMaxSize;
4047 UserSvr::HalFunction(EHalGroupVM,EVMHalSetCacheSize,(TAny*)minSize,(TAny*)maxSize);
4049 RamstressLdd.Close();
4050 test.Next(_L("Ram Defrag : Done"));
4054 // PerformExceptionThread
4059 LOCAL_C TInt PerformExceptionThread(TAny* )
4061 User::AfterHighRes(1000000);
4062 // this line will cause a Kern::Exec 0 !!!
4063 test.Printf(_L("Hello World\n"));
4069 // DoExceptionInAnotherThread
4071 // Test the d_exc and minkda functionality with faulting processes.
4074 void DoExceptionInAnotherThread(void)
4076 TRequestStatus theStatus;
4079 TInt ret = theThread.Create(KTestBlank,PerformExceptionThread,KDefaultStackSize,NULL,NULL);
4080 test(ret == KErrNone);
4081 theThread.Logon(theStatus);
4082 RUNTEST1(theStatus == KRequestPending);
4085 User::WaitForRequest(theStatus);
4091 // Test the d_exc and minkda functionality with faulting processes.
4098 test.Next(_L("DoTestD_Exc : d_exc check test."));
4100 DBGS_PRINT((_L("%S : DoTestD_Exc start...\n"), &TestNameBuffer));
4101 // first we need to spawn d_exc.exe
4102 RProcess dexcProcess;
4103 TInt ret = dexcProcess.Create(_L("d_exc.exe"),_L("-b"));
4104 RUNTEST1(KErrNone == ret);
4105 TRequestStatus dexcStatus;
4106 dexcProcess.Logon(dexcStatus);
4107 RUNTEST1(dexcStatus == KRequestPending);
4108 dexcProcess.Resume();
4110 DBGS_PRINT((_L("%S : DoTestD_Exc started d_exc.exe\n"), &TestNameBuffer));
4112 DoExceptionInAnotherThread();
4114 DBGS_PRINT((_L("%S : DoTestD_Exc test completed\n"), &TestNameBuffer));
4115 // check that d_exc and minkda don't die!
4116 RUNTEST1(dexcProcess.ExitType() == EExitPending);
4118 DBGS_PRINT((_L("%S : DoTestD_Exc d_exc still running\n"), &TestNameBuffer));
4121 dexcProcess.Kill(KErrNone);
4122 dexcProcess.Close();
4123 User::WaitForRequest(dexcStatus);
4124 DBGS_PRINT((_L("%S : DoTestD_Exc d_exc killed and exiting\n"), &TestNameBuffer));
4129 Get name of the hash file used for an EXE or DLL which has been
4130 copied to writable media.
4132 @param aOrigName Name of EXE or DLL which has been copied to
4133 writable media. This does not have to be
4134 qualified because only the name and extension
4136 @param aHashName On return this is set to the absolute filename
4137 which should contain the file's hash. This
4138 function does not create the file, or its containing
4142 static void GetHashFileName(const TDesC& aOrigName, TDes& aHashName)
4144 aHashName.Copy(KSysHash);
4145 aHashName[0] = (TUint8) RFs::GetSystemDriveChar();
4146 const TParsePtrC ppc(aOrigName);
4147 aHashName.Append(ppc.NameAndExt());
4152 // take hash of files require full drive:/path/name.ext
4155 void HashFile(const TDesC& aFileName, RFs& aFs)
4157 CSHA1* sha1 = CSHA1::NewL();
4158 CleanupStack::PushL(sha1);
4161 hashfile = KSysHash;
4162 hashfile[0] = (TUint8) RFs::GetSystemDriveChar();
4164 TInt r = aFs.MkDirAll(hashfile);
4165 RUNTEST1(r==KErrNone || r==KErrAlreadyExists);
4168 r = fDest.Open(aFs, aFileName, EFileRead | EFileStream);
4171 if (TestingReaper && (r == KErrInUse))
4173 TBool whinged = EFalse;
4174 while (r == KErrInUse)
4176 User::After(2000000);
4179 DBGS_PRINT((_L("HashFile() retrying Open for %S (%d)\n"), &aFileName, r));
4182 r = fDest.Open(aFs, aFileName, EFileRead | EFileStream);
4188 DBGS_PRINT((_L("fDest.Open returned %d\n"), r));
4191 User::LeaveIfError(r);
4192 CleanupClosePushL(fDest);
4198 r = fDest.Read(content);
4200 DBGS_PRINT((_L("fDest.Read returned %d\n"), r));
4201 User::LeaveIfError(r);
4202 done = (content.Length() == 0);
4204 sha1->Update(content);
4206 CleanupStack::PopAndDestroy(&fDest);
4208 // write hash to \sys\hash
4209 TBuf8<SHA1_HASH> hashVal = sha1->Final();
4211 TFileName fnSrc(aFileName);
4212 GetHashFileName(aFileName, fnSrc);
4214 r = fHash.Replace(aFs, fnSrc, EFileWrite | EFileStream);
4216 DBGS_PRINT((_L("fHash.Replace returned %d\n"), r));
4217 User::LeaveIfError(r);
4218 CleanupClosePushL(fHash);
4219 r = fHash.Write(hashVal);
4221 DBGS_PRINT((_L("fHash.Write returned %d\n"), r));
4222 User::LeaveIfError(r);
4224 CleanupStack::PopAndDestroy(2, sha1);
4230 // Copy a file to the MMC card and create a hash of it.
4233 TInt CopyFileToMMc(RFs& aFs,CFileMan* aFileMan, TPtrC aPath, TPtrC aOldFilename, TPtrC aNewFilename)
4235 TInt retVal = aFs.MkDirAll(aPath);
4236 RUNTEST1(retVal==KErrNone || retVal==KErrAlreadyExists);
4241 oldPath.Format(_L("%S%S"),&KRomPath, &aOldFilename);
4242 newPath.Format(_L("%S%S"),&aPath, &aNewFilename);
4243 DBGD_PRINT((_L("Copying %S to %S\n"), &oldPath, &newPath));
4244 retVal = aFileMan->Copy(oldPath, newPath, CFileMan::EOverWrite);
4245 if (retVal == KErrNone)
4247 retVal = aFileMan->Attribs(newPath, KEntryAttNormal, KEntryAttReadOnly, 0);
4248 if (retVal != KErrNone)
4250 DBGS_PRINT((_L("%S : Attribs failed (%d)\n"), &newPath, retVal));
4253 retVal = aFs.Entry(newPath, anEntry);
4254 if (retVal != KErrNone)
4256 DBGS_PRINT((_L("%S : aFs.Entry failed (%d)\n"), &newPath, retVal));
4258 TRAPD(r, HashFile(newPath, aFs));
4259 RUNTEST1(r == KErrNone);
4262 DBGS_PRINT((_L("Failed to copy file %d\n"), retVal));
4263 DBGD_PRINT((_L("%S : now %S (%d)\n"), &newPath, EXISTS(retVal), retVal));
4268 // CopyAndFragmentFiles
4270 // Copy the test files to a specified location edeavouring to fragment as much as possible.
4273 TBool CopyAndFragmentFiles(RFs& aFs,CFileMan* aFileMan, TPtrC aPath, ETestMediaType aMediaType)
4275 TInt retVal = aFs.MkDirAll(aPath);
4276 RUNTEST1(retVal==KErrNone || retVal==KErrAlreadyExists);
4277 #define FILECOUNTMAX (PAGELDRTST_MAX_DLLS + 2)
4278 RFile theInFiles[FILECOUNTMAX];
4279 RFile theOutFiles[FILECOUNTMAX];
4280 TInt inFileSize[FILECOUNTMAX];
4281 TInt inFilePos[FILECOUNTMAX];
4282 TBool fileOk[FILECOUNTMAX];
4288 for (index = 0; index < FILECOUNTMAX; index ++)
4290 inFileSize[index] = 0;
4291 inFilePos[index] = 0;
4292 fileOk[index] = EFalse;
4294 if (index < PAGELDRTST_MAX_DLLS)
4296 oldPath.Format(_L("%S%S%d%S"), &KRomPath, &KDllBaseName, index, &TestPlExtNames[KTestMediaBase]);
4297 newPath.Format(_L("%S%S%d%S"), &aPath, &KDllBaseName, index, &TestPlExtNames[aMediaType]);
4299 else if (index < (PAGELDRTST_MAX_DLLS + 1))
4301 oldPath.Format(_L("%S%S"), &KRomPath, &TestPsExeNames[KTestMediaBase]);
4302 newPath.Format(_L("%S%S"), &aPath, &TestPsExeNames[aMediaType]);
4306 oldPath.Format(_L("%S%S"), &KRomPath, &TestPlExeNames[KTestMediaBase]);
4307 newPath.Format(_L("%S%S"), &aPath, &TestPlExeNames[aMediaType]);
4310 retVal = theInFiles[index].Open(aFs, oldPath, EFileRead);
4311 if (retVal != KErrNone)
4313 DBGS_PRINT((_L("%S : Failed to open for read (%d)\n"), &oldPath, retVal));
4316 retVal = theInFiles[index].Size(inFileSize[index]);
4317 if (retVal != KErrNone)
4319 theInFiles[index].Close();
4320 DBGS_PRINT((_L("%S : Failed to get file size (%d)\n"), &newPath, retVal));
4323 retVal = theOutFiles[index].Replace(aFs, newPath, EFileWrite);
4324 if (retVal != KErrNone)
4326 theInFiles[index].Close();
4327 DBGS_PRINT((_L("%S : Failed to open for write (%d)\n"), &newPath, retVal));
4331 fileOk[index] = ETrue;
4334 const TInt KBufferSize = 3333;
4335 TBuf8<KBufferSize> buffer;
4340 stillGoing = EFalse;
4341 for (index = 0; index < FILECOUNTMAX; index ++)
4345 if (inFilePos[index] < inFileSize[index])
4347 retVal = theInFiles[index].Read(buffer);
4348 if (retVal != KErrNone)
4350 DBGS_PRINT((_L("theInFiles[%d] read failed (%d)\n"), index, retVal));
4353 retVal = theOutFiles[index].Write(buffer);
4354 if (retVal != KErrNone)
4356 DBGS_PRINT((_L("theOutFiles[%d] Write failed (%d)\n"), index, retVal));
4359 retVal = theOutFiles[index].Flush();
4360 if (retVal != KErrNone)
4362 DBGS_PRINT((_L("theOutFiles[%d] flush failed (%d)\n"), index, retVal));
4365 inFilePos[index] += buffer.Length();
4366 if (inFilePos[index] < inFileSize[index])
4373 TBool allOk = retVal == KErrNone;
4374 for (index = 0; index < FILECOUNTMAX; index ++)
4381 theInFiles[index].Close();
4382 theOutFiles[index].Close();
4383 if (index < PAGELDRTST_MAX_DLLS)
4385 newPath.Format(_L("%S%S%d%S"), &aPath, &KDllBaseName, index, &TestPlExtNames[aMediaType]);
4387 else if (index < (PAGELDRTST_MAX_DLLS + 1))
4389 newPath.Format(_L("%S%S"), &aPath, &TestPsExeNames[aMediaType]);
4393 newPath.Format(_L("%S%S"), &aPath, &TestPlExeNames[aMediaType]);
4396 retVal = aFileMan->Attribs(newPath, KEntryAttNormal, KEntryAttReadOnly, 0);
4397 if (retVal != KErrNone)
4399 DBGS_PRINT((_L("%S : Attribs failed (%d)\n"), &newPath, retVal));
4403 retVal = aFs.Entry(newPath, anEntry);
4404 if (retVal != KErrNone)
4406 DBGS_PRINT((_L("%S : aFs.Entry failed (%d)\n"), &newPath, retVal));
4409 TRAPD(r, HashFile(newPath, aFs));
4414 DBGD_PRINT((_L("%S : %S!\n"), &newPath, EXISTS(!allOk)));
4420 // CheckFilePresence
4422 // Checks all the files required for the test are present and copies some tests to the MMC card
4425 void CheckFilePresence(TBool aDoFileCopy)
4427 TUint start = User::TickCount();
4430 if (KErrNone != fs.Connect())
4432 DBGS_PRINT(_L("CheckFilePresence : Can't connect to the FS\n"));
4437 TFileName newFilename;
4443 // now we need to add the MMC files
4444 TInt drvNum = FindMMCDriveNumber(fs);
4446 mmcPath.Format(_L("%S"),&KMmcDefaultPath);
4448 mmcPath[0] = 'a' + drvNum;
4451 //TInt indexMax = aDoFileCopy ? KTestMediaMmc : KTestMediaCOUNT;
4452 for (index = 0; index < TEST_MEDIA_COUNT_HACK; index ++)
4455 filename.Format(_L("%S%S"),(index == KTestMediaMmc) ? & mmcPath : &KRomPath, &TestPsExeNames[index]);
4456 if (KErrNone != fs.Entry(filename, anEntry))
4459 filename.Format(_L("%S%S"),(index == KTestMediaMmc) ? & mmcPath : &KRomPath, &TestPlExeNames[index]);
4460 if (KErrNone != fs.Entry(filename, anEntry))
4463 for (dllIndex = 0; dllIndex < PAGELDRTST_MAX_DLLS; dllIndex ++)
4465 filename.Format(_L("%S%S%d%S"), (index == KTestMediaMmc) ? & mmcPath : &KRomPath, &KDllBaseName, dllIndex, &TestPlExtNames[index]);
4466 if (KErrNone != fs.Entry(filename, anEntry))
4469 TestDllExesExist[index] = allOk;
4470 DBGS_PRINT((_L("%S : %S!\n"), &TestPsExeNames[index], EXISTS(!TestDllExesExist[index])));
4472 TInt nandDrvNum = FindFsNANDDrive(fs);
4473 if (aDoFileCopy && (drvNum >= 0) && (nandDrvNum >= 0))
4475 CTrapCleanup* cleanupStack = CTrapCleanup::New();
4477 DBGS_PRINT((_L("Cleanup stack failed\n")));
4478 CFileMan* pFileMan = NULL;
4479 TRAP(retVal, pFileMan = CFileMan::NewL(fs));
4481 // First make a clean copy of the DLLs to the MMC card.
4483 if (KErrNone != CopyFileToMMc(fs, pFileMan, mmcPath, TestPsExeNames[KTestMediaBase], TestPsExeNames[KTestMediaMmc]))
4485 if (KErrNone != CopyFileToMMc(fs, pFileMan, mmcPath, TestPlExeNames[KTestMediaBase], TestPlExeNames[KTestMediaMmc]))
4487 for (dllIndex = 0; dllIndex < PAGELDRTST_MAX_DLLS; dllIndex ++)
4489 filename.Format(_L("%S%d%S"), &KDllBaseName, dllIndex, &TestPlExtNames[KTestMediaBase]);
4490 newFilename.Format(_L("%S%d%S"), &KDllBaseName, dllIndex, &TestPlExtNames[KTestMediaMmc]);
4491 if (KErrNone != CopyFileToMMc(fs, pFileMan, mmcPath, filename, newFilename))
4494 TestDllExesExist[KTestMediaMmc] = allOk;
4495 DBGS_PRINT((_L("%S : %S! (Drive %c)\n"), &TestPsExeNames[index], EXISTS(!TestDllExesExist[index]), mmcPath[0]));
4496 #ifdef TEST_ADD_FRAGD_MEDIA
4497 //now make some fragmented files on the MMC card.
4498 TestDllExesExist[KTestMediaMmcFrag] = CopyAndFragmentFiles(fs, pFileMan, mmcPath, KTestMediaMmcFrag);
4499 DBGS_PRINT((_L("%S : %S! (Drive %c)\n"), &TestPsExeNames[KTestMediaMmcFrag], EXISTS(!TestDllExesExist[KTestMediaMmcFrag]), mmcPath[0]));
4501 //now make some fragmented files on the NAND card.
4502 if (nandDrvNum >= 0)
4504 mmcPath[0] = 'a' + nandDrvNum;
4505 TestDllExesExist[KTestMediaNandFrag] = CopyAndFragmentFiles(fs, pFileMan, mmcPath, KTestMediaNandFrag);
4506 DBGS_PRINT((_L("%S : %S! (Drive %c)\n"), &TestPsExeNames[KTestMediaNandFrag], EXISTS(!TestDllExesExist[KTestMediaNandFrag]), mmcPath[0]));
4509 DBGS_PRINT((_L("CheckFilePresence : Failed to get NAND drive number\n")));
4510 #endif // TEST_ADD_FRAGD_MEDIA
4511 delete pFileMan; pFileMan = NULL;
4512 delete cleanupStack; cleanupStack = NULL;
4517 TUint end = User::TickCount();
4518 TUint time = TUint((TUint64)(end-start)*(TUint64)TickPeriod/(TUint64)1000000);
4519 DBGS_PRINT((_L("CheckFilePresence : %d secs elapsed\n"), time));
4525 // Delete a file and remove the hash
4528 void DoDeleteFile(CFileMan* aFileMan, TBool aSilent,TFileName& aFileName )
4532 test(l.Connect() == KErrNone);
4534 DBGD_PRINT((_L("Deleting %S ...\n"), &aFileName));
4536 DBGD_PRINT((_L("Deleting %S\n"), &aFileName));
4537 TInt retVal = aFileMan->Delete(aFileName);
4538 if (retVal != KErrNone)
4542 aFileMan->Attribs(aFileName, KEntryAttNormal, KEntryAttReadOnly, 0);
4543 retVal = l.Delete(aFileName);
4544 if (retVal != KErrNone)
4546 DBGS_PRINT((_L("RLoader::Delete %S Failed %d\n"), &aFileName, retVal));
4552 DBGS_PRINT((_L("Deleting %S Failed %d\n"), &aFileName, retVal));
4555 GetHashFileName(aFileName, hashName);
4556 retVal = aFileMan->Delete(hashName);
4557 if (retVal != KErrNone)
4559 if (TestingReaper && (retVal == KErrInUse))
4561 retVal = l.Delete(hashName);
4562 if (retVal != KErrNone)
4564 DBGS_PRINT((_L("RLoader::Delete %S Failed %d\n"), &hashName, retVal));
4570 DBGS_PRINT((_L("Deleting %S Failed %d\n"), &hashName, retVal));
4579 // Remove any copied files and created directories.
4582 void CleanupFiles(TBool silent)
4584 TUint start = User::TickCount();
4587 if (KErrNone != fs.Connect())
4589 DBGS_PRINT(_L("CleanupFiles : Can't connect to the FS\n"));
4593 CTrapCleanup* cleanupStack = CTrapCleanup::New();
4596 DBGS_PRINT((_L("Cleanup stack failed\n")));
4598 CFileMan* pFileMan = NULL;
4600 TRAP(retVal, pFileMan = CFileMan::NewL(fs));
4607 path.Format(_L("%S"),&KMmcDefaultPath);
4608 TInt mmcDrvNum = FindMMCDriveNumber(fs);
4609 TInt nandDrvNum = FindFsNANDDrive(fs);
4610 for (index = KTestMediaMmc; index < KTestMediaCOUNT; index ++)
4612 #ifdef TEST_ADD_FRAGD_MEDIA
4613 if (index == KTestMediaNandFrag)
4617 path[0] = 'a' + nandDrvNum;
4623 path[0] = 'a' + mmcDrvNum;
4626 path[0] = 'a' + mmcDrvNum;
4628 newPath.Format(_L("%S%S"),&path, &TestPsExeNames[index]);
4629 DoDeleteFile(pFileMan, silent, newPath);
4631 newPath.Format(_L("%S%S"),&path, &TestPlExeNames[index]);
4632 DoDeleteFile(pFileMan, silent, newPath);
4634 for (dllIndex = 0; dllIndex < PAGELDRTST_MAX_DLLS; dllIndex ++)
4636 newPath.Format(_L("%S%S%d%S"), &path, &KDllBaseName, dllIndex, &TestPlExtNames[index]);
4637 DoDeleteFile(pFileMan, silent, newPath);
4640 if (nandDrvNum >= 0)
4642 path[0] = 'a' + nandDrvNum;
4647 path[0] = 'a' + mmcDrvNum;
4651 delete pFileMan; pFileMan = NULL;
4652 delete cleanupStack; cleanupStack = NULL;
4654 TUint end = User::TickCount();
4655 TUint time = TUint((TUint64)(end-start)*(TUint64)TickPeriod/(TUint64)1000000);
4656 DBGS_PRINT((_L("CleanupFiles : %d secs elapsed\n"), time));
4662 // FindLocalDriveNumber
4664 // Find the local drive
4667 TInt FindLocalDriveNumber(RFs &aFs, TInt aFsDrvNum)
4671 fileName.Append((TChar)('A' + aFsDrvNum));
4672 fileName+=_L(":\\f32-tst\\");
4673 TInt r=aFs.MkDirAll(fileName);
4674 TInt locDriveNumber = -1;
4675 if (r==KErrNone || r== KErrAlreadyExists)
4677 fileName += _L("tempy.txt");
4678 r=file.Replace(aFs,fileName,EFileWrite);
4680 DBGS_PRINT((_L("FindLocalDriveNumber : Error %d: file '%S' could not be created\n"),r,&fileName));
4681 RUNTEST1(r==KErrNone);
4682 r=file.Write(_L8("Flies as big as sparrows indoletly buzzing in the warm air, heavy with the stench of rotting carcasses"));
4685 DBGS_PRINT((_L("FindLocalDriveNumber : Error %d: could not write to file %d (%S)\n"),r,aFsDrvNum, &fileName));
4689 // write caching may be enabled to flush the cache...
4690 TRequestStatus flushStatus;
4691 file.Flush(flushStatus);
4692 User::WaitForRequest(flushStatus);
4693 // get the block map
4696 r=file.BlockMap(info, start, -1,ETestDebug);
4697 if (r==KErrNone || r==KErrCompletion)
4699 locDriveNumber=info.iLocalDriveNumber;
4700 DBGD_PRINT((_L("FindLocalDriveNumber : locDriveNumber %d\n"), locDriveNumber));
4703 DBGS_PRINT((_L("FindLocalDriveNumber : Error %d: error getting blockmap for drive %d (%S)\n"),r,aFsDrvNum, &fileName));
4705 aFs.Delete(fileName);
4709 DBGS_PRINT((_L("FindLocalDriveNumber : Error %d: error creating dir \n"),r));
4710 return locDriveNumber;
4714 // ResetConcurrencyStats
4719 void ResetConcurrencyStats(RFs& aFs)
4721 if(TestBootedFromMmc)
4723 TInt fsDriveNum = FindMMCDriveNumber(aFs);
4724 if (fsDriveNum >= 0)
4726 TInt locDriveNumber = FindLocalDriveNumber(aFs, fsDriveNum);
4727 if (locDriveNumber >= 0)
4729 RUNTEST(PagingInfo::ResetConcurrency(locDriveNumber,EMediaPagingStatsRomAndCode),KErrNone);
4732 DBGS_PRINT((_L("ResetConcurrencyStats MMC : Failed to get locDriveNumber %d (%d)\n"), locDriveNumber, fsDriveNum));
4735 DBGS_PRINT((_L("ResetConcurrencyStats MMC : Failed to get fsDriveNum %d\n"), fsDriveNum));
4739 TInt fsDriveNum = FindFsNANDDrive(aFs);
4740 if (fsDriveNum >= 0)
4742 TInt locDriveNumber = FindLocalDriveNumber(aFs, fsDriveNum);
4743 if (locDriveNumber >= 0)
4745 RUNTEST(PagingInfo::ResetConcurrency(locDriveNumber,EMediaPagingStatsRomAndCode),KErrNone);
4748 DBGS_PRINT((_L("ResetConcurrencyStats NAND : Failed to get locDriveNumber %d (%d)\n"), locDriveNumber, fsDriveNum));
4751 DBGS_PRINT((_L("ResetConcurrencyStats NAND : Failed to get fsDriveNum %d\n"), fsDriveNum));
4761 void ResetBenchmarks(RFs& aFs)
4763 if(TestBootedFromMmc)
4765 TInt fsDriveNum = FindMMCDriveNumber(aFs);
4766 if (fsDriveNum >= 0)
4768 TInt locDriveNumber = FindLocalDriveNumber(aFs, fsDriveNum);
4769 if (locDriveNumber >= 0)
4771 RUNTEST(PagingInfo::ResetBenchmarks(locDriveNumber,EMediaPagingStatsRomAndCode),KErrNone);
4774 DBGS_PRINT((_L("ResetBenchmarks MMC : Failed to get locDriveNumber %d (%d)\n"), locDriveNumber, fsDriveNum));
4777 DBGS_PRINT((_L("ResetBenchmarks MMC : Failed to get fsDriveNum %d\n"), fsDriveNum));
4781 TInt fsDriveNum = FindFsNANDDrive(aFs);
4782 if (fsDriveNum >= 0)
4784 TInt locDriveNumber = FindLocalDriveNumber(aFs, fsDriveNum);
4785 if (locDriveNumber >= 0)
4787 RUNTEST(PagingInfo::ResetBenchmarks(locDriveNumber,EMediaPagingStatsRomAndCode),KErrNone);
4790 DBGS_PRINT((_L("ResetBenchmarks NAND : Failed to get locDriveNumber %d (%d)\n"), locDriveNumber, fsDriveNum));
4793 DBGS_PRINT((_L("ResetBenchmarks NAND : Failed to get fsDriveNum %d\n"), fsDriveNum));
4798 // DisplayConcurrencyStats
4800 // Display the stats
4803 void DisplayConcurrencyStats(RFs& aFs)
4805 if(TestBootedFromMmc)
4807 TInt fsDriveNum = FindMMCDriveNumber(aFs);
4808 if (fsDriveNum >= 0)
4810 TInt locDriveNumber = FindLocalDriveNumber(aFs, fsDriveNum);
4811 if (locDriveNumber >= 0)
4813 DBGS_PRINT((_L("MMC stats\n")));
4814 RUNTEST1(PagingInfo::PrintConcurrency(locDriveNumber,EMediaPagingStatsRomAndCode)==KErrNone);
4817 DBGS_PRINT((_L("DisplayConcurrencyStats MMC : Failed to get locDriveNumber %d (%d)\n"), locDriveNumber, fsDriveNum));
4820 DBGS_PRINT((_L("DisplayConcurrencyStats MMC : Failed to get fsDriveNum %d\n"), fsDriveNum));
4824 TInt fsDriveNum = FindFsNANDDrive(aFs);
4825 if (fsDriveNum >= 0)
4827 TInt locDriveNumber = FindLocalDriveNumber(aFs, fsDriveNum);
4829 if (locDriveNumber >= 0)
4831 DBGS_PRINT((_L("NAND stats\n")));
4832 RUNTEST1(PagingInfo::PrintConcurrency(locDriveNumber,EMediaPagingStatsRomAndCode)==KErrNone);
4835 DBGS_PRINT((_L("DisplayConcurrencyStats NAND : Failed to get locDriveNumber %d (%d)\n"), locDriveNumber, fsDriveNum));
4838 DBGS_PRINT((_L("DisplayConcurrencyStats NAND : Failed to get fsDriveNum %d\n"), fsDriveNum));
4842 void DisplayBenchmarks(RFs& aFs)
4844 if(TestBootedFromMmc)
4846 TInt fsDriveNum = FindMMCDriveNumber(aFs);
4847 if (fsDriveNum >= 0)
4849 TInt locDriveNumber = FindLocalDriveNumber(aFs, fsDriveNum);
4850 if(locDriveNumber>=0)
4852 DBGS_PRINT((_L("MMC benchmarks\n")));
4853 RUNTEST1(PagingInfo::PrintBenchmarks(locDriveNumber,EMediaPagingStatsRomAndCode)==KErrNone);
4856 DBGS_PRINT((_L("DisplayBenchmarks MMC : Failed to get locDriveNumber %d (%d)\n"), locDriveNumber, fsDriveNum));
4859 DBGS_PRINT((_L("DisplayBenchmarks MMC : Failed to get fsDriveNum %d\n"), fsDriveNum));
4863 TInt fsDriveNum = FindFsNANDDrive(aFs);
4864 if (fsDriveNum >= 0)
4866 TInt locDriveNumber = FindLocalDriveNumber(aFs, fsDriveNum);
4867 if(locDriveNumber>=0)
4869 DBGS_PRINT((_L("NAND benchmarks\n")));
4870 RUNTEST1(PagingInfo::PrintBenchmarks(locDriveNumber,EMediaPagingStatsRomAndCode)==KErrNone);
4873 DBGS_PRINT((_L("DisplayBenchmarks NAND : Failed to get locDriveNumber %d (%d)\n"), locDriveNumber, fsDriveNum));
4876 DBGS_PRINT((_L("DisplayBenchmarks NAND : Failed to get fsDriveNum %d\n"), fsDriveNum));
4884 if (TestIsDemandPaged)
4886 SVMCacheInfo tempPages;
4887 UserSvr::HalFunction(EHalGroupVM,EVMHalGetCacheSize,&tempPages,0);
4888 DBGS_PRINT((_L("DPC : min %d max %d curr %d\n"),
4889 tempPages.iMinSize, tempPages.iMaxSize, tempPages.iCurrentSize));
4890 DBGS_PRINT((_L(" : maxFree %d freeRam %d\n"),
4891 tempPages.iMaxFreeSize, FreeRam()));
4895 if (TestWeAreTheTestBase && !TestSilent)
4898 if (KErrNone != fs.Connect())
4900 DBGS_PRINT(_L("ResetConcurrencyStats : Can't connect to the FS\n"));
4904 #ifndef TEST_MINIMAL_STATS
4905 DisplayConcurrencyStats(fs);
4906 DisplayBenchmarks(fs);
4908 #ifndef TEST_DONT_RESET_STATS
4909 ResetConcurrencyStats(fs);
4910 ResetBenchmarks(fs);
4921 // Main entry point.
4926 #ifndef TEST_ON_UNPAGED
4927 TRomHeader* romHeader = (TRomHeader*)UserSvr::RomHeaderAddress();
4928 if(!romHeader->iPageableRomStart)
4930 TestIsDemandPaged = EFalse;
4933 // Turn off lazy dll unloading
4935 if (l.Connect() == KErrNone)
4937 l.CancelLazyDllUnload();
4941 HAL::Get(HAL::ESystemTickPeriod, TickPeriod);
4943 SVMCacheInfo tempPages;
4944 memset(&tempPages, 0, sizeof(tempPages));
4946 TBool parseResult = ParseCommandLine();
4953 TUint start = User::TickCount();
4957 if (TestIsDemandPaged)
4959 TInt minSize = TestMinCacheSize;
4960 TInt maxSize = TestMaxCacheSize;
4962 SVMCacheInfo tempPages;
4964 // get the old cache info
4965 UserSvr::HalFunction(EHalGroupVM,EVMHalGetCacheSize,&tempPages,0);
4966 // set the cache to our test value
4967 UserSvr::HalFunction(EHalGroupVM,EVMHalSetCacheSize,(TAny*)minSize,(TAny*)maxSize);
4972 test.Start(_L("Demand Paging loader stress tests..."));
4973 test.Printf(_L("%S (%d)\n"), &TestNameBuffer, TestWeAreTheTestBase);
4974 test.Printf(_L("TestBootedFromMmc %d\n"), TestBootedFromMmc);
4976 if (TestWeAreTheTestBase)
4977 CleanupFiles(ETrue);
4979 CheckFilePresence(TestWeAreTheTestBase);
4986 DoLowMemTest(ETrue);
4990 RUNTEST(DoSingleTest(),KErrNone);
4994 RUNTEST(DoMultipleTest(),KErrNone);
4998 RUNTEST(DoTestD_Exc(),KErrNone);
5020 if (TestWeAreTheTestBase)
5023 if (KErrNone == fs.Connect())
5025 //fs.SetDebugRegister(KCACHE);
5026 ResetConcurrencyStats(fs);
5027 ResetBenchmarks(fs);
5035 if (TestIsDemandPaged)
5037 #ifdef TEST_RUN_AUTOTEST
5039 #endif //TEST_RUN_AUTOTEST
5041 #ifndef TEST_SHORT_TEST
5042 #ifdef TEST_RUN_LOWMEMTEST
5043 DoLowMemTest(ETrue);
5044 #endif //TEST_RUN_LOWMEMTEST
5045 #ifdef TEST_RUN_CHUNKTEST
5047 #endif //TEST_RUN_CHUNKTEST
5048 #ifdef TEST_RUN_REAPERTEST
5050 #endif //TEST_RUN_REAPERTEST
5051 #endif //TEST_SHORT_TEST
5054 #ifdef TEST_RUN_DEFRAGTEST
5056 #endif //TEST_RUN_DEFRAGTEST
5060 TInt minSize = 512 * 4096;
5061 TInt maxSize = 32767 * 4096;
5062 UserSvr::HalFunction(EHalGroupVM,EVMHalSetCacheSize,(TAny*)minSize,(TAny*)maxSize);
5064 test.Printf(_L("%S Stress Free!!\n"), &TestNameBuffer, TestWeAreTheTestBase);
5065 TestStressFree = EFalse;
5073 #ifndef TEST_SHORT_TEST
5074 #ifndef TEST_NO_DEXC_IN_AUTO
5075 #ifdef TEST_RUN_D_EXCTEST
5076 RUNTEST(DoTestD_Exc(),KErrNone);
5077 #endif //TEST_RUN_D_EXCTEST
5078 #endif //TEST_NO_DEXC_IN_AUTO
5079 if (TestWeAreTheTestBase && TestFullAutoTest && TestIsDemandPaged)
5081 RProcess theProcess;
5082 TRequestStatus status;
5084 TInt retVal = theProcess.Create(_L("t_pageldrtst_rom.exe"),_L("fullauto"));
5085 if (retVal != KErrNotFound)
5087 RUNTEST1(KErrNone == retVal);
5088 theProcess.Logon(status);
5089 RUNTEST1(status == KRequestPending);
5090 theProcess.Resume();
5091 #ifdef TEST_THRASHING_TEST
5094 if (theProcess.ExitType() != EExitPending)
5096 RUNTEST1(theProcess.ExitType() != EExitPanic);
5099 User::AfterHighRes(1);
5101 User::WaitForRequest(status);
5103 User::WaitForRequest(status);
5104 if (theProcess.ExitType() != EExitPending)
5106 RUNTEST1(theProcess.ExitType() != EExitPanic);
5108 #endif //TEST_THRASHING_TEST
5112 #endif //TEST_SHORT_TEST
5114 if (TestWeAreTheTestBase && !TestSilent)
5117 if (KErrNone == fs.Connect())
5119 DisplayConcurrencyStats(fs);
5120 DisplayBenchmarks(fs);
5127 if (TestWeAreTheTestBase && !TestNoClean)
5128 CleanupFiles(EFalse);
5130 if (TestIsDemandPaged)
5132 TInt minSize = tempPages.iMinSize;
5133 TInt maxSize = tempPages.iMaxSize;
5134 // put the cache back to the the original values.
5135 UserSvr::HalFunction(EHalGroupVM,EVMHalSetCacheSize,(TAny*)minSize,(TAny*)maxSize);
5139 TUint end = User::TickCount();
5140 TUint time = TUint((TUint64)(end-start)*(TUint64)TickPeriod/(TUint64)1000000);
5141 test.Printf(_L("%S : Complete (%u seconds)\n"), &TestNameBuffer, time);