- Timestamp:
- Sep 5, 2007 7:17:14 AM (17 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/VMAll.cpp
r4071 r4520 250 250 * Switch to EMT. 251 251 */ 252 va_list WorkaroundVA; 253 va_copy(WorkaroundVA, args); /* Have to make a copy here or GCC will break. */ 252 254 PVMREQ pReq; 253 255 VMR3ReqCall(pVM, &pReq, RT_INDEFINITE_WAIT, (PFNRT)vmR3SetRuntimeErrorV, 5, 254 pVM, fFatal, pszErrorID, pszFormat, & args);256 pVM, fFatal, pszErrorID, pszFormat, &WorkaroundVA); 255 257 VMR3ReqFree(pReq); 258 va_end(WorkaroundVA); 256 259 257 260 #else -
trunk/src/VBox/VMM/testcase/tstVMREQ.cpp
r4071 r4520 33 33 34 34 35 36 37 35 /******************************************************************************* 38 36 * Defined Constants And Macros * … … 40 38 #define TESTCASE "tstVMREQ" 41 39 40 /******************************************************************************* 41 * Global Variables * 42 *******************************************************************************/ 43 /** the error count. */ 44 static int g_cErrors = 0; 45 46 47 /** 48 * Testings va_list passing in VMSetRuntimeError. 49 */ 50 static DECLCALLBACK(void) MyAtRuntimeError(PVM pVM, void *pvUser, bool fFatal, const char *pszErrorId, const char *pszFormat, va_list va) 51 { 52 if (strcmp((const char *)pvUser, "user argument")) 53 { 54 RTPrintf(TESTCASE ": pvUser=%p:{%s}!\n", pvUser, (const char *)pvUser); 55 g_cErrors++; 56 } 57 if (fFatal) 58 { 59 RTPrintf(TESTCASE ": fFatal=%d!\n", fFatal); 60 g_cErrors++; 61 } 62 if (strcmp(pszErrorId, "enum")) 63 { 64 RTPrintf(TESTCASE ": pszErrorId=%p:{%s}!\n", pszErrorId, pszErrorId); 65 g_cErrors++; 66 } 67 if (strcmp(pszFormat, "some %s string")) 68 { 69 RTPrintf(TESTCASE ": pszFormat=%p:{%s}!\n", pszFormat, pszFormat); 70 g_cErrors++; 71 } 72 73 char szBuf[1024]; 74 RTStrPrintfV(szBuf, sizeof(szBuf), pszFormat, va); 75 if (strcmp(szBuf, "some error string")) 76 { 77 RTPrintf(TESTCASE ": RTStrPrintfV -> '%s'!\n", szBuf); 78 g_cErrors++; 79 } 80 } 81 82 83 /** 84 * The function PassVA and PassVA2 calls. 85 */ 86 static DECLCALLBACK(int) PassVACallback(PVM pVM, unsigned u4K, unsigned u1G, const char *pszFormat, va_list *pva) 87 { 88 if (u4K != _4K) 89 { 90 RTPrintf(TESTCASE ": u4K=%#x!\n", u4K); 91 g_cErrors++; 92 } 93 if (u1G != _1G) 94 { 95 RTPrintf(TESTCASE ": u1G=%#x!\n", u1G); 96 g_cErrors++; 97 } 98 99 if (strcmp(pszFormat, "hello %s")) 100 { 101 RTPrintf(TESTCASE ": pszFormat=%p:{%s}!\n", pszFormat, pszFormat); 102 g_cErrors++; 103 } 104 105 char szBuf[1024]; 106 RTStrPrintfV(szBuf, sizeof(szBuf), pszFormat, *pva); 107 if (strcmp(szBuf, "hello world")) 108 { 109 RTPrintf(TESTCASE ": RTStrPrintfV -> '%s'!\n", szBuf); 110 g_cErrors++; 111 } 112 113 return VINF_SUCCESS; 114 } 115 116 117 /** 118 * Functions that tests passing a va_list * argument in a request, 119 * similar to VMSetRuntimeError. 120 */ 121 static void PassVA2(PVM pVM, const char *pszFormat, va_list va) 122 { 123 #if 0 /** @todo test if this is a GCC problem only or also happens with AMD64+VCC80... */ 124 void *pvVA = &va; 125 #else 126 va_list va2; 127 va_copy(va2, va); 128 void *pvVA = va2; 129 #endif 130 131 PVMREQ pReq; 132 int rc = VMR3ReqCall(pVM, &pReq, RT_INDEFINITE_WAIT, (PFNRT)PassVACallback, 5, 133 pVM, _4K, _1G, pszFormat, pvVA); 134 if (VBOX_SUCCESS(rc)) 135 rc = pReq->iStatus; 136 VMR3ReqFree(pReq); 137 138 #if 1 139 va_end(va2); 140 #endif 141 } 142 143 144 /** 145 * Functions that tests passing a va_list * argument in a request, 146 * similar to VMSetRuntimeError. 147 */ 148 static void PassVA(PVM pVM, const char *pszFormat, ...) 149 { 150 /* 1st test */ 151 va_list va1; 152 va_start(va1, pszFormat); 153 PVMREQ pReq; 154 int rc = VMR3ReqCall(pVM, &pReq, RT_INDEFINITE_WAIT, (PFNRT)PassVACallback, 5, 155 pVM, _4K, _1G, pszFormat, &va1); 156 if (VBOX_SUCCESS(rc)) 157 rc = pReq->iStatus; 158 VMR3ReqFree(pReq); 159 va_end(va1); 160 161 /* 2nd test */ 162 va_list va2; 163 va_start(va2, pszFormat); 164 PassVA2(pVM, pszFormat, va2); 165 va_end(va2); 166 } 167 168 42 169 /** 43 170 * Thread function which allocates and frees requests like wildfire. 44 171 */ 45 DECLCALLBACK(int) Thread(RTTHREAD Thread, void *pvUser)172 static DECLCALLBACK(int) Thread(RTTHREAD Thread, void *pvUser) 46 173 { 47 174 int rc = VINF_SUCCESS; … … 88 215 int main(int argc, char **argv) 89 216 { 90 int cErrors = 0;91 92 217 RTR3Init(); 93 218 RTPrintf(TESTCASE ": TESTING...\n"); … … 117 242 { 118 243 RTPrintf(TESTCASE ": RTThreadWait(Thread1,,) failed, rc=%Vrc\n", rc); 119 cErrors++;244 g_cErrors++; 120 245 } 121 246 if (VBOX_FAILURE(rcThread1)) 122 cErrors++;247 g_cErrors++; 123 248 } 124 249 else 125 250 { 126 251 RTPrintf(TESTCASE ": RTThreadCreate(&Thread1,,,,) failed, rc=%Vrc\n", rc); 127 cErrors++;252 g_cErrors++; 128 253 } 129 254 … … 133 258 { 134 259 RTPrintf(TESTCASE ": RTThreadWait(Thread1,,) failed, rc=%Vrc\n", rc); 135 cErrors++;260 g_cErrors++; 136 261 } 137 262 if (VBOX_FAILURE(rcThread0)) 138 cErrors++;263 g_cErrors++; 139 264 } 140 265 else 141 266 { 142 267 RTPrintf(TESTCASE ": RTThreadCreate(&Thread0,,,,) failed, rc=%Vrc\n", rc); 143 cErrors++;268 g_cErrors++; 144 269 } 145 270 uint64_t u64ElapsedTS = RTTimeNanoTS() - u64StartTS; … … 150 275 */ 151 276 STAMR3Print(pVM, "/VM/Req/*"); 277 278 /* 279 * Testing va_list fun. 280 */ 281 RTPrintf(TESTCASE ": va_list argument test...\n"); 282 PassVA(pVM, "hello %s", "world"); 283 VMR3AtRuntimeErrorRegister(pVM, MyAtRuntimeError, (void *)"user argument"); 284 VMSetRuntimeError(pVM, false, "enum", "some %s string", "error"); 152 285 153 286 /* … … 158 291 { 159 292 RTPrintf(TESTCASE ": error: failed to destroy vm! rc=%Vrc\n", rc); 160 cErrors++;293 g_cErrors++; 161 294 } 162 295 } … … 164 297 { 165 298 RTPrintf(TESTCASE ": fatal error: failed to create vm! rc=%Vrc\n", rc); 166 cErrors++;299 g_cErrors++; 167 300 } 168 301 … … 170 303 * Summary and return. 171 304 */ 172 if (! cErrors)305 if (!g_cErrors) 173 306 RTPrintf(TESTCASE ": SUCCESS\n"); 174 307 else 175 RTPrintf(TESTCASE ": FAILURE - %d errors\n", cErrors);176 177 return !! cErrors;178 } 308 RTPrintf(TESTCASE ": FAILURE - %d errors\n", g_cErrors); 309 310 return !!g_cErrors; 311 }
Note:
See TracChangeset
for help on using the changeset viewer.