diff options
author | Andrei Vagin <avagin@google.com> | 2020-06-10 13:25:17 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-06-10 13:26:54 -0700 |
commit | a5a4f804879f8d1b5e6de6005aef6d3e14e7dca2 (patch) | |
tree | 5fc837de7c6878ffdf2e9d534ae5643a1cb4cb95 /test/syscalls/linux/socket_unix_seqpacket.cc | |
parent | fadbfd83d9e7f7b00fcffdaf8532e006327c74ad (diff) |
socket/unix: handle sendto address argument for connected sockets
In case of SOCK_SEQPACKET, it has to be ignored.
In case of SOCK_STREAM, EISCONN or EOPNOTSUPP has to be returned.
PiperOrigin-RevId: 315755972
Diffstat (limited to 'test/syscalls/linux/socket_unix_seqpacket.cc')
-rw-r--r-- | test/syscalls/linux/socket_unix_seqpacket.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/syscalls/linux/socket_unix_seqpacket.cc b/test/syscalls/linux/socket_unix_seqpacket.cc index 84d3a569e..6d03df4d9 100644 --- a/test/syscalls/linux/socket_unix_seqpacket.cc +++ b/test/syscalls/linux/socket_unix_seqpacket.cc @@ -43,6 +43,24 @@ TEST_P(SeqpacketUnixSocketPairTest, ReadOneSideClosed) { SyscallSucceedsWithValue(0)); } +TEST_P(SeqpacketUnixSocketPairTest, Sendto) { + auto sockets = ASSERT_NO_ERRNO_AND_VALUE(NewSocketPair()); + + struct sockaddr_un addr = {}; + addr.sun_family = AF_UNIX; + constexpr char kPath[] = "\0nonexistent"; + memcpy(addr.sun_path, kPath, sizeof(kPath)); + + constexpr char kStr[] = "abc"; + ASSERT_THAT(sendto(sockets->second_fd(), kStr, 3, 0, (struct sockaddr*)&addr, + sizeof(addr)), + SyscallSucceedsWithValue(3)); + + char data[10] = {}; + ASSERT_THAT(read(sockets->first_fd(), data, sizeof(data)), + SyscallSucceedsWithValue(3)); +} + } // namespace } // namespace testing |