From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 0D83F3858C5F for ; Fri, 4 Aug 2023 16:10:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0D83F3858C5F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691165403; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=QFsvawnO+NEq7TzUF60vwrJHz5Lyzalj3BGLTc0Q9v0=; b=WmQsUEpXYVW4uaa49C+JkHX/YWkD+1xc4j2nsV0RnRp/9/2jxfQrWtsfNbc54tSYuvueIR 9hMDwSZzK9NWHI11VLpIpa4wW2n83jZCdXZ+psTBTr/g/06i7ruigVKbkbhkOObFZSSEQh 6qOPU8LZP59xgwoLUXtjs3FrGAfKi0g= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-481-1yR_q1zhPue_6uoGSiig3w-1; Fri, 04 Aug 2023 12:10:01 -0400 X-MC-Unique: 1yR_q1zhPue_6uoGSiig3w-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2F2E580006E for ; Fri, 4 Aug 2023 16:10:01 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.226.102]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AA15840C206F; Fri, 4 Aug 2023 16:10:00 +0000 (UTC) From: Bruno Larsen To: gdb-patches@sourceware.org Cc: Bruno Larsen Subject: [PATCH v2] gdb/testsuite: fix completion tests when using READ1 Date: Fri, 4 Aug 2023 18:09:24 +0200 Message-ID: <20230804160924.1338942-1-blarsen@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: The commit a3da2e7e550c4fe79128b5e532dbb90df4d4f418 has introduced regressions when testing using the READ1 mechanism. The reason for that is the new failure path in proc test_gdb_complete_tab_unique, which looks for GDB suggesting more than what the test inputted, but not the correct answer, followed by a white space. Consider the following case: int foo(int bar, int baz); Sending the command "break foo" to GDB will return break foo(int, int) which easily fits the buffer in normal testing, so everything works, but when reading one character at a time, the test will find the partial "break foo(int, " and assume that there was a mistake, so we get a spurious FAIL. To fix this issue, the new code looks at the partial response, and the test only fails if the received characters are not part of the expected pattern. --- gdb/testsuite/lib/completion-support.exp | 33 ++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/lib/completion-support.exp b/gdb/testsuite/lib/completion-support.exp index ea73c3bb367..bef4d7f1ed7 100644 --- a/gdb/testsuite/lib/completion-support.exp +++ b/gdb/testsuite/lib/completion-support.exp @@ -71,6 +71,16 @@ proc make_cmd_completion_list_re { cmd_prefix completion_list start_quote_char e return $completion_list_re } +# Make a list of the characters in $PATTERN that come after $PREFIX. +# this assumes that PATTERN does start with PREFIX and is at least +# one character longer. + +proc make_optional_partial_complete { prefix pattern } { + set pattern [string range $pattern [string length $prefix]+1 end] + + return [split $pattern ""] +} + # Clear the input line. proc clear_input_line { test } { @@ -112,13 +122,32 @@ proc test_gdb_complete_tab_unique { input_line complete_line_re append_char_re } set test "tab complete \"$input_line\"" send_gdb "$input_line\t" set partial_complete [string_to_regexp $input_line] + set partial_expected [make_optional_partial_complete $input_line $complete_line_re] + set partial_size [array size $partial_expected] set res 1 gdb_test_multiple "" "$test" { -re "^$complete_line_re$append_char_re$" { pass "$test" } - -re "$partial_complete\[^ \]+ $" { - fail "$test" + -re "${partial_complete}(\[^ \]+) $" { + set captured [split $expect_out(1,string) ""] + set captured_size [array size $captured] + if { $captured_size >= $partial_size } { + set unexpected 0 + for { set i 0 } { $i < $captured_size } { incr i } { + if { $captured($i) != $partial_expected($i) } { + set unexpected 1 + break + } + } + if { $unexpected } { + fail "$test" + set res -1 + } + } else { + fail "$test" + set res -1 + } } timeout { fail "$test (timeout)" -- 2.41.0