[libcxx-commits] [libcxx] b166441 - [libcxx] [test] Use GetWindowsInaccessibleDir() instead of dirs with perms::none in fs.op.is_*

Martin Storsjö via libcxx-commits libcxx-commits at lists.llvm.org
Fri Apr 9 11:25:01 PDT 2021


Author: Martin Storsjö
Date: 2021-04-09T21:24:34+03:00
New Revision: b166441bbe7f33e80e70c49feb18285b52ecec3d

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

LOG: [libcxx] [test] Use GetWindowsInaccessibleDir() instead of dirs with perms::none in fs.op.is_*

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

Added: 
    

Modified: 
    libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_block_file/is_block_file.pass.cpp
    libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_char_file/is_character_file.pass.cpp
    libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_directory/is_directory.pass.cpp
    libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_empty/is_empty.pass.cpp
    libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_fifo/is_fifo.pass.cpp
    libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_other/is_other.pass.cpp
    libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_regular_file/is_regular_file.pass.cpp
    libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_socket/is_socket.pass.cpp
    libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_symlink/is_symlink.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_block_file/is_block_file.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_block_file/is_block_file.pass.cpp
index 3a5f9458b7d5..d28898472a94 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_block_file/is_block_file.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_block_file/is_block_file.pass.cpp
@@ -8,8 +8,6 @@
 
 // UNSUPPORTED: c++03
 
-// XFAIL: LIBCXX-WINDOWS-FIXME
-
 // <filesystem>
 
 // bool is_block_file(file_status s) noexcept
@@ -72,15 +70,24 @@ TEST_CASE(test_exist_not_found)
 TEST_CASE(test_is_block_file_fails)
 {
     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 p = GetWindowsInaccessibleDir();
+    if (p.empty())
+        TEST_UNSUPPORTED();
+#else
     const path dir = env.create_dir("dir");
-    const path file = env.create_file("dir/file", 42);
+    const path p = env.create_file("dir/file", 42);
     permissions(dir, perms::none);
+#endif
 
     std::error_code ec;
-    TEST_CHECK(is_block_file(file, ec) == false);
+    TEST_CHECK(is_block_file(p, ec) == false);
     TEST_CHECK(ec);
 
-    TEST_CHECK_THROW(filesystem_error, is_block_file(file));
+    TEST_CHECK_THROW(filesystem_error, is_block_file(p));
 }
 
 TEST_SUITE_END()

diff  --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_char_file/is_character_file.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_char_file/is_character_file.pass.cpp
index 99ccf2b886ec..738e06cc1ad5 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_char_file/is_character_file.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_char_file/is_character_file.pass.cpp
@@ -8,8 +8,6 @@
 
 // UNSUPPORTED: c++03
 
-// XFAIL: LIBCXX-WINDOWS-FIXME
-
 // <filesystem>
 
 // bool is_character_file(file_status s) noexcept
@@ -72,15 +70,24 @@ TEST_CASE(test_exist_not_found)
 TEST_CASE(test_is_character_file_fails)
 {
     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 p = GetWindowsInaccessibleDir();
+    if (p.empty())
+        TEST_UNSUPPORTED();
+#else
     const path dir = env.create_dir("dir");
-    const path file = env.create_file("dir/file", 42);
+    const path p = env.create_file("dir/file", 42);
     permissions(dir, perms::none);
+#endif
 
     std::error_code ec;
-    TEST_CHECK(is_character_file(file, ec) == false);
+    TEST_CHECK(is_character_file(p, ec) == false);
     TEST_CHECK(ec);
 
-    TEST_CHECK_THROW(filesystem_error, is_character_file(file));
+    TEST_CHECK_THROW(filesystem_error, is_character_file(p));
 }
 
 TEST_SUITE_END()

diff  --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_directory/is_directory.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_directory/is_directory.pass.cpp
index e24f19338504..8b1e41ef7f1b 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_directory/is_directory.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_directory/is_directory.pass.cpp
@@ -8,8 +8,6 @@
 
 // UNSUPPORTED: c++03
 
-// XFAIL: LIBCXX-WINDOWS-FIXME
-
 // <filesystem>
 
 // bool is_directory(file_status s) noexcept
