Changeset 55863 in vbox for trunk/src/VBox/Runtime/testcase
- Timestamp:
- May 14, 2015 6:29:34 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/testcase/tstRTR0ThreadPreemption.cpp
r54453 r55863 49 49 RTCPUID uSourceCpuId; 50 50 RTNATIVETHREAD hSourceThread; 51 RTTHREADCTX hThreadCtx;52 51 53 52 /* For RTTHREADCTXEVENT_PREEMPTING. */ … … 82 81 switch (enmEvent) 83 82 { 84 case RTTHREADCTXEVENT_ PREEMPTING:83 case RTTHREADCTXEVENT_OUT: 85 84 { 86 85 ASMAtomicWriteBool(&pData->fPreemptingInvoked, true); … … 119 118 } 120 119 121 case RTTHREADCTXEVENT_ RESUMED:120 case RTTHREADCTXEVENT_IN: 122 121 { 123 122 ASMAtomicWriteBool(&pData->fResumedInvoked, true); … … 302 301 } 303 302 304 bool fRegistered = RTThreadCtxHook sAreRegistered(NIL_RTTHREADCTX);303 bool fRegistered = RTThreadCtxHookIsEnabled(NIL_RTTHREADCTXHOOK); 305 304 if (fRegistered) 306 305 { 307 RTStrPrintf(pszErr, cchErr, "!RTThreadCtxHooksAreRegistered returns true before creating any hooks"); 308 break; 309 } 310 311 RTTHREADCTX hThreadCtx; 312 int rc = RTThreadCtxHooksCreate(&hThreadCtx); 313 if (RT_FAILURE(rc)) 314 { 315 if (rc == VERR_NOT_SUPPORTED) 316 RTStrPrintf(pszErr, cchErr, "RTThreadCtxHooksCreate returns VERR_NOT_SUPPORTED"); 317 else 318 RTStrPrintf(pszErr, cchErr, "!RTThreadCtxHooksCreate returns %Rrc", rc); 319 break; 320 } 321 322 fRegistered = RTThreadCtxHooksAreRegistered(hThreadCtx); 323 if (fRegistered) 324 { 325 RTStrPrintf(pszErr, cchErr, "!RTThreadCtxHooksAreRegistered returns true before registering any hooks"); 326 RTThreadCtxHooksRelease(hThreadCtx); 306 RTStrPrintf(pszErr, cchErr, "!RTThreadCtxHookIsEnabled returns true before creating any hooks"); 327 307 break; 328 308 } … … 331 311 AssertReturn(pCtxData, VERR_NO_MEMORY); 332 312 pCtxData->u32Magic = TSTRTR0THREADCTXDATA_MAGIC; 333 pCtxData->hThreadCtx = hThreadCtx;334 313 pCtxData->fPreemptingSuccess = false; 335 314 pCtxData->fPreemptingInvoked = false; … … 339 318 RT_ZERO(pCtxData->achResult); 340 319 320 RTTHREADCTXHOOK hThreadCtx; 321 int rc = RTThreadCtxHookCreate(&hThreadCtx, 0, tstRTR0ThreadCtxHook, pCtxData); 322 if (RT_FAILURE(rc)) 323 { 324 if (rc == VERR_NOT_SUPPORTED) 325 RTStrPrintf(pszErr, cchErr, "RTThreadCtxHooksCreate returns VERR_NOT_SUPPORTED"); 326 else 327 RTStrPrintf(pszErr, cchErr, "!RTThreadCtxHooksCreate returns %Rrc", rc); 328 RTMemFree(pCtxData); 329 break; 330 } 331 332 fRegistered = RTThreadCtxHookIsEnabled(hThreadCtx); 333 if (fRegistered) 334 { 335 RTStrPrintf(pszErr, cchErr, "!RTThreadCtxHookIsEnabled returns true before registering any hooks"); 336 RTThreadCtxHookDestroy(hThreadCtx); 337 break; 338 } 339 341 340 RTTHREADPREEMPTSTATE PreemptState = RTTHREADPREEMPTSTATE_INITIALIZER; 342 341 RTThreadPreemptDisable(&PreemptState); … … 345 344 pCtxData->uSourceCpuId = RTMpCpuId(); 346 345 347 rc = RTThreadCtxHook sRegister(hThreadCtx, &tstRTR0ThreadCtxHook, pCtxData);346 rc = RTThreadCtxHookEnable(hThreadCtx); 348 347 if (RT_FAILURE(rc)) 349 348 { 350 349 RTThreadPreemptRestore(&PreemptState); 351 350 RTMemFree(pCtxData); 352 RTStrPrintf(pszErr, cchErr, "!RTThreadCtxHook sRegisterreturns %Rrc", rc);353 break; 354 } 355 356 fRegistered = RTThreadCtxHook sAreRegistered(hThreadCtx);351 RTStrPrintf(pszErr, cchErr, "!RTThreadCtxHookEnable returns %Rrc", rc); 352 break; 353 } 354 355 fRegistered = RTThreadCtxHookIsEnabled(hThreadCtx); 357 356 if (!fRegistered) 358 357 { 359 358 RTThreadPreemptRestore(&PreemptState); 360 359 RTMemFree(pCtxData); 361 RTStrPrintf(pszErr, cchErr, "!RTThreadCtxHook sAreRegistered return false when hooks are supposedly registered");360 RTStrPrintf(pszErr, cchErr, "!RTThreadCtxHookIsEnabled return false when hooks are supposedly registered"); 362 361 break; 363 362 } … … 428 427 } 429 428 430 RTThreadCtxHook sDeregister(hThreadCtx);431 432 fRegistered = RTThreadCtxHook sAreRegistered(hThreadCtx);429 RTThreadCtxHookDisable(hThreadCtx); 430 431 fRegistered = RTThreadCtxHookIsEnabled(hThreadCtx); 433 432 if (fRegistered) 434 433 { 435 434 RTMemFree(pCtxData); 436 RTStrPrintf(pszErr, cchErr, "!RTThreadCtxHook sAreRegistered return true when hooks are deregistered");435 RTStrPrintf(pszErr, cchErr, "!RTThreadCtxHookIsEnabled return true when hooks are deregistered"); 437 436 break; 438 437 } 439 438 440 439 Assert(RTThreadPreemptIsEnabled(NIL_RTTHREAD)); 441 uint32_t cRefs = RTThreadCtxHooksRelease(hThreadCtx);442 if ( cRefs == UINT32_MAX)443 RTStrPrintf(pszErr, cchErr, "!RTThreadCtxHooksRelease returns invalid cRefs!");440 rc = RTThreadCtxHookDestroy(hThreadCtx); 441 if (RT_FAILURE(rc)) 442 RTStrPrintf(pszErr, cchErr, "!RTThreadCtxHooksRelease returns %Rrc!", rc); 444 443 445 444 RTMemFree(pCtxData);
Note:
See TracChangeset
for help on using the changeset viewer.