]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/kill-detach-inferiors-cmd.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / kill-detach-inferiors-cmd.exp
CommitLineData
e3ae3c43
PP
1# This testcase is part of GDB, the GNU debugger.
2#
1d506c26 3# Copyright 2015-2024 Free Software Foundation, Inc.
e3ae3c43
PP
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# Test the basic operation of the "kill inferiors" and "detach inferiors"
19# commands.
20
06e93b05 21require can_spawn_for_attach
e3ae3c43
PP
22
23standard_testfile
24set executable $testfile
25
5b362f04 26if [prepare_for_testing "failed to prepare" $executable] {
e3ae3c43
PP
27 return -1
28}
29
30runto_main
31
32# Add another forked inferior process.
121b3efd 33gdb_test "add-inferior" "Added inferior 2 on connection .*" "add inferior 2"
e3ae3c43 34gdb_test "inferior 2" "Switching to inferior 2.*"
3453e7e4 35gdb_test "file $binfile" "Reading symbols from .*" "load binary"
e3ae3c43
PP
36gdb_test "start" "Temporary breakpoint.*Starting program.*"
37
38# Add an attached inferior process.
39set test_spawn_id [spawn_wait_for_attach $binfile]
40set test_pid [spawn_id_get_pid $test_spawn_id]
121b3efd 41gdb_test "add-inferior" "Added inferior 3 on connection .*" "add inferior 3"
e3ae3c43
PP
42gdb_test "inferior 3" "Switching to inferior 3.*"
43gdb_test "attach $test_pid" "Attaching to process.*" "attach to pid"
44
45# Kill the first two inferiors, and detach the third.
46gdb_test_no_output "kill inferiors 1 2"
cfaa8f76 47gdb_test "info inferiors 3" "\r\n\\* 3 \[^\r\n\]+" "inf 3 is still current"
e3ae3c43
PP
48gdb_test "inferior 1" "Switching to inferior 1.*"
49gdb_test "kill" "The program is not being run.*"
50gdb_test "detach inferiors 3" "Detaching from program.*process $test_pid.*"
cfaa8f76 51gdb_test "info inferiors 1" "\r\n\\* 1 \[^\r\n\]+" "inf 1 is still current"
e3ae3c43
PP
52
53# No inferiors should be running anymore.
54gdb_test "kill inferiors 1 2 3" \
55 "ID 1 is not running.*ID 2 is not running.*ID 3 is not running.*"
56gdb_test "detach inferiors 1 2 3" \
57 "ID 1 is not running.*ID 2 is not running.*ID 3 is not running.*"
58
59gdb_test "kill inferiors 10" \
60 "ID 10 not known.*"
61
62kill_wait_spawned_process $test_spawn_id