Changeset 98574 in vbox
- Timestamp:
- Feb 15, 2023 12:24:25 AM (2 years ago)
- svn:sync-xref-src-repo-rev:
- 155860
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/GuestHost/HGCMMock.h
r98531 r98574 171 171 * 0 is considered as being invalid. */ 172 172 HGCMCLIENTID uNextClientId; 173 /** Size (in bytes) of opaque pvClient area to reserve174 * for a connected client. */175 size_t cbClient;176 173 /** Array of connected HGCM mock clients. 177 174 * Currently limited to 4 clients maximum. */ … … 198 195 199 196 /** Static HGCM service to mock. */ 200 static TSTHGCMMOCKSVC s_tstHgcmSvc; 197 static TSTHGCMMOCKSVC g_tstHgcmSvc; 198 201 199 202 200 /********************************************************************************************************************************* … … 206 204 PTSTHGCMMOCKCLIENT TstHgcmMockSvcWaitForConnectEx(PTSTHGCMMOCKSVC pSvc, RTMSINTERVAL msTimeout); 207 205 PTSTHGCMMOCKCLIENT TstHgcmMockSvcWaitForConnect(PTSTHGCMMOCKSVC pSvc); 208 int TstHgcmMockSvcCreate(PTSTHGCMMOCKSVC pSvc , size_t cbClient);206 int TstHgcmMockSvcCreate(PTSTHGCMMOCKSVC pSvc); 209 207 int TstHgcmMockSvcDestroy(PTSTHGCMMOCKSVC pSvc); 210 208 int TstHgcmMockSvcStart(PTSTHGCMMOCKSVC pSvc); … … 281 279 PTSTHGCMMOCKCLIENT pClient = &pSvc->aHgcmClient[pSvc->uNextClientId]; 282 280 283 int rc = tstHgcmMockClientInit(pClient, pSvc->uNextClientId, pSvc-> cbClient);281 int rc = tstHgcmMockClientInit(pClient, pSvc->uNextClientId, pSvc->fnTable.cbClient); 284 282 if (RT_FAILURE(rc)) 285 283 return rc; … … 349 347 pFn->u.Call.hCall = callHandle; 350 348 pFn->u.Call.iFunc = function; 351 pFn->u.Call.pParms = (PVBOXHGCMSVCPARM)RTMemDup(paParms, cbParms); 349 PVBOXHGCMSVCPARM const paParmsCopy = (PVBOXHGCMSVCPARM)RTMemDup(paParms, cbParms); 350 pFn->u.Call.pParms = paParmsCopy; 352 351 AssertPtrReturn(pFn->u.Call.pParms, VERR_NO_MEMORY); 353 352 pFn->u.Call.cParms = cParms; … … 361 360 AssertRCReturn(rc2, rc2); 362 361 363 memcpy(paParms, pFn->u.Call.pParms, cbParms); 362 memcpy(paParms, paParmsCopy, cbParms); 363 /** @todo paParmsCopy is leaked, right? Doesn't appear to be a 364 * use-after-free here. (pFn is freeded though) */ 364 365 365 366 return VINF_SUCCESS; /** @todo Return host call rc */ … … 503 504 case TSTHGCMMOCKFNTYPE_CALL: 504 505 { 505 pSvc->fnTable.pfnCall(NULL, pFn->u.Call.hCall, pFn->pClient->idClient, pFn->pClient->pvClient, 506 pFn->u.Call.iFunc, pFn->u.Call.cParms, pFn->u.Call.pParms, RTTimeMilliTS()); 506 pSvc->fnTable.pfnCall(pSvc->fnTable.pvService, pFn->u.Call.hCall, pFn->pClient->idClient, 507 pFn->pClient->pvClient, pFn->u.Call.iFunc, pFn->u.Call.cParms, 508 pFn->u.Call.pParms, RTTimeNanoTS()); 507 509 508 510 /* Note: Call will be completed in the call completion callback. */ … … 512 514 case TSTHGCMMOCKFNTYPE_HOST_CALL: 513 515 { 514 pSvc->rcHostCall = pSvc->fnTable.pfnHostCall(NULL, pFn->u.HostCall.iFunc, pFn->u.HostCall.cParms, pFn->u.HostCall.pParms); 516 pSvc->rcHostCall = pSvc->fnTable.pfnHostCall(pSvc->fnTable.pvService, pFn->u.HostCall.iFunc, 517 pFn->u.HostCall.cParms, pFn->u.HostCall.pParms); 515 518 516 519 int rc2 = RTSemEventSignal(pSvc->hEventHostCall); … … 544 547 PTSTHGCMMOCKSVC TstHgcmMockSvcInst(void) 545 548 { 546 return & s_tstHgcmSvc;549 return &g_tstHgcmSvc; 547 550 } 548 551 … … 581 584 * @return VBox status code. 582 585 * @param pSvc HGCM mock service instance to create. 583 * @param cbClient Size (in bytes) of service-specific client data to 584 * allocate for a HGCM mock client. 585 */ 586 int TstHgcmMockSvcCreate(PTSTHGCMMOCKSVC pSvc, size_t cbClient) 587 { 588 AssertReturn(cbClient, VERR_INVALID_PARAMETER); 589 586 */ 587 int TstHgcmMockSvcCreate(PTSTHGCMMOCKSVC pSvc) 588 { 590 589 RT_ZERO(pSvc->aHgcmClient); 591 590 pSvc->fShutdown = false; … … 600 599 { 601 600 RTListInit(&pSvc->lstCall); 602 603 pSvc->cbClient = cbClient;604 601 } 605 602 } -
trunk/src/VBox/HostServices/GuestControl/testcase/tstGuestControlMockHGCM.cpp
r98526 r98574 26 26 */ 27 27 28 29 /********************************************************************************************************************************* 30 * Header Files * 31 *********************************************************************************************************************************/ 28 32 #include <VBox/HostServices/GuestControlSvc.h> 29 33 #include <VBox/VBoxGuestLib.h> … … 51 55 * Shared Clipboard testing * 52 56 *********************************************************************************************************************************/ 57 /** @todo r=bird: Clipboard? */ 58 53 59 struct CLIPBOARDTESTDESC; 54 60 /** Pointer to a test description. */ … … 103 109 CLIPBOARDTESTCTX g_TstCtx; 104 110 111 #if 0 /** @todo r=bird: Clipboard? This times out and asserts and doesn't seems to do anything sensible. */ 112 105 113 /** 106 114 * Structure for keeping a clipboard test description. … … 120 128 } SHCLCONTEXT; 121 129 130 #endif 131 122 132 123 133 static void testGuestSimple(void) … … 155 165 * Test: Guest reading from host * 156 166 ********************************************************************************************************************************/ 167 /** @todo r=bird: Reading from the host? WTF? Doesn't seem to work, so I've disabled it till it can be rewritten and 168 * made to do something useful rather than asserting. */ 169 #if 0 157 170 typedef struct TSTUSERMOCK 158 171 { … … 193 206 { 194 207 RT_NOREF(pTstCtx, ppvCtx); 195 196 int rc = VINF_SUCCESS; 197 198 return rc; 208 return VINF_SUCCESS; 199 209 } 200 210 … … 233 243 } 234 244 245 #endif 246 235 247 236 248 /********************************************************************************************************************************* 237 249 * Main * 238 250 ********************************************************************************************************************************/ 251 #if 0 /** @todo r=bird: Same as above. */ 239 252 240 253 /** Test definition table. */ … … 265 278 } 266 279 267 int main(int argc, char *argv[]) 280 #endif 281 282 int main() 268 283 { 269 284 /* 270 285 * Init the runtime, test and say hello. 271 286 */ 272 const char *pcszExecName; 273 NOREF(argc); 274 pcszExecName = strrchr(argv[0], '/'); 275 pcszExecName = pcszExecName ? pcszExecName + 1 : argv[0]; 276 RTEXITCODE rcExit = RTTestInitAndCreate(pcszExecName, &g_hTest); 287 RTEXITCODE rcExit = RTTestInitAndCreate("tstGuestControlMockHGCM", &g_hTest); 277 288 if (rcExit != RTEXITCODE_SUCCESS) 278 289 return rcExit; 279 290 RTTestBanner(g_hTest); 280 291 281 #if ndef DEBUG_andy292 #if 0 //ndef DEBUG_andy - bird: fix the 'ing code. 282 293 /* Don't let assertions in the host service panic (core dump) the test cases. */ 283 294 RTAssertSetMayPanic(false); … … 285 296 286 297 PTSTHGCMMOCKSVC const pSvc = TstHgcmMockSvcInst(); 287 288 TstHgcmMockSvcCreate(pSvc, 42 /** @todo */); 298 TstHgcmMockSvcCreate(pSvc); 289 299 TstHgcmMockSvcStart(pSvc); 290 300 … … 298 308 } 299 309 310 #if 0 /** @todo r=bird: Clipboard? This times out and asserts and doesn't seems to do anything sensible. */ 300 311 RT_ZERO(g_TstCtx); 301 312 … … 311 322 312 323 TstHGCMUtilsTaskDestroy(pTask); 324 #endif 313 325 314 326 TstHgcmMockSvcStop(pSvc); -
trunk/src/VBox/HostServices/SharedClipboard/testcase/tstClipboardMockHGCM.cpp
r98103 r98574 699 699 700 700 PTSTHGCMMOCKSVC const pSvc = TstHgcmMockSvcInst(); 701 TstHgcmMockSvcCreate(pSvc , sizeof(SHCLCLIENT));701 TstHgcmMockSvcCreate(pSvc); 702 702 TstHgcmMockSvcStart(pSvc); 703 703
Note:
See TracChangeset
for help on using the changeset viewer.