VirtualBox

忽略:
時間撮記:
2023-2-17 下午12:40:38 (2 年 以前)
作者:
vboxsync
svn:sync-xref-src-repo-rev:
155912
訊息:

IPRT/tstRTPipe: Tweaked the test to no fail on some old windows behaviour that we're not able to work around.

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Runtime/testcase/tstRTPipe.cpp

    r98103 r98619  
    4949#include <iprt/process.h>
    5050#include <iprt/string.h>
     51#ifdef RT_OS_WINDOWS
     52# include <iprt/system.h>
     53#endif
    5154#include <iprt/test.h>
    5255
     
    5558*   Global Variables                                                                                                             *
    5659*********************************************************************************************************************************/
     60static RTTEST     g_hTest            = NIL_RTTEST;
    5761static const char g_szTest4Message[] = "This is test #4, everything is working fine.\n\r";
    5862static const char g_szTest5Message[] = "This is test #5, everything is working fine.\n\r";
     
    214218{
    215219    RTTestISub("Full write buffer");
    216 
    217220#ifdef RT_OS_WINDOWS
    218221    /* Kludge! The RTPipeWrite+RTPipeWriteBlocking code is able to write twice the size
     
    255258            size_t cbRead;
    256259            RTTESTI_CHECK_RC(RTPipeReadBlocking(hPipeR, s_abBuf, cbToRead, &cbRead), VINF_SUCCESS);
    257             RTTESTI_CHECK_RC(RTPipeSelectOne(hPipeW, 0), VINF_SUCCESS);
    258             RTTESTI_CHECK_RC(RTPipeSelectOne(hPipeW, 1), VINF_SUCCESS);
    259 
    260             size_t cbWritten = _1G;
    261             rc = RTPipeWrite(hPipeW, s_abBuf, sizeof(s_abBuf), &cbWritten);
    262             RTTESTI_CHECK(rc == VINF_SUCCESS);
     260
     261#ifdef RT_OS_WINDOWS
     262            /* Kludge! Older Windows NT versions does not complete a pending write till
     263                       all the pending data has been read and the pipe buffer is
     264                       completely empty. Applies to NT4, W2K, and XP. Though on XP the
     265                       test works at 50% for some reason and we can write double the
     266                       amount, so possibly a different issue there, so we'l
     267
     268                       This does not seem to be a bug in pipe-win.cpp. */
     269            if (RTSystemGetNtVersion() < (uPct == 50 ? RTSYSTEM_MAKE_NT_VERSION(5,2,0) : RTSYSTEM_MAKE_NT_VERSION(6,0,0)))
     270                RTTestIPrintf(RTTESTLVL_ALWAYS, "old buggy windows - skipping 2nd part (0: %Rrc, 1: %Rrc)\n",
     271                              RTPipeSelectOne(hPipeW, 0), RTPipeSelectOne(hPipeW, 1));
     272            else
     273#endif
     274            {
     275                RTTESTI_CHECK_RC(RTPipeSelectOne(hPipeW, 0), VINF_SUCCESS);
     276                RTTESTI_CHECK_RC(RTPipeSelectOne(hPipeW, 1), VINF_SUCCESS);
     277
     278                size_t cbWritten = _1G;
     279                rc = RTPipeWrite(hPipeW, s_abBuf, sizeof(s_abBuf), &cbWritten);
     280                RTTESTI_CHECK(rc == VINF_SUCCESS);
     281            }
    263282        }
    264283
     
    508527        return tstRTPipe5Child(argv[2]);
    509528
    510     RTTEST hTest;
    511     int rc = RTTestInitAndCreate("tstRTPipe", &hTest);
     529    int rc = RTTestInitAndCreate("tstRTPipe", &g_hTest);
    512530    if (rc)
    513531        return rc;
    514     RTTestBanner(hTest);
     532    RTTestBanner(g_hTest);
    515533
    516534    /*
     
    518536     */
    519537    tstRTPipe1();
    520     if (RTTestErrorCount(hTest) == 0)
     538    if (RTTestErrorCount(g_hTest) == 0)
    521539    {
    522540        bool fMayPanic = RTAssertMayPanic();
     
    536554     * Summary.
    537555     */
    538     return RTTestSummaryAndDestroy(hTest);
    539 }
    540 
     556    return RTTestSummaryAndDestroy(g_hTest);
     557}
     558
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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