os/kernelhwsrv/kerneltest/f32test/demandpaging/t_ramstress.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // f32test\demandpaging\t_ramstress.cpp
    15 // Following this, it requests that the driver continuously attempt 
    16 // to move pages directly.
    17 // Platforms/Drives/Compatibility:
    18 // Hardware only. No defrag support on emulator. 	
    19 // 
    20 //
    21 
    22 //! @SYMTestCaseID				KBASE-t_ramstress-0606
    23 //! @SYMTestType				CT
    24 //! @SYMTestCaseDesc			RAM Defrag background defrag stresser 
    25 //! @SYMPREQ					PREQ308
    26 //! @SYMTestPriority			High
    27 //! @SYMTestActions				t_ramstress loads and opens the logical device driver ("D_RAMSTRESS"). 
    28 //! @SYMTestExpectedResults		Finishes if the system behaves as expected, panics otherwise
    29 //! @SYMTestPriority			High
    30 //! @SYMTestStatus				Implemented
    31 //-------------------------------------------------------------------------------------------------
    32 #include <e32test.h>
    33 #include <u32hal.h>
    34 #include <f32file.h>
    35 #include <e32svr.h>
    36 #include <hal.h>
    37 #include "t_ramstress.h"
    38 
    39 RTest test(_L("T_RAMSTRESS"));
    40 
    41 RRamStressTestLdd  RamstressLdd;
    42 
    43 
    44 //
    45 // E32Main
    46 //
    47 // Main entry point.
    48 //
    49 
    50 TInt E32Main()
    51 	{
    52 	test.Title();
    53 	test.Start(_L("RAM Defrag background stress testing..."));
    54 
    55 	TBuf<256> args;
    56 	User::CommandLine(args);
    57 	TLex	lex(args);
    58 	TPtrC  token=lex.NextToken();
    59 	if (token.Length() != 0)
    60 		{
    61 		// exit immediately if we are run as part of autotest
    62 		test.End();
    63 		return KErrNone;
    64 		}
    65 
    66 	TInt r = User::LoadLogicalDevice(KRamStressTestLddName);
    67 	test(r==KErrNone || r==KErrAlreadyExists);
    68 	test(RamstressLdd.Open()==KErrNone);
    69 
    70 	TUint zoneCount = 0;
    71 	TInt ret = UserSvr::HalFunction(EHalGroupRam,ERamHalGetZoneCount,&zoneCount,0);
    72 	test(ret == KErrNone);
    73 	test(zoneCount != 0);
    74 
    75 	TUint index;
    76 	TInt iters = 0;
    77 	while (1)
    78 		{
    79 		for (index = 0; index < zoneCount; index ++)
    80 			{
    81 			RamstressLdd.DoMovePagesInZone(index);
    82 			User::AfterHighRes(1000);
    83 			}
    84 		//## mDH make it run forever iters ++;
    85 		if (iters > 1000000)
    86 			{
    87 			break;
    88 			}
    89 		}
    90 	RamstressLdd.Close();
    91 	test.Next(_L("Ram Defrag : Done"));
    92 	test.End();
    93 	return KErrNone;
    94 	}