/** @file
*
* Simple VBox HDD container test utility. Compares two images and prints
* differences. Mainly used to check cloning of disk images.
*/
/*
* 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"
/* from VBoxHDD.cpp */
/*******************************************************************************
* Global Variables *
*******************************************************************************/
/** The error count. */
unsigned g_cErrors = 0;
{
g_cErrors++;
RTPrintf("\n");
}
{
int rc;
if (argc != 3)
{
RTPrintf("Usage: ./tstVDCopy <hdd1> <hdd2>\n");
return 1;
}
RTPrintf("tstVDCopy: TESTING...\n");
do \
{ \
if (RT_FAILURE(rc)) \
{ \
if (pVD1) \
VDCloseAll(pVD1); \
if (pVD2) \
VDCloseAll(pVD2); \
return rc; \
} \
} while (0)
/* Create error interface. */
CHECK("VDGetFormat() hdd1");
CHECK("VDGetFormat() hdd2");
CHECK("VDCreate() hdd1");
CHECK("VDCreate() hdd1");
CHECK("VDOpen() hdd1");
CHECK("VDOpen() hdd2");
{
/* Compare block by block. */
{
CHECK("VDRead() hdd1");
CHECK("VDRead() hdd2");
{
/* Do byte by byte comparison. */
{
{
break;
}
}
break;
}
}
}
else
CHECK("VDClose() hdd1");
CHECK("VDClose() hdd2");
rc = VDShutdown();
if (RT_FAILURE(rc))
{
g_cErrors++;
}
/*
* Summary
*/
if (!g_cErrors)
RTPrintf("tstVDCopy: SUCCESS\n");
else
return !!g_cErrors;
}