proxygen
|
#include <folly/SocketAddress.h>
#include <iostream>
#include <sstream>
#include <system_error>
#include <folly/String.h>
#include <folly/container/Array.h>
#include <folly/experimental/TestUtil.h>
#include <folly/portability/GTest.h>
#include <folly/portability/Sockets.h>
#include <folly/test/SocketAddressTestHelper.h>
Go to the source code of this file.
Macros | |
#define | REQUIRE_ERRNO(cond, msg) |
Functions | |
TEST (SocketAddress, Size) | |
TEST (SocketAddress, ConstructFromIpv4) | |
TEST (SocketAddress, StringConversion) | |
TEST (SocketAddress, IPv4ToStringConversion) | |
TEST (SocketAddress, SetFromIpAddressPort) | |
TEST (SocketAddress, SetFromIpv4) | |
TEST (SocketAddress, ConstructFromInvalidIpv4) | |
TEST (SocketAddress, SetFromInvalidIpv4) | |
TEST (SocketAddress, SetFromHostname) | |
TEST (SocketAddress, SetFromStrings) | |
TEST (SocketAddress, EqualityAndHash) | |
TEST (SocketAddress, IsPrivate) | |
TEST (SocketAddress, IsLoopback) | |
void | CheckPrefixMatch (const SocketAddress &first, const SocketAddress &second, unsigned matchingPrefixLen) |
TEST (SocketAddress, PrefixMatch) | |
void | CheckFirstLessThanSecond (SocketAddress first, SocketAddress second) |
TEST (SocketAddress, CheckComparatorBehavior) | |
TEST (SocketAddress, Unix) | |
TEST (SocketAddress, AnonymousUnix) | |
void | testSetFromSocket (const SocketAddress *serverBindAddr, const SocketAddress *clientBindAddr, SocketAddress *listenAddrRet, SocketAddress *acceptAddrRet, SocketAddress *serverAddrRet, SocketAddress *serverPeerAddrRet, SocketAddress *clientAddrRet, SocketAddress *clientPeerAddrRet) |
TEST (SocketAddress, SetFromSocketIPv4) | |
TEST (SocketAddress, SetFromSocketUnixAbstract) | |
TEST (SocketAddress, SetFromSocketUnixExplicit) | |
TEST (SocketAddress, SetFromSocketUnixAnonymous) | |
TEST (SocketAddress, ResetUnixAddress) | |
TEST (SocketAddress, ResetIPAddress) | |
TEST (SocketAddress, ValidFamilyInet) | |
#define REQUIRE_ERRNO | ( | cond, | |
msg | |||
) |
Definition at line 674 of file SocketAddressTest.cpp.
Referenced by testSetFromSocket().
void CheckFirstLessThanSecond | ( | SocketAddress | first, |
SocketAddress | second | ||
) |
void CheckPrefixMatch | ( | const SocketAddress & | first, |
const SocketAddress & | second, | ||
unsigned | matchingPrefixLen | ||
) |
Definition at line 429 of file SocketAddressTest.cpp.
References EXPECT_TRUE, folly::SocketAddress::getFamily(), i, and folly::SocketAddress::prefixMatch().
Referenced by TEST().
TEST | ( | SocketAddress | , |
Size | |||
) |
Definition at line 40 of file SocketAddressTest.cpp.
References addr, and EXPECT_EQ.
TEST | ( | SocketAddress | , |
ConstructFromIpv4 | |||
) |
Definition at line 45 of file SocketAddressTest.cpp.
References addr, EXPECT_EQ, folly::SocketAddress::getAddress(), folly::SocketAddress::getAddressStr(), folly::SocketAddress::getFamily(), and folly::SocketAddress::getPort().
TEST | ( | SocketAddress | , |
StringConversion | |||
) |
Definition at line 57 of file SocketAddressTest.cpp.
References addr, EXPECT_EQ, EXPECT_STREQ, folly::SocketAddress::getAddressStr(), and folly::SocketAddress::getFamily().
TEST | ( | SocketAddress | , |
IPv4ToStringConversion | |||
) |
Definition at line 66 of file SocketAddressTest.cpp.
References addr, EXPECT_EQ, folly::SocketAddress::getAddressStr(), i, folly::join(), folly::make_array(), and folly::SocketAddress::setFromIpPort().
TEST | ( | SocketAddress | , |
SetFromIpAddressPort | |||
) |
Definition at line 80 of file SocketAddressTest.cpp.
References addr, EXPECT_EQ, folly::SocketAddress::getAddressStr(), folly::SocketAddress::getFamily(), folly::SocketAddress::getIPAddress(), folly::SocketAddress::getPort(), and folly::SocketAddress::setFromIpAddrPort().
TEST | ( | SocketAddress | , |
SetFromIpv4 | |||
) |
Definition at line 97 of file SocketAddressTest.cpp.
References addr, EXPECT_EQ, folly::SocketAddress::getAddress(), folly::SocketAddress::getAddressStr(), folly::SocketAddress::getFamily(), folly::SocketAddress::getPort(), and folly::SocketAddress::setFromIpPort().
TEST | ( | SocketAddress | , |
ConstructFromInvalidIpv4 | |||
) |
Definition at line 110 of file SocketAddressTest.cpp.
References EXPECT_THROW.
TEST | ( | SocketAddress | , |
SetFromInvalidIpv4 | |||
) |
Definition at line 114 of file SocketAddressTest.cpp.
References addr, EXPECT_EQ, EXPECT_THROW, folly::SocketAddress::getAddress(), folly::SocketAddress::getAddressStr(), folly::SocketAddress::getFamily(), folly::SocketAddress::getPort(), and folly::SocketAddress::setFromIpPort().
TEST | ( | SocketAddress | , |
SetFromHostname | |||
) |
Definition at line 132 of file SocketAddressTest.cpp.
References addr, EXPECT_THROW, folly::SocketAddress::setFromHostPort(), and folly::SocketAddress::setFromIpPort().
TEST | ( | SocketAddress | , |
SetFromStrings | |||
) |
Definition at line 142 of file SocketAddressTest.cpp.
References addr, EXPECT_EQ, EXPECT_THROW, folly::SocketAddress::getAddressStr(), folly::SocketAddress::getFamily(), folly::SocketAddress::getPort(), folly::SocketAddress::setFromIpPort(), folly::SocketAddress::setFromLocalIpPort(), and folly::SocketAddress::setFromLocalPort().
TEST | ( | SocketAddress | , |
EqualityAndHash | |||
) |
Definition at line 199 of file SocketAddressTest.cpp.
References folly::SocketAddress::convertToIPv4(), EXPECT_EQ, EXPECT_NE, EXPECT_TRUE, folly::SocketAddress::hash(), folly::SocketAddress::isIPv4Mapped(), and folly::SocketAddress::setFromPath().
TEST | ( | SocketAddress | , |
IsPrivate | |||
) |
Definition at line 302 of file SocketAddressTest.cpp.
References addr, EXPECT_TRUE, folly::SocketAddress::isPrivateAddress(), folly::SocketAddress::setFromIpPort(), and folly::SocketAddress::setFromPath().
TEST | ( | SocketAddress | , |
IsLoopback | |||
) |
Definition at line 390 of file SocketAddressTest.cpp.
References addr, EXPECT_TRUE, folly::SocketAddress::isLoopbackAddress(), folly::SocketAddress::setFromIpPort(), and folly::SocketAddress::setFromPath().
TEST | ( | SocketAddress | , |
PrefixMatch | |||
) |
Definition at line 443 of file SocketAddressTest.cpp.
References CheckPrefixMatch(), EXPECT_TRUE, folly::SocketAddress::prefixMatch(), and folly::SocketAddress::setFromIpPort().
TEST | ( | SocketAddress | , |
CheckComparatorBehavior | |||
) |
Definition at line 478 of file SocketAddressTest.cpp.
References CheckFirstLessThanSecond(), folly::gen::first, folly::SocketAddress::setFromIpPort(), and folly::SocketAddress::setFromPath().
TEST | ( | SocketAddress | , |
Unix | |||
) |
Definition at line 540 of file SocketAddressTest.cpp.
References addr, folly::copy(), folly::SocketAddress::describe(), EXPECT_EQ, EXPECT_NE, EXPECT_THROW, EXPECT_TRUE, folly::SocketAddress::getAddressStr(), folly::SocketAddress::getFamily(), folly::SocketAddress::getPath(), folly::SocketAddress::getPort(), folly::SocketAddress::isLoopbackAddress(), folly::SocketAddress::isPrivateAddress(), folly::gen::move, folly::SocketAddress::setFromHostPort(), folly::SocketAddress::setFromIpPort(), and folly::SocketAddress::setFromPath().
TEST | ( | SocketAddress | , |
AnonymousUnix | |||
) |
Definition at line 641 of file SocketAddressTest.cpp.
References folly::netops::close(), folly::SocketAddress::describe(), EXPECT_EQ, EXPECT_NE, folly::SocketAddress::setFromLocalAddress(), folly::SocketAddress::setFromPeerAddress(), and folly::netops::socketpair().
TEST | ( | SocketAddress | , |
SetFromSocketIPv4 | |||
) |
Definition at line 748 of file SocketAddressTest.cpp.
References EXPECT_EQ, folly::SocketAddress::getPort(), and testSetFromSocket().
TEST | ( | SocketAddress | , |
SetFromSocketUnixAbstract | |||
) |
Definition at line 787 of file SocketAddressTest.cpp.
References EXPECT_EQ, folly::SocketAddress::setFromPath(), and testSetFromSocket().
TEST | ( | SocketAddress | , |
SetFromSocketUnixExplicit | |||
) |
Definition at line 830 of file SocketAddressTest.cpp.
References EXPECT_EQ, folly::test::TemporaryDirectory::path(), folly::SocketAddress::setFromPath(), string, and testSetFromSocket().
TEST | ( | SocketAddress | , |
SetFromSocketUnixAnonymous | |||
) |
Definition at line 879 of file SocketAddressTest.cpp.
References EXPECT_EQ, folly::SocketAddress::getPath(), folly::test::TemporaryDirectory::path(), folly::SocketAddress::setFromPath(), string, and testSetFromSocket().
TEST | ( | SocketAddress | , |
ResetUnixAddress | |||
) |
Definition at line 925 of file SocketAddressTest.cpp.
References EXPECT_EQ, folly::SocketAddress::getFamily(), folly::SocketAddress::reset(), and folly::SocketAddress::setFromPath().
TEST | ( | SocketAddress | , |
ResetIPAddress | |||
) |
Definition at line 933 of file SocketAddressTest.cpp.
References addr, folly::SocketAddress::empty(), EXPECT_EQ, EXPECT_FALSE, EXPECT_TRUE, folly::SocketAddress::getFamily(), folly::SocketAddress::isInitialized(), folly::SocketAddress::reset(), and folly::SocketAddress::setFromIpPort().
TEST | ( | SocketAddress | , |
ValidFamilyInet | |||
) |
Definition at line 948 of file SocketAddressTest.cpp.
References addr, EXPECT_FALSE, EXPECT_TRUE, folly::SocketAddress::isFamilyInet(), and folly::SocketAddress::setFromIpAddrPort().
void testSetFromSocket | ( | const SocketAddress * | serverBindAddr, |
const SocketAddress * | clientBindAddr, | ||
SocketAddress * | listenAddrRet, | ||
SocketAddress * | acceptAddrRet, | ||
SocketAddress * | serverAddrRet, | ||
SocketAddress * | serverPeerAddrRet, | ||
SocketAddress * | clientAddrRet, | ||
SocketAddress * | clientPeerAddrRet | ||
) |
Definition at line 679 of file SocketAddressTest.cpp.
References folly::netops::accept(), folly::netops::bind(), folly::netops::close(), folly::netops::connect(), EXPECT_THROW, folly::SocketAddress::getActualSize(), folly::SocketAddress::getAddress(), folly::SocketAddress::getFamily(), folly::netops::listen(), REQUIRE_ERRNO, folly::SocketAddress::setFromLocalAddress(), folly::SocketAddress::setFromPeerAddress(), folly::SocketAddress::setFromSockaddr(), and folly::netops::socket().
Referenced by TEST().