proxygen
|
#include <folly/io/async/test/AsyncSocketTest2.h>
#include <folly/ExceptionWrapper.h>
#include <folly/Random.h>
#include <folly/SocketAddress.h>
#include <folly/io/async/AsyncSocket.h>
#include <folly/io/async/AsyncTimeout.h>
#include <folly/io/async/EventBase.h>
#include <folly/io/async/ScopedEventBaseThread.h>
#include <folly/experimental/TestUtil.h>
#include <folly/io/IOBuf.h>
#include <folly/io/async/test/AsyncSocketTest.h>
#include <folly/io/async/test/Util.h>
#include <folly/portability/GMock.h>
#include <folly/portability/GTest.h>
#include <folly/portability/Sockets.h>
#include <folly/portability/Unistd.h>
#include <folly/synchronization/Baton.h>
#include <folly/test/SocketAddressTestHelper.h>
#include <fcntl.h>
#include <sys/types.h>
#include <iostream>
#include <memory>
#include <thread>
Go to the source code of this file.
Classes | |
class | DelayedWrite |
class | AsyncSocketConnectTest |
class | AsyncSocketImmediateRead |
class | MockEvbChangeCallback |
Enumerations | |
enum | TFOState { TFOState::DISABLED, TFOState::ENABLED } |
Functions | |
TEST (AsyncSocketTest, Connect) | |
std::vector< TFOState > | getTestingValues () |
INSTANTIATE_TEST_CASE_P (ConnectTests, AsyncSocketConnectTest,::testing::ValuesIn(getTestingValues())) | |
TEST (AsyncSocketTest, ConnectRefused) | |
TEST (AsyncSocketTest, ConnectTimeout) | |
TEST_P (AsyncSocketConnectTest, ConnectAndWrite) | |
TEST_P (AsyncSocketConnectTest, ConnectNullCallback) | |
TEST_P (AsyncSocketConnectTest, ConnectWriteAndClose) | |
TEST (AsyncSocketTest, ConnectAndClose) | |
TEST (AsyncSocketTest, ConnectAndCloseNow) | |
TEST (AsyncSocketTest, ConnectWriteAndCloseNow) | |
TEST_P (AsyncSocketConnectTest, ConnectAndRead) | |
TEST (AsyncSocketTest, ConnectReadAndClose) | |
TEST_P (AsyncSocketConnectTest, ConnectWriteAndRead) | |
TEST (AsyncSocketTest, ConnectWriteAndShutdownWrite) | |
TEST (AsyncSocketTest, ConnectReadWriteAndShutdownWrite) | |
TEST (AsyncSocketTest, ConnectReadWriteAndShutdownWriteNow) | |
void | tmpDisableReads (AsyncSocket *socket, ReadCallback *rcb) |
void | testConnectOptWrite (size_t size1, size_t size2, bool close=false) |
TEST (AsyncSocketTest, ConnectCallbackWrite) | |
TEST (AsyncSocketTest, WriteNullCallback) | |
TEST (AsyncSocketTest, WriteTimeout) | |
TEST (AsyncSocketTest, WritePipeError) | |
TEST (AsyncSocketTest, WriteAfterReadEOF) | |
TEST (AsyncSocketTest, WriteErrorCallbackBytesWritten) | |
TEST (AsyncSocketTest, WriteIOBuf) | |
TEST (AsyncSocketTest, WriteIOBufCorked) | |
TEST (AsyncSocketTest, ZeroLengthWrite) | |
TEST (AsyncSocketTest, ZeroLengthWritev) | |
TEST (AsyncSocketTest, ClosePendingWritesWhileClosing) | |
TEST (AsyncSocket, ConnectReadImmediateRead) | |
TEST (AsyncSocket, ConnectReadUninstallRead) | |
TEST (AsyncSocketTest, ServerAcceptOptions) | |
TEST (AsyncSocketTest, RemoveAcceptCallback) | |
TEST (AsyncSocketTest, OtherThreadAcceptCallback) | |
void | serverSocketSanityTest (AsyncServerSocket *serverSocket) |
TEST (AsyncSocketTest, DestroyCloseTest) | |
TEST (AsyncSocketTest, ServerExistingSocket) | |
TEST (AsyncSocketTest, UnixDomainSocketTest) | |
TEST (AsyncSocketTest, ConnectionEventCallbackDefault) | |
TEST (AsyncSocketTest, CallbackInPrimaryEventBase) | |
TEST (AsyncSocketTest, CallbackInSecondaryEventBase) | |
TEST (AsyncSocketTest, NumPendingMessagesInQueue) | |
TEST (AsyncSocketTest, BufferTest) | |
TEST (AsyncSocketTest, BufferCallbackKill) | |
TEST (AsyncSocketTest, EvbCallbacks) | |
TEST (AsyncSocketTest, TestEvbDetachWtRegisteredIOHandlers) | |
TEST (AsyncSocket, PreReceivedData) | |
TEST (AsyncSocket, PreReceivedDataOnly) | |
TEST (AsyncSocket, PreReceivedDataPartial) | |
TEST (AsyncSocket, PreReceivedDataTakeover) | |
|
strong |
Enumerator | |
---|---|
DISABLED | |
ENABLED |
Definition at line 118 of file AsyncSocketTest2.cpp.
std::vector<TFOState> getTestingValues | ( | ) |
Definition at line 125 of file AsyncSocketTest2.cpp.
References DISABLED, ENABLED, and INSTANTIATE_TEST_CASE_P().
INSTANTIATE_TEST_CASE_P | ( | ConnectTests | , |
AsyncSocketConnectTest | , | ||
::testing::ValuesIn(getTestingValues()) | |||
) |
Referenced by getTestingValues().
void serverSocketSanityTest | ( | AsyncServerSocket * | serverSocket | ) |
Definition at line 1911 of file AsyncSocketTest2.cpp.
References folly::AsyncServerSocket::addAcceptCallback(), ASSERT_EQ, folly::AsyncServerSocket::getAddress(), folly::AsyncServerSocket::getEventBase(), folly::test::TestAcceptCallback::getEvents(), folly::EventBase::loop(), folly::AsyncServerSocket::removeAcceptCallback(), folly::test::TestAcceptCallback::setAcceptErrorFn(), folly::test::TestAcceptCallback::setConnectionAcceptedFn(), folly::netops::socket(), folly::AsyncServerSocket::startAccepting(), folly::test::TestAcceptCallback::TYPE_ACCEPT, folly::test::TestAcceptCallback::TYPE_START, and folly::test::TestAcceptCallback::TYPE_STOP.
Referenced by TEST().
TEST | ( | AsyncSocketTest | , |
Connect | |||
) |
Test connecting to a server
Definition at line 96 of file AsyncSocketTest2.cpp.
References ASSERT_EQ, EXPECT_EQ, EXPECT_GE, EXPECT_LE, TestServer::getAddress(), folly::EventBase::loop(), folly::AsyncSocket::newSocket(), now(), folly::netops::socket(), ConnCallback::state, and folly::STATE_SUCCEEDED.
TEST | ( | AsyncSocketTest | , |
ConnectRefused | |||
) |
Test connecting to a server that isn't listening
Definition at line 143 of file AsyncSocketTest2.cpp.
References addr, ConnCallback::exception, EXPECT_EQ, EXPECT_LE, folly::AsyncSocketException::getType(), folly::EventBase::loop(), folly::AsyncSocket::newSocket(), folly::AsyncSocketException::NOT_OPEN, folly::netops::socket(), ConnCallback::state, and folly::STATE_FAILED.
TEST | ( | AsyncSocketTest | , |
ConnectTimeout | |||
) |
Test connection timeout
Definition at line 164 of file AsyncSocketTest2.cpp.
References addr, ASSERT_EQ, ConnCallback::exception, EXPECT_EQ, EXPECT_LE, folly::AsyncSocketException::getType(), folly::SocketAddressTestHelper::isIPv4Enabled(), folly::SocketAddressTestHelper::isIPv6Enabled(), folly::SocketAddressTestHelper::kGooglePublicDnsAAddrIPv4, folly::SocketAddressTestHelper::kGooglePublicDnsAAddrIPv6, folly::EventBase::loop(), folly::AsyncSocket::newSocket(), folly::AsyncSocketException::NOT_OPEN, SKIP, folly::netops::socket(), ConnCallback::state, folly::STATE_FAILED, and folly::AsyncSocketException::TIMED_OUT.
TEST | ( | AsyncSocketTest | , |
ConnectAndClose | |||
) |
Test calling close() immediately after connect()
Definition at line 323 of file AsyncSocketTest2.cpp.
References ASSERT_EQ, ASSERT_FALSE, ASSERT_TRUE, TestServer::getAddress(), folly::INFO, folly::EventBase::loop(), folly::AsyncSocket::newSocket(), folly::netops::socket(), ConnCallback::state, folly::STATE_FAILED, and folly::STATE_SUCCEEDED.
TEST | ( | AsyncSocketTest | , |
ConnectAndCloseNow | |||
) |
Test calling closeNow() immediately after connect()
This should be identical to the normal close behavior.
Definition at line 357 of file AsyncSocketTest2.cpp.
References ASSERT_EQ, ASSERT_FALSE, ASSERT_TRUE, TestServer::getAddress(), folly::INFO, folly::EventBase::loop(), folly::AsyncSocket::newSocket(), folly::netops::socket(), ConnCallback::state, folly::STATE_FAILED, and folly::STATE_SUCCEEDED.
TEST | ( | AsyncSocketTest | , |
ConnectWriteAndCloseNow | |||
) |
Test calling both write() and closeNow() immediately after connecting, without waiting for connect to finish.
This should abort the pending write.
Definition at line 392 of file AsyncSocketTest2.cpp.
References ASSERT_EQ, ASSERT_FALSE, ASSERT_TRUE, TestServer::getAddress(), folly::INFO, folly::EventBase::loop(), folly::AsyncSocket::newSocket(), folly::netops::socket(), ConnCallback::state, WriteCallback::state, folly::STATE_FAILED, and folly::STATE_SUCCEEDED.
TEST | ( | AsyncSocketTest | , |
ConnectReadAndClose | |||
) |
Test installing a read callback and then closing immediately before the connect attempt finishes.
Definition at line 477 of file AsyncSocketTest2.cpp.
References ASSERT_EQ, ASSERT_FALSE, ASSERT_TRUE, folly::ReadCallback::buffers, TestServer::getAddress(), folly::INFO, folly::EventBase::loop(), folly::AsyncSocket::newSocket(), folly::netops::socket(), ConnCallback::state, folly::ReadCallbackBase::state, folly::STATE_FAILED, and folly::STATE_SUCCEEDED.
TEST | ( | AsyncSocketTest | , |
ConnectWriteAndShutdownWrite | |||
) |
Test writing to the socket then shutting down writes before the connect attempt finishes.
Definition at line 579 of file AsyncSocketTest2.cpp.
References TestServer::accept(), ASSERT_EQ, ASSERT_FALSE, folly::ReadCallback::buffers, TestServer::getAddress(), folly::INFO, folly::EventBase::loop(), folly::AsyncSocket::newSocket(), folly::netops::poll(), folly::netops::socket(), ConnCallback::state, WriteCallback::state, folly::ReadCallbackBase::state, folly::STATE_SUCCEEDED, uint32_t, and uint8_t.
TEST | ( | AsyncSocketTest | , |
ConnectReadWriteAndShutdownWrite | |||
) |
Test reading, writing, and shutting down writes before the connect attempt finishes.
Definition at line 667 of file AsyncSocketTest2.cpp.
References TestServer::accept(), ASSERT_EQ, ASSERT_FALSE, ASSERT_TRUE, folly::ReadCallback::buffers, TestServer::getAddress(), folly::INFO, folly::EventBase::loop(), folly::AsyncSocket::newSocket(), folly::netops::poll(), folly::shutdown(), folly::netops::socket(), ConnCallback::state, WriteCallback::state, folly::ReadCallbackBase::state, folly::STATE_SUCCEEDED, uint32_t, and uint8_t.
TEST | ( | AsyncSocketTest | , |
ConnectReadWriteAndShutdownWriteNow | |||
) |
Test reading, writing, and calling shutdownWriteNow() before the connect attempt finishes.
Definition at line 755 of file AsyncSocketTest2.cpp.
References TestServer::accept(), ASSERT_EQ, ASSERT_FALSE, ASSERT_TRUE, folly::ReadCallback::buffers, WriteCallback::bytesWritten, TestServer::getAddress(), folly::INFO, folly::EventBase::loop(), folly::AsyncSocket::newSocket(), folly::netops::poll(), folly::shutdown(), folly::netops::socket(), ConnCallback::state, WriteCallback::state, folly::ReadCallbackBase::state, folly::STATE_FAILED, folly::STATE_SUCCEEDED, uint32_t, and uint8_t.
TEST | ( | AsyncSocketTest | , |
ConnectCallbackWrite | |||
) |
Definition at line 954 of file AsyncSocketTest2.cpp.
References testConnectOptWrite().
TEST | ( | AsyncSocketTest | , |
WriteNullCallback | |||
) |
Test writing using a nullptr callback
Definition at line 992 of file AsyncSocketTest2.cpp.
References ASSERT_FALSE, ASSERT_TRUE, TestServer::getAddress(), folly::EventBase::loop(), folly::AsyncSocket::newSocket(), folly::netops::socket(), and TestServer::verifyConnection().
TEST | ( | AsyncSocketTest | , |
WriteTimeout | |||
) |
Test writing with a send timeout
Definition at line 1019 of file AsyncSocketTest2.cpp.
References ASSERT_EQ, folly::test::end(), TestServer::getAddress(), folly::EventBase::loop(), folly::AsyncSocket::newSocket(), folly::netops::socket(), start, folly::STATE_FAILED, T_CHECK_TIMEOUT, folly::AsyncSocketException::TIMED_OUT, folly::detail::timeout, and uint32_t.
TEST | ( | AsyncSocketTest | , |
WritePipeError | |||
) |
Test writing to a socket that the remote endpoint has closed
Definition at line 1075 of file AsyncSocketTest2.cpp.
References TestServer::accept(), ASSERT_EQ, ASSERT_FALSE, TestServer::getAddress(), folly::AsyncSocketException::INTERNAL_ERROR, folly::EventBase::loop(), folly::AsyncSocket::newSocket(), folly::netops::socket(), and folly::STATE_FAILED.
TEST | ( | AsyncSocketTest | , |
WriteAfterReadEOF | |||
) |
Test writing to a socket that has its read side closed
Definition at line 1111 of file AsyncSocketTest2.cpp.
References TestServer::acceptAsync(), ASSERT_EQ, ASSERT_FALSE, ASSERT_TRUE, TestServer::getAddress(), folly::EventBase::loop(), folly::AsyncSocket::newSocket(), folly::netops::socket(), WriteCallback::state, folly::ReadCallbackBase::state, and folly::STATE_SUCCEEDED.
TEST | ( | AsyncSocketTest | , |
WriteErrorCallbackBytesWritten | |||
) |
Test that bytes written is correctly computed in case of write failure
Definition at line 1149 of file AsyncSocketTest2.cpp.
References TestServer::accept(), ASSERT_EQ, ASSERT_GE, ASSERT_LE, EXPECT_EQ, TestServer::getAddress(), folly::EventBase::loopForever(), folly::AsyncSocket::newSocket(), now(), folly::EventBase::runInEventBaseThreadAndWait(), folly::netops::socket(), folly::STATE_FAILED, folly::EventBase::terminateLoopSoon(), uint8_t, and folly::fibers::yield().
TEST | ( | AsyncSocketTest | , |
WriteIOBuf | |||
) |
Test writing a mix of simple buffers and IOBufs
Definition at line 1230 of file AsyncSocketTest2.cpp.
References TestServer::acceptAsync(), folly::IOBuf::append(), folly::IOBuf::appendChain(), ASSERT_EQ, ASSERT_FALSE, ASSERT_TRUE, folly::ReadCallback::buffers, folly::IOBuf::clone(), folly::IOBuf::create(), EXPECT_FALSE, EXPECT_TRUE, TestServer::getAddress(), folly::EventBase::loop(), folly::gen::move, folly::AsyncSocket::newSocket(), folly::netops::socket(), WriteCallback::state, folly::ReadCallbackBase::state, folly::STATE_SUCCEEDED, and folly::IOBuf::writableData().
TEST | ( | AsyncSocketTest | , |
WriteIOBufCorked | |||
) |
Definition at line 1317 of file AsyncSocketTest2.cpp.
References TestServer::acceptAsync(), folly::IOBuf::append(), ASSERT_EQ, ASSERT_FALSE, ASSERT_TRUE, folly::ReadCallback::buffers, folly::IOBuf::create(), WriteCallback::exception, TestServer::getAddress(), folly::EventBase::loop(), folly::gen::move, folly::AsyncSocket::newSocket(), folly::AsyncTimeout::scheduleTimeout(), folly::netops::socket(), ConnCallback::state, WriteCallback::state, folly::ReadCallbackBase::state, folly::STATE_SUCCEEDED, and folly::IOBuf::writableData().
TEST | ( | AsyncSocketTest | , |
ZeroLengthWrite | |||
) |
Test performing a zero-length write
Definition at line 1381 of file AsyncSocketTest2.cpp.
References TestServer::acceptAsync(), ASSERT_EQ, ASSERT_FALSE, ASSERT_TRUE, TestServer::getAddress(), folly::EventBase::loop(), folly::AsyncSocket::newSocket(), folly::netops::socket(), WriteCallback::state, and folly::STATE_SUCCEEDED.
TEST | ( | AsyncSocketTest | , |
ZeroLengthWritev | |||
) |
Definition at line 1422 of file AsyncSocketTest2.cpp.
References TestServer::acceptAsync(), ASSERT_EQ, ASSERT_FALSE, ASSERT_TRUE, TestServer::getAddress(), folly::EventBase::loop(), folly::AsyncSocket::newSocket(), folly::netops::socket(), and folly::STATE_SUCCEEDED.
TEST | ( | AsyncSocketTest | , |
ClosePendingWritesWhileClosing | |||
) |
Test calling close() with pending writes when the socket is already closing.
Definition at line 1471 of file AsyncSocketTest2.cpp.
References TestServer::accept(), ASSERT_EQ, ASSERT_FALSE, ASSERT_TRUE, folly::netops::bind(), folly::AsyncSocket::close(), TestServer::getAddress(), folly::EventBase::loop(), folly::AsyncSocket::newSocket(), folly::netops::socket(), ConnCallback::state, folly::STATE_FAILED, and folly::STATE_SUCCEEDED.
TEST | ( | AsyncSocket | , |
ConnectReadImmediateRead | |||
) |
Definition at line 1542 of file AsyncSocketTest2.cpp.
References TestServer::acceptAsync(), ASSERT_EQ, ASSERT_FALSE, folly::AsyncSocket::connect(), TestServer::getAddress(), AsyncSocketImmediateRead::immediateReadCalled, folly::AsyncSocket::isClosedByPeer(), folly::AsyncSocket::isClosedBySelf(), folly::EventBase::loop(), folly::AsyncSocket::setMaxReadsPerEvent(), folly::AsyncSocket::setReadCB(), folly::netops::socket(), WriteCallback::state, folly::STATE_SUCCEEDED, and folly::AsyncSocket::write().
TEST | ( | AsyncSocket | , |
ConnectReadUninstallRead | |||
) |
Definition at line 1588 of file AsyncSocketTest2.cpp.
References TestServer::acceptAsync(), ASSERT_EQ, ASSERT_FALSE, folly::AsyncSocket::connect(), TestServer::getAddress(), AsyncSocketImmediateRead::immediateReadCalled, folly::AsyncSocket::isClosedByPeer(), folly::AsyncSocket::isClosedBySelf(), folly::EventBase::loop(), folly::AsyncSocket::setMaxReadsPerEvent(), folly::AsyncSocket::setReadCB(), folly::netops::socket(), WriteCallback::state, folly::STATE_SUCCEEDED, and folly::AsyncSocket::write().
TEST | ( | AsyncSocketTest | , |
ServerAcceptOptions | |||
) |
Make sure accepted sockets have O_NONBLOCK and TCP_NODELAY set
Definition at line 1661 of file AsyncSocketTest2.cpp.
References ASSERT_EQ, folly::SocketAddress::getAddress(), folly::test::TestAcceptCallback::getEvents(), folly::netops::getsockopt(), folly::EventBase::loop(), folly::AsyncServerSocket::newSocket(), folly::AsyncSocket::newSocket(), folly::test::TestAcceptCallback::setAcceptErrorFn(), folly::test::TestAcceptCallback::setConnectionAcceptedFn(), folly::netops::socket(), folly::test::TestAcceptCallback::TYPE_ACCEPT, folly::test::TestAcceptCallback::TYPE_START, folly::test::TestAcceptCallback::TYPE_STOP, and folly::value().
TEST | ( | AsyncSocketTest | , |
RemoveAcceptCallback | |||
) |
Test AsyncServerSocket::removeAcceptCallback()
Definition at line 1717 of file AsyncSocketTest2.cpp.
References ASSERT_EQ, folly::SocketAddress::getAddress(), folly::test::TestAcceptCallback::getEvents(), folly::EventBase::loop(), folly::AsyncServerSocket::newSocket(), folly::AsyncSocket::newSocket(), folly::test::TestAcceptCallback::setConnectionAcceptedFn(), folly::test::TestAcceptCallback::TYPE_ACCEPT, folly::test::TestAcceptCallback::TYPE_START, and folly::test::TestAcceptCallback::TYPE_STOP.
TEST | ( | AsyncSocketTest | , |
OtherThreadAcceptCallback | |||
) |
Test AsyncServerSocket::removeAcceptCallback()
Definition at line 1859 of file AsyncSocketTest2.cpp.
References ASSERT_EQ, folly::SocketAddress::getAddress(), folly::test::TestAcceptCallback::getEvents(), folly::EventBase::loop(), folly::AsyncServerSocket::newSocket(), folly::AsyncSocket::newSocket(), folly::test::TestAcceptCallback::setAcceptStartedFn(), folly::test::TestAcceptCallback::setAcceptStoppedFn(), folly::test::TestAcceptCallback::setConnectionAcceptedFn(), folly::test::TestAcceptCallback::TYPE_ACCEPT, folly::test::TestAcceptCallback::TYPE_START, and folly::test::TestAcceptCallback::TYPE_STOP.
TEST | ( | AsyncSocketTest | , |
DestroyCloseTest | |||
) |
Definition at line 1952 of file AsyncSocketTest2.cpp.
References TestServer::acceptAsync(), ASSERT_EQ, TestServer::getAddress(), folly::test::msvcSuppressAbortOnInvalidParams(), folly::AsyncSocket::newSocket(), fizz::detail::read(), and folly::netops::socket().
TEST | ( | AsyncSocketTest | , |
ServerExistingSocket | |||
) |
Test AsyncServerSocket::useExistingSocket()
Definition at line 1992 of file AsyncSocketTest2.cpp.
References ASSERT_EQ, ASSERT_GE, folly::netops::bind(), folly::SocketAddress::getAddress(), folly::netops::listen(), serverSocketSanityTest(), folly::SocketAddress::setFromLocalAddress(), folly::SocketAddress::setPort(), and folly::netops::socket().
TEST | ( | AsyncSocketTest | , |
UnixDomainSocketTest | |||
) |
Definition at line 2081 of file AsyncSocketTest2.cpp.
References ASSERT_EQ, folly::test::TestAcceptCallback::getEvents(), folly::EventBase::loop(), folly::AsyncServerSocket::newSocket(), folly::AsyncSocket::newSocket(), folly::Random::rand64(), folly::test::TestAcceptCallback::setAcceptErrorFn(), folly::test::TestAcceptCallback::setConnectionAcceptedFn(), folly::SocketAddress::setFromPath(), folly::netops::socket(), folly::test::TestAcceptCallback::TYPE_ACCEPT, folly::test::TestAcceptCallback::TYPE_START, and folly::test::TestAcceptCallback::TYPE_STOP.
TEST | ( | AsyncSocketTest | , |
ConnectionEventCallbackDefault | |||
) |
Definition at line 2127 of file AsyncSocketTest2.cpp.
References ASSERT_EQ, folly::SocketAddress::getAddress(), folly::test::TestConnectionEventCallback::getBackoffEnded(), folly::test::TestConnectionEventCallback::getBackoffError(), folly::test::TestConnectionEventCallback::getBackoffStarted(), folly::test::TestConnectionEventCallback::getConnectionAccepted(), folly::test::TestConnectionEventCallback::getConnectionAcceptedError(), folly::test::TestConnectionEventCallback::getConnectionDequeuedByAcceptCallback(), folly::test::TestConnectionEventCallback::getConnectionDropped(), folly::test::TestConnectionEventCallback::getConnectionEnqueuedForAcceptCallback(), folly::EventBase::loop(), folly::AsyncServerSocket::newSocket(), folly::AsyncSocket::newSocket(), folly::test::TestAcceptCallback::setAcceptErrorFn(), folly::test::TestAcceptCallback::setConnectionAcceptedFn(), and folly::netops::socket().
TEST | ( | AsyncSocketTest | , |
CallbackInPrimaryEventBase | |||
) |
Definition at line 2170 of file AsyncSocketTest2.cpp.
References ASSERT_EQ, ASSERT_TRUE, folly::SocketAddress::getAddress(), folly::test::TestConnectionEventCallback::getBackoffEnded(), folly::test::TestConnectionEventCallback::getBackoffError(), folly::test::TestConnectionEventCallback::getBackoffStarted(), folly::test::TestConnectionEventCallback::getConnectionAccepted(), folly::test::TestConnectionEventCallback::getConnectionAcceptedError(), folly::test::TestConnectionEventCallback::getConnectionDequeuedByAcceptCallback(), folly::test::TestConnectionEventCallback::getConnectionDropped(), folly::test::TestConnectionEventCallback::getConnectionEnqueuedForAcceptCallback(), folly::EventBase::loop(), folly::AsyncServerSocket::newSocket(), folly::AsyncSocket::newSocket(), folly::test::TestAcceptCallback::setAcceptErrorFn(), folly::test::TestAcceptCallback::setAcceptStartedFn(), folly::test::TestAcceptCallback::setAcceptStoppedFn(), folly::test::TestAcceptCallback::setConnectionAcceptedFn(), and folly::netops::socket().
TEST | ( | AsyncSocketTest | , |
CallbackInSecondaryEventBase | |||
) |
Definition at line 2221 of file AsyncSocketTest2.cpp.
References ASSERT_EQ, ASSERT_TRUE, folly::SocketAddress::getAddress(), folly::test::TestConnectionEventCallback::getBackoffEnded(), folly::test::TestConnectionEventCallback::getBackoffError(), folly::test::TestConnectionEventCallback::getBackoffStarted(), folly::test::TestConnectionEventCallback::getConnectionAccepted(), folly::test::TestConnectionEventCallback::getConnectionAcceptedError(), folly::test::TestConnectionEventCallback::getConnectionDequeuedByAcceptCallback(), folly::test::TestConnectionEventCallback::getConnectionDropped(), folly::test::TestConnectionEventCallback::getConnectionEnqueuedForAcceptCallback(), folly::ScopedEventBaseThread::getEventBase(), folly::EventBase::loop(), folly::AsyncServerSocket::newSocket(), folly::AsyncSocket::newSocket(), folly::Baton< MayBlock, Atom >::post(), folly::EventBase::runInEventBaseThread(), folly::test::TestAcceptCallback::setAcceptErrorFn(), folly::test::TestAcceptCallback::setAcceptStartedFn(), folly::test::TestAcceptCallback::setAcceptStoppedFn(), folly::test::TestAcceptCallback::setConnectionAcceptedFn(), folly::netops::socket(), and folly::Baton< MayBlock, Atom >::try_wait_for().
TEST | ( | AsyncSocketTest | , |
NumPendingMessagesInQueue | |||
) |
Test AsyncServerSocket::getNumPendingMessagesInQueue()
Definition at line 2277 of file AsyncSocketTest2.cpp.
References ASSERT_EQ, count, folly::SocketAddress::getAddress(), folly::ScopedEventBaseThread::getEventBase(), folly::EventBase::loop(), folly::AsyncServerSocket::newSocket(), folly::AsyncSocket::newSocket(), folly::EventBase::runInEventBaseThread(), folly::EventBase::runInEventBaseThreadAndWait(), folly::test::TestAcceptCallback::setAcceptErrorFn(), and folly::test::TestAcceptCallback::setConnectionAcceptedFn().
TEST | ( | AsyncSocketTest | , |
BufferTest | |||
) |
Test AsyncTransport::BufferCallback
Definition at line 2325 of file AsyncSocketTest2.cpp.
References ASSERT_EQ, ASSERT_FALSE, ASSERT_TRUE, TestServer::getAddress(), BufferCallback::hasBufferCleared(), BufferCallback::hasBuffered(), folly::EventBase::loop(), folly::AsyncSocket::newSocket(), folly::NONE, option(), folly::netops::socket(), ConnCallback::state, WriteCallback::state, folly::STATE_SUCCEEDED, and TestServer::verifyConnection().
TEST | ( | AsyncSocketTest | , |
BufferCallbackKill | |||
) |
Definition at line 2355 of file AsyncSocketTest2.cpp.
References testing::_, TestServer::accept(), addr, ASSERT_EQ, ASSERT_FALSE, ASSERT_TRUE, folly::ReadCallback::buffers, folly::netops::connect(), folly::IOBuf::copyBuffer(), folly::IOBuf::create(), EXPECT_CALL, EXPECT_EQ, EXPECT_FALSE, EXPECT_LE, EXPECT_TRUE, TestServer::getAddress(), folly::SocketAddress::getAddress(), folly::INFO, testing::Invoke(), folly::SocketAddressTestHelper::isIPv4Enabled(), folly::SocketAddressTestHelper::isIPv6Enabled(), folly::SocketAddressTestHelper::kGooglePublicDnsAAddrIPv4, folly::SocketAddressTestHelper::kGooglePublicDnsAAddrIPv6, folly::EventBase::loop(), folly::EventBase::loopOnce(), MOCK_METHOD3, folly::AsyncSocket::newSocket(), folly::NONE, option(), fizz::detail::readBuf(), testing::SetErrnoAndReturn(), folly::netops::socket(), ConnCallback::state, WriteCallback::state, folly::ReadCallbackBase::state, folly::STATE_FAILED, folly::STATE_SUCCEEDED, folly::STATE_WAITING, WriteCallback::successCallback, folly::pushmi::detail::t, folly::test::TEST(), and fizz::detail::write().
TEST | ( | AsyncSocketTest | , |
EvbCallbacks | |||
) |
Definition at line 2900 of file AsyncSocketTest2.cpp.
References EXPECT_CALL, folly::gen::move, folly::AsyncSocket::newSocket(), folly::gen::seq(), and folly::netops::socket().
TEST | ( | AsyncSocketTest | , |
TestEvbDetachWtRegisteredIOHandlers | |||
) |
Definition at line 2914 of file AsyncSocketTest2.cpp.
References TestServer::accept(), folly::AsyncSocket::OptionKey::apply(), ASSERT_EQ, ASSERT_FALSE, ASSERT_GT, ASSERT_TRUE, EXPECT_CALL, EXPECT_EQ, EXPECT_LE, EXPECT_TRUE, TestServer::getAddress(), folly::INFO, folly::EventBase::loop(), folly::EventBase::loopOnce(), folly::gen::move, folly::AsyncSocket::newSocket(), folly::pushmi::__adl::noexcept(), folly::gen::seq(), folly::netops::socket(), socket_, ConnCallback::state, WriteCallback::state, folly::STATE_SUCCEEDED, folly::test::TEST(), uint32_t, and folly::AsyncSocketException::UNKNOWN.
TEST | ( | AsyncSocket | , |
PreReceivedData | |||
) |
Definition at line 3072 of file AsyncSocketTest2.cpp.
References TestServer::acceptAsync(), folly::IOBuf::copyBuffer(), TestServer::getAddress(), folly::EventBase::loop(), folly::AsyncSocket::newSocket(), and folly::netops::socket().
TEST | ( | AsyncSocket | , |
PreReceivedDataOnly | |||
) |
Definition at line 3105 of file AsyncSocketTest2.cpp.
References TestServer::acceptAsync(), folly::IOBuf::copyBuffer(), TestServer::getAddress(), folly::EventBase::loop(), folly::AsyncSocket::newSocket(), and folly::netops::socket().
TEST | ( | AsyncSocket | , |
PreReceivedDataPartial | |||
) |
Definition at line 3134 of file AsyncSocketTest2.cpp.
References TestServer::acceptAsync(), folly::IOBuf::copyBuffer(), TestServer::getAddress(), folly::EventBase::loop(), folly::AsyncSocket::newSocket(), and folly::netops::socket().
TEST | ( | AsyncSocket | , |
PreReceivedDataTakeover | |||
) |
Definition at line 3168 of file AsyncSocketTest2.cpp.
References TestServer::accept(), TestServer::acceptFD(), ASSERT_EQ, ASSERT_FALSE, ASSERT_GE, ASSERT_NE, ASSERT_TRUE, folly::netops::close(), folly::IOBuf::copyBuffer(), EXPECT_EQ, EXPECT_TRUE, folly::test::TemporaryFile::fd(), TestServer::getAddress(), folly::SocketAddress::getAddress(), folly::test::TestAcceptCallback::getEvents(), folly::netops::getsockopt(), folly::EventBase::loop(), folly::gen::move, folly::AsyncServerSocket::newSocket(), folly::AsyncSocket::newSocket(), TestSendMsgParamsCallback::queriedData_, TestSendMsgParamsCallback::queriedFlags_, fizz::detail::read(), folly::netops::recvmsg(), TestSendMsgParamsCallback::reset(), SCOPE_EXIT, folly::test::TestAcceptCallback::setAcceptErrorFn(), folly::test::TestAcceptCallback::setConnectionAcceptedFn(), folly::netops::socket(), folly::netops::socketpair(), ConnCallback::state, WriteCallback::state, folly::STATE_SUCCEEDED, string, folly::test::TEST(), uint32_t, folly::test::TemporaryFile::UNLINK_IMMEDIATELY, folly::value(), and fizz::detail::write().
TEST_P | ( | AsyncSocketConnectTest | , |
ConnectAndWrite | |||
) |
Test writing immediately after connecting, without waiting for connect to finish.
Definition at line 209 of file AsyncSocketTest2.cpp.
References ASSERT_EQ, ASSERT_FALSE, ASSERT_TRUE, ENABLED, EXPECT_EQ, TestServer::getAddress(), folly::EventBase::loop(), folly::AsyncSocket::newSocket(), folly::netops::socket(), ConnCallback::state, WriteCallback::state, folly::STATE_SUCCEEDED, and TestServer::verifyConnection().
TEST_P | ( | AsyncSocketConnectTest | , |
ConnectNullCallback | |||
) |
Test connecting using a nullptr connect callback.
Definition at line 248 of file AsyncSocketTest2.cpp.
References ASSERT_EQ, ASSERT_FALSE, ASSERT_TRUE, ENABLED, TestServer::getAddress(), folly::EventBase::loop(), folly::AsyncSocket::newSocket(), folly::netops::socket(), WriteCallback::state, folly::STATE_SUCCEEDED, and TestServer::verifyConnection().
TEST_P | ( | AsyncSocketConnectTest | , |
ConnectWriteAndClose | |||
) |
Test calling both write() and close() immediately after connecting, without waiting for connect to finish.
This exercises the STATE_CONNECTING_CLOSING code.
Definition at line 285 of file AsyncSocketTest2.cpp.
References ASSERT_EQ, ASSERT_FALSE, ASSERT_TRUE, ENABLED, TestServer::getAddress(), folly::EventBase::loop(), folly::AsyncSocket::newSocket(), folly::netops::socket(), ConnCallback::state, WriteCallback::state, folly::STATE_SUCCEEDED, and TestServer::verifyConnection().
TEST_P | ( | AsyncSocketConnectTest | , |
ConnectAndRead | |||
) |
Test installing a read callback immediately, before connect() finishes.
Definition at line 431 of file AsyncSocketTest2.cpp.
References TestServer::accept(), ASSERT_EQ, ASSERT_FALSE, folly::ReadCallback::buffers, folly::IOBuf::copyBuffer(), ENABLED, TestServer::getAddress(), folly::EventBase::loop(), folly::AsyncSocket::newSocket(), folly::netops::socket(), ConnCallback::state, folly::STATE_SUCCEEDED, and uint8_t.
TEST_P | ( | AsyncSocketConnectTest | , |
ConnectWriteAndRead | |||
) |
Test both writing and installing a read callback immediately, before connect() finishes.
Definition at line 515 of file AsyncSocketTest2.cpp.
References TestServer::accept(), ASSERT_EQ, ASSERT_FALSE, ASSERT_TRUE, folly::ReadCallback::buffers, ENABLED, TestServer::getAddress(), folly::EventBase::loop(), folly::AsyncSocket::newSocket(), folly::shutdown(), folly::netops::socket(), ConnCallback::state, folly::ReadCallbackBase::state, folly::STATE_SUCCEEDED, uint32_t, and uint8_t.
void testConnectOptWrite | ( | size_t | size1, |
size_t | size2, | ||
bool | close = false |
||
) |
Test connect+write, then have the connect callback perform another write.
This tests interaction of the optimistic writing after connect with additional write attempts that occur in the connect callback.
Definition at line 858 of file AsyncSocketTest2.cpp.
References TestServer::acceptAsync(), ASSERT_EQ, folly::netops::bind(), folly::ReadCallback::buffers, folly::netops::close(), folly::test::end(), TestServer::getAddress(), folly::INFO, folly::EventBase::loop(), min, folly::AsyncSocket::newSocket(), folly::AsyncSocket::setReadCB(), folly::netops::socket(), start, ConnCallback::state, WriteCallback::state, folly::STATE_SUCCEEDED, ConnCallback::successCallback, WriteCallback::successCallback, and tmpDisableReads().
Referenced by TEST().
void tmpDisableReads | ( | AsyncSocket * | socket, |
ReadCallback * | rcb | ||
) |
Definition at line 844 of file AsyncSocketTest2.cpp.
References folly::netops::bind(), folly::AsyncSocket::getEventBase(), folly::EventBase::runInLoop(), and folly::AsyncSocket::setReadCB().
Referenced by testConnectOptWrite().