From patchwork Fri Jan 6 18:57:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 62811 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B14553857C48 for ; Fri, 6 Jan 2023 18:58:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B14553857C48 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673031496; bh=hCtxmAa3VfITbwFIlG2VBMlvMyzwjvdOD+W72jNiCSc=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=qIKS1a1e64Eoluc2KPsJDmGOH64BxvOkj3H7GBQW5a7eF01rE5nw8ZYRteFOsHRFj drxyxw/utJE5DwPJcpLSMn1+0pOMVYuRjgrrHJ3iqzxl7vMkaMc6lq4h/AsMMLb/3U T7geqRqYi3Vofv4lMFf1XyN1ZsNxUGyLFONZRNGU= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 225FB3858CDB for ; Fri, 6 Jan 2023 18:57:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 225FB3858CDB X-ASG-Debug-ID: 1673031450-0c856e762b4b7e90001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id swSdvAMN6W18NYBG (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO); Fri, 06 Jan 2023 13:57:30 -0500 (EST) X-Barracuda-Envelope-From: simon.marchi@efficios.com X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from epycamd.internal.efficios.com (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) by smtp.ebox.ca (Postfix) with ESMTP id E3595441B21; Fri, 6 Jan 2023 13:57:30 -0500 (EST) X-Barracuda-RBL-IP: 192.222.180.24 X-Barracuda-Effective-Source-IP: 192-222-180-24.qc.cable.ebox.net[192.222.180.24] X-Barracuda-Apparent-Source-IP: 192.222.180.24 To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 4/9] gdb/testsuite/dap: make dap_request_and_response not catch / issue test result Date: Fri, 6 Jan 2023 13:57:24 -0500 X-ASG-Orig-Subj: [PATCH 4/9] gdb/testsuite/dap: make dap_request_and_response not catch / issue test result Message-Id: <20230106185729.42372-5-simon.marchi@efficios.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230106185729.42372-1-simon.marchi@efficios.com> References: <20230106185729.42372-1-simon.marchi@efficios.com> MIME-Version: 1.0 X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1673031450 X-Barracuda-Encrypted: AES128-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-BRTS-Status: 1 X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 2837 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=5.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.103363 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-3498.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Simon Marchi via Gdb-patches From: Simon Marchi Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" 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. Change-Id: I27568d3547f753c3a74e3e5a730d38a8caef9356 --- 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/basic-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 global in main" \ dap_match_values "global value in main" [lindex $obj 0] \ "body result" 25 -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] == "false" } "result of invalid request" diff --git a/gdb/testsuite/lib/dap-support.exp b/gdb/testsuite/lib/dap-support.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} { } # 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] } # 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 == ""} { - return "" - } + set result [dap_request_and_response $command $obj] set d [namespace eval ton::2dict [lindex $result 0]] if {[dict get $d success] != "true"} { verbose "request failure: $result"