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.
sl@0
     1
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// T_WAITPIDLAUNCH.CPP
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include <e32cons.h>
sl@0
    19
#include <e32test.h>
sl@0
    20
sl@0
    21
sl@0
    22
LOCAL_D RTest test(_L("WAITPID DEF073739"));
sl@0
    23
LOCAL_D RProcess me;
sl@0
    24
sl@0
    25
sl@0
    26
/**
sl@0
    27
@SYMTestCaseID 			SYSLIB-STDLIB-UT-1575
sl@0
    28
@SYMTestCaseDesc	    Testing if POSIX waitpid function conforms to POSIX standard
sl@0
    29
@SYMTestPriority 	    High
sl@0
    30
@SYMTestActions  	    Starts a new process (T_WAITPID) this new process
sl@0
    31
						creates some processes and tests the POSIX waitpid function behaves correctly
sl@0
    32
						by waiting for these processes.
sl@0
    33
@SYMTestExpectedResults The test should not fail.
sl@0
    34
@SYMDEF 				INC073739
sl@0
    35
*/
sl@0
    36
sl@0
    37
//INC073739 Incorrect error codes returned from waitpid() in STDLIB
sl@0
    38
void Defect_073739()
sl@0
    39
	{
sl@0
    40
sl@0
    41
sl@0
    42
	test.Printf(_L("Create a new process t_waitpid to test POSIX waitpid\n"));
sl@0
    43
	//Creating another process to run T_WAITPID and test if it completed correctly
sl@0
    44
	TInt err=me.Create(_L("T_WAITPID"),_L(""));
sl@0
    45
	if (err==KErrNotFound)
sl@0
    46
		err=me.Create(_L("z:\\test\\T_WAITPID"),_L(""));
sl@0
    47
	if (err==KErrNotFound)
sl@0
    48
		err=me.Create(_L("c:\\test\\T_WAITPID"),_L(""));
sl@0
    49
	if (err==KErrNotFound)
sl@0
    50
		err=me.Create(_L("c:\\sys\\bin\\T_WAITPID"),_L(""));
sl@0
    51
	test(err==KErrNone);
sl@0
    52
sl@0
    53
	//Checking that the child proces T_WAITPID executes properly with no panic
sl@0
    54
	TRequestStatus status;
sl@0
    55
	me.Logon(status);
sl@0
    56
	me.Resume();
sl@0
    57
	User::WaitForRequest(status);
sl@0
    58
	//Test to make sure the child process ended correctly
sl@0
    59
	test(status==KErrNone);
sl@0
    60
	test(me.ExitReason()==KErrNone);
sl@0
    61
	me.Close();
sl@0
    62
	}
sl@0
    63
sl@0
    64
sl@0
    65
/**
sl@0
    66
Invoke the tests
sl@0
    67
*/
sl@0
    68
LOCAL_C void RunTestsL ()
sl@0
    69
    {
sl@0
    70
	Defect_073739();
sl@0
    71
	}
sl@0
    72
sl@0
    73
sl@0
    74
GLDEF_C TInt E32Main()
sl@0
    75
    {
sl@0
    76
	test.Title();
sl@0
    77
	test.Start(_L(" @SYMTestCaseID:SYSLIB-STDLIB-UT-1575 Starting the T_WAITPID tests... "));
sl@0
    78
	__UHEAP_MARK;
sl@0
    79
	CTrapCleanup* cleanup=CTrapCleanup::New();
sl@0
    80
	test(cleanup != NULL);
sl@0
    81
	TRAPD(error,RunTestsL());
sl@0
    82
	test(error==KErrNone);
sl@0
    83
	test.End();
sl@0
    84
	test.Close();
sl@0
    85
	delete cleanup;
sl@0
    86
	__UHEAP_MARKEND;
sl@0
    87
	return 0;
sl@0
    88
    }