VirtualBox

Ignore:
Timestamp:
Nov 11, 2007 11:11:40 AM (17 years ago)
Author:
vboxsync
Message:

testcase framework.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Debugger/testcase/tstDBGCParser.cpp

    r5681 r5685  
    2929
    3030/*******************************************************************************
     31*   Internal Functions                                                         *
     32*******************************************************************************/
     33static DECLCALLBACK(bool) tstDBGCBackInput(PDBGCBACK pBack, uint32_t cMillies);
     34static DECLCALLBACK(int) tstDBGCBackRead(PDBGCBACK pBack, void *pvBuf, size_t cbBuf, size_t *pcbRead);
     35static DECLCALLBACK(int) tstDBGCBackWrite(PDBGCBACK pBack, const void *pvBuf, size_t cbBuf, size_t *pcbWritten);
     36
     37
     38/*******************************************************************************
    3139*   Global Variables                                                           *
    3240*******************************************************************************/
    3341/** Global error counter. */
    3442static unsigned g_cErrors = 0;
     43/** The DBGC backend structure for use in this testcase. */
     44static DBGCBACK g_tstBack =
     45{
     46    tstDBGCBackInput,
     47    tstDBGCBackRead,
     48    tstDBGCBackWrite
     49};
     50/** For keeping track of output prefixing. */
     51static bool g_fPendingPrefix = true;
     52
     53
     54/**
     55 * Checks if there is input.
     56 *
     57 * @returns true if there is input ready.
     58 * @returns false if there not input ready.
     59 * @param   pBack       Pointer to the backend structure supplied by
     60 *                      the backend. The backend can use this to find
     61 *                      it's instance data.
     62 * @param   cMillies    Number of milliseconds to wait on input data.
     63 */
     64static DECLCALLBACK(bool) tstDBGCBackInput(PDBGCBACK pBack, uint32_t cMillies)
     65{
     66    RTPrintf("tstDBGCParser: tstDBGCBackInput was called!\n");
     67    g_cErrors++;
     68    return false;
     69}
     70
     71
     72/**
     73 * Read input.
     74 *
     75 * @returns VBox status code.
     76 * @param   pBack       Pointer to the backend structure supplied by
     77 *                      the backend. The backend can use this to find
     78 *                      it's instance data.
     79 * @param   pvBuf       Where to put the bytes we read.
     80 * @param   cbBuf       Maximum nymber of bytes to read.
     81 * @param   pcbRead     Where to store the number of bytes actually read.
     82 *                      If NULL the entire buffer must be filled for a
     83 *                      successful return.
     84 */
     85static DECLCALLBACK(int) tstDBGCBackRead(PDBGCBACK pBack, void *pvBuf, size_t cbBuf, size_t *pcbRead)
     86{
     87    RTPrintf("tstDBGCParser: tstDBGCBackRead was called!\n");
     88    g_cErrors++;
     89    return VERR_INTERNAL_ERROR;
     90}
     91
     92
     93/**
     94 * Write (output).
     95 *
     96 * @returns VBox status code.
     97 * @param   pBack       Pointer to the backend structure supplied by
     98 *                      the backend. The backend can use this to find
     99 *                      it's instance data.
     100 * @param   pvBuf       What to write.
     101 * @param   cbBuf       Number of bytes to write.
     102 * @param   pcbWritten  Where to store the number of bytes actually written.
     103 *                      If NULL the entire buffer must be successfully written.
     104 */
     105static DECLCALLBACK(int) tstDBGCBackWrite(PDBGCBACK pBack, const void *pvBuf, size_t cbBuf, size_t *pcbWritten)
     106{
     107    const char *pch = (const char *)pvBuf;
     108    *pcbWritten = cbBuf;
     109    while (cbBuf-- > 0)
     110    {
     111        if (g_fPendingPrefix)
     112        {
     113            RTPrintf("tstDBGCParser: OUTPUT: ");
     114            g_fPendingPrefix = false;
     115        }
     116        if (*pch == '\n')
     117            g_fPendingPrefix = true;
     118        RTPrintf("%c", *pch);
     119        pch++;
     120    }
     121    return VINF_SUCCESS;
     122}
     123
     124
     125/**
     126 * Completes the output, making sure that we're in
     127 * the 1 position of a new line.
     128 */
     129static void tstCompleteOutput(void)
     130{
     131    if (!g_fPendingPrefix)
     132        RTPrintf("\n");
     133    g_fPendingPrefix = true;
     134}
     135
    35136
    36137
     
    45146
    46147    /*
    47      *
     148     * Create a DBGC instance.
    48149     */
     150    PDBGC pDbgc;
     151    int rc = dbgcCreate(&pDbgc, &g_tstBack, 0);
     152    if (RT_SUCCESS(rc))
     153    {
     154
     155        dbgcDestroy(pDbgc);
     156    }
    49157
    50158
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette