tstSupSem-Zombie.cpp revision c58f1213e628a545081c70e26c6b67a841cff880
/* $Id$ */
/** @file
* Support Library Testcase - Ring-3 Semaphore interface - Zombie bugs.
*/
/*
* Copyright (C) 2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <iprt/initterm.h>
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
static PSUPDRVSESSION g_pSession;
{
return rc;
}
{
return rc;
}
{
return rc;
}
{
return rc;
}
static int mainChild(void)
{
/*
* Init.
*/
if (RT_FAILURE(rc))
{
return 1;
}
if (RT_FAILURE(rc))
{
return 1;
}
if (RT_FAILURE(rc))
{
return RTTestSummaryAndDestroy(hTest);
}
/*
* A semaphore of each kind and throw a bunch of threads on them.
*/
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
{
{
RTTESTI_CHECK_RC(RTThreadCreate(&hThread, tstSupSemSRETimed, (void *)hEvent, 0, RTTHREADTYPE_TIMER, 0 /*fFlags*/, "IntSRE"), VINF_SUCCESS);
RTTESTI_CHECK_RC(RTThreadCreate(&hThread, tstSupSemMRETimed, (void *)hEventMulti, 0, RTTHREADTYPE_TIMER, 0 /*fFlags*/, "IntMRE"), VINF_SUCCESS);
RTTESTI_CHECK_RC(RTThreadCreate(&hThread, tstSupSemSREInf, (void *)hEvent, 0, RTTHREADTYPE_TIMER, 0 /*fFlags*/, "IntSRE"), VINF_SUCCESS);
RTTESTI_CHECK_RC(RTThreadCreate(&hThread, tstSupSemMREInf, (void *)hEventMulti, 0, RTTHREADTYPE_TIMER, 0 /*fFlags*/, "IntMRE"), VINF_SUCCESS);
RTThreadSleep(2);
}
RTThreadSleep(50);
/*
* This is where the test really starts...
*/
return 0;
}
}
return RTTestSummaryAndDestroy(hTest);
}
/**
* The parent main routine.
* @param argv0 The executable name (or whatever).
*/
static int mainParent(const char *argv0)
{
/*
* Init.
*/
if (rc)
return rc;
/*
* Spin of the child process which may or may not turn into a zombie
*/
{
if (RT_SUCCESS(rc))
{
/*
* Wait for 60 seconds then give up.
*/
for (;;)
{
if (RT_SUCCESS(rc))
break;
break;
}
if ( RT_SUCCESS(rc)
{
}
}
/* one zombie process is enough. */
if (RT_FAILURE(rc))
break;
}
return RTTestSummaryAndDestroy(hTest);
}
{
if ( argc == 2
return mainChild();
return mainParent(argv[0]);
}