public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libstdc++: testsuite: test symlnks ifdef _GLIBCXX_HAVE_SYMLINK
@ 2022-06-22  6:13 Alexandre Oliva
  2022-06-22  9:25 ` Jonathan Wakely
  0 siblings, 1 reply; 14+ messages in thread
From: Alexandre Oliva @ 2022-06-22  6:13 UTC (permalink / raw)
  To: gcc-patches, libstdc++


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.

Regstrapped on x86_64-linux-gnu, also tested with a cross to
aarch64-rtems6.  Ok to install?

PS: Testing with trunk was somewhat impaired by various changes in the
filesystem implementation and tests that cause new failures on rtems6
that I have not (yet?) been able to investigate.  A slight variant of
this patch, along with a number of patches I'm yet to post, has enabled
gcc-11 to pass all filesystem tests.  Meaning this might turn out to be
an incomplete fix for the problem on mainline, in case remaining
failures hide similar but new (compared with gcc-11) occurrences of the
problem this attempts to fix.  However, it brings strict improvement, so
I expect it to be useful to integrate it nevertheless.


for  libstdc++-v3/ChangeLog

	* testsuite/27_io/filesystem/operations/canonical.cc (test03):
	Only create symlinks when _GLIBCXX_HAVE_SYMLINK is defined.
	* 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/read_symlink.cc
	(test01): 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/symlink_status.cc
	(test01, test02): 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/read_symlink.cc
	(test01): 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.
---
 .../27_io/filesystem/operations/canonical.cc       |    2 ++
 .../testsuite/27_io/filesystem/operations/copy.cc  |    3 ++-
 .../filesystem/operations/create_directories.cc    |    3 ++-
 .../filesystem/operations/create_directory.cc      |    3 ++-
 .../27_io/filesystem/operations/permissions.cc     |    4 ++++
 .../27_io/filesystem/operations/read_symlink.cc    |    2 ++
 .../27_io/filesystem/operations/remove.cc          |    3 ++-
 .../27_io/filesystem/operations/remove_all.cc      |    3 ++-
 .../27_io/filesystem/operations/rename.cc          |    3 ++-
 .../27_io/filesystem/operations/symlink_status.cc  |    4 ++++
 .../filesystem/operations/weakly_canonical.cc      |    3 ++-
 .../iterators/recursive_directory_iterator.cc      |    3 ++-
 .../experimental/filesystem/operations/copy.cc     |    3 ++-
 .../filesystem/operations/create_directories.cc    |    3 ++-
 .../filesystem/operations/create_directory.cc      |    3 ++-
 .../filesystem/operations/permissions.cc           |    4 ++++
 .../filesystem/operations/read_symlink.cc          |    2 ++
 .../experimental/filesystem/operations/remove.cc   |    3 ++-
 .../filesystem/operations/remove_all.cc            |    3 ++-
 .../experimental/filesystem/operations/rename.cc   |    3 ++-
 20 files changed, 46 insertions(+), 14 deletions(-)

diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc
index bc7ef0de2b716..1ae23dadac517 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc
@@ -114,6 +114,8 @@ test03()
 #if defined(__MINGW32__) || defined(__MINGW64__)
   // No symlink support
   const fs::path baz = dir/"foo\\\\..\\bar///";
+#elif !defined (_GLIBCXX_HAVE_SYMLINK)
+  const fs::path baz = dir/"foo//../bar///";
 #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 f3081f4b64ebc..575d32d34fc3d 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
@@ -66,7 +66,8 @@ test01()
 void
 test02()
 {
-#if defined(__MINGW32__) || defined(__MINGW64__)
+#if defined(__MINGW32__) || defined(__MINGW64__) \
+  || !defined (_GLIBCXX_HAVE_SYMLINK)
   // No symlink support
   return;
 #endif
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 4a7ba1fcb4944..3b9b893ad8e2d 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directories.cc
@@ -148,7 +148,8 @@ test03()
 void
 test04()
 {
-#if defined(__MINGW32__) || defined(__MINGW64__)
+#if defined(__MINGW32__) || defined(__MINGW64__) \
+  || !defined (_GLIBCXX_HAVE_SYMLINK)
   // no symlinks
 #else
   // PR libstdc++/101510
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 90f98302c00f8..e10a4c854f032 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directory.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directory.cc
@@ -70,7 +70,8 @@ test01()
     VERIFY( e.path1() == f );
   }
 
-#if defined(__MINGW32__) || defined(__MINGW64__)
+#if defined(__MINGW32__) || defined(__MINGW64__) \
+  || !defined (_GLIBCXX_HAVE_SYMLINK)
   // no symlinks
 #else
   // PR libstdc++/101510 create_directory on an existing symlink to a directory
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/permissions.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/permissions.cc
index deed759be80e9..9e7c5fc7e485c 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()
 {
+#ifdef _GLIBCXX_HAVE_SYMLINK
   using std::filesystem::perms;
   using std::filesystem::perm_options;
 
@@ -111,11 +112,13 @@ test03()
     VERIFY( !caught );
 
   remove(p);
+#endif
 }
 
 void
 test04()
 {
+#ifdef _GLIBCXX_HAVE_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 68bbab33bc9e2..feb9e4f3fe0b6 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc
@@ -28,6 +28,7 @@ namespace fs = std::filesystem;
 void
 test01()
 {
+#ifdef _GLIBCXX_HAVE_SYMLINK
   auto p = __gnu_test::nonexistent_path();
   std::error_code ec;
 
@@ -42,6 +43,7 @@ test01()
   VERIFY( result == tgt );
 
   remove(p);
+#endif
 }
 
 int
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc
index 26f2d548f82d5..2b094868e4c03 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove.cc
@@ -41,7 +41,8 @@ test01()
   VERIFY( !ec );
   VERIFY( !n );
 
-#if defined(__MINGW32__) || defined(__MINGW64__)
+#if defined(__MINGW32__) || defined(__MINGW64__) \
+  || !defined (_GLIBCXX_HAVE_SYMLINK)
   // No symlink support
 #else
   auto link = __gnu_test::nonexistent_path();
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 943d85c0cc2e3..45b29d6bb7aa2 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc
@@ -41,7 +41,8 @@ test01()
   VERIFY( !ec );
   VERIFY( n == 0 );
 
-#if defined(__MINGW32__) || defined(__MINGW64__)
+#if defined(__MINGW32__) || defined(__MINGW64__) \
+  || !defined (_GLIBCXX_HAVE_SYMLINK)
   // No symlink support
 #else
   auto link = __gnu_test::nonexistent_path();
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/rename.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/rename.cc
index f23a2862a0b99..936e306041290 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/rename.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/rename.cc
@@ -75,7 +75,8 @@ test01()
 void
 test_symlinks()
 {
-#if defined(__MINGW32__) || defined(__MINGW64__)
+#if defined(__MINGW32__) || defined(__MINGW64__) \
+  || !defined (_GLIBCXX_HAVE_SYMLINK)
   // No symlink support
 #else
   std::error_code ec;
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 ef973b7807b8a..7ed91fa986c11 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc
@@ -39,6 +39,7 @@ test01()
   fs::file_status st2 = fs::symlink_status(dot);
   VERIFY( st2.type() == fs::file_type::directory );
 
+#ifdef _GLIBCXX_HAVE_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 +50,7 @@ test01()
   st2 = fs::symlink_status(link, ec);
   VERIFY( !ec );
   VERIFY( st2.type() == fs::file_type::symlink );
+#endif
 }
 
 void
@@ -68,6 +70,7 @@ test02()
 void
 test03()
 {
+#ifdef _GLIBCXX_HAVE_SYMLINK
   if (!__gnu_test::permissions_are_testable())
     return;
 
@@ -111,6 +114,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 244b753f84d1d..38c5e76497da0 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/weakly_canonical.cc
@@ -39,7 +39,8 @@ test01()
   fs::create_directory(bar/"baz");
   fs::path p;
 
-#if defined(__MINGW32__) || defined(__MINGW64__)
+#if defined(__MINGW32__) || defined(__MINGW64__) \
+  || !defined (_GLIBCXX_HAVE_SYMLINK)
   // No symlink support
 #else
   fs::create_symlink("../bar", foo/"bar");
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 a201415921cfc..be27237b42c69 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,8 @@ test05()
 void
 test06()
 {
-#if !(defined __MINGW32__ || defined __MINGW64__)
+#if !(defined __MINGW32__ || defined __MINGW64__) \
+  && defined _GLIBCXX_HAVE_SYMLINK
   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 ca38328c5da15..6d95801e34f7c 100644
--- a/libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc
+++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc
@@ -67,7 +67,8 @@ test01()
 void
 test02()
 {
-#if defined(__MINGW32__) || defined(__MINGW64__)
+#if defined(__MINGW32__) || defined(__MINGW64__) \
+  || !defined (_GLIBCXX_HAVE_SYMLINK)
   // No symlink support
   return;
 #endif
diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/create_directories.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/create_directories.cc
index 03060c6cbb33e..9e29bd978fb6a 100644
--- a/libstdc++-v3/testsuite/experimental/filesystem/operations/create_directories.cc
+++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/create_directories.cc
@@ -147,7 +147,8 @@ test03()
 void
 test04()
 {
-#if defined(__MINGW32__) || defined(__MINGW64__)
+#if defined(__MINGW32__) || defined(__MINGW64__) \
+  || !defined (_GLIBCXX_HAVE_SYMLINK)
   // no symlinks
 #else
   // PR libstdc++/101510
diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/create_directory.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/create_directory.cc
index 67e5fddca0094..dc1e518fe08aa 100644
--- a/libstdc++-v3/testsuite/experimental/filesystem/operations/create_directory.cc
+++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/create_directory.cc
@@ -69,7 +69,8 @@ test01()
     VERIFY( e.path1() == f );
   }
 
-#if defined(__MINGW32__) || defined(__MINGW64__)
+#if defined(__MINGW32__) || defined(__MINGW64__) \
+  || !defined (_GLIBCXX_HAVE_SYMLINK)
   // no symlinks
 #else
   // PR libstdc++/101510 create_directory on an existing symlink to a directory
diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/permissions.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/permissions.cc
index 833aa13dd158b..1cb318a7c3730 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()
 {
+#ifdef _GLIBCXX_HAVE_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()
 {
+#ifdef _GLIBCXX_HAVE_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 75dae3eac5108..90e92f1201cdb 100644
--- a/libstdc++-v3/testsuite/experimental/filesystem/operations/read_symlink.cc
+++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/read_symlink.cc
@@ -29,6 +29,7 @@ namespace fs = std::experimental::filesystem;
 void
 test01()
 {
+#ifdef _GLIBCXX_HAVE_SYMLINK
   auto p = __gnu_test::nonexistent_path();
   std::error_code ec;
 
@@ -43,6 +44,7 @@ test01()
   VERIFY( result == tgt );
 
   remove(p);
+#endif
 }
 
 int
diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/remove.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/remove.cc
index c01f140ee592a..29a24f1bd581e 100644
--- a/libstdc++-v3/testsuite/experimental/filesystem/operations/remove.cc
+++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/remove.cc
@@ -42,7 +42,8 @@ test01()
   VERIFY( !ec );
   VERIFY( !n );
 
-#if defined(__MINGW32__) || defined(__MINGW64__)
+#if defined(__MINGW32__) || defined(__MINGW64__) \
+  || !defined (_GLIBCXX_HAVE_SYMLINK)
   // No symlink support
   return;
 #else
diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/remove_all.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/remove_all.cc
index 4b0ce85cf9754..7165ddfb85cce 100644
--- a/libstdc++-v3/testsuite/experimental/filesystem/operations/remove_all.cc
+++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/remove_all.cc
@@ -42,7 +42,8 @@ test01()
   VERIFY( !ec );
   VERIFY( n == 0 );
 
-#if defined(__MINGW32__) || defined(__MINGW64__)
+#if defined(__MINGW32__) || defined(__MINGW64__) \
+  || !defined (_GLIBCXX_HAVE_SYMLINK)
   // No symlink support
 #else
   auto link = __gnu_test::nonexistent_path();
diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/rename.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/rename.cc
index 46776e80994e2..520d48ef8d844 100644
--- a/libstdc++-v3/testsuite/experimental/filesystem/operations/rename.cc
+++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/rename.cc
@@ -75,7 +75,8 @@ test01()
 void
 test_symlinks()
 {
-#if defined(__MINGW32__) || defined(__MINGW64__)
+#if defined(__MINGW32__) || defined(__MINGW64__) \
+  || !defined (_GLIBCXX_HAVE_SYMLINK)
   // No symlink support
 #else
   std::error_code ec;

-- 
Alexandre Oliva, happy hacker                https://FSFLA.org/blogs/lxo/
   Free Software Activist                       GNU Toolchain Engineer
Disinformation flourishes because many people care deeply about injustice
but very few check the facts.  Ask me about <https://stallmansupport.org>

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-06-27 13:36 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-22  6:13 [PATCH] libstdc++: testsuite: test symlnks ifdef _GLIBCXX_HAVE_SYMLINK Alexandre Oliva
2022-06-22  9:25 ` Jonathan Wakely
2022-06-22 10:42   ` Jonathan Wakely
2022-06-23  3:41     ` Alexandre Oliva
2022-06-23 10:53   ` Alexandre Oliva
2022-06-23 11:39     ` Jonathan Wakely
2022-06-23 11:02   ` Alexandre Oliva
2022-06-23 11:28     ` Jonathan Wakely
2022-06-23 11:29       ` Jonathan Wakely
2022-06-23 12:35       ` Alexandre Oliva
2022-06-23 12:37         ` Jonathan Wakely
2022-06-24  2:32         ` Alexandre Oliva
2022-06-27 13:29         ` Alexandre Oliva
2022-06-27 13:36           ` Jonathan Wakely

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).