* [PATCH][gdb/testsuite] Fix read1 timeout in gdb.base/info-types-c++.exp
@ 2021-05-12 6:40 Tom de Vries
2021-05-19 12:03 ` [committed][gdb/testsuite] " Tom de Vries
0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2021-05-12 6:40 UTC (permalink / raw)
To: gdb-patches
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?
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
}
}
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* [committed][gdb/testsuite] Fix read1 timeout in gdb.base/info-types-c++.exp
2021-05-12 6:40 [PATCH][gdb/testsuite] Fix read1 timeout in gdb.base/info-types-c++.exp Tom de Vries
@ 2021-05-19 12:03 ` Tom de Vries
0 siblings, 0 replies; 2+ messages in thread
From: Tom de Vries @ 2021-05-19 12:03 UTC (permalink / raw)
To: gdb-patches
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
> }
> }
> }
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-05-19 12:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-12 6:40 [PATCH][gdb/testsuite] Fix read1 timeout in gdb.base/info-types-c++.exp Tom de Vries
2021-05-19 12:03 ` [committed][gdb/testsuite] " 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).