continue-all-already-running.exp revision 1.7
1# Copyright (C) 2014-2020 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# Test that "c -a" doesn't leave GDB processing input, even if all
17# threads were already running.  PR gdb/17300.
18
19standard_testfile
20
21if { [prepare_for_testing "failed to prepare" ${testfile} $srcfile] } {
22    return -1
23}
24
25gdb_test_no_output "set non-stop on"
26
27if ![runto_main] {
28    return
29}
30
31set linenum [gdb_get_line_number "set break here"]
32gdb_breakpoint "$linenum"
33
34gdb_test "c -a&" "Continuing\\."
35
36set test "no stop"
37gdb_test_multiple "" $test {
38    -timeout 1
39    timeout {
40	pass $test
41    }
42}
43
44# Paranoia.  Check that input works after bg command.
45gdb_test "print 1" " = 1"
46
47# Continue in the foreground, and wait one second to make sure the
48# inferior really starts running.  If we get a prompt to soon (e.g.,
49# the program stops), this issues a fail.
50set saw_continuing 0
51set test "c -a"
52gdb_test_multiple "c -a" $test {
53    -timeout 1
54    -re "Continuing\\." {
55	set saw_continuing 1
56	exp_continue
57    }
58    timeout {
59	gdb_assert $saw_continuing $test
60    }
61}
62
63# Type something while the inferior is running in the foreground.
64send_gdb "print 2\n"
65
66# Poor buggy GDB would crash before the breakpoint was hit.
67set test "breakpoint hit"
68gdb_test_multiple "" $test {
69    -re "set break here ..\r\n$gdb_prompt " {
70	pass $test
71    }
72}
73
74set test "print command result"
75gdb_test_multiple "" $test {
76    -re " = 2\r\n$gdb_prompt $" {
77	pass $test
78    }
79}
80