test: use a bigger buffer to fill a socket

Otherwise we need to do a lot of system calls and cooperative_save tests work
slow.

PiperOrigin-RevId: 275536957
This commit is contained in:
Andrei Vagin
2019-10-18 13:40:31 -07:00
committed by gVisor bot
parent dfdbdf14fa
commit 4c7f849b25
+12 -2
View File
@@ -231,11 +231,21 @@ TEST_P(UnixNonStreamSocketPairTest, SendTimeout) {
setsockopt(sockets->first_fd(), SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)),
SyscallSucceeds());
char buf[100] = {};
const int buf_size = 5 * kPageSize;
EXPECT_THAT(setsockopt(sockets->first_fd(), SOL_SOCKET, SO_SNDBUF, &buf_size,
sizeof(buf_size)),
SyscallSucceeds());
EXPECT_THAT(setsockopt(sockets->second_fd(), SOL_SOCKET, SO_RCVBUF, &buf_size,
sizeof(buf_size)),
SyscallSucceeds());
// The buffer size should be big enough to avoid many iterations in the next
// loop. Otherwise, this will slow down cooperative_save tests.
std::vector<char> buf(kPageSize);
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;