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

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