1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/secure/t_sprocess.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,688 @@
1.4 +// Copyright (c) 2001-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\secure\t_sprocess.cpp
1.18 +// Overview:
1.19 +// Test the platform security aspects of the RProcess class
1.20 +// API Information:
1.21 +// RProcess
1.22 +// Details:
1.23 +// - Test SetJustInTime on the current process, a new un-Resumed process
1.24 +// and between processes. Verify results are as expected.
1.25 +// - Test process renaming and verify results are as expected.
1.26 +// - Test killing, terminating and panicking different processes, verify
1.27 +// results are as expected.
1.28 +// - Test resuming a process from a different process, verify results.
1.29 +// - Test setting process priority in a variety of ways, verify results
1.30 +// are as expected.
1.31 +// - Test the RProcess SetType(), SetProtected(), CommandLineLength(),
1.32 +// CommandLine(), SetSystem(), SetOwner() and Owner() methods. Verify
1.33 +// results are as expected.
1.34 +// Platforms/Drives/Compatibility:
1.35 +// All.
1.36 +// Assumptions/Requirement/Pre-requisites:
1.37 +// Failures and causes:
1.38 +// Base Port information:
1.39 +//
1.40 +//
1.41 +
1.42 +#include <e32test.h>
1.43 +
1.44 +LOCAL_D RTest test(_L("T_SPROCESS"));
1.45 +
1.46 +_LIT(KSyncMutext,"T_SPROCESS-sync-mutex");
1.47 +RMutex SyncMutex;
1.48 +
1.49 +void Wait()
1.50 + {
1.51 + RMutex syncMutex;
1.52 + if(syncMutex.OpenGlobal(KSyncMutext)!=KErrNone)
1.53 + User::Invariant();
1.54 + syncMutex.Wait();
1.55 + syncMutex.Signal();
1.56 + syncMutex.Close();
1.57 + }
1.58 +
1.59 +enum TTestProcessFunctions
1.60 + {
1.61 + ETestProcessNull,
1.62 + ETestProcessSetJustInTime,
1.63 + ETestProcessKill,
1.64 + ETestProcessTerminate,
1.65 + ETestProcessPanic,
1.66 + ETestProcessKillSelf,
1.67 + ETestProcessTerminateSelf,
1.68 + ETestProcessPanicSelf,
1.69 + ETestProcessResume,
1.70 + ETestProcessPriority,
1.71 + ETestProcessPriorityControlOff,
1.72 + ETestProcessPriorityControlOn,
1.73 + ETestProcessPriorityControlOnAndLowPriority,
1.74 + ETestProcessSetPriority,
1.75 + };
1.76 +
1.77 +#include "testprocess.h"
1.78 +
1.79 +_LIT(KTestPanicCategory,"TEST PANIC");
1.80 +_LIT(KTestProcessName,"TestName");
1.81 +_LIT(KTestProcessName2,"TestName2");
1.82 +
1.83 +
1.84 +TInt DoTestProcess(TInt aTestNum,TInt aArg1,TInt aArg2)
1.85 + {
1.86 + RTestProcess process;
1.87 + TInt r;
1.88 +
1.89 + switch(aTestNum)
1.90 + {
1.91 +
1.92 + case ETestProcessNull:
1.93 + Wait();
1.94 + return KErrNone;
1.95 +
1.96 + case ETestProcessSetJustInTime:
1.97 + {
1.98 + r = process.Open(aArg1);
1.99 + if(r==KErrNone)
1.100 + process.SetJustInTime(!process.JustInTime()); // Should panic us
1.101 + return r;
1.102 + }
1.103 +
1.104 + case ETestProcessResume:
1.105 + {
1.106 + r = process.Open(aArg1);
1.107 + if(r==KErrNone)
1.108 + process.Resume(); // Should panic us
1.109 + return r;
1.110 + }
1.111 +
1.112 + case ETestProcessKill:
1.113 + {
1.114 + r = process.Open(aArg1);
1.115 + if(r==KErrNone)
1.116 + process.Kill(999);
1.117 + return r;
1.118 + }
1.119 +
1.120 + case ETestProcessTerminate:
1.121 + {
1.122 + r = process.Open(aArg1);
1.123 + if(r==KErrNone)
1.124 + process.Terminate(999);
1.125 + return r;
1.126 + }
1.127 +
1.128 + case ETestProcessPanic:
1.129 + {
1.130 + r = process.Open(aArg1);
1.131 + if(r==KErrNone)
1.132 + process.Panic(KTestPanicCategory,999);
1.133 + return r;
1.134 + }
1.135 +
1.136 + case ETestProcessKillSelf:
1.137 + {
1.138 + RProcess().Kill(999);
1.139 + return KErrNone;
1.140 + }
1.141 +
1.142 + case ETestProcessTerminateSelf:
1.143 + {
1.144 + RProcess().Terminate(999);
1.145 + return KErrNone;
1.146 + }
1.147 +
1.148 + case ETestProcessPanicSelf:
1.149 + {
1.150 + RProcess().Panic(KTestPanicCategory,999);
1.151 + return KErrNone;
1.152 + }
1.153 +
1.154 + case ETestProcessSetPriority:
1.155 + {
1.156 + r = process.Open(aArg1);
1.157 + if(r==KErrNone)
1.158 + process.SetPriority((TProcessPriority)aArg2);
1.159 + return r;
1.160 + }
1.161 +
1.162 +
1.163 + case ETestProcessPriority:
1.164 + {
1.165 + r = process.Open(aArg1);
1.166 + if(r!=KErrNone)
1.167 + return r;
1.168 + TProcessPriority priority;
1.169 + priority = process.Priority();
1.170 + process.SetPriority(EPriorityLow);
1.171 + if(process.Priority()!=priority) // priority shouldn't have changed
1.172 + return KErrGeneral;
1.173 + process.SetPriority(EPriorityBackground);
1.174 + if(process.Priority()!=priority) // priority shouldn't have changed
1.175 + return KErrGeneral;
1.176 + process.SetPriority(EPriorityForeground);
1.177 + if(process.Priority()!=priority) // priority shouldn't have changed
1.178 + return KErrGeneral;
1.179 + return KErrNone;
1.180 + }
1.181 +
1.182 + case ETestProcessPriorityControlOnAndLowPriority:
1.183 + RProcess().SetPriority(EPriorityLow);
1.184 + // fall through...
1.185 + case ETestProcessPriorityControlOn:
1.186 + User::SetPriorityControl(ETrue);
1.187 + // fall through...
1.188 + case ETestProcessPriorityControlOff:
1.189 + RProcess::Rendezvous(0);
1.190 + Wait();
1.191 + return KErrNone;
1.192 +
1.193 + default:
1.194 + User::Panic(_L("T_SPROCESS"),1);
1.195 + }
1.196 +
1.197 + return KErrNone;
1.198 + }
1.199 +
1.200 +
1.201 +
1.202 +void TestProcessForPlatformSecurityTrap(TTestProcessFunctions aFunction)
1.203 + {
1.204 + TRequestStatus logonStatus2;
1.205 + RTestProcess process;
1.206 + process.Create(~0u,aFunction,RProcess().Id(),EPriorityAbsoluteLow);
1.207 + process.Logon(logonStatus2);
1.208 + process.Resume();
1.209 + User::WaitForRequest(logonStatus2);
1.210 + test(process.ExitType()==EExitPanic); // Process should have got a Platform Security panic
1.211 + test(logonStatus2==EPlatformSecurityTrap);
1.212 + }
1.213 +
1.214 +
1.215 +
1.216 +void TestSetJustInTime()
1.217 + {
1.218 + RTestProcess process;
1.219 + RTestProcess process2;
1.220 + TRequestStatus logonStatus;
1.221 +
1.222 + test.Start(_L("Test SetJustInTime on current process"));
1.223 + TBool jit = process.JustInTime();
1.224 + process.SetJustInTime(!jit);
1.225 + test((process.JustInTime()!=EFalse)!=(jit!=EFalse));
1.226 + process.SetJustInTime(jit);
1.227 + test((process.JustInTime()!=EFalse)==(jit!=EFalse));
1.228 +
1.229 + test.Next(_L("Test SetJustInTime on a new un-Resumed process"));
1.230 + process.RProcess::Create(RProcess().FileName(),_L(""));
1.231 + jit = process.JustInTime();
1.232 + process.SetJustInTime(!jit);
1.233 + test((process.JustInTime()!=EFalse)!=(jit!=EFalse));
1.234 + process.SetJustInTime(jit);
1.235 + test((process.JustInTime()!=EFalse)==(jit!=EFalse));
1.236 + process.Kill(0);
1.237 + CLOSE_AND_WAIT(process);
1.238 +
1.239 + test.Next(_L("Try other process using SetJustInTime on our created process"));
1.240 + process2.Create(0,ETestProcessNull);
1.241 + process.Create(~0u,ETestProcessSetJustInTime,process2.Id());
1.242 + process.Logon(logonStatus);
1.243 + process.Resume();
1.244 + User::WaitForRequest(logonStatus);
1.245 + test(process.ExitType()==EExitPanic); // Process should have got a Platform Security panic
1.246 + test(logonStatus==EPlatformSecurityTrap);
1.247 + CLOSE_AND_WAIT(process);
1.248 + process2.Kill(0);
1.249 + CLOSE_AND_WAIT(process2);
1.250 +
1.251 + test.Next(_L("Try other process to using SetJustInTime on us"));
1.252 + process.Create(~0u,ETestProcessSetJustInTime);
1.253 + process.Logon(logonStatus);
1.254 + process.Resume();
1.255 + User::WaitForRequest(logonStatus);
1.256 + test(process.ExitType()==EExitPanic); // Process should have got a Platform Security panic
1.257 + test(logonStatus==EPlatformSecurityTrap);
1.258 + CLOSE_AND_WAIT(process);
1.259 +
1.260 + test.End();
1.261 + }
1.262 +
1.263 +
1.264 +
1.265 +void TestRename()
1.266 + {
1.267 + TName name;
1.268 +
1.269 + test.Start(_L("Renaming the current process with User::RenameProcess"));
1.270 + name = RProcess().Name();
1.271 + name.SetLength(KTestProcessName().Length());
1.272 + test(name.CompareF(KTestProcessName)!=0);
1.273 + User::RenameProcess(KTestProcessName);
1.274 + name = RProcess().Name();
1.275 + name.SetLength(KTestProcessName().Length());
1.276 + test(name.CompareF(KTestProcessName)==0);
1.277 +
1.278 +
1.279 + test.End();
1.280 + }
1.281 +
1.282 +
1.283 +
1.284 +void TestKill()
1.285 + {
1.286 + RTestProcess process;
1.287 + RTestProcess process2;
1.288 + TRequestStatus logonStatus;
1.289 + TRequestStatus logonStatus2;
1.290 +
1.291 + process2.Create(0,ETestProcessNull);
1.292 + process2.Logon(logonStatus2);
1.293 +
1.294 + // Test RProcess::Kill()
1.295 +
1.296 + test.Start(_L("Test killing an un-resumed process created by us"));
1.297 + process.Create(0,ETestProcessNull);
1.298 + process.Logon(logonStatus);
1.299 + process.Kill(999);
1.300 + User::WaitForRequest(logonStatus);
1.301 + test(process.ExitType()==EExitKill);
1.302 + test(logonStatus==999);
1.303 + CLOSE_AND_WAIT(process);
1.304 +
1.305 + test.Next(_L("Try killing un-resumed process not created by self"));
1.306 + process.Create(~(1u<<ECapabilityPowerMgmt),ETestProcessKill,process2.Id());
1.307 + process.Logon(logonStatus);
1.308 + process.Resume();
1.309 + User::WaitForRequest(logonStatus);
1.310 + test(process.ExitType()==EExitPanic); // Process should have got a Platform Security panic
1.311 + test(logonStatus==EPlatformSecurityTrap);
1.312 + test(logonStatus2==KRequestPending); // the process should still be alive
1.313 + CLOSE_AND_WAIT(process);
1.314 +
1.315 + test.Next(_L("Test a process killing itself"));
1.316 + process.Create(0,ETestProcessKillSelf);
1.317 + process.Logon(logonStatus);
1.318 + process.Resume();
1.319 + User::WaitForRequest(logonStatus);
1.320 + test(process.ExitType()==EExitKill);
1.321 + test(logonStatus==999);
1.322 + CLOSE_AND_WAIT(process);
1.323 +
1.324 + test.Next(_L("Try killing running process"));
1.325 + process.Create(~(1u<<ECapabilityPowerMgmt),ETestProcessKill,RProcess().Id());
1.326 + process.Logon(logonStatus);
1.327 + process.Resume();
1.328 + User::WaitForRequest(logonStatus);
1.329 + test(process.ExitType()==EExitPanic); // Process should have got a Platform Security panic
1.330 + test(logonStatus==EPlatformSecurityTrap);
1.331 + CLOSE_AND_WAIT(process);
1.332 +
1.333 + // Test RProcess::Teminate()
1.334 +
1.335 + test.Next(_L("Test terminating an un-resumed process created by us"));
1.336 + process.Create(0,ETestProcessNull);
1.337 + process.Logon(logonStatus);
1.338 + process.Terminate(999);
1.339 + User::WaitForRequest(logonStatus);
1.340 + test(process.ExitType()==EExitTerminate);
1.341 + test(logonStatus==999);
1.342 + CLOSE_AND_WAIT(process);
1.343 +
1.344 + test.Next(_L("Try terminating un-resumed process not created by self"));
1.345 + process.Create(~(1u<<ECapabilityPowerMgmt),ETestProcessTerminate,process2.Id());
1.346 + process.Logon(logonStatus);
1.347 + process.Resume();
1.348 + User::WaitForRequest(logonStatus);
1.349 + test(process.ExitType()==EExitPanic); // Process should have got a Platform Security panic
1.350 + test(logonStatus==EPlatformSecurityTrap);
1.351 + test(logonStatus2==KRequestPending); // the process should still be alive
1.352 + CLOSE_AND_WAIT(process);
1.353 +
1.354 + test.Next(_L("Test a process terminating itself"));
1.355 + process.Create(0,ETestProcessTerminateSelf);
1.356 + process.Logon(logonStatus);
1.357 + process.Resume();
1.358 + User::WaitForRequest(logonStatus);
1.359 + test(process.ExitType()==EExitTerminate);
1.360 + test(logonStatus==999);
1.361 + CLOSE_AND_WAIT(process);
1.362 +
1.363 + test.Next(_L("Try terminating running process"));
1.364 + process.Create(~(1u<<ECapabilityPowerMgmt),ETestProcessTerminate,RProcess().Id());
1.365 + process.Logon(logonStatus);
1.366 + process.Resume();
1.367 + User::WaitForRequest(logonStatus);
1.368 + test(process.ExitType()==EExitPanic); // Process should have got a Platform Security panic
1.369 + test(logonStatus==EPlatformSecurityTrap);
1.370 + CLOSE_AND_WAIT(process);
1.371 +
1.372 + // Test RProcess::Panic()
1.373 +
1.374 + test.Next(_L("Test panicking an un-resumed process created by us"));
1.375 + process.Create(0,ETestProcessNull);
1.376 + process.Logon(logonStatus);
1.377 + process.Panic(KTestPanicCategory,999);
1.378 + User::WaitForRequest(logonStatus);
1.379 + test(process.ExitType()==EExitPanic);
1.380 + test(logonStatus==999);
1.381 + CLOSE_AND_WAIT(process);
1.382 +
1.383 + test.Next(_L("Try panicking un-resumed process not created by self"));
1.384 + process.Create(~(1u<<ECapabilityPowerMgmt),ETestProcessPanic,process2.Id());
1.385 + process.Logon(logonStatus);
1.386 + process.Resume();
1.387 + User::WaitForRequest(logonStatus);
1.388 + test(process.ExitType()==EExitPanic); // Process should have got a Platform Security panic
1.389 + test(logonStatus==EPlatformSecurityTrap);
1.390 + test(logonStatus2==KRequestPending); // the process should still be alive
1.391 + CLOSE_AND_WAIT(process);
1.392 +
1.393 + test.Next(_L("Test a process panicking itself"));
1.394 + process.Create(0,ETestProcessPanicSelf);
1.395 + process.Logon(logonStatus);
1.396 + process.Resume();
1.397 + User::WaitForRequest(logonStatus);
1.398 + test(process.ExitType()==EExitPanic);
1.399 + test(logonStatus==999);
1.400 + CLOSE_AND_WAIT(process);
1.401 +
1.402 + test.Next(_L("Try panicking running process"));
1.403 + process.Create(~(1u<<ECapabilityPowerMgmt),ETestProcessPanic,RProcess().Id());
1.404 + process.Logon(logonStatus);
1.405 + process.Resume();
1.406 + User::WaitForRequest(logonStatus);
1.407 + test(process.ExitType()==EExitPanic); // Process should have got a Platform Security panic
1.408 + test(logonStatus==EPlatformSecurityTrap);
1.409 + CLOSE_AND_WAIT(process);
1.410 +
1.411 + //
1.412 +
1.413 + test(logonStatus2==KRequestPending); // the process should still be alive
1.414 + process2.Resume();
1.415 + User::WaitForRequest(logonStatus2);
1.416 + test(logonStatus2==KErrNone);
1.417 + CLOSE_AND_WAIT(process2);
1.418 +
1.419 + // Checks with ECapabilityPowerMgmt
1.420 +
1.421 + test.Next(_L("Test kill running process ECapabilityPowerMgmt"));
1.422 + process2.Create(0,ETestProcessNull);
1.423 + process2.Logon(logonStatus2);
1.424 + process.Create((1<<ECapabilityPowerMgmt),ETestProcessKill,process2.Id());
1.425 + process.Logon(logonStatus);
1.426 + SyncMutex.Wait();
1.427 + process2.Resume();
1.428 + process.Resume();
1.429 + User::WaitForRequest(logonStatus);
1.430 + test(process.ExitType()==EExitKill);
1.431 + test(logonStatus==0);
1.432 + CLOSE_AND_WAIT(process);
1.433 + User::WaitForRequest(logonStatus2);
1.434 + test(process2.ExitType()==EExitKill);
1.435 + test(logonStatus2==999);
1.436 + process2.Close();
1.437 + SyncMutex.Signal();
1.438 +
1.439 + test.Next(_L("Test terminating running process ECapabilityPowerMgmt"));
1.440 + process2.Create(0,ETestProcessNull);
1.441 + process2.Logon(logonStatus2);
1.442 + process.Create((1<<ECapabilityPowerMgmt),ETestProcessTerminate,process2.Id());
1.443 + process.Logon(logonStatus);
1.444 + SyncMutex.Wait();
1.445 + process2.Resume();
1.446 + process.Resume();
1.447 + User::WaitForRequest(logonStatus);
1.448 + test(process.ExitType()==EExitKill);
1.449 + test(logonStatus==0);
1.450 + CLOSE_AND_WAIT(process);
1.451 + User::WaitForRequest(logonStatus2);
1.452 + test(process2.ExitType()==EExitTerminate);
1.453 + test(logonStatus2==999);
1.454 + CLOSE_AND_WAIT(process2);
1.455 + SyncMutex.Signal();
1.456 +
1.457 + test.Next(_L("Test panicking running process ECapabilityPowerMgmt"));
1.458 + process2.Create(0,ETestProcessNull);
1.459 + process2.Logon(logonStatus2);
1.460 + process.Create((1<<ECapabilityPowerMgmt),ETestProcessPanic,process2.Id());
1.461 + process.Logon(logonStatus);
1.462 + SyncMutex.Wait();
1.463 + process2.Resume();
1.464 + process.Resume();
1.465 + User::WaitForRequest(logonStatus);
1.466 + test(process.ExitType()==EExitKill);
1.467 + test(logonStatus==0);
1.468 + CLOSE_AND_WAIT(process);
1.469 + User::WaitForRequest(logonStatus2);
1.470 + test(process2.ExitType()==EExitPanic);
1.471 + test(logonStatus2==999);
1.472 + CLOSE_AND_WAIT(process2);
1.473 + SyncMutex.Signal();
1.474 +
1.475 + //
1.476 +
1.477 + test.End();
1.478 + }
1.479 +
1.480 +
1.481 +
1.482 +void TestResume()
1.483 + {
1.484 + RTestProcess process;
1.485 + RTestProcess process2;
1.486 + TRequestStatus logonStatus;
1.487 + TRequestStatus logonStatus2;
1.488 +
1.489 + test.Start(_L("Try to get another process to resume one we've created"));
1.490 + process2.Create(0,ETestProcessNull);
1.491 + process2.Logon(logonStatus2);
1.492 + process.Create(~0u,ETestProcessResume,process2.Id());
1.493 + process.Logon(logonStatus);
1.494 + process.Resume();
1.495 + User::WaitForRequest(logonStatus);
1.496 + test(process.ExitType()==EExitPanic); // Process should have got a Platform Security panic
1.497 + test(logonStatus==EPlatformSecurityTrap);
1.498 + User::After(1*1000*1000); // Give time for process to run (if it had been resumed)...
1.499 + test(logonStatus2==KRequestPending); // It shouldn't have, so logon will be pending
1.500 + process2.Kill(0);
1.501 + CLOSE_AND_WAIT(process2);
1.502 +
1.503 +// test.Next(_L("Test resuming a process we've created"));
1.504 +//
1.505 +// No code for this, because this whole test program wouldn't work if this wasn't OK
1.506 +//
1.507 +
1.508 + test.End();
1.509 + }
1.510 +
1.511 +
1.512 +
1.513 +void TestSetPriority()
1.514 + {
1.515 + RTestProcess process;
1.516 + RTestProcess process2;
1.517 + TProcessPriority priority;
1.518 + TRequestStatus rendezvousStatus;
1.519 + TRequestStatus logonStatus;
1.520 +
1.521 + test.Start(_L("Test changing our own process priority"));
1.522 + priority = process.Priority();
1.523 + process.SetPriority(EPriorityLow);
1.524 + test(process.Priority()==EPriorityLow);
1.525 + process.SetPriority(EPriorityBackground);
1.526 + test(process.Priority()==EPriorityBackground);
1.527 + process.SetPriority(EPriorityForeground);
1.528 + test(process.Priority()==EPriorityForeground);
1.529 + process.SetPriority(priority);
1.530 +
1.531 + test.Next(_L("Test changing unresumed process priority (which we created)"));
1.532 + process.Create(0,ETestProcessNull);
1.533 + priority = process.Priority();
1.534 + process.SetPriority(EPriorityLow);
1.535 + test(process.Priority()==EPriorityLow);
1.536 + process.SetPriority(EPriorityBackground);
1.537 + test(process.Priority()==EPriorityBackground);
1.538 + process.SetPriority(EPriorityForeground);
1.539 + test(process.Priority()==EPriorityForeground);
1.540 + process.SetPriority(priority);
1.541 + process.Kill(0);
1.542 + CLOSE_AND_WAIT(process);
1.543 +
1.544 + test.Next(_L("Try other process changing the priority of our created process"));
1.545 + process2.Create(0,ETestProcessNull);
1.546 + process.Create(~0u,ETestProcessPriority,process2.Id());
1.547 + process.Logon(logonStatus);
1.548 + process.Resume();
1.549 + User::WaitForRequest(logonStatus);
1.550 + test(logonStatus==KErrNone);
1.551 + CLOSE_AND_WAIT(process);
1.552 + process2.Kill(0);
1.553 + CLOSE_AND_WAIT(process2);
1.554 +
1.555 + test.Next(_L("Try changing other process's priority (no priority-control enabled)"));
1.556 + process.Create(~0u,ETestProcessPriorityControlOff);
1.557 + process.Rendezvous(rendezvousStatus);
1.558 + process.Logon(logonStatus);
1.559 + SyncMutex.Wait();
1.560 + process.Resume();
1.561 + User::WaitForRequest(rendezvousStatus); // Process has started
1.562 + priority = process.Priority();
1.563 + TInt result = process.SetPriority(EPriorityLow);
1.564 + test(result == KErrPermissionDenied);
1.565 + test(process.Priority()==priority); // priority shouldn't have changed
1.566 + process.SetPriority(EPriorityBackground);
1.567 + test(result == KErrPermissionDenied);
1.568 + test(process.Priority()==priority); // priority shouldn't have changed
1.569 + process.SetPriority(EPriorityForeground);
1.570 + test(result == KErrPermissionDenied);
1.571 + test(process.Priority()==priority); // priority shouldn't have changed
1.572 + test(logonStatus==KRequestPending); // wait for process to end
1.573 + SyncMutex.Signal();
1.574 + User::WaitForRequest(logonStatus);
1.575 + CLOSE_AND_WAIT(process);
1.576 +
1.577 + test.Next(_L("Try changing other process's priority (priority-control enabled)"));
1.578 + process.Create(~0u,ETestProcessPriorityControlOn);
1.579 + process.Rendezvous(rendezvousStatus);
1.580 + process.Logon(logonStatus);
1.581 + SyncMutex.Wait();
1.582 + process.Resume();
1.583 + User::WaitForRequest(rendezvousStatus); // Process has started
1.584 + priority = process.Priority();
1.585 + result = process.SetPriority(EPriorityForeground);
1.586 + test(result == KErrNone);
1.587 + test(process.Priority()==EPriorityForeground);
1.588 + result = process.SetPriority(EPriorityBackground);
1.589 + test(result == KErrNone);
1.590 + test(process.Priority()==EPriorityBackground);
1.591 + result = process.SetPriority(EPriorityForeground);
1.592 + test(result == KErrNone);
1.593 + test(process.Priority()==EPriorityForeground);
1.594 + result = process.SetPriority(EPriorityLow);
1.595 + test(result == KErrPermissionDenied);
1.596 + test(process.Priority()==EPriorityForeground); // should still be foreground priority
1.597 + result = process.SetPriority(EPriorityHigh);
1.598 + test(result == KErrNone);
1.599 + test(process.Priority()==EPriorityHigh);
1.600 + result = process.SetPriority(priority);
1.601 + test(result == KErrNone);
1.602 + test(logonStatus==KRequestPending); // wait for process to end
1.603 + SyncMutex.Signal();
1.604 + User::WaitForRequest(logonStatus);
1.605 + CLOSE_AND_WAIT(process);
1.606 +
1.607 + test.Next(_L("Try changing other process's priority (priority-control enabled and low priority)"));
1.608 + process.Create(~0u,ETestProcessPriorityControlOnAndLowPriority);
1.609 + process.Rendezvous(rendezvousStatus);
1.610 + process.Logon(logonStatus);
1.611 + SyncMutex.Wait();
1.612 + process.Resume();
1.613 + User::WaitForRequest(rendezvousStatus); // Process has started
1.614 + test(process.Priority()==EPriorityLow);
1.615 + result = process.SetPriority(EPriorityForeground);
1.616 + test(result == KErrPermissionDenied);
1.617 + test(process.Priority()==EPriorityLow);
1.618 + result = process.SetPriority(EPriorityBackground);
1.619 + test(result == KErrPermissionDenied);
1.620 + test(process.Priority()==EPriorityLow);
1.621 + result = process.SetPriority(EPriorityForeground);
1.622 + test(result == KErrPermissionDenied);
1.623 + test(process.Priority()==EPriorityLow);
1.624 + result = process.SetPriority(EPriorityLow);
1.625 + test(result == KErrPermissionDenied);
1.626 + test(process.Priority()==EPriorityLow);
1.627 + result = process.SetPriority(EPriorityHigh);
1.628 + test(result == KErrPermissionDenied);
1.629 + test(process.Priority()==EPriorityLow);
1.630 + test(logonStatus==KRequestPending); // wait for process to end
1.631 + SyncMutex.Signal();
1.632 + User::WaitForRequest(logonStatus);
1.633 + CLOSE_AND_WAIT(process);
1.634 +
1.635 + test.End();
1.636 + }
1.637 +
1.638 +
1.639 +
1.640 +GLDEF_C TInt E32Main()
1.641 + {
1.642 + TBuf16<512> cmd;
1.643 + User::CommandLine(cmd);
1.644 + if(cmd.Length() && TChar(cmd[0]).IsDigit())
1.645 + {
1.646 + TInt function = -1;
1.647 + TInt arg1 = -1;
1.648 + TInt arg2 = -1;
1.649 + TLex lex(cmd);
1.650 +
1.651 + lex.Val(function);
1.652 + lex.SkipSpace();
1.653 + lex.Val(arg1);
1.654 + lex.SkipSpace();
1.655 + lex.Val(arg2);
1.656 + return DoTestProcess(function,arg1,arg2);
1.657 + }
1.658 +
1.659 + test.Title();
1.660 +
1.661 + if((!PlatSec::ConfigSetting(PlatSec::EPlatSecProcessIsolation))||(!PlatSec::ConfigSetting(PlatSec::EPlatSecEnforcement)))
1.662 + {
1.663 + test.Start(_L("TESTS NOT RUN - PlatSecProcessIsolation is not enforced"));
1.664 + test.End();
1.665 + return 0;
1.666 + }
1.667 +
1.668 + test(SyncMutex.CreateGlobal(KSyncMutext)==KErrNone);
1.669 +
1.670 + test.Start(_L("Test SetJustInTime"));
1.671 + TestSetJustInTime();
1.672 +
1.673 + test.Next(_L("Test Rename"));
1.674 + TestRename();
1.675 +
1.676 + test.Next(_L("Test Kill, Panic and Teminate"));
1.677 + TestKill();
1.678 +
1.679 + test.Next(_L("Test Resume"));
1.680 + TestResume();
1.681 +
1.682 + test.Next(_L("Test SetPriority"));
1.683 + TestSetPriority();
1.684 +
1.685 +
1.686 + SyncMutex.Close();
1.687 + test.End();
1.688 +
1.689 + return(0);
1.690 + }
1.691 +