gdb/testsuite: fix race in gdb.server/multi-ui-errors.exp

Message ID 21d9b41b65c9215cc3fd387e20934ad174e57203.1684945721.git.aburgess@redhat.com
State New
Headers
Series gdb/testsuite: fix race in gdb.server/multi-ui-errors.exp |

Commit Message

Andrew Burgess May 24, 2023, 4:29 p.m. UTC
  After this commit:

  commit ed32754a8c7919feffc6ddb66ff1c532e4a4d1cd
  Date:   Thu Mar 9 10:45:03 2023 +0100

      [gdb/testsuite] Fix gdb.server/multi-ui-errors.exp for remote target

I noticed the occasional failure in gdb.server/multi-ui-errors.exp,
which looked like this:

  (gdb) PASS: gdb.server/multi-ui-errors.exp: interact with GDB's main UI
  interrupt
  (gdb)
  Program received signal SIGINT, Interrupt.
  0x00007ffff7d501e7 in nanosleep () from /lib64/libc.so.6
  FAIL: gdb.server/multi-ui-errors.exp: interrupt (timeout)
  PASS: gdb.server/multi-ui-errors.exp: interrupt arrived
  p server_pid
  $1 = 718174
  (gdb) PASS: gdb.server/multi-ui-errors.exp: p server_pid

This is triggered by this code in gdb.server/multi-ui-errors.exp:

    gdb_test "interrupt"

    gdb_test_multiple "" "interrupt arrived" {
	-re "Program received signal SIGINT, Interrupt\\.\r\n" {
	    pass $gdb_test_name
	}
    }

The problem here is that the first interrupt will trigger the prompt
to be printed, and then, after some time the inferior will be
interrupted.

However the default pattern for gdb_test includes a '$' end anchor.
If expect see the prompt with nothing following it then everything is
fine, and the test passes.

However, if the interrupt is quick and so what expect sees is this:

  (gdb)
  Program received signal SIGINT, Interrupt.
  0x00007ffff7d501e7 in nanosleep () from /lib64/libc.so.6

In this case the end anchor means that the gdb_test fails to match,
and eventually times out.

Fix this by passing -no-prompt-anchor to gdb_test.
---
 gdb/testsuite/gdb.server/multi-ui-errors.exp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


base-commit: 389971df23ca74092314dbde1303310a33766ba7
  

Comments

Tom de Vries May 24, 2023, 4:58 p.m. UTC | #1
On 5/24/23 18:29, Andrew Burgess wrote:
> After this commit:
> 
>    commit ed32754a8c7919feffc6ddb66ff1c532e4a4d1cd
>    Date:   Thu Mar 9 10:45:03 2023 +0100
> 
>        [gdb/testsuite] Fix gdb.server/multi-ui-errors.exp for remote target
> 
> I noticed the occasional failure in gdb.server/multi-ui-errors.exp,
> which looked like this:
> 
>    (gdb) PASS: gdb.server/multi-ui-errors.exp: interact with GDB's main UI
>    interrupt
>    (gdb)
>    Program received signal SIGINT, Interrupt.
>    0x00007ffff7d501e7 in nanosleep () from /lib64/libc.so.6
>    FAIL: gdb.server/multi-ui-errors.exp: interrupt (timeout)
>    PASS: gdb.server/multi-ui-errors.exp: interrupt arrived
>    p server_pid
>    $1 = 718174
>    (gdb) PASS: gdb.server/multi-ui-errors.exp: p server_pid
> 
> This is triggered by this code in gdb.server/multi-ui-errors.exp:
> 
>      gdb_test "interrupt"
> 
>      gdb_test_multiple "" "interrupt arrived" {
> 	-re "Program received signal SIGINT, Interrupt\\.\r\n" {
> 	    pass $gdb_test_name
> 	}
>      }
> 
> The problem here is that the first interrupt will trigger the prompt
> to be printed, and then, after some time the inferior will be
> interrupted.
> 
> However the default pattern for gdb_test includes a '$' end anchor.
> If expect see the prompt with nothing following it then everything is

Hi Andrew,

see -> sees

> fine, and the test passes.
> 
> However, if the interrupt is quick and so what expect sees is this:
> 
>    (gdb)
>    Program received signal SIGINT, Interrupt.
>    0x00007ffff7d501e7 in nanosleep () from /lib64/libc.so.6
> 
> In this case the end anchor means that the gdb_test fails to match,
> and eventually times out.
> 
> Fix this by passing -no-prompt-anchor to gdb_test.

thanks for fixing this.

LGTM.

Reviewed-by: Tom de Vries <tdevries@suse.de>

Thanks,
- Tom


