diff options
author | Jamie Liu <jamieliu@google.com> | 2019-01-25 22:37:41 -0800 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2019-01-25 22:38:48 -0800 |
commit | a8b8e13154fe39396b9139e8409cb822bbe0a68a (patch) | |
tree | 612e2d10b80880106f98b67de6aa14f7bf56a0e8 | |
parent | 55e8eb775b422a7485d6d1dc4f8e4c8fd32096da (diff) |
Deflake socket_stream_blocking tests.
PiperOrigin-RevId: 231020482
Change-Id: Idd9168678b18d03aac473adcc40902e27e06d0a1
-rw-r--r-- | test/syscalls/linux/socket_stream_blocking.cc | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/test/syscalls/linux/socket_stream_blocking.cc b/test/syscalls/linux/socket_stream_blocking.cc index a04f2d7d0..8b3f6a647 100644 --- a/test/syscalls/linux/socket_stream_blocking.cc +++ b/test/syscalls/linux/socket_stream_blocking.cc @@ -62,12 +62,14 @@ TEST_P(BlockingStreamSocketPairTest, BlockPartialWriteClosed) { }); // Leave time for write to become blocked. - absl::SleepFor(absl::Seconds(1.0)); + absl::SleepFor(absl::Seconds(1)); ASSERT_THAT(close(sockets->release_second_fd()), SyscallSucceeds()); } -TEST_P(BlockingStreamSocketPairTest, SendMsgTooLarge) { +// Random save may interrupt the call to sendmsg() in SendLargeSendMsg(), +// causing the write to be incomplete and the test to hang. +TEST_P(BlockingStreamSocketPairTest, SendMsgTooLarge_NoRandomSave) { auto sockets = ASSERT_NO_ERRNO_AND_VALUE(NewSocketPair()); int sndbuf; @@ -142,11 +144,15 @@ TEST_P(BlockingStreamSocketPairTest, SendTimeout) { setsockopt(sockets->first_fd(), SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)), SyscallSucceeds()); - char buf[100] = {}; + std::vector<char> buf(kPageSize); + // We don't know how much data the socketpair will buffer, so we may do an + // arbitrarily large number of writes; saving after each write causes this + // test's time to explode. + const DisableSave ds; for (;;) { int ret; ASSERT_THAT( - ret = RetryEINTR(send)(sockets->first_fd(), buf, sizeof(buf), 0), + ret = RetryEINTR(send)(sockets->first_fd(), buf.data(), buf.size(), 0), ::testing::AnyOf(SyscallSucceeds(), SyscallFailsWithErrno(EAGAIN))); if (ret == -1) { break; |