os/ossrv/genericopenlibs/cstdlib/TSTLIB/t_waitpid_launch.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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 	if (err==KErrNotFound)
    48 		err=me.Create(_L("c:\\test\\T_WAITPID"),_L(""));
    49 	if (err==KErrNotFound)
    50 		err=me.Create(_L("c:\\sys\\bin\\T_WAITPID"),_L(""));
    51 	test(err==KErrNone);
    52 
    53 	//Checking that the child proces T_WAITPID executes properly with no panic
    54 	TRequestStatus status;
    55 	me.Logon(status);
    56 	me.Resume();
    57 	User::WaitForRequest(status);
    58 	//Test to make sure the child process ended correctly
    59 	test(status==KErrNone);
    60 	test(me.ExitReason()==KErrNone);
    61 	me.Close();
    62 	}
    63 
    64 
    65 /**
    66 Invoke the tests
    67 */
    68 LOCAL_C void RunTestsL ()
    69     {
    70 	Defect_073739();
    71 	}
    72 
    73 
    74 GLDEF_C TInt E32Main()
    75     {
    76 	test.Title();
    77 	test.Start(_L(" @SYMTestCaseID:SYSLIB-STDLIB-UT-1575 Starting the T_WAITPID tests... "));
    78 	__UHEAP_MARK;
    79 	CTrapCleanup* cleanup=CTrapCleanup::New();
    80 	test(cleanup != NULL);
    81 	TRAPD(error,RunTestsL());
    82 	test(error==KErrNone);
    83 	test.End();
    84 	test.Close();
    85 	delete cleanup;
    86 	__UHEAP_MARKEND;
    87 	return 0;
    88     }