You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by qi...@apache.org on 2018/11/08 08:19:16 UTC
[mesos] 02/09: Added a test `FsTest.Lsof`.
This is an automated email from the ASF dual-hosted git repository.
qianzhang pushed a commit to branch 1.7.x
in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 5c61bb244b5e2d33e9853e5ce93b03b853869d85
Author: Qian Zhang <zh...@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 09d0a40..5290309 100644
--- a/3rdparty/stout/tests/os/filesystem_tests.cpp
+++ b/3rdparty/stout/tests/os/filesystem_tests.cpp
@@ -655,6 +655,7 @@ TEST_F(FsTest, Xattr)
}
#endif // __linux__ || __APPLE__
+
#ifdef __WINDOWS__
// Check if the overlapped field is set properly on Windows.
TEST_F(FsTest, Overlapped)
@@ -800,5 +801,24 @@ TEST_F(FsTest, ReadWriteAsyncLargeBuffer)
EXPECT_SOME(os::close(pipes.get()[0]));
EXPECT_SOME(os::close(pipes.get()[1]));
}
+#endif // __WINDOWS__
+
+
+#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__