[libcxx-commits] [libcxx] 1f1f8e2 - [libcxx] [test] Use GetWindowsInaccessibleDir() in a couple more tests
Martin Storsjö via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Apr 9 11:25:02 PDT 2021
Author: Martin Storsjö
Date: 2021-04-09T21:24:34+03:00
New Revision: 1f1f8e239bb32fc19990b652e0d0becff312f4aa
URL: https://github.com/llvm/llvm-project/commit/1f1f8e239bb32fc19990b652e0d0becff312f4aa
DIFF: https://github.com/llvm/llvm-project/commit/1f1f8e239bb32fc19990b652e0d0becff312f4aa.diff
LOG: [libcxx] [test] Use GetWindowsInaccessibleDir() in a couple more tests
Differential Revision: https://reviews.llvm.org/D98443
Added:
Modified:
libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/assign.pass.cpp
libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/ctor.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/assign.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/assign.pass.cpp
index 13eb08228582..1ab9a919fc20 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/assign.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/assign.pass.cpp
@@ -8,8 +8,6 @@
// UNSUPPORTED: c++03
-// XFAIL: LIBCXX-WINDOWS-FIXME
-
// <filesystem>
// class directory_entry
@@ -102,6 +100,24 @@ TEST_CASE(test_assign_calls_refresh) {
TEST_CASE(test_assign_propagates_error) {
using namespace fs;
scoped_test_env env;
+#ifdef _WIN32
+ // Windows doesn't support setting perms::none to trigger failures
+ // reading directories; test using a special inaccessible directory
+ // instead.
+ const path dir = GetWindowsInaccessibleDir();
+ if (dir.empty())
+ TEST_UNSUPPORTED();
+ const path file = dir / "inaccessible_file";
+ // We can't create files in the inaccessible directory, so this doesn't
+ // test exactly the same as the code below.
+ const path sym_out_of_dir = env.create_symlink(file, "sym");
+ {
+ directory_entry ent;
+ std::error_code ec = GetTestEC();
+ ent.assign(file, ec);
+ TEST_CHECK(ErrorIs(ec, std::errc::no_such_file_or_directory));
+ }
+#else
const path dir = env.create_dir("dir");
const path file = env.create_file("dir/file", 42);
const path sym_out_of_dir = env.create_symlink("dir/file", "sym");
@@ -122,6 +138,7 @@ TEST_CASE(test_assign_propagates_error) {
ent.assign(sym_in_dir, ec);
TEST_CHECK(ErrorIs(ec, std::errc::permission_denied));
}
+#endif
{
directory_entry ent;
std::error_code ec = GetTestEC();
diff --git a/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/ctor.pass.cpp b/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/ctor.pass.cpp
index c4856b61c06a..5a18c4654689 100644
--- a/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/ctor.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/ctor.pass.cpp
@@ -134,12 +134,22 @@ TEST_CASE(access_denied_test_case)
TEST_CASE(access_denied_to_file_test_case)
{
using namespace fs;
+#ifdef _WIN32
+ // Windows doesn't support setting perms::none to trigger failures
+ // reading directories; test using a special inaccessible directory
+ // instead.
+ const path testDir = GetWindowsInaccessibleDir();
+ if (testDir.empty())
+ TEST_UNSUPPORTED();
+ path const testFile = testDir / "inaccessible_file";
+#else
scoped_test_env env;
path const testFile = env.make_env_path("file1");
env.create_file(testFile, 42);
// Change the permissions so we can no longer iterate
permissions(testFile, perms::none);
+#endif
// Check that the construction fails when skip_permissions_denied is
// not given.
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp
index 3cc60a26092f..0b5018dea164 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp
@@ -8,8 +8,6 @@
// UNSUPPORTED: c++03
-// XFAIL: LIBCXX-WINDOWS-FIXME
-
// <filesystem>
// path temp_directory_path();
@@ -49,9 +47,16 @@ TEST_CASE(basic_tests)
scoped_test_env env;
const path dne = env.make_env_path("dne");
const path file = env.create_file("file", 42);
+#ifdef _WIN32
+ // Windows doesn't support setting perms::none to trigger failures
+ // reading directories; test using a special inaccessible directory
+ // instead.
+ const path inaccessible_dir = GetWindowsInaccessibleDir();
+#else
const path dir_perms = env.create_dir("bad_perms_dir");
- const path nested_dir = env.create_dir("bad_perms_dir/nested");
+ const path inaccessible_dir = env.create_dir("bad_perms_dir/nested");
permissions(dir_perms, perms::none);
+#endif
LIBCPP_ONLY(const std::errc expect_errc = std::errc::not_a_directory);
struct TestCase {
std::string name;
@@ -105,12 +110,14 @@ TEST_CASE(basic_tests)
TEST_CHECK(ec);
TEST_CHECK(ret == "");
- // Set the env variable to point to a dir we can't access
- PutEnv(TC.name, nested_dir);
- ec = GetTestEC();
- ret = temp_directory_path(ec);
- TEST_CHECK(ErrorIs(ec, std::errc::permission_denied));
- TEST_CHECK(ret == "");
+ if (!inaccessible_dir.empty()) {
+ // Set the env variable to point to a dir we can't access
+ PutEnv(TC.name, inaccessible_dir);
+ ec = GetTestEC();
+ ret = temp_directory_path(ec);
+ TEST_CHECK(ErrorIs(ec, std::errc::permission_denied));
+ TEST_CHECK(ret == "");
+ }
// Set the env variable to point to a non-existent dir
PutEnv(TC.name, TC.p / "does_not_exist");
More information about the libcxx-commits
mailing list