From 9f7f25bb35c1be3e5c8ef9325c03bb01a2d66963 Mon Sep 17 00:00:00 2001 From: Alexandre Oliva Date: Thu, 23 Jun 2022 23:20:50 -0300 Subject: libstdc++: testsuite: conditionalize symlink tests Several filesystem tests expect to be able to create symlinks even when !defined (_GLIBCXX_HAVE_SYMLINK), and fail predictably, reducing the amount of testing of other filesystem features. They are already skipped for mingw targets. I've extended the skipping to other targets in which _GLIBCXX_HAVE_SYMLINK is undefined, through a new NO_SYMLINKS macro in testsuite_fs.h that guards skippable portions of tests, and dg-require-target-fs-symlinks for tests that would be reduced to nothing. for libstdc++-v3/ChangeLog * testsuite/util/testsuite_fs.h (NO_SYMLINKS): Define on mingw and when create_symlink is a dummy. * testsuite/27_io/filesystem/operations/symlink_status.cc: Drop mingw xfail. (test01, test02): Don't create symlinks when NO_SYMLINKS is defined. * testsuite/27_io/filesystem/operations/canonical.cc (test03): Likewise. * testsuite/27_io/filesystem/operations/copy.cc (test02): Likewise. * testsuite/27_io/filesystem/operations/create_directories.cc (test04): Likewise. * testsuite/27_io/filesystem/operations/create_directory.cc (test01): Likewise. * testsuite/27_io/filesystem/operations/permissions.cc (test03, test04): Likewise. * testsuite/27_io/filesystem/operations/remove.cc (test01): Likewise. * testsuite/27_io/filesystem/operations/remove_all.cc (test01): Likewise. * testsuite/27_io/filesystem/operations/rename.cc (test_symlinks): Likewise. * testsuite/27_io/filesystem/operations/weakly_canonical.cc (test01): Likewise. * testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc (test06): Likewise. * testsuite/experimental/filesystem/operations/copy.cc (test01): Likewise. * testsuite/experimental/filesystem/operations/create_directories.cc (test04): Likewise. * testsuite/experimental/filesystem/operations/create_directory.cc (test01): Likewise. * testsuite/experimental/filesystem/operations/permissions.cc (test03, test04): Likewise. * testsuite/experimental/filesystem/operations/remove.cc (test01): Likewise. * testsuite/experimental/filesystem/operations/remove_all.cc (test01): Likewise. * testsuite/experimental/filesystem/operations/rename.cc (test01): Likewise. * testsuite/lib/libstdc++.exp (v3_check_preprocessor_condition): Add optional inc parameter. Add it to the test program after include bits/c++config.h. (check_v3_target_fs_symlinks): New. * testsuite/lib/dg-options.exp (dg-require-target-fs-symlinks): New. * testsuite/27_io/filesystem/operations/read_symlink.cc: Replace mingw xfail with require target-fs-symlinks. * testsuite/experimental/filesystem/operations/read_symlink.cc: Likewise. --- .../filesystem/iterators/recursive_directory_iterator.cc | 2 +- libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc | 7 ++----- .../experimental/filesystem/operations/create_directories.cc | 4 +--- .../experimental/filesystem/operations/create_directory.cc | 4 +--- .../testsuite/experimental/filesystem/operations/permissions.cc | 4 ++++ .../testsuite/experimental/filesystem/operations/read_symlink.cc | 2 +- .../testsuite/experimental/filesystem/operations/remove.cc | 5 +---- .../testsuite/experimental/filesystem/operations/remove_all.cc | 4 +--- .../testsuite/experimental/filesystem/operations/rename.cc | 4 +--- 9 files changed, 13 insertions(+), 23 deletions(-) (limited to 'libstdc++-v3/testsuite/experimental/filesystem') diff --git a/libstdc++-v3/testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc b/libstdc++-v3/testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc index a201415..393fb31 100644 --- a/libstdc++-v3/testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc +++ b/libstdc++-v3/testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc @@ -188,7 +188,7 @@ test05() void test06() { -#if !(defined __MINGW32__ || defined __MINGW64__) +#ifndef NO_SYMLINKS auto p = __gnu_test::nonexistent_path(); create_directories(p/"d1/d2"); create_directory_symlink("d1", p/"link"); diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc index ca38328..021897c 100644 --- a/libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc +++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc @@ -67,11 +67,7 @@ test01() void test02() { -#if defined(__MINGW32__) || defined(__MINGW64__) - // No symlink support - return; -#endif - +#ifndef NO_SYMLINKS auto from = __gnu_test::nonexistent_path(); std::error_code ec, bad = std::make_error_code(std::errc::invalid_argument); @@ -109,6 +105,7 @@ test02() remove(from, ec); remove(to, ec); +#endif } // Test is_regular_file(f) case. diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/create_directories.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/create_directories.cc index 03060c6..df27748 100644 --- a/libstdc++-v3/testsuite/experimental/filesystem/operations/create_directories.cc +++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/create_directories.cc @@ -147,9 +147,7 @@ test03() void test04() { -#if defined(__MINGW32__) || defined(__MINGW64__) - // no symlinks -#else +#ifndef NO_SYMLINKS // PR libstdc++/101510 // create_directories reports an error if the path is a symlink to a dir std::error_code ec = make_error_code(std::errc::invalid_argument); diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/create_directory.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/create_directory.cc index 67e5fdd..5e9346d 100644 --- a/libstdc++-v3/testsuite/experimental/filesystem/operations/create_directory.cc +++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/create_directory.cc @@ -69,9 +69,7 @@ test01() VERIFY( e.path1() == f ); } -#if defined(__MINGW32__) || defined(__MINGW64__) - // no symlinks -#else +#ifndef NO_SYMLINKS // PR libstdc++/101510 create_directory on an existing symlink to a directory fs::create_directory(p/"dir"); auto link = p/"link"; diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/permissions.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/permissions.cc index 833aa13..5866e33 100644 --- a/libstdc++-v3/testsuite/experimental/filesystem/operations/permissions.cc +++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/permissions.cc @@ -72,6 +72,7 @@ test02() void test03() { +#ifndef NO_SYMLINKS using perms = std::experimental::filesystem::perms; __gnu_test::scoped_file f; @@ -95,11 +96,13 @@ test03() VERIFY( ec == ec2 ); remove(p); +#endif } void test04() { +#ifndef NO_SYMLINKS using perms = std::experimental::filesystem::perms; auto p = __gnu_test::nonexistent_path(); @@ -120,6 +123,7 @@ test04() VERIFY( ec == ec2 ); remove(p); +#endif } void diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/read_symlink.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/read_symlink.cc index 75dae3e..d0a90976 100644 --- a/libstdc++-v3/testsuite/experimental/filesystem/operations/read_symlink.cc +++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/read_symlink.cc @@ -18,7 +18,7 @@ // { dg-options "-DUSE_FILESYSTEM_TS -lstdc++fs" } // { dg-do run { target c++11 } } // { dg-require-filesystem-ts "" } -// { dg-xfail-if "symlinks not supported" { *-*-mingw* } } +// { dg-require-target-fs-symlinks "" } #include #include diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/remove.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/remove.cc index c01f140..4ffc740 100644 --- a/libstdc++-v3/testsuite/experimental/filesystem/operations/remove.cc +++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/remove.cc @@ -42,10 +42,7 @@ test01() VERIFY( !ec ); VERIFY( !n ); -#if defined(__MINGW32__) || defined(__MINGW64__) - // No symlink support - return; -#else +#ifndef NO_SYMLINKS auto link = __gnu_test::nonexistent_path(); create_symlink(p, link); // dangling symlink ec = bad_ec; diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/remove_all.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/remove_all.cc index 4b0ce85..11c07d4 100644 --- a/libstdc++-v3/testsuite/experimental/filesystem/operations/remove_all.cc +++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/remove_all.cc @@ -42,9 +42,7 @@ test01() VERIFY( !ec ); VERIFY( n == 0 ); -#if defined(__MINGW32__) || defined(__MINGW64__) - // No symlink support -#else +#ifndef NO_SYMLINKS auto link = __gnu_test::nonexistent_path(); create_symlink(p, link); // dangling symlink ec = bad_ec; diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/rename.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/rename.cc index 46776e8..37e743b 100644 --- a/libstdc++-v3/testsuite/experimental/filesystem/operations/rename.cc +++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/rename.cc @@ -75,9 +75,7 @@ test01() void test_symlinks() { -#if defined(__MINGW32__) || defined(__MINGW64__) - // No symlink support -#else +#ifndef NO_SYMLINKS std::error_code ec; const std::error_code bad_ec = make_error_code(std::errc::invalid_argument); -- cgit v1.1