]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/kill-detach-inferiors-cmd.exp
4696825609f4be2174ab8a4f928ddf12984b8f72
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / kill-detach-inferiors-cmd.exp
1 # This testcase is part of GDB, the GNU debugger.
2 #
3 # Copyright 2015-2016 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 # Test the basic operation of the "kill inferiors" and "detach inferiors"
19 # commands.
20
21 if ![can_spawn_for_attach] {
22 return 0
23 }
24
25 standard_testfile
26 set executable $testfile
27
28 if [prepare_for_testing "failed to prepare" $executable] {
29 return -1
30 }
31
32 runto_main
33
34 # Add another forked inferior process.
35 gdb_test "add-inferior" "Added inferior 2" "add inferior 2"
36 gdb_test "inferior 2" "Switching to inferior 2.*"
37 gdb_test "file $binfile" "Reading symbols from .*done.*" "load binary"
38 gdb_test "start" "Temporary breakpoint.*Starting program.*"
39
40 # Add an attached inferior process.
41 set test_spawn_id [spawn_wait_for_attach $binfile]
42 set test_pid [spawn_id_get_pid $test_spawn_id]
43 gdb_test "add-inferior" "Added inferior 3" "add inferior 3"
44 gdb_test "inferior 3" "Switching to inferior 3.*"
45 gdb_test "attach $test_pid" "Attaching to process.*" "attach to pid"
46
47 # Kill the first two inferiors, and detach the third.
48 gdb_test_no_output "kill inferiors 1 2"
49 gdb_test "inferior 1" "Switching to inferior 1.*"
50 gdb_test "kill" "The program is not being run.*"
51 gdb_test "detach inferiors 3" "Detaching from program.*process $test_pid.*"
52
53 # No inferiors should be running anymore.
54 gdb_test "kill inferiors 1 2 3" \
55 "ID 1 is not running.*ID 2 is not running.*ID 3 is not running.*"
56 gdb_test "detach inferiors 1 2 3" \
57 "ID 1 is not running.*ID 2 is not running.*ID 3 is not running.*"
58
59 gdb_test "kill inferiors 10" \
60 "ID 10 not known.*"
61
62 kill_wait_spawned_process $test_spawn_id