xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.multi/remove-inferiors.exp (revision 4c3eb207d36f67d31994830c0a694161fc1ca39b)
1# Copyright 2016-2019 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
16standard_testfile
17
18if { [build_executable ${testfile}.exp ${binfile} "${srcfile}" {debug}] != 0 } {
19    return -1
20}
21
22proc switch_to_inferior { num message } {
23    gdb_test "inferior ${num}" \
24	     "\\\[Switching to inferior ${num} \\\[<null>\\\] \\\(<noexec>\\\)\\\]" \
25	     "${message}"
26}
27
28proc add_inferior { expected_num message } {
29    gdb_test "add-inferior" "Added inferior ${expected_num}" "${message}"
30}
31
32proc test_remove_inferiors { } {
33    global binfile
34
35    clean_restart ${binfile}
36
37    # Add another inferior and switch to it.
38    add_inferior 2 "add second inferior"
39    switch_to_inferior 2 "switch to second inferior"
40
41    # Test that it is not possible to remove the current inferior.
42    gdb_test "remove-inferiors 2" \
43	     "warning: Can not remove current inferior 2." \
44	     "can't remove current inferior"
45
46    # Test that it is possible to remove a non-active non-current inferior.
47    gdb_test_no_output "remove-inferiors 1" "remove non-current inferior"
48
49    # Load binfile and start the inferior.
50    set binfile_re [string_to_regexp ${binfile}]
51    gdb_test "file ${binfile}" \
52	     "Reading symbols from ${binfile_re}..." \
53	     "load binary"
54
55    if {![runto_main]} {
56	fail "couldn't run to main."
57	return
58    }
59
60    # Add another inferior and switch to it.
61    add_inferior 3 "add third inferior"
62    switch_to_inferior 3 "switch to third inferior"
63
64    # Test that it is not possible to remove an active non-current inferior.
65    gdb_test "remove-inferiors 2" \
66	     "warning: Can not remove active inferior 2." \
67	     "can't remove active inferior"
68}
69
70test_remove_inferiors
71