public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-9142] libstdc++: Fix ip::tcp::resolver test failure on Solaris
@ 2021-10-12 19:41 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2021-10-12 19:41 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:6d51766a558fac78f294031d4bf5b8b6d390aa9b

commit r11-9142-g6d51766a558fac78f294031d4bf5b8b6d390aa9b
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Aug 31 13:08:23 2021 +0100

    libstdc++: Fix ip::tcp::resolver test failure on Solaris
    
    Solaris 11 does not have "http" in /etc/services, which causes this test
    to fail. Try some other services until we find one that works.
    
    Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
    
    libstdc++-v3/ChangeLog:
    
            * testsuite/experimental/net/internet/resolver/ops/lookup.cc:
            Try other service if "http" fails.
    
    (cherry picked from commit 48b20d46f9597a4b1e19e0e2d4a0c68d056d7662)

Diff:
---
 .../experimental/net/internet/resolver/ops/lookup.cc | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/libstdc++-v3/testsuite/experimental/net/internet/resolver/ops/lookup.cc b/libstdc++-v3/testsuite/experimental/net/internet/resolver/ops/lookup.cc
index ca8f0899ccd..69be194fa29 100644
--- a/libstdc++-v3/testsuite/experimental/net/internet/resolver/ops/lookup.cc
+++ b/libstdc++-v3/testsuite/experimental/net/internet/resolver/ops/lookup.cc
@@ -30,13 +30,27 @@ test01()
   std::error_code ec;
   io_context ctx;
   ip::tcp::resolver resolv(ctx);
-  auto addrs = resolv.resolve("localhost", "http", ec);
+  auto hostname = "localhost", service = "http";
+  auto addrs = resolv.resolve(hostname, service, ec);
+  if (ec == ip::resolver_errc::service_not_found)
+  {
+    // Solaris doesn't have http in /etc/services, try some others.
+    for (auto serv : {"ftp", "telnet", "smtp"})
+    {
+      addrs = resolv.resolve(hostname, serv, ec);
+      if (!ec)
+      {
+	service = serv;
+	break;
+      }
+    }
+  }
   VERIFY( !ec );
   VERIFY( addrs.size() > 0 );
   VERIFY( addrs.begin() != addrs.end() );
   VERIFY( ! addrs.empty() );
 
-  auto addrs2 = resolv.resolve("localhost", "http");
+  auto addrs2 = resolv.resolve(hostname, service);
   VERIFY( addrs == addrs2 );
 }
 
@@ -68,7 +82,7 @@ test02()
 #if __cpp_exceptions
   bool caught = false;
   try {
-    resolv.resolve("localhost", "http", flags);
+    resolv.resolve("localhost", "42", flags);
   } catch (const std::system_error& e) {
     caught = true;
     VERIFY( e.code() == ec );


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-10-12 19:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-12 19:41 [gcc r11-9142] libstdc++: Fix ip::tcp::resolver test failure on Solaris Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).