VirtualBox

Changeset 26775 in vbox


Ignore:
Timestamp:
Feb 25, 2010 2:42:45 AM (15 years ago)
Author:
vboxsync
Message:

tstRTPipe: another test.

File:
1 edited

Legend:

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

    r26774 r26775  
    4141
    4242
     43static void tstRTPipe3(void)
     44{
     45    RTTestISub("Full write buffer");
     46
     47    RTPIPE  hPipeR = (RTPIPE)999999;
     48    RTPIPE  hPipeW = (RTPIPE)999999;
     49    RTTESTI_CHECK_RC_RETV(RTPipeCreate(&hPipeR, &hPipeW, 0), VINF_SUCCESS);
     50
     51    static char s_abBuf[_256K];
     52    int         rc      = VINF_SUCCESS;
     53    size_t      cbTotal = 0;
     54    memset(s_abBuf, 0xff, sizeof(s_abBuf));
     55    for (;;)
     56    {
     57        RTTESTI_CHECK(cbTotal < _1G);
     58        if (cbTotal > _1G)
     59            break;
     60
     61        size_t cbWritten = _1G;
     62        rc = RTPipeWrite(hPipeW, s_abBuf, sizeof(s_abBuf), &cbWritten);
     63        RTTESTI_CHECK(rc == VINF_SUCCESS || rc == VINF_TRY_AGAIN);
     64        if (rc != VINF_SUCCESS)
     65            break;
     66        cbTotal += cbWritten;
     67    }
     68
     69    if (rc == VINF_TRY_AGAIN)
     70    {
     71        RTTestIPrintf(RTTESTLVL_ALWAYS, "cbTotal=%zu (%#zx)\n", cbTotal, cbTotal);
     72        RTTESTI_CHECK_RC(RTPipeSelectOne(hPipeW, 0), VERR_TIMEOUT);
     73        RTTESTI_CHECK_RC(RTPipeSelectOne(hPipeW, 1), VERR_TIMEOUT);
     74        size_t cbRead;
     75        RTTESTI_CHECK_RC(RTPipeRead(hPipeR, s_abBuf, RT_MIN(sizeof(s_abBuf), cbTotal) / 2, &cbRead), VINF_SUCCESS);
     76        RTTESTI_CHECK_RC(RTPipeSelectOne(hPipeW, 0), VINF_SUCCESS);
     77        RTTESTI_CHECK_RC(RTPipeSelectOne(hPipeW, 1), VINF_SUCCESS);
     78
     79        size_t cbWritten = _1G;
     80        rc = RTPipeWrite(hPipeW, s_abBuf, sizeof(s_abBuf), &cbWritten);
     81        RTTESTI_CHECK(rc == VINF_SUCCESS);
     82    }
     83
     84    RTTESTI_CHECK_RC(RTPipeClose(hPipeR), VINF_SUCCESS);
     85    RTTESTI_CHECK_RC(RTPipeClose(hPipeW), VINF_SUCCESS);
     86}
     87
    4388static void tstRTPipe2(void)
    4489{
     
    265310        RTAssertSetQuiet(fQuiet);
    266311        RTAssertSetMayPanic(fMayPanic);
     312
     313        tstRTPipe3();
    267314    }
    268315
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