Fix SocketPairTest and BadSocketPairTest in opensource.

PiperOrigin-RevId: 328467152
This commit is contained in:
Zach Koopmans
2020-08-25 22:03:04 -07:00
committed by gVisor bot
parent df3c105f49
commit ebf5293374
2 changed files with 11 additions and 6 deletions
+7 -4
View File
@@ -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";
}
}
+4 -2
View File
@@ -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());