From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 291243954C7A for ; Tue, 8 Jun 2021 13:37:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 291243954C7A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap.suse.de (imap-alt.suse-dmz.suse.de [192.168.254.47]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 388AF21992 for ; Tue, 8 Jun 2021 13:37:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623159436; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=CmHyREjFaQrVhFPKgY5mG6olo19kN925BzRxkuC5F/M=; b=NKCnVQV9i5S3D2xBOjs84yM4CSNoX29kvJMOksd9vrriaO5+QVYK63pzQDfme92Jfxnl+N QV8wolFYOQexmPqiSchvpvTfF/4tMuI9bhuBJEtKr3G/iKYbjiNHJwtdDSDHmW1Ke8xJNj YjaT/D6f8Qxvzgld/TPLXi+NCFHl7wA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623159436; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=CmHyREjFaQrVhFPKgY5mG6olo19kN925BzRxkuC5F/M=; b=CHBmiCb7BhRg7XdS3WGXhaTb0IkD72ypT5NU7yiZMlLI1/9ymFZg2k/Xzoga6ZX/wihO2O s5d45ONtP80I2kBA== Received: from imap3-int (imap-alt.suse-dmz.suse.de [192.168.254.47]) by imap.suse.de (Postfix) with ESMTP id 1B02A118DD for ; Tue, 8 Jun 2021 13:37:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623159436; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=CmHyREjFaQrVhFPKgY5mG6olo19kN925BzRxkuC5F/M=; b=NKCnVQV9i5S3D2xBOjs84yM4CSNoX29kvJMOksd9vrriaO5+QVYK63pzQDfme92Jfxnl+N QV8wolFYOQexmPqiSchvpvTfF/4tMuI9bhuBJEtKr3G/iKYbjiNHJwtdDSDHmW1Ke8xJNj YjaT/D6f8Qxvzgld/TPLXi+NCFHl7wA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623159436; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=CmHyREjFaQrVhFPKgY5mG6olo19kN925BzRxkuC5F/M=; b=CHBmiCb7BhRg7XdS3WGXhaTb0IkD72ypT5NU7yiZMlLI1/9ymFZg2k/Xzoga6ZX/wihO2O s5d45ONtP80I2kBA== Received: from director2.suse.de ([192.168.254.72]) by imap3-int with ESMTPSA id 29+nBYxyv2B4bQAALh3uQQ (envelope-from ) for ; Tue, 08 Jun 2021 13:37:16 +0000 Date: Tue, 8 Jun 2021 15:37:14 +0200 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [committed][gdb/testsuite] Fix gdb.base/info-macros.exp with check-read1 Message-ID: <20210608133713.GA1704@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIM_INVALID, DKIM_SIGNED, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_NUMSUBJECT, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org 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: , X-List-Received-Date: Tue, 08 Jun 2021 13:37:18 -0000 Hi, With check-read1 we run into: ... FAIL: gdb.base/info-macros.exp: info macros info-macros.c:42 (timeout) ... Fix this by using gdb_test_lines from gdb.base/info-types.exp.tcl. Tested on x86_64-linux. Committed to trunk. Thanks, - Tom [gdb/testsuite] Fix gdb.base/info-macros.exp with check-read1 gdb/testsuite/ChangeLog: 2021-06-08 Tom de Vries * gdb.base/info-types.exp.tcl (match_line, gdb_test_lines): Move ... * lib/gdb.exp: ... here. * gdb.base/info-macros.exp: Use gdb_test_lines. --- gdb/testsuite/gdb.base/info-macros.exp | 6 +-- gdb/testsuite/gdb.base/info-types.exp.tcl | 82 ------------------------------- gdb/testsuite/lib/gdb.exp | 82 +++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+), 85 deletions(-) diff --git a/gdb/testsuite/gdb.base/info-macros.exp b/gdb/testsuite/gdb.base/info-macros.exp index c75229f80d9..3d096a3db51 100644 --- a/gdb/testsuite/gdb.base/info-macros.exp +++ b/gdb/testsuite/gdb.base/info-macros.exp @@ -273,6 +273,6 @@ gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname { set test "info macros info-macros.c:42" -set r1 ".*define DEF_MACROS" -set r2 ".*define ONE" -gdb_test "$test" "$r1$r2.*" +set r1 "#define DEF_MACROS" +set r2 "#define ONE" +gdb_test_lines "$test" "" [list $r1 "--any" $r2] diff --git a/gdb/testsuite/gdb.base/info-types.exp.tcl b/gdb/testsuite/gdb.base/info-types.exp.tcl index eef4b078221..c820adc4ac1 100644 --- a/gdb/testsuite/gdb.base/info-types.exp.tcl +++ b/gdb/testsuite/gdb.base/info-types.exp.tcl @@ -16,88 +16,6 @@ # Check that 'info types' produces the expected output for an inferior # containing a number of different types. -# Match LINE against regexp OUTPUT_LINES[IDX]. Helper function for -# gdb_test_lines. -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] - set opt 0 - set any 0 - if { $re == "--optional" } { - # Optional, get actual regexp. - set opt 1 - incr idx - set re [lindex $output_lines $idx] - } elseif { $re == "--any" } { - set any 1 - incr idx - set re [lindex $output_lines $idx] - } - - 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 - } elseif { $any } { - # Try again with next line. - incr idx -1 - return 0 - } else { - # Mismatch, bail out. - return -1 - } - } - break - } - - # Keep going. - return 0 -} - -# Match output of COMMAND line-by-line, using PATTERNS. -# Report pass/fail with MESSAGE. - -proc gdb_test_lines { command message patterns } { - set found 0 - set idx 0 - if { $message == ""} { - set message $command - } - gdb_test_multiple $command $message { - -re "\r\n(\[^\r\n\]*)(?=\r\n)" { - if { $found == 0 } { - set line $expect_out(1,string) - set found [match_line $line $patterns idx] - } - exp_continue - } - -re -wrap "" { - gdb_assert { $found == 1 } $gdb_test_name - } - } -} - # Run 'info types' test, compiling the test file for language LANG, # which should be either 'c' or 'c++'. proc run_test { lang } { diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index f6686e19162..f7ab2198a25 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -1432,6 +1432,88 @@ proc gdb_test_sequence { args } { } +# Match LINE against regexp OUTPUT_LINES[IDX]. Helper function for +# gdb_test_lines. +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] + set opt 0 + set any 0 + if { $re == "--optional" } { + # Optional, get actual regexp. + set opt 1 + incr idx + set re [lindex $output_lines $idx] + } elseif { $re == "--any" } { + set any 1 + incr idx + set re [lindex $output_lines $idx] + } + + 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 + } elseif { $any } { + # Try again with next line. + incr idx -1 + return 0 + } else { + # Mismatch, bail out. + return -1 + } + } + break + } + + # Keep going. + return 0 +} + +# Match output of COMMAND line-by-line, using PATTERNS. +# Report pass/fail with MESSAGE. + +proc gdb_test_lines { command message patterns } { + set found 0 + set idx 0 + if { $message == ""} { + set message $command + } + gdb_test_multiple $command $message { + -re "\r\n(\[^\r\n\]*)(?=\r\n)" { + if { $found == 0 } { + set line $expect_out(1,string) + set found [match_line $line $patterns idx] + } + exp_continue + } + -re -wrap "" { + gdb_assert { $found == 1 } $gdb_test_name + } + } +} + # Test that a command gives an error. For pass or fail, return # a 1 to indicate that more tests can proceed. However a timeout # is a serious error, generates a special fail message, and causes