You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2017/07/11 01:38:55 UTC

[09/50] mesos git commit: Windows: Added long path test.

Windows: Added long path test.

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


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

Branch: refs/heads/master
Commit: cabb64764e87d839bbfc86f053f196678cba669c
Parents: 4bfc99c
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Tue Jun 27 16:29:49 2017 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Mon Jul 10 17:15:32 2017 -0700

----------------------------------------------------------------------
 3rdparty/stout/tests/os/filesystem_tests.cpp | 29 +++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/cabb6476/3rdparty/stout/tests/os/filesystem_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/tests/os/filesystem_tests.cpp b/3rdparty/stout/tests/os/filesystem_tests.cpp
index ee5a1a1..f385d35 100644
--- a/3rdparty/stout/tests/os/filesystem_tests.cpp
+++ b/3rdparty/stout/tests/os/filesystem_tests.cpp
@@ -22,6 +22,7 @@
 #include <stout/try.hpp>
 #include <stout/uuid.hpp>
 
+#include <stout/os/access.hpp>
 #include <stout/os/find.hpp>
 #include <stout/os/getcwd.hpp>
 #include <stout/os/int_fd.hpp>
@@ -179,6 +180,30 @@ TEST_F(FsTest, Touch)
 }
 
 
+#ifdef __WINDOWS__
+// This test attempts to perform some basic file operations on a file
+// with an absolute path longer than the `MAX_PATH`.
+TEST_F(FsTest, LongPath)
+{
+  string testdir = os::getcwd();
+  while (testdir.length() <= MAX_PATH)
+  {
+    testdir = path::join(testdir, UUID::random().toString());
+  }
+  ASSERT_TRUE(testdir.length() > MAX_PATH);
+
+  ASSERT_SOME(os::mkdir(testdir));
+
+  const string testfile = path::join(testdir, "file.txt");
+
+  ASSERT_SOME(os::touch(testfile));
+  EXPECT_TRUE(os::exists(testfile));
+  EXPECT_SOME_TRUE(os::access(testfile, R_OK | W_OK));
+  EXPECT_SOME_EQ(testfile, os::realpath(testfile));
+}
+#endif // __WINDOWS__
+
+
 TEST_F(FsTest, SYMLINK_Symlink)
 {
   const string temp_path = os::getcwd();
@@ -387,8 +412,8 @@ TEST_F(FsTest, Close)
 #ifdef __WINDOWS__
   // Open a file with the traditional Windows `HANDLE` API, then verify that
   // writing to that `HANDLE` succeeds before we close it, and fails after.
-  const HANDLE open_valid_handle = CreateFile(
-      testfile.c_str(),
+  const HANDLE open_valid_handle = CreateFileW(
+      wide_stringify(testfile).data(),
       FILE_APPEND_DATA,
       0,                     // No sharing mode.
       nullptr,               // Default security.