You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2016/10/13 05:34:42 UTC
[4/7] mesos git commit: Added test to test corner cases with sorted
'MountInfoTable::read()'.
Added test to test corner cases with sorted 'MountInfoTable::read()'.
We allow entries in the MountInfoTable to be out of order, as well as
parent's of themselves. This test makes sure that this functionality
is exercised.
Review: https://reviews.apache.org/r/52703/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/2f005a03
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/2f005a03
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/2f005a03
Branch: refs/heads/master
Commit: 2f005a03d59948c9a41b3fea8f81332e4e74ab3c
Parents: 44c4383
Author: Kevin Klues <kl...@gmail.com>
Authored: Wed Oct 12 22:34:15 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed Oct 12 22:34:15 2016 -0700
----------------------------------------------------------------------
src/tests/containerizer/fs_tests.cpp | 35 +++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/2f005a03/src/tests/containerizer/fs_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/fs_tests.cpp b/src/tests/containerizer/fs_tests.cpp
index 0dd212f..d8bd1d0 100644
--- a/src/tests/containerizer/fs_tests.cpp
+++ b/src/tests/containerizer/fs_tests.cpp
@@ -22,6 +22,7 @@
#include <stout/foreach.hpp>
#include <stout/gtest.hpp>
+#include <stout/hashset.hpp>
#include <stout/none.hpp>
#include <stout/option.hpp>
#include <stout/os.hpp>
@@ -184,6 +185,40 @@ TEST_F(FsTest, MountInfoTableReadSorted)
}
+TEST_F(FsTest, MountInfoTableReadSortedParentOfSelf)
+{
+ // Construct a mount info table with a few entries out of order as
+ // well as a few having themselves as parents.
+ string lines =
+ "1 1 0:00 / / rw shared:6 - sysfs sysfs rw\n"
+ "6 5 0:00 / /6 rw shared:6 - sysfs sysfs rw\n"
+ "7 6 0:00 / /7 rw shared:6 - sysfs sysfs rw\n"
+ "8 8 0:00 / /8 rw shared:6 - sysfs sysfs rw\n"
+ "9 8 0:00 / /9 rw shared:6 - sysfs sysfs rw\n"
+ "2 1 0:00 / /2 rw shared:6 - sysfs sysfs rw\n"
+ "3 2 0:00 / /3 rw shared:6 - sysfs sysfs rw\n"
+ "4 3 0:00 / /4 rw shared:6 - sysfs sysfs rw\n"
+ "5 4 0:00 / /5 rw shared:6 - sysfs sysfs rw\n";
+
+ // Examine the calling process's mountinfo table.
+ Try<MountInfoTable> table = MountInfoTable::read(lines);
+ ASSERT_SOME(table);
+
+ hashset<int> ids;
+
+ // Verify that all parent entries appear *before* their children.
+ foreach (const MountInfoTable::Entry& entry, table->entries) {
+ if (entry.target != "/") {
+ ASSERT_TRUE(ids.contains(entry.parent));
+ }
+
+ ASSERT_FALSE(ids.contains(entry.id));
+
+ ids.insert(entry.id);
+ }
+}
+
+
TEST_F(FsTest, ROOT_SharedMount)
{
string directory = os::getcwd();