From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: [PATCH 3/5] gdb/testsuite: use 'return' in gdb_test_no_output
Date: Fri, 31 Mar 2023 21:20:56 +0100 [thread overview]
Message-ID: <f054db3b245b11f2f3a386a271a001b687b881e0.1680293848.git.aburgess@redhat.com> (raw)
In-Reply-To: <cover.1680293848.git.aburgess@redhat.com>
A TCL proc will return the return value of the last command executed
within the proc's body if there is no explicit return call, so
gdb_test_no_output is already returning the return value of
gdb_test_multiple.
However, I'm not a fan of this implicit return value behaviour, so in
this commit I have extended the comment on gdb_test_no_output to
document the possible return values (just as gdb_test does), and
explicitly call return.
This should make no different to our testing, but I think it's clearer
now what the gdb_test_no_output proc is expected to do.
The two tests gdb.base/auxv.exp and gdb.base/list.exp both rely on the
return value of gdb_test_no_output, and continue to pass after this
change.
I also spotted that gdb.base/watchpoint.exp could be updated to make
use of gdb_test_no_output, so I did that.
---
gdb/testsuite/gdb.base/watchpoint.exp | 17 ++++++++++-------
gdb/testsuite/lib/gdb.exp | 9 +++++++--
2 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/gdb/testsuite/gdb.base/watchpoint.exp b/gdb/testsuite/gdb.base/watchpoint.exp
index 513964ebf86..7f821ee8a11 100644
--- a/gdb/testsuite/gdb.base/watchpoint.exp
+++ b/gdb/testsuite/gdb.base/watchpoint.exp
@@ -80,7 +80,7 @@ proc initialize {} {
# to use it. This allows the test program to run at full speed until
# we get to the first marker function.
- if [gdb_test "disable 3" "disable 3\[\r\n\]+" "disable watchpoint" ] {
+ if [gdb_test_no_output "disable 3" "disable watchpoint" ] {
return 0
}
@@ -99,7 +99,8 @@ proc test_simple_watchpoint {} {
# Ensure that the watchpoint is disabled when we startup.
- if [gdb_test "disable 3" "^disable 3\[\r\n\]+" "disable watchpoint in test_simple_watchpoint" ] {
+ if [gdb_test_no_output "disable 3" \
+ "disable watchpoint in test_simple_watchpoint" ] {
return 0
}
@@ -120,7 +121,7 @@ proc test_simple_watchpoint {} {
# After reaching the marker function, enable the watchpoint.
- if [gdb_test "enable 3" "^enable 3\[\r\n\]+" "enable watchpoint" ] {
+ if [gdb_test_no_output "enable 3" "enable watchpoint" ] {
return
}
@@ -187,7 +188,7 @@ Continuing.*\[Ww\]atchpoint.*ival3.*Old value = -1.*New value = 0.*ival3 = count
# Disable the watchpoint so we run at full speed until we exit.
- if [gdb_test "disable 3" "^disable 3\[\r\n\]+" "watchpoint disabled" ] {
+ if [gdb_test_no_output "disable 3" "watchpoint disabled" ] {
return
}
@@ -212,7 +213,8 @@ proc test_disabling_watchpoints {} {
# Ensure that the watchpoint is disabled when we startup.
- if [gdb_test "disable 3" "^disable 3\[\r\n\]+" "disable watchpoint in test_disabling_watchpoints" ] {
+ if [gdb_test_no_output "disable 3" \
+ "disable watchpoint in test_disabling_watchpoints" ] {
return 0
}
@@ -234,7 +236,7 @@ proc test_disabling_watchpoints {} {
# After reaching the marker function, enable the watchpoint.
- if [gdb_test "enable 3" "^enable 3\[\r\n\]+" "watchpoint enabled" ] {
+ if [gdb_test_no_output "enable 3" "watchpoint enabled" ] {
return
}
@@ -249,7 +251,8 @@ proc test_disabling_watchpoints {} {
# Disable the watchpoint but leave breakpoints
- if [gdb_test "disable 3" "^disable 3\[\r\n\]+" "disable watchpoint #2 in test_disabling_watchpoints" ] {
+ if [gdb_test_no_output "disable 3" \
+ "disable watchpoint #2 in test_disabling_watchpoints" ] {
return 0
}
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 8b85618abcd..626841a4f0a 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -1520,6 +1520,11 @@ if { [tcl_version_at_least 8 5] == 0 } {
#
# See gdb_test for a description of the -prompt, -no-prompt-anchor, -nopass,
# COMMAND, and MESSAGE parameters.
+#
+# Returns:
+# 1 if the test failed,
+# 0 if the test passes,
+# -1 if there was an internal error.
proc gdb_test_no_output { args } {
global gdb_prompt
@@ -1535,13 +1540,13 @@ proc gdb_test_no_output { args } {
set prompt [fill_in_default_prompt $prompt [expr !${no-prompt-anchor}]]
set command_regex [string_to_regexp $command]
- gdb_test_multiple $command $message -prompt $prompt {
+ return [gdb_test_multiple $command $message -prompt $prompt {
-re "^$command_regex\r\n$prompt" {
if {!$nopass} {
pass $gdb_test_name
}
}
- }
+ }]
}
# Send a command and then wait for a sequence of outputs.
--
2.25.4
next prev parent reply other threads:[~2023-03-31 20:21 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-31 20:20 [PATCH 0/5] gdb/testsuite: stricter matching for gdb_test Andrew Burgess
2023-03-31 20:20 ` [PATCH 1/5] gdb/testsuite: fix occasional failure in gdb.base/clear_non_user_bp.exp Andrew Burgess
2023-03-31 20:20 ` [PATCH 2/5] gdb: remove some trailing newlines from warning messages Andrew Burgess
2023-03-31 20:20 ` Andrew Burgess [this message]
2023-03-31 20:20 ` [PATCH 4/5] gdb/testsuite: change newline patterns used in gdb_test Andrew Burgess
2023-04-27 19:39 ` Simon Marchi
2023-04-28 14:05 ` Andrew Burgess
2023-04-28 15:51 ` Andrew Burgess
2023-04-28 15:57 ` Simon Marchi
2023-04-28 18:37 ` Simon Marchi
2023-04-28 21:50 ` Andrew Burgess
2023-05-02 19:16 ` Simon Marchi
2023-04-29 15:20 ` Tom de Vries
2023-05-01 14:33 ` Andrew Burgess
2023-05-01 15:10 ` Tom de Vries
2023-05-02 11:13 ` Andrew Burgess
2023-05-02 14:48 ` Tom de Vries
2023-05-05 17:01 ` Andrew Burgess
2023-05-09 9:54 ` Andrew Burgess
2023-05-10 7:22 ` Tom de Vries
2023-05-12 12:54 ` Andrew Burgess
2023-03-31 20:20 ` [PATCH 5/5] gdb/testsuite: special case '^' in gdb_test pattern Andrew Burgess
2023-04-17 16:12 ` [PATCH 0/5] gdb/testsuite: stricter matching for gdb_test Tom Tromey
2023-04-27 12:58 ` Andrew Burgess
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=f054db3b245b11f2f3a386a271a001b687b881e0.1680293848.git.aburgess@redhat.com \
--to=aburgess@redhat.com \
--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).