From: Tom de Vries Date: Wed, 18 Sep 2019 22:23:54 +0000 (+0200) Subject: [gdb/testsuite] Handle unreachable network in server-connect.exp X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=81dc3ab59476c9851a6cda321b85dcf8a6ef4be8;p=binutils-gdb.git [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 * 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. --- diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 83d5a4f0058..2acc1f73423 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2019-09-19 Tom de Vries + + * 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 * gdb.base/source-dir.exp: Avoid having directory names in test diff --git a/gdb/testsuite/gdb.server/server-connect.exp b/gdb/testsuite/gdb.server/server-connect.exp index 682fdaaeebf..e69f792a1bb 100644 --- a/gdb/testsuite/gdb.server/server-connect.exp +++ b/gdb/testsuite/gdb.server/server-connect.exp @@ -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 } } } diff --git a/gdb/testsuite/lib/gdbserver-support.exp b/gdb/testsuite/lib/gdbserver-support.exp index ade99c0ea16..2ad53c1f608 100644 --- a/gdb/testsuite/lib/gdbserver-support.exp +++ b/gdb/testsuite/lib/gdbserver-support.exp @@ -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"