summaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@ericsson.com>2017-09-04 19:15:59 +0200
committerSimon Marchi <simon.marchi@ericsson.com>2017-09-04 19:15:59 +0200
commit9521ecda6835b338d61b1b06e1a91706711b1d0b (patch)
tree8bec2c2cc543bcc055940bf3a1091f83c4383bd1 /gdb/testsuite
parent80a65e9b8fbc93d4a7548ac17b8094ced23f66a7 (diff)
downloadbinutils-gdb-9521ecda6835b338d61b1b06e1a91706711b1d0b.tar.gz
Add tests for loop_break and loop_continue commands
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.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.base/commands.exp43
2 files changed, 48 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index cfcb55657a6..8a6838b065b 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2017-09-04 Simon Marchi <simon.marchi@ericsson.com>
+ * gdb.base/commands.exp: Call the new procedures.
+ (loop_break_test, loop_continue_test): New procedures.
+
+2017-09-04 Simon Marchi <simon.marchi@ericsson.com>
+
* gdb.base/commands.exp: Call new procedure.
(define_if_without_arg_test): New procedure.
diff --git a/gdb/testsuite/gdb.base/commands.exp b/gdb/testsuite/gdb.base/commands.exp
index 677361acb3d..49a9242342c 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