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

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