From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 123992 invoked by alias); 6 Oct 2019 08:24:59 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 123973 invoked by uid 89); 6 Oct 2019 08:24:59 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.5 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 06 Oct 2019 08:24:57 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 7BAC3ADDD; Sun, 6 Oct 2019 08:24:55 +0000 (UTC) Subject: Re: [PATCH] gdb/testsuite: Add gdb_test_multiple_name variable To: Andrew Burgess , gdb-patches References: <20191001172850.29867-1-andrew.burgess@embecosm.com> From: Tom de Vries Openpgp: preference=signencrypt Message-ID: <77c374d5-570d-6443-34c1-284b44d3a60b@suse.de> Date: Sun, 06 Oct 2019 08:24:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20191001172850.29867-1-andrew.burgess@embecosm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2019-10/txt/msg00174.txt.bz2 On 01-10-19 19:28, Andrew Burgess wrote: > diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp > index 3a1f053cf8a..a472650cc75 100644 > --- a/gdb/testsuite/lib/gdb.exp > +++ b/gdb/testsuite/lib/gdb.exp > @@ -719,10 +719,24 @@ proc gdb_internal_error_resync {} { > # > # gdb_test_multiple "print foo" "test foo" { > # -re "expected output 1" { > -# pass "print foo" > +# pass "test foo" > # } > # -re "expected output 2" { > -# fail "print foo" > +# fail "test foo" > +# } > +# } > +# > +# Within action elements you can also make use of the variable > +# gdb_test_multiple_name, this variable is setup automatically by > +# gdb_test_multiple, and contains the value of MESSAGE. You can then > +# write this, which is equivalent to the above: > +# I'd split up the first line, f.i. like so: ... # Within action elements you can also make use of the variable # gdb_test_multiple_name. This variable is setup automatically by # gdb_test_multiple, and contains the value of MESSAGE. ... > +# gdb_test_multiple "print foo" "test foo" { > +# -re "expected output 1" { > +# pass $gdb_test_multiple_name > +# } > +# -re "expected output 2" { > +# fail $gdb_test_multiple_name > # } > # } > # > @@ -1038,8 +1052,28 @@ proc gdb_test_multiple { command message user_code { prompt_regexp "" } } { > } > } > > + # Create gdb_test_multiple_name in the parent scope. If this > + # variable already exists, which is might if we have nested calls is -> it > + # to gdb_test_multiple, then preserve the old value, otherwise, > + # create a new variable in the parent scope. > + upvar gdb_test_multiple_name gdb_test_multiple_name > + if { [info exists gdb_test_multiple_name] } { > + set gdb_test_multiple_name_old "$gdb_test_multiple_name" > + } > + set gdb_test_multiple_name "$message" > + > set result 0 > set code [catch {gdb_expect $code} string] > + > + # Clean up the gdb_test_multiple_name variable. If we had a > + # previous value then restore it, otherwise, delete the variable > + # from the parent scope. > + if { [info exists gdb_test_multiple_name_old] } { > + set gdb_test_multiple_name "$gdb_test_multiple_name_old" > + } else { > + unset gdb_test_multiple_name > + } > + > if {$code == 1} { > global errorInfo errorCode > return -code error -errorinfo $errorInfo -errorcode $errorCode $string > Other than these nits, looks good to me. [ FWIW, Pedro's suggestion of using gdb_test_name instead of gdb_test_multiple_name is fine by me. ] Thanks, - Tom