public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [pushed] [gdb/testsuite] Fix gdb.dwarf2/forward-spec.exp with read1
@ 2023-07-15  8:11 Tom de Vries
  2023-07-15  8:46 ` Andreas Schwab
  0 siblings, 1 reply; 3+ messages in thread
From: Tom de Vries @ 2023-07-15  8:11 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

When running test-case gdb.dwarf2/forward-spec.exp with check-read1 we run
into:
...
    parent:     ((cooked_index_entry *) 0xFAIL: <exp>: v has a parent
7fdc1c002ed0) [ns]^M
...

The problem is using regexps containing '.' to avoid escaping, which makes
them too generic.

Fix this by eliminating the '.' from the regexps.

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.dwarf2/forward-spec.exp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.dwarf2/forward-spec.exp b/gdb/testsuite/gdb.dwarf2/forward-spec.exp
index ac7d16b09b8..f4512cf9b8c 100644
--- a/gdb/testsuite/gdb.dwarf2/forward-spec.exp
+++ b/gdb/testsuite/gdb.dwarf2/forward-spec.exp
@@ -74,7 +74,7 @@ if {[prepare_for_testing "failed to prepare" ${testfile} \
 
 set in_v 0
 gdb_test_multiple "maint print objfiles" "v has a parent" {
-    -re "^ *\\\[\[0-9\]\\\] *..cooked_index_entry\[^\r\n\]*" {
+    -re "^ *\\\[\[0-9\]\\\] *\\(\\(cooked_index_entry\[^\r\n\]*" {
 	set in_v 0
 	exp_continue
     }
@@ -82,7 +82,7 @@ gdb_test_multiple "maint print objfiles" "v has a parent" {
 	set in_v 1
 	exp_continue
     }
-    -re "^ *parent: *..cooked_index_entry .. (0|$hex)." {
+    -re "^ *parent: *\\(\\(cooked_index_entry \\*\\) (0|$hex)\\)" {
 	if {$in_v} {
 	    if {$expect_out(1,string) == "0"} {
 		fail $gdb_test_name

base-commit: c1f6762ce51fbcffb7ee3fdb1d794435fb19d43c
-- 
2.35.3


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

* Re: [pushed] [gdb/testsuite] Fix gdb.dwarf2/forward-spec.exp with read1
  2023-07-15  8:11 [pushed] [gdb/testsuite] Fix gdb.dwarf2/forward-spec.exp with read1 Tom de Vries
@ 2023-07-15  8:46 ` Andreas Schwab
  2023-07-15 15:06   ` Tom de Vries
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Schwab @ 2023-07-15  8:46 UTC (permalink / raw)
  To: Tom de Vries via Gdb-patches; +Cc: Tom de Vries, Tom Tromey

On Jul 15 2023, Tom de Vries via Gdb-patches wrote:

> diff --git a/gdb/testsuite/gdb.dwarf2/forward-spec.exp b/gdb/testsuite/gdb.dwarf2/forward-spec.exp
> index ac7d16b09b8..f4512cf9b8c 100644
> --- a/gdb/testsuite/gdb.dwarf2/forward-spec.exp
> +++ b/gdb/testsuite/gdb.dwarf2/forward-spec.exp
> @@ -74,7 +74,7 @@ if {[prepare_for_testing "failed to prepare" ${testfile} \
>  
>  set in_v 0
>  gdb_test_multiple "maint print objfiles" "v has a parent" {
> -    -re "^ *\\\[\[0-9\]\\\] *..cooked_index_entry\[^\r\n\]*" {
> +    -re "^ *\\\[\[0-9\]\\\] *\\(\\(cooked_index_entry\[^\r\n\]*" {

A match that ends with an empty element doesn't make much sense.  I
guess this should rather be

    -re "^ *\\\[\[0-9\]\\\] *..cooked_index_entry\[^\r\n\]*\[\r\n\]" {

to avoid matching an incomplete line.

>  	set in_v 0
>  	exp_continue
>      }
> @@ -82,7 +82,7 @@ gdb_test_multiple "maint print objfiles" "v has a parent" {
>  	set in_v 1
>  	exp_continue
>      }
> -    -re "^ *parent: *..cooked_index_entry .. (0|$hex)." {
> +    -re "^ *parent: *\\(\\(cooked_index_entry \\*\\) (0|$hex)\\)" {

I think this just needs to be anchored on EOL as well.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

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

* Re: [pushed] [gdb/testsuite] Fix gdb.dwarf2/forward-spec.exp with read1
  2023-07-15  8:46 ` Andreas Schwab
