From ebf5293374bc94e01eb58ebe29a1e53aa404d3a7 Mon Sep 17 00:00:00 2001 From: Zach Koopmans Date: Tue, 25 Aug 2020 22:01:00 -0700 Subject: Fix SocketPairTest and BadSocketPairTest in opensource. PiperOrigin-RevId: 328467152 --- test/syscalls/linux/socket_inet_loopback.cc | 11 +++++++---- test/syscalls/linux/socket_ip_udp_generic.cc | 6 ++++-- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'test/syscalls') diff --git a/test/syscalls/linux/socket_inet_loopback.cc b/test/syscalls/linux/socket_inet_loopback.cc index bd30fb86b..7c1d6a414 100644 --- a/test/syscalls/linux/socket_inet_loopback.cc +++ b/test/syscalls/linux/socket_inet_loopback.cc @@ -97,11 +97,13 @@ TEST(BadSocketPairArgs, ValidateErrForBadCallsToSocketPair) { ASSERT_THAT(socketpair(AF_INET6, 0, 0, fd), SyscallFailsWithErrno(ESOCKTNOSUPPORT)); - // Invalid AF will return ENOAFSUPPORT. + // Invalid AF will return ENOAFSUPPORT or EPERM. ASSERT_THAT(socketpair(AF_MAX, 0, 0, fd), - SyscallFailsWithErrno(EAFNOSUPPORT)); + ::testing::AnyOf(SyscallFailsWithErrno(EAFNOSUPPORT), + SyscallFailsWithErrno(EPERM))); ASSERT_THAT(socketpair(8675309, 0, 0, fd), - SyscallFailsWithErrno(EAFNOSUPPORT)); + ::testing::AnyOf(SyscallFailsWithErrno(EAFNOSUPPORT), + SyscallFailsWithErrno(EPERM))); } enum class Operation { @@ -116,7 +118,8 @@ std::string OperationToString(Operation operation) { return "Bind"; case Operation::Connect: return "Connect"; - case Operation::SendTo: + // Operation::SendTo is the default. + default: return "SendTo"; } } diff --git a/test/syscalls/linux/socket_ip_udp_generic.cc b/test/syscalls/linux/socket_ip_udp_generic.cc index 5cad6f017..6e4ecd680 100644 --- a/test/syscalls/linux/socket_ip_udp_generic.cc +++ b/test/syscalls/linux/socket_ip_udp_generic.cc @@ -435,8 +435,10 @@ TEST_P(UDPSocketPairTest, TOSRecvMismatch) { // Test that an IPv4 socket does not support the IPv6 TClass option. TEST_P(UDPSocketPairTest, TClassRecvMismatch) { - // This should only test AF_INET sockets for the mismatch behavior. - SKIP_IF(GetParam().domain != AF_INET); + // This should only test AF_INET6 sockets for the mismatch behavior. + SKIP_IF(GetParam().domain != AF_INET6); + // IPV6_RECVTCLASS is only valid for SOCK_DGRAM and SOCK_RAW. + SKIP_IF(GetParam().type != SOCK_DGRAM | GetParam().type != SOCK_RAW); auto sockets = ASSERT_NO_ERRNO_AND_VALUE(NewSocketPair()); -- cgit v1.2.3