public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix list.exp test cases
@ 2022-02-24 15:40 Tom Tromey
  2022-02-24 18:13 ` Andrew Burgess
  0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2022-02-24 15:40 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

PR testsuite/7142 -- old enough to have been converted from Gnats --
points out that test_list_filename_and_function in gdb.base/list.exp
has "fails" that are unmatched with passes.  This patch cleans this up
a little.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7142
---
 gdb/testsuite/gdb.base/list.exp | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/gdb/testsuite/gdb.base/list.exp b/gdb/testsuite/gdb.base/list.exp
index d035d9b1613..35206b993e1 100644
--- a/gdb/testsuite/gdb.base/list.exp
+++ b/gdb/testsuite/gdb.base/list.exp
@@ -251,18 +251,16 @@ proc test_list_filename_and_function {} {
     global gdb_prompt
     global last_line_re
 
-    set testcnt 0
-
     # gcc appears to generate incorrect debugging information for code
     # in include files, which breaks this test.
     # SunPRO cc is the second case below, it's also correct.
     send_gdb "list list0.c:main\n"
     gdb_expect {
 	-re "1\[ \t\]+#include .*10\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" {
-	    incr testcnt
+	    pass "list list0.c:main"
 	}
 	-re "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" {
-	    pass "list function in source file 1"
+	    pass "list list0.c:main"
 	}
 	-re ".*$gdb_prompt $" { fail "list list0.c:main" }
 	timeout { fail "list list0.c:main (timeout)" }
@@ -274,10 +272,10 @@ proc test_list_filename_and_function {} {
     send_gdb "list list0.c:unused\n"
     gdb_expect {
 	-re "40\[ \t\]+unused.*${last_line_re}\r\n$gdb_prompt $" {
-	    incr testcnt
+	    pass "list list0.c:unused"
 	}
 	-re "37.*42\[ \t\]+\}\r\n$gdb_prompt $" {
-	    incr testcnt
+	    pass "list list0.c:unused"
 	}
 	-re ".*$gdb_prompt $" { fail "list list0.c:unused" }
 	timeout { fail "list list0.c:unused (timeout)" }
@@ -293,13 +291,13 @@ proc test_list_filename_and_function {} {
     send_gdb "list list0.h:foo\n"
     gdb_expect {
 	-re "2\[ \t\]+including file.  This.*11\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$gdb_prompt $" {
-	    incr testcnt
+	    pass "list list0.h:foo"
 	}
 	-re "1\[ \t\]+/. An include file.*10\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$gdb_prompt $" {
-	    incr testcnt
+	    pass "list list0.h:foo"
 	}
 	-re "3\[ \t\]+.*12\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$gdb_prompt $" {
-	    incr testcnt
+	    pass "list list0.h:foo"
 	}
 	-re "No source file named list0.h.\r\n$gdb_prompt $" {
 	    fail "list list0.h:foo"
@@ -312,13 +310,13 @@ proc test_list_filename_and_function {} {
     send_gdb "list list1.c:bar\n"
     gdb_expect {
 	-re "4\[ \t\]+void.*13\[ \t\]+\}\r\n$gdb_prompt $" {
-	    incr testcnt
+	    pass "list list1.c:bar"
 	}
 	-re "4\[ \t\]+void.*12\[ \t\]*long_line ..;\r\n$gdb_prompt $" {
-	    incr testcnt
+	    pass "list list1.c:bar"
 	}
 	-re "4\[ \t\]+void.*11\[ \t\]*\r\n$gdb_prompt $" {
-	    incr testcnt
+	    pass "list list1.c:bar"
 	}
 	-re ".*$gdb_prompt $" { fail "list list1.c:bar" }
 	timeout { fail "list list1.c:bar (timeout)" }
@@ -330,18 +328,16 @@ proc test_list_filename_and_function {} {
     send_gdb "list list1.c:unused\n"
     gdb_expect {
 	-re "12\[ \t\]+long_line \[(\]\[)\];.*13\[ \t\]+\}\r\n.*$gdb_prompt $" {
-	    incr testcnt
+	    pass "list list1.c:unused"
 	}
 	-re "14.*19\[ \t\]+\}\r\n.*$gdb_prompt $" {
-	    incr testcnt
+	    pass "list list1.c:unused"
 	}
 	-re ".*$gdb_prompt $" { fail "list list1.c:unused" }
 	timeout { fail "list list1.c:unused (timeout)" }
     }
     clear_xfail "rs6000-*-aix*"
 
-    pass "list filename:function ($testcnt tests)"
-
     # Test with quoting.
     gdb_test "list 'list0.c:main'" "int main.*"
 
-- 
2.31.1


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

* Re: [PATCH] Fix list.exp test cases
  2022-02-24 15:40 [PATCH] Fix list.exp test cases Tom Tromey
@ 2022-02-24 18:13 ` Andrew Burgess
  2022-02-24 21:36   ` Tom Tromey
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Burgess @ 2022-02-24 18:13 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

* Tom Tromey via Gdb-patches <gdb-patches@sourceware.org> [2022-02-24 08:40:29 -0700]:

> PR testsuite/7142 -- old enough to have been converted from Gnats --
> points out that test_list_filename_and_function in gdb.base/list.exp
> has "fails" that are unmatched with passes.  This patch cleans this up
> a little.

If we're going to clean this up, maybe we could switch to use
gdb_test_multiple, which would allow the use of $gdb_test_name, and
remove the need for send_gdb calls.

Something like the patch below?

Thanks,
Andrew

---

commit 2db58395c641adedc8d198786aa0dbb6424cc766
Author: Tom Tromey <tromey@adacore.com>
Date:   Thu Feb 24 08:40:29 2022 -0700

    gdb/testsuite: fix list.exp test cases
    
    PR testsuite/7142 -- old enough to have been converted from Gnats --
    points out that test_list_filename_and_function in gdb.base/list.exp
    has "fails" that are unmatched with passes.  This patch cleans this up
    a little.
    
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7142

diff --git a/gdb/testsuite/gdb.base/list.exp b/gdb/testsuite/gdb.base/list.exp
index d035d9b1613..d11d35e6697 100644
--- a/gdb/testsuite/gdb.base/list.exp
+++ b/gdb/testsuite/gdb.base/list.exp
@@ -251,36 +251,28 @@ proc test_list_filename_and_function {} {
     global gdb_prompt
     global last_line_re
 
-    set testcnt 0
-
     # gcc appears to generate incorrect debugging information for code
     # in include files, which breaks this test.
     # SunPRO cc is the second case below, it's also correct.
-    send_gdb "list list0.c:main\n"
-    gdb_expect {
-	-re "1\[ \t\]+#include .*10\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" {
-	    incr testcnt
+    gdb_test_multiple "list list0.c:main" "" {
+	-re -wrap "1\[ \t\]+#include .*10\[ \t\]+foo \[(\]+.*\[)\]+;" {
+	    pass $gdb_test_name
 	}
-	-re "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" {
-	    pass "list function in source file 1"
+	-re -wrap "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;" {
+	    pass $gdb_test_name
 	}
-	-re ".*$gdb_prompt $" { fail "list list0.c:main" }
-	timeout { fail "list list0.c:main (timeout)" }
     }
 
     # Not sure what the point of having this function be unused is.
     # AIX is legitimately removing it.
     setup_xfail "rs6000-*-aix*"
-    send_gdb "list list0.c:unused\n"
-    gdb_expect {
-	-re "40\[ \t\]+unused.*${last_line_re}\r\n$gdb_prompt $" {
-	    incr testcnt
+    gdb_test_multiple "list list0.c:unused" "" {
+	-re -wrap "40\[ \t\]+unused.*${last_line_re}" {
+	    pass $gdb_test_name
 	}
-	-re "37.*42\[ \t\]+\}\r\n$gdb_prompt $" {
-	    incr testcnt
+	-re -wrap "37.*42\[ \t\]+\}" {
+	    pass $gdb_test_name
 	}
-	-re ".*$gdb_prompt $" { fail "list list0.c:unused" }
-	timeout { fail "list list0.c:unused (timeout)" }
     }
     clear_xfail "rs6000-*-aix*"
 
@@ -290,58 +282,47 @@ proc test_list_filename_and_function {} {
     # SunPRO cc is the third case.
     setup_xfail "rs6000-*-*" 1804
     setup_xfail_format "COFF"
-    send_gdb "list list0.h:foo\n"
-    gdb_expect {
-	-re "2\[ \t\]+including file.  This.*11\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$gdb_prompt $" {
-	    incr testcnt
+    gdb_test_multiple "list list0.h:foo" "" {
+	-re -wrap "2\[ \t\]+including file.  This.*11\[ \t\]+bar \[(\]+.*\[)\]+;" {
+	    pass $gdb_test_name
 	}
-	-re "1\[ \t\]+/. An include file.*10\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$gdb_prompt $" {
-	    incr testcnt
+	-re -wrap "1\[ \t\]+/. An include file.*10\[ \t\]+bar \[(\]+.*\[)\]+;" {
+	    pass $gdb_test_name
 	}
-	-re "3\[ \t\]+.*12\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$gdb_prompt $" {
-	    incr testcnt
+	-re -wrap "3\[ \t\]+.*12\[ \t\]+bar \[(\]+.*\[)\]+;" {
+	    pass $gdb_test_name
 	}
-	-re "No source file named list0.h.\r\n$gdb_prompt $" {
-	    fail "list list0.h:foo"
+	-re -wrap "No source file named list0.h." {
+	    fail $gdb_test_name
 	}
-	-re ".*$gdb_prompt $" { fail "list list0.h:foo" }
-	timeout { fail "list list0.h:foo (timeout)" }
     }
 
     # Ultrix gdb is the second case.
-    send_gdb "list list1.c:bar\n"
-    gdb_expect {
-	-re "4\[ \t\]+void.*13\[ \t\]+\}\r\n$gdb_prompt $" {
-	    incr testcnt
+    gdb_test_multiple "list list1.c:bar" "" {
+	-re -wrap "4\[ \t\]+void.*13\[ \t\]+\}" {
+	    pass $gdb_test_name
 	}
-	-re "4\[ \t\]+void.*12\[ \t\]*long_line ..;\r\n$gdb_prompt $" {
-	    incr testcnt
+	-re -wrap "4\[ \t\]+void.*12\[ \t\]*long_line ..;" {
+	    pass $gdb_test_name
 	}
-	-re "4\[ \t\]+void.*11\[ \t\]*\r\n$gdb_prompt $" {
-	    incr testcnt
+	-re -wrap "4\[ \t\]+void.*11\[ \t\]*" {
+	    pass $gdb_test_name
 	}
-	-re ".*$gdb_prompt $" { fail "list list1.c:bar" }
-	timeout { fail "list list1.c:bar (timeout)" }
     }
 
     # Not sure what the point of having this function be unused is.
     # AIX is legitimately removing it.
     setup_xfail "rs6000-*-aix*"
-    send_gdb "list list1.c:unused\n"
-    gdb_expect {
-	-re "12\[ \t\]+long_line \[(\]\[)\];.*13\[ \t\]+\}\r\n.*$gdb_prompt $" {
-	    incr testcnt
+    gdb_test_multiple "list list1.c:unused" "" {
+	-re -wrap "12\[ \t\]+long_line \[(\]\[)\];.*13\[ \t\]+\}.*" {
+	    pass $gdb_test_name
 	}
-	-re "14.*19\[ \t\]+\}\r\n.*$gdb_prompt $" {
-	    incr testcnt
+	-re -wrap "14.*19\[ \t\]+\}.*" {
+	    pass $gdb_test_name
 	}
-	-re ".*$gdb_prompt $" { fail "list list1.c:unused" }
-	timeout { fail "list list1.c:unused (timeout)" }
     }
     clear_xfail "rs6000-*-aix*"
 
-    pass "list filename:function ($testcnt tests)"
-
     # Test with quoting.
     gdb_test "list 'list0.c:main'" "int main.*"
 


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

* Re: [PATCH] Fix list.exp test cases
  2022-02-24 18:13 ` Andrew Burgess
