multi-line-starts-subshell.exp revision 1.6
1# Copyright (C) 2014-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 16# Test spawning a subshell from a multi-line command, where the last 17# prompt displayed is a secondary prompt. GDB used to have a bug 18# where in this case the subshell would start with the wrong terminal 19# settings. See PR python/17372. 20 21gdb_exit 22gdb_start 23 24# The subshell's prompt. 25set shell_prompt "gdb-subshell$ " 26set shell_prompt_re [string_to_regexp $shell_prompt] 27 28# Point HOME nowhere to avoid the shell sourcing the user's init 29# scripts. 30set shell_cmd "HOME=/dev/null PS1=\"$shell_prompt\" /bin/sh" 31 32set test "spawn subshell from multi-line" 33gdb_test_multiple "if 1\nshell ${shell_cmd}\nend" $test { 34 -re "$shell_prompt_re$" { 35 pass $test 36 37 # Now check that shell input works and that echo is enabled. 38 set test "shell input works" 39 send_gdb "echo foo\n" 40 gdb_expect { 41 -re "^echo foo\r\nfoo\r\n$shell_prompt_re$" { 42 pass $test 43 } 44 timeout { 45 fail "$test (timeout)" 46 } 47 } 48 49 # Exit the subshell, back to GDB 50 gdb_test "exit" ".*" "exit shell" 51 } 52} 53 54# Check that we restore input in GDB correctly. 55gdb_test "print 1" "^print 1\r\n.. = 1" "gdb input still works" 56