Thread premissions through sys::fs::create_director{y|ies}
llvm-svn: 244268
This commit is contained in:
@@ -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().
|
||||
|
||||
Reference in New Issue
Block a user