From d89836fe51eeef4920439d6d2433f2ee6f37aec9 Mon Sep 17 00:00:00 2001 From: Brian Geffon Date: Thu, 3 Jan 2019 13:22:12 -0800 Subject: Add test for reopening socketpair end via procfs. PiperOrigin-RevId: 227738801 Change-Id: Ic0c5d10c3b1f21b3f85ff9a661a55db77fab77b0 --- test/syscalls/linux/socket_unix.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test') diff --git a/test/syscalls/linux/socket_unix.cc b/test/syscalls/linux/socket_unix.cc index c60a965ae..8815ad849 100644 --- a/test/syscalls/linux/socket_unix.cc +++ b/test/syscalls/linux/socket_unix.cc @@ -14,6 +14,7 @@ #include "test/syscalls/linux/socket_unix.h" +#include #include #include #include @@ -1175,6 +1176,17 @@ TEST_P(UnixSocketPairTest, SocketShutdown) { EXPECT_EQ(data, absl::string_view(buf, 3)); } +// TODO: We should be returning ENXIO and NOT EIO. +TEST_P(UnixSocketPairTest, DISABLED_SocketReopenFromProcfs) { + auto sockets = ASSERT_NO_ERRNO_AND_VALUE(NewSocketPair()); + + // Opening a socket pair via /proc/self/fd/X is a ENXIO. + for (const int fd : {sockets->first_fd(), sockets->second_fd()}) { + ASSERT_THAT(Open(absl::StrCat("/proc/self/fd/", fd), O_WRONLY), + PosixErrorIs(ENXIO, ::testing::_)); + } +} + } // namespace } // namespace testing -- cgit v1.2.3