This is an automated email from the ASF dual-hosted git repository.

qianzhang pushed a commit to branch 1.6.x
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit b7f625a94c55d560d30c2d5315f4a28961906f6f
Author: Qian Zhang <zhq527...@gmail.com>
AuthorDate: Wed Sep 26 16:58:48 2018 +0800

    Added a test `FsTest.Lsof`.
    
    Review: https://reviews.apache.org/r/68991
---
 3rdparty/stout/tests/os/filesystem_tests.cpp | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/3rdparty/stout/tests/os/filesystem_tests.cpp 
b/3rdparty/stout/tests/os/filesystem_tests.cpp
index b17ab9a..0f05fdc 100644
--- a/3rdparty/stout/tests/os/filesystem_tests.cpp
+++ b/3rdparty/stout/tests/os/filesystem_tests.cpp
@@ -651,3 +651,23 @@ TEST_F(FsTest, Xattr)
   ASSERT_ERROR(os::getxattr(file, "user.mesos.test"));
 }
 #endif // __linux__ || __APPLE__
+
+
+#ifndef __WINDOWS__
+// This test verifies that the file descriptors returned by `os::lsof()`
+// are all open file descriptors and contains stdin, stdout and stderr.
+TEST_F(FsTest, Lsof)
+{
+  Try<std::vector<int_fd>> fds = os::lsof();
+  ASSERT_SOME(fds);
+
+  // Verify each `fd` is an open file descriptor.
+  foreach (int_fd fd, fds.get()) {
+    EXPECT_NE(-1, ::fcntl(fd, F_GETFD));
+  }
+
+  EXPECT_NE(std::find(fds->begin(), fds->end(), 0), fds->end());
+  EXPECT_NE(std::find(fds->begin(), fds->end(), 1), fds->end());
+  EXPECT_NE(std::find(fds->begin(), fds->end(), 2), fds->end());
+}
+#endif // __WINDOWS__

Reply via email to