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>