From 4da027d87eabd9a6cb0f5c1ed7ee10540501c7a3 Mon Sep 17 00:00:00 2001
From: Hans-Peter Nilsson <hp@bitrange.com>
Date: Sun, 29 Dec 2024 03:32:04 +0100
Subject: [PATCH] libstdc++-v3/testsuite/.../year_month_day/3.cc, 4.cc: Cut
 down for simulators

These two long-running tests happened to fail for me when
run in parallel (nprocs - 1) compared to a serial run, for
target mmix on my laptop.  The runtime is 3m40s for 3.cc
before this change, and 0.9s afterwards.

	* testsuite/std/time/year_month_day/3.cc (test01): Add ifdeffery to
	limit the tested dates.  For simulators, pass start and end dates
	limiting the tested range to 100000 days, centered on days (0).
	* testsuite/std/time/year_month_day/4.cc: Ditto.
---
 libstdc++-v3/testsuite/std/time/year_month_day/3.cc | 11 ++++++++++-
 libstdc++-v3/testsuite/std/time/year_month_day/4.cc | 10 +++++++++-
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/testsuite/std/time/year_month_day/3.cc b/libstdc++-v3/testsuite/std/time/year_month_day/3.cc
index 05dc750c0a09..f4829a686f79 100644
--- a/libstdc++-v3/testsuite/std/time/year_month_day/3.cc
+++ b/libstdc++-v3/testsuite/std/time/year_month_day/3.cc
@@ -1,4 +1,5 @@
 // { dg-do run { target c++20 } }
+// { dg-additional-options "-DSTART_DAY=-50000 -DEND_DAY=50000 -DSTART_YMD=1833y/February/8d" { target simulator } }
 
 // Copyright (C) 2021-2024 Free Software Foundation, Inc.
 //
@@ -50,11 +51,19 @@ void test01()
 {
   using namespace std::chrono;
 
+#ifdef START_DAY
+  auto n   = days{START_DAY};
+  auto ymd = START_YMD;
+  auto end_day = days{END_DAY};
+#else
   // [-12687428, 11248737] maps to [-32767y/January/1d, 32767y/December/31d]
 
   auto n   = days{-12687428};
   auto ymd = -32767y/January/1d;
-  while (n < days{11248737}) {
+  auto end_day = days{11248737};
+#endif
+
+  while (n < end_day) {
     VERIFY( year_month_day{sys_days{n}} == ymd );
     ++n;
     advance(ymd);
diff --git a/libstdc++-v3/testsuite/std/time/year_month_day/4.cc b/libstdc++-v3/testsuite/std/time/year_month_day/4.cc
index 6b6714e3a85e..09a7551dcfc0 100644
--- a/libstdc++-v3/testsuite/std/time/year_month_day/4.cc
+++ b/libstdc++-v3/testsuite/std/time/year_month_day/4.cc
@@ -1,4 +1,5 @@
 // { dg-do run { target c++20 } }
+// { dg-additional-options "-DSTART_DAY=-50000 -DSTART_YMD=1833y/February/8d -DEND_YMD=2106y/November/24d" { target simulator } }
 
 // Copyright (C) 2021-2024 Free Software Foundation, Inc.
 //
@@ -50,11 +51,18 @@ void test01()
 {
   using namespace std::chrono;
 
+#ifdef START_DAY
+  auto n   = days{START_DAY};
+  auto ymd = START_YMD;
+#else
   // [-32767y/January/1d, 32767y/December/31d] maps to [-12687428, 11248737]
 
   auto n   = days{-12687428};
   auto ymd = -32767y/January/1d;
-  while (ymd < 32767y/December/31d) {
+#define END_YMD 32767y/December/31d
+#endif
+
+  while (ymd < END_YMD) {
     VERIFY( static_cast<sys_days>(ymd) == sys_days{n} );
     ++n;
     advance(ymd);
-- 
GitLab