Skip TCP_DEFER_ACCEPT test if we sleep for longer than timeout

FIXED: https://fxbug.dev/326254381
PiperOrigin-RevId: 615470990
This commit is contained in:
Peter Johnston
2024-03-13 10:46:46 -07:00
committed by gVisor bot
parent d5f24ea92a
commit aff56ec25d
@@ -1571,7 +1571,13 @@ TEST_P(SocketInetLoopbackTest, TCPDeferAcceptTimeout) {
// Verify that there is no acceptable connection before TCP_DEFER_ACCEPT
// timeout is hit.
const auto start = absl::Now();
absl::SleepFor(absl::Seconds(kTCPDeferAccept - 1));
// It's possible that we ended up sleeping for longer than the
// TCP_DEFER_ACCEPT timeout. If this happens, skip this test.
if (absl::Now() >= start + absl::Seconds(kTCPDeferAccept)) {
GTEST_SKIP();
}
ASSERT_THAT(accept(listen_fd.get(), nullptr, nullptr),
SyscallFailsWithErrno(EWOULDBLOCK));