[libcxx] [test] Use GetWindowsInaccessibleDir() in a couple more tests

Differential Revision: https://reviews.llvm.org/D98443

GitOrigin-RevId: 1f1f8e239bb32fc19990b652e0d0becff312f4aa
diff --git a/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/assign.pass.cpp b/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/assign.pass.cpp
index 13eb082..1ab9a91 100644
--- a/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/assign.pass.cpp
+++ b/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_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 @@
     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/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/ctor.pass.cpp b/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/ctor.pass.cpp
index c4856b6..5a18c46 100644
--- a/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/ctor.pass.cpp
+++ b/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/ctor.pass.cpp
@@ -134,12 +134,22 @@
 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/test/std/input.output/filesystems/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp b/test/std/input.output/filesystems/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp
index 3cc60a2..0b5018d 100644
--- a/test/std/input.output/filesystems/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp
+++ b/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 @@
     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_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");