VirtualBox

Ignore:
Timestamp:
Sep 24, 2010 9:28:18 AM (14 years ago)
Author:
vboxsync
Message:

tstRTR0Timer: fixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/testcase/tstRTR0Timer.cpp

    r32742 r32749  
    124124    if (iCpu < RTCPUSET_MAX_CPUS)
    125125    {
    126         uint32_t iCountedTick = ASMAtomicIncU32(&paStates[iCpu].cTicks) - 1;
    127         RTR0TESTR0_CHECK_MSG(iCountedTick == iTick, 
     126        uint32_t iCountedTick = ASMAtomicIncU32(&paStates[iCpu].cTicks);
     127        RTR0TESTR0_CHECK_MSG(iCountedTick == iTick,
    128128                             ("iCountedTick=%u iTick=%u iCpu=%d idCpu=%u\n", iCountedTick, iTick, iCpu, idCpu));
    129129        paStates[iCpu].u64Last = RTTimeSystemNanoTS();
    130         if (paStates[iCpu].u64Start)
     130        if (!paStates[iCpu].u64Start)
    131131        {
    132132            paStates[iCpu].u64Start = paStates[iCpu].u64Last;
    133             RTR0TESTR0_CHECK_MSG(iCountedTick == 0, ("iCountedTick=%u iCpu=%d idCpu=%u\n", iCountedTick, iCpu, idCpu));
     133            RTR0TESTR0_CHECK_MSG(iCountedTick == 1, ("iCountedTick=%u iCpu=%d idCpu=%u\n", iCountedTick, iCpu, idCpu));
    134134        }
    135135    }
     
    707707
    708708            PRTTIMER        pTimer;
    709             uint32_t        fFlags = TSTRTR0TIMER_IS_HIRES(uOperation) ? RTTIMER_FLAGS_HIGH_RES : 0;
     709            uint32_t        fFlags = (TSTRTR0TIMER_IS_HIRES(uOperation) ? RTTIMER_FLAGS_HIGH_RES : 0)
     710                                   | RTTIMER_FLAGS_CPU_ALL;
    710711            RTR0TESTR0_CHECK_RC_BREAK(RTTimerCreateEx(&pTimer, cNsInterval, fFlags, tstRTR0TimerCallbackOmni, paStates),
    711712                                      VINF_SUCCESS);
     
    723724                RTMpGetOnlineSet(&OnlineSet);
    724725
    725                 for (uint32_t i = 0; i < 1000 && RTTimeSystemNanoTS() - uStartNsTS <= UINT32_C(1000000000); i++)
    726                     RTThreadSleep(10);
     726                for (uint32_t i = 0; i < 5000 && RTTimeSystemNanoTS() - uStartNsTS <= UINT32_C(1000000000); i++)
     727                    RTThreadSleep(2);
    727728
    728729                RTR0TESTR0_CHECK_RC_BREAK(RTTimerStop(pTimer), VINF_SUCCESS);
     730                uint64_t    cNsElapsedX = RTTimeNanoTS() - uStartNsTS;
    729731
    730732                /* Do a min/max on the start and stop times and calculate the test period. */
    731                 uint64_t  u64MinStart = UINT64_MAX;
    732                 uint64_t  u64MaxStop  = 0;
     733                uint64_t    u64MinStart = UINT64_MAX;
     734                uint64_t    u64MaxStop  = 0;
    733735                for (uint32_t iCpu = 0; iCpu < RTCPUSET_MAX_CPUS; iCpu++)
    734736                {
     
    743745                RTR0TESTR0_CHECK_MSG(u64MinStart < u64MaxStop, ("%llu, %llu", u64MinStart, u64MaxStop));
    744746                uint64_t cNsElapsed = u64MaxStop - u64MinStart;
    745                 uint32_t cAvgTicks  = cNsElapsed / cNsInterval;
     747                RTR0TESTR0_CHECK_MSG(cNsElapsed <= cNsElapsedX + 1000, ("%llu, %llu", cNsElapsed, cNsElapsedX));
     748                uint32_t cAvgTicks  = cNsElapsed / cNsInterval + 1;
    746749
    747750                /* Check tick counts. ASSUMES no cpu on- or offlining.
     
    753756                    {
    754757                        RTR0TESTR0_CHECK_MSG(RTCpuSetIsMemberByIndex(&OnlineSet, iCpu), ("%d\n", iCpu));
    755                         RTR0TESTR0_CHECK_MSG(paStates[iCpu].cTicks >= cMinTicks,
    756                                              ("%u, min=%u, iCpu=%u\n", paStates[iCpu].cTicks, cMinTicks, iCpu));
    757                         RTR0TESTR0_CHECK_MSG(paStates[iCpu].cTicks <= cMaxTicks,
    758                                               ("%u, max=%u, iCpu=%u\n", paStates[iCpu].cTicks, cMaxTicks, iCpu));
     758                        RTR0TESTR0_CHECK_MSG(paStates[iCpu].cTicks <= cMaxTicks && paStates[iCpu].cTicks >= cMinTicks,
     759                                             ("min=%u, ticks=%u, avg=%u max=%u, iCpu=%u, interval=%'u, elapsed=%'u/%'u\n",
     760                                              cMinTicks, paStates[iCpu].cTicks, cAvgTicks, cMaxTicks, iCpu,
     761                                              cNsInterval, cNsElapsed, cNsElapsedX));
    759762                    }
    760763                    else
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette