sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test\demandpaging\t_dpapi.cpp sl@0: // sl@0: // sl@0: sl@0: // sl@0: #define __E32TEST_EXTENSION__ sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "u32std.h" sl@0: sl@0: #include "t_dpcmn.h" sl@0: sl@0: RTest test(_L("T_DPAPI")); sl@0: sl@0: TInt TestingTChunkCreate(); sl@0: TInt TestingTChunkHeapCreate(); sl@0: TInt TestingTThreadCreate(); sl@0: sl@0: void TestGlobalConfig() sl@0: { sl@0: test_Equal(gDataPagingSupported, gDataPagingPolicy != EKernelConfigDataPagingPolicyNoPaging); sl@0: } sl@0: sl@0: enum TPagedSetting sl@0: { sl@0: EDefault, sl@0: EPaged, sl@0: EUnpaged sl@0: }; sl@0: sl@0: TPagedSetting GetMmpPagedSetting() sl@0: { sl@0: // t_dpapi suffixes: sl@0: // c => ram loaded code sl@0: // p => pageddata sl@0: // u => unpageddata sl@0: sl@0: TFileName name = RProcess().FileName(); sl@0: test.Printf(_L("%S\n"), &name); sl@0: TInt pos = name.LocateReverse('\\'); sl@0: test(pos >= 0 && pos < (name.Length() - 1)); sl@0: TPtrC leaf = name.Mid(pos + 1); sl@0: if (leaf == _L("t_dpapi_p.exe") || leaf == _L("t_dpapi_cp.exe")) sl@0: return EPaged; sl@0: else if (leaf == _L("t_dpapi_u.exe") || leaf == _L("t_dpapi_cu.exe")) sl@0: return EUnpaged; sl@0: test(leaf == _L("t_dpapi.exe") || leaf == _L("t_dpapi_c.exe")); sl@0: return EDefault; sl@0: } sl@0: sl@0: TPagedSetting ExpectedProcessPagedSetting(TPagedSetting aMmpPagedSetting) sl@0: { sl@0: switch (gDataPagingPolicy) sl@0: { sl@0: case EKernelConfigDataPagingPolicyAlwaysPage: sl@0: return EPaged; sl@0: sl@0: case EKernelConfigDataPagingPolicyNoPaging: sl@0: return EUnpaged; sl@0: sl@0: case EKernelConfigDataPagingPolicyDefaultUnpaged: sl@0: return aMmpPagedSetting == EDefault ? EUnpaged : aMmpPagedSetting; sl@0: sl@0: case EKernelConfigDataPagingPolicyDefaultPaged: sl@0: return aMmpPagedSetting == EDefault ? EPaged : aMmpPagedSetting; sl@0: sl@0: default: sl@0: test(EFalse); sl@0: } sl@0: return EDefault; sl@0: } sl@0: sl@0: void TestMmpFileDataPagedKeyword() sl@0: { sl@0: TPagedSetting expected = ExpectedProcessPagedSetting(GetMmpPagedSetting()); sl@0: TPagedSetting actual = gProcessPaged ? EPaged : EUnpaged; sl@0: test_Equal(expected, actual); sl@0: } sl@0: sl@0: TInt E32Main() sl@0: { sl@0: test.Title(); sl@0: test_KErrNone(GetGlobalPolicies()); sl@0: sl@0: test.Start(_L("Test global datapaging configuration")); sl@0: TestGlobalConfig(); sl@0: sl@0: test.Next(_L("Test mmp file data paged keyword")); sl@0: TestMmpFileDataPagedKeyword(); sl@0: sl@0: test.Next(_L("TestingTChunkCreate")); sl@0: TestingTChunkCreate(); sl@0: sl@0: test.Next(_L("TestingTThreadCreate")); sl@0: TestingTThreadCreate(); sl@0: sl@0: test.Next(_L("TestingTChunkHeapCreate")); sl@0: TestingTChunkHeapCreate(); sl@0: sl@0: test.End(); sl@0: return 0; sl@0: }