From 80cd26c2f43e78d43e2ff769cf0449e67254e673 Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Fri, 23 Apr 2021 16:43:03 -0700 Subject: hostinet: parse the timeval structure from a SO_TIMESTAMP control message PiperOrigin-RevId: 370181621 --- test/syscalls/linux/udp_socket.cc | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'test/syscalls/linux') diff --git a/test/syscalls/linux/udp_socket.cc b/test/syscalls/linux/udp_socket.cc index 18f566eec..29e174f71 100644 --- a/test/syscalls/linux/udp_socket.cc +++ b/test/syscalls/linux/udp_socket.cc @@ -1529,10 +1529,6 @@ TEST_P(UdpSocketTest, ErrorQueue) { #endif // __linux__ TEST_P(UdpSocketTest, SoTimestampOffByDefault) { - // TODO(gvisor.dev/issue/1202): SO_TIMESTAMP socket option not supported by - // hostinet. - SKIP_IF(IsRunningWithHostinet()); - int v = -1; socklen_t optlen = sizeof(v); ASSERT_THAT(getsockopt(bind_.get(), SOL_SOCKET, SO_TIMESTAMP, &v, &optlen), @@ -1542,10 +1538,6 @@ TEST_P(UdpSocketTest, SoTimestampOffByDefault) { } TEST_P(UdpSocketTest, SoTimestamp) { - // TODO(gvisor.dev/issue/1202): ioctl() and SO_TIMESTAMP socket option are not - // supported by hostinet. - SKIP_IF(IsRunningWithHostinet()); - ASSERT_NO_ERRNO(BindLoopback()); ASSERT_THAT(connect(sock_.get(), bind_addr_, addrlen_), SyscallSucceeds()); @@ -1555,8 +1547,8 @@ TEST_P(UdpSocketTest, SoTimestamp) { char buf[3]; // Send zero length packet from sock to bind_. - ASSERT_THAT(RetryEINTR(write)(sock_.get(), buf, 0), - SyscallSucceedsWithValue(0)); + ASSERT_THAT(RetryEINTR(write)(sock_.get(), buf, sizeof(buf)), + SyscallSucceedsWithValue(sizeof(buf))); struct pollfd pfd = {bind_.get(), POLLIN, 0}; ASSERT_THAT(RetryEINTR(poll)(&pfd, 1, /*timeout=*/1000), @@ -1586,9 +1578,13 @@ TEST_P(UdpSocketTest, SoTimestamp) { ASSERT_TRUE(tv.tv_sec != 0 || tv.tv_usec != 0); - // There should be nothing to get via ioctl. - ASSERT_THAT(ioctl(bind_.get(), SIOCGSTAMP, &tv), - SyscallFailsWithErrno(ENOENT)); + // TODO(gvisor.dev/issue/1202): ioctl(SIOCGSTAMP) is not supported by + // hostinet. + if (!IsRunningWithHostinet()) { + // There should be nothing to get via ioctl. + ASSERT_THAT(ioctl(bind_.get(), SIOCGSTAMP, &tv), + SyscallFailsWithErrno(ENOENT)); + } } TEST_P(UdpSocketTest, WriteShutdownNotConnected) { -- cgit v1.2.3