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

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