Changeset 5686 in vbox for trunk/src/VBox/Debugger/testcase/tstDBGCParser.cpp
- Timestamp:
- Nov 11, 2007 12:22:14 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Debugger/testcase/tstDBGCParser.cpp
r5685 r5686 50 50 /** For keeping track of output prefixing. */ 51 51 static bool g_fPendingPrefix = true; 52 52 /** Pointer to the the current input position. */ 53 const char *g_pszInput = NULL; 53 54 54 55 /** … … 64 65 static DECLCALLBACK(bool) tstDBGCBackInput(PDBGCBACK pBack, uint32_t cMillies) 65 66 { 66 RTPrintf("tstDBGCParser: tstDBGCBackInput was called!\n"); 67 g_cErrors++; 68 return false; 67 return g_pszInput != NULL 68 && *g_pszInput != '\0'; 69 69 } 70 70 … … 85 85 static DECLCALLBACK(int) tstDBGCBackRead(PDBGCBACK pBack, void *pvBuf, size_t cbBuf, size_t *pcbRead) 86 86 { 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; 90 99 } 91 100 … … 106 115 { 107 116 const char *pch = (const char *)pvBuf; 108 *pcbWritten = cbBuf; 117 if (pcbWritten) 118 *pcbWritten = cbBuf; 109 119 while (cbBuf-- > 0) 110 120 { 111 121 if (g_fPendingPrefix) 112 122 { 113 RTPrintf("tstDBGCParser: OUTPUT: ");123 RTPrintf("tstDBGCParser: OUTPUT: "); 114 124 g_fPendingPrefix = false; 115 125 } … … 135 145 136 146 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 */ 153 static 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 } 137 171 138 172 … … 152 186 if (RT_SUCCESS(rc)) 153 187 { 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 } 154 197 155 198 dbgcDestroy(pDbgc); 156 199 } 157 158 200 159 201 /*
Note:
See TracChangeset
for help on using the changeset viewer.