1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/demandpaging/t_dpapi.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,119 @@
1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// e32test\demandpaging\t_dpapi.cpp
1.18 +//
1.19 +//
1.20 +
1.21 +//
1.22 +#define __E32TEST_EXTENSION__
1.23 +#include <e32test.h>
1.24 +#include <dptest.h>
1.25 +#include <e32hal.h>
1.26 +#include <u32exec.h>
1.27 +#include <e32svr.h>
1.28 +#include <e32panic.h>
1.29 +#include "u32std.h"
1.30 +
1.31 +#include "t_dpcmn.h"
1.32 +
1.33 +RTest test(_L("T_DPAPI"));
1.34 +
1.35 +TInt TestingTChunkCreate();
1.36 +TInt TestingTChunkHeapCreate();
1.37 +TInt TestingTThreadCreate();
1.38 +
1.39 +void TestGlobalConfig()
1.40 + {
1.41 + test_Equal(gDataPagingSupported, gDataPagingPolicy != EKernelConfigDataPagingPolicyNoPaging);
1.42 + }
1.43 +
1.44 +enum TPagedSetting
1.45 + {
1.46 + EDefault,
1.47 + EPaged,
1.48 + EUnpaged
1.49 + };
1.50 +
1.51 +TPagedSetting GetMmpPagedSetting()
1.52 + {
1.53 + // t_dpapi suffixes:
1.54 + // c => ram loaded code
1.55 + // p => pageddata
1.56 + // u => unpageddata
1.57 +
1.58 + TFileName name = RProcess().FileName();
1.59 + test.Printf(_L("%S\n"), &name);
1.60 + TInt pos = name.LocateReverse('\\');
1.61 + test(pos >= 0 && pos < (name.Length() - 1));
1.62 + TPtrC leaf = name.Mid(pos + 1);
1.63 + if (leaf == _L("t_dpapi_p.exe") || leaf == _L("t_dpapi_cp.exe"))
1.64 + return EPaged;
1.65 + else if (leaf == _L("t_dpapi_u.exe") || leaf == _L("t_dpapi_cu.exe"))
1.66 + return EUnpaged;
1.67 + test(leaf == _L("t_dpapi.exe") || leaf == _L("t_dpapi_c.exe"));
1.68 + return EDefault;
1.69 + }
1.70 +
1.71 +TPagedSetting ExpectedProcessPagedSetting(TPagedSetting aMmpPagedSetting)
1.72 + {
1.73 + switch (gDataPagingPolicy)
1.74 + {
1.75 + case EKernelConfigDataPagingPolicyAlwaysPage:
1.76 + return EPaged;
1.77 +
1.78 + case EKernelConfigDataPagingPolicyNoPaging:
1.79 + return EUnpaged;
1.80 +
1.81 + case EKernelConfigDataPagingPolicyDefaultUnpaged:
1.82 + return aMmpPagedSetting == EDefault ? EUnpaged : aMmpPagedSetting;
1.83 +
1.84 + case EKernelConfigDataPagingPolicyDefaultPaged:
1.85 + return aMmpPagedSetting == EDefault ? EPaged : aMmpPagedSetting;
1.86 +
1.87 + default:
1.88 + test(EFalse);
1.89 + }
1.90 + return EDefault;
1.91 + }
1.92 +
1.93 +void TestMmpFileDataPagedKeyword()
1.94 + {
1.95 + TPagedSetting expected = ExpectedProcessPagedSetting(GetMmpPagedSetting());
1.96 + TPagedSetting actual = gProcessPaged ? EPaged : EUnpaged;
1.97 + test_Equal(expected, actual);
1.98 + }
1.99 +
1.100 +TInt E32Main()
1.101 + {
1.102 + test.Title();
1.103 + test_KErrNone(GetGlobalPolicies());
1.104 +
1.105 + test.Start(_L("Test global datapaging configuration"));
1.106 + TestGlobalConfig();
1.107 +
1.108 + test.Next(_L("Test mmp file data paged keyword"));
1.109 + TestMmpFileDataPagedKeyword();
1.110 +
1.111 + test.Next(_L("TestingTChunkCreate"));
1.112 + TestingTChunkCreate();
1.113 +
1.114 + test.Next(_L("TestingTThreadCreate"));
1.115 + TestingTThreadCreate();
1.116 +
1.117 + test.Next(_L("TestingTChunkHeapCreate"));
1.118 + TestingTChunkHeapCreate();
1.119 +
1.120 + test.End();
1.121 + return 0;
1.122 + }