diff options
| author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2014-03-26 19:21:20 +0000 |
|---|---|---|
| committer | <> | 2014-05-08 15:03:54 +0000 |
| commit | fb123f93f9f5ce42c8e5785d2f8e0edaf951740e (patch) | |
| tree | c2103d76aec5f1f10892cd1d3a38e24f665ae5db /src/VBox/Frontends/VBoxHeadless/testcase | |
| parent | 58ed4748338f9466599adfc8a9171280ed99e23f (diff) | |
| download | VirtualBox-master.tar.gz | |
Imported from /home/lorry/working-area/delta_VirtualBox/VirtualBox-4.3.10.tar.bz2.HEADVirtualBox-4.3.10master
Diffstat (limited to 'src/VBox/Frontends/VBoxHeadless/testcase')
| -rw-r--r-- | src/VBox/Frontends/VBoxHeadless/testcase/Makefile.kmk | 2 | ||||
| -rw-r--r-- | src/VBox/Frontends/VBoxHeadless/testcase/tstHeadless.cpp | 96 |
2 files changed, 46 insertions, 52 deletions
diff --git a/src/VBox/Frontends/VBoxHeadless/testcase/Makefile.kmk b/src/VBox/Frontends/VBoxHeadless/testcase/Makefile.kmk index c14eb4ae..02e7d092 100644 --- a/src/VBox/Frontends/VBoxHeadless/testcase/Makefile.kmk +++ b/src/VBox/Frontends/VBoxHeadless/testcase/Makefile.kmk @@ -20,7 +20,7 @@ include $(KBUILD_PATH)/subheader.kmk ifdef VBOX_WITH_TESTCASES PROGRAMS += tstHeadless - tstHeadless_TEMPLATE = VBOXMAINCLIENTEXE + tstHeadless_TEMPLATE = VBOXMAINCLIENTTSTEXE tstHeadless_SOURCES = tstHeadless.cpp endif diff --git a/src/VBox/Frontends/VBoxHeadless/testcase/tstHeadless.cpp b/src/VBox/Frontends/VBoxHeadless/testcase/tstHeadless.cpp index 4d94438a..3e40a75b 100644 --- a/src/VBox/Frontends/VBoxHeadless/testcase/tstHeadless.cpp +++ b/src/VBox/Frontends/VBoxHeadless/testcase/tstHeadless.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (C) 2006-2009 Oracle Corporation + * Copyright (C) 2006-2014 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -21,7 +21,6 @@ #include <VBox/com/Guid.h> #include <VBox/com/ErrorInfo.h> #include <VBox/com/errorprint.h> -#include <VBox/com/EventQueue.h> #include <VBox/com/VirtualBox.h> @@ -37,7 +36,7 @@ using namespace com; /** * Entry point. */ -int main (int argc, char **argv) +int main(int argc, char **argv) { // initialize VBox Runtime RTR3InitExe(argc, &argv, 0); @@ -55,18 +54,18 @@ int main (int argc, char **argv) if (!name || !operation) { - RTPrintf ("\nUsage:\n\n" - "%s <machine_name> [on|off|pause|resume]\n\n", - argv [0]); - return -1; + RTPrintf("\nUsage:\n\n" + "%s <machine_name> [on|off|pause|resume]\n\n", + argv [0]); + return 0; } - RTPrintf ("\n"); - RTPrintf ("tstHeadless STARTED.\n"); + RTPrintf("\n"); + RTPrintf("tstHeadless STARTED.\n"); - RTPrintf ("VM name : {%s}\n" - "Operation : %s\n\n", - name, operation); + RTPrintf("VM name : {%s}\n" + "Operation : %s\n\n", + name, operation); HRESULT rc; @@ -82,8 +81,8 @@ int main (int argc, char **argv) ComPtr <IVirtualBox> virtualBox; ComPtr <ISession> session; - RTPrintf ("Creating VirtualBox object...\n"); - rc = virtualBox.createLocalObject (CLSID_VirtualBox); + RTPrintf("Creating VirtualBox object...\n"); + rc = virtualBox.createLocalObject(CLSID_VirtualBox); if (FAILED(rc)) RTPrintf("ERROR: failed to create the VirtualBox object!\n"); else @@ -93,7 +92,7 @@ int main (int argc, char **argv) RTPrintf("ERROR: failed to create a session object!\n"); } - if (FAILED (rc)) + if (FAILED(rc)) { com::ErrorInfo info; if (!info.isFullAvailable() && !info.isBasicAvailable()) @@ -106,11 +105,6 @@ int main (int argc, char **argv) break; } - // create the event queue - // (here it is necessary only to process remaining XPCOM/IPC events - // after the session is closed) - EventQueue eventQ; - ComPtr <IMachine> m; // find ID by name @@ -120,78 +114,78 @@ int main (int argc, char **argv) if (!strcmp(operation, "on")) { ComPtr <IProgress> progress; - RTPrintf ("Opening a new (remote) session...\n"); - CHECK_ERROR_BREAK (m, - LaunchVMProcess(session, Bstr("vrdp").raw(), - NULL, progress.asOutParam())); + RTPrintf("Opening a new (remote) session...\n"); + CHECK_ERROR_BREAK(m, + LaunchVMProcess(session, Bstr("vrdp").raw(), + NULL, progress.asOutParam())); - RTPrintf ("Waiting for the remote session to open...\n"); - CHECK_ERROR_BREAK (progress, WaitForCompletion (-1)); + RTPrintf("Waiting for the remote session to open...\n"); + CHECK_ERROR_BREAK(progress, WaitForCompletion(-1)); BOOL completed; - CHECK_ERROR_BREAK (progress, COMGETTER(Completed) (&completed)); - ASSERT (completed); + CHECK_ERROR_BREAK(progress, COMGETTER(Completed)(&completed)); + ASSERT(completed); LONG resultCode; - CHECK_ERROR_BREAK (progress, COMGETTER(ResultCode) (&resultCode)); - if (FAILED (resultCode)) + CHECK_ERROR_BREAK(progress, COMGETTER(ResultCode)(&resultCode)); + if (FAILED(resultCode)) { ProgressErrorInfo info(progress); com::GluePrintErrorInfo(info); } else { - RTPrintf ("Remote session has been successfully opened.\n"); + RTPrintf("Remote session has been successfully opened.\n"); } } else { - RTPrintf ("Opening an existing session...\n"); + RTPrintf("Opening an existing session...\n"); CHECK_ERROR_BREAK(m, LockMachine(session, LockType_Shared)); ComPtr <IConsole> console; CHECK_ERROR_BREAK(session, COMGETTER(Console)(console.asOutParam())); - if (!strcmp (operation, "off")) + if (!strcmp(operation, "off")) { ComPtr <IProgress> progress; - RTPrintf ("Powering the VM off...\n"); - CHECK_ERROR_BREAK (console, PowerDown(progress.asOutParam())); + RTPrintf("Powering the VM off...\n"); + CHECK_ERROR_BREAK(console, PowerDown(progress.asOutParam())); - RTPrintf ("Waiting for the VM to power down...\n"); - CHECK_ERROR_BREAK (progress, WaitForCompletion (-1)); + RTPrintf("Waiting for the VM to power down...\n"); + CHECK_ERROR_BREAK(progress, WaitForCompletion(-1)); BOOL completed; - CHECK_ERROR_BREAK (progress, COMGETTER(Completed) (&completed)); - ASSERT (completed); + CHECK_ERROR_BREAK(progress, COMGETTER(Completed)(&completed)); + ASSERT(completed); LONG resultCode; - CHECK_ERROR_BREAK (progress, COMGETTER(ResultCode) (&resultCode)); - if (FAILED (resultCode)) + CHECK_ERROR_BREAK(progress, COMGETTER(ResultCode)(&resultCode)); + if (FAILED(resultCode)) { ProgressErrorInfo info(progress); com::GluePrintErrorInfo(info); } else { - RTPrintf ("VM is powered down.\n"); + RTPrintf("VM is powered down.\n"); } } else - if (!strcmp (operation, "pause")) + if (!strcmp(operation, "pause")) { - RTPrintf ("Pausing the VM...\n"); - CHECK_ERROR_BREAK (console, Pause()); + RTPrintf("Pausing the VM...\n"); + CHECK_ERROR_BREAK(console, Pause()); } else - if (!strcmp (operation, "resume")) + if (!strcmp(operation, "resume")) { - RTPrintf ("Resuming the VM...\n"); - CHECK_ERROR_BREAK (console, Resume()); + RTPrintf("Resuming the VM...\n"); + CHECK_ERROR_BREAK(console, Resume()); } else { - RTPrintf ("Invalid operation!\n"); + RTPrintf("Invalid operation!\n"); } } @@ -199,11 +193,11 @@ int main (int argc, char **argv) CHECK_ERROR(session, UnlockMachine()); } while (0); - RTPrintf ("\n"); + RTPrintf("\n"); com::Shutdown(); - RTPrintf ("tstHeadless FINISHED.\n"); + RTPrintf("tstHeadless FINISHED.\n"); return rc; } |
