paginate-after-ctrl-c-running.exp revision 1.3
1# Copyright (C) 2014-2015 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
16standard_testfile
17
18if {[build_executable "failed to prepare" $testfile $srcfile debug] == -1} {
19    return -1
20}
21
22# Send a ctrl-c while the target is running and the next output causes
23# a pagination prompt.
24
25proc test_ctrlc_while_target_running_paginates {} {
26    global binfile srcfile
27    global gdb_prompt pagination_prompt
28
29    set testline [gdb_get_line_number "after sleep"]
30
31    with_test_prefix "ctrlc target running" {
32	clean_restart $binfile
33
34	if ![runto_main] then {
35	    fail "Can't run to main"
36	    return 0
37	}
38
39	gdb_test "b $srcfile:$testline" \
40	    "Breakpoint .*$srcfile, line $testline.*" \
41	    "set breakpoint"
42
43	gdb_test_no_output "set height 2"
44
45	# Wait for the "Continuing" line, indicating the program is
46	# running.
47	set test "continue"
48	gdb_test_multiple $test $test {
49	    -re "Continuing" {
50		pass $test
51	    }
52	}
53
54	# The program sleeps 10 seconds.  Wait just a bit and send a
55	# ctrl-c.
56	sleep 2
57	send_gdb "\003"
58
59	# GDB now intercepts the SIGINT and tries to let the user know
60	# about the spurious signal, but that paginates.  Make sure
61	# the user can respond to the pagination query.
62	set test "got prompt"
63	set saw_pagination_prompt 0
64	gdb_test_multiple "" $test {
65	    -re "$pagination_prompt$" {
66		set saw_pagination_prompt 1
67		send_gdb "\n"
68		exp_continue
69	    }
70	    -re "$gdb_prompt $" {
71		gdb_assert $saw_pagination_prompt $test
72	    }
73	}
74
75	# Confirm GDB can still process input.
76	gdb_test "p 1" " = 1" "GDB accepts further input"
77
78	# In case the board file wants to send further commands.
79	gdb_test_no_output "set height unlimited"
80    }
81}
82
83test_ctrlc_while_target_running_paginates
84