[v3,testsuite] Introduce dg-add-options net_ts

Message ID yddd0sakto5.fsf@CeBiTec.Uni-Bielefeld.DE
State New
Headers show
Series
  • [v3,testsuite] Introduce dg-add-options net_ts
Related show

Commit Message

Rainer Orth Oct. 16, 2018, 11:38 a.m.
Some of the new Networking TS tests FAIL before Solaris 11.4 like this:

FAIL: experimental/net/internet/address/v4/members.cc (test for excess errors)
Excess errors:
Undefined                       first referenced
 symbol                             in file
inet_ntop                           /var/tmp//ccpcIRXj.o
gai_strerror                        /var/tmp//ccpcIRXj.o
ld: fatal: symbol referencing errors. No output written to ./members.exe
collect2: error: ld returned 1 exit status

This happens because until the socket etc. functions were integrated
into libc in Solaris 11.4, they only lived in libsocket and libnsl.

The following patch fixes this by introducing a new dg-add-options
keyword net_ts (I'm open for suggestions for the name, of course;
networking_ts might be an option, too) and adding the requirement to the
tests involved.

With the patch below, all but one of the tests PASS on
i386-pc-solaris2.10:

FAIL: experimental/net/internet/resolver/ops/lookup.cc execution test

/vol/gcc/src/hg/trunk/local/libstdc++-v3/testsuite/experimental/net/internet/res
olver/ops/lookup.cc:35: void test01(): Assertion '!ec' failed.

The code in question is

  auto addrs = resolv.resolve("localhost", "http", ec);
  VERIFY( !ec );

but "http" is missing from /etc/services before Solaris 11.4.

Ok for mainline?

Btw., one may want to do similarly for the Filesystem TS tests,
introducing dg-add-options fs_ts (or filesystem_ts) instead of repeating
dg-options "-DUSE_FILESYSTEM_TS -lstdc++fs" over and over again.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


2018-10-16  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	libstdc++-v3:
	* testsuite/lib/dg-options.exp (add_options_for_net_ts): New proc.
	* testsuite/experimental/net/internet/address/v4/comparisons.cc:
	Add dg-add-options net_ts.
	* testsuite/experimental/net/internet/address/v4/cons.cc: Likewise.
	* testsuite/experimental/net/internet/address/v4/creation.cc: Likewise.
	* testsuite/experimental/net/internet/address/v4/members.cc: Likewise.
	* testsuite/experimental/net/internet/resolver/base.cc: Likewise.
	* testsuite/experimental/net/internet/resolver/ops/lookup.cc: Likewise.
	* testsuite/experimental/net/internet/resolver/ops/reverse.cc: Likewise.

Comments

Jonathan Wakely Oct. 16, 2018, 12:10 p.m. | #1
On 16/10/18 13:38 +0200, Rainer Orth wrote:
>Some of the new Networking TS tests FAIL before Solaris 11.4 like this:

>

>FAIL: experimental/net/internet/address/v4/members.cc (test for excess errors)

>Excess errors:

>Undefined                       first referenced

> symbol                             in file

>inet_ntop                           /var/tmp//ccpcIRXj.o

>gai_strerror                        /var/tmp//ccpcIRXj.o

>ld: fatal: symbol referencing errors. No output written to ./members.exe

>collect2: error: ld returned 1 exit status

>

>This happens because until the socket etc. functions were integrated

>into libc in Solaris 11.4, they only lived in libsocket and libnsl.

>

>The following patch fixes this by introducing a new dg-add-options

>keyword net_ts (I'm open for suggestions for the name, of course;

>networking_ts might be an option, too) and adding the requirement to the

>tests involved.

>

>With the patch below, all but one of the tests PASS on

>i386-pc-solaris2.10:

>

>FAIL: experimental/net/internet/resolver/ops/lookup.cc execution test

>

>/vol/gcc/src/hg/trunk/local/libstdc++-v3/testsuite/experimental/net/internet/res

>olver/ops/lookup.cc:35: void test01(): Assertion '!ec' failed.

>

>The code in question is

>

>  auto addrs = resolv.resolve("localhost", "http", ec);

>  VERIFY( !ec );

>

>but "http" is missing from /etc/services before Solaris 11.4.

>

>Ok for mainline?


OK, thanks.
Jonathan Wakely Oct. 16, 2018, 4:25 p.m. | #2
On 16/10/18 13:38 +0200, Rainer Orth wrote:
>Some of the new Networking TS tests FAIL before Solaris 11.4 like this:

>

>FAIL: experimental/net/internet/address/v4/members.cc (test for excess errors)

>Excess errors:

>Undefined                       first referenced

> symbol                             in file

>inet_ntop                           /var/tmp//ccpcIRXj.o

>gai_strerror                        /var/tmp//ccpcIRXj.o

>ld: fatal: symbol referencing errors. No output written to ./members.exe

>collect2: error: ld returned 1 exit status

>

>This happens because until the socket etc. functions were integrated

