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 --- 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 @@ -100,6 +100,18 @@ TEST_CASE(test_assign_propagates_error) { using namespace fs; scoped_test_env env; +#ifdef _WIN32 + const path dir = GetWindowsInaccessibleDir(); + TEST_REQUIRE(!dir.empty()); + const path file = dir / "inaccessible_file"; + 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"); @@ -120,6 +132,7 @@ 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 --- 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 @@ -133,12 +133,21 @@ 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(); + TEST_REQUIRE(!testDir.empty()); + 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 --- 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 @@ -47,9 +47,17 @@ 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(); + TEST_REQUIRE(!inaccessible_dir.empty()); +#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; @@ -90,7 +98,7 @@ TEST_CHECK(ret == ""); // Set the env variable to point to a dir we can't access - PutEnv(TC.name, nested_dir); + PutEnv(TC.name, inaccessible_dir); ec = GetTestEC(); ret = temp_directory_path(ec); TEST_CHECK(ErrorIs(ec, std::errc::permission_denied));