From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [committed][gdb/testsuite] Fix read1 timeout in gdb.base/info-types-c++.exp
Date: Wed, 19 May 2021 14:03:35 +0200 [thread overview]
Message-ID: <1c11c589-dcac-273e-136c-13a37685a57d@suse.de> (raw)
In-Reply-To: <20210512063959.GA20913@delia.home>
On 5/12/21 8:40 AM, Tom de Vries wrote:
> Hi,
>
> When running test-case gdb.base/info-types-c++.exp with check-read1 I run
> into:
> ...
> 425: typedef const void * std::allocator_traits<std::allocator<std::\
> _Sp_counted_ptr_inplace<std::filesystem::__cxx11::\
> recursive_directory_iterator::_Dir_stack, std::allocator<std::filesystem::\
> __cxx11::recursive_directory_iterator::_Dir_stack>, \
> FAIL: gdb.base/info-types-c++.exp: info types (timeout)
> ...
>
> The corresponding gdb_test_multiple does contain an exp_continue which
> resets the timeout counter every time info for another file is printed, but
> this doesn't help for this timeout because it times out during printing info
> for a single file.
>
> Fix this by processing line-by-line.
>
> Tested on x86_64-linux, both with gcc-7.5.0 and gcc-4.8.5 (the latter is
> different because the "unsigned int" type is missing).
>
> Any comments?
>
Committed.
Thanks,
- Tom
> [gdb/testsuite] Fix read1 timeout in gdb.base/info-types-c++.exp
>
> gdb/testsuite/ChangeLog:
>
> 2021-05-12 Tom de Vries <tdevries@suse.de>
>
> * gdb.base/info-types.exp.tcl: Scan info types output line-by-line.
>
> ---
> gdb/testsuite/gdb.base/info-types.exp.tcl | 97 +++++++++++++++++++++++++------
> 1 file changed, 80 insertions(+), 17 deletions(-)
>
> diff --git a/gdb/testsuite/gdb.base/info-types.exp.tcl b/gdb/testsuite/gdb.base/info-types.exp.tcl
> index ffdc3fa9088..2989751eef9 100644
> --- a/gdb/testsuite/gdb.base/info-types.exp.tcl
> +++ b/gdb/testsuite/gdb.base/info-types.exp.tcl
> @@ -16,6 +16,57 @@
> # Check that 'info types' produces the expected output for an inferior
> # containing a number of different types.
>
> +# Match LINE against regexp OUTPUT_LINES[IDX].
> +proc match_line { line output_lines idx_name } {
> + upvar $idx_name idx
> +
> + while { 1 } {
> + if { $idx == [llength $output_lines] } {
> + # Ran out of regexps, bail out.
> + return -1
> + }
> +
> + set re [lindex $output_lines $idx]
> + if { $re == "--optional" } {
> + # Optional, get actual regexp.
> + set opt 1
> + incr idx
> + set re [lindex $output_lines $idx]
> + } else {
> + # Not optional.
> + set opt 0
> + }
> +
> + if { [regexp $re $line] } {
> + # Match.
> + incr idx
> + if { $idx == [llength $output_lines] } {
> + # Last match, we're done.
> + return 1
> + }
> + # Match found, keep looking for next match.
> + return 0
> + } else {
> + # No match.
> + if { $idx == 0 } {
> + # First match not found, just keep looking for first match.
> + return 0
> + } elseif { $opt } {
> + # Try next regexp on same line.
> + incr idx
> + continue
> + } else {
> + # Mismatch, bail out.
> + return -1
> + }
> + }
> + break
> + }
> +
> + # Keep going.
> + return 0
> +}
> +
> # Run 'info types' test, compiling the test file for language LANG,
> # which should be either 'c' or 'c++'.
> proc run_test { lang } {
> @@ -39,8 +90,8 @@ proc run_test { lang } {
> }
>
> if { $lang == "c++" } {
> - set output_re \
> - [multi_line \
> + set output_lines \
> + [list \
> "98:\[\t \]+CL;" \
> "42:\[\t \]+anon_struct_t;" \
> "65:\[\t \]+anon_union_t;" \
> @@ -69,11 +120,12 @@ proc run_test { lang } {
> "39:\[\t \]+typedef enum_t nested_enum_t;" \
> "19:\[\t \]+typedef float nested_float_t;" \
> "18:\[\t \]+typedef int nested_int_t;" \
> - "62:\[\t \]+typedef union_t nested_union_t;(" \
> - "\[\t \]+unsigned int)?"]
> + "62:\[\t \]+typedef union_t nested_union_t;" \
> + "--optional" "\[\t \]+unsigned int" \
> + ""]
> } else {
> - set output_re \
> - [multi_line \
> + set output_lines \
> + [list \
> "52:\[\t \]+typedef enum {\\.\\.\\.} anon_enum_t;" \
> "45:\[\t \]+typedef struct {\\.\\.\\.} anon_struct_t;" \
> "68:\[\t \]+typedef union {\\.\\.\\.} anon_union_t;" \
> @@ -96,33 +148,44 @@ proc run_test { lang } {
> "19:\[\t \]+typedef float nested_float_t;" \
> "18:\[\t \]+typedef int nested_int_t;" \
> "62:\[\t \]+typedef union union_t nested_union_t;" \
> - "56:\[\t \]+union union_t;(" \
> - "\[\t \]+unsigned int)?"]
> + "56:\[\t \]+union union_t;" \
> + "--optional" "\[\t \]+unsigned int" \
> + ""]
> }
>
> set state 0
> + set idx 0
> gdb_test_multiple "info types" "" {
> -re "\r\nAll defined types:" {
> - if { $state == 0 } { set state 1 }
> + if { $state == 0 } { set state 1 } else { set state -1 }
> exp_continue
> }
> - -re "\r\n\r\nFile .*[string_to_regexp $srcfile]:" {
> - if { $state == 1 } { set state 2 }
> + -re "^\r\nFile .*[string_to_regexp $srcfile]:" {
> + if { $state == 1 } { set state 2 } else { set state -2 }
> exp_continue
> }
> - -re $output_re {
> - if { $state == 2 } { set state 3 }
> - exp_continue
> - }
> - -re "\r\n\r\nFile \[^\r\n\]*:" {
> + -re "^\r\nFile \[^\r\n\]*:" {
> + if { $state == 2 } { set state -4 }
> exp_continue
> }
> -re -wrap "" {
> if { $state == 3} {
> pass $gdb_test_name
> } else {
> - fail $gdb_test_name
> + fail "$gdb_test_name (state == $state)"
> + }
> + }
> + -re "^\r\n(\[^\r\n\]*)(?=\r\n)" {
> + if { $state == 2 } {
> + set line $expect_out(1,string)
> + set res [match_line $line $output_lines idx]
> + if { $res == 1 } {
> + set state 3
> + } elseif { $res == -1 } {
> + set state -3
> + }
> }
> + exp_continue
> }
> }
> }
>
prev parent reply other threads:[~2021-05-19 12:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-12 6:40 [PATCH][gdb/testsuite] " Tom de Vries
2021-05-19 12:03 ` Tom de Vries [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1c11c589-dcac-273e-136c-13a37685a57d@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox