1# Copyright 2016-2020 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}( on connection .*)?" "${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 [multi_line "Reading symbols from ${binfile_re}\.\.\.(" \ 53 "Expanding full symbols from ${binfile_re}\.\.\.)?" ] \ 54 "load binary" 55 56 if {![runto_main]} { 57 fail "couldn't run to main." 58 return 59 } 60 61 # Add another inferior and switch to it. 62 add_inferior 3 "add third inferior" 63 switch_to_inferior 3 "switch to third inferior" 64 65 # Test that it is not possible to remove an active non-current inferior. 66 gdb_test "remove-inferiors 2" \ 67 "warning: Can not remove active inferior 2." \ 68 "can't remove active inferior" 69} 70 71test_remove_inferiors 72