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 2516A3858D20 for ; Thu, 14 Sep 2023 13:02:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2516A3858D20 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=1694696539; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AyFsvidBhvt/ASVxHII2Xa07oxZAHX8Xa9iNfj6DPPg=; b=eN5sadxc64+ESdnvidGB1Z+gM5fW1w4qPrhz6fVrarHvdpaLfu0XE/PSh00oiUdTvmJ5Qg L+O7r0obQZN6Cq4cKQ/SMuIQcTBXspo8E7mcnT24Sjsk1+tojl3itUGhtz78diYiYQYMDL VdYf7ki+JXgrggLLZzXl4zotS1nxvv4= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-695-j-oMe4E5PFi8R5E46LVIbg-1; Thu, 14 Sep 2023 09:02:18 -0400 X-MC-Unique: j-oMe4E5PFi8R5E46LVIbg-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-98e40d91fdfso75866666b.3 for ; Thu, 14 Sep 2023 06:02:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694696537; x=1695301337; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=AyFsvidBhvt/ASVxHII2Xa07oxZAHX8Xa9iNfj6DPPg=; b=T1HReHgVjMjjw6b81Q0QE0Z8P3Azb+EKNAp9m9eKygRVgJBnp8VWfBg/F3LY63jtd3 eHkhMwxKFop2T3MT6Syj3zkvXIYrvhLsPdkJVzkYn7qeJdoXYoE4uDDGnmDBs6SfPsu9 5kENmUK3ht1GcqcLGcd24opAxdW4y6hiC2BAPUMWj8+4oiTUfg9/00E+Zm0ghfnNamb6 CsmFynOUj2S5c2XAk3Dq9V4j8qw5IZxSD++kbCM5wTPd3R79dBSX9/IVCf0xyyC2+7Dn gIHt6jtHI1XYWGKcjt/jypiFPZj/EzudHv6FTMoJ/f6Hw7KTuHN3ycwFq+ul5hyzznox /0jQ== X-Gm-Message-State: AOJu0YzNna0yXz//CzRp9x9m+1diDRASPwN6CtFsqY7ulsYI1nnhvvgR w4x38o9WwHFdBUw7zKIcSr555JA7TPXAUTorKKri0Ig214zSKgmJk8XbmgPm0ynXJemchqScltS uSuEw9Rd2A6MrqeSII7xefYJGVVw8GQ== X-Received: by 2002:a17:906:24f:b0:9ad:a46c:2936 with SMTP id 15-20020a170906024f00b009ada46c2936mr4067618ejl.8.1694696537300; Thu, 14 Sep 2023 06:02:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEv7KlXlHftfyjM9ATW7NO4cgbtTM93n1ujaR0gY/gOsMbSv03F2rloNeAFvOqAULlHEklpnQ== X-Received: by 2002:a17:906:24f:b0:9ad:a46c:2936 with SMTP id 15-20020a170906024f00b009ada46c2936mr4067598ejl.8.1694696536917; Thu, 14 Sep 2023 06:02:16 -0700 (PDT) Received: from [10.43.2.16] (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id h27-20020a170906111b00b009a1fef32ce6sm1000336eja.177.2023.09.14.06.02.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 14 Sep 2023 06:02:15 -0700 (PDT) Message-ID: <420fe851-d357-f117-1486-a457cb2a4e99@redhat.com> Date: Thu, 14 Sep 2023 15:02:14 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: [PING][PATCH v3] gdb/testsuite: fix completion tests when using READ1 To: Guinevere Larsen , Bruno Larsen via Gdb-patches References: <20230828113026.76323-1-blarsen@redhat.com> From: Guinevere Larsen In-Reply-To: <20230828113026.76323-1-blarsen@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.7 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: Ping! -- Cheers, Guinevere Larsen She/Her/Hers On 28/08/2023 13:30, Guinevere Larsen wrote: > 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. > > That change was added because we wanted to avoid forcing a completion > failure to fail through timeout, which it had to do because there is no > way to verify that the output is done, mostly because when I was trying > to solve a different problem I kept getting reading errors and testing > completion was frustrating. > > This commit implements a better way to avoid that frustration, by first > testing gdb's complete command and only if that passes we will test tab > completion. The difference is that when testing with the complete > command, we can tell when the output is over when we receive the GDB > prompt again, so we don't need to rely on timeouts. With this, the > change to test_gdb_complete_tab_unique has been removed as that test > will only be run and fail in the very unlikely scenario that tab > completion is different than command completion. > --- > gdb/testsuite/lib/completion-support.exp | 31 +++++++++++++++--------- > 1 file changed, 20 insertions(+), 11 deletions(-) > > diff --git a/gdb/testsuite/lib/completion-support.exp b/gdb/testsuite/lib/completion-support.exp > index fdc512838c3..56c0eee8e1d 100644 > --- a/gdb/testsuite/lib/completion-support.exp > +++ b/gdb/testsuite/lib/completion-support.exp > @@ -111,15 +111,11 @@ 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 res 1 > gdb_test_multiple "" "$test" { > -re "^$complete_line_re$append_char_re$" { > pass "$test" > } > - -re "$partial_complete\[^ \]+ $" { > - fail "$test" > - } > timeout { > fail "$test (timeout)" > set res -1 > @@ -194,17 +190,21 @@ proc test_gdb_complete_cmd_none { line } { > proc test_gdb_complete_cmd_unique { input_line complete_line_re } { > global gdb_prompt > > + set res 0 > set cmd "complete $input_line" > set cmd_re [string_to_regexp $cmd] > set test "cmd complete \"$input_line\"" > gdb_test_multiple $cmd $test { > -re "^$cmd_re\r\n$complete_line_re\r\n$gdb_prompt $" { > pass $test > + set res 1 > } > -re "$gdb_prompt $" { > fail "$test" > + set res -1 > } > } > + return $res > } > > # Test that completing "CMD_PREFIX + COMPLETION_WORD" with the > @@ -263,12 +263,6 @@ proc test_gdb_complete_none { input_line } { > > proc test_gdb_complete_unique_re { input_line complete_line_re {append_char " "} {max_completions 0}} { > set append_char_re [string_to_regexp $append_char] > - if { [readline_is_used] } { > - if { [test_gdb_complete_tab_unique $input_line $complete_line_re \ > - $append_char_re] == -1 } { > - return -1 > - } > - } > > # Trim COMPLETE LINE, for the case we're completing a command with leading > # whitespace. Leading command whitespace is discarded by GDB. > @@ -288,7 +282,22 @@ proc test_gdb_complete_unique_re { input_line complete_line_re {append_char " "} > "\r\n$input_line_re $max_completion_reached_msg_re" > } > > - test_gdb_complete_cmd_unique $input_line $expected_output_re > + # First test completion with the command, then with tab. > + # It is done in this order because cmd_complete knows when the output > + # from GDB is over, so it can fail without requiring a timeout, which > + # speeds up testing if necessary. > + > + if { [test_gdb_complete_cmd_unique $input_line\ > + $expected_output_re] == -1 } { > + return -1 > + } > + > + if { [readline_is_used] } { > + if { [test_gdb_complete_tab_unique $input_line $complete_line_re \ > + $append_char_re] == -1 } { > + return -1 > + } > + } > return 1 > } >