binutils-gdb/gdb/testsuite/gdb.base/fork-print-inferior-events.exp
Joel Brobecker 42a4f53d2b Update copyright year range in all GDB files.
This commit applies all changes made after running the gdb/copyright.py
script.

Note that one file was flagged by the script, due to an invalid
copyright header
(gdb/unittests/basic_string_view/element_access/char/empty.cc).
As the file was copied from GCC's libstdc++-v3 testsuite, this commit
leaves this file untouched for the time being; a patch to fix the header
was sent to gcc-patches first.

gdb/ChangeLog:

	Update copyright year range in all GDB files.
2019-01-01 10:01:51 +04:00

86 lines
3.4 KiB
Plaintext

# This testcase is part of GDB, the GNU debugger.
# Copyright 2007-2019 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Test that the event messages printed when using 'set print
# inferior-events [on,off]', 'set follow-fork-mode [child,parent]' and
# 'set detach-on-fork [on,off]' are the correct ones.
# This test relies on "run", so it cannot run on target remote stubs.
if { [use_gdb_stub] } {
untested "not supported on target remote stubs"
return
}
standard_testfile
if { [prepare_for_testing "failed to prepare" $testfile $srcfile debug] } {
return -1
}
# This is the expected output for each of the test combinations
# below. The order here is important:
#
# inferior-events: on; follow-fork: child; detach-on-fork: on
# inferior-events: on; follow-fork: child; detach-on-fork: off
# inferior-events: on; follow-fork: parent; detach-on-fork: on
# inferior-events: on; follow-fork: parent; detach-on-fork: off
# inferior-events: off; follow-fork: child; detach-on-fork: on
# inferior-events: off; follow-fork: child; detach-on-fork: off
# inferior-events: off; follow-fork: parent; detach-on-fork: on
# inferior-events: off; follow-fork: parent; detach-on-fork: off
set reading_re "(Reading.*from remote target\\.\\.\\.\r\n)*"
set exited_normally_re "${reading_re}\\\[Inferior $decimal \\(.*\\) exited normally\\\]"
# gdbserver produces a slightly different message when attaching after
# a fork, so we have to tweak the regexp to accomodate that.
set attach_child_re "${reading_re}\\\[Attaching after .* fork to child .*\\\]\r\n"
set detach_child_re "${reading_re}\\\[Detaching after fork from child .*\\\]\r\n"
set detach_parent_re "${reading_re}\\\[Detaching after fork from parent .*\\\]\r\n"
set new_inf_re "${reading_re}\\\[New inferior $decimal \\(.*\\)\\\]\r\n"
set inf_detached_re "${reading_re}\\\[Inferior $decimal \\(.*\\) detached\\\]\r\n"
set expected_output [list \
"${attach_child_re}${new_inf_re}${detach_parent_re}${inf_detached_re}" \
"${attach_child_re}${new_inf_re}" \
"${detach_child_re}" \
"${new_inf_re}" \
"" \
"" \
"" \
"" \
]
set i 0
foreach_with_prefix print_inferior_events { "on" "off" } {
foreach_with_prefix follow_fork_mode { "child" "parent" } {
foreach_with_prefix detach_on_fork { "on" "off" } {
clean_restart $binfile
gdb_test_no_output "set print inferior-events $print_inferior_events"
gdb_test_no_output "set follow-fork-mode $follow_fork_mode"
gdb_test_no_output "set detach-on-fork $detach_on_fork"
set output [lindex $expected_output $i]
# Always add the "Starting program..." string so that we
# match exactly the lines we want.
set output "Starting program: $binfile\\s*\r\n${output}${exited_normally_re}"
set i [expr $i + 1]
gdb_test "run" $output
}
}
}