summaryrefslogtreecommitdiffstats
path: root/llvm/unittests
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/unittests')
-rw-r--r--llvm/unittests/Support/Path.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp
index 210b3a04cb2..11d53c83419 100644
--- a/llvm/unittests/Support/Path.cpp
+++ b/llvm/unittests/Support/Path.cpp
@@ -20,6 +20,10 @@
#include <winerror.h>
#endif
+#ifdef LLVM_ON_UNIX
+#include <sys/stat.h>
+#endif
+
using namespace llvm;
using namespace llvm::sys;
@@ -458,6 +462,26 @@ TEST_F(FileSystemTest, CreateDir) {
errc::file_exists);
ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "foo"));
+#ifdef LLVM_ON_UNIX
+ // Set a 0000 umask so that we can test our directory permissions.
+ mode_t OldUmask = ::umask(0000);
+
+ fs::file_status Status;
+ ASSERT_NO_ERROR(
+ fs::create_directory(Twine(TestDirectory) + "baz500", false,
+ fs::perms::owner_read | fs::perms::owner_exe));
+ ASSERT_NO_ERROR(fs::status(Twine(TestDirectory) + "baz500", Status));
+ ASSERT_EQ(Status.permissions() & fs::perms::all_all,
+ fs::perms::owner_read | fs::perms::owner_exe);
+ ASSERT_NO_ERROR(fs::create_directory(Twine(TestDirectory) + "baz777", false,
+ fs::perms::all_all));
+ ASSERT_NO_ERROR(fs::status(Twine(TestDirectory) + "baz777", Status));
+ ASSERT_EQ(Status.permissions() & fs::perms::all_all, fs::perms::all_all);
+
+ // Restore umask to be safe.
+ ::umask(OldUmask);
+#endif
+
#ifdef LLVM_ON_WIN32
// Prove that create_directories() can handle a pathname > 248 characters,
// which is the documented limit for CreateDirectory().
OpenPOWER on IntegriCloud