public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/aoliva/heads/testme)] libstdc++: testsuite: conditionalize symlink tests
@ 2022-06-23 10:05 Alexandre Oliva
0 siblings, 0 replies; 7+ messages in thread
From: Alexandre Oliva @ 2022-06-23 10:05 UTC (permalink / raw)
To: gcc-cvs, libstdc++-cvs
https://gcc.gnu.org/g:8fa9c3a51b834a41fd4d2523d83da63e4463405f
commit 8fa9c3a51b834a41fd4d2523d83da63e4463405f
Author: Alexandre Oliva <oliva@adacore.com>
Date: Mon Jun 20 20:03:05 2022 -0300
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_itreator.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 inc parameter. Include
it after bits/c++config.h. Adjust all callers.
(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.
Diff:
---
.../27_io/filesystem/operations/canonical.cc | 5 +-
.../testsuite/27_io/filesystem/operations/copy.cc | 7 +--
.../filesystem/operations/create_directories.cc | 4 +-
.../filesystem/operations/create_directory.cc | 4 +-
.../27_io/filesystem/operations/permissions.cc | 4 ++
.../27_io/filesystem/operations/read_symlink.cc | 2 +-
.../27_io/filesystem/operations/remove.cc | 4 +-
.../27_io/filesystem/operations/remove_all.cc | 4 +-
.../27_io/filesystem/operations/rename.cc | 4 +-
.../27_io/filesystem/operations/symlink_status.cc | 5 +-
.../filesystem/operations/weakly_canonical.cc | 4 +-
.../iterators/recursive_directory_iterator.cc | 2 +-
.../experimental/filesystem/operations/copy.cc | 7 +--
.../filesystem/operations/create_directories.cc | 4 +-
.../filesystem/operations/create_directory.cc | 4 +-
.../filesystem/operations/permissions.cc | 4 ++
.../filesystem/operations/read_symlink.cc | 2 +-
.../experimental/filesystem/operations/remove.cc | 5 +-
.../filesystem/operations/remove_all.cc | 4 +-
.../experimental/filesystem/operations/rename.cc | 4 +-
libstdc++-v3/testsuite/lib/dg-options.exp | 9 ++++
libstdc++-v3/testsuite/lib/libstdc++.exp | 55 +++++++++++++---------
libstdc++-v3/testsuite/util/testsuite_fs.h | 5 ++
23 files changed, 81 insertions(+), 71 deletions(-)
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc
index bc7ef0de2b7..9c432b25acf 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc
@@ -111,9 +111,12 @@ test03()
fs::path foo = dir/"foo", bar = dir/"bar";
fs::create_directory(foo);
fs::create_directory(bar);
+#ifdef NO_SYMLINKS
#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
const fs::path baz = dir/"foo\\\\..\\bar///";
+#else
+ const fs::path baz = dir/"foo//../bar///";
+#endif
#else
fs::create_symlink("../bar", foo/"baz");
const fs::path baz = dir/"foo//./baz///";
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
index f3081f4b64e..f9fb4dff77e 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
@@ -66,11 +66,7 @@ test01()
void
test02()
{
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
- return;
-#endif
-
+#ifndef NO_SYMLINKS
const std::error_code bad_ec = make_error_code(std::errc::invalid_argument);
auto from = __gnu_test::nonexistent_path();
std::error_code ec;
@@ -110,6 +106,7 @@ test02()
remove(from, ec);
remove(to, ec);
+#endif
}
// Test is_regular_file(f) case.
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc
index 4a7ba1fcb49..2b48c152e39 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc
@@ -148,9 +148,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/27_io/filesystem/operations/create_directory.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directory.cc
index 90f98302c00..aa59f7f3ee2 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directory.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directory.cc
@@ -70,9 +70,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/27_io/filesystem/operations/permissions.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/permissions.cc
index deed759be80..ee5afd529ba 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/permissions.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/permissions.cc
@@ -76,6 +76,7 @@ test02()
void
test03()
{
+#ifndef NO_SYMLINKS
using std::filesystem::perms;
using std::filesystem::perm_options;
@@ -111,11 +112,13 @@ test03()
VERIFY( !caught );
remove(p);
+#endif
}
void
test04()
{
+#ifndef NO_SYMLINKS
using perms = std::filesystem::perms;
auto p = __gnu_test::nonexistent_path();
@@ -137,6 +140,7 @@ test04()
VERIFY( ec == ec2 );
remove(p);
+#endif
}
void
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc
index 68bbab33bc9..030d6271de5 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc
@@ -17,7 +17,7 @@
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }
-// { dg-xfail-if "symlinks not supported" { *-*-mingw* } }
+// { dg-require-target-fs-symlinks "" }
#include <filesystem>
#include <testsuite_hooks.h>
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc
index 26f2d548f82..f769723ae30 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc
@@ -41,9 +41,7 @@ test01()
VERIFY( !ec );
VERIFY( !n );
-#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/27_io/filesystem/operations/remove_all.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc
index 943d85c0cc2..d5266a46449 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc
@@ -41,9 +41,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/27_io/filesystem/operations/rename.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/rename.cc
index f23a2862a0b..b74e1133a76 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/rename.cc
+++ b/libstdc++-v3/testsuite/27_io/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);
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc
index ef973b7807b..e00e4aaa78e 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc
@@ -17,7 +17,6 @@
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }
-// { dg-xfail-if "symlinks not supported" { *-*-mingw* } }
#include <filesystem>
#include <testsuite_hooks.h>
@@ -39,6 +38,7 @@ test01()
fs::file_status st2 = fs::symlink_status(dot);
VERIFY( st2.type() == fs::file_type::directory );
+#ifndef NO_SYMLINKS
fs::path link = __gnu_test::nonexistent_path();
create_directory_symlink(dot, link);
__gnu_test::scoped_file l(link, __gnu_test::scoped_file::adopt_file);
@@ -49,6 +49,7 @@ test01()
st2 = fs::symlink_status(link, ec);
VERIFY( !ec );
VERIFY( st2.type() == fs::file_type::symlink );
+#endif
}
void
@@ -68,6 +69,7 @@ test02()
void
test03()
{
+#ifndef NO_SYMLINKS
if (!__gnu_test::permissions_are_testable())
return;
@@ -111,6 +113,7 @@ test03()
VERIFY( st2.type() == fs::file_type::symlink );
fs::permissions(dir, fs::perms::owner_all, ec);
+#endif
}
void
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc
index 244b753f84d..ad164f52809 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc
@@ -39,9 +39,7 @@ test01()
fs::create_directory(bar/"baz");
fs::path p;
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
-#else
+#ifndef NO_SYMLINKS
fs::create_symlink("../bar", foo/"bar");
p = fs::weakly_canonical(dir/"foo//./bar///../biz/.");
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 a201415921c..393fb315593 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 ca38328c5da..021897cfede 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 03060c6cbb3..df27748ff99 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 67e5fddca00..5e9346d5c73 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 833aa13dd15..5866e334d7b 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 75dae3eac51..d0a90976a71 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 <experimental/filesystem>
#include <testsuite_hooks.h>
diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/remove.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/remove.cc
index c01f140ee59..4ffc74093b8 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 4b0ce85cf97..11c07d4f781 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 46776e80994..37e743b770f 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);
diff --git a/libstdc++-v3/testsuite/lib/dg-options.exp b/libstdc++-v3/testsuite/lib/dg-options.exp
index 15f37da468a..e624a69460e 100644
--- a/libstdc++-v3/testsuite/lib/dg-options.exp
+++ b/libstdc++-v3/testsuite/lib/dg-options.exp
@@ -241,6 +241,15 @@ proc dg-require-filesystem-ts { args } {
return
}
+proc dg-require-target-fs-symlinks { args } {
+ if { ![ check_v3_target_fs_symlinks ] } {
+ upvar dg-do-what dg-do-what
+ set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+ return
+ }
+ return
+}
+
proc add_options_for_no_pch { flags } {
# This forces any generated and possibly included PCH to be invalid.
return "-D__GLIBCXX__=99999999"
diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 93fdfee687d..d71d88fb998 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -974,13 +974,16 @@ proc v3_try_preprocess { name code flags } {
}
# Return 1 if COND evaluates to true in the preprocessor, 0 otherwise.
-# The <bits/c++config.h> config header is included.
-proc v3_check_preprocessor_condition { name cond } {
+# The <bits/c++config.h> config header is included, and INC, if given,
+# is pasted between it and the condition evaluation, so it can be used
+# for additional #include's.
+proc v3_check_preprocessor_condition { name cond inc } {
global cxxflags
global DEFAULT_CXXFLAGS
set code "
#include <bits/c++config.h>
+ $inc
#if ! ($cond)
#error '$cond' is false
#endif
@@ -1030,7 +1033,7 @@ proc check_v3_target_normal_mode { } {
proc check_v3_target_normal_namespace { } {
return [check_v3_target_prop_cached et_normal_namespace {
set cond "!_GLIBCXX_INLINE_VERSION"
- return [v3_check_preprocessor_condition normal_namespace $cond]
+ return [v3_check_preprocessor_condition normal_namespace $cond ""]
}]
}
@@ -1051,7 +1054,7 @@ proc check_v3_target_parallel_mode { } {
proc check_v3_target_cstdint { } {
return [check_v3_target_prop_cached et_cstdint {
set cond "defined _GLIBCXX_USE_C99_STDINT_TR1"
- return [v3_check_preprocessor_condition cstdint $cond]
+ return [v3_check_preprocessor_condition cstdint $cond ""]
}]
}
@@ -1059,7 +1062,7 @@ proc check_v3_target_cstdint { } {
proc check_v3_target_cmath { } {
return [check_v3_target_prop_cached et_c99_math {
set cond "defined _GLIBCXX_USE_C99_MATH_TR1"
- return [v3_check_preprocessor_condition cmath $cond]
+ return [v3_check_preprocessor_condition cmath $cond ""]
}]
}
@@ -1101,7 +1104,7 @@ proc check_v3_target_thread_fence { } {
proc check_v3_target_atomic_builtins { } {
return [check_v3_target_prop_cached et_atomic_builtins {
set cond "__GCC_ATOMIC_BOOL_LOCK_FREE > 1 && __GCC_ATOMIC_INT_LOCK_FREE > 1"
- return [v3_check_preprocessor_condition atomic_builtins $cond]
+ return [v3_check_preprocessor_condition atomic_builtins $cond ""]
}]
}
@@ -1115,7 +1118,7 @@ proc check_effective_target_atomic_builtins { } {
proc check_v3_target_gthreads { } {
return [check_v3_target_prop_cached et_gthreads {
set cond "defined _GLIBCXX_HAS_GTHREADS"
- return [v3_check_preprocessor_condition gthreads $cond]
+ return [v3_check_preprocessor_condition gthreads $cond ""]
}]
}
@@ -1129,7 +1132,7 @@ proc check_v3_target_gthreads_timed { } {
return [check_v3_target_prop_cached et_gthreads_timed {
if [check_v3_target_gthreads] {
set cond "_GTHREAD_USE_MUTEX_TIMEDLOCK"
- return [v3_check_preprocessor_condition gthreads_timed $cond]
+ return [v3_check_preprocessor_condition gthreads_timed $cond ""]
} else {
return 0
}
@@ -1145,7 +1148,7 @@ proc check_effective_target_gthreads_timed { } {
proc check_v3_target_sleep { } {
return [check_v3_target_prop_cached et_sleep {
set cond "defined _GLIBCXX_USE_NANOSLEEP || defined _GLIBCXX_HAVE_SLEEP"
- return [v3_check_preprocessor_condition sleep $cond]
+ return [v3_check_preprocessor_condition sleep $cond ""]
}]
}
@@ -1153,7 +1156,7 @@ proc check_v3_target_sleep { } {
proc check_v3_target_sched_yield { } {
return [check_v3_target_prop_cached et_sched_yield {
set cond "defined _GLIBCXX_USE_SCHED_YIELD"
- return [v3_check_preprocessor_condition sched_yield $cond]
+ return [v3_check_preprocessor_condition sched_yield $cond ""]
}]
}
@@ -1163,7 +1166,7 @@ proc check_v3_target_string_conversions { } {
set cond "_GLIBCXX_USE_C99_STDIO && _GLIBCXX_USE_C99_STDLIB"
set cond "$cond && _GLIBCXX_USE_C99_WCHAR"
set cond "$cond && !defined _GLIBCXX_HAVE_BROKEN_VSWPRINTF"
- return [v3_check_preprocessor_condition string_conversions $cond]
+ return [v3_check_preprocessor_condition string_conversions $cond ""]
}]
}
@@ -1171,7 +1174,7 @@ proc check_v3_target_string_conversions { } {
proc check_v3_target_swprintf { } {
return [check_v3_target_prop_cached et_swprintf {
set cond "! defined _GLIBCXX_HAVE_BROKEN_VSWPRINTF"
- return [v3_check_preprocessor_condition swprintf $cond]
+ return [v3_check_preprocessor_condition swprintf $cond ""]
}]
}
@@ -1179,7 +1182,7 @@ proc check_v3_target_swprintf { } {
proc check_v3_target_binary_io { } {
return [check_v3_target_prop_cached et_binary_io {
set cond "! defined _GLIBCXX_HAVE_DOS_BASED_FILESYSTEM"
- return [v3_check_preprocessor_condition binary_io $cond]
+ return [v3_check_preprocessor_condition binary_io $cond ""]
}]
}
@@ -1192,7 +1195,7 @@ proc check_v3_target_nprocs { } {
set cond "$cond || defined _GLIBCXX_USE_SYSCTL_HW_NCPU"
set cond "$cond || defined _GLIBCXX_USE_SC_NPROCESSORS_ONLN"
set cond "$cond || defined _GLIBCXX_USE_SC_NPROC_ONLN"
- return [v3_check_preprocessor_condition nprocs $cond]
+ return [v3_check_preprocessor_condition nprocs $cond ""]
}]
}
@@ -1267,19 +1270,27 @@ proc check_v3_target_filesystem_ts { } {
}]
}
+# Return 1 if the libstdc++ filesystem create_symlinks implementation
+# is not an always-failing dummy.
+proc check_v3_target_fs_symlinks { } {
+ set inc "#include <testsuite_fs.h>"
+ set cond "!defined NO_SYMLINKS"
+ return [v3_check_preprocessor_condition fs_symlinks $cond $inc]
+}
+
# Return 1 if the "cxx11" ABI is in use using the current flags, 0 otherwise.
# Any flags provided by RUNTESTFLAGS or a target board will be used here.
# Flags added in the test by dg-options or dg-add-options will not be used.
proc check_effective_target_cxx11_abi { } {
set cond "_GLIBCXX_USE_CXX11_ABI"
- return [v3_check_preprocessor_condition cxx11_abi $cond]
+ return [v3_check_preprocessor_condition cxx11_abi $cond ""]
}
# Return 1 if std::random_device should be usable using the current flags,
# 0 otherwise.
proc check_effective_target_random_device { } {
set cond "_GLIBCXX_USE_RANDOM_TR1"
- return [v3_check_preprocessor_condition random_device $cond]
+ return [v3_check_preprocessor_condition random_device $cond ""]
}
# Return 1 if tbb parallel backend is available, 0 otherwise.
@@ -1318,7 +1329,7 @@ proc check_effective_target_tbb_backend { } {
proc check_effective_target_futex { } {
return [check_v3_target_prop_cached et_futex {
set cond "_GLIBCXX_HAVE_LINUX_FUTEX"
- return [v3_check_preprocessor_condition futex $cond]
+ return [v3_check_preprocessor_condition futex $cond ""]
}]
}
@@ -1326,7 +1337,7 @@ proc check_effective_target_futex { } {
proc check_effective_target_ieee_floats { } {
return [check_v3_target_prop_cached et_ieee_floats {
set cond "_GLIBCXX_FLOAT_IS_IEEE_BINARY32 && _GLIBCXX_DOUBLE_IS_IEEE_BINARY64"
- return [v3_check_preprocessor_condition ieee_floats $cond]
+ return [v3_check_preprocessor_condition ieee_floats $cond ""]
}]
}
@@ -1334,7 +1345,7 @@ proc check_effective_target_ieee_floats { } {
proc check_effective_target_net_ts_ip { } {
return [check_v3_target_prop_cached et_net_ts_ip {
set cond "__has_include(<netinet/in.h>)"
- return [v3_check_preprocessor_condition net_ts_ip $cond]
+ return [v3_check_preprocessor_condition net_ts_ip $cond ""]
}]
}
@@ -1342,7 +1353,7 @@ proc check_effective_target_net_ts_ip { } {
proc check_effective_target_std_allocator_new { } {
return [check_v3_target_prop_cached et_std_alloc_new {
set cond "_GLIBCXX_USE_ALLOCATOR_NEW"
- return [v3_check_preprocessor_condition std_alloc_new $cond]
+ return [v3_check_preprocessor_condition std_alloc_new $cond ""]
}]
}
@@ -1350,7 +1361,7 @@ proc check_effective_target_std_allocator_new { } {
proc check_effective_target_stacktrace { } {
return [check_v3_target_prop_cached et_stacktrace {
set cond "_GLIBCXX_HAVE_STACKTRACE"
- return [v3_check_preprocessor_condition stacktrace $cond]
+ return [v3_check_preprocessor_condition stacktrace $cond ""]
}]
}
@@ -1358,7 +1369,7 @@ proc check_effective_target_stacktrace { } {
proc check_effective_target_rtti { } {
return [check_v3_target_prop_cached et_rtti {
set cond "__cpp_rtti"
- return [v3_check_preprocessor_condition rtti $cond]
+ return [v3_check_preprocessor_condition rtti $cond ""]
}]
}
diff --git a/libstdc++-v3/testsuite/util/testsuite_fs.h b/libstdc++-v3/testsuite/util/testsuite_fs.h
index 9358a04e56c..048f03103e4 100644
--- a/libstdc++-v3/testsuite/util/testsuite_fs.h
+++ b/libstdc++-v3/testsuite/util/testsuite_fs.h
@@ -42,6 +42,11 @@ namespace test_fs = std::experimental::filesystem;
#include <random> // std::random_device
#endif
+#if defined(__MINGW32__) || defined(__MINGW64__) \
+ || !defined (_GLIBCXX_HAVE_SYMLINK)
+#define NO_SYMLINKS
+#endif
+
namespace __gnu_test
{
#define PATH_CHK(p1, p2, fn) \
^ permalink raw reply [flat|nested] 7+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] libstdc++: testsuite: conditionalize symlink tests
@ 2022-06-23 14:02 Alexandre Oliva
0 siblings, 0 replies; 7+ messages in thread
From: Alexandre Oliva @ 2022-06-23 14:02 UTC (permalink / raw)
To: gcc-cvs, libstdc++-cvs
https://gcc.gnu.org/g:d62fad563fb809a3b8335e5b2882c944df7b4500
commit d62fad563fb809a3b8335e5b2882c944df7b4500
Author: Alexandre Oliva <oliva@adacore.com>
Date: Mon Jun 20 20:03:05 2022 -0300
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_itreator.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.
Diff:
---
.../testsuite/27_io/filesystem/operations/canonical.cc | 5 ++++-
.../testsuite/27_io/filesystem/operations/copy.cc | 7 ++-----
.../27_io/filesystem/operations/create_directories.cc | 4 +---
.../27_io/filesystem/operations/create_directory.cc | 4 +---
.../testsuite/27_io/filesystem/operations/permissions.cc | 4 ++++
.../testsuite/27_io/filesystem/operations/read_symlink.cc | 2 +-
.../testsuite/27_io/filesystem/operations/remove.cc | 4 +---
.../testsuite/27_io/filesystem/operations/remove_all.cc | 4 +---
.../testsuite/27_io/filesystem/operations/rename.cc | 4 +---
.../27_io/filesystem/operations/symlink_status.cc | 5 ++++-
.../27_io/filesystem/operations/weakly_canonical.cc | 4 +---
.../filesystem/iterators/recursive_directory_iterator.cc | 2 +-
.../testsuite/experimental/filesystem/operations/copy.cc | 7 ++-----
.../filesystem/operations/create_directories.cc | 4 +---
.../filesystem/operations/create_directory.cc | 4 +---
.../experimental/filesystem/operations/permissions.cc | 4 ++++
.../experimental/filesystem/operations/read_symlink.cc | 2 +-
.../experimental/filesystem/operations/remove.cc | 5 +----
.../experimental/filesystem/operations/remove_all.cc | 4 +---
.../experimental/filesystem/operations/rename.cc | 4 +---
libstdc++-v3/testsuite/lib/dg-options.exp | 9 +++++++++
libstdc++-v3/testsuite/lib/libstdc++.exp | 15 +++++++++++++--
libstdc++-v3/testsuite/util/testsuite_fs.h | 4 ++++
23 files changed, 60 insertions(+), 51 deletions(-)
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc
index bc7ef0de2b7..9c432b25acf 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc
@@ -111,9 +111,12 @@ test03()
fs::path foo = dir/"foo", bar = dir/"bar";
fs::create_directory(foo);
fs::create_directory(bar);
+#ifdef NO_SYMLINKS
#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
const fs::path baz = dir/"foo\\\\..\\bar///";
+#else
+ const fs::path baz = dir/"foo//../bar///";
+#endif
#else
fs::create_symlink("../bar", foo/"baz");
const fs::path baz = dir/"foo//./baz///";
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
index f3081f4b64e..f9fb4dff77e 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
@@ -66,11 +66,7 @@ test01()
void
test02()
{
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
- return;
-#endif
-
+#ifndef NO_SYMLINKS
const std::error_code bad_ec = make_error_code(std::errc::invalid_argument);
auto from = __gnu_test::nonexistent_path();
std::error_code ec;
@@ -110,6 +106,7 @@ test02()
remove(from, ec);
remove(to, ec);
+#endif
}
// Test is_regular_file(f) case.
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc
index 4a7ba1fcb49..2b48c152e39 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc
@@ -148,9 +148,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/27_io/filesystem/operations/create_directory.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directory.cc
index 90f98302c00..aa59f7f3ee2 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directory.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directory.cc
@@ -70,9 +70,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/27_io/filesystem/operations/permissions.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/permissions.cc
index deed759be80..ee5afd529ba 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/permissions.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/permissions.cc
@@ -76,6 +76,7 @@ test02()
void
test03()
{
+#ifndef NO_SYMLINKS
using std::filesystem::perms;
using std::filesystem::perm_options;
@@ -111,11 +112,13 @@ test03()
VERIFY( !caught );
remove(p);
+#endif
}
void
test04()
{
+#ifndef NO_SYMLINKS
using perms = std::filesystem::perms;
auto p = __gnu_test::nonexistent_path();
@@ -137,6 +140,7 @@ test04()
VERIFY( ec == ec2 );
remove(p);
+#endif
}
void
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc
index 68bbab33bc9..030d6271de5 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc
@@ -17,7 +17,7 @@
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }
-// { dg-xfail-if "symlinks not supported" { *-*-mingw* } }
+// { dg-require-target-fs-symlinks "" }
#include <filesystem>
#include <testsuite_hooks.h>
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc
index 26f2d548f82..f769723ae30 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc
@@ -41,9 +41,7 @@ test01()
VERIFY( !ec );
VERIFY( !n );
-#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/27_io/filesystem/operations/remove_all.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc
index 943d85c0cc2..d5266a46449 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc
@@ -41,9 +41,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/27_io/filesystem/operations/rename.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/rename.cc
index f23a2862a0b..b74e1133a76 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/rename.cc
+++ b/libstdc++-v3/testsuite/27_io/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);
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc
index ef973b7807b..e00e4aaa78e 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc
@@ -17,7 +17,6 @@
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }
-// { dg-xfail-if "symlinks not supported" { *-*-mingw* } }
#include <filesystem>
#include <testsuite_hooks.h>
@@ -39,6 +38,7 @@ test01()
fs::file_status st2 = fs::symlink_status(dot);
VERIFY( st2.type() == fs::file_type::directory );
+#ifndef NO_SYMLINKS
fs::path link = __gnu_test::nonexistent_path();
create_directory_symlink(dot, link);
__gnu_test::scoped_file l(link, __gnu_test::scoped_file::adopt_file);
@@ -49,6 +49,7 @@ test01()
st2 = fs::symlink_status(link, ec);
VERIFY( !ec );
VERIFY( st2.type() == fs::file_type::symlink );
+#endif
}
void
@@ -68,6 +69,7 @@ test02()
void
test03()
{
+#ifndef NO_SYMLINKS
if (!__gnu_test::permissions_are_testable())
return;
@@ -111,6 +113,7 @@ test03()
VERIFY( st2.type() == fs::file_type::symlink );
fs::permissions(dir, fs::perms::owner_all, ec);
+#endif
}
void
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc
index 244b753f84d..ad164f52809 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc
@@ -39,9 +39,7 @@ test01()
fs::create_directory(bar/"baz");
fs::path p;
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
-#else
+#ifndef NO_SYMLINKS
fs::create_symlink("../bar", foo/"bar");
p = fs::weakly_canonical(dir/"foo//./bar///../biz/.");
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 a201415921c..393fb315593 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 ca38328c5da..021897cfede 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 03060c6cbb3..df27748ff99 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 67e5fddca00..5e9346d5c73 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 833aa13dd15..5866e334d7b 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 75dae3eac51..d0a90976a71 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 <experimental/filesystem>
#include <testsuite_hooks.h>
diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/remove.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/remove.cc
index c01f140ee59..4ffc74093b8 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 4b0ce85cf97..11c07d4f781 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 46776e80994..37e743b770f 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);
diff --git a/libstdc++-v3/testsuite/lib/dg-options.exp b/libstdc++-v3/testsuite/lib/dg-options.exp
index 15f37da468a..e624a69460e 100644
--- a/libstdc++-v3/testsuite/lib/dg-options.exp
+++ b/libstdc++-v3/testsuite/lib/dg-options.exp
@@ -241,6 +241,15 @@ proc dg-require-filesystem-ts { args } {
return
}
+proc dg-require-target-fs-symlinks { args } {
+ if { ![ check_v3_target_fs_symlinks ] } {
+ upvar dg-do-what dg-do-what
+ set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+ return
+ }
+ return
+}
+
proc add_options_for_no_pch { flags } {
# This forces any generated and possibly included PCH to be invalid.
return "-D__GLIBCXX__=99999999"
diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 93fdfee687d..03f47e8d772 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -974,13 +974,16 @@ proc v3_try_preprocess { name code flags } {
}
# Return 1 if COND evaluates to true in the preprocessor, 0 otherwise.
-# The <bits/c++config.h> config header is included.
-proc v3_check_preprocessor_condition { name cond } {
+# The <bits/c++config.h> config header is included, and INC, if given,
+# is pasted between it and the condition evaluation, so it can be used
+# for additional #include's.
+proc v3_check_preprocessor_condition { name cond { inc "" } } {
global cxxflags
global DEFAULT_CXXFLAGS
set code "
#include <bits/c++config.h>
+ $inc
#if ! ($cond)
#error '$cond' is false
#endif
@@ -1267,6 +1270,14 @@ proc check_v3_target_filesystem_ts { } {
}]
}
+# Return 1 if the libstdc++ filesystem create_symlinks implementation
+# is not an always-failing dummy.
+proc check_v3_target_fs_symlinks { } {
+ set inc "#include <testsuite_fs.h>"
+ set cond "!defined NO_SYMLINKS"
+ return [v3_check_preprocessor_condition fs_symlinks $cond $inc]
+}
+
# Return 1 if the "cxx11" ABI is in use using the current flags, 0 otherwise.
# Any flags provided by RUNTESTFLAGS or a target board will be used here.
# Flags added in the test by dg-options or dg-add-options will not be used.
diff --git a/libstdc++-v3/testsuite/util/testsuite_fs.h b/libstdc++-v3/testsuite/util/testsuite_fs.h
index 9358a04e56c..03af7ae96e3 100644
--- a/libstdc++-v3/testsuite/util/testsuite_fs.h
+++ b/libstdc++-v3/testsuite/util/testsuite_fs.h
@@ -42,6 +42,10 @@ namespace test_fs = std::experimental::filesystem;
#include <random> // std::random_device
#endif
+#ifndef _GLIBCXX_HAVE_SYMLINK
+#define NO_SYMLINKS
+#endif
+
namespace __gnu_test
{
#define PATH_CHK(p1, p2, fn) \
^ permalink raw reply [flat|nested] 7+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] libstdc++: testsuite: conditionalize symlink tests
@ 2022-06-23 12:43 Alexandre Oliva
0 siblings, 0 replies; 7+ messages in thread
From: Alexandre Oliva @ 2022-06-23 12:43 UTC (permalink / raw)
To: gcc-cvs, libstdc++-cvs
https://gcc.gnu.org/g:4a87f3148cfe15c3d38295b82958c48e843a0fc3
commit 4a87f3148cfe15c3d38295b82958c48e843a0fc3
Author: Alexandre Oliva <oliva@adacore.com>
Date: Mon Jun 20 20:03:05 2022 -0300
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_itreator.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.
Diff:
---
.../testsuite/27_io/filesystem/operations/canonical.cc | 5 ++++-
.../testsuite/27_io/filesystem/operations/copy.cc | 7 ++-----
.../27_io/filesystem/operations/create_directories.cc | 4 +---
.../27_io/filesystem/operations/create_directory.cc | 4 +---
.../testsuite/27_io/filesystem/operations/permissions.cc | 4 ++++
.../testsuite/27_io/filesystem/operations/read_symlink.cc | 2 +-
.../testsuite/27_io/filesystem/operations/remove.cc | 4 +---
.../testsuite/27_io/filesystem/operations/remove_all.cc | 4 +---
.../testsuite/27_io/filesystem/operations/rename.cc | 4 +---
.../27_io/filesystem/operations/symlink_status.cc | 5 ++++-
.../27_io/filesystem/operations/weakly_canonical.cc | 4 +---
.../filesystem/iterators/recursive_directory_iterator.cc | 2 +-
.../testsuite/experimental/filesystem/operations/copy.cc | 7 ++-----
.../filesystem/operations/create_directories.cc | 4 +---
.../filesystem/operations/create_directory.cc | 4 +---
.../experimental/filesystem/operations/permissions.cc | 4 ++++
.../experimental/filesystem/operations/read_symlink.cc | 2 +-
.../experimental/filesystem/operations/remove.cc | 5 +----
.../experimental/filesystem/operations/remove_all.cc | 4 +---
.../experimental/filesystem/operations/rename.cc | 4 +---
libstdc++-v3/testsuite/lib/dg-options.exp | 9 +++++++++
libstdc++-v3/testsuite/lib/libstdc++.exp | 15 +++++++++++++--
libstdc++-v3/testsuite/util/testsuite_fs.h | 4 ++++
23 files changed, 60 insertions(+), 51 deletions(-)
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc
index bc7ef0de2b7..9c432b25acf 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc
@@ -111,9 +111,12 @@ test03()
fs::path foo = dir/"foo", bar = dir/"bar";
fs::create_directory(foo);
fs::create_directory(bar);
+#ifdef NO_SYMLINKS
#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
const fs::path baz = dir/"foo\\\\..\\bar///";
+#else
+ const fs::path baz = dir/"foo//../bar///";
+#endif
#else
fs::create_symlink("../bar", foo/"baz");
const fs::path baz = dir/"foo//./baz///";
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
index f3081f4b64e..f9fb4dff77e 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
@@ -66,11 +66,7 @@ test01()
void
test02()
{
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
- return;
-#endif
-
+#ifndef NO_SYMLINKS
const std::error_code bad_ec = make_error_code(std::errc::invalid_argument);
auto from = __gnu_test::nonexistent_path();
std::error_code ec;
@@ -110,6 +106,7 @@ test02()
remove(from, ec);
remove(to, ec);
+#endif
}
// Test is_regular_file(f) case.
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc
index 4a7ba1fcb49..2b48c152e39 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc
@@ -148,9 +148,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/27_io/filesystem/operations/create_directory.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directory.cc
index 90f98302c00..aa59f7f3ee2 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directory.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directory.cc
@@ -70,9 +70,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/27_io/filesystem/operations/permissions.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/permissions.cc
index deed759be80..ee5afd529ba 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/permissions.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/permissions.cc
@@ -76,6 +76,7 @@ test02()
void
test03()
{
+#ifndef NO_SYMLINKS
using std::filesystem::perms;
using std::filesystem::perm_options;
@@ -111,11 +112,13 @@ test03()
VERIFY( !caught );
remove(p);
+#endif
}
void
test04()
{
+#ifndef NO_SYMLINKS
using perms = std::filesystem::perms;
auto p = __gnu_test::nonexistent_path();
@@ -137,6 +140,7 @@ test04()
VERIFY( ec == ec2 );
remove(p);
+#endif
}
void
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc
index 68bbab33bc9..030d6271de5 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc
@@ -17,7 +17,7 @@
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }
-// { dg-xfail-if "symlinks not supported" { *-*-mingw* } }
+// { dg-require-target-fs-symlinks "" }
#include <filesystem>
#include <testsuite_hooks.h>
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc
index 26f2d548f82..f769723ae30 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc
@@ -41,9 +41,7 @@ test01()
VERIFY( !ec );
VERIFY( !n );
-#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/27_io/filesystem/operations/remove_all.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc
index 943d85c0cc2..d5266a46449 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc
@@ -41,9 +41,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/27_io/filesystem/operations/rename.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/rename.cc
index f23a2862a0b..b74e1133a76 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/rename.cc
+++ b/libstdc++-v3/testsuite/27_io/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);
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc
index ef973b7807b..e00e4aaa78e 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc
@@ -17,7 +17,6 @@
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }
-// { dg-xfail-if "symlinks not supported" { *-*-mingw* } }
#include <filesystem>
#include <testsuite_hooks.h>
@@ -39,6 +38,7 @@ test01()
fs::file_status st2 = fs::symlink_status(dot);
VERIFY( st2.type() == fs::file_type::directory );
+#ifndef NO_SYMLINKS
fs::path link = __gnu_test::nonexistent_path();
create_directory_symlink(dot, link);
__gnu_test::scoped_file l(link, __gnu_test::scoped_file::adopt_file);
@@ -49,6 +49,7 @@ test01()
st2 = fs::symlink_status(link, ec);
VERIFY( !ec );
VERIFY( st2.type() == fs::file_type::symlink );
+#endif
}
void
@@ -68,6 +69,7 @@ test02()
void
test03()
{
+#ifndef NO_SYMLINKS
if (!__gnu_test::permissions_are_testable())
return;
@@ -111,6 +113,7 @@ test03()
VERIFY( st2.type() == fs::file_type::symlink );
fs::permissions(dir, fs::perms::owner_all, ec);
+#endif
}
void
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc
index 244b753f84d..ad164f52809 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc
@@ -39,9 +39,7 @@ test01()
fs::create_directory(bar/"baz");
fs::path p;
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
-#else
+#ifndef NO_SYMLINKS
fs::create_symlink("../bar", foo/"bar");
p = fs::weakly_canonical(dir/"foo//./bar///../biz/.");
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 a201415921c..393fb315593 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 ca38328c5da..021897cfede 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 03060c6cbb3..df27748ff99 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 67e5fddca00..5e9346d5c73 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 833aa13dd15..5866e334d7b 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 75dae3eac51..d0a90976a71 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 <experimental/filesystem>
#include <testsuite_hooks.h>
diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/remove.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/remove.cc
index c01f140ee59..4ffc74093b8 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 4b0ce85cf97..11c07d4f781 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 46776e80994..37e743b770f 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);
diff --git a/libstdc++-v3/testsuite/lib/dg-options.exp b/libstdc++-v3/testsuite/lib/dg-options.exp
index 15f37da468a..e624a69460e 100644
--- a/libstdc++-v3/testsuite/lib/dg-options.exp
+++ b/libstdc++-v3/testsuite/lib/dg-options.exp
@@ -241,6 +241,15 @@ proc dg-require-filesystem-ts { args } {
return
}
+proc dg-require-target-fs-symlinks { args } {
+ if { ![ check_v3_target_fs_symlinks ] } {
+ upvar dg-do-what dg-do-what
+ set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+ return
+ }
+ return
+}
+
proc add_options_for_no_pch { flags } {
# This forces any generated and possibly included PCH to be invalid.
return "-D__GLIBCXX__=99999999"
diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 93fdfee687d..03f47e8d772 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -974,13 +974,16 @@ proc v3_try_preprocess { name code flags } {
}
# Return 1 if COND evaluates to true in the preprocessor, 0 otherwise.
-# The <bits/c++config.h> config header is included.
-proc v3_check_preprocessor_condition { name cond } {
+# The <bits/c++config.h> config header is included, and INC, if given,
+# is pasted between it and the condition evaluation, so it can be used
+# for additional #include's.
+proc v3_check_preprocessor_condition { name cond { inc "" } } {
global cxxflags
global DEFAULT_CXXFLAGS
set code "
#include <bits/c++config.h>
+ $inc
#if ! ($cond)
#error '$cond' is false
#endif
@@ -1267,6 +1270,14 @@ proc check_v3_target_filesystem_ts { } {
}]
}
+# Return 1 if the libstdc++ filesystem create_symlinks implementation
+# is not an always-failing dummy.
+proc check_v3_target_fs_symlinks { } {
+ set inc "#include <testsuite_fs.h>"
+ set cond "!defined NO_SYMLINKS"
+ return [v3_check_preprocessor_condition fs_symlinks $cond $inc]
+}
+
# Return 1 if the "cxx11" ABI is in use using the current flags, 0 otherwise.
# Any flags provided by RUNTESTFLAGS or a target board will be used here.
# Flags added in the test by dg-options or dg-add-options will not be used.
diff --git a/libstdc++-v3/testsuite/util/testsuite_fs.h b/libstdc++-v3/testsuite/util/testsuite_fs.h
index 9358a04e56c..03af7ae96e3 100644
--- a/libstdc++-v3/testsuite/util/testsuite_fs.h
+++ b/libstdc++-v3/testsuite/util/testsuite_fs.h
@@ -42,6 +42,10 @@ namespace test_fs = std::experimental::filesystem;
#include <random> // std::random_device
#endif
+#ifndef _GLIBCXX_HAVE_SYMLINK
+#define NO_SYMLINKS
+#endif
+
namespace __gnu_test
{
#define PATH_CHK(p1, p2, fn) \
^ permalink raw reply [flat|nested] 7+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] libstdc++: testsuite: conditionalize symlink tests
@ 2022-06-23 12:29 Alexandre Oliva
0 siblings, 0 replies; 7+ messages in thread
From: Alexandre Oliva @ 2022-06-23 12:29 UTC (permalink / raw)
To: gcc-cvs, libstdc++-cvs
https://gcc.gnu.org/g:c25c3a8ac6052b35aaddb340093026cb07cee8dd
commit c25c3a8ac6052b35aaddb340093026cb07cee8dd
Author: Alexandre Oliva <oliva@adacore.com>
Date: Mon Jun 20 20:03:05 2022 -0300
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_itreator.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 inc parameter. Include
it after bits/c++config.h. Adjust all callers.
(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.
Diff:
---
.../testsuite/27_io/filesystem/operations/canonical.cc | 5 ++++-
.../testsuite/27_io/filesystem/operations/copy.cc | 7 ++-----
.../27_io/filesystem/operations/create_directories.cc | 4 +---
.../27_io/filesystem/operations/create_directory.cc | 4 +---
.../testsuite/27_io/filesystem/operations/permissions.cc | 4 ++++
.../testsuite/27_io/filesystem/operations/read_symlink.cc | 2 +-
.../testsuite/27_io/filesystem/operations/remove.cc | 4 +---
.../testsuite/27_io/filesystem/operations/remove_all.cc | 4 +---
.../testsuite/27_io/filesystem/operations/rename.cc | 4 +---
.../27_io/filesystem/operations/symlink_status.cc | 5 ++++-
.../27_io/filesystem/operations/weakly_canonical.cc | 4 +---
.../filesystem/iterators/recursive_directory_iterator.cc | 2 +-
.../testsuite/experimental/filesystem/operations/copy.cc | 7 ++-----
.../filesystem/operations/create_directories.cc | 4 +---
.../filesystem/operations/create_directory.cc | 4 +---
.../experimental/filesystem/operations/permissions.cc | 4 ++++
.../experimental/filesystem/operations/read_symlink.cc | 2 +-
.../experimental/filesystem/operations/remove.cc | 5 +----
.../experimental/filesystem/operations/remove_all.cc | 4 +---
.../experimental/filesystem/operations/rename.cc | 4 +---
libstdc++-v3/testsuite/lib/dg-options.exp | 9 +++++++++
libstdc++-v3/testsuite/lib/libstdc++.exp | 15 +++++++++++++--
libstdc++-v3/testsuite/util/testsuite_fs.h | 4 ++++
23 files changed, 60 insertions(+), 51 deletions(-)
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc
index bc7ef0de2b7..9c432b25acf 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc
@@ -111,9 +111,12 @@ test03()
fs::path foo = dir/"foo", bar = dir/"bar";
fs::create_directory(foo);
fs::create_directory(bar);
+#ifdef NO_SYMLINKS
#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
const fs::path baz = dir/"foo\\\\..\\bar///";
+#else
+ const fs::path baz = dir/"foo//../bar///";
+#endif
#else
fs::create_symlink("../bar", foo/"baz");
const fs::path baz = dir/"foo//./baz///";
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
index f3081f4b64e..f9fb4dff77e 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
@@ -66,11 +66,7 @@ test01()
void
test02()
{
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
- return;
-#endif
-
+#ifndef NO_SYMLINKS
const std::error_code bad_ec = make_error_code(std::errc::invalid_argument);
auto from = __gnu_test::nonexistent_path();
std::error_code ec;
@@ -110,6 +106,7 @@ test02()
remove(from, ec);
remove(to, ec);
+#endif
}
// Test is_regular_file(f) case.
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc
index 4a7ba1fcb49..2b48c152e39 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc
@@ -148,9 +148,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/27_io/filesystem/operations/create_directory.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directory.cc
index 90f98302c00..aa59f7f3ee2 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directory.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directory.cc
@@ -70,9 +70,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/27_io/filesystem/operations/permissions.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/permissions.cc
index deed759be80..ee5afd529ba 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/permissions.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/permissions.cc
@@ -76,6 +76,7 @@ test02()
void
test03()
{
+#ifndef NO_SYMLINKS
using std::filesystem::perms;
using std::filesystem::perm_options;
@@ -111,11 +112,13 @@ test03()
VERIFY( !caught );
remove(p);
+#endif
}
void
test04()
{
+#ifndef NO_SYMLINKS
using perms = std::filesystem::perms;
auto p = __gnu_test::nonexistent_path();
@@ -137,6 +140,7 @@ test04()
VERIFY( ec == ec2 );
remove(p);
+#endif
}
void
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc
index 68bbab33bc9..030d6271de5 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc
@@ -17,7 +17,7 @@
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }
-// { dg-xfail-if "symlinks not supported" { *-*-mingw* } }
+// { dg-require-target-fs-symlinks "" }
#include <filesystem>
#include <testsuite_hooks.h>
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc
index 26f2d548f82..f769723ae30 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc
@@ -41,9 +41,7 @@ test01()
VERIFY( !ec );
VERIFY( !n );
-#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/27_io/filesystem/operations/remove_all.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc
index 943d85c0cc2..d5266a46449 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc
@@ -41,9 +41,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/27_io/filesystem/operations/rename.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/rename.cc
index f23a2862a0b..b74e1133a76 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/rename.cc
+++ b/libstdc++-v3/testsuite/27_io/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);
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc
index ef973b7807b..e00e4aaa78e 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc
@@ -17,7 +17,6 @@
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }
-// { dg-xfail-if "symlinks not supported" { *-*-mingw* } }
#include <filesystem>
#include <testsuite_hooks.h>
@@ -39,6 +38,7 @@ test01()
fs::file_status st2 = fs::symlink_status(dot);
VERIFY( st2.type() == fs::file_type::directory );
+#ifndef NO_SYMLINKS
fs::path link = __gnu_test::nonexistent_path();
create_directory_symlink(dot, link);
__gnu_test::scoped_file l(link, __gnu_test::scoped_file::adopt_file);
@@ -49,6 +49,7 @@ test01()
st2 = fs::symlink_status(link, ec);
VERIFY( !ec );
VERIFY( st2.type() == fs::file_type::symlink );
+#endif
}
void
@@ -68,6 +69,7 @@ test02()
void
test03()
{
+#ifndef NO_SYMLINKS
if (!__gnu_test::permissions_are_testable())
return;
@@ -111,6 +113,7 @@ test03()
VERIFY( st2.type() == fs::file_type::symlink );
fs::permissions(dir, fs::perms::owner_all, ec);
+#endif
}
void
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc
index 244b753f84d..ad164f52809 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc
@@ -39,9 +39,7 @@ test01()
fs::create_directory(bar/"baz");
fs::path p;
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
-#else
+#ifndef NO_SYMLINKS
fs::create_symlink("../bar", foo/"bar");
p = fs::weakly_canonical(dir/"foo//./bar///../biz/.");
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 a201415921c..393fb315593 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 ca38328c5da..021897cfede 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 03060c6cbb3..df27748ff99 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 67e5fddca00..5e9346d5c73 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 833aa13dd15..5866e334d7b 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 75dae3eac51..d0a90976a71 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 <experimental/filesystem>
#include <testsuite_hooks.h>
diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/remove.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/remove.cc
index c01f140ee59..4ffc74093b8 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 4b0ce85cf97..11c07d4f781 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 46776e80994..37e743b770f 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);
diff --git a/libstdc++-v3/testsuite/lib/dg-options.exp b/libstdc++-v3/testsuite/lib/dg-options.exp
index 15f37da468a..e624a69460e 100644
--- a/libstdc++-v3/testsuite/lib/dg-options.exp
+++ b/libstdc++-v3/testsuite/lib/dg-options.exp
@@ -241,6 +241,15 @@ proc dg-require-filesystem-ts { args } {
return
}
+proc dg-require-target-fs-symlinks { args } {
+ if { ![ check_v3_target_fs_symlinks ] } {
+ upvar dg-do-what dg-do-what
+ set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+ return
+ }
+ return
+}
+
proc add_options_for_no_pch { flags } {
# This forces any generated and possibly included PCH to be invalid.
return "-D__GLIBCXX__=99999999"
diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 93fdfee687d..03f47e8d772 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -974,13 +974,16 @@ proc v3_try_preprocess { name code flags } {
}
# Return 1 if COND evaluates to true in the preprocessor, 0 otherwise.
-# The <bits/c++config.h> config header is included.
-proc v3_check_preprocessor_condition { name cond } {
+# The <bits/c++config.h> config header is included, and INC, if given,
+# is pasted between it and the condition evaluation, so it can be used
+# for additional #include's.
+proc v3_check_preprocessor_condition { name cond { inc "" } } {
global cxxflags
global DEFAULT_CXXFLAGS
set code "
#include <bits/c++config.h>
+ $inc
#if ! ($cond)
#error '$cond' is false
#endif
@@ -1267,6 +1270,14 @@ proc check_v3_target_filesystem_ts { } {
}]
}
+# Return 1 if the libstdc++ filesystem create_symlinks implementation
+# is not an always-failing dummy.
+proc check_v3_target_fs_symlinks { } {
+ set inc "#include <testsuite_fs.h>"
+ set cond "!defined NO_SYMLINKS"
+ return [v3_check_preprocessor_condition fs_symlinks $cond $inc]
+}
+
# Return 1 if the "cxx11" ABI is in use using the current flags, 0 otherwise.
# Any flags provided by RUNTESTFLAGS or a target board will be used here.
# Flags added in the test by dg-options or dg-add-options will not be used.
diff --git a/libstdc++-v3/testsuite/util/testsuite_fs.h b/libstdc++-v3/testsuite/util/testsuite_fs.h
index 9358a04e56c..03af7ae96e3 100644
--- a/libstdc++-v3/testsuite/util/testsuite_fs.h
+++ b/libstdc++-v3/testsuite/util/testsuite_fs.h
@@ -42,6 +42,10 @@ namespace test_fs = std::experimental::filesystem;
#include <random> // std::random_device
#endif
+#ifndef _GLIBCXX_HAVE_SYMLINK
+#define NO_SYMLINKS
+#endif
+
namespace __gnu_test
{
#define PATH_CHK(p1, p2, fn) \
^ permalink raw reply [flat|nested] 7+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] libstdc++: testsuite: conditionalize symlink tests
@ 2022-06-23 12:21 Alexandre Oliva
0 siblings, 0 replies; 7+ messages in thread
From: Alexandre Oliva @ 2022-06-23 12:21 UTC (permalink / raw)
To: gcc-cvs, libstdc++-cvs
https://gcc.gnu.org/g:00c5d8cafedb84cfafe9fe38ab62fc4e7f6d730c
commit 00c5d8cafedb84cfafe9fe38ab62fc4e7f6d730c
Author: Alexandre Oliva <oliva@adacore.com>
Date: Mon Jun 20 20:03:05 2022 -0300
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_itreator.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 inc parameter. Include
it after bits/c++config.h. Adjust all callers.
(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.
Diff:
---
.../testsuite/27_io/filesystem/operations/canonical.cc | 5 ++++-
.../testsuite/27_io/filesystem/operations/copy.cc | 7 ++-----
.../27_io/filesystem/operations/create_directories.cc | 4 +---
.../27_io/filesystem/operations/create_directory.cc | 4 +---
.../testsuite/27_io/filesystem/operations/permissions.cc | 4 ++++
.../testsuite/27_io/filesystem/operations/read_symlink.cc | 2 +-
.../testsuite/27_io/filesystem/operations/remove.cc | 4 +---
.../testsuite/27_io/filesystem/operations/remove_all.cc | 4 +---
.../testsuite/27_io/filesystem/operations/rename.cc | 4 +---
.../27_io/filesystem/operations/symlink_status.cc | 5 ++++-
.../27_io/filesystem/operations/weakly_canonical.cc | 4 +---
.../filesystem/iterators/recursive_directory_iterator.cc | 2 +-
.../testsuite/experimental/filesystem/operations/copy.cc | 7 ++-----
.../filesystem/operations/create_directories.cc | 4 +---
.../filesystem/operations/create_directory.cc | 4 +---
.../experimental/filesystem/operations/permissions.cc | 4 ++++
.../experimental/filesystem/operations/read_symlink.cc | 2 +-
.../experimental/filesystem/operations/remove.cc | 5 +----
.../experimental/filesystem/operations/remove_all.cc | 4 +---
.../experimental/filesystem/operations/rename.cc | 4 +---
libstdc++-v3/testsuite/lib/dg-options.exp | 9 +++++++++
libstdc++-v3/testsuite/lib/libstdc++.exp | 15 +++++++++++++--
libstdc++-v3/testsuite/util/testsuite_fs.h | 5 +++++
23 files changed, 61 insertions(+), 51 deletions(-)
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc
index bc7ef0de2b7..9c432b25acf 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc
@@ -111,9 +111,12 @@ test03()
fs::path foo = dir/"foo", bar = dir/"bar";
fs::create_directory(foo);
fs::create_directory(bar);
+#ifdef NO_SYMLINKS
#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
const fs::path baz = dir/"foo\\\\..\\bar///";
+#else
+ const fs::path baz = dir/"foo//../bar///";
+#endif
#else
fs::create_symlink("../bar", foo/"baz");
const fs::path baz = dir/"foo//./baz///";
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
index f3081f4b64e..f9fb4dff77e 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
@@ -66,11 +66,7 @@ test01()
void
test02()
{
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
- return;
-#endif
-
+#ifndef NO_SYMLINKS
const std::error_code bad_ec = make_error_code(std::errc::invalid_argument);
auto from = __gnu_test::nonexistent_path();
std::error_code ec;
@@ -110,6 +106,7 @@ test02()
remove(from, ec);
remove(to, ec);
+#endif
}
// Test is_regular_file(f) case.
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc
index 4a7ba1fcb49..2b48c152e39 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc
@@ -148,9 +148,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/27_io/filesystem/operations/create_directory.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directory.cc
index 90f98302c00..aa59f7f3ee2 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directory.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directory.cc
@@ -70,9 +70,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/27_io/filesystem/operations/permissions.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/permissions.cc
index deed759be80..ee5afd529ba 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/permissions.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/permissions.cc
@@ -76,6 +76,7 @@ test02()
void
test03()
{
+#ifndef NO_SYMLINKS
using std::filesystem::perms;
using std::filesystem::perm_options;
@@ -111,11 +112,13 @@ test03()
VERIFY( !caught );
remove(p);
+#endif
}
void
test04()
{
+#ifndef NO_SYMLINKS
using perms = std::filesystem::perms;
auto p = __gnu_test::nonexistent_path();
@@ -137,6 +140,7 @@ test04()
VERIFY( ec == ec2 );
remove(p);
+#endif
}
void
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc
index 68bbab33bc9..030d6271de5 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc
@@ -17,7 +17,7 @@
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }
-// { dg-xfail-if "symlinks not supported" { *-*-mingw* } }
+// { dg-require-target-fs-symlinks "" }
#include <filesystem>
#include <testsuite_hooks.h>
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc
index 26f2d548f82..f769723ae30 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc
@@ -41,9 +41,7 @@ test01()
VERIFY( !ec );
VERIFY( !n );
-#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/27_io/filesystem/operations/remove_all.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc
index 943d85c0cc2..d5266a46449 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc
@@ -41,9 +41,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/27_io/filesystem/operations/rename.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/rename.cc
index f23a2862a0b..b74e1133a76 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/rename.cc
+++ b/libstdc++-v3/testsuite/27_io/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);
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc
index ef973b7807b..e00e4aaa78e 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc
@@ -17,7 +17,6 @@
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }
-// { dg-xfail-if "symlinks not supported" { *-*-mingw* } }
#include <filesystem>
#include <testsuite_hooks.h>
@@ -39,6 +38,7 @@ test01()
fs::file_status st2 = fs::symlink_status(dot);
VERIFY( st2.type() == fs::file_type::directory );
+#ifndef NO_SYMLINKS
fs::path link = __gnu_test::nonexistent_path();
create_directory_symlink(dot, link);
__gnu_test::scoped_file l(link, __gnu_test::scoped_file::adopt_file);
@@ -49,6 +49,7 @@ test01()
st2 = fs::symlink_status(link, ec);
VERIFY( !ec );
VERIFY( st2.type() == fs::file_type::symlink );
+#endif
}
void
@@ -68,6 +69,7 @@ test02()
void
test03()
{
+#ifndef NO_SYMLINKS
if (!__gnu_test::permissions_are_testable())
return;
@@ -111,6 +113,7 @@ test03()
VERIFY( st2.type() == fs::file_type::symlink );
fs::permissions(dir, fs::perms::owner_all, ec);
+#endif
}
void
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc
index 244b753f84d..ad164f52809 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc
@@ -39,9 +39,7 @@ test01()
fs::create_directory(bar/"baz");
fs::path p;
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
-#else
+#ifndef NO_SYMLINKS
fs::create_symlink("../bar", foo/"bar");
p = fs::weakly_canonical(dir/"foo//./bar///../biz/.");
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 a201415921c..393fb315593 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 ca38328c5da..021897cfede 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 03060c6cbb3..df27748ff99 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 67e5fddca00..5e9346d5c73 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 833aa13dd15..5866e334d7b 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 75dae3eac51..d0a90976a71 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 <experimental/filesystem>
#include <testsuite_hooks.h>
diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/remove.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/remove.cc
index c01f140ee59..4ffc74093b8 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 4b0ce85cf97..11c07d4f781 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 46776e80994..37e743b770f 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);
diff --git a/libstdc++-v3/testsuite/lib/dg-options.exp b/libstdc++-v3/testsuite/lib/dg-options.exp
index 15f37da468a..e624a69460e 100644
--- a/libstdc++-v3/testsuite/lib/dg-options.exp
+++ b/libstdc++-v3/testsuite/lib/dg-options.exp
@@ -241,6 +241,15 @@ proc dg-require-filesystem-ts { args } {
return
}
+proc dg-require-target-fs-symlinks { args } {
+ if { ![ check_v3_target_fs_symlinks ] } {
+ upvar dg-do-what dg-do-what
+ set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+ return
+ }
+ return
+}
+
proc add_options_for_no_pch { flags } {
# This forces any generated and possibly included PCH to be invalid.
return "-D__GLIBCXX__=99999999"
diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 93fdfee687d..03f47e8d772 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -974,13 +974,16 @@ proc v3_try_preprocess { name code flags } {
}
# Return 1 if COND evaluates to true in the preprocessor, 0 otherwise.
-# The <bits/c++config.h> config header is included.
-proc v3_check_preprocessor_condition { name cond } {
+# The <bits/c++config.h> config header is included, and INC, if given,
+# is pasted between it and the condition evaluation, so it can be used
+# for additional #include's.
+proc v3_check_preprocessor_condition { name cond { inc "" } } {
global cxxflags
global DEFAULT_CXXFLAGS
set code "
#include <bits/c++config.h>
+ $inc
#if ! ($cond)
#error '$cond' is false
#endif
@@ -1267,6 +1270,14 @@ proc check_v3_target_filesystem_ts { } {
}]
}
+# Return 1 if the libstdc++ filesystem create_symlinks implementation
+# is not an always-failing dummy.
+proc check_v3_target_fs_symlinks { } {
+ set inc "#include <testsuite_fs.h>"
+ set cond "!defined NO_SYMLINKS"
+ return [v3_check_preprocessor_condition fs_symlinks $cond $inc]
+}
+
# Return 1 if the "cxx11" ABI is in use using the current flags, 0 otherwise.
# Any flags provided by RUNTESTFLAGS or a target board will be used here.
# Flags added in the test by dg-options or dg-add-options will not be used.
diff --git a/libstdc++-v3/testsuite/util/testsuite_fs.h b/libstdc++-v3/testsuite/util/testsuite_fs.h
index 9358a04e56c..048f03103e4 100644
--- a/libstdc++-v3/testsuite/util/testsuite_fs.h
+++ b/libstdc++-v3/testsuite/util/testsuite_fs.h
@@ -42,6 +42,11 @@ namespace test_fs = std::experimental::filesystem;
#include <random> // std::random_device
#endif
+#if defined(__MINGW32__) || defined(__MINGW64__) \
+ || !defined (_GLIBCXX_HAVE_SYMLINK)
+#define NO_SYMLINKS
+#endif
+
namespace __gnu_test
{
#define PATH_CHK(p1, p2, fn) \
^ permalink raw reply [flat|nested] 7+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] libstdc++: testsuite: conditionalize symlink tests
@ 2022-06-23 7:15 Alexandre Oliva
0 siblings, 0 replies; 7+ messages in thread
From: Alexandre Oliva @ 2022-06-23 7:15 UTC (permalink / raw)
To: gcc-cvs, libstdc++-cvs
https://gcc.gnu.org/g:d5455ccd99d0ac2a18c36ec94761488578be56a7
commit d5455ccd99d0ac2a18c36ec94761488578be56a7
Author: Alexandre Oliva <oliva@adacore.com>
Date: Mon Jun 20 20:03:05 2022 -0300
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_itreator.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 inc parameter. Include
it after bits/c++config.h. Adjust all callers.
(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.
Diff:
---
.../27_io/filesystem/operations/canonical.cc | 5 +-
.../testsuite/27_io/filesystem/operations/copy.cc | 7 +--
.../filesystem/operations/create_directories.cc | 4 +-
.../filesystem/operations/create_directory.cc | 4 +-
.../27_io/filesystem/operations/permissions.cc | 4 ++
.../27_io/filesystem/operations/read_symlink.cc | 2 +-
.../27_io/filesystem/operations/remove.cc | 4 +-
.../27_io/filesystem/operations/remove_all.cc | 4 +-
.../27_io/filesystem/operations/rename.cc | 4 +-
.../27_io/filesystem/operations/symlink_status.cc | 5 +-
.../filesystem/operations/weakly_canonical.cc | 4 +-
.../iterators/recursive_directory_iterator.cc | 2 +-
.../experimental/filesystem/operations/copy.cc | 7 +--
.../filesystem/operations/create_directories.cc | 4 +-
.../filesystem/operations/create_directory.cc | 4 +-
.../filesystem/operations/permissions.cc | 4 ++
.../filesystem/operations/read_symlink.cc | 2 +-
.../experimental/filesystem/operations/remove.cc | 5 +-
.../filesystem/operations/remove_all.cc | 4 +-
.../experimental/filesystem/operations/rename.cc | 4 +-
libstdc++-v3/testsuite/lib/dg-options.exp | 9 ++++
libstdc++-v3/testsuite/lib/libstdc++.exp | 55 +++++++++++++---------
libstdc++-v3/testsuite/util/testsuite_fs.h | 5 ++
23 files changed, 81 insertions(+), 71 deletions(-)
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc
index bc7ef0de2b7..156fd4d8149 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc
@@ -111,9 +111,12 @@ test03()
fs::path foo = dir/"foo", bar = dir/"bar";
fs::create_directory(foo);
fs::create_directory(bar);
+#if defined(NO_SYMLINK)
#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
const fs::path baz = dir/"foo\\\\..\\bar///";
+#else
+ const fs::path baz = dir/"foo//../bar///";
+#endif
#else
fs::create_symlink("../bar", foo/"baz");
const fs::path baz = dir/"foo//./baz///";
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
index f3081f4b64e..70b7f18c147 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
@@ -66,11 +66,7 @@ test01()
void
test02()
{
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
- return;
-#endif
-
+#ifndef NO_SYMLINK
const std::error_code bad_ec = make_error_code(std::errc::invalid_argument);
auto from = __gnu_test::nonexistent_path();
std::error_code ec;
@@ -110,6 +106,7 @@ test02()
remove(from, ec);
remove(to, ec);
+#endif
}
// Test is_regular_file(f) case.
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc
index 4a7ba1fcb49..57d64e2f981 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc
@@ -148,9 +148,7 @@ test03()
void
test04()
{
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // no symlinks
-#else
+#ifndef NO_SYMLINK
// 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/27_io/filesystem/operations/create_directory.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directory.cc
index 90f98302c00..14f71614267 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directory.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directory.cc
@@ -70,9 +70,7 @@ test01()
VERIFY( e.path1() == f );
}
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // no symlinks
-#else
+#ifndef NO_SYMLINK
// 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/27_io/filesystem/operations/permissions.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/permissions.cc
index deed759be80..f1d7ac04fa2 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/permissions.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/permissions.cc
@@ -76,6 +76,7 @@ test02()
void
test03()
{
+#ifndef NO_SYMLINK
using std::filesystem::perms;
using std::filesystem::perm_options;
@@ -111,11 +112,13 @@ test03()
VERIFY( !caught );
remove(p);
+#endif
}
void
test04()
{
+#ifndef NO_SYMLINK
using perms = std::filesystem::perms;
auto p = __gnu_test::nonexistent_path();
@@ -137,6 +140,7 @@ test04()
VERIFY( ec == ec2 );
remove(p);
+#endif
}
void
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc
index 68bbab33bc9..030d6271de5 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc
@@ -17,7 +17,7 @@
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }
-// { dg-xfail-if "symlinks not supported" { *-*-mingw* } }
+// { dg-require-target-fs-symlinks "" }
#include <filesystem>
#include <testsuite_hooks.h>
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc
index 26f2d548f82..e127b914a55 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc
@@ -41,9 +41,7 @@ test01()
VERIFY( !ec );
VERIFY( !n );
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
-#else
+#ifndef NO_SYMLINK
auto link = __gnu_test::nonexistent_path();
create_symlink(p, link); // dangling symlink
ec = bad_ec;
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc
index 943d85c0cc2..74ac777b3bb 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc
@@ -41,9 +41,7 @@ test01()
VERIFY( !ec );
VERIFY( n == 0 );
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
-#else
+#ifndef NO_SYMLINK
auto link = __gnu_test::nonexistent_path();
create_symlink(p, link); // dangling symlink
ec = bad_ec;
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/rename.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/rename.cc
index f23a2862a0b..e62204ab03f 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/rename.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/rename.cc
@@ -75,9 +75,7 @@ test01()
void
test_symlinks()
{
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
-#else
+#ifndef NO_SYMLINK
std::error_code ec;
const std::error_code bad_ec = make_error_code(std::errc::invalid_argument);
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc
index ef973b7807b..6ba9350c4f2 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc
@@ -17,7 +17,6 @@
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }
-// { dg-xfail-if "symlinks not supported" { *-*-mingw* } }
#include <filesystem>
#include <testsuite_hooks.h>
@@ -39,6 +38,7 @@ test01()
fs::file_status st2 = fs::symlink_status(dot);
VERIFY( st2.type() == fs::file_type::directory );
+#ifndef NO_SYMLINK
fs::path link = __gnu_test::nonexistent_path();
create_directory_symlink(dot, link);
__gnu_test::scoped_file l(link, __gnu_test::scoped_file::adopt_file);
@@ -49,6 +49,7 @@ test01()
st2 = fs::symlink_status(link, ec);
VERIFY( !ec );
VERIFY( st2.type() == fs::file_type::symlink );
+#endif
}
void
@@ -68,6 +69,7 @@ test02()
void
test03()
{
+#ifndef NO_SYMLINK
if (!__gnu_test::permissions_are_testable())
return;
@@ -111,6 +113,7 @@ test03()
VERIFY( st2.type() == fs::file_type::symlink );
fs::permissions(dir, fs::perms::owner_all, ec);
+#endif
}
void
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc
index 244b753f84d..0cf5609b374 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc
@@ -39,9 +39,7 @@ test01()
fs::create_directory(bar/"baz");
fs::path p;
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
-#else
+#ifndef NO_SYMLINK
fs::create_symlink("../bar", foo/"bar");
p = fs::weakly_canonical(dir/"foo//./bar///../biz/.");
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 a201415921c..393fb315593 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 ca38328c5da..6c9a8eecf60 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_SYMLINK
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 03060c6cbb3..f3a64ef0f4e 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_SYMLINK
// 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 67e5fddca00..0134ef85ac8 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_SYMLINK
// 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 833aa13dd15..1469e6c455a 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_SYMLINK
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_SYMLINK
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 75dae3eac51..d0a90976a71 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 <experimental/filesystem>
#include <testsuite_hooks.h>
diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/remove.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/remove.cc
index c01f140ee59..8cf06cb6e80 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_SYMLINK
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 4b0ce85cf97..9ad1352aa28 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_SYMLINK
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 46776e80994..40b45699dff 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_SYMLINK
std::error_code ec;
const std::error_code bad_ec = make_error_code(std::errc::invalid_argument);
diff --git a/libstdc++-v3/testsuite/lib/dg-options.exp b/libstdc++-v3/testsuite/lib/dg-options.exp
index 15f37da468a..e624a69460e 100644
--- a/libstdc++-v3/testsuite/lib/dg-options.exp
+++ b/libstdc++-v3/testsuite/lib/dg-options.exp
@@ -241,6 +241,15 @@ proc dg-require-filesystem-ts { args } {
return
}
+proc dg-require-target-fs-symlinks { args } {
+ if { ![ check_v3_target_fs_symlinks ] } {
+ upvar dg-do-what dg-do-what
+ set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+ return
+ }
+ return
+}
+
proc add_options_for_no_pch { flags } {
# This forces any generated and possibly included PCH to be invalid.
return "-D__GLIBCXX__=99999999"
diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 93fdfee687d..d71d88fb998 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -974,13 +974,16 @@ proc v3_try_preprocess { name code flags } {
}
# Return 1 if COND evaluates to true in the preprocessor, 0 otherwise.
-# The <bits/c++config.h> config header is included.
-proc v3_check_preprocessor_condition { name cond } {
+# The <bits/c++config.h> config header is included, and INC, if given,
+# is pasted between it and the condition evaluation, so it can be used
+# for additional #include's.
+proc v3_check_preprocessor_condition { name cond inc } {
global cxxflags
global DEFAULT_CXXFLAGS
set code "
#include <bits/c++config.h>
+ $inc
#if ! ($cond)
#error '$cond' is false
#endif
@@ -1030,7 +1033,7 @@ proc check_v3_target_normal_mode { } {
proc check_v3_target_normal_namespace { } {
return [check_v3_target_prop_cached et_normal_namespace {
set cond "!_GLIBCXX_INLINE_VERSION"
- return [v3_check_preprocessor_condition normal_namespace $cond]
+ return [v3_check_preprocessor_condition normal_namespace $cond ""]
}]
}
@@ -1051,7 +1054,7 @@ proc check_v3_target_parallel_mode { } {
proc check_v3_target_cstdint { } {
return [check_v3_target_prop_cached et_cstdint {
set cond "defined _GLIBCXX_USE_C99_STDINT_TR1"
- return [v3_check_preprocessor_condition cstdint $cond]
+ return [v3_check_preprocessor_condition cstdint $cond ""]
}]
}
@@ -1059,7 +1062,7 @@ proc check_v3_target_cstdint { } {
proc check_v3_target_cmath { } {
return [check_v3_target_prop_cached et_c99_math {
set cond "defined _GLIBCXX_USE_C99_MATH_TR1"
- return [v3_check_preprocessor_condition cmath $cond]
+ return [v3_check_preprocessor_condition cmath $cond ""]
}]
}
@@ -1101,7 +1104,7 @@ proc check_v3_target_thread_fence { } {
proc check_v3_target_atomic_builtins { } {
return [check_v3_target_prop_cached et_atomic_builtins {
set cond "__GCC_ATOMIC_BOOL_LOCK_FREE > 1 && __GCC_ATOMIC_INT_LOCK_FREE > 1"
- return [v3_check_preprocessor_condition atomic_builtins $cond]
+ return [v3_check_preprocessor_condition atomic_builtins $cond ""]
}]
}
@@ -1115,7 +1118,7 @@ proc check_effective_target_atomic_builtins { } {
proc check_v3_target_gthreads { } {
return [check_v3_target_prop_cached et_gthreads {
set cond "defined _GLIBCXX_HAS_GTHREADS"
- return [v3_check_preprocessor_condition gthreads $cond]
+ return [v3_check_preprocessor_condition gthreads $cond ""]
}]
}
@@ -1129,7 +1132,7 @@ proc check_v3_target_gthreads_timed { } {
return [check_v3_target_prop_cached et_gthreads_timed {
if [check_v3_target_gthreads] {
set cond "_GTHREAD_USE_MUTEX_TIMEDLOCK"
- return [v3_check_preprocessor_condition gthreads_timed $cond]
+ return [v3_check_preprocessor_condition gthreads_timed $cond ""]
} else {
return 0
}
@@ -1145,7 +1148,7 @@ proc check_effective_target_gthreads_timed { } {
proc check_v3_target_sleep { } {
return [check_v3_target_prop_cached et_sleep {
set cond "defined _GLIBCXX_USE_NANOSLEEP || defined _GLIBCXX_HAVE_SLEEP"
- return [v3_check_preprocessor_condition sleep $cond]
+ return [v3_check_preprocessor_condition sleep $cond ""]
}]
}
@@ -1153,7 +1156,7 @@ proc check_v3_target_sleep { } {
proc check_v3_target_sched_yield { } {
return [check_v3_target_prop_cached et_sched_yield {
set cond "defined _GLIBCXX_USE_SCHED_YIELD"
- return [v3_check_preprocessor_condition sched_yield $cond]
+ return [v3_check_preprocessor_condition sched_yield $cond ""]
}]
}
@@ -1163,7 +1166,7 @@ proc check_v3_target_string_conversions { } {
set cond "_GLIBCXX_USE_C99_STDIO && _GLIBCXX_USE_C99_STDLIB"
set cond "$cond && _GLIBCXX_USE_C99_WCHAR"
set cond "$cond && !defined _GLIBCXX_HAVE_BROKEN_VSWPRINTF"
- return [v3_check_preprocessor_condition string_conversions $cond]
+ return [v3_check_preprocessor_condition string_conversions $cond ""]
}]
}
@@ -1171,7 +1174,7 @@ proc check_v3_target_string_conversions { } {
proc check_v3_target_swprintf { } {
return [check_v3_target_prop_cached et_swprintf {
set cond "! defined _GLIBCXX_HAVE_BROKEN_VSWPRINTF"
- return [v3_check_preprocessor_condition swprintf $cond]
+ return [v3_check_preprocessor_condition swprintf $cond ""]
}]
}
@@ -1179,7 +1182,7 @@ proc check_v3_target_swprintf { } {
proc check_v3_target_binary_io { } {
return [check_v3_target_prop_cached et_binary_io {
set cond "! defined _GLIBCXX_HAVE_DOS_BASED_FILESYSTEM"
- return [v3_check_preprocessor_condition binary_io $cond]
+ return [v3_check_preprocessor_condition binary_io $cond ""]
}]
}
@@ -1192,7 +1195,7 @@ proc check_v3_target_nprocs { } {
set cond "$cond || defined _GLIBCXX_USE_SYSCTL_HW_NCPU"
set cond "$cond || defined _GLIBCXX_USE_SC_NPROCESSORS_ONLN"
set cond "$cond || defined _GLIBCXX_USE_SC_NPROC_ONLN"
- return [v3_check_preprocessor_condition nprocs $cond]
+ return [v3_check_preprocessor_condition nprocs $cond ""]
}]
}
@@ -1267,19 +1270,27 @@ proc check_v3_target_filesystem_ts { } {
}]
}
+# Return 1 if the libstdc++ filesystem create_symlinks implementation
+# is not an always-failing dummy.
+proc check_v3_target_fs_symlinks { } {
+ set inc "#include <testsuite_fs.h>"
+ set cond "!defined NO_SYMLINKS"
+ return [v3_check_preprocessor_condition fs_symlinks $cond $inc]
+}
+
# Return 1 if the "cxx11" ABI is in use using the current flags, 0 otherwise.
# Any flags provided by RUNTESTFLAGS or a target board will be used here.
# Flags added in the test by dg-options or dg-add-options will not be used.
proc check_effective_target_cxx11_abi { } {
set cond "_GLIBCXX_USE_CXX11_ABI"
- return [v3_check_preprocessor_condition cxx11_abi $cond]
+ return [v3_check_preprocessor_condition cxx11_abi $cond ""]
}
# Return 1 if std::random_device should be usable using the current flags,
# 0 otherwise.
proc check_effective_target_random_device { } {
set cond "_GLIBCXX_USE_RANDOM_TR1"
- return [v3_check_preprocessor_condition random_device $cond]
+ return [v3_check_preprocessor_condition random_device $cond ""]
}
# Return 1 if tbb parallel backend is available, 0 otherwise.
@@ -1318,7 +1329,7 @@ proc check_effective_target_tbb_backend { } {
proc check_effective_target_futex { } {
return [check_v3_target_prop_cached et_futex {
set cond "_GLIBCXX_HAVE_LINUX_FUTEX"
- return [v3_check_preprocessor_condition futex $cond]
+ return [v3_check_preprocessor_condition futex $cond ""]
}]
}
@@ -1326,7 +1337,7 @@ proc check_effective_target_futex { } {
proc check_effective_target_ieee_floats { } {
return [check_v3_target_prop_cached et_ieee_floats {
set cond "_GLIBCXX_FLOAT_IS_IEEE_BINARY32 && _GLIBCXX_DOUBLE_IS_IEEE_BINARY64"
- return [v3_check_preprocessor_condition ieee_floats $cond]
+ return [v3_check_preprocessor_condition ieee_floats $cond ""]
}]
}
@@ -1334,7 +1345,7 @@ proc check_effective_target_ieee_floats { } {
proc check_effective_target_net_ts_ip { } {
return [check_v3_target_prop_cached et_net_ts_ip {
set cond "__has_include(<netinet/in.h>)"
- return [v3_check_preprocessor_condition net_ts_ip $cond]
+ return [v3_check_preprocessor_condition net_ts_ip $cond ""]
}]
}
@@ -1342,7 +1353,7 @@ proc check_effective_target_net_ts_ip { } {
proc check_effective_target_std_allocator_new { } {
return [check_v3_target_prop_cached et_std_alloc_new {
set cond "_GLIBCXX_USE_ALLOCATOR_NEW"
- return [v3_check_preprocessor_condition std_alloc_new $cond]
+ return [v3_check_preprocessor_condition std_alloc_new $cond ""]
}]
}
@@ -1350,7 +1361,7 @@ proc check_effective_target_std_allocator_new { } {
proc check_effective_target_stacktrace { } {
return [check_v3_target_prop_cached et_stacktrace {
set cond "_GLIBCXX_HAVE_STACKTRACE"
- return [v3_check_preprocessor_condition stacktrace $cond]
+ return [v3_check_preprocessor_condition stacktrace $cond ""]
}]
}
@@ -1358,7 +1369,7 @@ proc check_effective_target_stacktrace { } {
proc check_effective_target_rtti { } {
return [check_v3_target_prop_cached et_rtti {
set cond "__cpp_rtti"
- return [v3_check_preprocessor_condition rtti $cond]
+ return [v3_check_preprocessor_condition rtti $cond ""]
}]
}
diff --git a/libstdc++-v3/testsuite/util/testsuite_fs.h b/libstdc++-v3/testsuite/util/testsuite_fs.h
index 9358a04e56c..048f03103e4 100644
--- a/libstdc++-v3/testsuite/util/testsuite_fs.h
+++ b/libstdc++-v3/testsuite/util/testsuite_fs.h
@@ -42,6 +42,11 @@ namespace test_fs = std::experimental::filesystem;
#include <random> // std::random_device
#endif
+#if defined(__MINGW32__) || defined(__MINGW64__) \
+ || !defined (_GLIBCXX_HAVE_SYMLINK)
+#define NO_SYMLINKS
+#endif
+
namespace __gnu_test
{
#define PATH_CHK(p1, p2, fn) \
^ permalink raw reply [flat|nested] 7+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] libstdc++: testsuite: conditionalize symlink tests
@ 2022-06-23 5:10 Alexandre Oliva
0 siblings, 0 replies; 7+ messages in thread
From: Alexandre Oliva @ 2022-06-23 5:10 UTC (permalink / raw)
To: gcc-cvs, libstdc++-cvs
https://gcc.gnu.org/g:7d6d894053b84f53ccf3bc7edcd7c0f15ecab852
commit 7d6d894053b84f53ccf3bc7edcd7c0f15ecab852
Author: Alexandre Oliva <oliva@adacore.com>
Date: Mon Jun 20 20:03:05 2022 -0300
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_itreator.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 inc parameter. Include
it after 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.
Diff:
---
.../testsuite/27_io/filesystem/operations/canonical.cc | 5 ++++-
.../testsuite/27_io/filesystem/operations/copy.cc | 7 ++-----
.../27_io/filesystem/operations/create_directories.cc | 4 +---
.../27_io/filesystem/operations/create_directory.cc | 4 +---
.../testsuite/27_io/filesystem/operations/permissions.cc | 4 ++++
.../testsuite/27_io/filesystem/operations/read_symlink.cc | 2 +-
.../testsuite/27_io/filesystem/operations/remove.cc | 4 +---
.../testsuite/27_io/filesystem/operations/remove_all.cc | 4 +---
.../testsuite/27_io/filesystem/operations/rename.cc | 4 +---
.../27_io/filesystem/operations/symlink_status.cc | 5 ++++-
.../27_io/filesystem/operations/weakly_canonical.cc | 4 +---
.../filesystem/iterators/recursive_directory_iterator.cc | 2 +-
.../testsuite/experimental/filesystem/operations/copy.cc | 7 ++-----
.../filesystem/operations/create_directories.cc | 4 +---
.../filesystem/operations/create_directory.cc | 4 +---
.../experimental/filesystem/operations/permissions.cc | 4 ++++
.../experimental/filesystem/operations/read_symlink.cc | 2 +-
.../experimental/filesystem/operations/remove.cc | 5 +----
.../experimental/filesystem/operations/remove_all.cc | 4 +---
.../experimental/filesystem/operations/rename.cc | 4 +---
libstdc++-v3/testsuite/lib/dg-options.exp | 9 +++++++++
libstdc++-v3/testsuite/lib/libstdc++.exp | 15 +++++++++++++--
libstdc++-v3/testsuite/util/testsuite_fs.h | 5 +++++
23 files changed, 61 insertions(+), 51 deletions(-)
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc
index bc7ef0de2b7..156fd4d8149 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc
@@ -111,9 +111,12 @@ test03()
fs::path foo = dir/"foo", bar = dir/"bar";
fs::create_directory(foo);
fs::create_directory(bar);
+#if defined(NO_SYMLINK)
#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
const fs::path baz = dir/"foo\\\\..\\bar///";
+#else
+ const fs::path baz = dir/"foo//../bar///";
+#endif
#else
fs::create_symlink("../bar", foo/"baz");
const fs::path baz = dir/"foo//./baz///";
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
index f3081f4b64e..70b7f18c147 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
@@ -66,11 +66,7 @@ test01()
void
test02()
{
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
- return;
-#endif
-
+#ifndef NO_SYMLINK
const std::error_code bad_ec = make_error_code(std::errc::invalid_argument);
auto from = __gnu_test::nonexistent_path();
std::error_code ec;
@@ -110,6 +106,7 @@ test02()
remove(from, ec);
remove(to, ec);
+#endif
}
// Test is_regular_file(f) case.
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc
index 4a7ba1fcb49..57d64e2f981 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc
@@ -148,9 +148,7 @@ test03()
void
test04()
{
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // no symlinks
-#else
+#ifndef NO_SYMLINK
// 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/27_io/filesystem/operations/create_directory.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directory.cc
index 90f98302c00..14f71614267 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directory.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directory.cc
@@ -70,9 +70,7 @@ test01()
VERIFY( e.path1() == f );
}
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // no symlinks
-#else
+#ifndef NO_SYMLINK
// 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/27_io/filesystem/operations/permissions.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/permissions.cc
index deed759be80..f1d7ac04fa2 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/permissions.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/permissions.cc
@@ -76,6 +76,7 @@ test02()
void
test03()
{
+#ifndef NO_SYMLINK
using std::filesystem::perms;
using std::filesystem::perm_options;
@@ -111,11 +112,13 @@ test03()
VERIFY( !caught );
remove(p);
+#endif
}
void
test04()
{
+#ifndef NO_SYMLINK
using perms = std::filesystem::perms;
auto p = __gnu_test::nonexistent_path();
@@ -137,6 +140,7 @@ test04()
VERIFY( ec == ec2 );
remove(p);
+#endif
}
void
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc
index 68bbab33bc9..030d6271de5 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc
@@ -17,7 +17,7 @@
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }
-// { dg-xfail-if "symlinks not supported" { *-*-mingw* } }
+// { dg-require-target-fs-symlinks "" }
#include <filesystem>
#include <testsuite_hooks.h>
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc
index 26f2d548f82..e127b914a55 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc
@@ -41,9 +41,7 @@ test01()
VERIFY( !ec );
VERIFY( !n );
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
-#else
+#ifndef NO_SYMLINK
auto link = __gnu_test::nonexistent_path();
create_symlink(p, link); // dangling symlink
ec = bad_ec;
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc
index 943d85c0cc2..74ac777b3bb 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc
@@ -41,9 +41,7 @@ test01()
VERIFY( !ec );
VERIFY( n == 0 );
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
-#else
+#ifndef NO_SYMLINK
auto link = __gnu_test::nonexistent_path();
create_symlink(p, link); // dangling symlink
ec = bad_ec;
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/rename.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/rename.cc
index f23a2862a0b..e62204ab03f 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/rename.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/rename.cc
@@ -75,9 +75,7 @@ test01()
void
test_symlinks()
{
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
-#else
+#ifndef NO_SYMLINK
std::error_code ec;
const std::error_code bad_ec = make_error_code(std::errc::invalid_argument);
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc
index ef973b7807b..6ba9350c4f2 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc
@@ -17,7 +17,6 @@
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }
-// { dg-xfail-if "symlinks not supported" { *-*-mingw* } }
#include <filesystem>
#include <testsuite_hooks.h>
@@ -39,6 +38,7 @@ test01()
fs::file_status st2 = fs::symlink_status(dot);
VERIFY( st2.type() == fs::file_type::directory );
+#ifndef NO_SYMLINK
fs::path link = __gnu_test::nonexistent_path();
create_directory_symlink(dot, link);
__gnu_test::scoped_file l(link, __gnu_test::scoped_file::adopt_file);
@@ -49,6 +49,7 @@ test01()
st2 = fs::symlink_status(link, ec);
VERIFY( !ec );
VERIFY( st2.type() == fs::file_type::symlink );
+#endif
}
void
@@ -68,6 +69,7 @@ test02()
void
test03()
{
+#ifndef NO_SYMLINK
if (!__gnu_test::permissions_are_testable())
return;
@@ -111,6 +113,7 @@ test03()
VERIFY( st2.type() == fs::file_type::symlink );
fs::permissions(dir, fs::perms::owner_all, ec);
+#endif
}
void
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc
index 244b753f84d..0cf5609b374 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc
@@ -39,9 +39,7 @@ test01()
fs::create_directory(bar/"baz");
fs::path p;
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // No symlink support
-#else
+#ifndef NO_SYMLINK
fs::create_symlink("../bar", foo/"bar");
p = fs::weakly_canonical(dir/"foo//./bar///../biz/.");
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 a201415921c..393fb315593 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 ca38328c5da..6c9a8eecf60 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_SYMLINK
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 03060c6cbb3..f3a64ef0f4e 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_SYMLINK
// 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 67e5fddca00..0134ef85ac8 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_SYMLINK
// 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 833aa13dd15..1469e6c455a 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_SYMLINK
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_SYMLINK
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 75dae3eac51..d0a90976a71 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 <experimental/filesystem>
#include <testsuite_hooks.h>
diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/remove.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/remove.cc
index c01f140ee59..8cf06cb6e80 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_SYMLINK
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 4b0ce85cf97..9ad1352aa28 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_SYMLINK
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 46776e80994..40b45699dff 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_SYMLINK
std::error_code ec;
const std::error_code bad_ec = make_error_code(std::errc::invalid_argument);
diff --git a/libstdc++-v3/testsuite/lib/dg-options.exp b/libstdc++-v3/testsuite/lib/dg-options.exp
index 15f37da468a..e624a69460e 100644
--- a/libstdc++-v3/testsuite/lib/dg-options.exp
+++ b/libstdc++-v3/testsuite/lib/dg-options.exp
@@ -241,6 +241,15 @@ proc dg-require-filesystem-ts { args } {
return
}
+proc dg-require-target-fs-symlinks { args } {
+ if { ![ check_v3_target_fs_symlinks ] } {
+ upvar dg-do-what dg-do-what
+ set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+ return
+ }
+ return
+}
+
proc add_options_for_no_pch { flags } {
# This forces any generated and possibly included PCH to be invalid.
return "-D__GLIBCXX__=99999999"
diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 93fdfee687d..fed05edafd5 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -974,13 +974,16 @@ proc v3_try_preprocess { name code flags } {
}
# Return 1 if COND evaluates to true in the preprocessor, 0 otherwise.
-# The <bits/c++config.h> config header is included.
-proc v3_check_preprocessor_condition { name cond } {
+# The <bits/c++config.h> config header is included, and INC, if given,
+# is pasted between it and the condition evaluation, so it can be used
+# for additional #include's.
+proc v3_check_preprocessor_condition { name cond inc } {
global cxxflags
global DEFAULT_CXXFLAGS
set code "
#include <bits/c++config.h>
+ $inc
#if ! ($cond)
#error '$cond' is false
#endif
@@ -1267,6 +1270,14 @@ proc check_v3_target_filesystem_ts { } {
}]
}
+# Return 1 if the libstdc++ filesystem create_symlinks implementation
+# is not an always-failing dummy.
+proc check_v3_target_fs_symlinks { } {
+ set inc "#include <testsuite_fs.h>"
+ set cond "!defined NO_SYMLINKS"
+ return [v3_check_preprocessor_condition fs_symlinks $cond $inc]
+}
+
# Return 1 if the "cxx11" ABI is in use using the current flags, 0 otherwise.
# Any flags provided by RUNTESTFLAGS or a target board will be used here.
# Flags added in the test by dg-options or dg-add-options will not be used.
diff --git a/libstdc++-v3/testsuite/util/testsuite_fs.h b/libstdc++-v3/testsuite/util/testsuite_fs.h
index 9358a04e56c..048f03103e4 100644
--- a/libstdc++-v3/testsuite/util/testsuite_fs.h
+++ b/libstdc++-v3/testsuite/util/testsuite_fs.h
@@ -42,6 +42,11 @@ namespace test_fs = std::experimental::filesystem;
#include <random> // std::random_device
#endif
+#if defined(__MINGW32__) || defined(__MINGW64__) \
+ || !defined (_GLIBCXX_HAVE_SYMLINK)
+#define NO_SYMLINKS
+#endif
+
namespace __gnu_test
{
#define PATH_CHK(p1, p2, fn) \
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-06-23 14:02 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-23 10:05 [gcc(refs/users/aoliva/heads/testme)] libstdc++: testsuite: conditionalize symlink tests Alexandre Oliva
-- strict thread matches above, loose matches on Subject: below --
2022-06-23 14:02 Alexandre Oliva
2022-06-23 12:43 Alexandre Oliva
2022-06-23 12:29 Alexandre Oliva
2022-06-23 12:21 Alexandre Oliva
2022-06-23 7:15 Alexandre Oliva
2022-06-23 5:10 Alexandre Oliva
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).