forked from OSchip/llvm-project
[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
This commit is contained in:
parent
e657c84fa1
commit
f9ddb81d79
|
@ -8,8 +8,6 @@
|
|||
|
||||
// UNSUPPORTED: c++03
|
||||
|
||||
// XFAIL: LIBCXX-WINDOWS-FIXME
|
||||
|
||||
// The string reported on errors changed, which makes those tests fail when run
|
||||
// against already-released libc++'s.
|
||||
// XFAIL: with_system_cxx_lib=macosx10.15
|
||||
|
@ -66,6 +64,9 @@ TEST_CASE(test_refresh_ec_method) {
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
|
||||
// Windows doesn't support setting perms::none to trigger failures
|
||||
// reading directories.
|
||||
TEST_CASE(refresh_on_file_dne) {
|
||||
using namespace fs;
|
||||
scoped_test_env env;
|
||||
|
@ -100,6 +101,7 @@ TEST_CASE(refresh_on_file_dne) {
|
|||
TEST_CHECK(!ent.exists());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void remove_if_exists(const fs::path& p) {
|
||||
std::error_code ec;
|
||||
|
@ -128,8 +130,10 @@ TEST_CASE(refresh_on_bad_symlink) {
|
|||
|
||||
LIBCPP_ONLY(permissions(dir, perms::none));
|
||||
TEST_CHECK(ent.is_symlink());
|
||||
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
|
||||
TEST_CHECK(!ent.is_regular_file());
|
||||
TEST_CHECK(!ent.exists());
|
||||
#endif
|
||||
}
|
||||
permissions(dir, old_perms);
|
||||
env.create_file("dir/file", 101);
|
||||
|
@ -147,10 +151,15 @@ TEST_CASE(refresh_on_bad_symlink) {
|
|||
TEST_CHECK(!ec); // we don't report bad symlinks as an error.
|
||||
|
||||
LIBCPP_ONLY(permissions(dir, perms::none));
|
||||
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
|
||||
TEST_CHECK(!ent.exists());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
|
||||
// Windows doesn't support setting perms::none to trigger failures
|
||||
// reading directories.
|
||||
TEST_CASE(refresh_cannot_resolve) {
|
||||
using namespace fs;
|
||||
scoped_test_env env;
|
||||
|
@ -224,6 +233,7 @@ TEST_CASE(refresh_cannot_resolve) {
|
|||
TEST_CHECK_NO_THROW(ent_sym2);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST_CASE(refresh_doesnt_throw_on_dne_but_reports_it) {
|
||||
using namespace fs;
|
||||
|
@ -271,6 +281,9 @@ TEST_CASE(refresh_doesnt_throw_on_dne_but_reports_it) {
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
|
||||
// Windows doesn't support setting perms::none to trigger failures
|
||||
// reading directories.
|
||||
TEST_CASE(access_cache_after_refresh_fails) {
|
||||
using namespace fs;
|
||||
scoped_test_env env;
|
||||
|
@ -342,5 +355,6 @@ TEST_CASE(access_cache_after_refresh_fails) {
|
|||
}
|
||||
#undef CHECK_ACCESS
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST_SUITE_END()
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
|
||||
// UNSUPPORTED: c++03
|
||||
|
||||
// XFAIL: LIBCXX-WINDOWS-FIXME
|
||||
|
||||
// <filesystem>
|
||||
|
||||
// class directory_entry
|
||||
|
@ -125,6 +123,9 @@ TEST_CASE(test_replace_filename_calls_refresh) {
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
|
||||
// Windows doesn't support setting perms::none to trigger failures
|
||||
// reading directories.
|
||||
TEST_CASE(test_replace_filename_propagates_error) {
|
||||
using namespace fs;
|
||||
scoped_test_env env;
|
||||
|
@ -167,5 +168,6 @@ TEST_CASE(test_replace_filename_propagates_error) {
|
|||
TEST_CHECK(ErrorIs(ec, std::errc::permission_denied));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST_SUITE_END()
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
|
||||
// UNSUPPORTED: c++03
|
||||
|
||||
// XFAIL: LIBCXX-WINDOWS-FIXME
|
||||
|
||||
// The string reported on errors changed, which makes those tests fail when run
|
||||
// against already-released libc++'s.
|
||||
// XFAIL: with_system_cxx_lib=macosx10.15
|
||||
|
@ -126,7 +124,9 @@ TEST_CASE(error_reporting) {
|
|||
const path sym_out_of_dir = env.create_symlink("dir/file", "sym");
|
||||
const path sym_in_dir = env.create_symlink("file2", "dir/sym2");
|
||||
|
||||
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
|
||||
const perms old_perms = status(dir).permissions();
|
||||
#endif
|
||||
|
||||
// test a file which doesn't exist
|
||||
{
|
||||
|
@ -169,6 +169,9 @@ TEST_CASE(error_reporting) {
|
|||
"directory_entry::file_size");
|
||||
TEST_CHECK_THROW_RESULT(filesystem_error, Checker, ent.file_size());
|
||||
}
|
||||
// Windows doesn't support setting perms::none to trigger failures
|
||||
// reading directories.
|
||||
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
|
||||
// test a file w/o appropriate permissions.
|
||||
{
|
||||
directory_entry ent;
|
||||
|
@ -245,6 +248,7 @@ TEST_CASE(error_reporting) {
|
|||
TEST_CHECK(!ec);
|
||||
TEST_CHECK_NO_THROW(ent.file_size());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_SUITE_END()
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
|
||||
// UNSUPPORTED: c++03
|
||||
|
||||
// XFAIL: LIBCXX-WINDOWS-FIXME
|
||||
|
||||
// <filesystem>
|
||||
|
||||
// class directory_entry
|
||||
|
@ -207,6 +205,9 @@ TEST_CASE(test_with_ec_dne) {
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
|
||||
// Windows doesn't support setting perms::none to trigger failures
|
||||
// reading directories.
|
||||
TEST_CASE(test_with_ec_cannot_resolve) {
|
||||
using namespace fs;
|
||||
using fs::directory_entry;
|
||||
|
@ -269,5 +270,6 @@ TEST_CASE(test_with_ec_cannot_resolve) {
|
|||
TEST_CHECK(CheckEC(sym_status_ec));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST_SUITE_END()
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
|
||||
// UNSUPPORTED: c++03
|
||||
|
||||
// XFAIL: LIBCXX-WINDOWS-FIXME
|
||||
|
||||
// The string reported on errors changed, which makes those tests fail when run
|
||||
// against already-released libc++'s.
|
||||
// XFAIL: with_system_cxx_lib=macosx10.15
|
||||
|
@ -129,7 +127,9 @@ TEST_CASE(error_reporting) {
|
|||
const path sym_out_of_dir = env.create_symlink("dir/file", "sym");
|
||||
const path sym_in_dir = env.create_symlink("file2", "dir/sym2");
|
||||
|
||||
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
|
||||
const perms old_perms = status(dir).permissions();
|
||||
#endif
|
||||
|
||||
// test a file which doesn't exist
|
||||
{
|
||||
|
@ -173,6 +173,9 @@ TEST_CASE(error_reporting) {
|
|||
"directory_entry::hard_link_count");
|
||||
TEST_CHECK_THROW_RESULT(filesystem_error, Checker, ent.hard_link_count());
|
||||
}
|
||||
// Windows doesn't support setting perms::none to trigger failures
|
||||
// reading directories.
|
||||
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
|
||||
// test a file w/o appropriate permissions.
|
||||
{
|
||||
directory_entry ent;
|
||||
|
@ -250,6 +253,7 @@ TEST_CASE(error_reporting) {
|
|||
TEST_CHECK(!ec);
|
||||
TEST_CHECK_NO_THROW(ent.hard_link_count());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_SUITE_END()
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
|
||||
// UNSUPPORTED: c++03
|
||||
|
||||
// XFAIL: LIBCXX-WINDOWS-FIXME
|
||||
|
||||
// The string reported on errors changed, which makes those tests fail when run
|
||||
// against already-released libc++'s.
|
||||
// XFAIL: with_system_cxx_lib=macosx10.15
|
||||
|
@ -98,7 +96,9 @@ TEST_CASE(error_reporting) {
|
|||
const path sym_out_of_dir = env.create_symlink("dir/file", "sym");
|
||||
const path sym_in_dir = env.create_symlink("file2", "dir/sym2");
|
||||
|
||||
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
|
||||
const perms old_perms = status(dir).permissions();
|
||||
#endif
|
||||
|
||||
// test a file which doesn't exist
|
||||
{
|
||||
|
@ -141,6 +141,9 @@ TEST_CASE(error_reporting) {
|
|||
"directory_entry::last_write_time");
|
||||
TEST_CHECK_THROW_RESULT(filesystem_error, Checker, ent.last_write_time());
|
||||
}
|
||||
// Windows doesn't support setting perms::none to trigger failures
|
||||
// reading directories.
|
||||
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
|
||||
// test a file w/o appropriate permissions.
|
||||
{
|
||||
directory_entry ent;
|
||||
|
@ -218,6 +221,7 @@ TEST_CASE(error_reporting) {
|
|||
TEST_CHECK(!ec);
|
||||
TEST_CHECK_NO_THROW(ent.last_write_time());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_SUITE_END()
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
|
||||
// UNSUPPORTED: c++03
|
||||
|
||||
// XFAIL: LIBCXX-WINDOWS-FIXME
|
||||
|
||||
// <filesystem>
|
||||
|
||||
// class recursive_directory_iterator
|
||||
|
@ -142,6 +140,9 @@ TEST_CASE(test_follow_symlinks)
|
|||
TEST_CHECK(it == endIt);
|
||||
}
|
||||
|
||||
// Windows doesn't support setting perms::none to trigger failures
|
||||
// reading directories.
|
||||
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
|
||||
TEST_CASE(access_denied_on_recursion_test_case)
|
||||
{
|
||||
using namespace fs;
|
||||
|
@ -492,6 +493,7 @@ TEST_CASE(test_PR35078_with_symlink_file)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
TEST_SUITE_END()
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
|
||||
// UNSUPPORTED: c++03
|
||||
|
||||
// XFAIL: LIBCXX-WINDOWS-FIXME
|
||||
|
||||
// This test requires the dylib support introduced in D92769.
|
||||
// XFAIL: with_system_cxx_lib=macosx10.15
|
||||
|
||||
|
@ -60,6 +58,8 @@ TEST_CASE(create_existing_directory)
|
|||
TEST_CHECK(fs::create_directory(dir, dir2) == false);
|
||||
}
|
||||
|
||||
// Windows doesn't have the concept of perms::none on directories.
|
||||
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
|
||||
TEST_CASE(create_directory_one_level)
|
||||
{
|
||||
scoped_test_env env;
|
||||
|
@ -79,6 +79,7 @@ TEST_CASE(create_directory_one_level)
|
|||
auto st = status(dir);
|
||||
TEST_CHECK(st.permissions() == perms::none);
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST_CASE(create_directory_multi_level)
|
||||
{
|
||||
|
|
|
@ -573,6 +573,9 @@ TEST_CASE(test_value_on_failure)
|
|||
TEST_CHECK(ErrorIs(ec, std::errc::no_such_file_or_directory));
|
||||
}
|
||||
|
||||
// Windows doesn't support setting perms::none to trigger failures
|
||||
// reading directories.
|
||||
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
|
||||
TEST_CASE(test_exists_fails)
|
||||
{
|
||||
scoped_test_env env;
|
||||
|
@ -588,5 +591,6 @@ TEST_CASE(test_exists_fails)
|
|||
"last_write_time");
|
||||
TEST_CHECK_THROW_RESULT(filesystem_error, Checker, last_write_time(file));
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST_SUITE_END()
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
|
||||
// UNSUPPORTED: c++03
|
||||
|
||||
// XFAIL: LIBCXX-WINDOWS-FIXME
|
||||
|
||||
// <filesystem>
|
||||
|
||||
// bool remove(const path& p);
|
||||
|
@ -62,7 +60,13 @@ TEST_CASE(test_error_reporting)
|
|||
permissions(bad_perms_dir, perms::none);
|
||||
const path testCases[] = {
|
||||
non_empty_dir,
|
||||
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
|
||||
// Windows doesn't support setting perms::none on a directory to
|
||||
// stop it from being accessed. And a fictional file under
|
||||
// GetWindowsInaccessibleDir() doesn't cause fs::remove() to report
|
||||
// errors, it just returns false cleanly.
|
||||
file_in_bad_dir,
|
||||
#endif
|
||||
};
|
||||
for (auto& p : testCases) {
|
||||
std::error_code ec;
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
|
||||
// UNSUPPORTED: c++03
|
||||
|
||||
// XFAIL: LIBCXX-WINDOWS-FIXME
|
||||
|
||||
// <filesystem>
|
||||
|
||||
// uintmax_t remove_all(const path& p);
|
||||
|
@ -38,6 +36,10 @@ TEST_CASE(test_signatures)
|
|||
|
||||
TEST_CASE(test_error_reporting)
|
||||
{
|
||||
scoped_test_env env;
|
||||
// Windows doesn't support setting perms::none to trigger failures
|
||||
// reading directories.
|
||||
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
|
||||
auto checkThrow = [](path const& f, const std::error_code& ec)
|
||||
{
|
||||
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||
|
@ -54,7 +56,6 @@ TEST_CASE(test_error_reporting)
|
|||
return true;
|
||||
#endif
|
||||
};
|
||||
scoped_test_env env;
|
||||
const path non_empty_dir = env.create_dir("dir");
|
||||
env.create_file(non_empty_dir / "file1", 42);
|
||||
const path bad_perms_dir = env.create_dir("bad_dir");
|
||||
|
@ -74,6 +75,7 @@ TEST_CASE(test_error_reporting)
|
|||
TEST_CHECK(ec);
|
||||
TEST_CHECK(checkThrow(p, ec));
|
||||
}
|
||||
#endif
|
||||
|
||||
// PR#35780
|
||||
const path testCasesNonexistant[] = {
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
|
||||
// UNSUPPORTED: c++03
|
||||
|
||||
// XFAIL: LIBCXX-WINDOWS-FIXME
|
||||
|
||||
// <filesystem>
|
||||
|
||||
// file_status status(const path& p);
|
||||
|
@ -56,6 +54,12 @@ TEST_CASE(test_status_not_found)
|
|||
}
|
||||
}
|
||||
|
||||
// Windows doesn't support setting perms::none to trigger failures
|
||||
// reading directories. Imaginary files under GetWindowsInaccessibleDir()
|
||||
// produce no_such_file_or_directory, not the error codes this test checks
|
||||
// for. Finally, status() for a too long file name doesn't return errors
|
||||
// on windows.
|
||||
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
|
||||
TEST_CASE(test_status_cannot_resolve)
|
||||
{
|
||||
scoped_test_env env;
|
||||
|
@ -98,6 +102,7 @@ TEST_CASE(test_status_cannot_resolve)
|
|||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST_CASE(status_file_types_test)
|
||||
{
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
|
||||
// UNSUPPORTED: c++03
|
||||
|
||||
// XFAIL: LIBCXX-WINDOWS-FIXME
|
||||
|
||||
// <filesystem>
|
||||
|
||||
// file_status symlink_status(const path& p);
|
||||
|
@ -55,6 +53,12 @@ TEST_CASE(test_symlink_status_not_found)
|
|||
}
|
||||
}
|
||||
|
||||
// Windows doesn't support setting perms::none to trigger failures
|
||||
// reading directories. Imaginary files under GetWindowsInaccessibleDir()
|
||||
// produce no_such_file_or_directory, not the error codes this test checks
|
||||
// for. Finally, status() for a too long file name doesn't return errors
|
||||
// on windows.
|
||||
#ifndef TEST_WIN_NO_FILESYSTEM_PERMS_NONE
|
||||
TEST_CASE(test_symlink_status_cannot_resolve)
|
||||
{
|
||||
scoped_test_env env;
|
||||
|
@ -105,6 +109,7 @@ TEST_CASE(test_symlink_status_cannot_resolve)
|
|||
TEST_CHECK(st.permissions() != perms::unknown);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
TEST_CASE(symlink_status_file_types_test)
|
||||
|
|
|
@ -378,6 +378,10 @@ inline void DoNotOptimize(Tp const& value) {
|
|||
#define TEST_NOT_WIN32(...) __VA_ARGS__
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define TEST_WIN_NO_FILESYSTEM_PERMS_NONE
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue