From 003eedea1c66d3ff07b28accb46bbe9abfa8c89c Mon Sep 17 00:00:00 2001 From: Ian Gudger Date: Mon, 14 Jan 2019 13:06:16 -0800 Subject: Deflake RecvLessThanBufferWaitAll. PiperOrigin-RevId: 229238781 Change-Id: Ib5a1e46293583efcb09e255fcd400c3fcc53ef1b --- test/syscalls/linux/socket_stream_blocking.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/syscalls/linux/socket_stream_blocking.cc b/test/syscalls/linux/socket_stream_blocking.cc index 6cfadc9da..a04f2d7d0 100644 --- a/test/syscalls/linux/socket_stream_blocking.cc +++ b/test/syscalls/linux/socket_stream_blocking.cc @@ -98,7 +98,10 @@ TEST_P(BlockingStreamSocketPairTest, RecvLessThanBuffer) { SyscallSucceedsWithValue(sizeof(sent_data))); } -TEST_P(BlockingStreamSocketPairTest, RecvLessThanBufferWaitAll) { +// Test that MSG_WAITALL causes recv to block until all requested data is +// received. Random save can interrupt blocking and cause received data to be +// returned, even if the amount received is less than the full requested amount. +TEST_P(BlockingStreamSocketPairTest, RecvLessThanBufferWaitAll_NoRandomSave) { auto sockets = ASSERT_NO_ERRNO_AND_VALUE(NewSocketPair()); char sent_data[100]; @@ -112,6 +115,10 @@ TEST_P(BlockingStreamSocketPairTest, RecvLessThanBufferWaitAll) { const ScopedThread t([&]() { absl::SleepFor(kDuration); + + // Don't let saving after the write interrupt the blocking recv. + const DisableSave ds; + ASSERT_THAT(write(sockets->first_fd(), sent_data, sizeof(sent_data)), SyscallSucceedsWithValue(sizeof(sent_data))); }); -- cgit v1.2.3