public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alexandre Oliva <oliva@adacore.com>
To: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org
Subject: [PATCH] libstdc++: testsuite: skip fs last_write_time tests if not available
Date: Wed, 22 Jun 2022 03:33:16 -0300	[thread overview]
Message-ID: <ora6a59phv.fsf@lxoliva.fsfla.org> (raw)


The last_write_time functions are defined in ways that are useful, or
that fail immediately, depending on various macros.  When they fail
immediately, the filesystem last_write_time.cc tests fail noisily, but
the fail is entirely expected.

Define HAVE_LWT in the last_write_time.cc tests, according to the
macros that select implementations of last_write_time, and use it to
skip tests that are expected to fail.

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

PS: I realize _GLIBCXX_HAVE_SYS_STAT_H is tested for in two different
ways in the #if expressions added to the tests.  This mirrors the
different uses in the do_stat template body, and in
fs::last_write_time(const path&, file_time_type, error_code&).  Perhaps
they should all be using either value or definedness, but I didn't want
to go there, at least not at first, so I retained the apparent
inconsistency.


for  libstdc++-v3/ChangeLog

	* testsuite/27_io/filesystem/operations/last_write_time.cc:
	Skip the test if the features are unavailable.
	* testsuite/experimental/filesystem/operations/last_write_time.cc:
	Likewise.
---
 .../27_io/filesystem/operations/last_write_time.cc |   11 +++++++++++
 .../filesystem/operations/last_write_time.cc       |   11 +++++++++++
 2 files changed, 22 insertions(+)

diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/last_write_time.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/last_write_time.cc
index 7d6468a512424..ecdd45d6ac99e 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/last_write_time.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/last_write_time.cc
@@ -33,6 +33,14 @@
 #endif
 #include <stdio.h>
 
+#if (_GLIBCXX_USE_UTIMENSAT \
+     || (_GLIBCXX_USE_UTIME && _GLIBCXX_HAVE_SYS_STAT_H)) \
+  && defined (_GLIBCXX_HAVE_SYS_STAT_H)
+# define HAVE_LWT 1
+#else
+# define HAVE_LWT 0
+#endif
+
 using time_type = std::filesystem::file_time_type;
 
 namespace chrono = std::chrono;
@@ -209,6 +217,9 @@ test02()
 int
 main()
 {
+  if (!HAVE_LWT)
+    return 0;
+
   test01();
   test02();
 }
diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/last_write_time.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/last_write_time.cc
index 38fafc392ca9e..562c1114a7fb3 100644
--- a/libstdc++-v3/testsuite/experimental/filesystem/operations/last_write_time.cc
+++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/last_write_time.cc
@@ -34,6 +34,14 @@
 #endif
 #include <stdio.h>
 
+#if (_GLIBCXX_USE_UTIMENSAT \
+     || (_GLIBCXX_USE_UTIME && _GLIBCXX_HAVE_SYS_STAT_H)) \
+  && defined (_GLIBCXX_HAVE_SYS_STAT_H)
+# define HAVE_LWT 1
+#else
+# define HAVE_LWT 0
+#endif
+
 using time_type = std::experimental::filesystem::file_time_type;
 
 namespace chrono = std::chrono;
@@ -175,6 +183,9 @@ test02()
 int
 main()
 {
+  if (!HAVE_LWT)
+    return 0;
+
   test01();
   test02();
 }

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

             reply	other threads:[~2022-06-22  6:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-22  6:33 Alexandre Oliva [this message]
2022-06-22 10:47 ` Jonathan Wakely
2022-06-23 11:04   ` Alexandre Oliva
2022-06-23 11:30     ` Jonathan Wakely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ora6a59phv.fsf@lxoliva.fsfla.org \
    --to=oliva@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).