tstVMREQ.cpp revision 5eabf773597082761832bc0a32b3660e8771f9f1
/* $Id$ */
/** @file
* VMM Testcase.
*/
/*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* 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.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <iprt/initterm.h>
#include <iprt/semaphore.h>
/*******************************************************************************
* Defined Constants And Macros *
*******************************************************************************/
#define TESTCASE "tstVMREQ"
/*******************************************************************************
* Global Variables *
*******************************************************************************/
/** the error count. */
static int g_cErrors = 0;
/**
* Testings va_list passing in VMSetRuntimeError.
*/
static DECLCALLBACK(void) MyAtRuntimeError(PVM pVM, void *pvUser, bool fFatal, const char *pszErrorId, const char *pszFormat, va_list va)
{
{
g_cErrors++;
}
if (fFatal)
{
g_cErrors++;
}
{
g_cErrors++;
}
{
g_cErrors++;
}
char szBuf[1024];
{
g_cErrors++;
}
}
/**
* The function PassVA and PassVA2 calls.
*/
static DECLCALLBACK(int) PassVACallback(PVM pVM, unsigned u4K, unsigned u1G, const char *pszFormat, va_list *pva)
{
{
g_cErrors++;
}
{
g_cErrors++;
}
{
g_cErrors++;
}
char szBuf[1024];
{
g_cErrors++;
}
return VINF_SUCCESS;
}
/**
* Functions that tests passing a va_list * argument in a request,
* similar to VMSetRuntimeError.
*/
{
#if 0 /** @todo test if this is a GCC problem only or also happens with AMD64+VCC80... */
#else
#endif
if (RT_SUCCESS(rc))
#if 1
#endif
}
/**
* Functions that tests passing a va_list * argument in a request,
* similar to VMSetRuntimeError.
*/
{
/* 1st test */
if (RT_SUCCESS(rc))
/* 2nd test */
}
/**
* Thread function which allocates and frees requests like wildfire.
*/
{
int rc = VINF_SUCCESS;
for (unsigned i = 0; i < 100000; i++)
{
unsigned iReq;
{
if (RT_FAILURE(rc))
{
return rc;
}
}
{
{
RTPrintf(TESTCASE ": i=%d iReq=%d cReqs=%d: iStatus=%d != %d\n", i, iReq, cReqs, apReq[iReq]->iStatus, iReq + i);
return VERR_GENERAL_FAILURE;
}
if (RT_FAILURE(rc))
{
return rc;
}
}
//if (!(i % 10000))
// RTPrintf(TESTCASE ": i=%d\n", i);
}
return VINF_SUCCESS;
}
{
/*
* Create empty VM.
*/
if (RT_SUCCESS(rc))
{
/*
* Do testing.
*/
rc = RTThreadCreate(&Thread0, Thread, pVM, 0, RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, "REQ1");
if (RT_SUCCESS(rc))
{
rc = RTThreadCreate(&Thread1, Thread, pVM, 0, RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, "REQ1");
if (RT_SUCCESS(rc))
{
int rcThread1;
if (RT_FAILURE(rc))
{
g_cErrors++;
}
if (RT_FAILURE(rcThread1))
g_cErrors++;
}
else
{
g_cErrors++;
}
int rcThread0;
if (RT_FAILURE(rc))
{
g_cErrors++;
}
if (RT_FAILURE(rcThread0))
g_cErrors++;
}
else
{
g_cErrors++;
}
/*
* Print stats.
*/
/*
* Testing va_list fun.
*/
/*
* Cleanup.
*/
if (!RT_SUCCESS(rc))
{
g_cErrors++;
}
}
else
{
g_cErrors++;
}
/*
* Summary and return.
*/
if (!g_cErrors)
else
return !!g_cErrors;
}