public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Simon Marchi <simark@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] gdb/testsuite: get_set_option_choices: expect \r\n after each item
Date: Tue, 15 Nov 2022 15:48:18 +0000 (GMT)	[thread overview]
Message-ID: <20221115154818.E27923898505@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7e21379963c8be351a03693ce64d0a597ea0dbd7

commit 7e21379963c8be351a03693ce64d0a597ea0dbd7
Author: Simon Marchi <simon.marchi@polymtl.ca>
Date:   Mon Nov 14 10:10:04 2022 -0500

    gdb/testsuite: get_set_option_choices: expect \r\n after each item
    
    I get some random failures since commit 8d45c3a82a0e ("[gdb/testsuite]
    Set completions to unlimited in get_set_option_choices"), which can be
    reproduced with:
    
        $ make check-read1 TESTS="gdb.base/parse_number.exp"
    
    For instance:
    
        set architecture A^M
        Ambiguous item "A".^M
        (gdb) FAIL: gdb.base/parse_number.exp: arch=A: set architecture A
    
    The problem is the regexp in get_set_option_choices, it is possible that
    is only matches part of a completion result.  With check-read1, that is
    always one letter.
    
    Fix this by expecting the \r\n at the end of the line, so we only match
    entire results.  Use ^ in match patterns to ensure we don't miss any
    output.
    
    Approved-By: Tom de Vries <tdevries@suse.de>
    Change-Id: Ib1733737feab7dde0f7095866e089081a891054e

Diff:
---
 gdb/testsuite/lib/gdb.exp | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 0543da31da6..698b3f4bd79 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -9156,11 +9156,16 @@ proc get_set_option_choices {set_cmd} {
 
     with_set max-completions unlimited {
 	gdb_test_multiple $cmd $test {
-	    -re "\r\n$set_cmd (\[^\r\n\]+)" {
+	    -re "^[string_to_regexp $cmd]\r\n" {
+		exp_continue
+	    }
+
+	    -re "^$set_cmd (\[^\r\n\]+)\r\n" {
 		lappend values $expect_out(1,string)
 		exp_continue
 	    }
-	    -re -wrap "" {
+
+	    -re "^$::gdb_prompt $" {
 		pass $gdb_test_name
 	    }
 	}

                 reply	other threads:[~2022-11-15 15:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221115154818.E27923898505@sourceware.org \
    --to=simark@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).