[libcxx-commits] [libcxx] a9a7498 - [libcxx] [test] Allow C:\System Volume Information to be missing

Martin Storsjö via libcxx-commits libcxx-commits at lists.llvm.org
Tue Apr 6 10:58:43 PDT 2021


Author: Martin Storsjö
Date: 2021-04-06T20:55:18+03:00
New Revision: a9a7498b3f25750608ae07eb009a4091cbe9060f

URL: https://github.com/llvm/llvm-project/commit/a9a7498b3f25750608ae07eb009a4091cbe9060f
DIFF: https://github.com/llvm/llvm-project/commit/a9a7498b3f25750608ae07eb009a4091cbe9060f.diff

LOG: [libcxx] [test] Allow C:\System Volume Information to be missing

If running in a Windows Container, there is no such directory at all.

If running from within bash on Windows Server, the directory seems to
be fully accessible. (The mechanics of this isn't fully understood, and
it doesn't seem to happen on desktop versions.)

If the directory isn't available with the expected behaviour, mark those
individual tests as unsupported. (The test as a whole is considered to
pass, but the unsupported test is mentioned in a test summary printed on
stdout.)

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

Added: 
    

Modified: 
    libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/path.pass.cpp
    libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/ctor.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.exists/exists.pass.cpp
    libcxx/test/support/filesystem_test_helper.h

Removed: 
    


################################################################################
diff  --git a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/path.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/path.pass.cpp
index f91d87e9b6d4a..19148e7c779de 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/path.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/path.pass.cpp
@@ -8,8 +8,6 @@
 
 // UNSUPPORTED: c++03
 
-// XFAIL: LIBCXX-WINDOWS-FIXME
-
 // <filesystem>
 
 // class directory_entry
@@ -155,7 +153,8 @@ TEST_CASE(path_ctor_cannot_resolve) {
   // reading directories; test using a special inaccessible directory
   // instead.
   const path dir = GetWindowsInaccessibleDir();
-  TEST_REQUIRE(!dir.empty());
+  if (dir.empty())
+    TEST_UNSUPPORTED();
   const path file = dir / "file";
   {
     std::error_code ec = GetTestEC();

diff  --git a/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/ctor.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/ctor.pass.cpp
index 306b65267aca0..4ab9a2dea3360 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/ctor.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/ctor.pass.cpp
@@ -8,8 +8,6 @@
 
 // UNSUPPORTED: c++03
 
-// XFAIL: LIBCXX-WINDOWS-FIXME
-
 // <filesystem>
 
 // class directory_iterator
@@ -94,7 +92,8 @@ TEST_CASE(access_denied_test_case)
     // reading directories; test using a special inaccessible directory
     // instead.
     const path testDir = GetWindowsInaccessibleDir();
-    TEST_REQUIRE(!testDir.empty());
+    if (testDir.empty())
+        TEST_UNSUPPORTED();
 #else
     scoped_test_env env;
     path const testDir = env.make_env_path("dir1");

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 4b28130a85d07..c4856b61c06a7 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
@@ -8,8 +8,6 @@
 
 // UNSUPPORTED: c++03
 
-// XFAIL: LIBCXX-WINDOWS-FIXME
-
 // <filesystem>
 
 // class directory_iterator
@@ -95,7 +93,8 @@ TEST_CASE(access_denied_test_case)
     // reading directories; test using a special inaccessible directory
     // instead.
     const path testDir = GetWindowsInaccessibleDir();
-    TEST_REQUIRE(!testDir.empty());
+    if (testDir.empty())
+        TEST_UNSUPPORTED();
 #else
     scoped_test_env env;
     path const testDir = env.make_env_path("dir1");

diff  --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.exists/exists.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.exists/exists.pass.cpp
index fd3a63b0eaeaf..13e8b95d1e540 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.exists/exists.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.exists/exists.pass.cpp
@@ -8,8 +8,6 @@
 
 // UNSUPPORTED: c++03
 
-// XFAIL: LIBCXX-WINDOWS-FIXME
-
 // <filesystem>
 
 // bool exists(file_status s) noexcept
@@ -91,7 +89,8 @@ TEST_CASE(test_exists_fails)
     // reading directories; test using a special inaccessible directory
     // instead.
     const path p = GetWindowsInaccessibleDir();
-    TEST_REQUIRE(!p.empty());
+    if (p.empty())
+        TEST_UNSUPPORTED();
 #else
     scoped_test_env env;
     const path dir = env.create_dir("dir");

diff  --git a/libcxx/test/support/filesystem_test_helper.h b/libcxx/test/support/filesystem_test_helper.h
index e87c43b9ea09b..1e102f3f53100 100644
--- a/libcxx/test/support/filesystem_test_helper.h
+++ b/libcxx/test/support/filesystem_test_helper.h
@@ -678,22 +678,28 @@ inline fs::path GetWindowsInaccessibleDir() {
   const fs::path dir("C:\\System Volume Information");
   std::error_code ec;
   const fs::path root("C:\\");
-  fs::directory_iterator it(root, ec);
-  if (ec)
-    return fs::path();
-  const fs::directory_iterator endIt{};
-  while (it != endIt) {
-    const fs::directory_entry &ent = *it;
-    if (ent == dir) {
-      // Basic sanity checks on the directory_entry
-      if (!ent.exists())
-        return fs::path();
-      if (!ent.is_directory())
-        return fs::path();
-      return ent;
+  for (const auto &ent : fs::directory_iterator(root, ec)) {
+    if (ent != dir)
+      continue;
+    // Basic sanity checks on the directory_entry
+    if (!ent.exists() || !ent.is_directory()) {
+      fprintf(stderr, "The expected inaccessible directory \"%s\" was found "
+                      "but doesn't behave as expected, skipping tests "
+                      "regarding it\n", dir.string().c_str());
+      return fs::path();
     }
-    ++it;
+    // Check that it indeed is inaccessible as expected
+    (void)fs::exists(ent, ec);
+    if (!ec) {
+      fprintf(stderr, "The expected inaccessible directory \"%s\" was found "
+                      "but seems to be accessible, skipping tests "
+                      "regarding it\n", dir.string().c_str());
+      return fs::path();
+    }
+    return ent;
   }
+  fprintf(stderr, "No inaccessible directory \"%s\" found, skipping tests "
+                  "regarding it\n", dir.string().c_str());
   return fs::path();
 }
 


        


More information about the libcxx-commits mailing list