From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 117333 invoked by alias); 18 Sep 2019 11:56:02 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 117323 invoked by uid 89); 18 Sep 2019 11:56:02 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.6 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 spammy=flight, multiprocess, UD:reconnect-ctrl-c.exp, sk:reconne X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 18 Sep 2019 11:55:59 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 53AD0ABC4; Wed, 18 Sep 2019 11:55:57 +0000 (UTC) Subject: Re: [PATCH][gdb/testsuite] Handle unreachable network in server-connect.exp To: Tom Tromey Cc: gdb-patches@sourceware.org References: <20190914102344.GA5471@delia> <87y2ymx0o2.fsf@tromey.com> From: Tom de Vries Openpgp: preference=signencrypt Message-ID: <5f724500-d168-9bbb-139f-c455899b6c82@suse.de> Date: Wed, 18 Sep 2019 11:56:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <87y2ymx0o2.fsf@tromey.com> Content-Type: multipart/mixed; boundary="------------8CB1F55ACEAF88B55CBF794D" X-IsSubscribed: yes X-SW-Source: 2019-09/txt/msg00337.txt.bz2 This is a multi-part message in MIME format. --------------8CB1F55ACEAF88B55CBF794D Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-length: 7009 On 17-09-19 20:01, Tom Tromey wrote: >>>>>> "Tom" == Tom de Vries writes: > > Tom> + set res [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport] > Tom> + if { $res == 0 } { > Tom> pass $test > Tom> - } else { > Tom> + } elseif { $res == 1 } { > Tom> fail $test > Tom> + } else { > Tom> + unsupported $test > > Should this treatment be applied to the other callers of gdb_target_cmd? > The callers in the test-cases either don't check the result, or compare to 0, so there it doesn't matter. But there are uses in f.i. gdbserver-support.exp where the new value does matter, f.i. in gdbserver_run. So, I'm attaching an updated patch that does not modify the existing semantics of gdb_target_cmd. > I agree with Sergio that the patch is fine, but I wonder if a bigger > cleanup is warranted here. FWIW, I did a test run with my laptop switched into flight mode and with the loopback device removed (sudo ifconfig lo down), and found these new failures: ... FAIL: gdb.btrace/reconnect.exp: first: record btrace enable FAIL: gdb.btrace/reconnect.exp: first: stepi 19 (the program is no longer running) FAIL: gdb.btrace/reconnect.exp: first: info record FAIL: gdb.btrace/reconnect.exp: first: disconnect FAIL: gdb.btrace/reconnect.exp: second: info record FAIL: gdb.btrace/reconnect.exp: second: record stop FAIL: gdb.btrace/reconnect.exp: second: disconnect FAIL: gdb.btrace/reconnect.exp: third: info record FAIL: gdb.mi/mi-file-transfer.exp: put binary file (unexpected output) FAIL: gdb.mi/mi-file-transfer.exp: get binary file (unexpected output) FAIL: gdb.mi/mi-file-transfer.exp: compare intermediate binary file FAIL: gdb.mi/mi-file-transfer.exp: compare binary file FAIL: gdb.mi/mi-file-transfer.exp: deleted binary file (unexpected output) FAIL: gdb.server/abspath.exp: setting breakpoint at main FAIL: gdb.server/abspath.exp: continue to main (the program is no longer running) FAIL: gdb.server/connect-stopped-target.exp: non-stop=off: connect and print pc (timeout) FAIL: gdb.server/connect-stopped-target.exp: non-stop=off: print pc again FAIL: gdb.server/connect-stopped-target.exp: non-stop=on: connect and print pc (timeout) FAIL: gdb.server/connect-stopped-target.exp: non-stop=on: print pc again FAIL: gdb.server/connect-with-no-symbol-file.exp: sysroot=: action=permission: connection to GDBserver succeeded FAIL: gdb.server/connect-with-no-symbol-file.exp: sysroot=: action=delete: connection to GDBserver succeeded FAIL: gdb.server/connect-with-no-symbol-file.exp: sysroot=target:: action=permission: connection to GDBserver succeeded FAIL: gdb.server/connect-with-no-symbol-file.exp: sysroot=target:: action=delete: connection to GDBserver succeeded FAIL: gdb.server/connect-without-multi-process.exp: multiprocess=off: target remote (timeout) FAIL: gdb.server/connect-without-multi-process.exp: multiprocess=off: continue to main FAIL: gdb.server/connect-without-multi-process.exp: multiprocess=auto: target remote (timeout) FAIL: gdb.server/connect-without-multi-process.exp: multiprocess=auto: continue to main FAIL: gdb.server/ext-attach.exp: set remote exec-file FAIL: gdb.server/ext-attach.exp: monitor exit FAIL: gdb.server/ext-restart.exp: set remote exec-file FAIL: gdb.server/ext-restart.exp: monitor exit FAIL: gdb.server/ext-run.exp: set remote exec-file FAIL: gdb.server/ext-run.exp: load new file without any gdbserver inferior FAIL: gdb.server/ext-run.exp: monitor exit FAIL: gdb.server/ext-wrapper.exp: set remote exec-file FAIL: gdb.server/ext-wrapper.exp: print d FAIL: gdb.server/ext-wrapper.exp: restart: print d FAIL: gdb.server/ext-wrapper.exp: monitor exit FAIL: gdb.server/file-transfer.exp: put binary file FAIL: gdb.server/file-transfer.exp: get binary file FAIL: gdb.server/file-transfer.exp: compare intermediate binary file FAIL: gdb.server/file-transfer.exp: compare binary file FAIL: gdb.server/file-transfer.exp: deleted binary file FAIL: gdb.server/file-transfer.exp: put text file FAIL: gdb.server/file-transfer.exp: get text file FAIL: gdb.server/file-transfer.exp: compare intermediate text file FAIL: gdb.server/file-transfer.exp: compare text file FAIL: gdb.server/file-transfer.exp: deleted text file FAIL: gdb.server/no-thread-db.exp: libthread-db is now unresolvable FAIL: gdb.server/no-thread-db.exp: continue to breakpoint: after tls assignment (the program is no longer running) FAIL: gdb.server/no-thread-db.exp: print foo FAIL: gdb.server/reconnect-ctrl-c.exp: first: connect FAIL: gdb.server/reconnect-ctrl-c.exp: second: disconnect FAIL: gdb.server/reconnect-ctrl-c.exp: second: connect FAIL: gdb.server/run-without-local-binary.exp: connect to gdbserver (timeout) FAIL: gdb.server/run-without-local-binary.exp: run test program until the end FAIL: gdb.server/server-exec-info.exp: info files FAIL: gdb.server/server-kill.exp: setting breakpoint at server-kill.c:29 FAIL: gdb.server/server-kill.exp: tstatus FAIL: gdb.server/server-mon.exp: monitor help FAIL: gdb.server/server-mon.exp: monitor FAIL: gdb.server/server-mon.exp: monitor set debug 1 FAIL: gdb.server/server-mon.exp: monitor set debug 0 FAIL: gdb.server/server-mon.exp: monitor set remote-debug 1 FAIL: gdb.server/server-mon.exp: monitor set remote-debug 0 FAIL: gdb.server/server-mon.exp: monitor set debug-format all FAIL: gdb.server/server-mon.exp: monitor set debug-format none FAIL: gdb.server/server-run.exp: continue to main (the program is no longer running) FAIL: gdb.server/solib-list.exp: non-stop 0: target remote (timeout) FAIL: gdb.server/solib-list.exp: non-stop 0: continue FAIL: gdb.server/solib-list.exp: non-stop 0: p libvar FAIL: gdb.server/solib-list.exp: non-stop 1: target remote (timeout) FAIL: gdb.server/solib-list.exp: non-stop 1: continue FAIL: gdb.server/solib-list.exp: non-stop 1: p libvar FAIL: gdb.server/stop-reply-no-thread.exp: connect FAIL: gdb.server/sysroot.exp: sysroot=local: connect to remote and read binary FAIL: gdb.server/sysroot.exp: sysroot=local: setting breakpoint at main FAIL: gdb.server/sysroot.exp: sysroot=local: continue to main (got interactive prompt) FAIL: gdb.server/sysroot.exp: sysroot=local: setting breakpoint at printf FAIL: gdb.server/sysroot.exp: sysroot=local: continue to printf (the program is no longer running) FAIL: gdb.server/sysroot.exp: sysroot=remote: connect to remote and read binary FAIL: gdb.server/sysroot.exp: sysroot=remote: setting breakpoint at main FAIL: gdb.server/sysroot.exp: sysroot=remote: continue to main (got interactive prompt) FAIL: gdb.server/sysroot.exp: sysroot=remote: setting breakpoint at printf FAIL: gdb.server/sysroot.exp: sysroot=remote: continue to printf (the program is no longer running) FAIL: gdb.server/wrapper.exp: setting breakpoint at marker FAIL: gdb.server/wrapper.exp: continue to marker (the program is no longer running) FAIL: gdb.server/wrapper.exp: print d ... So, I think you're right that a larger cleanup could be done. But for now, I'd like to focus on this ipv6-specific one. Thanks, - Tom --------------8CB1F55ACEAF88B55CBF794D Content-Type: text/x-patch; name="0001-gdb-testsuite-Handle-unreachable-network-in-server-connect.exp.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename*0="0001-gdb-testsuite-Handle-unreachable-network-in-server-conn"; filename*1="ect.exp.patch" Content-length: 3878 [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-14 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. --- gdb/testsuite/gdb.server/server-connect.exp | 7 +++++-- gdb/testsuite/lib/gdbserver-support.exp | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/gdb/testsuite/gdb.server/server-connect.exp b/gdb/testsuite/gdb.server/server-connect.exp index 682fdaaeeb..e69f792a1b 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 ade99c0ea1..2ad53c1f60 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" --------------8CB1F55ACEAF88B55CBF794D--