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 // e32test\mmu\t_codepaging.cpp
15 // This test relies on four dlls which it loads dynamically:
16 // - t_codepaging_dll Very simple dll, contains a single function. Used for testing state
18 // - t_codepaging_dll2 Contains 8 pages of data, used for testing the correct data is paged
19 // - t_codepaging_dll3 Statically links to t_codepaging_sll, used for testing ReadExportDir
20 // - t_codepaging_dll4 Large dll, used for testing code segment that span more than one page
22 // - t_codepaging_dll5 Contains relocatable const data.
23 // - t_codepaging_dll6 Contains relocatable writable data.
24 // - t_codepaging_dll7 Statically linked to t_codepaging_dll5 to check dependent DLLs
25 // are initialised correctly.
26 // Suite of tests specifically to test the code paging portion of demand
28 // 002 Exercise ReadExportDir with one code seg mapped already into current process
29 // 003 Exercise ReadExportDir with one code seg mapped into different process
30 // 004 Check locking of code which then gets unloaded
31 // 004.01 Load test driver...
32 // 004.02 Load/unload dll
33 // 004.03 Load dll again
34 // 004.04 Get data from DLL
35 // 004.05 Lock DLL data
36 // 004.06 Check DLL data
38 // 004.08 Check DLL loaded at different address
39 // 004.09 Unlock DLL data
40 // 004.10 Check DLL loaded at original address
42 // 005 Test writing to paged code
44 // 005.02 Get data from DLL
45 // 005.03 Write to pages in DLL
46 // 006 Running tests on drive I:
47 // 007 Test accessing pages by executing code
48 // 008 Test accessing pages by reading code
49 // 009 Test accessing pages by reading code from another process via an alias
50 // 010 Test unmapping paged code
51 // 011 Test interactions between two processes
52 // 012 Test that the contents of a paged DLL are as expected
53 // 013 Test relocated const data in DLL
54 // 014 Test relocated writable data in DLL
55 // 015 Test relocated writable data in dependent DLL
56 // 016 Test relocated writable data in preloaded dependent DLL
57 // 017 Test relocated writable data in preloaded dependent DLL opened in other process
58 // 018 Test killing a thread while it is taking paging faults
59 // 019 Test unloading a library while another thread is executing it
60 // 020 Test random access to a large dll
61 // 021 Test accessing paged code from 2 processes at 1 priority level(s) for 5 seconds
62 // 022 Test accessing paged code from 5 processes at 1 priority level(s) for 10 seconds
63 // 023 Test accessing paged code from 10 processes at 1 priority level(s) for 20 seconds
64 // 024 Test accessing paged code from 5 processes at 2 priority level(s) for 10 seconds
65 // 025 Test accessing paged code from 50 processes at 1 priority level(s) for 2 seconds
66 // 026 Running tests on drive Z:
67 // 027 Test accessing pages by executing code
68 // 028 Test accessing pages by reading code
69 // 029 Test accessing pages by reading code from another process via an alias
70 // 030 Test unmapping paged code
71 // 031 Test interactions between two processes
72 // 032 Test that the contents of a paged DLL are as expected
73 // 033 Test relocated const data in DLL
74 // 034 Test relocated writable data in DLL
75 // 035 Test relocated writable data in dependent DLL
76 // 036 Test relocated writable data in preloaded dependent DLL
77 // 037 Test relocated writable data in preloaded dependent DLL opened in other process
78 // 038 Test killing a thread while it is taking paging faults
79 // 039 Test unloading a library while another thread is executing it
80 // 040 Test random access to a large dll
81 // 041 Test accessing paged code from 2 processes at 1 priority level(s) for 5 seconds
82 // 042 Test accessing paged code from 5 processes at 1 priority level(s) for 10 seconds
83 // 043 Test accessing paged code from 10 processes at 1 priority level(s) for 20 seconds
84 // 044 Test accessing paged code from 5 processes at 2 priority level(s) for 10 seconds
85 // 045 Test accessing paged code from 50 processes at 1 priority level(s) for 2 seconds
89 //! @SYMTestCaseID KBASE-T_CODEPAGING-0335
92 //! @SYMTestCaseDesc Demand Paging Code Paging tests.
93 //! @SYMTestActions 001 Code paging tests
94 //! @SYMTestExpectedResults All tests should pass.
95 //! @SYMTestPriority High
96 //! @SYMTestStatus Implemented
99 #define __E32TEST_EXTENSION__
105 #include "mmudetect.h"
106 #include "d_memorytest.h"
107 #include "d_demandpaging.h"
108 #include "t_codepaging_dll.h"
109 #include "paging_info.h"
111 class TPagingDriveInfo
115 TDriveInfo iDriveInfo;
118 RArray<TPagingDriveInfo> SupportedDrives;
120 /// Page attributes, cut-n-paste'd from mmubase.h
123 // EInvalid=0, // No physical RAM exists for this page
124 // EFixed=1, // RAM fixed at boot time
125 // EUnused=2, // Page is unused
143 EStateNormal = 0, // no special state
144 EStatePagedYoung = 1,
146 EStatePagedDead = 3, // Not possible on the flexible memory model.
147 EStatePagedLocked = 4,
148 EStatePagedOldestClean = 5, // Flexible memory model only.
149 EStatePagedOldestDirty = 6, // Flexible memory model only.
154 /// The possible states for a logical page of RAM loaded code
167 const TUint KPagedStateShift = 8;
168 const TUint KPagedStateMask = 0xff00;
171 /// The possible states for a physical page of RAM loaded code
183 /// Names of the logical page states
184 const char* StateNames[ENumPageStates] =
194 /// Names of the physical page states
195 const char* PhysStateNames[ENumPhysStates] =
204 /// Array of physical page states indexed by logical page state
205 TPhysState PhysStateFromPageState[ENumPageStates] =
215 /// The expected logical page state bitmask for each state
216 TInt ExpectedPageState[ENumPageStates] =
219 EPageStatePageTablePresent | EPageStateInRamCode | EPageStatePaged,
220 EPageStatePageTablePresent | EPageStateInRamCode | EPageStatePaged | EPageStatePtePresent | EPageStatePteValid,
221 EPageStatePageTablePresent | EPageStateInRamCode | EPageStatePaged | EPageStatePtePresent,
222 EPageStatePageTablePresent | EPageStateInRamCode | EPageStatePaged | EPageStatePtePresent,
223 EPageStatePageTablePresent | EPageStateInRamCode | EPageStatePaged | EPageStatePtePresent
226 /// Extra bits we expect to be set on the multiple memory model
227 TInt ExpectedPageStateMultipleExtra[ENumPageStates] =
229 EPageStateCodeChunkPresent,
230 EPageStateCodeChunkPresent,
231 EPageStateCodeChunkPresent | EPageStatePhysAddrPresent,
232 EPageStateCodeChunkPresent | EPageStatePhysAddrPresent
235 /// Mask for the bits of the page state related to the physicsal page that we check
236 TInt PhysStateMask = 0xffff;
238 /// The expected physical page state bitmask for each state
239 TInt ExpectedPhysState[ENumPhysStates] =
242 EPagedCode | (EStatePagedYoung<<8),
243 EPagedCode | (EStatePagedOld<<8),
244 EPagedCode | (EStatePagedOldestClean<<8),
245 EPagedCode | (EStatePagedOldestDirty<<8)
248 typedef void (*TFunc)(void);
249 typedef void (*TFunc1)(TInt aArg1);
250 typedef TFunc TTransitionTable[ENumPageStates][ENumPageStates];
253 void UnloadLibrary();
259 TTransitionTable StateTransitions =
261 // Current: Next: EStateUnmapped EStatePagedOut EStateYoung EStateOld EStateOldestClean EStateOldestDirty
262 /* EStateUnmapped */ { 0, LoadLibrary, 0, 0, 0, 0 },
263 /* EStatePagedOut */ { UnloadLibrary, 0, AccessPage, 0, 0, 0 },
264 /* EStateYoung */ { UnloadLibrary, MakePagedOut, AccessPage, MakeOld, 0, 0 },
265 /* EStateOld */ { UnloadLibrary, MakePagedOut, AccessPage, 0, MakeOldest, MakeOldest },
266 /* EStateOldestClean*/ { UnloadLibrary, MakePagedOut, AccessPage, 0, 0, 0 },
267 /* EStateOldestDirty*/ { UnloadLibrary, MakePagedOut, AccessPage, 0, 0, 0 },
270 const TInt KMaxPathLen = 16;
271 typedef TPageState TStatePath[KMaxPathLen];
273 // Test paths through the possible states that excercises all transitions except those back to unmapped
274 // Doesn't consider dirty pages.
275 TStatePath TestPathNoOldest =
287 TStatePath TestPathOldest =
306 TStatePath* TestPath = NULL;
308 /// The different ways of accessing paged code
316 _LIT(KLibraryName, "t_codepaging_dll");
317 _LIT(KSearchPathTemplate, "?:\\sys\\bin");
319 // RTest stuff /////////////////////////////////////////////////////////////////
321 RTest test(_L("T_CODEPAGING"));
323 #define test_noError(x) { TInt _r = (x); if (_r < 0) HandleError(_r, __LINE__); }
324 #define test_notNull(x) { TAny* _a = (TAny*)(x); if (_a == NULL) HandleNull(__LINE__); }
325 #define test_equal(e, a) { TInt _e = TInt(e); TInt _a = TInt(a); if (_e != _a) HandleNotEqual(_e, _a, __LINE__); }
327 void HandleError(TInt aError, TInt aLine)
329 test.Printf(_L("Error %d\n"), aError);
330 test.operator()(EFalse, aLine);
333 void HandleNull(TInt aLine)
335 test.Printf(_L("Null value\n"));
336 test.operator()(EFalse, aLine);
339 void HandleNotEqual(TInt aExpected, TInt aActual, TInt aLine)
341 test.Printf(_L("Expected 0x%x but got 0x%x\n"), aExpected, aActual);
342 test.operator()(EFalse, aLine);
345 // Server session /////////////////////////////////////////////////////////////
347 _LIT(KServerName, "t_codepaging_server");
349 class RTestSession : public RSessionBase
359 ETestStateTransition,
360 EStartRandomAccessThread
363 TInt Connect(TInt aProcessNum);
365 { test_noError(RSessionBase::SendReceive(EKill,TIpcArgs())); }
366 inline void Exec(TFunc aFunc)
367 { test_noError(RSessionBase::SendReceive(EExec,TIpcArgs((TInt)aFunc))); }
368 inline void SetCurrentDrive(TUint16 aDrive)
369 { test_noError(RSessionBase::SendReceive(ESetCurrentDrive,TIpcArgs(aDrive))); }
370 inline void DesRead(const TDesC8& aData)
371 { test_noError(RSessionBase::SendReceive(EDesRead,TIpcArgs(&aData))); }
372 inline void TestPageState(TPageState aState, TPhysState aPhysState)
373 { test_noError(RSessionBase::SendReceive(ETestPageState,TIpcArgs(aState, aPhysState))); }
374 inline void TestStateTransition(TPageState aState)
375 { test_noError(RSessionBase::SendReceive(ETestStateTransition,TIpcArgs(aState))); }
376 inline void StartRandomAccessThread(TThreadPriority aPriority)
377 { test_noError(RSessionBase::SendReceive(EStartRandomAccessThread,TIpcArgs(aPriority))); }
380 TInt RTestSession::Connect(TInt aProcessNum)
383 name.AppendFormat(_L("%S-%d"), &KServerName, aProcessNum);
384 return CreateSession(name,TVersion());
388 // Global data /////////////////////////////////////////////////////////////////
390 TBool MovingMemoryModel;
391 TBool MultipleMemoryModel;
392 TBool FlexibleMemoryModel;
393 TBool HaveOldestLists;
396 RTestSession OtherProcess;
398 RLibrary PagedLibrary;
399 TBool LibraryLoaded = EFalse;
401 TTestFunction Library_TestFunction = NULL;
403 TAccessMethod AccessMethod;
405 RLibrary LargeLibrary;
406 TBool LargeLibraryLoaded = EFalse;
407 const TUint8* LargeDataStart;
408 const TUint8* LargeDataEnd;
409 const TUint8* LargeDataPtr;
410 TInt PagesReadSinceLastAccess = 0;
416 TPhysState PhysState;
418 TUint16 CurrentDrive;
419 TInt LocalDriveNumber;
421 RThread RandomAccessThread;
422 volatile TBool RandomAccessKill = EFalse;
424 TBool CanForcePageOut = ETrue;
426 // Utility functions ///////////////////////////////////////////////////////////
428 TPtrC16 GetMediaType(TInt aMediaType)
430 _LIT(KMediaNotPresent, "MediaNotPresent");
431 _LIT(KMediaUnknown, "MediaUnknown");
432 _LIT(KMediaFloppy, "MediaFloppy");
433 _LIT(KMediaHardDisk, "MediaHardDisk");
434 _LIT(KMediaCdRom, "MediaCdRom");
435 _LIT(KMediaRam, "MediaRam");
436 _LIT(KMediaFlash, "MediaFlash");
437 _LIT(KMediaRom, "MediaRom");
438 _LIT(KMediaRemote, "MediaRemote");
439 _LIT(KMediaNANDFlash, "MediaNANDFlash");
440 _LIT(KMediaUnKnown, "MediaUnKnown");
444 case EMediaNotPresent:
445 return KMediaNotPresent();
447 return KMediaUnknown();
449 return KMediaFloppy();
451 return KMediaHardDisk();
453 return KMediaCdRom();
457 return KMediaFlash();
461 return KMediaRemote();
462 case EMediaNANDFlash:
463 return KMediaNANDFlash();
465 return KMediaUnKnown();
469 // Get the list of pageable drives
470 void GetSupportedDrives(TBool aVerbose = EFalse)
474 test.Printf(_L("Supported drives:\n"));
475 test.Printf(_L(" Type Attr MedAttr Filesystem\n"));
479 test_noError(fs.Connect());
481 TDriveList driveList;
482 TDriveInfo driveInfo;
484 TInt r = fs.DriveList(driveList);
487 TBool NandPageableMediaFound = EFalse;
489 for (TInt drvNum=0; drvNum<KMaxDrives; ++drvNum)
491 if(!driveList[drvNum])
492 continue; //-- skip unexisting drive
494 r = fs.Drive(driveInfo, drvNum);
499 r = fs.DriveToChar(drvNum, ch);
502 TBuf<256> fileSystemName;
503 r = fs.FileSystemName(fileSystemName, drvNum);
506 if ((driveInfo.iDriveAtt & KDriveAttPageable) && (driveInfo.iType == EMediaNANDFlash))
507 NandPageableMediaFound = ETrue;
509 TBool pageable = EFalse;
510 if (driveInfo.iDriveAtt & KDriveAttPageable)
513 // If we've already found a pageable NAND drive,
514 // then assume the Z: drive is pageable too if it's got a composite file system
515 _LIT(KCompositeName,"Composite");
516 if ((fileSystemName == KCompositeName()) && NandPageableMediaFound)
522 r = fs.DriveToChar(drvNum, ch);
525 TPagingDriveInfo pagingDriveInfo;
526 pagingDriveInfo.iDriveLetter = ch;
527 pagingDriveInfo.iDriveInfo = driveInfo;
529 r = SupportedDrives.Append(pagingDriveInfo);
535 TPtrC16 mediaType = GetMediaType(driveInfo.iType);
536 _LIT(KPageable, "pageable");
537 test.Printf(_L(" %c: %16S %08x %08x %10S %S\n"),
538 (TInt) ch, &mediaType, driveInfo.iDriveAtt, driveInfo.iMediaAtt,
539 &fileSystemName, (pageable ? &KPageable : &KNullDesC));
547 TInt GetPageState(TAny* aPage)
549 TInt r = UserSvr::HalFunction(EHalGroupVM, EVMPageState, aPage, 0);
554 // Force a page to be paged in or rejuvenated, to simulate aging of pages in the live list
557 // Find a page that's old or paged out
560 LargeDataPtr += PageSize;
561 if (LargeDataPtr >= LargeDataEnd)
562 LargeDataPtr = LargeDataStart;
564 while (GetPageState((TAny*)LargeDataPtr) & EPageStatePteValid);
566 // and read from it to make it young
567 TUint32 value = *(volatile TUint8*)LargeDataPtr;
569 ++PagesReadSinceLastAccess;
574 test_noError(UserSvr::HalFunction(EHalGroupVM,EVMHalFlushCache,0,0));
577 void TestCurrentState()
579 test_Value(State, State >= 0 && State < ENumPageStates);
580 test_Value(PhysState, PhysState >= 0 && PhysState < ENumPhysStates);
582 TInt stateBits = GetPageState((TAny*)Library_TestFunction);
583 TInt expected = ExpectedPageState[State];
584 if (MultipleMemoryModel)
585 expected |= ExpectedPageStateMultipleExtra[State];
586 TUint physStateIgnore = 0;
587 if (FlexibleMemoryModel)
589 expected &= ~EPageStatePageTablePresent; // flexible memory model allocates page tables on demand
590 physStateIgnore = 0xff; // flexible memory model doesn't have separate page types for code/data/ROM
593 test_equal(expected, stateBits & (~PhysStateMask))
594 test_equal(ExpectedPhysState[PhysState] & ~physStateIgnore, stateBits & PhysStateMask & ~physStateIgnore)
597 void TestPageState(TPageState aExpected, TPhysState aExpectedPhys)
599 RDebug::Printf("%d: %-12s %-12s", ProcessNum, StateNames[aExpected], PhysStateNames[aExpectedPhys]);
600 test_equal(State, aExpected);
601 test_equal(PhysState, aExpectedPhys);
605 TInt PathLength(const TStatePath& aPath)
608 while (aPath[i] != EStateUnmapped && i < KMaxPathLen)
613 TInt FindState(const TStatePath& aPath, TPageState aTarget)
615 TInt len = PathLength(aPath);
617 for (j = 1 ; j < len ; ++j)
619 if (aPath[j] == aTarget)
625 TInt WriteByte(TAny* aArg)
627 TUint8* ptr = (TUint8*)aArg;
632 void StartOtherProcess(TInt aProcessNum, RTestSession& aSession)
636 arg.AppendNum(aProcessNum);
637 test_noError(other.Create(me.FileName(), arg));
638 TRequestStatus status;
639 other.Rendezvous(status);
641 User::WaitForRequest(status);
642 test_noError(status.Int());
643 test_equal(EExitPending, other.ExitType());
644 test_noError(aSession.Connect(aProcessNum));
648 const TDesC& LibrarySearchPath(TUint16 aDrive)
650 static TBuf<32> path;
651 path = KSearchPathTemplate;
656 const TDesC& LibraryName(TInt aLibraryNum, TUint16 aDrive)
658 // this gives dlls a different name on each drive so we can be sure we're loading the right one
659 static TBuf<32> name;
662 name.AppendNum(aLibraryNum);
664 name.AppendFormat(_L("_%c"), aDrive);
668 const TDesC& LibraryFilename(TInt aLibraryNum, TUint16 aDrive)
670 static TBuf<40> filename;
671 filename = LibrarySearchPath(aDrive);
672 filename.AppendFormat(_L("\\%S.dll"), &LibraryName(aLibraryNum, aDrive));
676 TInt LoadSpecificLibrary(RLibrary& aLibrary, TInt aLibraryNum, TUint16 aDrive)
678 const TDesC& name = LibraryName(aLibraryNum, aDrive);
679 const TDesC& path = LibrarySearchPath(aDrive);
680 return aLibrary.Load(name, path);
683 TInt GetLocDrvNumber(TUint16 aDrive)
688 TBuf<40> libname = LibraryFilename(1, aDrive);
691 TInt r=file.Open(fs,libname,EFileRead);
693 test.Printf(_L("%d: Error %d: could not open file %S\n"),ProcessNum, r, &libname);
698 r=file.BlockMap(info,start, -1,ETestDebug);
700 if (r!=KErrNone && r!=KErrCompletion)
701 test.Printf(_L("Error %d: could not obtain block map\n"),r);
702 test(r==KErrNone || r==KErrCompletion);
703 TInt locDriveNumber=info.iLocalDriveNumber;
707 return locDriveNumber;
710 void LoadLargeLibrary()
712 test(!LargeLibraryLoaded);
713 test_noError(LoadSpecificLibrary(LargeLibrary, 4, CurrentDrive));
714 TGetAddressOfDataFunction func = (TGetAddressOfDataFunction)LargeLibrary.Lookup(KGetAddressOfDataFunctionOrdinal);
716 LargeDataStart = (TUint8*)func(size);
717 test_notNull(LargeDataStart);
718 if (size < LiveListSize*PageSize)
720 // We need an area of paged data large enough to ensure we can cause a page of our choice to
721 // be paged out. If the size of the live list for testing is too small, we'll skip some tests
722 CanForcePageOut = EFalse;
724 LargeDataEnd = LargeDataStart + size;
725 LargeDataPtr = LargeDataStart;
726 LargeLibraryLoaded = ETrue;
729 void UnloadLargeLibrary()
731 test(LargeLibraryLoaded);
732 LargeLibrary.Close();
733 LargeDataStart = NULL;
736 LargeLibraryLoaded = EFalse;
739 // Page in a page and keep aging it to see if it ever reaches an oldest list.
740 TBool SetHaveOldestLists()
742 AccessMethod = EAccessExec;
744 TInt pagedState = (GetPageState((TAny*)Library_TestFunction) & KPagedStateMask) >> KPagedStateShift;
748 pagedState = (GetPageState((TAny*)Library_TestFunction) & KPagedStateMask) >> KPagedStateShift;
749 if (EStatePagedOldestClean == pagedState || EStatePagedOldestDirty == pagedState)
752 while ( PagesReadSinceLastAccess <= LiveListSize);
754 HaveOldestLists = EStatePagedOldestClean == pagedState || EStatePagedOldestDirty == pagedState;
755 return HaveOldestLists;
758 void SetCurrentDrive(TUint16 aDrive)
760 if (LargeLibraryLoaded)
761 UnloadLargeLibrary();
762 CurrentDrive = aDrive;
763 LocalDriveNumber = GetLocDrvNumber(aDrive);
765 if (!Library_TestFunction)
768 Library_TestFunction = (TTestFunction)PagedLibrary.Lookup(KTestFunctionOrdinal);
769 test_notNull(Library_TestFunction);
770 if (SetHaveOldestLists())
771 TestPath = &TestPathOldest;
773 TestPath = &TestPathNoOldest;
779 // State transition functions //////////////////////////////////////////////////
783 test_noError(LoadSpecificLibrary(PagedLibrary, 1, CurrentDrive));
784 if (MovingMemoryModel)
785 FlushAllPages(); // to make sure pages aren't already mapped
786 LibraryLoaded = ETrue;
791 PagedLibrary.Close();
792 LibraryLoaded = EFalse;
797 switch (AccessMethod)
800 Library_TestFunction();
805 TUint8 x = *(volatile TUint8*)Library_TestFunction;
810 case EAccessAliasRead:
812 TPtrC8 des((TUint8*)Library_TestFunction, 4); // descriptor header must be in different page to data
813 OtherProcess.DesRead(des);
818 PagesReadSinceLastAccess = 0;
823 TInt initialState = GetPageState((TAny*)Library_TestFunction);
826 while (PagesReadSinceLastAccess <= LiveListSize &&
827 initialState == GetPageState((TAny*)Library_TestFunction));
828 TUint pagedState = (GetPageState((TAny*)Library_TestFunction) & KPagedStateMask) >> KPagedStateShift;
829 test_Equal(EStatePagedOld, pagedState);
834 TInt pagedState = (GetPageState((TAny*)Library_TestFunction) & KPagedStateMask) >> KPagedStateShift;
838 pagedState = (GetPageState((TAny*)Library_TestFunction) & KPagedStateMask) >> KPagedStateShift;
839 if (EStatePagedOldestClean == pagedState || EStatePagedOldestDirty == pagedState)
842 while (PagesReadSinceLastAccess <= LiveListSize);
843 test_Value(pagedState, EStatePagedOldestClean == pagedState || EStatePagedOldestDirty == pagedState);
848 TInt finalListState1 = EStatePagedOld;
849 TInt finalListState2 = EStatePagedOld;
852 finalListState1 = EStatePagedOldestClean;
853 finalListState2 = EStatePagedOldestDirty;
856 TInt pagedState = (GetPageState((TAny*)Library_TestFunction) & KPagedStateMask) >> KPagedStateShift;
857 // Get the page onto the final list(s) so it can be detected when it is paged out.
858 while ( pagedState != finalListState1 && pagedState != finalListState2 &&
859 PagesReadSinceLastAccess <= LiveListSize)
862 pagedState = (GetPageState((TAny*)Library_TestFunction) & KPagedStateMask) >> KPagedStateShift;
864 // Now force the page off the paging lists.
865 pagedState = GetPageState((TAny*)Library_TestFunction);
870 while ( PagesReadSinceLastAccess <= LiveListSize &&
871 pagedState == GetPageState((TAny*)Library_TestFunction));
874 // Test functions //////////////////////////////////////////////////////////////
880 TUint32 memModelAttrs = MemModelAttributes();
881 MovingMemoryModel = ((memModelAttrs & EMemModelTypeMask) == EMemModelTypeMoving);
882 MultipleMemoryModel = ((memModelAttrs & EMemModelTypeMask) == EMemModelTypeMultiple);
883 FlexibleMemoryModel = ((memModelAttrs & EMemModelTypeMask) == EMemModelTypeFlexible);
885 test_noError(UserSvr::HalFunction(EHalGroupKernel, EKernelHalPageSizeInBytes, &PageSize, 0));
888 test_noError(UserSvr::HalFunction(EHalGroupVM, EVMHalGetCacheSize, &info, 0));
889 LiveListSize = info.iMaxSize / PageSize;
892 void CopyDllFragmented(RFs& aFs, const TDesC& aSourceName, const TDesC& aDestName)
894 test.Printf(_L(" %S\n"), &aDestName);
896 TInt r = aFs.MkDirAll(aDestName);
897 test(r == KErrNone || r == KErrAlreadyExists);
899 TBuf<40> tempName(aDestName);
900 tempName.Append(_L(".tmp"));
903 test_noError(in.Open(aFs, aSourceName, EFileRead));
904 test_noError(out.Replace(aFs, aDestName, EFileWrite));
905 test_noError(temp.Replace(aFs, tempName, EFileWrite));
907 const TInt KBufferSize = 3333;
908 TBuf8<KBufferSize> buffer;
910 test_noError(temp.Write(buffer));
911 test_noError(temp.Flush());
914 test_noError(in.Size(size));
918 test_noError(in.Read(buffer));
919 test_noError(out.Write(buffer));
920 test_noError(out.Flush());
921 test_noError(temp.Write(buffer));
922 test_noError(temp.Flush());
923 pos += buffer.Length();
931 void CopyDllToSupportedDrives(RFs& aFs, CFileMan* aFileMan, TInt aLibraryNum)
933 TBuf<40> source = LibraryFilename(aLibraryNum, 'Z');
935 test.Printf(_L("Copying %S to:\n"), &source);
937 for (TInt i = 0 ; i < SupportedDrives.Count() ; ++i)
939 TUint8 drive = SupportedDrives[i].iDriveLetter;
940 if (!(SupportedDrives[i].iDriveInfo.iMediaAtt & KMediaAttWriteProtected))
942 TBuf<40> dest = LibraryFilename(aLibraryNum, drive);
943 CopyDllFragmented(aFs, source, dest);
948 void CopyDllsToSupportedDrives()
951 test_noError(fs.Connect());
953 CTrapCleanup* cleanup = CTrapCleanup::New();
954 test_notNull(cleanup);
956 CFileMan* fileMan = NULL;
957 TRAPD(r, fileMan = CFileMan::NewL(fs));
960 for (TInt i = 1 ; i <= 7 ; ++i)
961 CopyDllToSupportedDrives(fs, fileMan, i);
968 void TestStateTransition(TPageState aNext)
970 TPhysState nextPhys = PhysStateFromPageState[aNext];
971 RDebug::Printf("%d: %-12s -> %-12s", ProcessNum, StateNames[State], StateNames[aNext]);
972 TFunc func = StateTransitions[State][aNext];
976 PhysState = nextPhys;
980 void RunPathTest(const TStatePath& aPath, TInt aStart = 0, TInt aEnd = -1)
983 aEnd = PathLength(aPath) - 1;
985 // Check we're already in the starting state
986 TestPageState(aPath[aStart], PhysStateFromPageState[aPath[aStart]]);
988 for (TInt i = aStart + 1 ; i <= aEnd ; ++i)
989 TestStateTransition(aPath[i]);
992 void RunUnmapTest(const TStatePath& aPath)
994 TInt len = PathLength(aPath);
996 // Test an unmodified code paged page can be unmapped from all the possible
997 // states it can be in.
998 TInt endState = EStateOld;
1000 endState = EStateOldestClean;
1002 for (TInt i = EStateUnmapped + 1; i <= endState; ++i)
1004 TPageState target = (TPageState)i;
1005 RDebug::Printf("\nUnmap from %s:\n", StateNames[target]);
1008 memcpy(path, aPath, sizeof(path));
1010 TInt j = FindState(path, target) + 1;
1011 test_Value(j, j > 0 && j < len + 1);
1012 path[j] = EStateUnmapped;
1014 RunPathTest(path, 0, j);
1018 void GoToState(TPageState aState)
1023 State = EStateUnmapped;
1024 PhysState = PhysStateFromPageState[State];
1027 TInt i = FindState(*TestPath, aState);
1029 RunPathTest(*TestPath, 0, i);
1032 void RunMultiProcessTest()
1034 TStatePath& testPath = *TestPath;
1035 TInt len = PathLength(testPath);
1037 TInt endState = EStateOld;
1038 if (HaveOldestLists)
1039 endState = EStateOldestClean;
1040 for (TInt i = EStateUnmapped; i <= endState; ++i)
1042 TPageState target = (TPageState)i;
1043 RDebug::Printf("\nTesting interaction with second process in state %s:\n", StateNames[target]);
1046 TPageState state2 = testPath[0]; // current state in other process
1047 OtherProcess.TestPageState(state2, PhysStateFromPageState[state2]);
1048 for (TInt i = 1 ; i < len ; ++i)
1050 TPageState next2 = testPath[i];
1051 OtherProcess.TestStateTransition(next2);
1053 // Update physical state if affected by transition in other process
1054 if ((State == EStateYoung || State == EStateOld || State == EStateOldestClean) &&
1055 (state2 != EStateUnmapped && next2 != EStateUnmapped))
1056 PhysState = PhysStateFromPageState[next2];
1058 // Update logical state in this process if affected by transition in other process
1059 if (State == EStateYoung && next2 == EStateOld)
1061 else if (State == EStateOld && next2 == EStateOldestClean)
1062 State = EStateOldestClean;
1063 else if ((State == EStateYoung || State == EStateOld || State == EStateOldestClean) &&
1064 (state2 == EStateOld || state2 == EStateOldestClean) && next2 == EStatePagedOut)
1065 State = EStatePagedOut;
1067 RDebug::Printf("%d: %-12s %-12s", ProcessNum, StateNames[State], PhysStateNames[PhysState]);
1076 State = EStateUnmapped;
1077 PhysState = PhysStateFromPageState[State];
1081 void TestReadExportDir()
1084 test_noError(LoadSpecificLibrary(library, 3, CurrentDrive));
1085 TTestFunction func = (TTestFunction)library.Lookup(KTestFunctionOrdinal);
1087 test_noError(func());
1091 void RunReadExportDirTest()
1093 test.Next(_L("Exercise ReadExportDir with one code seg mapped already into current process"));
1095 TestReadExportDir();
1098 test.Next(_L("Exercise ReadExportDir with one code seg mapped into different process"));
1099 OtherProcess.Exec(LoadLibrary);
1100 TestReadExportDir();
1101 OtherProcess.Exec(UnloadLibrary);
1104 void RunWriteToPagedCodeTest()
1106 test.Next(_L("Test writing to paged code"));
1108 RMemoryTestLdd memoryTest;
1109 test(KErrNone==memoryTest.Open());
1112 TUint8* ptr = (TUint8*)LargeDataStart;
1113 while(ptr<LargeDataEnd)
1115 TInt stateBits = GetPageState(ptr);
1116 // write to paged out memory should cause exception...
1117 test(KErrBadDescriptor==memoryTest.WriteMemory(ptr,0));
1118 // page state should be unchanged...
1119 test_equal(stateBits,GetPageState(ptr))
1120 // page-in in memory...
1121 TUint32 value = *(TUint32*)ptr;
1122 // page state should be changed...
1123 test(stateBits!=GetPageState(ptr));
1124 // write to paged out memory should still cause exception...
1125 test(KErrBadDescriptor==memoryTest.WriteMemory(ptr,~value));
1126 // memory should be unchanged...
1127 test(value==*(TUint32*)ptr);
1134 void RunPageLockingTest()
1136 test.Next(_L("Check locking of code which then gets unloaded"));
1138 // load test driver...
1139 test.Start(_L("Load test driver..."));
1140 RDemandPagingTestLdd ldd;
1141 TInt r = User::LoadLogicalDevice(KDemandPagingTestLddName);
1142 test(r==KErrNone || r==KErrAlreadyExists);
1143 test(ldd.Open()==KErrNone);
1145 // load once to get address that code will be loaded at...
1146 test.Next(_L("Load/unload dll"));
1148 test_noError(LoadSpecificLibrary(library, 5, CurrentDrive));
1149 TGetAddressOfRelocatedDataFunction func = (TGetAddressOfRelocatedDataFunction)library.Lookup(KGetAddressOfDataFunctionOrdinal);
1153 // load again and check it's at the same place...
1154 test.Next(_L("Load dll again"));
1155 test_noError(LoadSpecificLibrary(library, 5, CurrentDrive));
1156 TGetAddressOfRelocatedDataFunction func2 = (TGetAddressOfRelocatedDataFunction)library.Lookup(KGetAddressOfDataFunctionOrdinal);
1157 test_equal(func,func2);
1159 // get address of data in the DLL...
1160 test.Next(_L("Get data from DLL"));
1164 void** data = func(size,d,c);
1167 test.Next(_L("Lock DLL data"));
1168 r = ldd.Lock(data,size);
1172 test.Next(_L("Check DLL data"));
1173 for (TInt i = 0 ; i < size / 4 ; i+=2)
1175 test_equal(c, data[i]);
1176 test_equal(d, data[i+1]);
1180 test.Next(_L("Close DLL"));
1182 User::After(1000000);
1184 if(!FlexibleMemoryModel) // flexible memory model doesn't actually hog virtual address when locked (pinned)
1186 // load again and check it's at a different place
1187 // (because the locked memory is hogging the old place)...
1188 test.Next(_L("Check DLL loaded at different address"));
1189 test_noError(LoadSpecificLibrary(library, 5, CurrentDrive));
1190 func2 = (TGetAddressOfRelocatedDataFunction)library.Lookup(KGetAddressOfDataFunctionOrdinal);
1193 User::After(1000000);
1196 test.Next(_L("Unlock DLL data"));
1198 User::After(1000000);
1200 // load again and check it's back at the original place
1201 // (because the locked memory now gone)...
1202 test.Next(_L("Check DLL loaded at original address"));
1203 test_noError(LoadSpecificLibrary(library, 5, CurrentDrive));
1204 func2 = (TGetAddressOfRelocatedDataFunction)library.Lookup(KGetAddressOfDataFunctionOrdinal);
1210 test.Next(_L("Cleanup"));
1216 void TestContentsOfPagedDll()
1218 test.Next(_L("Test that the contents of a paged DLL are as expected"));
1221 test_noError(LoadSpecificLibrary(library2, 2, CurrentDrive));
1223 TGetAddressOfDataFunction func = (TGetAddressOfDataFunction)library2.Lookup(KGetAddressOfDataFunctionOrdinal);
1231 // Data contents are psuedorandom numbers generated according to the following scheme
1232 const TInt A = 1664525;
1233 const TInt B = 1013904223;
1235 for (TInt i = 0 ; i < size / 4 ; ++i)
1238 test_equal(v, data[i]);
1245 void CheckRelocatableData(RLibrary& library)
1247 TGetAddressOfRelocatedDataFunction func = (TGetAddressOfRelocatedDataFunction)library.Lookup(KGetAddressOfDataFunctionOrdinal);
1252 void** data = func(size,d,c);
1253 test_equal(d, data);
1254 for (TInt i = 0 ; i < size / 4 ; i+=2)
1256 test_equal(c, data[i]);
1257 test_equal(d, data[i+1]);
1262 void OtherProcessCheckRelocatableData()
1265 test_noError(LoadSpecificLibrary(library, 7, CurrentDrive));
1266 CheckRelocatableData(library);
1271 void TestContentsOfPagedDllWithRelocatedData()
1273 test.Next(_L("Test relocated const data in DLL"));
1274 PagingInfo::ResetBenchmarks();
1276 test_noError(LoadSpecificLibrary(library, 5, CurrentDrive));
1277 CheckRelocatableData(library);
1279 PagingInfo::PrintBenchmarks(); // worst case fixups
1281 test.Next(_L("Test relocated writable data in DLL"));
1282 test_noError(LoadSpecificLibrary(library, 6, CurrentDrive));
1283 CheckRelocatableData(library);
1286 test.Next(_L("Test relocated writable data in dependent DLL"));
1287 test_noError(LoadSpecificLibrary(library, 7, CurrentDrive));
1288 CheckRelocatableData(library);
1291 test.Next(_L("Test relocated writable data in preloaded dependent DLL"));
1293 test_noError(LoadSpecificLibrary(library2, 6, CurrentDrive));
1294 test_noError(LoadSpecificLibrary(library, 7, CurrentDrive));
1295 CheckRelocatableData(library);
1299 test.Next(_L("Test relocated writable data in preloaded dependent DLL opened in other process"));
1300 test_noError(LoadSpecificLibrary(library2, 6, CurrentDrive));
1301 OtherProcess.Exec(OtherProcessCheckRelocatableData);
1306 TInt RandomAccessFunc(TAny* aArg)
1308 const TUint8* dataStart = LargeDataStart;
1309 const TUint8* dataEnd = LargeDataEnd;
1310 TInt size = dataEnd - dataStart;
1311 TUint32 random = (User::FastCounter() << 8) | ProcessNum;
1313 while (!RandomAccessKill)
1315 random = random*69069+1;
1316 TInt offset = random % size;
1317 TInt value = dataStart[offset];
1318 if (offset != 0 && value != 0)
1323 RDebug::Printf("%d: Performed %d accesses", ProcessNum, i);
1327 void StartRandomAccessThread(TThreadPriority aPriority)
1329 RandomAccessKill = EFalse;
1330 test_noError(RandomAccessThread.Create(_L("RandomAccessThread"), RandomAccessFunc, 4096, NULL, 0));
1331 RDebug::Printf("%d: starting thread with priority %d", ProcessNum, aPriority);
1332 RandomAccessThread.SetPriority(aPriority);
1333 RandomAccessThread.Resume();
1336 void KillRandomAccessThread()
1338 test_equal(EExitPending, RandomAccessThread.ExitType());
1339 TRequestStatus status;
1340 RandomAccessThread.Logon(status);
1341 RandomAccessKill = ETrue;
1342 User::WaitForRequest(status);
1343 test_equal(EExitKill, RandomAccessThread.ExitType());
1344 test_equal(0, RandomAccessThread.ExitReason());
1345 RandomAccessThread.Close();
1346 PagedLibrary.Close();
1349 void TestLargeDll(TInt aDelay)
1351 test.Next(_L("Test random access to a large dll"));
1352 StartRandomAccessThread(EPriorityLess);
1353 User::After(aDelay * 1000000);
1354 KillRandomAccessThread();
1357 void TestKillThreadWhilePaging()
1359 test.Next(_L("Test killing a thread while it is taking paging faults"));
1360 for (TInt i = 0 ; i < 50 ; ++i)
1362 RDebug::Printf(" iteration %d", i);
1363 StartRandomAccessThread(EPriorityLess);
1364 User::After(10000); // time for ~ 10 paging requests
1365 test_equal(EExitPending, RandomAccessThread.ExitType());
1366 TRequestStatus status;
1367 RandomAccessThread.Logon(status);
1368 RandomAccessThread.Terminate(666);
1369 User::WaitForRequest(status);
1370 test_equal(EExitTerminate, RandomAccessThread.ExitType());
1371 test_equal(666, RandomAccessThread.ExitReason());
1372 RandomAccessThread.Close();
1373 PagedLibrary.Close();
1377 void TestUnloadDllWhilePaging()
1379 test.Next(_L("Test unloading a library while another thread is accessing it"));
1380 OtherProcess.Exec(UnloadLargeLibrary);
1381 for (TInt i = 0 ; i < 50 ; ++i)
1383 RDebug::Printf(" iteration %d", i);
1384 StartRandomAccessThread(EPriorityLess);
1385 User::After(10000); // time for ~ 10 paging requests
1386 test_equal(EExitPending, RandomAccessThread.ExitType());
1387 TRequestStatus status;
1388 RandomAccessThread.Logon(status);
1389 UnloadLargeLibrary();
1390 PagedLibrary.Close();
1391 User::WaitForRequest(status);
1392 test_equal(EExitPanic, RandomAccessThread.ExitType());
1393 test_equal(3, RandomAccessThread.ExitReason()); // KERN-EXEC 3
1394 RandomAccessThread.Close();
1397 OtherProcess.Exec(LoadLargeLibrary);
1400 void PrintElapsedTime(TTime& aStartTime)
1403 timeNow.UniversalTime();
1404 TTimeIntervalSeconds elapsed;
1405 test_noError(timeNow.SecondsFrom(aStartTime, elapsed));
1406 test.Printf(_L("%d seconds elapsed\n"), elapsed.Int());
1409 void TestManyProcesses(TInt aCount, TInt aDelay, TInt aPriorities = 1)
1412 name.AppendFormat(_L("Test accessing paged code from %d processes at %d priority level(s) for %d seconds"),
1413 aCount, aPriorities, aDelay);
1417 startTime.UniversalTime();
1419 // start subprocesses and let them initialise
1420 RArray<RTestSession> processes;
1421 TInt threadsAtEachPriority = aCount / aPriorities;
1422 for (TInt i = 0 ; i < aCount ; ++i)
1425 StartOtherProcess(i + 3, sess);
1426 test_noError(processes.Append(sess));
1427 sess.SetCurrentDrive(CurrentDrive);
1429 test.Printf(_L("Started subprocesses: "));
1430 PrintElapsedTime(startTime);
1432 // then start random accesses to paged memory
1433 for (TInt i = 0 ; i < aCount ; ++i)
1435 TThreadPriority pri;
1436 switch (i / threadsAtEachPriority)
1438 case 0: pri = EPriorityLess; break;
1439 default: pri = EPriorityMuchLess; break;
1441 processes[i].StartRandomAccessThread(pri);
1443 test.Printf(_L("Started threads: "));
1444 PrintElapsedTime(startTime);
1446 test_noError(PagingInfo::ResetAll(LocalDriveNumber,EMediaPagingStatsCode));
1447 User::After(aDelay * 1000000);
1448 test_noError(PagingInfo::PrintAll(LocalDriveNumber,EMediaPagingStatsCode));
1450 test.Printf(_L("Killing subprocesses: "));
1451 PrintElapsedTime(startTime);
1453 for (TInt i = 0 ; i < aCount ; ++i)
1455 processes[i].Exec(KillRandomAccessThread);
1456 processes[i].Kill();
1457 processes[i].Close();
1460 test.Printf(_L("Test finished: "));
1461 PrintElapsedTime(startTime);
1466 void TestCacheSize()
1468 test.Next(_L("Test cache size within bounds"));
1471 TUint currentSize = 0;
1472 DPTest::CacheSize(sizeMin,sizeMax,currentSize);
1473 test.Printf(_L(" minimum size == %d pages\n"), sizeMin >> 12);
1474 test.Printf(_L(" maximum size == %d pages\n"), sizeMax >> 12);
1475 test.Printf(_L(" current size == %d pages\n"), currentSize >> 12);
1476 test(currentSize >= sizeMin);
1477 test(currentSize <= sizeMax);
1480 void RunUnalignedAliasAccessTest()
1482 test.Next(_L("Test accesses to aliased non-word-aligned data"));
1484 for (TInt size = 0 ; size <= 28 ; ++ size)
1486 test.Printf(_L(" size = %d:"), size);
1487 for (TInt align = 0 ; align <= 3 ; ++align)
1489 test.Printf(_L(" %d"), align);
1490 TPtrC8 des(LargeDataStart + align, size);
1492 OtherProcess.DesRead(des);
1494 test.Printf(_L("\n"));
1498 void TestCodeChunkCreated()
1501 TAny* func = (TAny*)PagedLibrary.Lookup(KTestFunctionOrdinal);
1504 test(GetPageState(func) & EPageStateCodeChunkPresent);
1507 test(!(GetPageState(func) & EPageStateCodeChunkPresent));
1510 void TestRepeatedLoading()
1512 test.Next(_L("Test loading/unloading a DLL doesn't leak address space"));
1514 for (TInt dll = 1 ; dll <= 7 ; ++dll)
1516 test.Printf(_L(" trying dll %d...\n"), dll);
1519 test_noError(LoadSpecificLibrary(library, dll, CurrentDrive));
1520 TLibraryFunction func1 = library.Lookup(1);
1523 test_noError(LoadSpecificLibrary(library, dll, CurrentDrive));
1524 TLibraryFunction func2 = library.Lookup(1);
1527 test_equal(func1, func2);
1531 void RunDriveIndependantTests()
1533 if (MultipleMemoryModel)
1535 test.Next(_L("Test code chunk created and destroyed correctly"));
1536 TestCodeChunkCreated();
1539 SetCurrentDrive('Z');
1541 if (CanForcePageOut)
1543 test.Next(_L("Test accessing pages by executing code"));
1544 AccessMethod = EAccessExec;
1545 RunPathTest(*TestPath);
1547 test.Next(_L("Test accessing pages by reading code"));
1548 AccessMethod = EAccessRead;
1549 RunPathTest(*TestPath);
1551 if (!MovingMemoryModel)
1553 test.Next(_L("Test accessing pages by reading code from another process via an alias"));
1554 AccessMethod = EAccessAliasRead;
1555 RunPathTest(*TestPath);
1558 test.Next(_L("Test unmapping paged code"));
1559 AccessMethod = EAccessExec;
1560 RunUnmapTest(*TestPath);
1562 if (!MovingMemoryModel)
1564 test.Next(_L("Test interactions between two processes"));
1565 RunMultiProcessTest();
1569 RunReadExportDirTest();
1570 RunPageLockingTest();
1571 RunWriteToPagedCodeTest();
1572 RunUnalignedAliasAccessTest();
1573 TestRepeatedLoading();
1576 void RunPerDriveTests()
1578 TestContentsOfPagedDll();
1579 TestContentsOfPagedDllWithRelocatedData();
1580 TestKillThreadWhilePaging();
1581 TestUnloadDllWhilePaging();
1585 TestManyProcesses(2, 5, 1);
1586 TestManyProcesses(5, 10, 1);
1587 TestManyProcesses(10, 20, 1);
1588 TestManyProcesses(5, 10, 2);
1589 TestManyProcesses(50, 2, 1);
1595 RunDriveIndependantTests();
1597 for (TInt i = 0 ; i < SupportedDrives.Count() ; ++i)
1599 SetCurrentDrive(SupportedDrives[i].iDriveLetter);
1600 OtherProcess.SetCurrentDrive(CurrentDrive);
1603 message.AppendFormat(_L("Running tests on drive %c:"), (TUint) SupportedDrives[i].iDriveLetter);
1610 // Server implementation ///////////////////////////////////////////////////////
1612 class CTestSession : public CSession2
1615 virtual void ServiceL(const RMessage2& aMessage);
1618 void CTestSession::ServiceL(const RMessage2& aMessage)
1621 switch (aMessage.Function())
1623 case RTestSession::EKill:
1624 CActiveScheduler::Stop();
1627 case RTestSession::EExec:
1628 ((TFunc)aMessage.Int0())();
1631 case RTestSession::ESetCurrentDrive:
1632 SetCurrentDrive(aMessage.Int0());
1635 case RTestSession::EDesRead:
1638 if (buf.MaxSize() < aMessage.GetDesLength(0))
1641 r = aMessage.Read(0, buf);
1645 case RTestSession::ETestPageState:
1646 TestPageState((TPageState)aMessage.Int0(), (TPhysState)aMessage.Int1());
1649 case RTestSession::ETestStateTransition:
1650 TestStateTransition((TPageState)aMessage.Int0());
1653 case RTestSession::EStartRandomAccessThread:
1654 StartRandomAccessThread((TThreadPriority)aMessage.Int0());
1658 r = KErrNotSupported;
1662 aMessage.Complete(r);
1665 class CTestServer : public CServer2
1668 CTestServer() : CServer2(0) { }
1669 virtual CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const;
1672 CSession2* CTestServer::NewSessionL(const TVersion& /*aVersion*/,const RMessage2& /*aMessage*/) const
1674 return new (ELeave) CTestSession();
1677 void DoStartServerL()
1679 CActiveScheduler* activeScheduler = new CActiveScheduler;
1680 test_notNull(activeScheduler);
1681 CActiveScheduler::Install(activeScheduler);
1682 CTestServer* server = new CTestServer();
1683 test_notNull(server);
1685 name.AppendFormat(_L("%S-%d"), &KServerName, ProcessNum);
1686 test_noError(server->Start(name));
1687 RProcess().Rendezvous(KErrNone);
1688 CActiveScheduler::Start();
1690 delete activeScheduler;
1695 CTrapCleanup* cleanupStack = CTrapCleanup::New();
1696 test_notNull(cleanupStack);
1697 TRAPD(leaveError,DoStartServerL());
1698 test_noError(leaveError);
1699 delete cleanupStack;
1702 void SecondaryProcess()
1705 User::CommandLine(cmd);
1707 lex.Val(ProcessNum);
1710 name.AppendFormat(_L("t_codepaging-%d"), ProcessNum);
1712 test_noError(me.RenameMe(name));
1714 GetSupportedDrives(EFalse);
1716 SetCurrentDrive('Z');
1725 test.Start(_L("Code paging tests"));
1727 TUint32 memModelAttributes=UserSvr::HalFunction(EHalGroupKernel, EKernelHalMemModelInfo, NULL, NULL);
1728 TUint32 pagingPolicy = E32Loader::PagingPolicy();
1729 TBool codePagingSupported = (memModelAttributes & EMemModelAttrCodePaging) != 0;
1730 TBool pagingPolicyAllowsPaging = pagingPolicy != EKernelConfigCodePagingPolicyNoPaging;
1731 test_Equal(codePagingSupported, pagingPolicyAllowsPaging);
1732 if(!codePagingSupported)
1734 test.Printf(_L("TESTS NOT RUN - Code paging not enabled on system.\n"));
1739 GetSupportedDrives(ETrue);
1740 test(SupportedDrives.Count() > 0);
1742 // Turn off evil lazy dll unloading
1744 test(l.Connect()==KErrNone);
1745 test(l.CancelLazyDllUnload()==KErrNone);
1748 CopyDllsToSupportedDrives();
1752 StartOtherProcess(2, OtherProcess);
1756 OtherProcess.Kill();
1757 OtherProcess.Close();
1764 if (User::CommandLineLength() == 0)