]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.threads/kill.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.threads / kill.exp
1 # This testcase is part of GDB, the GNU debugger.
2
3 # Copyright 2014-2024 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]} {
42 return
43 }
44
45 set linenum [gdb_get_line_number "set break here"]
46 gdb_breakpoint "$srcfile:$linenum"
47 gdb_continue_to_breakpoint "break here" ".*break here.*"
48
49 if {$threaded} {
50 gdb_test "info threads" "1.*2.*3.*4.*5.*6.*" "all threads started"
51 }
52
53 # This kills and ensures no output other than the prompt comes out,
54 # like:
55 #
56 # (gdb) kill
57 # Kill the program being debugged? (y or n) y
58 # (gdb)
59 #
60 # If we instead saw more output, like e.g., with an extended-remote
61 # connection:
62 #
63 # (gdb) kill
64 # Kill the program being debugged? (y or n) y
65 # Remote connection closed
66 # (gdb)
67 #
68 # the above would mean that the remote end crashed.
69
70 gdb_test_multiple "kill" "kill" {
71 -re "Kill the program being debugged\\? \\(y or n\\) $" {
72 gdb_test "y" "\\\[Inferior $decimal \\(.*\\) killed\\\]" "kill"
73 }
74 }
75 }
76 }
77
78 foreach threaded {true false} {
79 test $threaded
80 }