From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 4/9] testsuite: Introduce gdb_assert
Date: Thu, 03 Jul 2014 15:27:00 -0000 [thread overview]
Message-ID: <1404400736-17307-5-git-send-email-palves@redhat.com> (raw)
In-Reply-To: <1404400736-17307-1-git-send-email-palves@redhat.com>
Often we'll do something like:
if {$ok} {
fail "whatever"
} else {
pass "whatever"
}
This adds a helper procedure for that, and converts one random place
to use it, as an example.
2014-07-02 Pedro Alves <palves@redhat.com>
* lib/gdb.exp (gdb_assert): New procedure.
* gdb.trace/backtrace.exp (gdb_backtrace_tdp_4): Use it.
---
gdb/testsuite/gdb.trace/backtrace.exp | 7 ++-----
gdb/testsuite/lib/gdb.exp | 21 +++++++++++++++++++++
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/gdb/testsuite/gdb.trace/backtrace.exp b/gdb/testsuite/gdb.trace/backtrace.exp
index a74fc3f..cb50f06 100644
--- a/gdb/testsuite/gdb.trace/backtrace.exp
+++ b/gdb/testsuite/gdb.trace/backtrace.exp
@@ -256,11 +256,8 @@ proc gdb_backtrace_tdp_4 { msg depth traceframe } {
# Output of 'tdump' on frame 0 and frame 1 should be
# identical.
- if ![string compare $output_string0 $output_string1] {
- pass "tdump output"
- } else {
- fail "tdump output"
- }
+ gdb_assert ![string compare $output_string0 $output_string1] \
+ "tdump output"
}
}
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 30463a9..36cbf05 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -1204,6 +1204,27 @@ proc gdb_test_list_exact { cmd name elm_find_regexp elm_extract_regexp result_ma
}
}
\f
+
+# Issue a PASS and return true if evaluating CONDITION in the caller's
+# frame returns true, and issue a FAIL and return false otherwise.
+# MESSAGE is the pass/fail message to be printed. If MESSAGE is
+# omitted or is empty, then the pass/fail messages use the condition
+# string as the message.
+
+proc gdb_assert { condition {message ""} } {
+ if { $message == ""} {
+ set message $condition
+ }
+
+ set res [uplevel 1 expr $condition]
+ if {!$res} {
+ fail $message
+ } else {
+ pass $message
+ }
+ return $res
+}
+
proc gdb_reinitialize_dir { subdir } {
global gdb_prompt
--
1.9.3
next prev parent reply other threads:[~2014-07-03 15:27 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-03 15:19 [RESEND/PROPER PATCH 0/9] pagination/readline/async issues Pedro Alves
2014-07-03 15:19 ` [PATCH 8/9] Fix double prompt Pedro Alves
2014-07-03 15:19 ` [PATCH 5/9] Canceling pagination caused by execution command from command line aborts readline/gdb Pedro Alves
2014-07-04 6:11 ` Yao Qi
2014-07-09 16:45 ` Pedro Alves
2014-07-10 9:26 ` Yao Qi
2014-07-03 15:19 ` [PATCH 2/9] Eliminate exceptions.c:print_any_exception Pedro Alves
2014-07-03 20:38 ` Tom Tromey
2014-07-03 15:19 ` [PATCH 3/9] Move catch_command_errors and catch_command_errors_const to main.c Pedro Alves
2014-07-03 15:19 ` [PATCH 9/9] Put GDB's terminal settings into effect when paginating Pedro Alves
2014-07-03 15:19 ` [PATCH 6/9] Background execution + pagination aborts readline/gdb Pedro Alves
2014-09-13 0:05 ` Sergio Durigan Junior
2014-07-03 15:19 ` [PATCH 1/9] Put the inferior's terminal settings in effect while running (fg) infcalls Pedro Alves
2014-07-03 15:27 ` Pedro Alves [this message]
2014-07-03 20:41 ` [PATCH 4/9] testsuite: Introduce gdb_assert Tom Tromey
2014-07-03 15:31 ` [RESEND/PROPER PATCH 0/9] pagination/readline/async issues Pedro Alves
2014-07-14 22:38 ` Pedro Alves
2014-07-03 15:40 ` [PATCH 7/9] Remove the target from the event loop while in secondary prompts Pedro Alves
-- strict thread matches above, loose matches on Subject: below --
2014-07-03 15:13 [PATCH 0/9] pagination/readline/async issues Pedro Alves
2014-07-03 15:13 ` [PATCH 4/9] testsuite: Introduce gdb_assert Pedro Alves
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=1404400736-17307-5-git-send-email-palves@redhat.com \
--to=palves@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).