os/kernelhwsrv/kerneltest/e32test/misc/kill.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/misc/kill.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,74 @@
     1.4 +// Copyright (c) 1997-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\misc\kill.cpp
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include <e32test.h>
    1.22 +
    1.23 +_LIT(KPanicCat,"Test");
    1.24 +
    1.25 +LOCAL_D RTest test(_L("Kill"));
    1.26 +
    1.27 +GLDEF_C TInt E32Main()
    1.28 +	{
    1.29 +	test.Title();
    1.30 +	TBuf<256> cmd;
    1.31 +	TFullName fn;
    1.32 +	User::CommandLine(cmd);
    1.33 +	TLex lex(cmd);
    1.34 +	TPtrC threadSpec(lex.NextToken());
    1.35 +	TFindThread ft(threadSpec);
    1.36 +	TExitType exitType=EExitKill;
    1.37 +	TInt exitCode=0;
    1.38 +	if (!lex.Eos())
    1.39 +		{
    1.40 +		TPtrC xtSpec(lex.NextToken());
    1.41 +		TPtrC xc(xtSpec);
    1.42 +		TChar xt0=xtSpec[0];
    1.43 +		if (xt0.IsAlpha())
    1.44 +			{
    1.45 +			xt0.LowerCase();
    1.46 +			if (xt0==TChar('t'))
    1.47 +				exitType=EExitTerminate;
    1.48 +			else if (xt0==TChar('p'))
    1.49 +				exitType=EExitPanic;
    1.50 +			new(&xc) TPtrC(lex.NextToken());
    1.51 +			}
    1.52 +		if (xc.Length())
    1.53 +			{
    1.54 +			TLex lex2(xc);
    1.55 +			lex2.Val(exitCode);
    1.56 +			}
    1.57 +		}
    1.58 +	while (ft.Next(fn)==KErrNone)
    1.59 +		{
    1.60 +		test.Printf(_L("Killing %S\n"),&fn);
    1.61 +		RThread t;
    1.62 +		TInt r=t.Open(ft);
    1.63 +		if (r==KErrNone)
    1.64 +			{
    1.65 +			// FIXME: SHOULD REMOVE CRITICALNESS - WOULD NEED DEVICE DRIVER
    1.66 +			switch (exitType)
    1.67 +				{
    1.68 +				case EExitKill:	t.Kill(exitCode); break;
    1.69 +				case EExitTerminate: t.Terminate(exitCode); break;
    1.70 +				case EExitPanic: t.Panic(KPanicCat,exitCode); break;
    1.71 +				default: break;
    1.72 +				}
    1.73 +			t.Close();
    1.74 +			}
    1.75 +		}
    1.76 +	return 0;
    1.77 +	}