tstDBGCParser.cpp revision f7f5cd7b1e530eb5636da51c974b48ae0c1775b3
/* $Id$ */
/** @file
* DBGC Testcase - Command Parser.
*/
/*
* Copyright (C) 2006-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 "../DBGCInternal.h"
/*******************************************************************************
* Internal Functions *
*******************************************************************************/
static DECLCALLBACK(int) tstDBGCBackRead(PDBGCBACK pBack, void *pvBuf, size_t cbBuf, size_t *pcbRead);
static DECLCALLBACK(int) tstDBGCBackWrite(PDBGCBACK pBack, const void *pvBuf, size_t cbBuf, size_t *pcbWritten);
/*******************************************************************************
* Global Variables *
*******************************************************************************/
/** The test handle. */
/** The DBGC backend structure for use in this testcase. */
{
};
/** For keeping track of output prefixing. */
static bool g_fPendingPrefix = true;
/** Pointer to the current input position. */
const char *g_pszInput = NULL;
/** The output of the last command. */
static char g_szOutput[1024];
/** The current offset into g_szOutput. */
static size_t g_offOutput = 0;
/**
* Checks if there is input.
*
* @returns true if there is input ready.
* @returns false if there not input ready.
* @param pBack Pointer to the backend structure supplied by
* the backend. The backend can use this to find
* it's instance data.
* @param cMillies Number of milliseconds to wait on input data.
*/
{
return g_pszInput != NULL
&& *g_pszInput != '\0';
}
/**
* Read input.
*
* @returns VBox status code.
* @param pBack Pointer to the backend structure supplied by
* the backend. The backend can use this to find
* it's instance data.
* @param pvBuf Where to put the bytes we read.
* @param cbBuf Maximum nymber of bytes to read.
* @param pcbRead Where to store the number of bytes actually read.
* If NULL the entire buffer must be filled for a
* successful return.
*/
static DECLCALLBACK(int) tstDBGCBackRead(PDBGCBACK pBack, void *pvBuf, size_t cbBuf, size_t *pcbRead)
{
if (g_pszInput && *g_pszInput)
{
g_pszInput += cb;
}
else
*pcbRead = 0;
return VINF_SUCCESS;
}
/**
* Write (output).
*
* @returns VBox status code.
* @param pBack Pointer to the backend structure supplied by
* the backend. The backend can use this to find
* it's instance data.
* @param pvBuf What to write.
* @param cbBuf Number of bytes to write.
* @param pcbWritten Where to store the number of bytes actually written.
* If NULL the entire buffer must be successfully written.
*/
static DECLCALLBACK(int) tstDBGCBackWrite(PDBGCBACK pBack, const void *pvBuf, size_t cbBuf, size_t *pcbWritten)
{
if (pcbWritten)
*pcbWritten = cbBuf;
while (cbBuf-- > 0)
{
if (g_fPendingPrefix)
{
g_fPendingPrefix = false;
}
if (*pch == '\n')
g_fPendingPrefix = true;
/* buffer output */
{
}
/* advance */
pch++;
}
return VINF_SUCCESS;
}
/**
* Ready / busy notification.
*
* @param pBack Pointer to the backend structure supplied by
* the backend. The backend can use this to find
* it's instance data.
* @param fReady Whether it's ready (true) or busy (false).
*/
{
}
/**
* Completes the output, making sure that we're in
* the 1 position of a new line.
*/
static void tstCompleteOutput(void)
{
if (!g_fPendingPrefix)
g_fPendingPrefix = true;
}
/**
* Tries one command string.
* @param pDbgc Pointer to the debugger instance.
* @param pszCmds The command to test.
* @param rcCmd The expected result.
* @param fNoExecute When set, the command is not executed.
* @param pszExpected Expected output. This does not need to include all
* of the output, just the start of it. Thus the
* prompt can be omitted.
*/
static void tstTryEx(PDBGC pDbgc, const char *pszCmds, int rcCmd, bool fNoExecute, const char *pszExpected)
{
g_offOutput = 0;
else
else if ( !fNoExecute
&& pszExpected
}
/**
* Tries one command string without executing it.
*
* @param pDbgc Pointer to the debugger instance.
* @param pszCmds The command to test.
* @param rcCmd The expected result.
*/
{
}
#ifdef SOME_UNUSED_FUNCTION
/**
* Tries to execute one command string.
* @param pDbgc Pointer to the debugger instance.
* @param pszCmds The command to test.
* @param rcCmd The expected result.
* @param pszExpected Expected output. This does not need to include all
* of the output, just the start of it. Thus the
* prompt can be omitted.
*/
{
}
#endif
/**
* Test an operator on an expression resulting a plain number.
*
* @param pDbgc Pointer to the debugger instance.
* @param pszExpr The express to test.
* @param u64Expect The expected result.
*/
{
char szCmd[80];
char szExpected[80];
}
int main()
{
/*
* Init.
*/
if (rc)
return rc;
/*
* Create a DBGC instance.
*/
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
{
if (RTTestErrorCount(g_hTest) == 0)
{
}
if (RTTestErrorCount(g_hTest) == 0)
{
}
}
}
/*
* Summary
*/
return RTTestSummaryAndDestroy(g_hTest);
}