[gdb/testsuite] Handle unreachable network in server-connect.exp

When running gdb.server/server-connect.exp I run into:
...
FAIL: gdb.server/server-connect.exp: tcp6: connect to gdbserver using tcp6:::1
FAIL: gdb.server/server-connect.exp: tcp6-with-brackets: connect to gdbserver \
  using tcp6:[::1]
FAIL: gdb.server/server-connect.exp: udp6: connect to gdbserver using udp6:::1
FAIL: gdb.server/server-connect.exp: udp6-with-brackets: connect to gdbserver \
  using udp6:[::1]
...

The FAIL is caused by the fact that the ipv6 loopback address is not available:
...
PASS: gdb.server/server-connect.exp: tcp6: start gdbserver
target remote tcp6:::1:2347^M
A program is being debugged already.  Kill it? (y or n) y^M
tcp6:::1:2347: Network is unreachable.^M
(gdb) FAIL: gdb.server/server-connect.exp: tcp6: connect to gdbserver using tcp6:::1
...
This should be marked UNSUPPORTED rather than FAIL.

Furthermore, the test-case takes about 4 minutes, because the 'Network is
unreachable' response is not explicitly handled in gdb_target_cmd, so instead
it runs into the timeout case.

Fix this by handling the 'Network is unreachable' response as UNSUPPORTED.
This reduces testing time from 4 minutes to about 2 seconds.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-09-19  Tom de Vries  <tdevries@suse.de>

	* lib/gdbserver-support.exp (gdb_target_cmd_ext): Return 2 (meaning
	UNSUPPORTED) for 'Network is unreachable' message.  Factor out of ...
	(gdb_target_cmd): ... here.
	* gdb.server/server-connect.exp: Use gdb_target_cmd_ext, handle return
	value 2.
This commit is contained in:
Tom de Vries 2019-09-19 00:23:54 +02:00
parent a1726c38a9
commit 81dc3ab594
3 changed files with 26 additions and 5 deletions

View File

@ -1,3 +1,11 @@
2019-09-19 Tom de Vries <tdevries@suse.de>
* lib/gdbserver-support.exp (gdb_target_cmd_ext): Return 2 (meaning
UNSUPPORTED) for 'Network is unreachable' message. Factor out of ...
(gdb_target_cmd): ... here.
* gdb.server/server-connect.exp: Use gdb_target_cmd_ext, handle return
value 2.
2019-09-18 Andrew Burgess <andrew.burgess@embecosm.com>
* gdb.base/source-dir.exp: Avoid having directory names in test

View File

@ -101,10 +101,13 @@ save_vars { GDB_TEST_SOCKETHOST } {
set gdbserver_gdbport [lindex $res 1]
set test "connect to gdbserver using $sockhost"
if { [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport] == 0 } {
set res [gdb_target_cmd_ext $gdbserver_protocol $gdbserver_gdbport]
if { $res == 0 } {
pass $test
} else {
} elseif { $res == 1 } {
fail $test
} else {
unsupported $test
}
}
}

View File

@ -41,12 +41,13 @@
#
#
# gdb_target_cmd
# Send gdb the "target" command. Returns 0 on success, 1 on failure.
# gdb_target_cmd_ext
# Send gdb the "target" command. Returns 0 on success, 1 on failure, 2 on
# unsupported.
# If specified, then ADDITIONAL_TEXT must match the text that comes after
# the connection message in order for the procedure to succeed.
#
proc gdb_target_cmd { targetname serialport {additional_text ""} } {
proc gdb_target_cmd_ext { targetname serialport {additional_text ""} } {
global gdb_prompt
set serialport_re [string_to_regexp $serialport]
@ -97,6 +98,9 @@ proc gdb_target_cmd { targetname serialport {additional_text ""} } {
# Leave it there for the test to diagnose.
return 1
}
-re ": Network is unreachable.\r\n.*$gdb_prompt $" {
return 2
}
timeout {
send_gdb ""
break
@ -106,6 +110,12 @@ proc gdb_target_cmd { targetname serialport {additional_text ""} } {
return 1
}
# Like gdb_target_cmd_ext, but returns 0 on success, 1 on failure.
proc gdb_target_cmd { $args } {
set res [gdb_target_cmd_ext $args]
return [expr $res == 0 ? 0 : 1]
}
global portnum
set portnum "2345"