public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH][gdb/testsuite] Handle shell prompt in batch-preserve-term-settings.exp
@ 2020-12-14  6:53 Tom de Vries
  2020-12-14 15:42 ` Tom Tromey
  2020-12-15 15:21 ` Luis Machado
  0 siblings, 2 replies; 5+ messages in thread
From: Tom de Vries @ 2020-12-14  6:53 UTC (permalink / raw)
  To: gdb-patches

Hi,

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.

Any comments?

Thanks,
- Tom

[gdb/testsuite] Handle shell prompt in batch-preserve-term-settings.exp

gdb/testsuite/ChangeLog:

2020-12-14  Tom de Vries  <tdevries@suse.de>

	PR testsuite/26951
	* gdb.base/batch-preserve-term-settings.exp: Use "gdb-subshell$ " as
	shell prompt.

---
 gdb/testsuite/gdb.base/batch-preserve-term-settings.exp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp b/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp
index 7ae3518beb..c39d638aeb 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
 	}

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH][gdb/testsuite] Handle shell prompt in batch-preserve-term-settings.exp
  2020-12-14  6:53 [PATCH][gdb/testsuite] Handle shell prompt in batch-preserve-term-settings.exp Tom de Vries
@ 2020-12-14 15:42 ` Tom Tromey
  2020-12-15 15:21 ` Luis Machado
  1 sibling, 0 replies; 5+ messages in thread
From: Tom Tromey @ 2020-12-14 15:42 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches

>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:

Tom> Fix this instead by setting the shell prompt to "gdb-subshell$ " (as in
Tom> gdb.base/multi-line-starts-subshell.exp).

Tom> Tested on x86_64-linux.

Tom> Any comments?

Looks good to me.  Thank you.

Tom

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH][gdb/testsuite] Handle shell prompt in batch-preserve-term-settings.exp
  2020-12-14  6:53 [PATCH][gdb/testsuite] Handle shell prompt in batch-preserve-term-settings.exp Tom de Vries
  2020-12-14 15:42 ` Tom Tromey
@ 2020-12-15 15:21 ` Luis Machado
  2020-12-15 15:21   ` Luis Machado
  2020-12-16 20:34   ` Tom de Vries
  1 sibling, 2 replies; 5+ messages in thread
From: Luis Machado @ 2020-12-15 15:21 UTC (permalink / raw)
  To: Tom de Vries, gdb-patches

Ubuntu 18.04 on aarch64 isn't happy about this change.

I'm getting a number of timeouts now.

FAIL: gdb.base/batch-preserve-term-settings.exp: batch run: spawn shell 
(timeout)
FAIL: gdb.base/batch-preserve-term-settings.exp: cli exit: spawn shell 
(timeout)
FAIL: gdb.base/batch-preserve-term-settings.exp: cli exit after start 
cmd: spawn shell (timeout)
FAIL: gdb.base/batch-preserve-term-settings.exp: cli exit after run cmd: 
spawn shell (timeout)
FAIL: gdb.base/batch-preserve-term-settings.exp: cli exit after SIGTERM: 
spawn shell (timeout)

All look like this:

spawn /bin/sh^M
$ gdb-subshell$


On 12/14/20 3:53 AM, Tom de Vries wrote:
> Hi,
> 
> 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.
> 
> Any comments?
> 
> Thanks,
> - Tom
> 
> [gdb/testsuite] Handle shell prompt in batch-preserve-term-settings.exp
> 
> gdb/testsuite/ChangeLog:
> 
> 2020-12-14  Tom de Vries  <tdevries@suse.de>
> 
> 	PR testsuite/26951
> 	* gdb.base/batch-preserve-term-settings.exp: Use "gdb-subshell$ " as
> 	shell prompt.
> 
> ---
>   gdb/testsuite/gdb.base/batch-preserve-term-settings.exp | 9 ++++++---
>   1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp b/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp
> index 7ae3518beb..c39d638aeb 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
>   	}
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH][gdb/testsuite] Handle shell prompt in batch-preserve-term-settings.exp
  2020-12-15 15:21 ` Luis Machado
@ 2020-12-15 15:21   ` Luis Machado
  2020-12-16 20:34   ` Tom de Vries
  1 sibling, 0 replies; 5+ messages in thread
From: Luis Machado @ 2020-12-15 15:21 UTC (permalink / raw)
  To: Tom de Vries, gdb-patches

It also times out on Ubuntu 20.04.

On 12/15/20 12:21 PM, Luis Machado wrote:
> Ubuntu 18.04 on aarch64 isn't happy about this change.
> 
> I'm getting a number of timeouts now.
> 
> FAIL: gdb.base/batch-preserve-term-settings.exp: batch run: spawn shell 
> (timeout)
> FAIL: gdb.base/batch-preserve-term-settings.exp: cli exit: spawn shell 
> (timeout)
> FAIL: gdb.base/batch-preserve-term-settings.exp: cli exit after start 
> cmd: spawn shell (timeout)
> FAIL: gdb.base/batch-preserve-term-settings.exp: cli exit after run cmd: 
> spawn shell (timeout)
> FAIL: gdb.base/batch-preserve-term-settings.exp: cli exit after SIGTERM: 
> spawn shell (timeout)
> 
> All look like this:
> 
> spawn /bin/sh^M
> $ gdb-subshell$
> 
> 
> On 12/14/20 3:53 AM, Tom de Vries wrote:
>> Hi,
>>
>> 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.
>>
>> Any comments?
>>
>> Thanks,
>> - Tom
>>
>> [gdb/testsuite] Handle shell prompt in batch-preserve-term-settings.exp
>>
>> gdb/testsuite/ChangeLog:
>>
>> 2020-12-14  Tom de Vries  <tdevries@suse.de>
>>
>>     PR testsuite/26951
>>     * gdb.base/batch-preserve-term-settings.exp: Use "gdb-subshell$ " as
>>     shell prompt.
>>
>> ---
>>   gdb/testsuite/gdb.base/batch-preserve-term-settings.exp | 9 ++++++---
>>   1 file changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp 
>> b/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp
>> index 7ae3518beb..c39d638aeb 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
>>       }
>>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH][gdb/testsuite] Handle shell prompt in batch-preserve-term-settings.exp
  2020-12-15 15:21 ` Luis Machado
  2020-12-15 15:21   ` Luis Machado
@ 2020-12-16 20:34   ` Tom de Vries
  1 sibling, 0 replies; 5+ messages in thread