>into libc in Solaris 11.4, they only lived in libsocket and libnsl.

>

>The following patch fixes this by introducing a new dg-add-options

>keyword net_ts (I'm open for suggestions for the name, of course;

>networking_ts might be an option, too) and adding the requirement to the

>tests involved.

>

>With the patch below, all but one of the tests PASS on

>i386-pc-solaris2.10:

>

>FAIL: experimental/net/internet/resolver/ops/lookup.cc execution test

>

>/vol/gcc/src/hg/trunk/local/libstdc++-v3/testsuite/experimental/net/internet/res

>olver/ops/lookup.cc:35: void test01(): Assertion '!ec' failed.

>

>The code in question is

>

>  auto addrs = resolv.resolve("localhost", "http", ec);

>  VERIFY( !ec );

>

>but "http" is missing from /etc/services before Solaris 11.4.

>

>Ok for mainline?

>

>Btw., one may want to do similarly for the Filesystem TS tests,

>introducing dg-add-options fs_ts (or filesystem_ts) instead of repeating

>dg-options "-DUSE_FILESYSTEM_TS -lstdc++fs" over and over again.


I tried to add this:

diff --git a/libstdc++-v3/testsuite/lib/dg-options.exp b/libstdc++-v3/testsuite/lib/dg-options.exp
index f73ce06..fae0b0d 100644
--- a/libstdc++-v3/testsuite/lib/dg-options.exp
+++ b/libstdc++-v3/testsuite/lib/dg-options.exp
@@ -254,6 +254,9 @@ proc add_options_for_net_ts { flags } {
     if { [istarget *-*-solaris2*] } {
        return "$flags -lsocket -lnsl"
     }
+    if { [istarget *-*-aix*] } {
+       return "$flags -pthread"
+    }
     return $flags
 }

But it doesn't work. It seems to be ignored, as the test log shows:

extra_tool_flags are:
  -Wl,-bmaxdata:0x20000000

That suggests I need to add:

{ dg-additional-options "-pthread" { target *-*-aix* } }

Which is a shame, given that we have your new net_ts that should work.
Rainer Orth Oct. 17, 2018, 9:08 a.m. | #3
Hi Jonathan,

>>Btw., one may want to do similarly for the Filesystem TS tests,

>>introducing dg-add-options fs_ts (or filesystem_ts) instead of repeating

>>dg-options "-DUSE_FILESYSTEM_TS -lstdc++fs" over and over again.

>

> I tried to add this:

>

> diff --git a/libstdc++-v3/testsuite/lib/dg-options.exp b/libstdc++-v3/testsuite/lib/dg-options.exp

> index f73ce06..fae0b0d 100644

> --- a/libstdc++-v3/testsuite/lib/dg-options.exp

> +++ b/libstdc++-v3/testsuite/lib/dg-options.exp

> @@ -254,6 +254,9 @@ proc add_options_for_net_ts { flags } {

>     if { [istarget *-*-solaris2*] } {

>        return "$flags -lsocket -lnsl"

>     }

> +    if { [istarget *-*-aix*] } {

> +       return "$flags -pthread"

> +    }

>     return $flags

> }

>

> But it doesn't work. It seems to be ignored, as the test log shows:

>

> extra_tool_flags are:

>  -Wl,-bmaxdata:0x20000000

>

> That suggests I need to add:

>

> { dg-additional-options "-pthread" { target *-*-aix* } }

>

> Which is a shame, given that we have your new net_ts that should work.


indeed.  After some investigation, it seems libstd++.exp
(libstdc++_init) is misusing DEFAULT_CFLAGS here: the third arg to
dg-runtest ($DEFAULT_CXXFLAGS $PCH_CXXFLAGS in
libstdc++.dg/conformance.exp) is documented like this in DejaGnu's
dg.exp:

# DEFAULT_EXTRA_OPTIONS is a set of options to pass if the testcase
# doesn't specify any (with dg-option).

The two settings of DEFAULT_CXXFLAGS in libstdc++.exp don't seem to fall
in that category at all, and most likely don't need overriding in
individual testcases.  Unfortunately, their semantics/need isn't
documented in the file and I didn't try to dig that up.

However, the proper way to handle this seems to use ALWAYS_CXXFLAGS
instead, appending to it along the lines of what libitm.exp
(libitm_init) does for ALWAYS_CFLAGS for a couple of targets.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

Patch

# HG changeset patch
# Parent  a0cb3bedd3f9d8fb598a779b1954c257c9a97cc7
Introduce dg-add-options net_ts

diff --git a/libstdc++-v3/testsuite/experimental/net/internet/address/v4/comparisons.cc b/libstdc++-v3/testsuite/experimental/net/internet/address/v4/comparisons.cc
--- a/libstdc++-v3/testsuite/experimental/net/internet/address/v4/comparisons.cc
+++ b/libstdc++-v3/testsuite/experimental/net/internet/address/v4/comparisons.cc
@@ -16,6 +16,7 @@ 
 // <http://www.gnu.org/licenses/>.
 
 // { dg-options "-std=gnu++14" }
