Blame SOURCES/0011-Add-dts.exp-and-use-it-to-fix-22_locale-messages-136.patch

56505a
From b6989e3a4acda2d75612f3f3847dbea4245ff536 Mon Sep 17 00:00:00 2001
56505a
From: David Malcolm <dmalcolm@redhat.com>
56505a
Date: Wed, 1 Sep 2021 15:39:45 -0400
56505a
Subject: [PATCH 11/17] Add dts.exp and use it to fix
56505a
 22_locale/messages/13631.cc
56505a
56505a
This test was added upstream 2014-12-03:
56505a
  "re PR libstdc++/13631 (Problems in messages)"
56505a
    https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=d31008d7a0d53b431f176aad8dda5498de823122
56505a
56505a
as part of a fix that is present in the system libstdc++.so in
56505a
GCC 5 onwards.
56505a
56505a
When run in DTS against such a system library, this test will fail.
56505a
This patch introduces a dts.exp which detects the version of the
56505a
underlying system libstdc++.so and exposes it to tests via
56505a
-D__CXXSTDLIB_SO_VERSION__=, so that we can ifdef specific tests
56505a
away, conditionally on the base GCC.
56505a
---
56505a
 .../testsuite/22_locale/messages/13631.cc     |  7 +++++
56505a
 libstdc++-v3/testsuite/lib/dts.exp            | 31 +++++++++++++++++++
56505a
 libstdc++-v3/testsuite/lib/libstdc++.exp      |  6 ++++
56505a
 3 files changed, 44 insertions(+)
56505a
 create mode 100644 libstdc++-v3/testsuite/lib/dts.exp
56505a
56505a
diff --git a/libstdc++-v3/testsuite/22_locale/messages/13631.cc b/libstdc++-v3/testsuite/22_locale/messages/13631.cc
56505a
index b8ae3d4f1..5b20df382 100644
56505a
--- a/libstdc++-v3/testsuite/22_locale/messages/13631.cc
56505a
+++ b/libstdc++-v3/testsuite/22_locale/messages/13631.cc
56505a
@@ -50,7 +50,10 @@ void test01()
56505a
   msgs_facet.close(fake_msgs);
56505a
   msgs_facet.close(msgs);
56505a
 
56505a
+  // Fixed upstream in GCC 5
56505a
+#if __CXXSTDLIB_SO_VERSION__ >= 501000
56505a
   VERIFY( translation1 == translation2 );
56505a
+#endif
56505a
 }
56505a
 
56505a
 void test02()
56505a
@@ -72,8 +75,12 @@ void test02()
56505a
   std::wstring translation1 = msgs_facet.get(msgs, 0, 0, msgid);
56505a
 
56505a
   // Without a real translation this test doesn't mean anything:
56505a
+
56505a
+  // Fixed upstream in GCC 5
56505a
+#if __CXXSTDLIB_SO_VERSION__ >= 501000
56505a
   VERIFY( !translation1.empty() );
56505a
   VERIFY( translation1 != msgid );
56505a
+#endif
56505a
 
56505a
   // Opening another catalog was enough to show the problem, even a fake
56505a
   // catalog.
56505a
diff --git a/libstdc++-v3/testsuite/lib/dts.exp b/libstdc++-v3/testsuite/lib/dts.exp
56505a
new file mode 100644
56505a
index 000000000..76ece66d3
56505a
--- /dev/null
56505a
+++ b/libstdc++-v3/testsuite/lib/dts.exp
56505a
@@ -0,0 +1,31 @@
56505a
+# For DTS testing, generate a number expressing the
56505a
+# system version of libstdc++.so
56505a
+#
56505a
+# Generate a version number equivalent to
56505a
+#  #define GCC_VERSION (__GNUC__ * 10000 \
56505a
+#                       + __GNUC_MINOR__ * 100 \
56505a
+#                       + __GNUC_PATCHLEVEL__)
56505a
+#
56505a
+# For example, given an underlying version of gcc 4.8.5
56505a
+# this function will return 408050.
56505a
+
56505a
+proc get_dts_base_version { } {
56505a
+
56505a
+    # Invoke gcc in the PATH to get at the underlying GCC version
56505a
+    # in dotted form (e.g. "4.8.5").
56505a
+    set dotted_version [exec gcc -dumpversion]
56505a
+    verbose "dotted_version: '$dotted_version'" 2
56505a
+
56505a
+    # Extract major, minor, patchlevel
56505a
+    regexp {([0-9]+)\.([0-9]+)\.([0-9]+)} \
56505a
+	$dotted_version \
56505a
+	_ major minor patchlevel
56505a
+    verbose "major: '$major'" 2
56505a
+    verbose "minor: '$minor'" 2
56505a
+    verbose "patchlevel: '$patchlevel'" 2
56505a
+
56505a
+    set base_gcc_version [expr (($major * 10000) + ($minor * 100)  + $patchlevel)]
56505a
+    verbose "base_gcc_version: '$base_gcc_version'" 2
56505a
+
56505a
+    return $base_gcc_version
56505a
+}
56505a
diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
56505a
index 7f9580db8..5e4b32f76 100644
56505a
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
56505a
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
56505a
@@ -58,6 +58,7 @@ load_gcc_lib timeout.exp
56505a
 load_gcc_lib timeout-dg.exp
56505a
 load_gcc_lib wrapper.exp
56505a
 load_gcc_lib target-utils.exp
56505a
+load_lib dts.exp
56505a
 
56505a
 # Useful for debugging.  Pass the name of a variable and the verbosity
56505a
 # threshold (number of -v's on the command line).
56505a
@@ -323,6 +324,11 @@ proc libstdc++_init { testfile } {
56505a
     set ccflags "$cxxflags -DLOCALEDIR=\".\""
56505a
     set cxxflags "$cxxflags -DLOCALEDIR=\".\""
56505a
 
56505a
+    # For DTS testing, expose the system version of libstdc++.so as
56505a
+    # a preprocessor define.
56505a
+    set base_gcc_version [get_dts_base_version]
56505a
+    set cxxflags "$cxxflags -D__CXXSTDLIB_SO_VERSION__=$base_gcc_version"
56505a
+
56505a
     # If a PCH file is available, use it.  We must delay performing
56505a
     # this check until $cxx and such have been initialized because we
56505a
     # perform a test compilation.  (Ideally, gcc --print-file-name would
56505a
-- 
56505a
2.31.1
56505a