From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) by sourceware.org (Postfix) with ESMTPS id 546563888C59 for ; Wed, 30 Mar 2022 19:29:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 546563888C59 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-f43.google.com with SMTP id w21so26144031wra.2 for ; Wed, 30 Mar 2022 12:29:44 -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=rZ4oyMkAP93TRIYjtuYEe3NCDobeeEwIlnz5IPLjnG8=; b=CqynHJ2GUgINTp6IjfjiTLKPWLKtL6lML4fqxvGI2dkhKJVma8ES4ZEa2ta3Xm9/KW /eJsKRzR+jhHaxcfhvc7PRcUPJiru2X6F7iUrP+96S+KE2arAgCof4a9/jyWVegp3zXR YBC9uHNcIs1CVupB2d/hpo/J6drxUefy5M5gltQWShN4p/M/G7XJk7080UBhW/BbEj+X sa6/54LjBM9M2tWhSy3srEeOsjk90TEpiTP1Yx5TEHgfRCwyeSCyaniYPhgTcCfxTCiD zlpZvUGZi0CmR7wit5vZT5t4tcukObiDbzRGM2ONZhUes8A8ozqHI5cvqGLWMswIybCC I/og== X-Gm-Message-State: AOAM532X04fV1kbUt11FepinsOcnfoRYODyc2PEd16eIQayAhUOFywoP SGTzt7Vu7yKQLsLlmxWsP+TnNf+tByw= X-Google-Smtp-Source: ABdhPJwcG62ngrgI3GaDLkqh6nx3JGdJepK6/PwIT6RZtQrzExIGx+yyAGzP+K1PMhzfyYEwXR5fpg== X-Received: by 2002:a05:6000:ca:b0:203:dbf3:8f8a with SMTP id q10-20020a05600000ca00b00203dbf38f8amr1085482wrx.10.1648668581861; Wed, 30 Mar 2022 12:29:41 -0700 (PDT) Received: from localhost ([2001:8a0:f924:2600:209d:85e2:409e:8726]) by smtp.gmail.com with ESMTPSA id u7-20020a05600c19c700b0038cc9aac1a3sm5907413wmq.23.2022.03.30.12.29.40 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 30 Mar 2022 12:29:41 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 5/5] Make gdb_test's question non-optional if specified Date: Wed, 30 Mar 2022 20:29:29 +0100 Message-Id: <20220330192929.3161015-6-pedro@palves.net> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220330192929.3161015-1-pedro@palves.net> References: <20220330192929.3161015-1-pedro@palves.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.5 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Wed, 30 Mar 2022 19:29:45 -0000 gdb_test supports handling scenarios where GDB asks a question before finishing handling some command. The full prototype of gdb_test is: # gdb_test COMMAND PATTERN MESSAGE QUESTION RESPONSE However, QUESTION is a question that GDB _may_ ask, not one that GDB _must_ ask: # QUESTION is a question GDB may ask in response to COMMAND, like # "are you sure?" # RESPONSE is the response to send if QUESTION appears. If GDB doesn't raise the question, the test still passes. I think that this is a misfeature. If GDB regresses and stops asking a question, the testsuite won't notice. So I think that if a QUESTION is specified, gdb_test should ensure it comes out of GDB. Running the testsuite exposed a number of tests that pass QUESTION/RESPONSE to GDB, but no question comes out. The previous commits fixed them all, so this commit changes gdb_test's behavior. A related issue is that gdb_test doesn't enforce that if you specify QUESTION, that you also specify RESPONSE. I.e., you should pass 1, 2, 3, or 5 arguments to gdb_test, but never 4, or more than 5. Making gdb_test detect bogus arguments actually regressed some testcases, also all fixed in previous commits. Change-Id: I47c39c9034e6a6841129312037a5ca4c5811f0db --- gdb/testsuite/lib/gdb.exp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 0b242b64992..e9cbbe77fa4 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -1324,9 +1324,10 @@ proc gdb_test_multiline { name args } { # omitted, then the pass/fail messages use the command string as the # message. (If this is the empty string, then sometimes we don't # call pass or fail at all; I don't understand this at all.) -# QUESTION is a question GDB may ask in response to COMMAND, like -# "are you sure?" -# RESPONSE is the response to send if QUESTION appears. +# QUESTION is a question GDB should ask in response to COMMAND, like +# "are you sure?" If this is specified, the test fails if GDB +# doesn't print the question. +# RESPONSE is the response to send when QUESTION appears. # # Returns: # 1 if the test failed, @@ -1337,6 +1338,11 @@ proc gdb_test { args } { global gdb_prompt upvar timeout timeout + # Can't have a question without a response. + if { [llength $args] == 4 || [llength $args] > 5 } { + error "Unexpected arguments: $args" + } + if [llength $args]>2 then { set message [lindex $args 2] } else { @@ -1345,11 +1351,21 @@ proc gdb_test { args } { set command [lindex $args 0] set pattern [lindex $args 1] + set must_see_question 0 + if { [llength $args] == 5 } { + set must_see_question 1 + set saw_question 0 + } + set user_code {} lappend user_code { -re "\[\r\n\]*(?:$pattern)\[\r\n\]+$gdb_prompt $" { if ![string match "" $message] then { - pass "$message" + if {$must_see_question} { + gdb_assert $saw_question "$message" + } else { + pass "$message" + } } } } @@ -1359,6 +1375,7 @@ proc gdb_test { args } { set response_string [lindex $args 4] lappend user_code { -re "(${question_string})$" { + set saw_question 1 send_gdb "$response_string\n" exp_continue } -- 2.26.2