tstVDShareable.cpp revision cd6f71bc352f550074f1ba2c830a2cf2f0b3dd46
/* $Id$ */
/** @file
* Simple VBox HDD container test utility for shareable images.
*/
/*
* Copyright (C) 2010 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/asm-amd64-x86.h>
#include <iprt/initterm.h>
#include "stdio.h"
#include "stdlib.h"
#define VHD_TEST
#define VDI_TEST
#define VMDK_TEST
/*******************************************************************************
* Global Variables *
*******************************************************************************/
/** The error count. */
unsigned g_cErrors = 0;
{
g_cErrors++;
RTPrintf("\n");
}
{
RTPrintf("tstVD: ");
return VINF_SUCCESS;
}
{
int rc;
VDGEOMETRY PCHS = { 0, 0, 0 };
VDGEOMETRY LCHS = { 0, 0, 0 };
do \
{ \
if (RT_FAILURE(rc)) \
{ \
return rc; \
} \
} while (0)
/* Create error interface. */
CHECK("VDCreate()");
CHECK("VDCreate() #2");
CHECK("VDCreateBase()");
CHECK("VDOpen()");
CHECK("VDOpen() #2");
if (VDIsReadOnly(pVD2))
return 0;
}
{
RTR3Init();
int rc;
RTPrintf("tstVD: TESTING...\n");
/*
* Clean up potential leftovers from previous unsuccessful runs.
*/
RTFileDelete("tmpVDCreate.vdi");
if (!RTDirExists("tmp"))
{
if (RT_FAILURE(rc))
{
g_cErrors++;
}
}
#ifdef VDI_TEST
if (RT_FAILURE(rc))
{
g_cErrors++;
}
#endif /* VDI_TEST */
/*
* Clean up any leftovers.
*/
RTFileDelete("tmpVDCreate.vdi");
rc = VDShutdown();
if (RT_FAILURE(rc))
{
g_cErrors++;
}
/*
* Summary
*/
if (!g_cErrors)
RTPrintf("tstVD: SUCCESS\n");
else
return !!g_cErrors;
}