/** @file
*
* Simple VBox HDD container test utility. Only fast tests.
*/
/*
* Copyright (C) 2006-2011 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.
*/
#include <iprt/initterm.h>
#include "stdio.h"
#include "stdlib.h"
/*******************************************************************************
* Global Variables *
*******************************************************************************/
/** The error count. */
unsigned g_cErrors = 0;
static struct KeyValuePair {
const char *key;
const char *value;
} aCfgNode[] = {
{ "TargetName", "test" },
{ "LUN", "1" },
{ "TargetAddress", "address" },
};
{
return true;
}
{
return NULL;
}
{
if (!pszValue)
return VERR_CFGM_VALUE_NOT_FOUND;
return VINF_SUCCESS;
}
{
if (!pszValue)
return VERR_CFGM_VALUE_NOT_FOUND;
return VERR_CFGM_NOT_ENOUGH_SPACE;
return VINF_SUCCESS;
}
{
switch (enmType)
{
case VDTYPE_HDD:
return "HardDisk";
case VDTYPE_DVD:
return "DVD";
case VDTYPE_FLOPPY:
return "Floppy";
default:
return "Unknown";
}
}
static int tstVDBackendInfo(void)
{
int rc;
unsigned cEntries;
do \
{ \
if (RT_FAILURE(rc)) \
return rc; \
} while (0)
CHECK("VDBackendInfo()");
for (unsigned i=0; i < cEntries; i++)
{
RTPrintf("Backend %u: name=%s capabilities=%#06x extensions=",
if (aVDInfo[i].paFileExtensions)
{
{
RTPrintf(",");
pa++;
}
RTPrintf("<EMPTY>");
}
else
RTPrintf("<NONE>");
RTPrintf(" config=");
if (aVDInfo[i].paConfigInfo)
{
{
RTPrintf(",");
switch (pa->enmValueType)
{
case VDCFGVALUETYPE_INTEGER:
RTPrintf("integer");
break;
case VDCFGVALUETYPE_STRING:
RTPrintf("string");
break;
case VDCFGVALUETYPE_BYTES:
RTPrintf("bytes");
break;
default:
RTPrintf("INVALID!");
}
RTPrintf(" default=");
if (pa->pszDefaultValue)
else
RTPrintf("<NONE>");
RTPrintf(" flags=");
RTPrintf("none");
unsigned cFlags = 0;
{
if (cFlags)
RTPrintf(",");
RTPrintf("mandatory");
cFlags++;
}
{
if (cFlags)
RTPrintf(",");
RTPrintf("expert");
cFlags++;
}
RTPrintf(")");
pa++;
}
RTPrintf("<EMPTY>");
}
else
RTPrintf("<NONE>");
RTPrintf("\n");
CHECK("pfnComposeLocation()");
if (pszLocation)
{
{
RTPrintf("Non-NULL location returned for file-based backend!\n");
return VERR_INTERNAL_ERROR;
}
}
CHECK("pfnComposeName()");
if (pszName)
{
{
RTPrintf("Non-NULL name returned for file-based backend!\n");
return VERR_INTERNAL_ERROR;
}
}
}
return 0;
}
{
int rc;
RTPrintf("tstVD-2: TESTING...\n");
rc = tstVDBackendInfo();
if (RT_FAILURE(rc))
{
g_cErrors++;
}
rc = VDShutdown();
if (RT_FAILURE(rc))
{
g_cErrors++;
}
/*
* Summary
*/
if (!g_cErrors)
RTPrintf("tstVD-2: SUCCESS\n");
else
return !!g_cErrors;
}