diff options
author | Eric Fiselier <eric@efcs.ca> | 2016-06-17 20:54:25 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2016-06-17 20:54:25 +0000 |
commit | 34ecebcb230ee79f82cb0606367123c557a2fc76 (patch) | |
tree | 035b698ef307b35f1161dacc8212a48eb74467df /libcxx/test/std/experimental/filesystem | |
parent | 1afc1de4064a73efc04b91ecb2c3dda7e6bb9bef (diff) | |
download | bcm5719-llvm-34ecebcb230ee79f82cb0606367123c557a2fc76.tar.gz bcm5719-llvm-34ecebcb230ee79f82cb0606367123c557a2fc76.zip |
Respect the processes umask in the create_directory test
llvm-svn: 273048
Diffstat (limited to 'libcxx/test/std/experimental/filesystem')
-rw-r--r-- | libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_directory/create_directory.pass.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_directory/create_directory.pass.cpp b/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_directory/create_directory.pass.cpp index 6a7b8453801..2381936c6d8 100644 --- a/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_directory/create_directory.pass.cpp +++ b/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_directory/create_directory.pass.cpp @@ -26,9 +26,18 @@ #include "rapid-cxx-test.hpp" #include "filesystem_test_helper.hpp" +#include <sys/types.h> +#include <sys/stat.h> + using namespace std::experimental::filesystem; namespace fs = std::experimental::filesystem; +fs::perms read_umask() { + mode_t old_mask = umask(0); + umask(old_mask); // reset the mask to the old value. + return static_cast<fs::perms>(old_mask); +} + TEST_SUITE(filesystem_create_directory_test_suite) TEST_CASE(test_signatures) @@ -68,15 +77,8 @@ TEST_CASE(create_directory_one_level) TEST_CHECK(is_directory(dir)); auto st = status(dir); - perms owner_perms = perms::owner_all; - perms gperms = perms::group_all; - perms other_perms = perms::others_read | perms::others_exec; -#if defined(__APPLE__) || defined(__FreeBSD__) - gperms = perms::group_read | perms::group_exec; -#endif - TEST_CHECK((st.permissions() & perms::owner_all) == owner_perms); - TEST_CHECK((st.permissions() & perms::group_all) == gperms); - TEST_CHECK((st.permissions() & perms::others_all) == other_perms); + const perms expect_perms = perms::all & ~(read_umask()); + TEST_CHECK((st.permissions() & perms::all) == expect_perms); } TEST_CASE(create_directory_multi_level) |