summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/syscalls/linux/socket_unix_unbound_abstract.cc46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/syscalls/linux/socket_unix_unbound_abstract.cc b/test/syscalls/linux/socket_unix_unbound_abstract.cc
index 8b1762000..dd3d25450 100644
--- a/test/syscalls/linux/socket_unix_unbound_abstract.cc
+++ b/test/syscalls/linux/socket_unix_unbound_abstract.cc
@@ -72,6 +72,52 @@ TEST_P(UnboundAbstractUnixSocketPairTest, BindNothing) {
SyscallSucceeds());
}
+TEST_P(UnboundAbstractUnixSocketPairTest, ListenZeroBacklog) {
+ SKIP_IF((GetParam().type & SOCK_DGRAM) != 0);
+ auto sockets = ASSERT_NO_ERRNO_AND_VALUE(NewSocketPair());
+ struct sockaddr_un addr = {};
+ addr.sun_family = AF_UNIX;
+ constexpr char kPath[] = "\x00/foo_bar";
+ memcpy(addr.sun_path, kPath, sizeof(kPath));
+ ASSERT_THAT(bind(sockets->first_fd(),
+ reinterpret_cast<struct sockaddr*>(&addr), sizeof(addr)),
+ SyscallSucceeds());
+ ASSERT_THAT(listen(sockets->first_fd(), 0 /* backlog */), SyscallSucceeds());
+ ASSERT_THAT(connect(sockets->second_fd(),
+ reinterpret_cast<struct sockaddr*>(&addr), sizeof(addr)),
+ SyscallSucceeds());
+ auto sockets2 = ASSERT_NO_ERRNO_AND_VALUE(NewSocketPair());
+ {
+ // Set the FD to O_NONBLOCK.
+ int opts;
+ int orig_opts;
+ ASSERT_THAT(opts = fcntl(sockets2->first_fd(), F_GETFL), SyscallSucceeds());
+ orig_opts = opts;
+ opts |= O_NONBLOCK;
+ ASSERT_THAT(fcntl(sockets2->first_fd(), F_SETFL, opts), SyscallSucceeds());
+
+ ASSERT_THAT(
+ connect(sockets2->first_fd(), reinterpret_cast<struct sockaddr*>(&addr),
+ sizeof(addr)),
+ SyscallFailsWithErrno(EAGAIN));
+ }
+ {
+ // Set the FD to O_NONBLOCK.
+ int opts;
+ int orig_opts;
+ ASSERT_THAT(opts = fcntl(sockets2->second_fd(), F_GETFL),
+ SyscallSucceeds());
+ orig_opts = opts;
+ opts |= O_NONBLOCK;
+ ASSERT_THAT(fcntl(sockets2->second_fd(), F_SETFL, opts), SyscallSucceeds());
+
+ ASSERT_THAT(
+ connect(sockets2->second_fd(),
+ reinterpret_cast<struct sockaddr*>(&addr), sizeof(addr)),
+ SyscallFailsWithErrno(EAGAIN));
+ }
+}
+
TEST_P(UnboundAbstractUnixSocketPairTest, GetSockNameFullLength) {
auto sockets = ASSERT_NO_ERRNO_AND_VALUE(NewSocketPair());