kerneltest/e32test/secure/t_suser.cpp
changeset 286 48e57fb1237e
parent 133 2a0ada0a1bf8
equal deleted inserted replaced
285:ff5437e4337c 286:48e57fb1237e
     1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2001-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    42 #include <e32test.h>
    42 #include <e32test.h>
    43 #include <e32svr.h>
    43 #include <e32svr.h>
    44 #include <nkern/nk_trace.h>
    44 #include <nkern/nk_trace.h>
    45 #include <e32hal.h>
    45 #include <e32hal.h>
    46 #include <hal.h>
    46 #include <hal.h>
       
    47 #include "testexclusions.h"
    47 
    48 
    48 LOCAL_D RTest test(_L("T_SUSER"));
    49 LOCAL_D RTest test(_L("T_SUSER"));
    49 
    50 
    50 _LIT(KSyncSemaphoreName,"T_SUSER-SyncSemaphore");
    51 _LIT(KSyncSemaphoreName,"T_SUSER-SyncSemaphore");
    51 RSemaphore SyncSemaphore;
    52 RSemaphore SyncSemaphore;
       
    53 TBool gControllerShutdownDisabled = EFalse;
       
    54 TInt gTestExclusions = 0;
    52 
    55 
    53 
    56 
    54 void SlaveWait()
    57 void SlaveWait()
    55 	{
    58 	{
    56 	RSemaphore sem;
    59 	RSemaphore sem;
   317 	ETestProcessChangeLocale,
   320 	ETestProcessChangeLocale,
   318 	ETestProcessSaveSystemSettings,
   321 	ETestProcessSaveSystemSettings,
   319 	ETestProcessSetCurrencySymbol,
   322 	ETestProcessSetCurrencySymbol,
   320 	ETestProcessAddEventESwitchOff,
   323 	ETestProcessAddEventESwitchOff,
   321 	ETestProcessAddEventECaseOpen,
   324 	ETestProcessAddEventECaseOpen,
   322 	ETestProcessAddEventECaseClose
   325 	ETestProcessAddEventECaseClose,
       
   326 	ETestProcessPowerHalTestMode,
       
   327 	ETestProcessGetTestExclusions
   323 	};
   328 	};
   324 
   329 
   325 #include "testprocess.h"
   330 #include "testprocess.h"
   326 
   331 
   327 const TInt KMachineConfigSize = 1024;
   332 const TInt KMachineConfigSize = 1024;
   530 		TRawEvent event;
   535 		TRawEvent event;
   531 		event.Set(TRawEvent::ECaseClose);
   536 		event.Set(TRawEvent::ECaseClose);
   532 		return UserSvr::AddEvent(event);
   537 		return UserSvr::AddEvent(event);
   533 		}
   538 		}
   534 
   539 
       
   540 	case ETestProcessPowerHalTestMode:
       
   541 		{
       
   542 		return UserSvr::HalFunction(EHalGroupPower, EPowerHalPowerManagerTestMode, (TAny*)KDisableControllerShutdown, NULL);
       
   543 		}
       
   544 		
       
   545 	case ETestProcessGetTestExclusions:
       
   546 		{
       
   547 		return GetTestExclusionSettings(gTestExclusions);
       
   548 		}
       
   549 
   535 	default:
   550 	default:
   536 		User::Panic(_L("T_SUSER"),1);
   551 		User::Panic(_L("T_SUSER"),1);
   537 		}
   552 		}
   538 
   553 
   539 	return KErrNone;
   554 	return KErrNone;
   819 	}
   834 	}
   820 
   835 
   821 
   836 
   822 
   837 
   823 TUint KTestUid = 0x87654321;
   838 TUint KTestUid = 0x87654321;
       
   839 
       
   840 void GetTestExclusions()
       
   841 	{
       
   842 	RTestProcess process;
       
   843 	TRequestStatus logonStatus;
       
   844 
       
   845 	test.Start(_L("Get Test exclusions"));
       
   846 	TInt caps = 1u<<ECapabilityWriteDeviceData | 1u<<ECapabilityAllFiles;
       
   847 	process.Create(caps, ETestProcessGetTestExclusions, KTestUid);
       
   848 	process.Logon(logonStatus);
       
   849 	process.Resume();
       
   850 	User::WaitForRequest(logonStatus);
       
   851 	test(process.ExitType()==EExitKill);
       
   852 	test(logonStatus==KErrNone);
       
   853 	CLOSE_AND_WAIT(process);
       
   854 	test.End();
       
   855 	}
       
   856 	
       
   857 void TestPowerHalTestMode()
       
   858 	{
       
   859 	RTestProcess process;
       
   860 	TRequestStatus logonStatus;
       
   861 
       
   862 	test.Start(_L("Try calling PowerHal without ECapabilityWriteDeviceData"));
       
   863 	process.Create(~(1u<<ECapabilityWriteDeviceData), ETestProcessPowerHalTestMode, KTestUid);
       
   864 	process.Logon(logonStatus);
       
   865 	process.Resume();
       
   866 	User::WaitForRequest(logonStatus);
       
   867 	test(process.ExitType()==EExitKill);
       
   868 	test(logonStatus==KErrPermissionDenied);
       
   869 	CLOSE_AND_WAIT(process);
       
   870 	
       
   871 	test.Start(_L("Try calling PowerHal without ECapabilityPowerMgmt"));
       
   872 	process.Create(~(1u<<ECapabilityPowerMgmt), ETestProcessPowerHalTestMode, KTestUid);
       
   873 	process.Logon(logonStatus);
       
   874 	process.Resume();
       
   875 	User::WaitForRequest(logonStatus);
       
   876 	test(process.ExitType()==EExitKill);
       
   877 	test(logonStatus==KErrPermissionDenied);
       
   878 	CLOSE_AND_WAIT(process);
       
   879 
       
   880 	test.Next(_L("Call PowerHal with ECapabilityWriteDeviceData and ECapabilityPowerMgmt"));
       
   881 	TInt caps = 1u<<ECapabilityWriteDeviceData | 1u<<ECapabilityPowerMgmt;
       
   882 	process.Create(caps,ETestProcessPowerHalTestMode, KTestUid);
       
   883 	process.Logon(logonStatus);
       
   884 	process.Resume();
       
   885 	User::WaitForRequest(logonStatus);
       
   886 	test(process.ExitType()==EExitKill);
       
   887 	test(logonStatus==KErrNone);
       
   888 	gControllerShutdownDisabled = ETrue;
       
   889 	CLOSE_AND_WAIT(process);
       
   890 
       
   891 	test.End();
       
   892 	}
   824 
   893 
   825 void SetAbsoluteTimeout(RTimer& aTimer, TUint aUs, TRequestStatus& aStatus)
   894 void SetAbsoluteTimeout(RTimer& aTimer, TUint aUs, TRequestStatus& aStatus)
   826 	{
   895 	{
   827 	TTime wakeup;
   896 	TTime wakeup;
   828 	wakeup.HomeTime();
   897 	wakeup.HomeTime();
   948 	test(logonStatus==KErrPermissionDenied);
  1017 	test(logonStatus==KErrPermissionDenied);
   949 	CLOSE_AND_WAIT(process);
  1018 	CLOSE_AND_WAIT(process);
   950 
  1019 
   951 	TInt muid = 0;
  1020 	TInt muid = 0;
   952 	HAL::Get(HAL::EMachineUid, muid);
  1021 	HAL::Get(HAL::EMachineUid, muid);
   953 	if(muid==HAL::EMachineUid_OmapH2 || muid==HAL::EMachineUid_OmapH4 || muid==HAL::EMachineUid_OmapH6 || muid==HAL::EMachineUid_NE1_TB || muid==HAL::EMachineUid_X86PC || muid==HAL::EMachineUid_Win32Emulator)
  1022 	if(gControllerShutdownDisabled || muid==HAL::EMachineUid_OmapH2 || muid==HAL::EMachineUid_OmapH4 || muid==HAL::EMachineUid_OmapH6 || muid==HAL::EMachineUid_NE1_TB || muid==HAL::EMachineUid_X86PC || muid==HAL::EMachineUid_Win32Emulator)
   954 		{
  1023 		{
   955 		test.Next(_L("Calling UserSvr::AddEvent(ESwitchOff) with ECapabilityPowerMgmt & ECapabilitySwEvent"));
  1024 		test.Next(_L("Calling UserSvr::AddEvent(ESwitchOff) with ECapabilityPowerMgmt & ECapabilitySwEvent"));
   956 		TRequestStatus absstatus;
  1025 		TRequestStatus absstatus;
   957 		RTimer abstimer;
  1026 		RTimer abstimer;
   958 		TInt r = abstimer.CreateLocal();
  1027 		TInt r = abstimer.CreateLocal();
  1230 		}
  1299 		}
  1231 
  1300 
  1232 	test_KErrNone(SyncSemaphore.CreateGlobal(KSyncSemaphoreName,0));
  1301 	test_KErrNone(SyncSemaphore.CreateGlobal(KSyncSemaphoreName,0));
  1233 
  1302 
  1234 	test.Start(_L("Test MachineConfiguration()"));
  1303 	test.Start(_L("Test MachineConfiguration()"));
       
  1304 
  1235 	TestMachineConfiguration();
  1305 	TestMachineConfiguration();
  1236 
  1306 
       
  1307 	GetTestExclusions();
       
  1308 	
       
  1309 	TestPowerHalTestMode();
       
  1310 	
  1237 	test.Next(_L("Test SetCritical()"));
  1311 	test.Next(_L("Test SetCritical()"));
  1238 	TestSetCritical();
  1312 	TestSetCritical();
  1239 
  1313 
  1240 	test.Next(_L("Test Set/PriorityControl()"));
  1314 	test.Next(_L("Test Set/PriorityControl()"));
  1241 	User::SetPriorityControl(ETrue);
  1315 	User::SetPriorityControl(ETrue);