summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorZach Koopmans <zkoopmans@google.com>2020-08-25 22:01:00 -0700
committerAndrei Vagin <avagin@gmail.com>2020-09-09 17:53:10 -0700
commit5116c7be8d64934980937113870a8fbc82b14ea0 (patch)
treecb37e9cb327df5729899250ff8c98b6b5110cd5b /test
parent87e03869065f0784bf9ed76855205693128f65a4 (diff)
Fix SocketPairTest and BadSocketPairTest in opensource.
PiperOrigin-RevId: 328467152
Diffstat (limited to 'test')
-rw-r--r--test/syscalls/linux/socket_inet_loopback.cc11
-rw-r--r--test/syscalls/linux/socket_ip_udp_generic.cc6
2 files changed, 11 insertions, 6 deletions
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());