genericopenlibs/cstdlib/TSTLIB/t_waitpid_launch.cpp
changeset 0 e4d67989cc36
child 67 a1e347446159
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 // Copyright (c) 2005-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 // T_WAITPIDLAUNCH.CPP
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <e32cons.h>
       
    19 #include <e32test.h>
       
    20 
       
    21 
       
    22 LOCAL_D RTest test(_L("WAITPID DEF073739"));
       
    23 LOCAL_D RProcess me;
       
    24 
       
    25 
       
    26 /**
       
    27 @SYMTestCaseID 			SYSLIB-STDLIB-UT-1575
       
    28 @SYMTestCaseDesc	    Testing if POSIX waitpid function conforms to POSIX standard
       
    29 @SYMTestPriority 	    High
       
    30 @SYMTestActions  	    Starts a new process (T_WAITPID) this new process
       
    31 						creates some processes and tests the POSIX waitpid function behaves correctly
       
    32 						by waiting for these processes.
       
    33 @SYMTestExpectedResults The test should not fail.
       
    34 @SYMDEF 				INC073739
       
    35 */
       
    36 
       
    37 //INC073739 Incorrect error codes returned from waitpid() in STDLIB
       
    38 void Defect_073739()
       
    39 	{
       
    40 
       
    41 
       
    42 	test.Printf(_L("Create a new process t_waitpid to test POSIX waitpid\n"));
       
    43 	//Creating another process to run T_WAITPID and test if it completed correctly
       
    44 	TInt err=me.Create(_L("T_WAITPID"),_L(""));
       
    45 	if (err==KErrNotFound)
       
    46 		err=me.Create(_L("z:\\test\\T_WAITPID"),_L(""));
       
    47 	test(err==KErrNone);
       
    48 
       
    49 	//Checking that the child proces T_WAITPID executes properly with no panic
       
    50 	TRequestStatus status;
       
    51 	me.Logon(status);
       
    52 	me.Resume();
       
    53 	User::WaitForRequest(status);
       
    54 	//Test to make sure the child process ended correctly
       
    55 	test(status==KErrNone);
       
    56 	test(me.ExitReason()==KErrNone);
       
    57 	me.Close();
       
    58 	}
       
    59 
       
    60 
       
    61 /**
       
    62 Invoke the tests
       
    63 */
       
    64 LOCAL_C void RunTestsL ()
       
    65     {
       
    66 	Defect_073739();
       
    67 	}
       
    68 
       
    69 
       
    70 GLDEF_C TInt E32Main()
       
    71     {
       
    72 	test.Title();
       
    73 	test.Start(_L(" @SYMTestCaseID:SYSLIB-STDLIB-UT-1575 Starting the T_WAITPID tests... "));
       
    74 	__UHEAP_MARK;
       
    75 	CTrapCleanup* cleanup=CTrapCleanup::New();
       
    76 	test(cleanup != NULL);
       
    77 	TRAPD(error,RunTestsL());
       
    78 	test(error==KErrNone);
       
    79 	test.End();
       
    80 	test.Close();
       
    81 	delete cleanup;
       
    82 	__UHEAP_MARKEND;
       
    83 	return 0;
       
    84     }