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

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