@ 2022-02-24 21:36   ` Tom Tromey
  2022-02-25 11:51     ` Andrew Burgess
  0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2022-02-24 21:36 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: Tom Tromey, gdb-patches

>>>>> "Andrew" == Andrew Burgess <aburgess@redhat.com> writes:

Andrew> Something like the patch below?

Works for me!

Andrew> commit 2db58395c641adedc8d198786aa0dbb6424cc766
Andrew> Author: Tom Tromey <tromey@adacore.com>

You might as well change the author at this point :)

Tom

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

* Re: [PATCH] Fix list.exp test cases
  2022-02-24 21:36   ` Tom Tromey
@ 2022-02-25 11:51     ` Andrew Burgess
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Burgess @ 2022-02-25 11:51 UTC (permalink / raw)
  To: Tom Tromey via Gdb-patches; +Cc: gdb-patches, Tom Tromey

Tom Tromey via Gdb-patches <gdb-patches@sourceware.org> writes:

>>>>>> "Andrew" == Andrew Burgess <aburgess@redhat.com> writes:
>
> Andrew> Something like the patch below?
>
> Works for me!
>
> Andrew> commit 2db58395c641adedc8d198786aa0dbb6424cc766
> Andrew> Author: Tom Tromey <tromey@adacore.com>
>
> You might as well change the author at this point :)

Thanks, I pushed this patch.

Andrew


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

end of thread, other threads:[~2022-02-25 11:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-24 15:40 [PATCH] Fix list.exp test cases Tom Tromey
2022-02-24 18:13 ` Andrew Burgess
2022-02-24 21:36   ` Tom Tromey
2022-02-25 11:51     ` Andrew Burgess

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).