From patchwork Mon Jul 29 09:38:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 33839 Received: (qmail 118765 invoked by alias); 29 Jul 2019 09:38:50 -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 118616 invoked by uid 89); 29 Jul 2019 09:38:50 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, SPF_PASS autolearn=ham version=3.3.1 spammy=stephen, Verify, hooks, $expect_out 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; Mon, 29 Jul 2019 09:38:48 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 261B9AF40; Mon, 29 Jul 2019 09:38:46 +0000 (UTC) Subject: [committed][gdb/testsuite] Fix gdb.base/define.exp with check-read1 To: Richard Bunt , "gdb-patches@sourceware.org" Cc: nd References: From: Tom de Vries Openpgp: preference=signencrypt Message-ID: Date: Mon, 29 Jul 2019 11:38:45 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: X-IsSubscribed: yes [ was: Re: [PATCH v2] Restore original GDB prompt in define.exp ] On 09-07-19 09:17, Richard Bunt wrote: > Restore original GDB prompt in define.exp > > define.exp will fail on a GDB which has set a custom prompt to identify > itself. This is because the test resets the prompt to a hard coded > "(gdb)" but then verifies the success of this against the value in > $gdb_prompt, which is set to the custom prompt. > > The original approach to fix this involved resetting the prompt to > $gdb_prompt rather than a hard coded "(gdb)". However it was noted during > review that $gdb_prompt is a regular expression rather than a string. > This is problematic because in general the prompt would be reset to a > regular expression rather than an instance of a string accepted by said > regular expression. > > The fix used in commit avoids the above issue by capturing the literal > prompt from running "show prompt" and uses this literal to restore the > previous prompt. > > Regression tested with GCC 7.3.0 on x86_64, ppc64le, aarch64. > > gdb/testsuite/ChangeLog: > > 2019-07-04 Richard Bunt > Stephen Roberts > > * gdb.base/define.exp: Restore original prompt. > > --- > gdb/testsuite/gdb.base/define.exp | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/gdb/testsuite/gdb.base/define.exp b/gdb/testsuite/gdb.base/define.exp > index 0590da9..e8508b8 100644 > --- a/gdb/testsuite/gdb.base/define.exp > +++ b/gdb/testsuite/gdb.base/define.exp > @@ -283,6 +283,15 @@ gdb_test_multiple "define target hookpost-testsuite" "" { > > gdb_test "target testsuite" "one\r\nhello\r\ntwo" "target testsuite with hooks" > > +# Save the GDB prompt so it can be restored to the original value later. > +set prior_prompt "" > +gdb_test_multiple "show prompt" "save gdb_prompt" { > + -re "Gdb's prompt is \"($gdb_prompt) \"\.\[\r\n\]*$gdb_prompt $" { > + set prior_prompt $expect_out(1,string) > + pass "save gdb_prompt" > + } > +} > + > # This is a quasi-define command: Verify that the user can redefine > # GDB's gdb_prompt. > # > @@ -292,7 +301,7 @@ gdb_test_multiple "set prompt \\(blah\\) " "set gdb_prompt" { > } > } > > -gdb_test_multiple "set prompt \\(gdb\\) " "reset gdb_prompt" { > +gdb_test_multiple "set prompt $prior_prompt " "reset gdb_prompt" { > -re "$gdb_prompt $" { > pass "reset gdb_prompt" > } > This seems to have caused a check-read1 regression. Fixed by patch below, committed to trunk. Thanks, - Tom [gdb/testsuite] Fix gdb.base/define.exp with check-read1 When running gdb.base/define.exp with check-read1, we get: ... show prompt^M Gdb's prompt is "(gdb) ".^M (gdb) PASS: gdb.base/define.exp: save gdb_prompt set prompt \(blah\) ^M (blah) PASS: gdb.base/define.exp: set gdb_prompt set prompt (gdb) PASS: gdb.base/define.exp: reset gdb_prompt ^M (gdb) FAIL: gdb.base/define.exp: define do-define ... The problem is that the "$gdb_prompt $" regexp here: ... gdb_test_multiple "set prompt $prior_prompt " "reset gdb_prompt" { -re "$gdb_prompt $" { pass "reset gdb_prompt" } } ... triggers for the echoing of the command "set prompt $prior_prompt " rather than for the prompt after the command has executed. Fix this by changing the regexp to "\r\n$gdb_prompt $". Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-07-29 Tom de Vries * gdb.base/define.exp: Add "\r\n" to "reset gdb_prompt" regexp. --- gdb/testsuite/gdb.base/define.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.base/define.exp b/gdb/testsuite/gdb.base/define.exp index e8508b8728..d7d4fd03ba 100644 --- a/gdb/testsuite/gdb.base/define.exp +++ b/gdb/testsuite/gdb.base/define.exp @@ -302,7 +302,7 @@ gdb_test_multiple "set prompt \\(blah\\) " "set gdb_prompt" { } gdb_test_multiple "set prompt $prior_prompt " "reset gdb_prompt" { - -re "$gdb_prompt $" { + -re "\r\n$gdb_prompt $" { pass "reset gdb_prompt" } }