xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.base/async-shell.exp (revision c9055873d0546e63388f027d3d7f85381cde0545)
1# Copyright (C) 2011-2023 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 { ![support_displaced_stepping] } {
19    unsupported "displaced stepping"
20    return -1
21}
22
23# The testfile uses "run".  The real bug happened only for ![is_remote target].
24if [use_gdb_stub] {
25    return 0
26}
27
28save_vars { GDBFLAGS } {
29    set GDBFLAGS "$GDBFLAGS -ex \"set non-stop on\""
30    if { [prepare_for_testing "failed to prepare" ${testfile} $srcfile] } {
31	return -1
32    }
33}
34
35set gdbindex_warning_re "warning: Skipping \[^\r\n\]+ \\.gdb_index section \[^\r\n\]*\r\nDo \"set use-deprecated-index-sections on\" before the file is read\r\nto use the section anyway\\."
36
37gdb_test -no-prompt-anchor "run &" "Starting program: \[^\r\n\]*(\r\n$gdbindex_warning_re)?"
38
39# `sleep 5' here would workaround the bug, do not sleep here.
40# "shell" could eat waitpid event from the asynchronous inferior process.
41
42gdb_test "shell echo foo" "foo"
43
44set test "interrupt"
45gdb_test_multiple $test $test {
46    -re "interrupt\r\n$gdb_prompt " {
47	pass $test
48    }
49}
50
51set test "process stopped"
52gdb_test_multiple "" $test {
53    -re "Program stopped\\\.\r\n" {
54	pass $test
55    }
56}
57