Update contrib.
1 // Copyright (c) 2002-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\power\t_domain_slave.cpp
20 #include <domainmember.h>
21 #include <domainmanager.h>
25 LOCAL_D RTest test(_L(" T_DOMAIN_SLAVE "));
27 // This will be run in its own thread as part of test #1. It should get killed when trying to connect
28 // to the manager without appropriate caps set
29 TInt IncorrectClient(TAny*)
32 TInt r = domain.Connect(KDmIdRoot);
34 RDmDomainManager manager;
35 r = manager.Connect();
40 GLDEF_C TInt E32Main()
43 test.Start(_L("Testing"));
45 // test.Next(_L("test security"));
47 // Get arguments from the command line
48 TInt len = User::CommandLineLength();
50 TInt size = len * sizeof(TUint16);
51 test (size == sizeof(TInt));
53 TPtr cmd((TUint16*) &arg, len);
54 User::CommandLine(cmd);
56 TInt expected_result = PlatSec::IsCapabilityEnforced(ECapabilityPowerMgmt) ? KErrPermissionDenied : KErrNone;
62 // This is the original t_domain_slave test, minus the panicking parts which now get
65 test.Next(_L("test security -- 0"));
68 TInt r = domain.Connect(KDmIdRoot);
69 test (r == expected_result);
76 test.Next(_L("test security -- 1"));
78 TBool jit = User::JustInTime();
80 User::SetJustInTime(EFalse);
82 _LIT(KPanicThread, "PanicThread");
86 TInt tt=testThread.Create(KPanicThread, IncorrectClient, KDefaultStackSize,
89 test (KErrNone == tt);
91 TRequestStatus tStatus;
92 // testThread.Logon(tStatus);
94 RUndertaker deathChecker;
95 TInt dcOK = deathChecker.Create();
97 test (KErrNone == dcOK);
101 deathChecker.Logon(tStatus, nextDeadThread);
103 // threads are created in a suspended state. calling resume here starts the thread.
105 User::WaitForRequest(tStatus);
107 // If thread suicided for the correct reason --> successful test
108 // NB. KErrPermissionDenied means that the server refused the
109 // connection because of incorrect capabilities
112 corpse.SetHandle(nextDeadThread);
114 RDebug::Printf("Subthread exit type: %d", corpse.ExitType() );
116 RDebug::Printf("Subthread exit reason: %d",corpse.ExitReason() );
118 test (corpse.ExitType() == EExitKill);
120 test (corpse.ExitReason() == KErrPermissionDenied);
124 // close the RUndertaker and test thread
125 deathChecker.Close();
126 CLOSE_AND_WAIT(testThread);
128 User::SetJustInTime(jit);
133 User::Panic(_L("USER"), EInvariantFalse);