tstRTPipe.cpp revision e64031e20c39650a7bc902a3e1aba613b9415dee
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync * IPRT Testcase - RTPipe.
e64031e20c39650a7bc902a3e1aba613b9415deevboxsync * Copyright (C) 2010 Oracle Corporation
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync * available from http://www.virtualbox.org. This file is free software;
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync * you can redistribute it and/or modify it under the terms of the GNU
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync * General Public License (GPL) as published by the Free Software
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync * The contents of this file may alternatively be used under the terms
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync * of the Common Development and Distribution License Version 1.0
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync * VirtualBox OSE distribution, in which case the provisions of the
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync * CDDL are applicable instead of those of the GPL.
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync * You may elect to license modified versions of this file under the
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync * terms and conditions of either the GPL or the CDDL or both.
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync/*******************************************************************************
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync* Header Files *
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync*******************************************************************************/
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync/*******************************************************************************
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync* Global Variables *
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync*******************************************************************************/
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsyncstatic const char g_szTest4Message[] = "This is test #4, everything is working fine.\n\r";
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsyncstatic const char g_szTest5Message[] = "This is test #5, everything is working fine.\n\r";
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsyncstatic RTEXITCODE tstRTPipe5Child(const char *pszPipe)
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTStrToUInt64Full(%s) -> %Rrc\n", pszPipe, rc);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync rc = RTPipeFromNative(&hPipe, (RTHCINTPTR)iNative, RTPIPE_N_READ);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTPipeFromNative(,%s,READ) -> %Rrc\n", pszPipe, rc);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync rc = RTPipeReadBlocking(hPipe, szTmp, sizeof(szTmp) - 1, &cbRead);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTPipeReadBlocking() -> %Rrc\n", rc);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync rc = RTPipeReadBlocking(hPipe, szTmp2, sizeof(szTmp2), &cbRead2);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTPipeReadBlocking() -> %Rrc instead of VERR_BROKEN_PIPE\n", rc);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTPipeClose() -> %Rrc\n", rc);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync if (memcmp(szTmp, g_szTest5Message, sizeof(g_szTest5Message)))
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync return RTMsgErrorExit(RTEXITCODE_FAILURE, "Message mismatch.\n:Expected '%s'\nGot '%s'\n", g_szTest5Message, szTmp);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsyncstatic void tstRTPipe5(void)
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync RTTestISub("Inherit non-standard pipe handle, read end");
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync RTTESTI_CHECK_RETV(RTProcGetExecutableName(szPathSelf, sizeof(szPathSelf)) == szPathSelf);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync RTTESTI_CHECK_RC_RETV(RTPipeCreate(&hPipeR, &hPipeW, RTPIPE_C_INHERIT_READ), VINF_SUCCESS);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync RTStrPrintf(szNative, sizeof(szNative), "%RHi", hNative);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync const char *papszArgs[4] = { szPathSelf, "--child-5", szNative, NULL };
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync RTTESTI_CHECK_RC_RETV(RTProcCreate(szPathSelf, papszArgs, RTENV_DEFAULT, 0 /*fFlags*/, &hChild), VINF_SUCCESS);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync RTTESTI_CHECK_RC_RETV(RTPipeClose(hPipeR), VINF_SUCCESS);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync RTTESTI_CHECK_RC(RTPipeWriteBlocking(hPipeW, g_szTest5Message, sizeof(g_szTest5Message) - 1, NULL), VINF_SUCCESS);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync RTTESTI_CHECK_RC(rc = RTPipeClose(hPipeW), VINF_SUCCESS);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync RTTESTI_CHECK_RC(RTProcTerminate(hChild), VINF_SUCCESS);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync RTTESTI_CHECK_RC(rc = RTProcWait(hChild, RTPROCWAIT_FLAGS_BLOCK, &ProcStatus), VINF_SUCCESS);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync RTTESTI_CHECK( ProcStatus.enmReason == RTPROCEXITREASON_NORMAL
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsyncstatic RTEXITCODE tstRTPipe4Child(const char *pszPipe)
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTStrToUInt64Full(%s) -> %Rrc\n", pszPipe, rc);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync rc = RTPipeFromNative(&hPipe, (RTHCINTPTR)iNative, RTPIPE_N_WRITE);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTPipeFromNative(,%s,WRITE) -> %Rrc\n", pszPipe, rc);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync rc = RTPipeWriteBlocking(hPipe, g_szTest4Message, sizeof(g_szTest4Message) - 1, NULL);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTPipeWriteBlocking() -> %Rrc\n", rc);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTPipeClose() -> %Rrc\n", rc);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsyncstatic void tstRTPipe4(void)
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync RTTestISub("Inherit non-standard pipe handle, write end");
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync RTTESTI_CHECK_RETV(RTProcGetExecutableName(szPathSelf, sizeof(szPathSelf)) == szPathSelf);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync RTTESTI_CHECK_RC_RETV(RTPipeCreate(&hPipeR, &hPipeW, RTPIPE_C_INHERIT_WRITE), VINF_SUCCESS);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync RTStrPrintf(szNative, sizeof(szNative), "%RHi", hNative);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync const char *papszArgs[4] = { szPathSelf, "--child-4", szNative, NULL };
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync RTTESTI_CHECK_RC_RETV(RTProcCreate(szPathSelf, papszArgs, RTENV_DEFAULT, 0 /*fFlags*/, &hChild), VINF_SUCCESS);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync RTTESTI_CHECK_RC_RETV(RTPipeClose(hPipeW), VINF_SUCCESS);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync RTTESTI_CHECK_RC(rc = RTPipeReadBlocking(hPipeR, szTmp, sizeof(szTmp) - 1, &cbRead), VINF_SUCCESS);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync RTTESTI_CHECK_RC(RTPipeReadBlocking(hPipeR, szTmp2, sizeof(szTmp2), &cbRead2), VERR_BROKEN_PIPE);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync RTTESTI_CHECK_RC(rc = RTPipeClose(hPipeR), VINF_SUCCESS);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync RTTESTI_CHECK_RC(RTProcTerminate(hChild), VINF_SUCCESS);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync RTTESTI_CHECK_RC(rc = RTProcWait(hChild, RTPROCWAIT_FLAGS_BLOCK, &ProcStatus), VINF_SUCCESS);
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync RTTESTI_CHECK( ProcStatus.enmReason == RTPROCEXITREASON_NORMAL
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync if (memcmp(szTmp, g_szTest4Message, sizeof(g_szTest4Message)))
33698994f509c2b3a92e81a828ee7a0e01b81de0vboxsync RTTestIFailed("Message mismatch.\n:Expected '%s'\nGot '%s'\n", g_szTest4Message, szTmp);
3ba795251a7b9f108fb01a3cfb37d763db9188b9vboxsyncstatic void tstRTPipe3(void)
3ba795251a7b9f108fb01a3cfb37d763db9188b9vboxsync RTTESTI_CHECK_RC_RETV(RTPipeCreate(&hPipeR, &hPipeW, 0), VINF_SUCCESS);
3ba795251a7b9f108fb01a3cfb37d763db9188b9vboxsync rc = RTPipeWrite(hPipeW, s_abBuf, sizeof(s_abBuf), &cbWritten);
5e08248e91d26e48931e78837c050a7210b10f52vboxsync RTTESTI_CHECK_MSG(rc == VINF_SUCCESS || rc == VINF_TRY_AGAIN, ("rc=%Rrc\n", rc));
3ba795251a7b9f108fb01a3cfb37d763db9188b9vboxsync RTTestIPrintf(RTTESTLVL_ALWAYS, "cbTotal=%zu (%#zx)\n", cbTotal, cbTotal);
3ba795251a7b9f108fb01a3cfb37d763db9188b9vboxsync RTTESTI_CHECK_RC(RTPipeSelectOne(hPipeW, 0), VERR_TIMEOUT);
3ba795251a7b9f108fb01a3cfb37d763db9188b9vboxsync RTTESTI_CHECK_RC(RTPipeSelectOne(hPipeW, 1), VERR_TIMEOUT);
3ba795251a7b9f108fb01a3cfb37d763db9188b9vboxsync RTTESTI_CHECK_RC(RTPipeRead(hPipeR, s_abBuf, RT_MIN(sizeof(s_abBuf), cbTotal) / 2, &cbRead), VINF_SUCCESS);
3ba795251a7b9f108fb01a3cfb37d763db9188b9vboxsync RTTESTI_CHECK_RC(RTPipeSelectOne(hPipeW, 0), VINF_SUCCESS);
3ba795251a7b9f108fb01a3cfb37d763db9188b9vboxsync RTTESTI_CHECK_RC(RTPipeSelectOne(hPipeW, 1), VINF_SUCCESS);
3ba795251a7b9f108fb01a3cfb37d763db9188b9vboxsync rc = RTPipeWrite(hPipeW, s_abBuf, sizeof(s_abBuf), &cbWritten);
3ba795251a7b9f108fb01a3cfb37d763db9188b9vboxsync RTTESTI_CHECK_RC(RTPipeClose(hPipeR), VINF_SUCCESS);
3ba795251a7b9f108fb01a3cfb37d763db9188b9vboxsync RTTESTI_CHECK_RC(RTPipeClose(hPipeW), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsyncstatic void tstRTPipe2(void)
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC(RTPipeCreate(&hPipeR, &hPipeW, ~0), VERR_INVALID_PARAMETER);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC(RTPipeCreate(NULL, &hPipeW, 0), VERR_INVALID_POINTER);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC(RTPipeCreate(&hPipeR, NULL, 0), VERR_INVALID_POINTER);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeCreate(&hPipeR, &hPipeW, 0), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC(RTPipeRead(hPipeW, abBuf, 0, &cbRead), VERR_ACCESS_DENIED);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC(RTPipeRead(hPipeW, abBuf, 1, &cbRead), VERR_ACCESS_DENIED);
b1d7d513c459787311cd09c440524044fa7ff8a9vboxsync RTTESTI_CHECK_RC(RTPipeReadBlocking(hPipeW, abBuf, 0, NULL), VERR_ACCESS_DENIED);
b1d7d513c459787311cd09c440524044fa7ff8a9vboxsync RTTESTI_CHECK_RC(RTPipeReadBlocking(hPipeW, abBuf, 1, NULL), VERR_ACCESS_DENIED);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC(RTPipeWrite(hPipeR, "asdf", 0, &cbWrite), VERR_ACCESS_DENIED);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC(RTPipeWrite(hPipeR, "asdf", 4, &cbWrite), VERR_ACCESS_DENIED);
b1d7d513c459787311cd09c440524044fa7ff8a9vboxsync RTTESTI_CHECK_RC(RTPipeWriteBlocking(hPipeR, "asdf", 0, NULL), VERR_ACCESS_DENIED);
b1d7d513c459787311cd09c440524044fa7ff8a9vboxsync RTTESTI_CHECK_RC(RTPipeWriteBlocking(hPipeR, "asdf", 4, NULL), VERR_ACCESS_DENIED);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC(RTPipeFlush(hPipeR), VERR_ACCESS_DENIED);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC(RTPipeClose(hPipeR), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC(RTPipeClose(hPipeW), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsyncstatic void tstRTPipe1(void)
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeCreate(&hPipeR, &hPipeW, 0), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeClose(hPipeR), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeClose(hPipeW), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeClose(NIL_RTPIPE), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeCreate(&hPipeR, &hPipeW, RTPIPE_C_INHERIT_READ | RTPIPE_C_INHERIT_WRITE), VINF_SUCCESS);
45c4c3d2db1a166b7b1e92960adb823960821386vboxsync RTTESTI_CHECK_MSG(rc == VERR_NOT_SUPPORTED || rc == VINF_SUCCESS, ("%Rrc\n", rc));
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeClose(hPipeR), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeClose(hPipeW), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeCreate(&hPipeR, &hPipeW, RTPIPE_C_INHERIT_READ), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeSelectOne(hPipeR, 0), VERR_TIMEOUT);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeSelectOne(hPipeR, 1), VERR_TIMEOUT);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeSelectOne(hPipeW, 0), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeSelectOne(hPipeW, 1), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeClose(hPipeR), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeClose(hPipeW), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeCreate(&hPipeR, &hPipeW, RTPIPE_C_INHERIT_WRITE), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeClose(hPipeR), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeClose(hPipeW), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeCreate(&hPipeR, &hPipeW, RTPIPE_C_INHERIT_READ), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeRead(hPipeR, abBuf, sizeof(abBuf), &cbRead), VINF_TRY_AGAIN);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeRead(hPipeR, abBuf, 1, &cbRead), VINF_TRY_AGAIN);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeRead(hPipeR, abBuf, 0, &cbRead), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeWrite(hPipeW, abBuf, 0, &cbWritten), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync /* We can write a number of bytes without blocking (see PIPE_BUF on
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync POSIX systems). */
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeWrite(hPipeW, "42", 2, &cbWritten), VINF_SUCCESS);
bd51228d218e2f43d2d5d7f0559901dfaac31c9cvboxsync RTTESTI_CHECK_MSG_RETV(cbWritten == 2, ("cbWritten=%zu\n", cbWritten));
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeWrite(hPipeW, "!", 1, &cbWritten), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeRead(hPipeR, abBuf, 3, &cbRead), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeWrite(hPipeW, "BigQ", 4, &cbWritten), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeSelectOne(hPipeR, 0), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeSelectOne(hPipeR, 1), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeRead(hPipeR, abBuf, sizeof(abBuf), &cbRead), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeWrite(hPipeW, "H2G2", 4, &cbWritten), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeRead(hPipeR, &abBuf[0], 1, &cbRead), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeRead(hPipeR, &abBuf[1], 1, &cbRead), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeRead(hPipeR, &abBuf[2], 1, &cbRead), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeRead(hPipeR, &abBuf[3], 1, &cbRead), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeClose(hPipeR), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeClose(hPipeW), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeCreate(&hPipeR, &hPipeW, 0), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeClose(hPipeR), VINF_SUCCESS);
45c4c3d2db1a166b7b1e92960adb823960821386vboxsync RTTESTI_CHECK_RC(RTPipeWrite(hPipeW, "", 0, &cbWritten), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC(RTPipeWrite(hPipeW, "4", 1, &cbWritten), VERR_BROKEN_PIPE);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC(RTPipeClose(hPipeW), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeCreate(&hPipeR, &hPipeW, 0), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeClose(hPipeW), VINF_SUCCESS);
45c4c3d2db1a166b7b1e92960adb823960821386vboxsync RTTESTI_CHECK_RC(RTPipeRead(hPipeR, abBuf, 0, &cbRead), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC(RTPipeRead(hPipeR, abBuf, sizeof(abBuf), &cbRead), VERR_BROKEN_PIPE);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC(RTPipeClose(hPipeR), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeCreate(&hPipeR, &hPipeW, 0), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC(RTPipeWrite(hPipeW, "42", 2, &cbWritten), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeClose(hPipeW), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeRead(hPipeR, abBuf, 0, &cbRead), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC(RTPipeRead(hPipeR, &abBuf[0], 1, &cbRead), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC(RTPipeRead(hPipeR, &abBuf[1], 1, &cbRead), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC(RTPipeRead(hPipeR, abBuf, 0, &cbRead), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeRead(hPipeR, abBuf, sizeof(abBuf), &cbRead), VERR_BROKEN_PIPE);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC(RTPipeClose(hPipeR), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeCreate(&hPipeR, &hPipeW, 0), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeWrite(hPipeW, "42!", 3, &cbWritten), VINF_SUCCESS);
b1d7d513c459787311cd09c440524044fa7ff8a9vboxsync RTTESTI_CHECK_RC_RETV(RTPipeReadBlocking(hPipeR, abBuf, 3, NULL), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC(RTPipeClose(hPipeW), VINF_SUCCESS);
b1d7d513c459787311cd09c440524044fa7ff8a9vboxsync RTTESTI_CHECK_RC_RETV(RTPipeReadBlocking(hPipeR, &abBuf[0], 0, NULL), VINF_SUCCESS);
b1d7d513c459787311cd09c440524044fa7ff8a9vboxsync RTTESTI_CHECK_RC_RETV(RTPipeReadBlocking(hPipeR, &abBuf[0], 0, &cbRead), VINF_SUCCESS);
b1d7d513c459787311cd09c440524044fa7ff8a9vboxsync RTTESTI_CHECK_RC_RETV(RTPipeReadBlocking(hPipeR, &abBuf[0], 1, NULL), VERR_BROKEN_PIPE);
b1d7d513c459787311cd09c440524044fa7ff8a9vboxsync RTTESTI_CHECK_RC_RETV(RTPipeReadBlocking(hPipeR, &abBuf[0], 1, &cbRead), VERR_BROKEN_PIPE);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC(RTPipeClose(hPipeR), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeCreate(&hPipeR, &hPipeW, 0), VINF_SUCCESS);
b1d7d513c459787311cd09c440524044fa7ff8a9vboxsync RTTESTI_CHECK_RC_RETV(RTPipeWriteBlocking(hPipeW, "42!", 3, NULL), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC_RETV(RTPipeRead(hPipeR, &abBuf[0], 1, &cbRead), VINF_SUCCESS);
b1d7d513c459787311cd09c440524044fa7ff8a9vboxsync RTTESTI_CHECK_RC_RETV(RTPipeReadBlocking(hPipeR, &abBuf[1], 1, NULL), VINF_SUCCESS);
b1d7d513c459787311cd09c440524044fa7ff8a9vboxsync RTTESTI_CHECK_RC_RETV(RTPipeReadBlocking(hPipeR, &abBuf[2], 1, NULL), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC(RTPipeClose(hPipeR), VINF_SUCCESS);
b1d7d513c459787311cd09c440524044fa7ff8a9vboxsync RTTESTI_CHECK_RC_RETV(RTPipeWriteBlocking(hPipeW, "", 0, NULL), VINF_SUCCESS);
b1d7d513c459787311cd09c440524044fa7ff8a9vboxsync RTTESTI_CHECK_RC_RETV(RTPipeWriteBlocking(hPipeW, "", 0, &cbWritten), VINF_SUCCESS);
b1d7d513c459787311cd09c440524044fa7ff8a9vboxsync RTTESTI_CHECK_RC_RETV(RTPipeWriteBlocking(hPipeW, "42", 2, NULL), VERR_BROKEN_PIPE);
b1d7d513c459787311cd09c440524044fa7ff8a9vboxsync RTTESTI_CHECK_RC_RETV(RTPipeWriteBlocking(hPipeW, "42", 2, &cbWritten), VERR_BROKEN_PIPE);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync RTTESTI_CHECK_RC(RTPipeClose(hPipeW), VINF_SUCCESS);
b41f65ee355ae1d4b24473c6d6d70c653497429avboxsync * The tests.