messagingfw/msgtest/tools/utils/src/t_KillSysAgent.cpp
changeset 0 8e480a14352b
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     1 // Copyright (c) 1999-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 "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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <e32test.h>
       
    17 #include <e32std.h>
       
    18 
       
    19 RTest test(_L("KillSysAgent Testrig"));
       
    20 CTrapCleanup* theCleanup;
       
    21 
       
    22 _LIT(KSysAgent, "SYSAG*");
       
    23 
       
    24 LOCAL_C void doMainL()
       
    25 	{
       
    26 	test.Printf(_L("Killing process \"%S\"\n"), &KSysAgent);
       
    27 
       
    28 	TFullName name;
       
    29 	TFindProcess find(KSysAgent);
       
    30 	
       
    31 	TInt err = find.Next(name);
       
    32 
       
    33 	test.Printf(_L("find.Next() returned %d\n"), err);
       
    34 
       
    35 	if (!err)
       
    36 		{
       
    37 		RProcess process;
       
    38 		err = process.Open(find);
       
    39 
       
    40 		test.Printf(_L("process.Open() returned %d\n"), err);
       
    41 
       
    42 		if (!err)
       
    43 			{
       
    44 			process.Terminate(KErrGeneral);
       
    45 			process.Close();	
       
    46 			}
       
    47 		}
       
    48 
       
    49 	test.Printf(_L("Press any key to continue..."));
       
    50 	test.Getch();
       
    51 	}
       
    52 
       
    53 GLDEF_C TInt E32Main()
       
    54 	{	
       
    55 	__UHEAP_MARK;
       
    56 	test.Start(_L("Setup"));
       
    57 	theCleanup = CTrapCleanup::New();
       
    58 	TRAPD(ret,doMainL());		
       
    59 	test(ret==KErrNone);
       
    60 	delete theCleanup;	
       
    61 	test.Console()->SetPos(0, 13);
       
    62 	test.End();
       
    63 	test.Close();
       
    64 	__UHEAP_MARKEND;
       
    65 	return(KErrNone);
       
    66 	}