From: Tom de Vries Date: Mon, 14 Dec 2020 16:05:11 +0000 (+0100) Subject: [gdb/testsuite] Handle shell prompt in batch-preserve-term-settings.exp X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=153f6e6cb0266f8312ba85956b256ce1e3a2cb8e;p=binutils-gdb.git [gdb/testsuite] Handle shell prompt in batch-preserve-term-settings.exp On SLE-11, I run into: ... FAIL: gdb.base/batch-preserve-term-settings.exp: batch run: spawn shell \ (timeout) ... The problem is that the shell prompt has PS1="\h:\w> ", but the test expects a shell prompt ending in a space preceded by either '$' or '#': ... set shell_prompt_re "\[$#\] " ... We could easily fix this by adding '>' to shell_prompt_re, but this wouldn't work for other PS1 setting. Fix this instead by setting the shell prompt to "gdb-subshell$ " (as in gdb.base/multi-line-starts-subshell.exp). Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-12-14 Tom de Vries PR testsuite/26951 * gdb.base/batch-preserve-term-settings.exp: Use "gdb-subshell$ " as shell prompt. --- diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index d5442f9a1d8..4bd45211c7b 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2020-12-14 Tom de Vries + + PR testsuite/26951 + * gdb.base/batch-preserve-term-settings.exp: Use "gdb-subshell$ " as + shell prompt. + 2020-12-14 Tom Tromey * gdb.ada/nested.exp: Add new tests. diff --git a/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp b/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp index 7ae3518beba..c39d638aeb1 100644 --- a/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp +++ b/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp @@ -28,12 +28,13 @@ if [is_remote host] { } # The shell's prompt. -set shell_prompt_re "\[$#\] " +set shell_prompt_ps1 "gdb-subshell$ " +set shell_prompt_re [string_to_regexp $shell_prompt_ps1] # Spawn shell. Returns true on success, false otherwise. proc spawn_shell {} { - global shell_prompt_re + global shell_prompt_ps1 shell_prompt_re set res [remote_spawn host "/bin/sh"] if { $res < 0 || $res == "" } { @@ -41,10 +42,12 @@ proc spawn_shell {} { return 0 } + send_gdb "PS1=\"$shell_prompt_ps1\"\n" + set gotit 0 set test "spawn shell" gdb_expect { - -re "$shell_prompt_re$" { + -re "PS1=\[^\r\n\]*\r\n$shell_prompt_re$" { pass $test set gotit 1 }