From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sourceware.org
Subject: [commit/testsuite] lib/gdb.exp: New gdb_test_no_output function.
Date: Thu, 20 May 2010 19:45:00 -0000 [thread overview]
Message-ID: <1274383407-3191-1-git-send-email-brobecker@adacore.com> (raw)
In-Reply-To: <4BF579B8.1040503@vmware.com>
This implements the suggestion provided by Pedro on how to test a command
which is expected to generate no output. I can now see why my own attempts
so far have failed: the output being matched by gdb_test_multiple actually
contains the command itself. This is something that I managed to never
actually notice :-/.
2010-05-20 Pedro Alves <pedro@codesourcery.com>
Joel Brobecker <brobecker@adacore.com>
* lib/gdb.exp (gdb_test_no_output): New function.
* lib/gdb.ada/arrayidx.exp: Use gdb_test_no_output instead of gdb_test
when testing commands that should produce no output.
Tested on x86_64-linux.
---
gdb/testsuite/ChangeLog | 7 +++++++
gdb/testsuite/gdb.ada/arrayidx.exp | 8 ++------
gdb/testsuite/lib/gdb.exp | 25 +++++++++++++++++++++++++
3 files changed, 34 insertions(+), 6 deletions(-)
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index b6f9469..93df121 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2010-05-20 Pedro Alves <pedro@codesourcery.com>
+ Joel Brobecker <brobecker@adacore.com>
+
+ * lib/gdb.exp (gdb_test_no_output): New function.
+ * lib/gdb.ada/arrayidx.exp: Use gdb_test_no_output instead of gdb_test
+ when testing commands that should produce no output.
+
2010-05-19 Michael Snyder <msnyder@vmware.com>
* gdb.base/whatis.exp: Replace send_gdb with gdb_test.
diff --git a/gdb/testsuite/gdb.ada/arrayidx.exp b/gdb/testsuite/gdb.ada/arrayidx.exp
index 13be845..3d45461 100644
--- a/gdb/testsuite/gdb.ada/arrayidx.exp
+++ b/gdb/testsuite/gdb.ada/arrayidx.exp
@@ -41,9 +41,7 @@ runto "p.adb:$bp_location"
# First, print all the arrays without indexes
-gdb_test "set print array-indexes off" \
- "" \
- "set print array-indexes to off"
+gdb_test_no_output "set print array-indexes off"
gdb_test "print one_two_three" \
"= \\(1, 2, 3\\)" \
@@ -79,9 +77,7 @@ gdb_test "print empty" \
# Next, print all the arrays with the indexes
-gdb_test "set print array-indexes on" \
- "" \
- "set print array-indexes to on"
+gdb_test_no_output "set print array-indexes on"
gdb_test "print one_two_three" \
"= \\(1 => 1, 2 => 2, 3 => 3\\)" \
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 70df5ea..563ffa7 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -877,6 +877,31 @@ proc gdb_test { args } {
}
}]
}
+
+# gdb_test_no_output 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.
+
+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
+ }
+
+ set command_regex [string_to_regexp $command]
+ gdb_test_multiple $command $message {
+ -re "^$command_regex\r\n$gdb_prompt $" {
+ pass $message
+ }
+ }
+}
+
\f
# Test that a command gives an error. For pass or fail, return
# a 1 to indicate that more tests can proceed. However a timeout
--
1.7.1
next prev parent reply other threads:[~2010-05-20 19:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-19 20:54 [rfa] gdb.base/volatile.exp / varargs.exp: replace send_gdb with gdb_test Michael Snyder
2010-05-20 16:13 ` Joel Brobecker
2010-05-20 16:31 ` Pedro Alves
2010-05-20 16:42 ` Joel Brobecker
2010-05-20 16:47 ` Pedro Alves
2010-05-20 17:09 ` Joel Brobecker
2010-05-20 17:57 ` Pedro Alves
2010-05-20 18:08 ` Michael Snyder
2010-05-20 19:45 ` Joel Brobecker [this message]
2010-05-20 18:04 ` Michael Snyder
2010-05-20 18:40 ` Joel Brobecker
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=1274383407-3191-1-git-send-email-brobecker@adacore.com \
--to=brobecker@adacore.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