Commit | Line | Data |
---|---|---|
0017922d PA |
1 | # Copyright (C) 2014 Free Software Foundation, Inc. |
2 | ||
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. | |
7 | # | |
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. | |
12 | # | |
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/>. | |
15 | ||
16 | # A collection of tests related to running execution commands directly | |
17 | # from the command line, with "-ex". | |
18 | ||
19 | standard_testfile | |
20 | ||
21 | if {[build_executable "failed to prepare" $testfile $srcfile debug] == -1} { | |
22 | return -1 | |
23 | } | |
24 | ||
25 | # Check that we handle pagination correctly when it triggers due to an | |
26 | # background execution command entered directly on the command line. | |
27 | ||
28 | proc test_bg_execution_pagination_return {} { | |
29 | global binfile | |
30 | global pagination_prompt | |
31 | ||
32 | with_test_prefix "paginate" { | |
33 | clean_restart $binfile | |
34 | ||
35 | if ![runto_main] then { | |
36 | fail "Can't run to main" | |
37 | return 0 | |
38 | } | |
39 | ||
40 | gdb_test "b after_sleep" | |
41 | ||
42 | gdb_test_no_output "set height 2" | |
43 | ||
44 | gdb_test "continue&" "Continuing\." | |
45 | ||
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 | |
51 | send_gdb "\n" | |
52 | exp_continue | |
53 | } | |
54 | -notransfer -re "<return>" { | |
55 | # Otherwise gdb_test_multiple considers this an | |
56 | # error. | |
57 | exp_continue | |
58 | } | |
59 | -re "after sleep\[^\r\n\]+\r\n$" { | |
60 | gdb_assert $saw_pagination_prompt $test | |
61 | } | |
62 | } | |
63 | ||
64 | # GDB used to crash here. | |
65 | gdb_test "p 1" " = 1" "GDB accepts further input" | |
66 | ||
67 | # In case the board file wants to send further commands. | |
68 | gdb_test_no_output "set height unlimited" | |
69 | } | |
70 | } | |
71 | ||
72 | # Check that we handle canceling pagination correctly when it triggers | |
73 | # due to a background execution command entered directly on the | |
74 | # command line. | |
75 | ||
76 | proc test_bg_execution_pagination_cancel { how } { | |
77 | global binfile | |
78 | global gdb_prompt pagination_prompt | |
79 | ||
80 | with_test_prefix "cancel with $how" { | |
81 | clean_restart $binfile | |
82 | ||
83 | if ![runto_main] then { | |
84 | fail "Can't run to main" | |
85 | return 0 | |
86 | } | |
87 | ||
88 | gdb_test "b after_sleep" | |
89 | ||
90 | gdb_test_no_output "set height 2" | |
91 | ||
92 | gdb_test "continue&" "Continuing\." | |
93 | ||
94 | set test "continue& paginates" | |
95 | gdb_test_multiple "" $test { | |
96 | -re "$pagination_prompt$" { | |
97 | pass $test | |
98 | } | |
99 | -notransfer -re "<return>" { | |
100 | # Otherwise gdb_test_multiple considers this an error. | |
101 | exp_continue | |
102 | } | |
103 | } | |
104 | ||
105 | set test "cancel pagination" | |
106 | if { $how == "ctrl-c" } { | |
107 | send_gdb "\003" | |
108 | } else { | |
109 | send_gdb "q\n" | |
110 | ||
111 | } | |
112 | gdb_test_multiple "" $test { | |
113 | -re "Quit\r\n$gdb_prompt $" { | |
114 | pass $test | |
115 | } | |
116 | } | |
117 | ||
118 | gdb_test "p 1" " = 1" "GDB accepts further input" | |
119 | ||
120 | # In case the board file wants to send further commands. | |
121 | gdb_test_no_output "set height unlimited" | |
122 | } | |
123 | } | |
124 | ||
125 | test_bg_execution_pagination_return | |
126 | test_bg_execution_pagination_cancel "ctrl-c" | |
127 | test_bg_execution_pagination_cancel "quit" |