Repository: mesos
Updated Branches:
  refs/heads/master b6e31887d -> 294de9fbc


Added a test for os::realpath().

See summary.

Review: https://reviews.apache.org/r/38667


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/294de9fb
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/294de9fb
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/294de9fb

Branch: refs/heads/master
Commit: 294de9fbc775804346f1d0befed14543217f3858
Parents: b6e3188
Author: Artem Harutyunyan <[email protected]>
Authored: Sun Sep 27 17:46:00 2015 -0700
Committer: Joris Van Remoortere <[email protected]>
Committed: Sun Sep 27 17:46:00 2015 -0700

----------------------------------------------------------------------
 .../3rdparty/stout/tests/os_tests.cpp           | 35 ++++++++++++++++++++
 1 file changed, 35 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/294de9fb/3rdparty/libprocess/3rdparty/stout/tests/os_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/os_tests.cpp 
b/3rdparty/libprocess/3rdparty/stout/tests/os_tests.cpp
index 37cfcb7..e6d36ec 100644
--- a/3rdparty/libprocess/3rdparty/stout/tests/os_tests.cpp
+++ b/3rdparty/libprocess/3rdparty/stout/tests/os_tests.cpp
@@ -1003,3 +1003,38 @@ TEST_F(OsTest, Mknod)
 
   EXPECT_SOME(os::rm(another));
 }
+
+
+TEST_F(OsTest, Realpath)
+{
+  // Create a file.
+  const Try<std::string> _testFile = os::mktemp();
+  ASSERT_SOME(_testFile);
+  ASSERT_SOME(os::touch(_testFile.get()));
+  const std::string testFile = _testFile.get();
+
+  // Create a symlink pointing to a file.
+  const std::string testLink = UUID::random().toString();
+  ASSERT_SOME(fs::symlink(testFile, testLink));
+
+  // Validate the symlink.
+  const Try<ino_t> fileInode = os::stat::inode(testFile);
+  ASSERT_SOME(fileInode);
+  const Try<ino_t> linkInode = os::stat::inode(testLink);
+  ASSERT_SOME(linkInode);
+  ASSERT_EQ(fileInode.get(), linkInode.get());
+
+  // Verify that the symlink resolves correctly.
+  Result<std::string> resolved = os::realpath(testLink);
+  ASSERT_SOME(resolved);
+  EXPECT_TRUE(strings::contains(resolved.get(), testFile));
+
+  // Verify that the file itself resolves correctly.
+  resolved = os::realpath(testFile);
+  ASSERT_SOME(resolved);
+  EXPECT_TRUE(strings::contains(resolved.get(), testFile));
+
+  // Remove the file and the symlink.
+  os::rm(testFile);
+  os::rm(testLink);
+}

Reply via email to