From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1879) id 1197B3858022; Thu, 26 Jan 2023 20:22:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1197B3858022 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1674764573; bh=lyWE77jpnM5o16dx+lUGRj+KwkCmoQ7sgssaIZlt+z4=; h=From:To:Subject:Date:From; b=Tr5OMJ0WWBdxSJ3BbaS+78U8FWU+dm+AQthsPjhK248fDqU9H1jkdhRY9eJ5cboUI 4HQ7v1KpCKQO/Nsiuryvn1kMSvxpD885/szP43dur0En7F0Gi0/kVEjRN2tG6y1YEU 1dyPPCOLDh6exQ9QW/iewgyV0VqkO+3QDfuasCrE= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Simon Marchi To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/testsuite/dap: make dap_request_and_response not catch / issue test result X-Act-Checkin: binutils-gdb X-Git-Author: Simon Marchi X-Git-Refname: refs/heads/master X-Git-Oldrev: 4cdda229da53bde30b2a22155ee7ceb025cebc49 X-Git-Newrev: 2e9a03fd2e20f9d0d3ddb340ba248bfb1d5ed521 Message-Id: <20230126202253.1197B3858022@sourceware.org> Date: Thu, 26 Jan 2023 20:22:53 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D2e9a03fd2e20= f9d0d3ddb340ba248bfb1d5ed521 commit 2e9a03fd2e20f9d0d3ddb340ba248bfb1d5ed521 Author: Simon Marchi Date: Fri Jan 6 11:09:00 2023 -0500 gdb/testsuite/dap: make dap_request_and_response not catch / issue test= result =20 Following some of my changes, dap_request_and_response was failing and I didn't know why. I think it's better to make it not catch any exception, and just make it do a simple "send request, read response". If an exception is thrown while sending a request or reading a response, things are going really badly, it's not like we'll want to recover from that and continue the test. =20 Change-Id: I27568d3547f753c3a74e3e5a730d38a8caef9356 Diff: --- gdb/testsuite/gdb.dap/basic-dap.exp | 2 +- gdb/testsuite/lib/dap-support.exp | 25 ++++++------------------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/gdb/testsuite/gdb.dap/basic-dap.exp b/gdb/testsuite/gdb.dap/ba= sic-dap.exp index c60989d2a6f..af55d19349f 100644 --- a/gdb/testsuite/gdb.dap/basic-dap.exp +++ b/gdb/testsuite/gdb.dap/basic-dap.exp @@ -123,7 +123,7 @@ set obj [dap_check_request_and_response "evaluate globa= l in main" \ dap_match_values "global value in main" [lindex $obj 0] \ "body result" 25 =20 -set obj [dap_request_and_response "evaluate non-existing variable" \ +set obj [dap_request_and_response \ evaluate {o expression [s nosuchvariable]}] set d [namespace eval ton::2dict [lindex $obj 0]] gdb_assert { [dict get $d success] =3D=3D "false" } "result of invalid req= uest" diff --git a/gdb/testsuite/lib/dap-support.exp b/gdb/testsuite/lib/dap-supp= ort.exp index 94a0d27c8a8..bc99f0182a7 100644 --- a/gdb/testsuite/lib/dap-support.exp +++ b/gdb/testsuite/lib/dap-support.exp @@ -201,29 +201,16 @@ proc _dap_read_response {cmd num} { } =20 # A wrapper for _dap_send_request and _dap_read_response. This sends a -# request to gdb and returns the result. NAME is used to issue a pass -# or fail; on failure, this always returns an empty string. -proc dap_request_and_response {name command {obj {}}} { - set result {} - if {[catch { - set seq [_dap_send_request $command $obj] - set result [_dap_read_response $command $seq] - } text]} { - verbose "reason: $text" - fail $name - } else { - pass $name - } - return $result +# request to gdb and returns the response as a dict. +proc dap_request_and_response {command {obj {}}} { + set seq [_dap_send_request $command $obj] + return [_dap_read_response $command $seq] } =20 # Like dap_request_and_response, but also checks that the response -# indicates success. +# indicates success. NAME is used to issue a test result. proc dap_check_request_and_response {name command {obj {}}} { - set result [dap_request_and_response $name $command $obj] - if {$result =3D=3D ""} { - return "" - } + set result [dap_request_and_response $command $obj] set d [namespace eval ton::2dict [lindex $result 0]] if {[dict get $d success] !=3D "true"} { verbose "request failure: $result"