@ 2023-07-15 15:06   ` Tom de Vries
  0 siblings, 0 replies; 3+ messages in thread
From: Tom de Vries @ 2023-07-15 15:06 UTC (permalink / raw)
  To: Andreas Schwab, Tom de Vries via Gdb-patches; +Cc: Tom Tromey

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

On 7/15/23 10:46, Andreas Schwab wrote:
> On Jul 15 2023, Tom de Vries via Gdb-patches wrote:
> 
>> diff --git a/gdb/testsuite/gdb.dwarf2/forward-spec.exp b/gdb/testsuite/gdb.dwarf2/forward-spec.exp
>> index ac7d16b09b8..f4512cf9b8c 100644
>> --- a/gdb/testsuite/gdb.dwarf2/forward-spec.exp
>> +++ b/gdb/testsuite/gdb.dwarf2/forward-spec.exp
>> @@ -74,7 +74,7 @@ if {[prepare_for_testing "failed to prepare" ${testfile} \
>>   
>>   set in_v 0
>>   gdb_test_multiple "maint print objfiles" "v has a parent" {
>> -    -re "^ *\\\[\[0-9\]\\\] *..cooked_index_entry\[^\r\n\]*" {
>> +    -re "^ *\\\[\[0-9\]\\\] *\\(\\(cooked_index_entry\[^\r\n\]*" {
> 
> A match that ends with an empty element doesn't make much sense.  I
> guess this should rather be
> 
>      -re "^ *\\\[\[0-9\]\\\] *..cooked_index_entry\[^\r\n\]*\[\r\n\]" {
> 
> to avoid matching an incomplete line.
> 
>>   	set in_v 0
>>   	exp_continue
>>       }
>> @@ -82,7 +82,7 @@ gdb_test_multiple "maint print objfiles" "v has a parent" {
>>   	set in_v 1
>>   	exp_continue
>>       }
>> -    -re "^ *parent: *..cooked_index_entry .. (0|$hex)." {
>> +    -re "^ *parent: *\\(\\(cooked_index_entry \\*\\) (0|$hex)\\)" {
> 
> I think this just needs to be anchored on EOL as well.
> 

Agreed, anchoring can be improved, but I'd rather use the style that can 
be used in combination with -wrap, which only lookahead-matches the EOL, 
but doesn't consume it.  This plays well with "-wrap", and all the 
implicit patterns added by gdb_test_multiple.

Thanks,
- Tom

[-- Attachment #2: 0001-gdb-testsuite-Improve-matching-in-gdb.dwarf2-forward.patch --]
[-- Type: text/x-patch, Size: 2146 bytes --]

From a3f50dcb9b7dca39546781ebf0ee6b0061f1098e Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevries@suse.de>
Date: Sat, 15 Jul 2023 16:52:05 +0200
Subject: [PATCH] [gdb/testsuite] Improve matching in
 gdb.dwarf2/forward-spec.exp

Improve matching in test-case in gdb.dwarf2/forward-spec.exp:
- use -wrap rather than an explicit "$gdb_prompt " , which misses
  the $ anchor at the end
- use line-by-line matching, consuming the start-of-line \r\n, and
  lookahead-matching the end-of-line \r\n
- always produce a pass/fail by using a gdb_assert in the -wrap clause

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.dwarf2/forward-spec.exp | 26 +++++++++++------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/gdb/testsuite/gdb.dwarf2/forward-spec.exp b/gdb/testsuite/gdb.dwarf2/forward-spec.exp
index f4512cf9b8c..e252cbd5890 100644
--- a/gdb/testsuite/gdb.dwarf2/forward-spec.exp
+++ b/gdb/testsuite/gdb.dwarf2/forward-spec.exp
@@ -72,31 +72,31 @@ if {[prepare_for_testing "failed to prepare" ${testfile} \
     return -1
 }
 
+set ok 0
 set in_v 0
-gdb_test_multiple "maint print objfiles" "v has a parent" {
-    -re "^ *\\\[\[0-9\]\\\] *\\(\\(cooked_index_entry\[^\r\n\]*" {
+set cmd "maint print objfiles"
+gdb_test_multiple $cmd "v has a parent" {
+    -re "^${cmd}(?=\r\n)" {
+	exp_continue
+    }
+    -re "^\r\n *\\\[$decimal\\\] *\\(\\(cooked_index_entry\[^\r\n\]*(?=\r\n)" {
 	set in_v 0
 	exp_continue
     }
-    -re "^ *name: *v\[\r\n\]*" {
+    -re "^\r\n *name: *v(?=\r\n)" {
 	set in_v 1
 	exp_continue
     }
-    -re "^ *parent: *\\(\\(cooked_index_entry \\*\\) (0|$hex)\\)" {
+    -re "^\r\n *parent: *\\(\\(cooked_index_entry \\*\\) $hex\\)\[^\r\n\]*(?=\r\n)" {
 	if {$in_v} {
-	    if {$expect_out(1,string) == "0"} {
-		fail $gdb_test_name
-	    } else {
-		pass $gdb_test_name
-	    }
-	    set in_v 0
+	    set ok 1
 	}
 	exp_continue
     }
-    -re "^\[^\r\n\]*\[\r\n\]+" {
+    -re "^\r\n\[^\r\n\]*(?=\r\n)" {
 	exp_continue
     }
-    -re "$gdb_prompt " {
-	# Done.
+    -re -wrap "" {
+	gdb_assert $ok $gdb_test_name
     }
 }

base-commit: 6c1e84f5c6f36263998ef1934bf3132c8cebe75e
-- 
2.35.3


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

end of thread, other threads:[~2023-07-15 15:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-15  8:11 [pushed] [gdb/testsuite] Fix gdb.dwarf2/forward-spec.exp with read1 Tom de Vries
2023-07-15  8:46 ` Andreas Schwab
2023-07-15 15:06   ` 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).