1 # Copyright
(C
) 2014-2019 Free Software Foundation
, Inc.
3 # This
program is free software
; you can redistribute it and
/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation
; either version
3 of the License
, or
6 #
(at your option
) any later version.
8 # This
program is distributed in the hope that it will be useful
,
9 # but WITHOUT
ANY WARRANTY
; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License
for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this
program.
If not
, see
<http
://www.gnu.org
/licenses
/>.
16 # A collection of tests related to running execution commands directly
17 # from the command line
, with
"-ex".
21 if {[build_executable
"failed to prepare" $testfile $srcfile debug] == -1} {
25 # Check that we handle pagination correctly when it triggers due to an
26 # background execution command entered directly
on the command line.
28 proc test_bg_execution_pagination_return
{} {
30 global pagination_prompt
32 with_test_prefix
"paginate" {
33 clean_restart $binfile
35 if ![runto_main
] then {
36 fail
"can't run to main"
40 gdb_test
"b after_sleep"
42 gdb_test_no_output
"set height 2"
44 gdb_test
"continue&" "Continuing\."
46 set test
"pagination handled, breakpoint hit"
47 set saw_pagination_prompt
0
48 gdb_test_multiple
"" $test {
49 -re
"$pagination_prompt$" {
50 set saw_pagination_prompt
1
54 -re
"after sleep\[^\r\n\]+\r\n$" {
55 gdb_assert $saw_pagination_prompt $test
59 # GDB used to crash here.
60 gdb_test
"p 1" " = 1" "GDB accepts further input"
62 # In case the board file wants to send further commands.
63 gdb_test_no_output
"set height unlimited"
67 # Check that we handle canceling pagination correctly when it triggers
68 # due to a background execution command entered directly
on the
71 proc test_bg_execution_pagination_cancel
{ how
} {
73 global gdb_prompt pagination_prompt
75 with_test_prefix
"cancel with $how" {
76 clean_restart $binfile
78 if ![runto_main
] then {
79 fail
"can't run to main"
83 gdb_test
"b after_sleep"
85 gdb_test_no_output
"set height 2"
87 gdb_test
"continue&" "Continuing\."
89 set test
"continue& paginates"
90 gdb_test_multiple
"" $test {
91 -re
"$pagination_prompt$" {
96 set test
"cancel pagination"
97 if { $how
== "ctrl-c" } {
103 gdb_test_multiple
"" $test {
104 -re
"Quit\r\n$gdb_prompt $" {
109 gdb_test
"p 1" " = 1" "GDB accepts further input"
111 # In case the board file wants to send further commands.
112 gdb_test_no_output
"set height unlimited"
116 test_bg_execution_pagination_return
117 if ![target_info
exists gdb
,nointerrupts
] {
118 test_bg_execution_pagination_cancel
"ctrl-c"
120 test_bg_execution_pagination_cancel
"quit"