summaryrefslogtreecommitdiffhomepage
path: root/test/syscalls/linux/accept_bind.cc
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2019-10-18 15:31:33 -0700
committergVisor bot <gvisor-bot@google.com>2019-10-18 15:33:03 -0700
commit49b596b98d9317cb1b63d8004b812e3329812528 (patch)
tree38dafb5af1c8705c4335a9658bfde84739e9551f /test/syscalls/linux/accept_bind.cc
parent8ae70f864d7ab9ca6aa2b47d144d1a2671857603 (diff)
Cleanup host UDS support
This change fixes several issues with the fsgofer host UDS support. Notably, it adds support for SOCK_SEQPACKET and SOCK_DGRAM sockets [1]. It also fixes unsafe use of unet.Socket, which could cause a panic if Socket.FD is called when err != nil, and calls to Socket.FD with nothing to prevent the garbage collector from destroying and closing the socket. A set of tests is added to exercise host UDS access. This required extracting most of the syscall test runner into a library that can be used by custom tests. Updates #235 Updates #1003 [1] N.B. SOCK_DGRAM sockets are likely not particularly useful, as a server can only reply to a client that binds first. We don't allow bind, so these are unlikely to be used. PiperOrigin-RevId: 275558502
Diffstat (limited to 'test/syscalls/linux/accept_bind.cc')
-rw-r--r--test/syscalls/linux/accept_bind.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/syscalls/linux/accept_bind.cc b/test/syscalls/linux/accept_bind.cc
index 1122ea240..328192a05 100644
--- a/test/syscalls/linux/accept_bind.cc
+++ b/test/syscalls/linux/accept_bind.cc
@@ -140,6 +140,18 @@ TEST_P(AllSocketPairTest, Connect) {
SyscallSucceeds());
}
+TEST_P(AllSocketPairTest, ConnectNonListening) {
+ auto sockets = ASSERT_NO_ERRNO_AND_VALUE(NewSocketPair());
+
+ ASSERT_THAT(bind(sockets->first_fd(), sockets->first_addr(),
+ sockets->first_addr_size()),
+ SyscallSucceeds());
+
+ ASSERT_THAT(connect(sockets->second_fd(), sockets->first_addr(),
+ sockets->first_addr_size()),
+ SyscallFailsWithErrno(ECONNREFUSED));
+}
+
TEST_P(AllSocketPairTest, ConnectToFilePath) {
auto sockets = ASSERT_NO_ERRNO_AND_VALUE(NewSocketPair());