Skip to content

Commit f9ddb81

Browse files
committed
[libcxx] [test] Ifdef out tests that rely on perms::none on directories for triggering errors
On Windows, one can't use perms::none on a directory to trigger failures to read the directory entries. These remaining tests can't use GetWindowsInaccessibleDir() sensibly, e.g. for tests that rely on toggling accessibility back and forth during the test, or where the semantics of the dir provided by GetWindowsInaccessibleDir() doesn't allow for running the ifdeffed tests meaningfully. Differential Revision: https://reviews.llvm.org/D97538
1 parent e657c84 commit f9ddb81

File tree

14 files changed

+82
-25
lines changed

14 files changed

+82
-25
lines changed

libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/refresh.pass.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
// UNSUPPORTED: c++03
1010

11-
// XFAIL: LIBCXX-WINDOWS-FIXME
12-
1311
// The string reported on errors changed, which makes those tests fail when run
1412
// against already-released libc++'s.
1513
// XFAIL: with_system_cxx_lib=macosx10.15
@@ -66,6 +64,9 @@ TEST_CASE(test_refresh_ec_method) {
6664
}
6765
}
6866

67+
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
68+
// Windows doesn't support setting perms::none to trigger failures
69+
// reading directories.
6970
TEST_CASE(refresh_on_file_dne) {
7071
using namespace fs;
7172
scoped_test_env env;
@@ -100,6 +101,7 @@ TEST_CASE(refresh_on_file_dne) {
100101
TEST_CHECK(!ent.exists());
101102
}
102103
}
104+
#endif
103105

104106
void remove_if_exists(const fs::path& p) {
105107
std::error_code ec;
@@ -128,8 +130,10 @@ TEST_CASE(refresh_on_bad_symlink) {
128130

129131
LIBCPP_ONLY(permissions(dir, perms::none));
130132
TEST_CHECK(ent.is_symlink());
133+
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
131134
TEST_CHECK(!ent.is_regular_file());
132135
TEST_CHECK(!ent.exists());
136+
#endif
133137
}
134138
permissions(dir, old_perms);
135139
env.create_file("dir/file", 101);
@@ -147,10 +151,15 @@ TEST_CASE(refresh_on_bad_symlink) {
147151
TEST_CHECK(!ec); // we don't report bad symlinks as an error.
148152

149153
LIBCPP_ONLY(permissions(dir, perms::none));
154+
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
150155
TEST_CHECK(!ent.exists());
156+
#endif
151157
}
152158
}
153159

160+
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
161+
// Windows doesn't support setting perms::none to trigger failures
162+
// reading directories.
154163
TEST_CASE(refresh_cannot_resolve) {
155164
using namespace fs;
156165
scoped_test_env env;
@@ -224,6 +233,7 @@ TEST_CASE(refresh_cannot_resolve) {
224233
TEST_CHECK_NO_THROW(ent_sym2);
225234
}
226235
}
236+
#endif
227237

228238
TEST_CASE(refresh_doesnt_throw_on_dne_but_reports_it) {
229239
using namespace fs;
@@ -271,6 +281,9 @@ TEST_CASE(refresh_doesnt_throw_on_dne_but_reports_it) {
271281
}
272282
}
273283

284+
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
285+
// Windows doesn't support setting perms::none to trigger failures
286+
// reading directories.
274287
TEST_CASE(access_cache_after_refresh_fails) {
275288
using namespace fs;
276289
scoped_test_env env;
@@ -342,5 +355,6 @@ TEST_CASE(access_cache_after_refresh_fails) {
342355
}
343356
#undef CHECK_ACCESS
344357
}
358+
#endif
345359

346360
TEST_SUITE_END()

libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/replace_filename.pass.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
// UNSUPPORTED: c++03
1010

11-
// XFAIL: LIBCXX-WINDOWS-FIXME
12-
1311
// <filesystem>
1412

1513
// class directory_entry
@@ -125,6 +123,9 @@ TEST_CASE(test_replace_filename_calls_refresh) {
125123
}
126124
}
127125

126+
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
127+
// Windows doesn't support setting perms::none to trigger failures
128+
// reading directories.
128129
TEST_CASE(test_replace_filename_propagates_error) {
129130
using namespace fs;
130131
scoped_test_env env;
@@ -167,5 +168,6 @@ TEST_CASE(test_replace_filename_propagates_error) {
167168
TEST_CHECK(ErrorIs(ec, std::errc::permission_denied));
168169
}
169170
}
171+
#endif
170172

171173
TEST_SUITE_END()

libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_size.pass.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
// UNSUPPORTED: c++03
1010

