tstOVF.cpp revision d8b658a6b59104fdf0a35e569136f9b42fcf672d
/* $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 pVirtualBox VirtualBox instance.
* @param pcszOVF File to import.
*/
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],
}
}
}
/**
* 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.
*/
{
if (RT_FAILURE(vrc))
}
/**
*
* @param argc
* @param argv[]
* @return
*/
{
RTR3Init();
try
{
RTPrintf("Initializing COM...\n");
RTPrintf("Creating VirtualBox object...\n");
// create the event queue
// testcase 1: import ovf-joomla-0.9/joomla-1.1.4-ovf.ovf
// copyDummyDiskImage(llFiles2Delete, "ovf-testcases/ovf-joomla-0.9/joomla-1.1.4-ovf-0.vmdk");
// copyDummyDiskImage(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");
// testcase 2: import ovf-winxp-vbox-sharedfolders/winxp.ovf
copyDummyDiskImage(llFiles2Delete, "ovf-testcases/ovf-winxp-vbox-sharedfolders/Windows 5.1 XP 1 merged.vmdk");
importOVF("winxp-vbox-sharedfolders", pVirtualBox, "ovf-testcases/ovf-winxp-vbox-sharedfolders/winxp.ovf");
RTPrintf ("tstOVF all done, no errors.\n");
// todo: cleanup created machines, created disk images
}
catch (MyError &e)
{
}
// clean up
++it)
{
}
RTPrintf("Shutting down COM...\n");
return rc;
}