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

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