> ---
>   gdb/testsuite/gdb.server/multi-ui-errors.exp | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gdb/testsuite/gdb.server/multi-ui-errors.exp b/gdb/testsuite/gdb.server/multi-ui-errors.exp
> index af83614fe55..47ded35bc86 100644
> --- a/gdb/testsuite/gdb.server/multi-ui-errors.exp
> +++ b/gdb/testsuite/gdb.server/multi-ui-errors.exp
> @@ -106,7 +106,7 @@ with_spawn_id $gdb_main_spawn_id {
>   # Get the gdbserver PID.
>   set gdbserver_pid 0
>   with_spawn_id $gdb_main_spawn_id {
> -    gdb_test "interrupt"
> +    gdb_test -no-prompt-anchor "interrupt"
>   
>       gdb_test_multiple "" "interrupt arrived" {
>   	-re "Program received signal SIGINT, Interrupt\\.\r\n" {
> 
> base-commit: 389971df23ca74092314dbde1303310a33766ba7
  
Andrew Burgess May 24, 2023, 5:39 p.m. UTC | #2
Tom de Vries <tdevries@suse.de> writes:

> On 5/24/23 18:29, Andrew Burgess wrote:
>> After this commit:
>> 
>>    commit ed32754a8c7919feffc6ddb66ff1c532e4a4d1cd
>>    Date:   Thu Mar 9 10:45:03 2023 +0100
>> 
>>        [gdb/testsuite] Fix gdb.server/multi-ui-errors.exp for remote target
>> 
>> I noticed the occasional failure in gdb.server/multi-ui-errors.exp,
>> which looked like this:
>> 
>>    (gdb) PASS: gdb.server/multi-ui-errors.exp: interact with GDB's main UI
>>    interrupt
>>    (gdb)
>>    Program received signal SIGINT, Interrupt.
>>    0x00007ffff7d501e7 in nanosleep () from /lib64/libc.so.6
>>    FAIL: gdb.server/multi-ui-errors.exp: interrupt (timeout)
>>    PASS: gdb.server/multi-ui-errors.exp: interrupt arrived
>>    p server_pid
>>    $1 = 718174
>>    (gdb) PASS: gdb.server/multi-ui-errors.exp: p server_pid
>> 
>> This is triggered by this code in gdb.server/multi-ui-errors.exp:
>> 
>>      gdb_test "interrupt"
>> 
>>      gdb_test_multiple "" "interrupt arrived" {
>> 	-re "Program received signal SIGINT, Interrupt\\.\r\n" {
>> 	    pass $gdb_test_name
>> 	}
>>      }
>> 
>> The problem here is that the first interrupt will trigger the prompt
>> to be printed, and then, after some time the inferior will be
>> interrupted.
>> 
>> However the default pattern for gdb_test includes a '$' end anchor.
>> If expect see the prompt with nothing following it then everything is
>
> Hi Andrew,
>
> see -> sees
>
>> fine, and the test passes.
>> 
>> However, if the interrupt is quick and so what expect sees is this:
>> 
>>    (gdb)
>>    Program received signal SIGINT, Interrupt.
>>    0x00007ffff7d501e7 in nanosleep () from /lib64/libc.so.6
>> 
>> In this case the end anchor means that the gdb_test fails to match,
>> and eventually times out.
>> 
>> Fix this by passing -no-prompt-anchor to gdb_test.
>
> thanks for fixing this.
>
> LGTM.
>
> Reviewed-by: Tom de Vries <tdevries@suse.de>

Pushed (with typo fixed).

Thanks,
Andrew

>
> Thanks,
> - Tom
>
>
>> ---
>>   gdb/testsuite/gdb.server/multi-ui-errors.exp | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/gdb/testsuite/gdb.server/multi-ui-errors.exp b/gdb/testsuite/gdb.server/multi-ui-errors.exp
>> index af83614fe55..47ded35bc86 100644
>> --- a/gdb/testsuite/gdb.server/multi-ui-errors.exp
>> +++ b/gdb/testsuite/gdb.server/multi-ui-errors.exp
>> @@ -106,7 +106,7 @@ with_spawn_id $gdb_main_spawn_id {
>>   # Get the gdbserver PID.
>>   set gdbserver_pid 0
>>   with_spawn_id $gdb_main_spawn_id {
>> -    gdb_test "interrupt"
>> +    gdb_test -no-prompt-anchor "interrupt"
>>   
>>       gdb_test_multiple "" "interrupt arrived" {
>>   	-re "Program received signal SIGINT, Interrupt\\.\r\n" {
>> 
>> base-commit: 389971df23ca74092314dbde1303310a33766ba7
  

Patch

diff --git a/gdb/testsuite/gdb.server/multi-ui-errors.exp b/gdb/testsuite/gdb.server/multi-ui-errors.exp
index af83614fe55..47ded35bc86 100644
--- a/gdb/testsuite/gdb.server/multi-ui-errors.exp
+++ b/gdb/testsuite/gdb.server/multi-ui-errors.exp
@@ -106,7 +106,7 @@  with_spawn_id $gdb_main_spawn_id {
 # Get the gdbserver PID.
 set gdbserver_pid 0
 with_spawn_id $gdb_main_spawn_id {
-    gdb_test "interrupt"
+    gdb_test -no-prompt-anchor "interrupt"
 
     gdb_test_multiple "" "interrupt arrived" {
 	-re "Program received signal SIGINT, Interrupt\\.\r\n" {