tstOVF.cpp revision 230bd8589bba39933ac5ec21482d6186d675e604
/* $Id$ */
/** @file
*
* tstOVF - testcases for OVF import and export
*/
/*
* 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.
*/
#include <iprt/initterm.h>
#include <list>
using namespace com;
// main
///////////////////////////////////////////////////////////////////////////////
/**
* Quick hack exception structure.
*
*/
struct MyError
{
const char *pcsz,
{
m_str = "ERROR: ";
if (pProgress)
{
}
else if (rc)
{
else
}
}
};
/**
* Imports the given OVF file, with all bells and whistles.
* Throws MyError on errors.
* @param pcszPrefix Descriptive short prefix string for console output.
* @param pVirtualBox VirtualBox instance.
* @param pcszOVF0 File to import.
* @param llMachinesCreated out: UUIDs of machines that were created so that caller can clean up.
*/
void importOVF(const char *pcszPrefix,
const char *pcszOVF0,
{
char szAbsOVF[RTPATH_MAX];
for (uint32_t u = 0;
u < aDescriptions.size();
++u)
{
++u2)
{
const char *pcszType;
switch (t)
{
pcszType = "ostype";
break;
pcszType = "name";
break;
pcszType = "product";
break;
pcszType = "producturl";
break;
pcszType = "vendor";
break;
pcszType = "vendorurl";
break;
pcszType = "version";
break;
pcszType = "description";
break;
pcszType = "license";
break;
pcszType = "cpu";
break;
pcszType = "memory";
break;
pcszType = "ide";
break;
pcszType = "sata";
break;
pcszType = "sas";
break;
pcszType = "scsi";
break;
pcszType = "hd";
break;
pcszType = "cdrom";
break;
pcszType = "floppy";
break;
pcszType = "net";
break;
pcszType = "usb";
break;
pcszType = "sound";
break;
default:
break;
}
RTPrintf(" vsys %2u item %2u: type %2d (%s), ovf: \"%ls\", vbox: \"%ls\", extra: \"%ls\"\n",
aOvfValues[u2],
}
}
for (size_t u = 0;
u < aMachineUUIDs.size();
++u)
{
}
}
/**
* Copies ovf-testcases/ovf-dummy.vmdk to the given target and appends that
* target as a string to the given list so that the caller can delete it
* again later.
* @param llFiles2Delete List of strings to append the target file path to.
* @param pcszDest Target for dummy VMDK.
*/
void copyDummyDiskImage(const char *pcszPrefix,
const char *pcszDest)
{
if (RT_FAILURE(vrc)) throw MyError(0, Utf8StrFmt("Cannot copy ovf-dummy.vmdk to %s: %Rra\n", pcszDest, vrc).c_str());
}
/**
*
* @param argc
* @param argv[]
* @return
*/
{
try
{
RTPrintf("Initializing COM...\n");
RTPrintf("Creating VirtualBox object...\n");
// create the event queue
// for each testcase, we will copy the dummy VMDK image to the subdirectory with the OVF testcase
// so that the import will find the disks it expects; this is just for testing the import since
// the imported machines will obviously not be usable.
// llFiles2Delete receives the paths of all the files that we need to clean up later.
// testcase 1: import ovf-joomla-0.9/joomla-1.1.4-ovf.ovf
copyDummyDiskImage("joomla-0.9", llFiles2Delete, "ovf-testcases/ovf-joomla-0.9/joomla-1.1.4-ovf-0.vmdk");
copyDummyDiskImage("joomla-0.9", llFiles2Delete, "ovf-testcases/ovf-joomla-0.9/joomla-1.1.4-ovf-1.vmdk");
importOVF("joomla-0.9", pVirtualBox, "ovf-testcases/ovf-joomla-0.9/joomla-1.1.4-ovf.ovf", llMachinesCreated);
// testcase 2: import ovf-winxp-vbox-sharedfolders/winxp.ovf
copyDummyDiskImage("winxp-vbox-sharedfolders", llFiles2Delete, "ovf-testcases/ovf-winxp-vbox-sharedfolders/Windows 5.1 XP 1 merged.vmdk");
copyDummyDiskImage("winxp-vbox-sharedfolders", llFiles2Delete, "ovf-testcases/ovf-winxp-vbox-sharedfolders/smallvdi.vmdk");
importOVF("winxp-vbox-sharedfolders", pVirtualBox, "ovf-testcases/ovf-winxp-vbox-sharedfolders/winxp.ovf", llMachinesCreated);
// testcase 3: import ovf-winxp-vbox-sharedfolders/winxp.ovf
importOVF("winhost-audio-nodisks", pVirtualBox, "ovf-testcases/ovf-winhost-audio-nodisks/WinXP.ovf", llMachinesCreated);
RTPrintf("Machine imports done, no errors. Cleaning up...\n");
}
catch (MyError &e)
{
}
try
{
// clean up the machines created
++it)
{
}
}
catch (MyError &e)
{
}
// clean up the VMDK copies that we made in copyDummyDiskImage()
++it)
{
}
RTPrintf("Shutting down COM...\n");
RTPrintf ("tstOVF all done!\n");
return rc;
}