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 07:39:31 UTC
[mesos] 02/08: Added a test `FsTest.Lsof`.
This is an automated email from the ASF dual-hosted git repository.
qianzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 00497ab19703fb20f71eea74c2df1ff6346391f5
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 071864b..23b7496 100644
--- a/3rdparty/stout/tests/os/filesystem_tests.cpp
+++ b/3rdparty/stout/tests/os/filesystem_tests.cpp
@@ -657,6 +657,7 @@ TEST_F(FsTest, Xattr)
}
#endif // __linux__ || __APPLE__
+
#ifdef __WINDOWS__
// Check if the overlapped field is set properly on Windows.
TEST_F(FsTest, Overlapped)
@@ -804,6 +805,7 @@ TEST_F(FsTest, ReadWriteAsyncLargeBuffer)
}
#endif // __WINDOWS__
+
#ifndef __WINDOWS__
TEST_F(FsTest, Used)
{
@@ -819,4 +821,22 @@ TEST_F(FsTest, Used)
EXPECT_GT(used.get(), 0u);
EXPECT_LT(used.get(), size.get());
}
+
+
+// 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__