Update copyright year range in header of all files managed by GDB
[binutils-gdb.git] / gdb / testsuite / gdb.base / sigwinch-notty.exp
blob99fb1c9a99ee09e3aa5a2b3cde6c339cfef7f484
1 # Copyright 2021-2023 Free Software Foundation, Inc.
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.
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.
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/>.
16 # Test that GDB does not crash when it is started without a terminal /
17 # without readline, and, it receives a SIGWINCH.  Regression test for
18 # PR gdb/26056.
20 if [target_info exists gdb,nosignals] {
21     verbose "Skipping $subdir/$gdb_test_file_name.exp because of nosignals."
22     return
25 # The testfile relies on "run" from the command line, so only works
26 # with "target native".
27 if { [target_info gdb_protocol] != "" } {
28     return
31 gdb_exit
33 # Start GDB without a terminal, running sleep for a while.  Before the
34 # sleep exits, we'll send a SIGWINCH.  "show editing" to double check
35 # that readline is disabled.
36 save_vars { GDB GDBFLAGS } {
37     set GDB "$srcdir/lib/notty-wrap $GDB"
38     set GDBFLAGS "$GDBFLAGS -ex \"show editing\" -ex run --args sleep 3"
40     gdb_spawn
43 set gdb_pid [exp_pid -i $gdb_spawn_id]
45 verbose -log "gdb_spawn_id=$gdb_spawn_id"
46 verbose -log "gdb_pid=$gdb_pid"
48 after 1000 {
49     # Note, GDB is started under a shell, so PID is actually the
50     # shell's pid, not GDB's.  Use "-PID" to send the signal to the
51     # whole process group and reach GDB, instead of just to the shell.
52     remote_exec host "kill -SIGWINCH -${gdb_pid}"
55 # If GDB mishandles the SIGWINCH and crashes, that happens before we
56 # see the "inferior exited normally" message, so this will ERROR with
57 # eof.
58 gdb_test_multiple "" "wait for sleep exit" {
59     -re "Editing of command lines as they are typed is off.*$inferior_exited_re normally.*$gdb_prompt " {
60         pass $gdb_test_name
61     }
64 gdb_test_multiple "" "wait for gdb exit" {
65     eof {
66         set wait_status [wait -i $gdb_spawn_id]
67         verbose -log "GDB process exited with wait status $wait_status"
68         pass $gdb_test_name
69     }