Match shell_prompt # in batch-preserve-term-settings.exp

Message ID 1462877837-31075-1-git-send-email-yao.qi@linaro.org
State New, archived
Headers

Commit Message

Yao Qi May 10, 2016, 10:57 a.m. UTC
  batch-preserve-term-settings.exp fails if the shell prompt isn't $.  It
is # in our testing env.  In fact, the shell prompt can be anything.

The perfect solution would be "set_board_info shell_prompt" in the
host board file, and use board_info shell_prompt in
batch-preserve-term-settings.exp.  This is a little bit overkill to
me, and we still need to figure out the different prompts on different
shells.  I also tried to start shell with the prompt preset, but there is
not unique way to set shell prompt in different shells, so I give up.

It is reasonably simple to match either $ or # for the shell prompt, and
we can easily extend it to match other char, like >.

gdb/testsuite:

2016-05-10  Yao Qi  <yao.qi@linaro.org>

	* gdb.base/batch-preserve-term-settings.exp: Remove variable
	shell_prompt.  Update shell_prompt_re.
---
 gdb/testsuite/gdb.base/batch-preserve-term-settings.exp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
  

Comments

Andreas Schwab May 10, 2016, 11:25 a.m. UTC | #1
Yao Qi <qiyaoltc@gmail.com> writes:

> diff --git a/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp b/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp
> index c925e88..f54a608 100644
> --- a/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp
> +++ b/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp
> @@ -28,8 +28,7 @@ if [is_remote host] {
>  }
>  
>  # The shell's prompt.
> -set shell_prompt "$ "
> -set shell_prompt_re [string_to_regexp $shell_prompt]
> +set shell_prompt_re "\[$|#\] "

Did you intent to match "|" too?

Andreas.
  
Pedro Alves May 18, 2016, 11:27 a.m. UTC | #2
On 05/10/2016 11:57 AM, Yao Qi wrote:
> batch-preserve-term-settings.exp fails if the shell prompt isn't $.  It
> is # in our testing env.  In fact, the shell prompt can be anything.
> 
> The perfect solution would be "set_board_info shell_prompt" in the
> host board file, and use board_info shell_prompt in
> batch-preserve-term-settings.exp.  This is a little bit overkill to
> me, and we still need to figure out the different prompts on different
> shells.  I also tried to start shell with the prompt preset, but there is
> not unique way to set shell prompt in different shells, so I give up.

Yeah, I think that'd be overkill.  Anyone running tests with a custom
prompt can just not do that.

> It is reasonably simple to match either $ or # for the shell prompt, and
> we can easily extend it to match other char, like >.

Excepting "#" is reasonable, since it'll be the usual prompt if
you run the shell as root.

Thanks,
Pedro Alves
  

Patch

diff --git a/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp b/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp
index c925e88..f54a608 100644
--- a/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp
+++ b/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp
@@ -28,8 +28,7 @@  if [is_remote host] {
 }
 
 # The shell's prompt.
-set shell_prompt "$ "
-set shell_prompt_re [string_to_regexp $shell_prompt]
+set shell_prompt_re "\[$|#\] "
 
 # Spawn shell.  Returns true on success, false otherwise.