tstVBoxDbg.cpp revision e02f72448d6a142ef9943dddd9cd5a4efccfb1ed
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/** @file
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * VBox Debugger GUI, dummy testcase.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * available from http://www.virtualbox.org. This file is free software;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * you can redistribute it and/or modify it under the terms of the GNU
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * General Public License (GPL) as published by the Free Software
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * additional information or have any questions.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*******************************************************************************
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync* Header Files *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync*******************************************************************************/
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <qapplication.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <VBox/dbggui.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <VBox/vm.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <VBox/err.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <iprt/runtime.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <VBox/log.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <iprt/assert.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <iprt/runtime.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <iprt/semaphore.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <iprt/stream.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#define TESTCASE "tstVBoxDbg"
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncint main(int argc, char **argv)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int cErrors = 0; /* error count. */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync RTR3InitAndSUPLib();
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync RTPrintf(TESTCASE ": TESTING...\n");
/*
* Create empty VM.
*/
PVM pVM;
int rc = VMR3Create(NULL, NULL, NULL, NULL, &pVM);
if (VBOX_SUCCESS(rc))
{
/*
* Instantiate the debugger GUI bits and run them.
*/
QApplication App(argc, argv);
PDBGGUI pGui;
PCDBGGUIVT pGuiVT;
rc = DBGGuiCreateForVM(pVM, &pGui, &pGuiVT);
if (RT_SUCCESS(rc))
{
if (argc <= 1 || argc == 2)
{
RTPrintf(TESTCASE ": calling pfnShowCommandLine...\n");
rc = pGuiVT->pfnShowCommandLine(pGui);
if (RT_FAILURE(rc))
{
RTPrintf(TESTCASE ": error: pfnShowCommandLine failed! rc=%Rrc\n", rc);
cErrors++;
}
}
if (argc <= 1 || argc == 3)
{
RTPrintf(TESTCASE ": calling pfnShowStatistics...\n");
pGuiVT->pfnShowStatistics(pGui);
if (RT_FAILURE(rc))
{
RTPrintf(TESTCASE ": error: pfnShowStatistics failed! rc=%Rrc\n", rc);
cErrors++;
}
}
pGuiVT->pfnAdjustRelativePos(pGui, 0, 0, 640, 480);
RTPrintf(TESTCASE ": calling App.exec()...\n");
App.exec();
}
else
{
RTPrintf(TESTCASE ": error: DBGGuiCreateForVM failed! rc=%Rrc\n", rc);
cErrors++;
}
/*
* Cleanup.
*/
rc = VMR3Destroy(pVM);
if (!VBOX_SUCCESS(rc))
{
RTPrintf(TESTCASE ": error: failed to destroy vm! rc=%Rrc\n", rc);
cErrors++;
}
}
else
{
RTPrintf(TESTCASE ": fatal error: failed to create vm! rc=%Rrc\n", rc);
cErrors++;
}
/*
* Summay and exit.
*/
if (!cErrors)
RTPrintf(TESTCASE ": SUCCESS\n");
else
RTPrintf(TESTCASE ": FAILURE - %d errors\n", cErrors);
return !!cErrors;
}