From: Simon Marchi <simon.marchi@ericsson.com>
To: <gdb-patches@sourceware.org>
Cc: Simon Marchi <simon.marchi@ericsson.com>
Subject: [PATCH 3/3] Add tests for loop_break and loop_continue commands
Date: Sat, 02 Sep 2017 21:37:00 -0000 [thread overview]
Message-ID: <1504388179-579-4-git-send-email-simon.marchi@ericsson.com> (raw)
In-Reply-To: <1504388179-579-1-git-send-email-simon.marchi@ericsson.com>
I grepped the testsuite for loop_break and loop_continue and didn't find
anything, so I wrote some simple tests for those.
gdb/testsuite/ChangeLog:
* gdb.base/commands.exp: Call the new procedures.
(loop_break_test, loop_continue_test): New procedures.
---
gdb/testsuite/gdb.base/commands.exp | 43 +++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/gdb/testsuite/gdb.base/commands.exp b/gdb/testsuite/gdb.base/commands.exp
index 677361a..49a9242 100644
--- a/gdb/testsuite/gdb.base/commands.exp
+++ b/gdb/testsuite/gdb.base/commands.exp
@@ -1026,6 +1026,47 @@ proc define_if_without_arg_test {} {
}
}
+# Test the loop_break command.
+
+proc_with_prefix loop_break_test {} {
+ gdb_test_no_output "set \$a = 0" "initialize \$a"
+
+ gdb_test \
+ [multi_line_input \
+ "while \$a < 5" \
+ " if \$a == 3" \
+ " loop_break" \
+ " end" \
+ " set \$a = \$a + 1" \
+ "end"] \
+ "" \
+ "run while loop"
+
+ gdb_test "print \$a" " = 3" "validate \$a"
+}
+
+# Test the loop_continue command.
+
+proc_with_prefix loop_continue_test {} {
+ gdb_test_no_output "set \$a = 0" "initialize \$a"
+ gdb_test_no_output "set \$b = 0" "initialize \$b"
+
+ gdb_test \
+ [multi_line_input \
+ "while \$a < 5" \
+ " set \$a = \$a + 1" \
+ " if \$a % 2 == 0" \
+ " loop_continue" \
+ " end" \
+ " set \$b = \$b + 1" \
+ "end"] \
+ "" \
+ "run while loop"
+
+ gdb_test "print \$a" " = 5" "validate \$a"
+ gdb_test "print \$b" " = 3" "validate \$b"
+}
+
# Test an input line split with a continuation character (backslash)
# while entering a multi-line command (in a secondary prompt).
@@ -1092,5 +1133,7 @@ error_clears_commands_left
redefine_hook_test
backslash_in_multi_line_command_test
define_if_without_arg_test
+loop_break_test
+loop_continue_test
# This one should come last, as it redefines "backtrace".
redefine_backtrace_test
--
2.7.4
next prev parent reply other threads:[~2017-09-02 21:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-02 21:36 [PATCH 0/3] Tiny patches related to command lines Simon Marchi
2017-09-02 21:37 ` [PATCH 2/3] Error out immediatly when using if command without args in command list Simon Marchi
2017-09-04 12:35 ` Pedro Alves
2017-09-04 17:15 ` Simon Marchi
2017-09-02 21:37 ` [PATCH 1/3] Move command lines types/declarations to cli-script.h Simon Marchi
2017-09-04 12:28 ` Pedro Alves
2017-09-02 21:37 ` Simon Marchi [this message]
2017-09-04 12:36 ` [PATCH 3/3] Add tests for loop_break and loop_continue commands Pedro Alves
2017-09-04 17:16 ` Simon Marchi
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=1504388179-579-4-git-send-email-simon.marchi@ericsson.com \
--to=simon.marchi@ericsson.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