@@ -80,15 +78,24 @@ TEST_CASE(static_env_test)
 TEST_CASE(test_is_directory_fails)
 {
     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 p = GetWindowsInaccessibleDir();
+    if (p.empty())
+        TEST_UNSUPPORTED();
+#else
     const path dir = env.create_dir("dir");
-    const path dir2 = env.create_dir("dir/dir2");
+    const path p = env.create_dir("dir/dir2");
     permissions(dir, perms::none);
+#endif
 
     std::error_code ec;
-    TEST_CHECK(is_directory(dir2, ec) == false);
+    TEST_CHECK(is_directory(p, ec) == false);
     TEST_CHECK(ec);
 
-    TEST_CHECK_THROW(filesystem_error, is_directory(dir2));
+    TEST_CHECK_THROW(filesystem_error, is_directory(p));
 }
 
 TEST_SUITE_END()

diff  --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_empty/is_empty.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_empty/is_empty.pass.cpp
index 6b051d5d3ae4..8478037a03c6 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_empty/is_empty.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_empty/is_empty.pass.cpp
@@ -8,8 +8,6 @@
 
 // UNSUPPORTED: c++03
 
-// XFAIL: LIBCXX-WINDOWS-FIXME
-
 // <filesystem>
 
 // bool is_empty(path const& p);
