tstVMREQ.cpp revision fb5e37303b228a79c05cabfce2fe0fedfe32ed8a
/* $Id$ */
/** @file
* VMM Testcase.
*/
/*
* Copyright (C) 2006 InnoTek Systemberatung GmbH
*
* 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 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.
*
* If you received this file as part of a commercial VirtualBox
* distribution, then only the terms of your commercial VirtualBox
* license agreement apply instead of the previous paragraph.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <iprt/semaphore.h>
/*******************************************************************************
* Defined Constants And Macros *
*******************************************************************************/
#define TESTCASE "tstVMREQ"
/**
* Thread function which allocates and frees requests like wildfire.
*/
{
int rc = VINF_SUCCESS;
for (unsigned i = 0; i < 100000; i++)
{
unsigned iReq;
{
if (VBOX_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 (VBOX_FAILURE(rc))
{
return rc;
}
}
//if (!(i % 10000))
// RTPrintf(TESTCASE ": i=%d\n", i);
}
return VINF_SUCCESS;
}
{
int cErrors = 0;
RTR3Init();
/*
* Create empty VM.
*/
if (VBOX_SUCCESS(rc))
{
/*
* Do testing.
*/
rc = RTThreadCreate(&Thread0, Thread, pVM, 0, RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, "REQ1");
if (VBOX_SUCCESS(rc))
{
rc = RTThreadCreate(&Thread1, Thread, pVM, 0, RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, "REQ1");
if (VBOX_SUCCESS(rc))
{
int rcThread1;
if (VBOX_FAILURE(rc))
{
cErrors++;
}
if (VBOX_FAILURE(rcThread1))
cErrors++;
}
else
{
cErrors++;
}
int rcThread0;
if (VBOX_FAILURE(rc))
{
cErrors++;
}
if (VBOX_FAILURE(rcThread0))
cErrors++;
}
else
{
cErrors++;
}
/*
* Print stats.
*/
/*
* Cleanup.
*/
if (!VBOX_SUCCESS(rc))
{
cErrors++;
}
}
else
{
cErrors++;
}
/*
* Summary and return.
*/
if (!cErrors)
else
return !!cErrors;
}