kerneltest/e32test/misc/t_proc3.cpp
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 1998-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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // e32test\misc\t_proc3.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <e32test.h>
       
    19 #include "u32std.h"
       
    20 #include "../misc/prbs.h"
       
    21 
       
    22 _LIT(KSecondProcessName,"T_PROC3A");
       
    23 
       
    24 RTest test(_L("T_PROC3"));
       
    25 
       
    26 GLDEF_C TInt E32Main()
       
    27 	{
       
    28 	test.Title();
       
    29 	test.Start(_L("Testing thread create/process kill"));
       
    30 	TUint seed[2];
       
    31 	seed[0]=0xc90fdaa2;
       
    32 	seed[1]=0;
       
    33 
       
    34 	TInt n=0;
       
    35 	FOREVER
       
    36 		{
       
    37 		TUint x=Random(seed);
       
    38 		TBuf<16> buf;
       
    39 		buf.Num(x,EHex);
       
    40 		RProcess p;
       
    41 		TInt r=p.Create(KSecondProcessName,buf);
       
    42 		if (r!=KErrNone)
       
    43 			{
       
    44 			test.Printf(_L("Process create failed, code %d\n"),r);
       
    45 			test.Getch();
       
    46 			test(0);
       
    47 			}
       
    48 		TRequestStatus s;
       
    49 		p.Logon(s);
       
    50 		test(s==KRequestPending);
       
    51 		++n;
       
    52 		p.Resume();
       
    53 		User::WaitForRequest(s);
       
    54 		if (p.ExitType()!=EExitKill || (TUint)p.ExitReason()!=x)
       
    55 			{
       
    56 			TExitCategoryName aExitCategory = p.ExitCategory();
       
    57 			test.Printf(_L("Exit      %d,%d,%S\n"),p.ExitType(),p.ExitReason(),&aExitCategory);
       
    58 			test.Printf(_L("Should be 0,%d,Kill\n"),x);
       
    59 			test.Getch();
       
    60 			test(0);
       
    61 			}
       
    62 		p.Close();
       
    63 		test.Printf(_L("%d\n"),n);
       
    64 		}
       
    65 
       
    66 //	test.End();
       
    67 	}