diff options
author | Ian Gudger <igudger@google.com> | 2019-03-21 18:52:03 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2019-03-21 18:53:17 -0700 |
commit | 7d0227ff16f4397924fb008a7452f6ed3f8205e0 (patch) | |
tree | 74954f0a26b7173145393be7356b80cc97759b67 /test/syscalls/linux | |
parent | 125d3a19e3a0e8d5549dca061f3dec9e0f5aa9d4 (diff) |
Add test for short recvmsg iovec length.
PiperOrigin-RevId: 239718991
Change-Id: Idc78557a8e9bfdd3cb7d8ec4db708364652640a4
Diffstat (limited to 'test/syscalls/linux')
-rw-r--r-- | test/syscalls/linux/socket_generic.cc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/syscalls/linux/socket_generic.cc b/test/syscalls/linux/socket_generic.cc index c83fb82fe..d04d5abe0 100644 --- a/test/syscalls/linux/socket_generic.cc +++ b/test/syscalls/linux/socket_generic.cc @@ -257,6 +257,32 @@ TEST_P(AllSocketPairTest, RecvmsgPeekMsghdrFlagsCleared) { EXPECT_EQ(msg.msg_flags, 0); } +TEST_P(AllSocketPairTest, RecvmsgIovNotUpdated) { + auto sockets = ASSERT_NO_ERRNO_AND_VALUE(NewSocketPair()); + + char sent_data[10]; + RandomizeBuffer(sent_data, sizeof(sent_data)); + ASSERT_THAT( + RetryEINTR(send)(sockets->first_fd(), sent_data, sizeof(sent_data), 0), + SyscallSucceedsWithValue(sizeof(sent_data))); + + char received_data[sizeof(sent_data) * 2] = {}; + + struct iovec iov; + iov.iov_base = received_data; + iov.iov_len = sizeof(received_data); + struct msghdr msg = {}; + msg.msg_iov = &iov; + msg.msg_iovlen = 1; + + ASSERT_THAT(RetryEINTR(recvmsg)(sockets->second_fd(), &msg, 0), + SyscallSucceedsWithValue(sizeof(sent_data))); + EXPECT_EQ(0, memcmp(received_data, sent_data, sizeof(sent_data))); + + // Check that the iovec length was not updated. + EXPECT_EQ(msg.msg_iov->iov_len, sizeof(received_data)); +} + TEST_P(AllSocketPairTest, RecvmmsgInvalidTimeout) { auto sockets = ASSERT_NO_ERRNO_AND_VALUE(NewSocketPair()); char buf[10]; |