tstHeadless.cpp revision dc09cb937d0a66e030b4d7bef88dec429f41e060
/** @file
*
* VBox frontends: VBoxHeadless frontend:
* Testcases
*/
/*
* Copyright (C) 2006-2009 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.
*/
using namespace com;
#include <iprt/initterm.h>
////////////////////////////////////////////////////////////////////////////////
/**
* Entry point.
*/
{
// initialize VBox Runtime
RTR3Init();
// the below cannot be Bstr because on Linux Bstr doesn't work
// until XPCOM (nsMemory) is initialized
// parse the command line
if (argc > 1)
if (argc > 2)
{
RTPrintf ("\nUsage:\n\n"
"%s <machine_name> [on|off|pause|resume]\n\n",
argv [0]);
return -1;
}
RTPrintf ("\n");
RTPrintf ("tstHeadless STARTED.\n");
RTPrintf ("VM name : {%s}\n"
"Operation : %s\n\n",
{
RTPrintf("ERROR: failed to initialize COM!\n");
return rc;
}
do
{
RTPrintf ("Creating VirtualBox object...\n");
RTPrintf("ERROR: failed to create the VirtualBox object!\n");
else
{
RTPrintf("ERROR: failed to create a session object!\n");
}
{
{
RTPrintf("Most likely, the VirtualBox COM server is not running or failed to start.\n");
}
else
break;
}
// create the event queue
// after the session is closed)
// find ID by name
{
}
{
RTPrintf ("Opening a new (remote) session...\n");
RTPrintf ("Waiting for the remote session to open...\n");
if (FAILED (resultCode))
{
}
else
{
RTPrintf ("Remote session has been successfully opened.\n");
}
}
else
{
RTPrintf ("Opening an existing session...\n");
{
RTPrintf ("Powering the VM off...\n");
RTPrintf ("Waiting for the VM to power down...\n");
if (FAILED (resultCode))
{
}
else
{
RTPrintf ("VM is powered down.\n");
}
}
else
{
RTPrintf ("Pausing the VM...\n");
}
else
{
RTPrintf ("Resuming the VM...\n");
}
else
{
RTPrintf ("Invalid operation!\n");
}
}
RTPrintf ("Closing the session (may fail after power off)...\n");
}
while (0);
RTPrintf ("\n");
RTPrintf ("tstHeadless FINISHED.\n");
return rc;
}