From: Pedro Alves <pedro@palves.net>
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 [thread overview]
Message-ID: <20220330192929.3161015-6-pedro@palves.net> (raw)
In-Reply-To: <20220330192929.3161015-1-pedro@palves.net>
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
next prev parent reply other threads:[~2022-03-30 19:29 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-30 19:29 [PATCH 0/5] " Pedro Alves
2022-03-30 19:29 ` [PATCH 1/5] Remove gdb_test questions that GDB doesn't ask Pedro Alves
2022-03-30 19:29 ` [PATCH 2/5] gdb.base/scope.exp: Remove bogus gdb_test questions Pedro Alves
2022-03-30 19:29 ` [PATCH 3/5] Fix bogus gdb_test invocations Pedro Alves
2022-03-30 19:29 ` [PATCH 4/5] Avoid having to unload file in gdb.server/connect-with-no-symbol-file.exp Pedro Alves
2022-03-30 19:29 ` Pedro Alves [this message]
2022-04-07 20:31 ` [PATCH 5/5] Make gdb_test's question non-optional if specified Bruno Larsen
2022-04-08 12:18 ` Pedro Alves
2022-05-17 10:13 ` [PATCH 5/6] gdb.base/skip.exp: Don't abuse gdb_test's question support (Re: [PATCH 5/5] Make gdb_test's question non-optional if specified) Pedro Alves
2022-05-16 16:01 ` [PATCH 5/5] Make gdb_test's question non-optional if specified Tom Tromey
2022-05-17 11:25 ` Pedro Alves
2022-05-17 22:48 ` Tom Tromey
2022-05-18 11:01 ` [pushed] Support -prompt and -lbl in gdb_test (Re: [PATCH 5/5] Make gdb_test's question non-optional if specified) Pedro Alves
2022-05-18 12:15 ` Tom de Vries
2022-05-18 12:36 ` Pedro Alves
2022-05-18 14:13 ` Pedro Alves
2022-05-18 14:49 ` Tom de Vries
2022-05-18 20:34 ` Tom Tromey
2022-05-19 12:42 ` Pedro Alves
2022-05-23 10:48 ` Tom de Vries
2022-05-23 12:01 ` Tom de Vries
2022-05-23 12:50 ` [committed][gdb/testsuite] Fix -prompt handling in gdb_test Tom de Vries
2022-05-23 12:53 ` [pushed] Support -prompt and -lbl in gdb_test (Re: [PATCH 5/5] Make gdb_test's question non-optional if specified) Pedro Alves
2022-05-17 11:41 ` [PATCH 5/5] Make gdb_test's question non-optional if specified Simon Marchi
2022-05-17 12:04 ` Pedro Alves
2022-05-16 16:02 ` [PATCH 0/5] " Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220330192929.3161015-6-pedro@palves.net \
--to=pedro@palves.net \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).