mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Deflake socket_stream_blocking tests.
PiperOrigin-RevId: 231020482 Change-Id: Idd9168678b18d03aac473adcc40902e27e06d0a1
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user