tstVMREQ.cpp revision cfb87b49d2b36055eb5aea681936cdc130b54267
/* $Id$ */
/** @file
* VMM Testcase.
*/
/*
* Copyright (C) 2006-2007 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.
*/
/*******************************************************************************
* 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, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list va)
{
{
g_cErrors++;
}
if (fFlags)
{
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
int rc = VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)PassVACallback, 5, pVM, _4K, _1G, pszFormat, pvVA);
#if 1
#endif
}
/**
* Functions that tests passing a va_list * argument in a request,
* similar to VMSetRuntimeError.
*/
{
/* 1st test */
int rc = VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)PassVACallback, 5, pVM, _4K, _1G, pszFormat, &va1);
/* 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;
}