- Timestamp:
- Mar 26, 2013 2:27:59 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/testcase/tstSupSem.cpp
r44528 r45182 288 288 289 289 { 290 291 #define LOOP_COUNT 20 290 292 static unsigned const s_acMsIntervals[] = { 0, 1, 2, 3, 4, 8, 10, 16, 32 }; 291 293 if (RTTestErrorCount(hTest) == 0) … … 294 296 RTTESTI_CHECK_RC(SUPSemEventCreate(pSession, &hEvent), VINF_SUCCESS); 295 297 298 uint32_t cInterrupted = 0; 296 299 for (unsigned i = 0; i < RT_ELEMENTS(s_acMsIntervals); i++) 297 300 { … … 301 304 uint64_t cNsTotalSys= 0; 302 305 uint64_t cNsTotal = 0; 303 for (unsigned j = 0; j < 10; j++) 306 unsigned cLoops = 0; 307 while (cLoops < LOOP_COUNT) 304 308 { 305 309 uint64_t u64StartSys = RTTimeSystemNanoTS(); 306 310 uint64_t u64Start = RTTimeNanoTS(); 307 311 int rcX = SUPSemEventWaitNoResume(pSession, hEvent, cMs); 308 if (rcX != VERR_TIMEOUT)309 RTTestFailed(hTest, "%Rrc j=%u cMs=%u", rcX, j, cMs);310 312 uint64_t cNsElapsedSys = RTTimeSystemNanoTS() - u64StartSys; 311 313 uint64_t cNsElapsed = RTTimeNanoTS() - u64Start; 314 315 if (rcX == VERR_INTERRUPTED) 316 { 317 cInterrupted++; 318 continue; /* retry */ 319 } 320 if (rcX != VERR_TIMEOUT) 321 RTTestFailed(hTest, "%Rrc cLoops=%u cMs=%u", rcX, cLoops, cMs); 322 312 323 if (cNsElapsedSys < cNsMinSys) 313 324 cNsMinSys = cNsElapsedSys; … … 316 327 cNsTotalSys += cNsElapsedSys; 317 328 cNsTotal += cNsElapsed; 329 cLoops++; 318 330 } 319 331 if (fSys) 320 332 { 321 RTTestValueF(hTest, cNsMinSys, RTTESTUNIT_NS, "%u ms min (clock=sys)", cMs);322 RTTestValueF(hTest, cNsTotalSys / 10, RTTESTUNIT_NS, "%u ms avg (clock=sys)", cMs);333 RTTestValueF(hTest, cNsMinSys, RTTESTUNIT_NS, "%u ms min (clock=sys)", cMs); 334 RTTestValueF(hTest, cNsTotalSys / cLoops, RTTESTUNIT_NS, "%u ms avg (clock=sys)", cMs); 323 335 } 324 336 if (fGip) 325 337 { 326 RTTestValueF(hTest, cNsMin, RTTESTUNIT_NS, "%u ms min (clock=gip)", cMs);327 RTTestValueF(hTest, cNsTotal / 10, RTTESTUNIT_NS, "%u ms avg (clock=gip)", cMs);338 RTTestValueF(hTest, cNsMin, RTTESTUNIT_NS, "%u ms min (clock=gip)", cMs); 339 RTTestValueF(hTest, cNsTotal / cLoops, RTTESTUNIT_NS, "%u ms avg (clock=gip)", cMs); 328 340 } 329 341 } 330 342 331 343 RTTESTI_CHECK_RC(SUPSemEventClose(pSession, hEvent), VINF_OBJECT_DESTROYED); 344 RTTestValueF(hTest, cInterrupted, RTTESTUNIT_OCCURRENCES, "VERR_INTERRUPTED returned", cInterrupted); 332 345 } 333 346 … … 337 350 RTTESTI_CHECK_RC(SUPSemEventMultiCreate(pSession, &hEvent), VINF_SUCCESS); 338 351 352 uint32_t cInterrupted = 0; 339 353 for (unsigned i = 0; i < RT_ELEMENTS(s_acMsIntervals); i++) 340 354 { … … 344 358 uint64_t cNsTotalSys= 0; 345 359 uint64_t cNsTotal = 0; 346 for (unsigned j = 0; j < 10; j++) 360 unsigned cLoops = 0; 361 while (cLoops < LOOP_COUNT) 347 362 { 348 363 uint64_t u64StartSys = RTTimeSystemNanoTS(); 349 364 uint64_t u64Start = RTTimeNanoTS(); 350 365 int rcX = SUPSemEventMultiWaitNoResume(pSession, hEvent, cMs); 351 if (rcX != VERR_TIMEOUT)352 RTTestFailed(hTest, "%Rrc j=%u cMs=%u", rcX, j, cMs);353 366 uint64_t cNsElapsedSys = RTTimeSystemNanoTS() - u64StartSys; 354 367 uint64_t cNsElapsed = RTTimeNanoTS() - u64Start; 368 369 if (rcX == VERR_INTERRUPTED) 370 { 371 cInterrupted++; 372 continue; /* retry */ 373 } 374 if (rcX != VERR_TIMEOUT) 375 RTTestFailed(hTest, "%Rrc cLoops=%u cMs=%u", rcX, cLoops, cMs); 376 355 377 if (cNsElapsedSys < cNsMinSys) 356 378 cNsMinSys = cNsElapsedSys; … … 359 381 cNsTotalSys += cNsElapsedSys; 360 382 cNsTotal += cNsElapsed; 383 cLoops++; 361 384 } 362 385 if (fSys) 363 386 { 364 RTTestValueF(hTest, cNsMinSys, RTTESTUNIT_NS, "%u ms min (clock=sys)", cMs);365 RTTestValueF(hTest, cNsTotalSys / 10, RTTESTUNIT_NS, "%u ms avg (clock=sys)", cMs);387 RTTestValueF(hTest, cNsMinSys, RTTESTUNIT_NS, "%u ms min (clock=sys)", cMs); 388 RTTestValueF(hTest, cNsTotalSys / cLoops, RTTESTUNIT_NS, "%u ms avg (clock=sys)", cMs); 366 389 } 367 390 if (fGip) 368 391 { 369 RTTestValueF(hTest, cNsMin, RTTESTUNIT_NS, "%u ms min (clock=gip)", cMs);370 RTTestValueF(hTest, cNsTotal / 10, RTTESTUNIT_NS, "%u ms avg (clock=gip)", cMs);392 RTTestValueF(hTest, cNsMin, RTTESTUNIT_NS, "%u ms min (clock=gip)", cMs); 393 RTTestValueF(hTest, cNsTotal / cLoops, RTTESTUNIT_NS, "%u ms avg (clock=gip)", cMs); 371 394 } 372 395 } 373 396 374 397 RTTESTI_CHECK_RC(SUPSemEventMultiClose(pSession, hEvent), VINF_OBJECT_DESTROYED); 398 RTTestValueF(hTest, cInterrupted, RTTESTUNIT_OCCURRENCES, "VERR_INTERRUPTED returned", cInterrupted); 375 399 } 376 400 } … … 388 412 RTTESTI_CHECK_RC(SUPSemEventCreate(pSession, &hEvent), VINF_SUCCESS); 389 413 414 uint32_t cInterrupted = 0; 390 415 for (unsigned i = 0; i < RT_ELEMENTS(s_acNsIntervals); i++) 391 416 { … … 395 420 uint64_t cNsTotalSys= 0; 396 421 uint64_t cNsTotal = 0; 397 for (unsigned j = 0; j < 10; j++) 422 unsigned cLoops = 0; 423 while (cLoops < LOOP_COUNT) 398 424 { 399 425 uint64_t u64StartSys = RTTimeSystemNanoTS(); 400 426 uint64_t u64Start = RTTimeNanoTS(); 401 427 int rcX = SUPSemEventWaitNsRelIntr(pSession, hEvent, cNs); 402 if (rcX != VERR_TIMEOUT)403 RTTestFailed(hTest, "%Rrc j=%u cNs=%u", rcX, j, cNs);404 428 uint64_t cNsElapsedSys = RTTimeSystemNanoTS() - u64StartSys; 405 429 uint64_t cNsElapsed = RTTimeNanoTS() - u64Start; 430 431 if (rcX == VERR_INTERRUPTED) 432 { 433 cInterrupted++; 434 continue; /* retry */ 435 } 436 if (rcX != VERR_TIMEOUT) 437 RTTestFailed(hTest, "%Rrc cLoops=%u cNs=%u", rcX, cLoops, cNs); 438 406 439 if (cNsElapsedSys < cNsMinSys) 407 440 cNsMinSys = cNsElapsedSys; … … 410 443 cNsTotalSys += cNsElapsedSys; 411 444 cNsTotal += cNsElapsed; 445 cLoops++; 412 446 } 413 447 if (fSys) 414 448 { 415 RTTestValueF(hTest, cNsMinSys, RTTESTUNIT_NS, "%'u ns min (clock=sys)", cNs);416 RTTestValueF(hTest, cNsTotalSys / 10, RTTESTUNIT_NS, "%'u ns avg (clock=sys)", cNs);449 RTTestValueF(hTest, cNsMinSys, RTTESTUNIT_NS, "%'u ns min (clock=sys)", cNs); 450 RTTestValueF(hTest, cNsTotalSys / cLoops, RTTESTUNIT_NS, "%'u ns avg (clock=sys)", cNs); 417 451 } 418 452 if (fGip) 419 453 { 420 RTTestValueF(hTest, cNsMin, RTTESTUNIT_NS, "%'u ns min (clock=gip)", cNs);421 RTTestValueF(hTest, cNsTotal / 10, RTTESTUNIT_NS, "%'u ns avg (clock=gip)", cNs);454 RTTestValueF(hTest, cNsMin, RTTESTUNIT_NS, "%'u ns min (clock=gip)", cNs); 455 RTTestValueF(hTest, cNsTotal / cLoops, RTTESTUNIT_NS, "%'u ns avg (clock=gip)", cNs); 422 456 } 423 457 } 424 458 425 459 RTTESTI_CHECK_RC(SUPSemEventClose(pSession, hEvent), VINF_OBJECT_DESTROYED); 460 RTTestValueF(hTest, cInterrupted, RTTESTUNIT_OCCURRENCES, "VERR_INTERRUPTED returned", cInterrupted); 426 461 } 427 462 … … 432 467 RTTESTI_CHECK_RC(SUPSemEventMultiCreate(pSession, &hEvent), VINF_SUCCESS); 433 468 469 uint32_t cInterrupted = 0; 434 470 for (unsigned i = 0; i < RT_ELEMENTS(s_acNsIntervals); i++) 435 471 { … … 439 475 uint64_t cNsTotalSys= 0; 440 476 uint64_t cNsTotal = 0; 441 for (unsigned j = 0; j < 10; j++) 477 unsigned cLoops = 0; 478 while (cLoops < LOOP_COUNT) 442 479 { 443 480 uint64_t u64StartSys = RTTimeSystemNanoTS(); 444 481 uint64_t u64Start = RTTimeNanoTS(); 445 482 int rcX = SUPSemEventMultiWaitNsRelIntr(pSession, hEvent, cNs); 446 if (rcX != VERR_TIMEOUT)447 RTTestFailed(hTest, "%Rrc j=%u cNs=%u", rcX, j, cNs);448 483 uint64_t cNsElapsedSys = RTTimeSystemNanoTS() - u64StartSys; 449 484 uint64_t cNsElapsed = RTTimeNanoTS() - u64Start; 485 486 if (rcX == VERR_INTERRUPTED) 487 { 488 cInterrupted++; 489 continue; /* retry */ 490 } 491 if (rcX != VERR_TIMEOUT) 492 RTTestFailed(hTest, "%Rrc cLoops=%u cNs=%u", rcX, cLoops, cNs); 493 450 494 if (cNsElapsedSys < cNsMinSys) 451 495 cNsMinSys = cNsElapsedSys; … … 454 498 cNsTotalSys += cNsElapsedSys; 455 499 cNsTotal += cNsElapsed; 500 cLoops++; 456 501 } 457 502 if (fSys) 458 503 { 459 RTTestValueF(hTest, cNsMinSys, RTTESTUNIT_NS, "%'u ns min (clock=sys)", cNs);460 RTTestValueF(hTest, cNsTotalSys / 10, RTTESTUNIT_NS, "%'u ns avg (clock=sys)", cNs);504 RTTestValueF(hTest, cNsMinSys, RTTESTUNIT_NS, "%'u ns min (clock=sys)", cNs); 505 RTTestValueF(hTest, cNsTotalSys / cLoops, RTTESTUNIT_NS, "%'u ns avg (clock=sys)", cNs); 461 506 } 462 507 if (fGip) 463 508 { 464 RTTestValueF(hTest, cNsMin, RTTESTUNIT_NS, "%'u ns min (clock=gip)", cNs);465 RTTestValueF(hTest, cNsTotal / 10, RTTESTUNIT_NS, "%'u ns avg (clock=gip)", cNs);509 RTTestValueF(hTest, cNsMin, RTTESTUNIT_NS, "%'u ns min (clock=gip)", cNs); 510 RTTestValueF(hTest, cNsTotal / cLoops, RTTESTUNIT_NS, "%'u ns avg (clock=gip)", cNs); 466 511 } 467 512 } 468 513 469 514 RTTESTI_CHECK_RC(SUPSemEventMultiClose(pSession, hEvent), VINF_OBJECT_DESTROYED); 515 RTTestValueF(hTest, cInterrupted, RTTESTUNIT_OCCURRENCES, "VERR_INTERRUPTED returned", cInterrupted); 470 516 } 471 517 … … 476 522 RTTESTI_CHECK_RC(SUPSemEventCreate(pSession, &hEvent), VINF_SUCCESS); 477 523 524 uint32_t cInterrupted = 0; 478 525 for (unsigned i = 0; i < RT_ELEMENTS(s_acNsIntervals); i++) 479 526 { … … 483 530 uint64_t cNsTotalSys= 0; 484 531 uint64_t cNsTotal = 0; 485 for (unsigned j = 0; j < 10; j++) 532 unsigned cLoops = 0; 533 while (cLoops < LOOP_COUNT) 486 534 { 487 535 uint64_t u64StartSys = RTTimeSystemNanoTS(); … … 489 537 uint64_t uAbsDeadline = (fGip ? u64Start : u64StartSys) + cNs; 490 538 int rcX = SUPSemEventWaitNsAbsIntr(pSession, hEvent, uAbsDeadline); 491 if (rcX != VERR_TIMEOUT)492 RTTestFailed(hTest, "%Rrc j=%u cNs=%u", rcX, j, cNs);493 539 uint64_t cNsElapsedSys = RTTimeSystemNanoTS() - u64StartSys; 494 540 uint64_t cNsElapsed = RTTimeNanoTS() - u64Start; 541 542 if (rcX == VERR_INTERRUPTED) 543 { 544 cInterrupted++; 545 continue; /* retry */ 546 } 547 if (rcX != VERR_TIMEOUT) 548 RTTestFailed(hTest, "%Rrc cLoops=%u cNs=%u", rcX, cLoops, cNs); 549 495 550 if (cNsElapsedSys < cNsMinSys) 496 551 cNsMinSys = cNsElapsedSys; … … 499 554 cNsTotalSys += cNsElapsedSys; 500 555 cNsTotal += cNsElapsed; 556 cLoops++; 501 557 } 502 558 if (fSys) 503 559 { 504 RTTestValueF(hTest, cNsMinSys, RTTESTUNIT_NS, "%'u ns min (clock=sys)", cNs);505 RTTestValueF(hTest, cNsTotalSys / 10, RTTESTUNIT_NS, "%'u ns avg (clock=sys)", cNs);560 RTTestValueF(hTest, cNsMinSys, RTTESTUNIT_NS, "%'u ns min (clock=sys)", cNs); 561 RTTestValueF(hTest, cNsTotalSys / cLoops, RTTESTUNIT_NS, "%'u ns avg (clock=sys)", cNs); 506 562 } 507 563 if (fGip) 508 564 { 509 RTTestValueF(hTest, cNsMin, RTTESTUNIT_NS, "%'u ns min (clock=gip)", cNs);510 RTTestValueF(hTest, cNsTotal / 10, RTTESTUNIT_NS, "%'u ns avg (clock=gip)", cNs);565 RTTestValueF(hTest, cNsMin, RTTESTUNIT_NS, "%'u ns min (clock=gip)", cNs); 566 RTTestValueF(hTest, cNsTotal / cLoops, RTTESTUNIT_NS, "%'u ns avg (clock=gip)", cNs); 511 567 } 512 568 } 513 569 514 570 RTTESTI_CHECK_RC(SUPSemEventClose(pSession, hEvent), VINF_OBJECT_DESTROYED); 571 RTTestValueF(hTest, cInterrupted, RTTESTUNIT_OCCURRENCES, "VERR_INTERRUPTED returned", cInterrupted); 515 572 } 516 573 … … 522 579 RTTESTI_CHECK_RC(SUPSemEventMultiCreate(pSession, &hEvent), VINF_SUCCESS); 523 580 581 uint32_t cInterrupted = 0; 524 582 for (unsigned i = 0; i < RT_ELEMENTS(s_acNsIntervals); i++) 525 583 { … … 529 587 uint64_t cNsTotalSys= 0; 530 588 uint64_t cNsTotal = 0; 531 for (unsigned j = 0; j < 10; j++) 589 unsigned cLoops = 0; 590 while (cLoops < LOOP_COUNT) 532 591 { 533 592 uint64_t u64StartSys = RTTimeSystemNanoTS(); … … 535 594 uint64_t uAbsDeadline = (fGip ? u64Start : u64StartSys) + cNs; 536 595 int rcX = SUPSemEventMultiWaitNsAbsIntr(pSession, hEvent, uAbsDeadline); 537 if (rcX != VERR_TIMEOUT)538 RTTestFailed(hTest, "%Rrc j=%u cNs=%u", rcX, j, cNs);539 596 uint64_t cNsElapsedSys = RTTimeSystemNanoTS() - u64StartSys; 540 597 uint64_t cNsElapsed = RTTimeNanoTS() - u64Start; 598 599 if (rcX == VERR_INTERRUPTED) 600 { 601 cInterrupted++; 602 continue; /* retry */ 603 } 604 if (rcX != VERR_TIMEOUT) 605 RTTestFailed(hTest, "%Rrc cLoops=%u cNs=%u", rcX, cLoops, cNs); 606 541 607 if (cNsElapsedSys < cNsMinSys) 542 608 cNsMinSys = cNsElapsedSys; … … 545 611 cNsTotalSys += cNsElapsedSys; 546 612 cNsTotal += cNsElapsed; 613 cLoops++; 547 614 } 548 615 if (fSys) 549 616 { 550 RTTestValueF(hTest, cNsMinSys, RTTESTUNIT_NS, "%'u ns min (clock=sys)", cNs);551 RTTestValueF(hTest, cNsTotalSys / 10, RTTESTUNIT_NS, "%'u ns avg (clock=sys)", cNs);617 RTTestValueF(hTest, cNsMinSys, RTTESTUNIT_NS, "%'u ns min (clock=sys)", cNs); 618 RTTestValueF(hTest, cNsTotalSys / cLoops, RTTESTUNIT_NS, "%'u ns avg (clock=sys)", cNs); 552 619 } 553 620 if (fGip) 554 621 { 555 RTTestValueF(hTest, cNsMin, RTTESTUNIT_NS, "%'u ns min (clock=gip)", cNs);556 RTTestValueF(hTest, cNsTotal / 10, RTTESTUNIT_NS, "%'u ns avg (clock=gip)", cNs);622 RTTestValueF(hTest, cNsMin, RTTESTUNIT_NS, "%'u ns min (clock=gip)", cNs); 623 RTTestValueF(hTest, cNsTotal / cLoops, RTTESTUNIT_NS, "%'u ns avg (clock=gip)", cNs); 557 624 } 558 625 } 559 626 560 627 RTTESTI_CHECK_RC(SUPSemEventMultiClose(pSession, hEvent), VINF_OBJECT_DESTROYED); 628 RTTestValueF(hTest, cInterrupted, RTTESTUNIT_OCCURRENCES, "VERR_INTERRUPTED returned", cInterrupted); 561 629 } 562 630
Note:
See TracChangeset
for help on using the changeset viewer.