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\system\testprocess.h
18 #ifndef __TESTPROCESS_H__
19 #define __TESTPROCESS_H__
21 class RTestProcess : public RProcess
24 void Create(TUint32 aCapability,TTestProcessFunctions aFunction,TInt aArg1=-1,TInt aArg2=-1);
25 void Create(TTestProcessFunctions aFunction,TInt aArg1=-1,TInt aArg2=-1);
27 static TUint iInstanceCount;
30 TUint RTestProcess::iInstanceCount = 0;
32 void RTestProcess::Create(TUint32 aCapability,TTestProcessFunctions aFunction,TInt aArg1,TInt aArg2)
34 TFileName source=RProcess().FileName();
36 TFileName destination;
37 _LIT(KTempPath,"c:\\system\\bin\\");
38 _LIT(KTempPathSysBin,"c:\\sys\\bin\\");
39 if(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin))
40 destination = KTempPathSysBin;
42 destination = KTempPath;
43 destination.Append(source.Mid(source.LocateReverse('\\')+1));
44 destination.SetLength(source.Locate('.'));
45 destination.Append((TText)'-');
46 destination.AppendNum(++iInstanceCount,EHex);
48 destination.Append(KDotExe);
54 if(source[0]=='z' || source[0]=='Z')
56 b.Append(source.Mid(source.LocateReverse('\\')+1));
62 b.AppendNum((TUint)aCapability,EHex);
64 b.Append(destination);
66 _LIT(KSetcapExe,"setcap.exe");
67 r = p.Create(KSetcapExe,b);
72 User::WaitForRequest(s);
74 test(p.ExitType()==EExitKill);
77 aArg1 = RProcess().Id();
78 TBuf<512> commandLine;
79 commandLine.AppendNum((TInt)aFunction);
80 commandLine.Append(_L(" "));
81 commandLine.AppendNum(aArg1);
82 commandLine.Append(_L(" "));
83 commandLine.AppendNum(aArg2);
84 r = RProcess::Create(destination,commandLine);
86 SetJustInTime(EFalse);
89 void RTestProcess::Create(TTestProcessFunctions aFunction,TInt aArg1,TInt aArg2)
92 aArg1 = RProcess().Id();
93 TBuf<512> commandLine;
94 commandLine.Num((TInt)aFunction);
95 commandLine.Append(_L(" "));
96 commandLine.AppendNum(aArg1);
97 commandLine.Append(_L(" "));
98 commandLine.AppendNum(aArg2);
99 TInt r = RProcess::Create(RProcess().FileName(),commandLine);
101 SetJustInTime(EFalse);
104 void RTestProcess::Run()
109 User::WaitForRequest(s);
111 test(ExitType()==EExitKill);
112 CLOSE_AND_WAIT(*this);