os/kernelhwsrv/kerneltest/e32test/demandpaging/t_dpapi.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2008-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 // e32test\demandpaging\t_dpapi.cpp
    15 // 
    16 //
    17 
    18 //
    19 #define __E32TEST_EXTENSION__
    20 #include <e32test.h>
    21 #include <dptest.h>
    22 #include <e32hal.h>
    23 #include <u32exec.h>
    24 #include <e32svr.h>
    25 #include <e32panic.h>
    26 #include "u32std.h"
    27 
    28 #include "t_dpcmn.h"
    29 
    30 RTest test(_L("T_DPAPI"));
    31 
    32 TInt TestingTChunkCreate();
    33 TInt TestingTChunkHeapCreate();
    34 TInt TestingTThreadCreate();
    35 
    36 void TestGlobalConfig()
    37 	{
    38 	test_Equal(gDataPagingSupported, gDataPagingPolicy != EKernelConfigDataPagingPolicyNoPaging);
    39 	}
    40 
    41 enum TPagedSetting
    42 	{
    43 	EDefault,
    44 	EPaged,
    45 	EUnpaged
    46 	};
    47 
    48 TPagedSetting GetMmpPagedSetting()
    49 	{
    50 	// t_dpapi suffixes:
    51 	//   c => ram loaded code
    52 	//   p => pageddata
    53 	//   u => unpageddata
    54 	
    55 	TFileName name = RProcess().FileName();
    56 	test.Printf(_L("%S\n"), &name);
    57 	TInt pos = name.LocateReverse('\\');
    58 	test(pos >= 0 && pos < (name.Length() - 1));
    59 	TPtrC leaf = name.Mid(pos + 1);
    60 	if (leaf == _L("t_dpapi_p.exe") || leaf == _L("t_dpapi_cp.exe"))
    61 		return EPaged;
    62 	else if (leaf == _L("t_dpapi_u.exe") || leaf == _L("t_dpapi_cu.exe"))
    63 		return EUnpaged;
    64 	test(leaf == _L("t_dpapi.exe") || leaf == _L("t_dpapi_c.exe"));
    65 	return EDefault;
    66 	}
    67 
    68 TPagedSetting ExpectedProcessPagedSetting(TPagedSetting aMmpPagedSetting)
    69 	{
    70 	switch (gDataPagingPolicy)
    71 		{
    72 		case EKernelConfigDataPagingPolicyAlwaysPage:
    73 			return EPaged;
    74 
    75 		case EKernelConfigDataPagingPolicyNoPaging:
    76 			return EUnpaged;
    77 
    78 		case EKernelConfigDataPagingPolicyDefaultUnpaged:
    79 			return aMmpPagedSetting == EDefault ? EUnpaged : aMmpPagedSetting;
    80 			
    81 		case EKernelConfigDataPagingPolicyDefaultPaged:
    82 			return aMmpPagedSetting == EDefault ? EPaged : aMmpPagedSetting;
    83 
    84 		default:
    85 			test(EFalse);
    86 		}
    87 	return EDefault;
    88 	}
    89 	
    90 void TestMmpFileDataPagedKeyword()
    91 	{
    92 	TPagedSetting expected = ExpectedProcessPagedSetting(GetMmpPagedSetting());
    93 	TPagedSetting actual = gProcessPaged ? EPaged : EUnpaged;
    94 	test_Equal(expected, actual);
    95 	}
    96 
    97 TInt E32Main()
    98 	{
    99 	test.Title();
   100 	test_KErrNone(GetGlobalPolicies());
   101 
   102 	test.Start(_L("Test global datapaging configuration"));
   103 	TestGlobalConfig();
   104 	
   105 	test.Next(_L("Test mmp file data paged keyword"));
   106 	TestMmpFileDataPagedKeyword();
   107 	
   108 	test.Next(_L("TestingTChunkCreate"));
   109 	TestingTChunkCreate();
   110 	
   111 	test.Next(_L("TestingTThreadCreate"));
   112 	TestingTThreadCreate();
   113 	
   114 	test.Next(_L("TestingTChunkHeapCreate"));
   115 	TestingTChunkHeapCreate();
   116 	
   117 	test.End();
   118 	return 0;
   119 	}