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

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