From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 7B8vEEl4m2BaUQAAWB0awg (envelope-from ) for ; Wed, 12 May 2021 02:40:09 -0400 Received: by simark.ca (Postfix, from userid 112) id 333301F11C; Wed, 12 May 2021 02:40:09 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 0AFD31E783 for ; Wed, 12 May 2021 02:40:08 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 958E5385780B; Wed, 12 May 2021 06:40:07 +0000 (GMT) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 8DE78385780B for ; Wed, 12 May 2021 06:40:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8DE78385780B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tdevries@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 8CAE1B12C for ; Wed, 12 May 2021 06:40:03 +0000 (UTC) Date: Wed, 12 May 2021 08:40:00 +0200 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH][gdb/testsuite] Fix read1 timeout in gdb.base/info-types-c++.exp Message-ID: <20210512063959.GA20913@delia.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces@sourceware.org Sender: "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, \ 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 * 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 } } }