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

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Mar 19 09:27:55 PDT 2021


mstorsjo created this revision.
mstorsjo added a reviewer: curdeius.
mstorsjo requested review of this revision.
Herald added a project: libc++.
Herald added a reviewer: libc++.

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.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98960

Files:
  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


Index: libcxx/test/support/filesystem_test_helper.h
===================================================================
--- libcxx/test/support/filesystem_test_helper.h
+++ libcxx/test/support/filesystem_test_helper.h
@@ -679,21 +679,36 @@
   std::error_code ec;
   const fs::path root("C:\\");
   fs::directory_iterator it(root, ec);
-  if (ec)
+  if (ec) {
+    fprintf(stderr, "Unable to iterate over %s, skipping tests regarding "
+                    "an inaccessible directory\n", root.string().c_str());
     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())
+      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();
-      if (!ent.is_directory())
+      }
+      // Check that it indeed is inaccessible as expected
+      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;
     }
     ++it;
   }
+  fprintf(stderr, "No inaccessible directory \"%s\" found, skipping tests "
+                  "regarding it\n", dir.string().c_str());
   return fs::path();
 }
 
Index: libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.exists/exists.pass.cpp
===================================================================
--- libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.exists/exists.pass.cpp
+++ libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.exists/exists.pass.cpp
@@ -78,7 +78,8 @@
     // 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");
Index: libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.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/class.rec.dir.itr/rec.dir.itr.members/ctor.pass.cpp
@@ -93,7 +93,8 @@
     // 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");
Index: libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/ctor.pass.cpp
===================================================================
--- libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/ctor.pass.cpp
+++ libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/ctor.pass.cpp
@@ -92,7 +92,8 @@
     // 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");
Index: libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/path.pass.cpp
===================================================================
--- libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/path.pass.cpp
+++ libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/path.pass.cpp
@@ -153,7 +153,8 @@
   // 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();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98960.331904.patch
Type: text/x-patch
Size: 4438 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210319/c8be1c39/attachment.bin>


More information about the libcxx-commits mailing list