Remove TcpAcceptBacklogSizes test

This test is not helpful because it tries to do connect and accept in
a loop. This will always succeed no matter what backlog is used (the
connection created will immediately be accepted, there is no backlog
at all). I think the actual test intention is already covered by the
TCPBacklog test. Removing this test so we don't spend unnecessary
time on a 1024 iteration loop that is bound to succeed.

PiperOrigin-RevId: 625139127
This commit is contained in:
Zeling Feng
2024-04-15 17:45:52 -07:00
committed by gVisor bot
parent dd51b97d9d
commit 435880365b
@@ -975,56 +975,6 @@ TEST_P(SocketInetLoopbackTest, TCPNonBlockingConnectClose) {
}
}
// TODO(b/153489135): Remove once bug is fixed. Test fails w/
// random save as established connections which can't be delivered to the accept
// queue because the queue is full are not correctly delivered after restore
// causing the last accept to timeout on the restore.
TEST_P(SocketInetLoopbackTest, TCPAcceptBacklogSizes) {
SocketInetTestParam const& param = GetParam();
TestAddress const& listener = param.listener;
TestAddress const& connector = param.connector;
// Create the listening socket.
const FileDescriptor listen_fd = ASSERT_NO_ERRNO_AND_VALUE(
Socket(listener.family(), SOCK_STREAM, IPPROTO_TCP));
sockaddr_storage listen_addr = listener.addr;
ASSERT_THAT(
bind(listen_fd.get(), AsSockAddr(&listen_addr), listener.addr_len),
SyscallSucceeds());
// Get the port bound by the listening socket.
socklen_t addrlen = listener.addr_len;
ASSERT_THAT(getsockname(listen_fd.get(), AsSockAddr(&listen_addr), &addrlen),
SyscallSucceeds());
uint16_t const port =
ASSERT_NO_ERRNO_AND_VALUE(AddrPort(listener.family(), listen_addr));
std::array<int, 3> backlogs = {-1, 0, 1};
for (auto& backlog : backlogs) {
ASSERT_THAT(listen(listen_fd.get(), backlog), SyscallSucceeds());
int expected_accepts;
if (backlog < 0) {
expected_accepts = 1024;
} else {
// See the comment in TCPBacklog for why this isn't backlog + 1.
expected_accepts = backlog;
}
for (int i = 0; i < expected_accepts; i++) {
SCOPED_TRACE(absl::StrCat("i=", i));
// Connect to the listening socket.
const FileDescriptor conn_fd = ASSERT_NO_ERRNO_AND_VALUE(
Socket(connector.family(), SOCK_STREAM, IPPROTO_TCP));
sockaddr_storage conn_addr = connector.addr;
ASSERT_NO_ERRNO(SetAddrPort(connector.family(), &conn_addr, port));
ASSERT_THAT(RetryEINTR(connect)(conn_fd.get(), AsSockAddr(&conn_addr),
connector.addr_len),
SyscallSucceeds());
const FileDescriptor accepted =
ASSERT_NO_ERRNO_AND_VALUE(Accept(listen_fd.get(), nullptr, nullptr));
}
}
}
// TODO(b/153489135): Remove once bug is fixed. Test fails w/
// random save as established connections which can't be delivered to the accept
// queue because the queue is full are not correctly delivered after restore