From patchwork Thu Jun 11 20:21:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Seitz X-Patchwork-Id: 7128 Received: (qmail 79916 invoked by alias); 11 Jun 2015 20:22:01 -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 79904 invoked by uid 89); 11 Jun 2015 20:22:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 11 Jun 2015 20:21:59 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 56D53B6F20 for ; Thu, 11 Jun 2015 20:21:58 +0000 (UTC) Received: from valrhona.uglyboxes.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t5BKLv1F031456 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 11 Jun 2015 16:21:58 -0400 Message-ID: <5579EDE5.3080802@redhat.com> Date: Thu, 11 Jun 2015 13:21:57 -0700 From: Keith Seitz User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Sergio Durigan Junior CC: gdb-patches@sourceware.org Subject: Re: [RFA/testsuite] Regexp-escape command in capture_command_output References: <20150519221428.769.46872.stgit@valrhona.uglyboxes.com> <555BB8E7.4010906@redhat.com> <87twuevz8b.fsf@redhat.com> <5579EB36.9010500@redhat.com> <87zj46uhp1.fsf@redhat.com> In-Reply-To: <87zj46uhp1.fsf@redhat.com> X-IsSubscribed: yes On 06/11/2015 01:13 PM, Sergio Durigan Junior wrote: > > Aha, this is definitely not clear in the function comments. Would it be > possible to explicitly mention this there? > Sure thing! Keith From 52323e069647b7931ad17c906b5a77980cc8b5e9 Mon Sep 17 00:00:00 2001 From: Keith Seitz Date: Thu, 11 Jun 2015 13:15:17 -0700 Subject: [PATCH] Regexp-escape command in capture_command_output The test suite library procedure capture_command_output will fail if the given command contains any regexp characters, such as "+" or "*". I noticed this while writing a test which attempts to call: set xyz [capture_command_output "list +,-" ""] Because COMMAND is not escaped, gdb_test_multiple will generate a false FAIL. This simple fix corrects that oversight. I've also updated the comment to clarify that PREFIX is a regexp. testsuite/ChangeLog * lib/gdb.exp (capture_command_output): Regexp-escape `command' before using it in the matching pattern. Clarify that `prefix' is a regular expression. --- gdb/testsuite/lib/gdb.exp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) set output_string $expect_out(1,string) diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 41797e7..2796514 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -5196,12 +5196,15 @@ proc parse_args { argset } { # number of items expected to be passed into the procedure... } -# Capture the output of COMMAND in a string ignoring PREFIX; return that string. +# Capture the output of COMMAND in a string ignoring PREFIX (a regexp); +# return that string. + proc capture_command_output { command prefix } { global gdb_prompt global expect_out set output_string "" + set command [string_to_regexp $command] gdb_test_multiple "$command" "capture_command_output for $command" { -re "${command}\[\r\n\]+${prefix}(.*)\[\r\n\]+$gdb_prompt $" {