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

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