diff options
author | Pedro Alves <palves@redhat.com> | 2014-07-14 19:55:31 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2014-07-14 20:30:41 +0100 |
commit | bd29394088b5685d336a501fadca88b25ed777bc (patch) | |
tree | 2b8d810c13fb9cc90d48ef9cea307033152e3739 /gdb/testsuite/lib/gdb.exp | |
parent | 9d1e69a21488cb5b8b7553c8df18ee5c3f4d82e3 (diff) | |
download | gdb-bd29394088b5685d336a501fadca88b25ed777bc.zip gdb-bd29394088b5685d336a501fadca88b25ed777bc.tar.gz gdb-bd29394088b5685d336a501fadca88b25ed777bc.tar.bz2 |
testsuite: Introduce gdb_assert
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-14 Pedro Alves <palves@redhat.com>
* lib/gdb.exp (gdb_assert): New procedure.
* gdb.trace/backtrace.exp (gdb_backtrace_tdp_4): Use it.
Diffstat (limited to 'gdb/testsuite/lib/gdb.exp')
-rw-r--r-- | gdb/testsuite/lib/gdb.exp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 3388e1f..50f2481 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -1205,6 +1205,27 @@ proc gdb_test_list_exact { cmd name elm_find_regexp elm_extract_regexp result_ma } } + +# 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 |