11-
// XFAIL: LIBCXX-WINDOWS-FIXME
12-
1311
// The string reported on errors changed, which makes those tests fail when run
1412
// against already-released libc++'s.
1513
// XFAIL: with_system_cxx_lib=macosx10.15
@@ -126,7 +124,9 @@ TEST_CASE(error_reporting) {
126124
const path sym_out_of_dir = env.create_symlink("dir/file", "sym");
127125
const path sym_in_dir = env.create_symlink("file2", "dir/sym2");
128126

127+
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
129128
const perms old_perms = status(dir).permissions();
129+
#endif
130130

131131
// test a file which doesn't exist
132132
{
@@ -169,6 +169,9 @@ TEST_CASE(error_reporting) {
169169
"directory_entry::file_size");
170170
TEST_CHECK_THROW_RESULT(filesystem_error, Checker, ent.file_size());
171171
}
172+
// Windows doesn't support setting perms::none to trigger failures
173+
// reading directories.
174+
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
172175
// test a file w/o appropriate permissions.
173176
{
174177
directory_entry ent;
@@ -245,6 +248,7 @@ TEST_CASE(error_reporting) {
245248
TEST_CHECK(!ec);
246249
TEST_CHECK_NO_THROW(ent.file_size());
247250
}
251+
#endif
248252
}
249253

250254
TEST_SUITE_END()

libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_type_obs.pass.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
// UNSUPPORTED: c++03
1010

11-
// XFAIL: LIBCXX-WINDOWS-FIXME
12-
1311
// <filesystem>
1412

1513
// class directory_entry
@@ -207,6 +205,9 @@ TEST_CASE(test_with_ec_dne) {
207205
}
208206
}
209207

208+
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
209+
// Windows doesn't support setting perms::none to trigger failures
210+
// reading directories.
210211
TEST_CASE(test_with_ec_cannot_resolve) {
211212
using namespace fs;
212213
using fs::directory_entry;
@@ -269,5 +270,6 @@ TEST_CASE(test_with_ec_cannot_resolve) {
269270
TEST_CHECK(CheckEC(sym_status_ec));
270271
}
271272
}
273+
#endif
272274

273275
TEST_SUITE_END()

libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/hard_link_count.pass.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
// UNSUPPORTED: c++03
1010

11-
// XFAIL: LIBCXX-WINDOWS-FIXME
12-
1311
// The string reported on errors changed, which makes those tests fail when run
1412
// against already-released libc++'s.
1513
// XFAIL: with_system_cxx_lib=macosx10.15
@@ -129,7 +127,9 @@ TEST_CASE(error_reporting) {
129127
const path sym_out_of_dir = env.create_symlink("dir/file", "sym");
130128
const path sym_in_dir = env.create_symlink("file2", "dir/sym2");
131129

130+
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
132131
const perms old_perms = status(dir).permissions();
132+
#endif
133133

134134
// test a file which doesn't exist
135135
{
@@ -173,6 +173,9 @@ TEST_CASE(error_reporting) {
173173
"directory_entry::hard_link_count");
174174
TEST_CHECK_THROW_RESULT(filesystem_error, Checker, ent.hard_link_count());
175175
}
176+
// Windows doesn't support setting perms::none to trigger failures
177+
// reading directories.
178+
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
176179
// test a file w/o appropriate permissions.
177180
{
178181
directory_entry ent;
@@ -250,6 +253,7 @@ TEST_CASE(error_reporting) {
250253
TEST_CHECK(!ec);
251254
TEST_CHECK_NO_THROW(ent.hard_link_count());
252255
}
256+
#endif
253257
}
254258

255259
TEST_SUITE_END()

libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/last_write_time.pass.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
// UNSUPPORTED: c++03
1010

11-
// XFAIL: LIBCXX-WINDOWS-FIXME
12-
1311
// The string reported on errors changed, which makes those tests fail when run
1412
// against already-released libc++'s.
1513
// XFAIL: with_system_cxx_lib=macosx10.15
@@ -98,7 +96,9 @@ TEST_CASE(error_reporting) {
9896
const path sym_out_of_dir = env.create_symlink("dir/file", "sym");
9997
const path sym_in_dir = env.create_symlink("file2", "dir/sym2");
10098

99+
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
101100
const perms old_perms = status(dir).permissions();
101+
#endif
102102

103103
// test a file which doesn't exist
104104
{
@@ -141,6 +141,9 @@ TEST_CASE(error_reporting) {
141141
"directory_entry::last_write_time");
142142
TEST_CHECK_THROW_RESULT(filesystem_error, Checker, ent.last_write_time());
143143
}
144+
// Windows doesn't support setting perms::none to trigger failures
145+
// reading directories.
146+
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
144147
// test a file w/o appropriate permissions.
145148
{
146149
directory_entry ent;
@@ -218,6 +221,7 @@ TEST_CASE(error_reporting) {
218221
TEST_CHECK(!ec);
219222
TEST_CHECK_NO_THROW(ent.last_write_time());
220223
}
224+
#endif
221225
}
222226

223227
TEST_SUITE_END()

libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
// UNSUPPORTED: c++03
1010

11-
// XFAIL: LIBCXX-WINDOWS-FIXME
12-
1311
// <filesystem>
1412

1513
// class recursive_directory_iterator
@@ -142,6 +140,9 @@ TEST_CASE(test_follow_symlinks)
142140
TEST_CHECK(it == endIt);
143141
}
144142

143+
// Windows doesn't support setting perms::none to trigger failures
144+
// reading directories.
145+
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
145146
TEST_CASE(access_denied_on_recursion_test_case)
146147
{
147148
using namespace fs;
@@ -492,6 +493,7 @@ TEST_CASE(test_PR35078_with_symlink_file)
492493
}
493494
}
494495
}
496+
#endif
495497

