c984d45e6be9df5ae875fbd85d2070b02dc11340
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.threads / kill.exp
1 # This testcase is part of GDB, the GNU debugger.
2
3 # Copyright 2014-2021 Free Software Foundation, Inc.
4
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18 standard_testfile
19
20 # Run the test proper. THREADED indicates whether to build a threaded
21 # program and spawn several threads before trying to kill the program.
22
23 proc test {threaded} {
24 global testfile srcfile decimal
25
26 with_test_prefix [expr ($threaded)?"threaded":"non-threaded"] {
27
28 set options {debug}
29 if {$threaded} {
30 lappend options "pthreads"
31 lappend options "additional_flags=-DUSE_THREADS"
32 set prog ${testfile}_threads
33 } else {
34 set prog ${testfile}_nothreads
35 }
36
37 if {[prepare_for_testing "failed to prepare" $prog $srcfile $options] == -1} {
38 return -1
39 }
40
41 if { ![runto_main] } then {
42 fail "run to main"
43 return
44 }
45
46 set linenum [gdb_get_line_number "set break here"]
47 gdb_breakpoint "$srcfile:$linenum"
48 gdb_continue_to_breakpoint "break here" ".*break here.*"
49
50 if {$threaded} {
51 gdb_test "info threads" "1.*2.*3.*4.*5.*6.*" "all threads started"
52 }
53
54 # This kills and ensures no output other than the prompt comes out,
55 # like:
56 #
57 # (gdb) kill
58 # Kill the program being debugged? (y or n) y
59 # (gdb)
60 #
61 # If we instead saw more output, like e.g., with an extended-remote
62 # connection:
63 #
64 # (gdb) kill
65 # Kill the program being debugged? (y or n) y
66 # Remote connection closed
67 # (gdb)
68 #
69 # the above would mean that the remote end crashed.
70
71 gdb_test_multiple "kill" "kill" {
72 -re "Kill the program being debugged\\? \\(y or n\\) $" {
73 gdb_test "y" "\\\[Inferior $decimal \\(.*\\) killed\\\]" "kill"
74 }
75 }
76 }
77 }
78
79 foreach threaded {true false} {
80 test $threaded
81 }
This page took 0.034806 seconds and 3 git commands to generate.