From: Tom de Vries @ 2020-12-16 20:34 UTC (permalink / raw)
  To: Luis Machado, gdb-patches

[-- Attachment #1: Type: text/plain, Size: 792 bytes --]

On 12/15/20 4:21 PM, Luis Machado wrote:
> Ubuntu 18.04 on aarch64 isn't happy about this change.
> 
> I'm getting a number of timeouts now.
> 
> FAIL: gdb.base/batch-preserve-term-settings.exp: batch run: spawn shell
> (timeout)

I could reproduce this on Ubuntu 18.04 x86_64 as well.

> FAIL: gdb.base/batch-preserve-term-settings.exp: cli exit: spawn shell
> (timeout)
> FAIL: gdb.base/batch-preserve-term-settings.exp: cli exit after start
> cmd: spawn shell (timeout)
> FAIL: gdb.base/batch-preserve-term-settings.exp: cli exit after run cmd:
> spawn shell (timeout)
> FAIL: gdb.base/batch-preserve-term-settings.exp: cli exit after SIGTERM:
> spawn shell (timeout)
> 
> All look like this:
> 
> spawn /bin/sh^M
> $ gdb-subshell$
> 
> 

Fixed in patch below, committed.

Thanks,
- Tom



[-- Attachment #2: 0001-gdb-testsuite-Fix-prompt-regexp-in-batch-preserve-term-settings.exp.patch --]
[-- Type: text/x-patch, Size: 1374 bytes --]

[gdb/testsuite] Fix prompt regexp in batch-preserve-term-settings.exp

On openSUSE Leap 15.2, when running test-case
gdb.base/batch-preserve-term-settings.exp I get:
...
spawn /bin/sh^M
PS1="gdb-subshell$ "^M
sh-4.4$ PS1="gdb-subshell$ "^M
gdb-subshell$ PASS: gdb.base/batch-preserve-term-settings.exp: batch run: \
  spawn shell
...
but on Ubuntu 18.04.5, I get instead:
...
spawn /bin/sh^M
PS1="gdb-subshell$ "^M
$ gdb-subshell$ FAIL: gdb.base/batch-preserve-term-settings.exp: batch run: \
  spawn shell (timeout)
...

Fix this by making the regexp recognize the second pattern as well.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-12-16  Tom de Vries  <tdevries@suse.de>

	* gdb.base/batch-preserve-term-settings.exp:

---
 gdb/testsuite/gdb.base/batch-preserve-term-settings.exp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp b/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp
index c39d638aeb..3e35d20dd7 100644
--- a/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp
+++ b/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp
@@ -47,7 +47,7 @@ proc spawn_shell {} {
     set gotit 0
     set test "spawn shell"
     gdb_expect {
-	-re "PS1=\[^\r\n\]*\r\n$shell_prompt_re$" {
+	-re "PS1=\[^\r\n\]*\r\n.*$shell_prompt_re$" {
 	    pass $test
 	    set gotit 1
 	}

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-12-16 20:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-14  6:53 [PATCH][gdb/testsuite] Handle shell prompt in batch-preserve-term-settings.exp Tom de Vries
2020-12-14 15:42 ` Tom Tromey
2020-12-15 15:21 ` Luis Machado
2020-12-15 15:21   ` Luis Machado
2020-12-16 20:34   ` Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).