From patchwork Thu Oct 26 17:42:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 23862 Received: (qmail 2055 invoked by alias); 26 Oct 2017 17:42:34 -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 2001 invoked by uid 89); 26 Oct 2017 17:42:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= 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:32 +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 115336869F for ; Thu, 26 Oct 2017 17:42:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 115336869F 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 7DE4C600CA for ; Thu, 26 Oct 2017 17:42:30 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 2/6] Fix racy output matching in gdb.base/completion.exp Date: Thu, 26 Oct 2017 18:42:23 +0100 Message-Id: <1509039747-15026-3-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> Testing with: $ make check-read1 TESTS="gdb.base/completion.exp" Exposes a testcase bug that can result in racy fails: FAIL: gdb.base/completion.exp: command-name completion limiting using tab character ERROR: Undefined command "". FAIL: gdb.base/completion.exp: symbol-name completion limiting using tab character FAIL: gdb.base/completion.exp: symbol-name completion limiting using complete command testsuite/gdb.log shows: (gdb) PASS: gdb.base/completion.exp: set max-completions 5 p^G passcount path print print-object printf *** List may be truncated, max-completions reached. *** (gdb) FAIL: gdb.base/completion.exp: command-name completion limiting using tab character pcomplete p Undefined command: "pcomplete". Try "help". (gdb) ERROR: Undefined command "". The problem is that the expect buffer can get filled with partial output that ends in the gdb prompt, and so the default FAIL inside gdb_test_multiple matches. Fix that by splitting the gdb_test_multiple in two stages. Since that is done in more than one place in the testcase, move the otherwise duplicate code to helper procedures. gdb/testsuite/ChangeLog: yyyy-mm-dd Pedro Alves * gdb.base/completion.exp (ignore_and_resync, test_tab_complete): New procedures, factored out from ... (top level): ... here, and adjusted to avoid expecting beyond the prompt in one go. --- gdb/testsuite/gdb.base/completion.exp | 86 ++++++++++++++--------------------- 1 file changed, 34 insertions(+), 52 deletions(-) diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp index f03bfc3e..9c7c17a 100644 --- a/gdb/testsuite/gdb.base/completion.exp +++ b/gdb/testsuite/gdb.base/completion.exp @@ -863,36 +863,45 @@ gdb_test "complete break $srcfile:ma" "break\.c:main" gdb_test_no_output "set max-completions 5" -set test "command-name completion limiting using tab character" -send_gdb "p\t" -gdb_test_multiple "" "$test" { - -re "^p\\\x07$" { - send_gdb "\t" - gdb_test_multiple "" "$test" { - -re "List may be truncated, max-completions reached.*\r\n$gdb_prompt p$" { - # Complete the command and ignore the output to resync - # gdb for the next test. - send_gdb "\n" - gdb_test_multiple "" "$test" { - -re "$gdb_prompt $" { - pass "$test" - } +proc ignore_and_resync {cmd result test} { + global gdb_prompt + + gdb_test_multiple "" "$test" { + -re "^${cmd}$" { + # Complete the command and ignore the output + # to resync gdb for the next test. + send_gdb "\n" + gdb_test_multiple "" "$test" { + -re "$gdb_prompt $" { + $result $test } } - -re "$gdb_prompt p$" { - # Complete the command and ignore the output to resync - # gdb for the next test. - send_gdb "\n" - gdb_test_multiple "" "$test" { - -re "$gdb_prompt $" { - fail "$test" - } + } + } +} + +proc test_tab_complete {cmd test} { + global gdb_prompt + + send_gdb "${cmd}\t" + gdb_test_multiple "" "$test" { + -re "^${cmd}\\\x07$" { + send_gdb "\t" + gdb_test_multiple "" "$test" { + -re "List may be truncated, max-completions reached.*\r\n$gdb_prompt " { + ignore_and_resync $cmd pass $test + } + -re "$gdb_prompt " { + ignore_and_resync $cmd fail $test } } - } + } } } +test_tab_complete "p" \ + "command-name completion limiting using tab character" + set test "command-name completion limiting using complete command" send_gdb "complete p\n" gdb_test_multiple "" "$test" { @@ -903,35 +912,8 @@ gdb_test_multiple "" "$test" { gdb_test_no_output "set max-completions 3" -set test "symbol-name completion limiting using tab character" -send_gdb "p marker\t" -gdb_test_multiple "" "$test" { - -re "^p marker\\\x07$" { - send_gdb "\t" - gdb_test_multiple "" "$test" { - -re "List may be truncated, max-completions reached.*\r\n$gdb_prompt p marker$" { - # Complete the command and ignore the output to resync - # gdb for the next test. - send_gdb "\n" - gdb_test_multiple "" "$test" { - -re "$gdb_prompt $" { - pass "$test" - } - } - } - -re "$gdb_prompt p marker$" { - # Complete the command and ignore the output to resync - # gdb for the next test. - send_gdb "\n" - gdb_test_multiple "" "$test" { - -re "$gdb_prompt $" { - fail "$test" - } - } - } - } - } -} +test_tab_complete "p marker" \ + "symbol-name completion limiting using tab character" set test "symbol-name completion limiting using complete command" send_gdb "complete p mark\n"