+// { dg-add-options net_ts }
 
 #include <experimental/internet>
 #include <testsuite_hooks.h>
diff --git a/libstdc++-v3/testsuite/experimental/net/internet/address/v4/cons.cc b/libstdc++-v3/testsuite/experimental/net/internet/address/v4/cons.cc
--- a/libstdc++-v3/testsuite/experimental/net/internet/address/v4/cons.cc
+++ b/libstdc++-v3/testsuite/experimental/net/internet/address/v4/cons.cc
@@ -16,6 +16,7 @@ 
 // <http://www.gnu.org/licenses/>.
 
 // { dg-options "-std=gnu++14" }
+// { dg-add-options net_ts }
 
 #include <experimental/internet>
 #include <testsuite_hooks.h>
diff --git a/libstdc++-v3/testsuite/experimental/net/internet/address/v4/creation.cc b/libstdc++-v3/testsuite/experimental/net/internet/address/v4/creation.cc
--- a/libstdc++-v3/testsuite/experimental/net/internet/address/v4/creation.cc
+++ b/libstdc++-v3/testsuite/experimental/net/internet/address/v4/creation.cc
@@ -16,6 +16,7 @@ 
 // <http://www.gnu.org/licenses/>.
 
 // { dg-options "-std=gnu++14" }
+// { dg-add-options net_ts }
 
 #include <experimental/internet>
 #include <testsuite_hooks.h>
diff --git a/libstdc++-v3/testsuite/experimental/net/internet/address/v4/members.cc b/libstdc++-v3/testsuite/experimental/net/internet/address/v4/members.cc
--- a/libstdc++-v3/testsuite/experimental/net/internet/address/v4/members.cc
+++ b/libstdc++-v3/testsuite/experimental/net/internet/address/v4/members.cc
@@ -16,6 +16,7 @@ 
 // <http://www.gnu.org/licenses/>.
 
 // { dg-options "-std=gnu++14" }
+// { dg-add-options net_ts }
 
 #include <experimental/internet>
 #include <testsuite_hooks.h>
diff --git a/libstdc++-v3/testsuite/experimental/net/internet/resolver/base.cc b/libstdc++-v3/testsuite/experimental/net/internet/resolver/base.cc
--- a/libstdc++-v3/testsuite/experimental/net/internet/resolver/base.cc
+++ b/libstdc++-v3/testsuite/experimental/net/internet/resolver/base.cc
@@ -16,6 +16,7 @@ 
 // <http://www.gnu.org/licenses/>.
 
 // { dg-options "-std=gnu++14" }
+// { dg-add-options net_ts }
 
 #include <experimental/internet>
 #include <testsuite_hooks.h>
diff --git a/libstdc++-v3/testsuite/experimental/net/internet/resolver/ops/lookup.cc b/libstdc++-v3/testsuite/experimental/net/internet/resolver/ops/lookup.cc
--- a/libstdc++-v3/testsuite/experimental/net/internet/resolver/ops/lookup.cc
+++ b/libstdc++-v3/testsuite/experimental/net/internet/resolver/ops/lookup.cc
@@ -16,6 +16,7 @@ 
 // <http://www.gnu.org/licenses/>.
 
 // { dg-options "-std=gnu++14" }
+// { dg-add-options net_ts }
 
 #include <experimental/internet>
 #include <testsuite_hooks.h>
diff --git a/libstdc++-v3/testsuite/experimental/net/internet/resolver/ops/reverse.cc b/libstdc++-v3/testsuite/experimental/net/internet/resolver/ops/reverse.cc
--- a/libstdc++-v3/testsuite/experimental/net/internet/resolver/ops/reverse.cc
+++ b/libstdc++-v3/testsuite/experimental/net/internet/resolver/ops/reverse.cc
@@ -16,6 +16,7 @@ 
 // <http://www.gnu.org/licenses/>.
 
 // { dg-options "-std=gnu++14" }
+// { dg-add-options net_ts }
 
 #include <experimental/internet>
 #include <testsuite_hooks.h>
diff --git a/libstdc++-v3/testsuite/lib/dg-options.exp b/libstdc++-v3/testsuite/lib/dg-options.exp
--- a/libstdc++-v3/testsuite/lib/dg-options.exp
+++ b/libstdc++-v3/testsuite/lib/dg-options.exp
@@ -246,6 +246,17 @@  proc add_options_for_no_pch { flags } {
     return "-D__GLIBCXX__=99999999"
 }
 
+# Add to FLAGS all the target-specific flags needed for networking.
+
+proc add_options_for_net_ts { flags } {
+    # Before they were integrated into libc in Solaris 11.4, Solaris needs
+    # libsocket and libnsl for networking applications.
+    if { [istarget *-*-solaris2*] } {
+	return "$flags -lsocket -lnsl"
+    }
+    return $flags
+}
+
 # Like dg-options, but adds to the default options rather than replacing them.
 
 proc dg-additional-options { args } {