[libcxx-commits] [PATCH] D98443: [libcxx] [test] Use GetWindowsInaccessibleDir() in a couple more tests
Martin Storsjö via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Mar 11 12:08:53 PST 2021
mstorsjo updated this revision to Diff 330047.
mstorsjo added a comment.
Simplify the modification in temp_directory_path
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D98443/new/
https://reviews.llvm.org/D98443
Files:
libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/assign.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.temp_dir_path/temp_directory_path.pass.cpp
Index: libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp
===================================================================
--- libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp
+++ 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));
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
@@ -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.
Index: libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/assign.pass.cpp
===================================================================
--- libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/assign.pass.cpp
+++ 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();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98443.330047.patch
Type: text/x-patch
Size: 3892 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210311/e62e5b9f/attachment.bin>
More information about the libcxx-commits
mailing list