From patchwork Thu Oct 24 16:44:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Simon Marchi (Code Review)" X-Patchwork-Id: 35281 Received: (qmail 111353 invoked by alias); 24 Oct 2019 16:44:14 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 111339 invoked by uid 89); 24 Oct 2019 16:44:14 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=at*, 8396 X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 24 Oct 2019 16:44:12 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id 47464201F1; Thu, 24 Oct 2019 12:44:11 -0400 (EDT) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [IPv6:2620:52:3:1:5054:ff:fe06:16ca]) by mx1.osci.io (Postfix) with ESMTP id 59DA9201F1; Thu, 24 Oct 2019 12:44:06 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id 00A8D204C9; Thu, 24 Oct 2019 12:44:05 -0400 (EDT) X-Gerrit-PatchSet: 3 Date: Thu, 24 Oct 2019 12:44:05 -0400 From: "Sourceware to Gerrit sync (Code Review)" To: Tom de Vries , Luis Machado , Andrew Burgess , gdb-patches@sourceware.org Auto-Submitted: auto-generated X-Gerrit-MessageType: newpatchset Subject: [pushed] [gdb/testsuite] Add -wrap pattern flag to gdb_test_multiple X-Gerrit-Change-Id: Ie42c97d5ab7acf6db351299ccd23a83540fe6e1a X-Gerrit-Change-Number: 36 X-Gerrit-ChangeURL: X-Gerrit-Commit: 4ccdfbec5028a56b9847ec2687b9139e1769ffc5 In-Reply-To: References: Reply-To: noreply@gnutoolchain-gerrit.osci.io, tdevries@suse.de, andrew.burgess@embecosm.com, luis.machado@linaro.org, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3 Message-Id: <20191024164406.00A8D204C9@gnutoolchain-gerrit.osci.io> The original change was created by Tom de Vries. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/36 ...................................................................... [gdb/testsuite] Add -wrap pattern flag to gdb_test_multiple Currently, in order to rewrite: ... gdb_test ... using gdb_test_multiple, we get: ... gdb_test_multiple { -re "\[\r\n\]*(?:)\[\r\n\]+$gdb_prompt $" { pass $gdb_test_name } } ... Add a '-wrap pattern flag to gdb_test_multiple, that wraps the regexp pattern as gdb_test wraps its message argument. This allows us to rewrite into the more compact: ... gdb_test_multiple { -re -wrap { pass $gdb_test_name } } ... Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-10-24 Tom de Vries * lib/gdb.exp (gdb_test_multiple): Add -wrap pattern flag. * gdb.reverse/step-precsave.exp: Rewrite gdb_test_multiple containing kfail using -wrap pattern flag and convenience variable gdb_test_name. Change-Id: Ie42c97d5ab7acf6db351299ccd23a83540fe6e1a --- M gdb/testsuite/ChangeLog M gdb/testsuite/gdb.reverse/step-precsave.exp M gdb/testsuite/lib/gdb.exp 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 12ef1fe..faee8e0 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2019-10-24 Tom de Vries + + * lib/gdb.exp (gdb_test_multiple): Add -wrap pattern flag. + * gdb.reverse/step-precsave.exp: Rewrite gdb_test_multiple containing + kfail using -wrap pattern flag and convenience variable + gdb_test_name. + 2019-10-24 Andrew Burgess * gdb.python/py-progspace.exp: Add tests for the diff --git a/gdb/testsuite/gdb.reverse/step-precsave.exp b/gdb/testsuite/gdb.reverse/step-precsave.exp index 72ee279..2cdceef 100644 --- a/gdb/testsuite/gdb.reverse/step-precsave.exp +++ b/gdb/testsuite/gdb.reverse/step-precsave.exp @@ -46,19 +46,15 @@ # This can take awhile. with_timeout_factor 20 { - set test "run to end of main" - set pass_pattern "Breakpoint .* end of main .*" - set kfail_pattern "Process record does not support instruction 0xc5 at.*" - set kfail2_pattern "Process record does not support instruction 0xfae64 at.*" - gdb_test_multiple "continue" $test { - -re "\[\r\n\]*(?:$pass_pattern)\[\r\n\]+$gdb_prompt $" { - pass $test + gdb_test_multiple "continue" "run to end of main" { + -re -wrap "Breakpoint .* end of main .*" { + pass $gdb_test_name } - -re "\[\r\n\]*(?:$kfail_pattern)\[\r\n\]+$gdb_prompt $" { - kfail "record/23188" $test + -re -wrap "Process record does not support instruction 0xc5 at.*" { + kfail "record/23188" $gdb_test_name } - -re "\[\r\n\]*(?:$kfail2_pattern)\[\r\n\]+$gdb_prompt $" { - kfail "record/25038" $test + -re -wrap "Process record does not support instruction 0xfae64 at.*" { + kfail "record/25038" $gdb_test_name } } } diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index fed46ec..6770741 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -764,6 +764,17 @@ # expected from $gdb_spawn_id. IOW, callers do not need to worry # about resetting "-i" back to $gdb_spawn_id explicitly. # +# In EXPECT_ARGUMENTS we can use a -wrap pattern flag, that wraps the regexp +# pattern as gdb_test wraps its message argument. +# This allows us to rewrite: +# gdb_test +# into: +# gdb_test_multiple { +# -re -wrap { +# pass $gdb_test_name +# } +# } +# proc gdb_test_multiple { command message user_code { prompt_regexp "" } } { global verbose use_gdb_stub global gdb_prompt pagination_prompt @@ -825,6 +836,7 @@ set patterns "" set expecting_action 0 set expecting_arg 0 + set wrap_pattern 0 foreach item $user_code subst_item $subst_code { if { $item == "-n" || $item == "-notransfer" || $item == "-nocase" } { lappend processed_code $item @@ -839,6 +851,10 @@ lappend processed_code $item continue } + if { $item == "-wrap" } { + set wrap_pattern 1 + continue + } if { $expecting_arg } { set expecting_arg 0 lappend processed_code $subst_item @@ -852,7 +868,14 @@ continue } set expecting_action 1 - lappend processed_code $subst_item + if { $wrap_pattern } { + # Wrap subst_item as is done for the gdb_test PATTERN argument. + lappend processed_code \ + "\[\r\n\]*(?:$subst_item)\[\r\n\]+$gdb_prompt $" + set wrap_pattern 0 + } else { + lappend processed_code $subst_item + } if {$patterns != ""} { append patterns "; " }