496498

497499
TEST_SUITE_END()

libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_directory/create_directory_with_attributes.pass.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
// UNSUPPORTED: c++03
1010

11-
// XFAIL: LIBCXX-WINDOWS-FIXME
12-
1311
// This test requires the dylib support introduced in D92769.
1412
// XFAIL: with_system_cxx_lib=macosx10.15
1513

@@ -60,6 +58,8 @@ TEST_CASE(create_existing_directory)
6058
TEST_CHECK(fs::create_directory(dir, dir2) == false);
6159
}
6260

61+
// Windows doesn't have the concept of perms::none on directories.
62+
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
6363
TEST_CASE(create_directory_one_level)
6464
{
6565
scoped_test_env env;
@@ -79,6 +79,7 @@ TEST_CASE(create_directory_one_level)
7979
auto st = status(dir);
8080
TEST_CHECK(st.permissions() == perms::none);
8181
}
82+
#endif
8283

8384
TEST_CASE(create_directory_multi_level)
8485
{

libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,9 @@ TEST_CASE(test_value_on_failure)
573573
TEST_CHECK(ErrorIs(ec, std::errc::no_such_file_or_directory));
574574
}
575575

576+
// Windows doesn't support setting perms::none to trigger failures
577+
// reading directories.
578+
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
576579
TEST_CASE(test_exists_fails)
577580
{
578581
scoped_test_env env;
@@ -588,5 +591,6 @@ TEST_CASE(test_exists_fails)
588591
"last_write_time");
589592
TEST_CHECK_THROW_RESULT(filesystem_error, Checker, last_write_time(file));
590593
}
594+
#endif
591595

592596
TEST_SUITE_END()

libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.remove/remove.pass.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
// UNSUPPORTED: c++03
1010

11-
// XFAIL: LIBCXX-WINDOWS-FIXME
12-
1311
// <filesystem>
1412

1513
// bool remove(const path& p);
@@ -62,7 +60,13 @@ TEST_CASE(test_error_reporting)
6260
permissions(bad_perms_dir, perms::none);
6361
const path testCases[] = {
6462
non_empty_dir,
63+
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
64+
// Windows doesn't support setting perms::none on a directory to
65+
// stop it from being accessed. And a fictional file under
66+
// GetWindowsInaccessibleDir() doesn't cause fs::remove() to report
67+
// errors, it just returns false cleanly.
6568
file_in_bad_dir,
69+
#endif
6670
};
6771
for (auto& p : testCases) {
6872
std::error_code ec;

libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.remove_all/remove_all.pass.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
// UNSUPPORTED: c++03
1010

11-
// XFAIL: LIBCXX-WINDOWS-FIXME
12-
1311
// <filesystem>
1412

1513
// uintmax_t remove_all(const path& p);
@@ -38,6 +36,10 @@ TEST_CASE(test_signatures)
3836

3937
TEST_CASE(test_error_reporting)
4038
{
39+
scoped_test_env env;
40+
// Windows doesn't support setting perms::none to trigger failures
41+
// reading directories.
42+
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
4143
auto checkThrow = [](path const& f, const std::error_code& ec)
4244
{
4345
#ifndef TEST_HAS_NO_EXCEPTIONS
@@ -54,7 +56,6 @@ TEST_CASE(test_error_reporting)
5456
return true;
5557
#endif
5658
};
57-
scoped_test_env env;
5859
const path non_empty_dir = env.create_dir("dir");
5960
env.create_file(non_empty_dir / "file1", 42);
6061
const path bad_perms_dir = env.create_dir("bad_dir");
@@ -74,6 +75,7 @@ TEST_CASE(test_error_reporting)
7475
TEST_CHECK(ec);
7576
TEST_CHECK(checkThrow(p, ec));
7677
}
78+
#endif
7779

7880
// PR#35780
7981
const path testCasesNonexistant[] = {

0 commit comments

Comments
 (0)