tstSupSem.cpp revision 5981e6935987b08737b730b63a41acc1dd696377
/* $Id$ */
/** @file
* Support Library Testcase - Ring-3 Semaphore interface.
*/
/*
* Copyright (C) 2009-2010 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;
{
}
{
}
{
bool fSys = true;
bool fGip = false;
#if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2)
fGip = true;
#endif
/*
* Init.
*/
if (RT_FAILURE(rc))
return RTMsgInitFailure(rc);
{
RTThreadSleep(300);
return 0;
}
if (RT_FAILURE(rc))
{
return 1;
}
if (RT_FAILURE(rc))
{
return RTTestSummaryAndDestroy(hTest);
}
/*
* Basic API checks.
*/
#if !defined(RT_OS_OS2) && !defined(RT_OS_WINDOWS)
RTTESTI_CHECK_RC(RTThreadCreate(&hThread, tstSupSemInterruptibleSRE, (void *)hEvent, 0, RTTHREADTYPE_TIMER, RTTHREADFLAGS_WAITABLE, "IntSRE"), VINF_SUCCESS);
RTThreadSleep(120);
int rcThread = VINF_SUCCESS;
RTTESTI_CHECK_RC(RTThreadCreate(&hThread, tstSupSemInterruptibleSRE, (void *)hEvent, 0, RTTHREADTYPE_TIMER, RTTHREADFLAGS_WAITABLE, "IntSRE"), VINF_SUCCESS);
RTThreadSleep(120);
RTTESTI_CHECK_RC(RTThreadCreate(&hThread, tstSupSemInterruptibleMRE, (void *)hEventMulti, 0, RTTHREADTYPE_TIMER, RTTHREADFLAGS_WAITABLE, "IntMRE"), VINF_SUCCESS);
RTThreadSleep(120);
RTTESTI_CHECK_RC(RTThreadCreate(&hThread, tstSupSemInterruptibleMRE, (void *)hEventMulti, 0, RTTHREADTYPE_TIMER, RTTHREADFLAGS_WAITABLE, "IntMRE"), VINF_SUCCESS);
RTThreadSleep(120);
/*
* Fork test.
* Spawn a thread waiting for an event, then spawn a new child process (of
* ourselves) and make sure that this does not alter the intended behaviour
* of our event semaphore implementation (see @bugref{5090}).
*/
RTTESTI_CHECK_RC(RTThreadCreate(&hThread, tstSupSemInterruptibleSRE, (void *)hEvent, 0, RTTHREADTYPE_TIMER, RTTHREADFLAGS_WAITABLE, "IntSRE"), VINF_SUCCESS);
RTThreadSleep(250);
RTThreadSleep(250);
RTTESTI_CHECK_RC(RTThreadCreate(&hThread, tstSupSemInterruptibleMRE, (void *)hEvent, 0, RTTHREADTYPE_TIMER, RTTHREADFLAGS_WAITABLE, "IntSRE"), VINF_SUCCESS);
RTTESTI_CHECK_RC(RTThreadCreate(&hThread2, tstSupSemInterruptibleMRE, (void *)hEvent, 0, RTTHREADTYPE_TIMER, RTTHREADFLAGS_WAITABLE, "IntSRE"), VINF_SUCCESS);
RTThreadSleep(250);
RTThreadSleep(250);
int rcThread2 = VERR_GENERAL_FAILURE;
#endif /* !OS2 && !WINDOWS */
{
if (RTTestErrorCount(hTest) == 0)
{
for (unsigned i = 0; i < RT_ELEMENTS(s_acMsIntervals); i++)
{
uint64_t cNsTotalSys= 0;
for (unsigned j = 0; j < 10; j++)
{
if (rcX != VERR_TIMEOUT)
if (cNsElapsedSys < cNsMinSys)
if (cNsElapsed < cNsMin)
cNsMin = cNsElapsed;
cNsTotal += cNsElapsed;
}
if (fSys)
{
}
if (fGip)
{
}
}
}
if (RTTestErrorCount(hTest) == 0)
{
for (unsigned i = 0; i < RT_ELEMENTS(s_acMsIntervals); i++)
{
uint64_t cNsTotalSys= 0;
for (unsigned j = 0; j < 10; j++)
{
if (rcX != VERR_TIMEOUT)
if (cNsElapsedSys < cNsMinSys)
if (cNsElapsed < cNsMin)
cNsMin = cNsElapsed;
cNsTotal += cNsElapsed;
}
if (fSys)
{
}
if (fGip)
{
}
}
}
}
{
static uint32_t const s_acNsIntervals[] =
{
0, 1000, 5000, 15000, 30000, 50000, 100000, 250000, 500000, 750000, 900000, 1500000, 2200000
};
if (RTTestErrorCount(hTest) == 0)
{
for (unsigned i = 0; i < RT_ELEMENTS(s_acNsIntervals); i++)
{
uint64_t cNsTotalSys= 0;
for (unsigned j = 0; j < 10; j++)
{
if (rcX != VERR_TIMEOUT)
if (cNsElapsedSys < cNsMinSys)
if (cNsElapsed < cNsMin)
cNsMin = cNsElapsed;
cNsTotal += cNsElapsed;
}
if (fSys)
{
}
if (fGip)
{
}
}
}
if (RTTestErrorCount(hTest) == 0)
{
for (unsigned i = 0; i < RT_ELEMENTS(s_acNsIntervals); i++)
{
uint64_t cNsTotalSys= 0;
for (unsigned j = 0; j < 10; j++)
{
if (rcX != VERR_TIMEOUT)
if (cNsElapsedSys < cNsMinSys)
if (cNsElapsed < cNsMin)
cNsMin = cNsElapsed;
cNsTotal += cNsElapsed;
}
if (fSys)
{
}
if (fGip)
{
}
}
}
if (RTTestErrorCount(hTest) == 0)
{
for (unsigned i = 0; i < RT_ELEMENTS(s_acNsIntervals); i++)
{
uint64_t cNsTotalSys= 0;
for (unsigned j = 0; j < 10; j++)
{
if (rcX != VERR_TIMEOUT)
if (cNsElapsedSys < cNsMinSys)
if (cNsElapsed < cNsMin)
cNsMin = cNsElapsed;
cNsTotal += cNsElapsed;
}
if (fSys)
{
}
if (fGip)
{
}
}
}
if (RTTestErrorCount(hTest) == 0)
{
for (unsigned i = 0; i < RT_ELEMENTS(s_acNsIntervals); i++)
{
uint64_t cNsTotalSys= 0;
for (unsigned j = 0; j < 10; j++)
{
if (rcX != VERR_TIMEOUT)
if (cNsElapsedSys < cNsMinSys)
if (cNsElapsed < cNsMin)
cNsMin = cNsElapsed;
cNsTotal += cNsElapsed;
}
if (fSys)
{
}
if (fGip)
{
}
}
}
}
/*
* Done.
*/
return RTTestSummaryAndDestroy(hTest);
}