From patchwork Thu Oct 26 17:42:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 23866 Received: (qmail 2603 invoked by alias); 26 Oct 2017 17:42:37 -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 2524 invoked by uid 89); 26 Oct 2017 17:42:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2794 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 ESMTP; Thu, 26 Oct 2017 17:42:35 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 66CFF6869B for ; Thu, 26 Oct 2017 17:42:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 66CFF6869B Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=palves@redhat.com Received: from cascais.lan (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id E6E43600CA for ; Thu, 26 Oct 2017 17:42:33 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 6/6] Fix racy output matching in gdb.tui/tui-completion.exp Date: Thu, 26 Oct 2017 18:42:27 +0100 Message-Id: <1509039747-15026-7-git-send-email-palves@redhat.com> In-Reply-To: <1509039747-15026-1-git-send-email-palves@redhat.com> References: <1509039747-15026-1-git-send-email-palves@redhat.com> 'make check-read1 TESTS="gdb.tui/tui-completion.exp"' exposes this test race: (gdb) PASS: gdb.tui/completion.exp: set max-completions unlimited layout ^G asm next prev regs split src (gdb) FAIL: gdb.tui/completion.exp: completion of layout names: tab completion Quit (gdb) PASS: gdb.tui/completion.exp: completion of layout names: quit command input focus ^G cmd next prev src (gdb) FAIL: gdb.tui/completion.exp: completion of focus command: tab completion Quit This is caused by expecting "$gdb_prompt layout $". gdb_test_multiple's internal prompt regexp can match first if expect's internal buffer is filled with partial output. Fix that by splitting the gdb_test_multiple in question in two. Since the same problem/code appears twice in the file, factor out a common procedure. gdb/testsuite/ChangeLog: yyyy-mm-dd Pedro Alves * gdb.tui/tui-completion.exp (test_tab_completion): New procedure, factored out from ... (top level): ... here, and adjusted to avoid expecting beyond the prompt in a single gdb_test_multiple. --- gdb/testsuite/gdb.tui/completion.exp | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/gdb/testsuite/gdb.tui/completion.exp b/gdb/testsuite/gdb.tui/completion.exp index ac5d5f2..f53a244 100644 --- a/gdb/testsuite/gdb.tui/completion.exp +++ b/gdb/testsuite/gdb.tui/completion.exp @@ -22,12 +22,20 @@ if {[skip_tui_tests] || [target_info exists gdb,nointerrupts]} { gdb_test_no_output "set max-completions unlimited" -with_test_prefix "completion of layout names" { +# TAB-complete INPUT_LINE, and expect EXPECTED_RE as completion match +# output. +proc test_tab_completion {input_line expected_re} { + global gdb_prompt + set test "tab completion" - send_gdb "layout\t\t\t" + send_gdb "$input_line\t\t\t" gdb_test_multiple "" "$test" { - -re "asm *next *prev *regs *split *src *\r\n$gdb_prompt layout $" { - pass "$test" + -re "$expected_re\r\n$gdb_prompt " { + gdb_test_multiple "" "$test" { + -re "^$input_line$" { + pass "$test" + } + } } } send_gdb "\003" @@ -39,20 +47,10 @@ with_test_prefix "completion of layout names" { } } -with_test_prefix "completion of focus command" { - set test "tab completion" - send_gdb "focus \t\t" - gdb_test_multiple "" "$test" { - -re "cmd *next *prev *src *\r\n$gdb_prompt focus $" { - pass "$test" - } - } +with_test_prefix "completion of layout names" { + test_tab_completion "layout" "asm *next *prev *regs *split *src *" +} - send_gdb "\003" - set test "quit command input" - gdb_test_multiple "" "$test" { - -re "$gdb_prompt $" { - pass "$test" - } - } +with_test_prefix "completion of focus command" { + test_tab_completion "focus" "cmd *next *prev *src *" }