@@ -70,23 +68,41 @@ TEST_CASE(test_is_empty_file)
 TEST_CASE(test_is_empty_fails)
 {
     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 p = GetWindowsInaccessibleDir();
+    if (p.empty())
+        TEST_UNSUPPORTED();
+#else
     const path dir = env.create_dir("dir");
-    const path dir2 = env.create_dir("dir/dir2");
+    const path p = env.create_dir("dir/dir2");
     permissions(dir, perms::none);
+#endif
 
     std::error_code ec;
-    TEST_CHECK(is_empty(dir2, ec) == false);
+    TEST_CHECK(is_empty(p, ec) == false);
     TEST_CHECK(ec);
 
-    TEST_CHECK_THROW(filesystem_error, is_empty(dir2));
+    TEST_CHECK_THROW(filesystem_error, is_empty(p));
 }
 
 TEST_CASE(test_directory_access_denied)
 {
     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();
+#else
     const path dir = env.create_dir("dir");
     const path file1 = env.create_file("dir/file", 42);
     permissions(dir, perms::none);
+#endif
 
     std::error_code ec = GetTestEC();
     TEST_CHECK(is_empty(dir, ec) == false);

diff  --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_fifo/is_fifo.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_fifo/is_fifo.pass.cpp
index c7d11e8017b5..0169fed28f54 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_fifo/is_fifo.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_fifo/is_fifo.pass.cpp
@@ -8,8 +8,6 @@
 
 // UNSUPPORTED: c++03
 
-// XFAIL: LIBCXX-WINDOWS-FIXME
-
 // <filesystem>
 
 // bool is_fifo(file_status s) noexcept
@@ -72,15 +70,24 @@ TEST_CASE(test_exist_not_found)
 TEST_CASE(test_is_fifo_fails)
 {
     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 p = GetWindowsInaccessibleDir();
+    if (p.empty())
+        TEST_UNSUPPORTED();
+#else
     const path dir = env.create_dir("dir");
-    const path file = env.create_file("dir/file", 42);
+    const path p = env.create_file("dir/file", 42);
     permissions(dir, perms::none);
+#endif
 
     std::error_code ec;
-    TEST_CHECK(is_fifo(file, ec) == false);
+    TEST_CHECK(is_fifo(p, ec) == false);
     TEST_CHECK(ec);
 
-    TEST_CHECK_THROW(filesystem_error, is_fifo(file));
+    TEST_CHECK_THROW(filesystem_error, is_fifo(p));
 }
 
 TEST_SUITE_END()

diff  --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_other/is_other.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_other/is_other.pass.cpp
index a3e812d82399..f84eb7dd32d8 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_other/is_other.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_other/is_other.pass.cpp
@@ -8,8 +8,6 @@
 
 // UNSUPPORTED: c++03
 
-// XFAIL: LIBCXX-WINDOWS-FIXME
-
 // <filesystem>
 
 // bool is_other(file_status s) noexcept
@@ -72,15 +70,24 @@ TEST_CASE(test_exist_not_found)
 TEST_CASE(test_is_other_fails)
 {
     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 p = GetWindowsInaccessibleDir();
+    if (p.empty())
+        TEST_UNSUPPORTED();
+#else
     const path dir = env.create_dir("dir");
-    const path file = env.create_file("dir/file", 42);
+    const path p = env.create_file("dir/file", 42);
     permissions(dir, perms::none);
+#endif
 
     std::error_code ec;
-    TEST_CHECK(is_other(file, ec) == false);
+    TEST_CHECK(is_other(p, ec) == false);
     TEST_CHECK(ec);
 
-    TEST_CHECK_THROW(filesystem_error, is_other(file));
+    TEST_CHECK_THROW(filesystem_error, is_other(p));
 }
 
 TEST_SUITE_END()

diff  --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_regular_file/is_regular_file.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_regular_file/is_regular_file.pass.cpp
index 0635c98abb08..441f15a9c5d1 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_regular_file/is_regular_file.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_regular_file/is_regular_file.pass.cpp
@@ -8,8 +8,6 @@
 
 // UNSUPPORTED: c++03
 
-// XFAIL: LIBCXX-WINDOWS-FIXME
-
 // <filesystem>
 
 // bool is_regular_file(file_status s) noexcept
@@ -75,15 +73,24 @@ TEST_CASE(test_exist_not_found)
 TEST_CASE(test_is_regular_file_fails)
 {
     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 p = GetWindowsInaccessibleDir();
+    if (p.empty())
+        TEST_UNSUPPORTED();
+#else
     const path dir = env.create_dir("dir");
-    const path file = env.create_file("dir/file", 42);
+    const path p = env.create_file("dir/file", 42);
     permissions(dir, perms::none);
+#endif
 
     std::error_code ec;
-    TEST_CHECK(is_regular_file(file, ec) == false);
+    TEST_CHECK(is_regular_file(p, ec) == false);
     TEST_CHECK(ec);
 
-    TEST_CHECK_THROW(filesystem_error, is_regular_file(file));
+    TEST_CHECK_THROW(filesystem_error, is_regular_file(p));
 }
 
 TEST_SUITE_END()

diff  --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_socket/is_socket.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_socket/is_socket.pass.cpp
index b45e8f07086f..21aa53709434 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_socket/is_socket.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_socket/is_socket.pass.cpp
@@ -8,8 +8,6 @@
 
 // UNSUPPORTED: c++03
 
-// XFAIL: LIBCXX-WINDOWS-FIXME
-
 // <filesystem>
 
 // bool is_socket(file_status s) noexcept
@@ -72,15 +70,24 @@ TEST_CASE(test_exist_not_found)
 TEST_CASE(test_is_socket_fails)
 {
     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 p = GetWindowsInaccessibleDir();
+    if (p.empty())
+        TEST_UNSUPPORTED();
+#else
     const path dir = env.create_dir("dir");
-    const path file = env.create_file("dir/file", 42);
+    const path p = env.create_file("dir/file", 42);
     permissions(dir, perms::none);
+#endif
 
     std::error_code ec;
-    TEST_CHECK(is_socket(file, ec) == false);
+    TEST_CHECK(is_socket(p, ec) == false);
     TEST_CHECK(ec);
 
-    TEST_CHECK_THROW(filesystem_error, is_socket(file));
+    TEST_CHECK_THROW(filesystem_error, is_socket(p));
 }
 
 TEST_SUITE_END()

diff  --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_symlink/is_symlink.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_symlink/is_symlink.pass.cpp
index a0f0468d2e23..d8ec533058c7 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_symlink/is_symlink.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_symlink/is_symlink.pass.cpp
@@ -8,8 +8,6 @@
 
 // UNSUPPORTED: c++03
 
-// XFAIL: LIBCXX-WINDOWS-FIXME
-
 // <filesystem>
 
 // bool is_symlink(file_status s) noexcept
@@ -94,15 +92,24 @@ TEST_CASE(test_exist_not_found)
 TEST_CASE(test_is_symlink_fails)
 {
     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 p = GetWindowsInaccessibleDir();
+    if (p.empty())
+        TEST_UNSUPPORTED();
+#else
     const path dir = env.create_dir("dir");
-    const path file = env.create_file("dir/file", 42);
+    const path p = env.create_file("dir/file", 42);
     permissions(dir, perms::none);
+#endif
 
     std::error_code ec;
-    TEST_CHECK(is_symlink(file, ec) == false);
+    TEST_CHECK(is_symlink(p, ec) == false);
     TEST_CHECK(ec);
 
-    TEST_CHECK_THROW(filesystem_error, is_symlink(file));
+    TEST_CHECK_THROW(filesystem_error, is_symlink(p));
 }
 
 TEST_SUITE_END()


        


More information about the libcxx-commits mailing list