* [PATCH] gdb/testsuite: Fix testing of "info copying"
@ 2024-01-11 2:59 Thiago Jung Bauermann
2024-01-24 17:09 ` Keith Seitz
0 siblings, 1 reply; 4+ messages in thread
From: Thiago Jung Bauermann @ 2024-01-11 2:59 UTC (permalink / raw)
To: gdb-patches
gdb.base/default.exp has an incomplete test for the "info copying" command,
as poetically pointed out by the FIXME removed by this patch.
The test omits the pattern argument to gdb_test, which causes it to just
check for a GDB prompt at the end of the command output.
The problem is that the command output is the whole GPLv3 license, which
due to its size causes the test to fail sometimes, making the testcase to
be out of sync with GDB's output and failing the tests that follow
it. E.g.,
FAIL: gdb.base/default.exp: info copying (timeout)
FAIL: gdb.base/default.exp: info display
FAIL: gdb.base/default.exp: info frame "f" abbreviation
PASS: gdb.base/default.exp: info frame
FAIL: gdb.base/default.exp: info files
FAIL: gdb.base/default.exp: info float
FAIL: gdb.base/default.exp: info functions
FAIL: gdb.base/default.exp: info locals
FAIL: gdb.base/default.exp: info program
FAIL: gdb.base/default.exp: info registers
FAIL: gdb.base/default.exp: info stack "s" abbreviation
Fix by by checking for a few excerpts at the beginning, middle and end of
the license text. This makes the test consume the command's output in
smallish chunks.
---
gdb/testsuite/gdb.base/default.exp | 94 +++++++++++++++++++++++++++---
1 file changed, 87 insertions(+), 7 deletions(-)
diff --git a/gdb/testsuite/gdb.base/default.exp b/gdb/testsuite/gdb.base/default.exp
index 2b5294fcddd7..912b0c881bb0 100644
--- a/gdb/testsuite/gdb.base/default.exp
+++ b/gdb/testsuite/gdb.base/default.exp
@@ -267,13 +267,93 @@ gdb_test "info bogus-gdb-command" "Undefined info command: \"bogus-gdb-command\"
#test info breakpoints
gdb_test "info breakpoints" "No breakpoints or watchpoints."
#test info copying
-# FIXME -- doesn't work worth a shit
-#send_gdb "info copying"
-# -re "GNU GENERAL PUBLIC LICENSE.*#of preserving the free status of all derivatives of our free software and.*#of promoting the sharing and reuse of software generally."#
-gdb_test "info copying"
-# }
-#
-#
+# The license text is very big, so it may overwhelm Expect's output buffer
+# and cause the test to fail occasionally. To avoid this problem, verify
+# the command's output in small chunks.
+set saw_header 0
+set saw_terms 0
+set saw_section5 0
+set saw_section7 0
+set saw_section10 0
+set saw_section14 0
+set saw_last_para 0
+# These excerpts were chosen for no particular reason, except that they
+# occur at the beginning, middle and end of the license text.
+set re_header [multi_line \
+ "\\s+GNU GENERAL PUBLIC LICENSE" \
+ "\\s+Version 3, 29 June 2007" \
+ "" \
+ " Copyright \\(C\\) 2007 Free Software Foundation, Inc. <http://fsf.org/>" \
+ " Everyone is permitted to copy and distribute verbatim copies" \
+ " of this license document, but changing it is not allowed." \
+ "" \
+ "\\s+Preamble" \
+ "" \
+ " The GNU General Public License is a free, copyleft license for" \
+ "software and other kinds of works.\r\n"]
+set re_terms [multi_line \
+ "\\s+TERMS AND CONDITIONS" \
+ "" \
+ " 0. Definitions." \
+ "" \
+ " \"This License\" refers to version 3 of the GNU General Public License.\r\n"]
+set re_section5 [multi_line \
+ " 5. Conveying Modified Source Versions." \
+ "" \
+ " You may convey a work based on the Program, or the modifications to\r\n"]
+set re_section7 [multi_line \
+ " 7. Additional Terms." \
+ "" \
+ " \"Additional permissions\" are terms that supplement the terms of this\r\n"]
+set re_section10 [multi_line \
+ " 10. Automatic Licensing of Downstream Recipients." \
+ "" \
+ " Each time you convey a covered work, the recipient automatically\r\n"]
+set re_section14 [multi_line \
+ " 14. Revised Versions of this License." \
+ "" \
+ " The Free Software Foundation may publish revised and/or new versions of\r\n"]
+set re_last_para [multi_line \
+ " Later license versions may give you additional or different" \
+ "permissions. However, no additional obligations are imposed on any" \
+ "author or copyright holder as a result of your choosing to follow a" \
+ "later version.\r\n"]
+set test "info copying"
+gdb_test_multiple $test $test {
+ -re $re_header {
+ set saw_header 1
+ exp_continue
+ }
+ -re $re_terms {
+ set saw_terms 1
+ exp_continue
+ }
+ -re $re_section5 {
+ set saw_section5 1
+ exp_continue
+ }
+ -re $re_section7 {
+ set saw_section7 1
+ exp_continue
+ }
+ -re $re_section10 {
+ set saw_section10 1
+ exp_continue
+ }
+ -re $re_section14 {
+ set saw_section14 1
+ exp_continue
+ }
+ -re $re_last_para {
+ set saw_last_para 1
+ exp_continue
+ }
+ -re "$gdb_prompt \$" {
+ gdb_assert { $saw_header && $saw_terms && $saw_section5 \
+ && $saw_section7 && $saw_section10 \
+ && $saw_section14 && $saw_last_para } $test
+ }
+}
#test info display
gdb_test "info display" "There are no auto-display expressions now."
#test info frame "f" abbreviation
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] gdb/testsuite: Fix testing of "info copying"
2024-01-11 2:59 [PATCH] gdb/testsuite: Fix testing of "info copying" Thiago Jung Bauermann
@ 2024-01-24 17:09 ` Keith Seitz
2024-02-08 16:20 ` Tom Tromey
0 siblings, 1 reply; 4+ messages in thread
From: Keith Seitz @ 2024-01-24 17:09 UTC (permalink / raw)
To: Thiago Jung Bauermann, gdb-patches
Hi,
On 1/10/24 18:59, Thiago Jung Bauermann wrote:
> gdb.base/default.exp has an incomplete test for the "info copying" command,
> as poetically pointed out by the FIXME removed by this patch.
Thank you for the patch... Oh, that FIXME! 🤣
> The test omits the pattern argument to gdb_test, which causes it to just
> check for a GDB prompt at the end of the command output.
>
> The problem is that the command output is the whole GPLv3 license, which
> due to its size causes the test to fail sometimes, making the testcase to
> be out of sync with GDB's output and failing the tests that follow
> it. E.g.,
>
> FAIL: gdb.base/default.exp: info copying (timeout)
> FAIL: gdb.base/default.exp: info display
> FAIL: gdb.base/default.exp: info frame "f" abbreviation
> PASS: gdb.base/default.exp: info frame
> FAIL: gdb.base/default.exp: info files
> FAIL: gdb.base/default.exp: info float
> FAIL: gdb.base/default.exp: info functions
> FAIL: gdb.base/default.exp: info locals
> FAIL: gdb.base/default.exp: info program
> FAIL: gdb.base/default.exp: info registers
> FAIL: gdb.base/default.exp: info stack "s" abbreviation
>
> Fix by by checking for a few excerpts at the beginning, middle and end of
> the license text. This makes the test consume the command's output in
> smallish chunks.
While I'm not really in favor of copying large swaths of text from
compiled code into the test suite, this text changes very infrequently.
I think the last time it was updated was around 2007?
So I think this is easily outweighed by the need to strive for
more deterministic test results.
Reviewed-by: Keith Seitz <keiths@redhat.com>
Thank you!
Keith
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] gdb/testsuite: Fix testing of "info copying"
2024-01-24 17:09 ` Keith Seitz
@ 2024-02-08 16:20 ` Tom Tromey
2024-02-08 23:47 ` Thiago Jung Bauermann
0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2024-02-08 16:20 UTC (permalink / raw)
To: Keith Seitz; +Cc: Thiago Jung Bauermann, gdb-patches
>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:
Keith> While I'm not really in favor of copying large swaths of text from
Keith> compiled code into the test suite, this text changes very infrequently.
Keith> I think the last time it was updated was around 2007?
Keith> So I think this is easily outweighed by the need to strive for
Keith> more deterministic test results.
Keith> Reviewed-by: Keith Seitz <keiths@redhat.com>
Makes sense to me. I didn't see this go in, so:
Approved-By: Tom Tromey <tom@tromey.com>
Tom
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] gdb/testsuite: Fix testing of "info copying"
2024-02-08 16:20 ` Tom Tromey
@ 2024-02-08 23:47 ` Thiago Jung Bauermann
0 siblings, 0 replies; 4+ messages in thread
From: Thiago Jung Bauermann @ 2024-02-08 23:47 UTC (permalink / raw)
To: Tom Tromey; +Cc: Keith Seitz, gdb-patches
Tom Tromey <tom@tromey.com> writes:
>>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:
>
> Keith> While I'm not really in favor of copying large swaths of text from
> Keith> compiled code into the test suite, this text changes very infrequently.
> Keith> I think the last time it was updated was around 2007?
>
> Keith> So I think this is easily outweighed by the need to strive for
> Keith> more deterministic test results.
Yes, I agree it's not ideal but in this case I think it's reasonable.
> Keith> Reviewed-by: Keith Seitz <keiths@redhat.com>
Thank you for your review!
> Makes sense to me. I didn't see this go in, so:
>
> Approved-By: Tom Tromey <tom@tromey.com>
Thank you! Pushed as commit 0fbd03fda1b6.
--
Thiago
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-02-08 23:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-11 2:59 [PATCH] gdb/testsuite: Fix testing of "info copying" Thiago Jung Bauermann
2024-01-24 17:09 ` Keith Seitz
2024-02-08 16:20 ` Tom Tromey
2024-02-08 23:47 ` Thiago Jung Bauermann
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).