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_stream_blocking.cc | |
parent | ed930354ef46df9b6feece36e59ee644a7cdfa7f (diff) |
Implement SO_SNDTIMEO
PiperOrigin-RevId: 225620490
Change-Id: Ia726107b3f58093a5f881634f90b071b32d2c269
Diffstat (limited to 'test/syscalls/linux/socket_stream_blocking.cc')
-rw-r--r-- | test/syscalls/linux/socket_stream_blocking.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/syscalls/linux/socket_stream_blocking.cc b/test/syscalls/linux/socket_stream_blocking.cc index 3fbbe54d8..6cfadc9da 100644 --- a/test/syscalls/linux/socket_stream_blocking.cc +++ b/test/syscalls/linux/socket_stream_blocking.cc @@ -125,5 +125,27 @@ TEST_P(BlockingStreamSocketPairTest, RecvLessThanBufferWaitAll) { EXPECT_GE(after - before, kDuration); } +TEST_P(BlockingStreamSocketPairTest, 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 |