VirtualBox

Changeset 102886 in vbox for trunk/src


Ignore:
Timestamp:
Jan 16, 2024 8:59:26 AM (13 months ago)
Author:
vboxsync
Message:

Runtime/tstRTSg: Ensure that u64First <= u64Last when passed to RTRandAdvU64Ex() as it will return very large values otherwise breaking the testcase as the offset is not in the range to be expected, fixes spurious testcase failes [better fix]

File:
1 edited

Legend:

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

    r102885 r102886  
    208208
    209209        /* Use RTSgBufGetNextSegment with random starting point. */
    210         for (unsigned iRun = 0; iRun < _1K; iRun++)
     210        for (unsigned iRun = 0; iRun < RT_MIN(_1K, cbSgBuf1); iRun++)
    211211        {
    212212            RTSgBufReset(pSgBuf1);
     
    214214            if (iRun > 1)
    215215            {
    216                 size_t const cbInitial = (size_t)RTRandAdvU64Ex(hRnd, RT_MIN(iRun, cbSgBuf1), cbSgBuf1);
     216                size_t const cbInitial = (size_t)RTRandAdvU64Ex(hRnd, iRun, cbSgBuf1);
    217217                size_t cbAdvanced = RTSgBufAdvance(pSgBuf1, cbInitial);
    218218                RTTESTI_CHECK_MSG(cbAdvanced == cbInitial, ("iBufVar=%u iRun=%u cbAdvanced=%zu, cbInitial=%zu\n", iBufVar, iRun, cbAdvanced, cbInitial));
     
    246246        {
    247247            uint8_t const *pbSrc = (uint8_t const *)pSgBuf1->paSegs[0].pvSeg;
    248             for (unsigned iRun = 0; iRun < _1K; iRun++)
     248            for (unsigned iRun = 0; iRun < RT_MIN(_1K, cbSgBuf1); iRun++)
    249249            {
    250250                RTSgBufReset(pSgBuf1);
     
    253253                if (iRun > 1)
    254254                {
    255                     cbInitial = (size_t)RTRandAdvU64Ex(hRnd, RT_MIN(iRun, cbSgBuf1), cbSgBuf1);
     255                    cbInitial = (size_t)RTRandAdvU64Ex(hRnd, iRun, cbSgBuf1);
    256256                    size_t cbAdvanced = RTSgBufAdvance(pSgBuf1, cbInitial);
    257257                    RTTESTI_CHECK_MSG(cbAdvanced == cbInitial, ("cbAdvanced=%zu, cbInitial=%zu\n",
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