VirtualBox

Ignore:
Timestamp:
Nov 11, 2007 12:22:14 PM (17 years ago)
Author:
vboxsync
Message:

Got the DBGC parser testcase framework going. enough fun for now.

File:
1 edited

Legend:

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

    r5685 r5686  
    5050/** For keeping track of output prefixing. */
    5151static bool g_fPendingPrefix = true;
    52 
     52/** Pointer to the the current input position. */
     53const char *g_pszInput = NULL;
    5354
    5455/**
     
    6465static DECLCALLBACK(bool) tstDBGCBackInput(PDBGCBACK pBack, uint32_t cMillies)
    6566{
    66     RTPrintf("tstDBGCParser: tstDBGCBackInput was called!\n");
    67     g_cErrors++;
    68     return false;
     67    return g_pszInput != NULL
     68       && *g_pszInput != '\0';
    6969}
    7070
     
    8585static DECLCALLBACK(int) tstDBGCBackRead(PDBGCBACK pBack, void *pvBuf, size_t cbBuf, size_t *pcbRead)
    8686{
    87     RTPrintf("tstDBGCParser: tstDBGCBackRead was called!\n");
    88     g_cErrors++;
    89     return VERR_INTERNAL_ERROR;
     87    if (g_pszInput && *g_pszInput)
     88    {
     89        size_t cb = strlen(g_pszInput);
     90        if (cb > cbBuf)
     91            cb = cbBuf;
     92        *pcbRead = cb;
     93        memcpy(pvBuf, g_pszInput, cb);
     94        g_pszInput += cb;
     95    }
     96    else
     97        *pcbRead = 0;
     98    return VINF_SUCCESS;
    9099}
    91100
     
    106115{
    107116    const char *pch = (const char *)pvBuf;
    108     *pcbWritten = cbBuf;
     117    if (pcbWritten)
     118        *pcbWritten = cbBuf;
    109119    while (cbBuf-- > 0)
    110120    {
    111121        if (g_fPendingPrefix)
    112122        {
    113             RTPrintf("tstDBGCParser: OUTPUT: ");
     123            RTPrintf("tstDBGCParser:  OUTPUT: ");
    114124            g_fPendingPrefix = false;
    115125        }
     
    135145
    136146
     147/**
     148 * Tries one command string.
     149 * @param   pDbgc           Pointer to the debugger instance.
     150 * @param   pszCmds         The command to test.
     151 * @param   rcCmd           The expected result.
     152 */
     153static void tstTry(PDBGC pDbgc, const char *pszCmds, int rcCmd)
     154{
     155    g_pszInput = pszCmds;
     156    if (strchr(pszCmds, '\0')[-1] == '\n')
     157        RTPrintf("tstDBGCParser: RUNNING: %s", pszCmds);
     158    else
     159        RTPrintf("tstDBGCParser: RUNNING: %s\n", pszCmds);
     160
     161    pDbgc->rcCmd = VERR_INTERNAL_ERROR;
     162    dbgcProcessInput(pDbgc, true /* fNoExecute */);
     163    tstCompleteOutput();
     164
     165    if (pDbgc->rcCmd != rcCmd)
     166    {
     167        RTPrintf("tstDBGCParser: rcCmd=%Rrc expected =%Rrc\n", pDbgc->rcCmd, rcCmd);
     168        g_cErrors++;
     169    }
     170}
    137171
    138172
     
    152186    if (RT_SUCCESS(rc))
    153187    {
     188        rc = dbgcProcessInput(pDbgc, true /* fNoExecute */);
     189        tstCompleteOutput();
     190        if (RT_SUCCESS(rc))
     191        {
     192            tstTry(pDbgc, "stop\n", VINF_SUCCESS);
     193            tstTry(pDbgc, "format \n", VERR_PARSE_TOO_FEW_ARGUMENTS);
     194            tstTry(pDbgc, "format 0 1 23 4\n", VERR_PARSE_TOO_MANY_ARGUMENTS);
     195            tstTry(pDbgc, "sa 3 23 4 'q' \"21123123\" 'b' \n", VINF_SUCCESS);
     196        }
    154197
    155198        dbgcDestroy(pDbgc);
    156199    }
    157 
    158200
    159201    /*
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