/* $Id$ */
/** @file
* MM Hypervisor Heap testcase.
*/
/*
* Copyright (C) 2006-2012 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>
/* does not work for more CPUs as SUPR3LowAlloc() would refuse to allocate more pages */
/**
* Entry point.
*/
{
/*
* Init runtime.
*/
/*
* Create empty VM structure and call MMR3Init().
*/
if (RT_SUCCESS(rc))
if (RT_FAILURE(rc))
{
return 1;
}
if (RT_FAILURE(rc))
{
return 1;
}
if (RT_FAILURE(rc))
{
return 1;
}
if (RT_FAILURE(rc))
{
return 1;
}
if (RT_FAILURE(rc))
{
return 1;
}
/*
* Try allocate.
*/
static struct
{
unsigned uAlignment;
void *pvAlloc;
unsigned iFreeOrder;
} aOps[] =
{
{ 16, 0, NULL, 0 },
};
unsigned i;
#ifdef DEBUG
#endif
/* allocate */
for (i = 0; i < RT_ELEMENTS(aOps); i++)
{
if (RT_FAILURE(rc))
{
return 1;
}
{
RTPrintf("Failure: MMHyperAlloc(, %#x, %#x,) -> %p, invalid alignment!\n", aOps[i].cb, aOps[i].uAlignment, aOps[i].pvAlloc);
return 1;
}
}
/* free and allocate the same node again. */
for (i = 0; i < RT_ELEMENTS(aOps); i++)
{
continue;
//size_t cbBeforeSub = MMHyperHeapGetFreeSize(pVM);
if (RT_FAILURE(rc))
{
return 1;
}
//RTPrintf("debug: i=%d cbBeforeSub=%d now=%d\n", i, cbBeforeSub, MMHyperHeapGetFreeSize(pVM));
void *pv;
if (RT_FAILURE(rc))
{
return 1;
}
{
RTPrintf("Failure: Free+Alloc returned different address. new=%p old=%p i=%d (doesn't work with delayed free)\n", pv, aOps[i].pvAlloc, i);
//return 1;
}
#if 0 /* won't work :/ */
if (cbBeforeSub != cbAfterSub)
{
return 1;
}
#endif
}
/* free it in a specific order. */
int cFreed = 0;
for (i = 0; i < RT_ELEMENTS(aOps); i++)
{
unsigned j;
for (j = 0; j < RT_ELEMENTS(aOps); j++)
{
if ( aOps[j].iFreeOrder != i
continue;
RTPrintf("j=%d i=%d free=%d cb=%d pv=%p\n", j, i, MMHyperHeapGetFreeSize(pVM), aOps[j].cb, aOps[j].pvAlloc);
else
{
if (RT_FAILURE(rc))
{
return 1;
}
}
cFreed++;
}
}
/* check that we're back at the right amount of free memory. */
{
RTPrintf("Warning: Either we've split out an alignment chunk at the start, or we've got\n"
#ifdef DEBUG
#endif
}
RTPrintf("tstMMHyperHeap: Success\n");
#ifdef LOG_ENABLED
#endif
return 0;
}
#if !defined(VBOX_WITH_HARDENING) || !defined(RT_OS_WINDOWS)
/**
* Main entry point.
*/
{
}
#endif