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

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