diff options
author | Kevin Krakauer <krakauer@google.com> | 2021-05-04 16:49:11 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-05-04 16:50:52 -0700 |
commit | 689b369f5788c15f9b018246baa4e318082c0d79 (patch) | |
tree | 46635865e68bac51013d1c03ab348422c4e350c2 /test/syscalls/linux/tcp_socket.cc | |
parent | 682415b6d0035a2af0e7981c31b728762e15bf10 (diff) |
tcp_socket_test: replace tcp_wmem with SO_SNDBUF
PiperOrigin-RevId: 372022596
Diffstat (limited to 'test/syscalls/linux/tcp_socket.cc')
-rw-r--r-- | test/syscalls/linux/tcp_socket.cc | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/test/syscalls/linux/tcp_socket.cc b/test/syscalls/linux/tcp_socket.cc index ef3452306..5bfdecc79 100644 --- a/test/syscalls/linux/tcp_socket.cc +++ b/test/syscalls/linux/tcp_socket.cc @@ -27,7 +27,6 @@ #include <vector> #include "gtest/gtest.h" -#include "absl/strings/str_split.h" #include "absl/time/clock.h" #include "absl/time/time.h" #include "test/syscalls/linux/socket_test_util.h" @@ -1145,17 +1144,6 @@ TEST_P(SimpleTcpSocketTest, SelfConnectSendRecv) { } TEST_P(SimpleTcpSocketTest, SelfConnectSend) { - // Ensure the write size is not larger than the write buffer. - size_t write_size = 512 << 10; // 512 KiB. - constexpr char kWMem[] = "/proc/sys/net/ipv4/tcp_wmem"; - std::string wmem = ASSERT_NO_ERRNO_AND_VALUE(GetContents(kWMem)); - std::vector<std::string> vals = absl::StrSplit(wmem, absl::ByAnyChar("\t ")); - size_t max_wmem; - ASSERT_TRUE(absl::SimpleAtoi(vals.back(), &max_wmem)); - if (write_size > max_wmem) { - write_size = max_wmem; - } - // Initialize address to the loopback one. sockaddr_storage addr = ASSERT_NO_ERRNO_AND_VALUE(InetLoopbackAddr(GetParam())); @@ -1176,6 +1164,12 @@ TEST_P(SimpleTcpSocketTest, SelfConnectSend) { ASSERT_THAT(RetryEINTR(connect)(s.get(), AsSockAddr(&addr), addrlen), SyscallSucceeds()); + // Ensure the write buffer is large enough not to block on a single write. + size_t write_size = 512 << 10; // 512 KiB. + EXPECT_THAT(setsockopt(s.get(), SOL_SOCKET, SO_SNDBUF, &write_size, + sizeof(write_size)), + SyscallSucceedsWithValue(0)); + std::vector<char> writebuf(write_size); // Try to send the whole thing. |