tstVMMR0CallHost-1.cpp revision 5eabf773597082761832bc0a32b3660e8771f9f1
/* $Id$ */
/** @file
* Testcase for the VMMR0JMPBUF operations.
*/
/*
* 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>
#define IN_VMM_R0
#define IN_RING0 /* pretent we're in Ring-0 to get the prototypes. */
#include "VMMInternal.h"
/*******************************************************************************
* Global Variables *
*******************************************************************************/
/** The jump buffer. */
static VMMR0JMPBUF g_Jmp;
/** The number of jumps we've done. */
static unsigned volatile g_cJmps;
/** The saved stack. */
{
/* allocate a buffer which we fill up to the end. */
/* Do long jmps every 7th time */
if ((i % 7) == 0)
{
g_cJmps++;
if (!rc)
return i + 10000;
return -1;
}
return i;
}
{
if (i < 0 || i > 8192)
{
RTPrintf("tstVMMR0CallHost-1: FAILURE - i=%d is out of range [0..8192]\n", i);
return 1;
}
if (i2 != 0)
{
return 1;
}
{
return 1;
}
return 0;
}
{
g_cJmps = 0;
{
{
return 1;
}
}
if (!g_cJmps)
{
RTPrintf("tstVMMR0CallHost-1: FAILURE - no jumps!\n");
return 1;
}
return 0;
}
int main()
{
/*
* Init.
*/
RTR3Init();
/*
* Try about 1000 long jumps with increasing stack size..
*/
RTPrintf("tstVMMR0CallHost-1: Testing 1\n");
if (!rc)
{
RTPrintf("tstVMMR0CallHost-1: Testing 2\n");
}
if (!rc)
RTPrintf("tstVMMR0CallHost-1: SUCCESS\n");
else
RTPrintf("tstVMMR0CallHost-1: FAILED\n");
return !!rc;
}