From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by sourceware.org (Postfix) with ESMTPS id E3867384B126 for ; Thu, 19 May 2022 12:34:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E3867384B126 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f48.google.com with SMTP id t6so6978981wra.4 for ; Thu, 19 May 2022 05:34:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bO0oQxjH6q+0Pb+ASlwdD6JjvftxZB/gyLGvR5CXVtY=; b=zB3+SfVRwmblV6jWAYxjbL/8A8+kgQi4PBOfCgbLZCm91PGRi1POaLTEvqO8gxu30m 07rQvENVg9pyefUIawO1q36pWNLvskU4fxrSfjUgSRKjgU8Wsf0NGA+ZgiBvBzV4MA2K w1SJBh2YC2Ywu92had52PfFTbvJXCzZJ2fXRKhDnaeavOhy157loLNvyLnHLHeSuhQQu FR2sf1UTaJ0SDCSz1sMJDMODurK3/LJQzu+OC8vY1GJ0oIYFaOLeQn99d3Rp0055v9T+ snNLSILDiaDlPu4cGfMFYSNTEPmkJvZ7VzT+vLKjJB61oKAb4QoSWkFnkRsWsInKaiJK Co7g== X-Gm-Message-State: AOAM530NTV/X3SIltZ/9Ne0+dBnGMt++eGDO0WE0cG2/P1+zFeVsmD26 JV4ctg6A339POAtTUlFCc4TvLqcYBoE= X-Google-Smtp-Source: ABdhPJxnfHsauVrcKSrusZel5jEdZDl7zIcDh0xfUH4VkCSL/RPZCtBn7P1etLTQVQlBATi/ShK/Mg== X-Received: by 2002:adf:fc52:0:b0:20e:5d79:893e with SMTP id e18-20020adffc52000000b0020e5d79893emr3857112wrs.711.1652963690138; Thu, 19 May 2022 05:34:50 -0700 (PDT) Received: from localhost ([2001:8a0:f924:2600:209d:85e2:409e:8726]) by smtp.gmail.com with ESMTPSA id t12-20020adfba4c000000b0020c5253d91esm4750241wrg.106.2022.05.19.05.34.48 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 19 May 2022 05:34:48 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 1/2] Add -nopass option to gdb_test/gdb_test_multiple Date: Thu, 19 May 2022 13:34:44 +0100 Message-Id: <20220519123445.2756177-2-pedro@palves.net> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220519123445.2756177-1-pedro@palves.net> References: <20220519123445.2756177-1-pedro@palves.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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-List-Received-Date: Thu, 19 May 2022 12:34:53 -0000 The previous patch to add -prompt/-lbl gdb_test to gdb_test introduced a regression: Before, you could specify an explicit empty message to indicate you didn't want to PASS, like so: gdb_test COMMAND PATTERN "" After said patch, gdb_test no longer distinguishes no-message-specified vs empty-message, so tests that previously would be silent on PASS, now started emitting PASS messages based on COMMAND. This in turn introduced a number of PATH/DUPLICATE violations in the testsuite. I think that not issuing a PASS should be restricted to only a few cases -- namely in shared routines exported by gdb.exp, which happen to use gdb_test internally. In tests that iterate an unknown number of tests exercising some racy scenario. In the latter case, if we emit PASSes for each iteration, we run into the situation where different testsuite runs emit a different number of PASSes. Thus, this patch preserves the current behavior, and, instead, adds a new "-nopass" option to gdb_test and gdb_test_no_output. Compared to the old way of supressing PASS with an empty message, this has the advantage that you can specify a FAIL message that is distinct from the command string, and, it's also more explicit. Change-Id: I5375f23f073493e0672190a0ec2e847938a580b2 --- gdb/testsuite/lib/gdb.exp | 60 +++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 97841ca19a1..d6627d3b23e 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -834,6 +834,13 @@ proc gdb_internal_error_resync {} { return 0 } +# Fill in the default prompt if PROMPT_REGEXP is empty. +proc fill_in_default_prompt {prompt_regexp} { + if { "$prompt_regexp" == "" } { + return "$::gdb_prompt $" + } + return $prompt_regexp +} # gdb_test_multiple COMMAND MESSAGE [ -prompt PROMPT_REGEXP] [ -lbl ] # EXPECT_ARGUMENTS @@ -960,9 +967,7 @@ proc gdb_test_multiple { command message args } { error "Too few arguments to gdb_test_multiple" } - if { "$prompt_regexp" == "" } { - set prompt_regexp "$gdb_prompt $" - } + set prompt_regexp [fill_in_default_prompt $prompt_regexp] if { $message == "" } { set message $command @@ -1335,6 +1340,7 @@ proc gdb_test_multiline { name args } { # -prompt PROMPT_REGEXP specifies a regexp matching the expected prompt # after the command output. If empty, defaults to "$gdb_prompt $". # -lbl specifies that line-by-line matching will be used. +# -nopass specifies that a PASS should not be issued. # # Returns: # 1 if the test failed, @@ -1348,6 +1354,7 @@ proc gdb_test { args } { parse_args { {prompt ""} {lbl} + {nopass} } lassign $args command pattern message question response @@ -1361,21 +1368,17 @@ proc gdb_test { args } { set message $command } - if { $prompt == "" } { - set prompt "$gdb_prompt $" - } + set prompt [fill_in_default_prompt $prompt] set saw_question 0 set user_code {} lappend user_code { -re "\[\r\n\]*(?:$pattern)\[\r\n\]+$prompt" { - if ![string match "" $message] then { - if { $question != "" } { - gdb_assert $saw_question "$message" - } else { - pass "$message" - } + if { $question != "" & !$saw_question} { + fail $message + } elseif {!$nopass} { + pass $message } } } @@ -1439,30 +1442,31 @@ if { [tcl_version_at_least 8 5] == 0 } { } } -# gdb_test_no_output COMMAND MESSAGE +# gdb_test_no_output [-prompt PROMPT_REGEXP] [-nopass] COMMAND [MESSAGE] # Send a command to GDB and verify that this command generated no output. # -# See gdb_test_multiple for a description of the COMMAND and MESSAGE -# parameters. If MESSAGE is ommitted, then COMMAND will be used as -# the message. (If MESSAGE is the empty string, then sometimes we do not -# call pass or fail at all; I don't understand this at all.) +# See gdb_test for a description of the -prompt, -nopass, COMMAND, and +# MESSAGE parameters. proc gdb_test_no_output { args } { global gdb_prompt - set command [lindex $args 0] - if [llength $args]>1 then { - set message [lindex $args 1] - } else { - set message $command + + parse_args { + {prompt_re ""} + {nopass} } + lassign $args command message + + set prompt_re [fill_in_default_prompt $prompt_re] + set command_regex [string_to_regexp $command] - gdb_test_multiple $command $message { - -re "^$command_regex\r\n$gdb_prompt $" { - if ![string match "" $message] then { - pass "$message" - } - } + gdb_test_multiple $command $message -prompt $prompt_re { + -re "^$command_regex\r\n$prompt_re" { + if {!$nopass} { + pass $gdb_test_name + } + } } } -- 2.36.0