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

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