tstGuestControlSvc.cpp revision f8ca8c787b4309ccbcfd9f1e584ca80c8e06680f
/* $Id$ */
/** @file
*
* Testcase for the guest control service.
*/
/*
* Copyright (C) 2011 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.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <iprt/initterm.h>
#include "../gctrl.h"
/*******************************************************************************
* Global Variables *
*******************************************************************************/
using namespace guestControl;
/** Simple call handle structure for the guest call completion callback */
struct VBOXHGCMCALLHANDLE_TYPEDEF
{
/** Where to store the result code. */
};
/** Call completion callback for guest calls. */
{
}
/**
* Initialise the HGCM service table as much as we need to start the
* service.
*
* @return IPRT status.
* @param pTable the table to initialise
*/
{
return VINF_SUCCESS;
}
typedef struct CMDHOST
{
/** The HGCM command to execute. */
int cmd;
/** Number of parameters. */
int num_parms;
/** The actual parameters. */
const PVBOXHGCMSVCPARM parms;
/** Flag indicating whether we need a connected client for this command. */
bool fNeedsClient;
/** The desired return value from the host. */
int rc;
typedef struct CMDCLIENT
{
/** The client's ID. */
int client_id;
/** The HGCM command to execute. */
int cmd;
/** Number of parameters. */
int num_parms;
/** The actual parameters. */
const PVBOXHGCMSVCPARM parms;
/** The desired return value from the host. */
int rc;
} CMDCLIENT, *PCMDCLIENT;
/**
* Tests the HOST_EXEC_CMD function.
* @returns iprt status value to indicate whether the test went as expected.
* @note prints its own diagnostic information to stdout.
*/
{
int rc = VINF_SUCCESS;
{
}
if (RT_SUCCESS(rc))
{
{
if (pCmd[i].fNeedsClient)
{
if (RT_FAILURE(client_rc))
}
if (RT_SUCCESS(rc))
{
{
RTTestPrintf(g_hTest, RTTESTLVL_FAILURE, "Host call test #%u returned with rc=%Rrc instead of rc=%Rrc\n",
if (RT_SUCCESS(rc))
}
if (pCmd[i].fNeedsClient)
{
int client_rc = pTable->pfnDisconnect(pTable->pvService, 1000 /* Client ID */, NULL /* pvClient */);
if (RT_SUCCESS(rc))
}
}
}
}
return rc;
}
{
static CMDHOST s_aCmdHostAll[] =
{
/** No client connected, invalid command. */
/** No client connected, valid command. */
{ HOST_CANCEL_PENDING_WAITS, 0, 0, false, VERR_NOT_FOUND },
/** Client connected. */
/** Client connected, valid parameters given. */
{ HOST_CANCEL_PENDING_WAITS, 0, 0, true, VINF_SUCCESS },
/** Client connected, invalid parameters given. */
/** Client connected, parameters given. */
};
return rc;
}
{
if (RT_SUCCESS(rc))
{
/* No commands from host yet. */
/* Host: Add a dummy command. */
/* Client: Get host command with a invalid parameter count specified. */
/* Client: Get host command with a too small HGCM array. */
GUEST_GET_HOST_MSG, 0, &s_aParmsGuest[0]);
/* Client: Get host command without an allocated buffer. */
/* Client: Get host command, this time with a valid buffer. */
char szBuf[16];
/* Client: Now make sure there's no host message left anymore. */
/* Client: Disconnect again. */
if (RT_SUCCESS(rc))
}
return rc;
}
/*
* Set environment variable "IPRT_TEST_MAX_LEVEL=all" to get more debug output!
*/
{
if (rcExit != RTEXITCODE_SUCCESS)
return rcExit;
/* Some host info. */
/* Do the tests. */
do
{
} while (0);
return RTTestSummaryAndDestroy(g_hTest);
}