diff options
author | Ian Gudger <igudger@google.com> | 2018-12-14 16:12:51 -0800 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-12-14 16:15:06 -0800 |
commit | e1dcf92ec5cf7d9bf58fb322f46f6ae2d98699d2 (patch) | |
tree | 61ed22a594dd96bb994d748e83358c5a51212ee5 /test/syscalls/linux/socket_unix_non_stream.cc | |
parent | ed930354ef46df9b6feece36e59ee644a7cdfa7f (diff) |
Implement SO_SNDTIMEO
PiperOrigin-RevId: 225620490
Change-Id: Ia726107b3f58093a5f881634f90b071b32d2c269
Diffstat (limited to 'test/syscalls/linux/socket_unix_non_stream.cc')
-rw-r--r-- | test/syscalls/linux/socket_unix_non_stream.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/syscalls/linux/socket_unix_non_stream.cc b/test/syscalls/linux/socket_unix_non_stream.cc index 620397746..264b7fe6a 100644 --- a/test/syscalls/linux/socket_unix_non_stream.cc +++ b/test/syscalls/linux/socket_unix_non_stream.cc @@ -225,5 +225,27 @@ TEST_P(UnixNonStreamSocketPairTest, FragmentedRecvMsg) { EXPECT_EQ(0, memcmp(write_buf.data(), ptr, buffer_size)); } +TEST_P(UnixNonStreamSocketPairTest, SendTimeout) { + auto sockets = ASSERT_NO_ERRNO_AND_VALUE(NewSocketPair()); + + struct timeval tv { + .tv_sec = 0, .tv_usec = 10 + }; + EXPECT_THAT( + setsockopt(sockets->first_fd(), SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)), + SyscallSucceeds()); + + char buf[100] = {}; + for (;;) { + int ret; + ASSERT_THAT( + ret = RetryEINTR(send)(sockets->first_fd(), buf, sizeof(buf), 0), + ::testing::AnyOf(SyscallSucceeds(), SyscallFailsWithErrno(EAGAIN))); + if (ret == -1) { + break; + } + } +} + } // namespace testing } // namespace gvisor |