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 AD28A3857712 for ; Fri, 13 Oct 2023 15:27:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AD28A3857712 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=1697210822; 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=iqe7HgrVNQNeXtOY1QyKSJ+W0DcJW6E7irBmyi+rNQGmgcmm00JRA23Xlp/cl09Aqyv0YH EAiX0Myxi2d7rcTBv51+R4AaOqqZ689dA327jfuBjW/G2y3+18u/MAxhfFChAOeBAX7GAb gtW6s7/gMY/aXAh/shpEmSHmfx0Vzmk= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-251-5UjVDWhHNUGH858u5rJJOA-1; Fri, 13 Oct 2023 11:26:49 -0400 X-MC-Unique: 5UjVDWhHNUGH858u5rJJOA-1 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-53db360296eso1929770a12.3 for ; Fri, 13 Oct 2023 08:26:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697210808; x=1697815608; 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=PmFEwXxzshLMfk3j6YJT9JhYJFgLq7nx+9QKmur+rSR09E4efnzsoipO3k+EMDUJ1s 9U/z7a3xAQxQWMEd9NNJ/zsKVBsLtLpidjCHp9hX3yt9sF/RiaBkqduTsmrS70jVU4l2 vQ8TGtMqz2L7VvfWahPrMuDDQnMTazO+ItDngHnU339ABuVrJgnK62zrllGbTFnPZ9UX yBGmyGM7K8p0IZ5AmANj9gSXohMCXKkLKGJaMsRIfLQhbB24kN7kVhm8WQFwX4oSzhLp BlBzLb0YxOFn9o34CwG2pEmCKXnMJdv/tGYsxcj5Skt4M0WdJ9LrTL5Av2ce9uaZutGD WPOQ== X-Gm-Message-State: AOJu0Ywhj0OquulfRSwtUcWQv+WzwWbDe8DDTIdbXJLyM1Ai/23webYt ZNZFLy9ECBJ3Tay5MoapE384YsSrs2vrCsSk9BWEyKvpsTvAEr2xvfXWvaHykoz2tiVlfswF8ZO Tg7eB30IHOXSn0Z5JbnWSshEbuwBgzA== X-Received: by 2002:a05:6402:27ce:b0:53e:34c5:ad8e with SMTP id c14-20020a05640227ce00b0053e34c5ad8emr3082379ede.19.1697210807795; Fri, 13 Oct 2023 08:26:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGEB1asGJIN18G8TgizrN1SQkzO3G1AHvFZgfUDzivBrq4Z8EIrqYhdQriSCfuNrlHU/zLcGA== X-Received: by 2002:a05:6402:27ce:b0:53e:34c5:ad8e with SMTP id c14-20020a05640227ce00b0053e34c5ad8emr3082366ede.19.1697210807475; Fri, 13 Oct 2023 08:26:47 -0700 (PDT) Received: from [192.168.0.129] (ip-94-112-227-180.bb.vodafone.cz. [94.112.227.180]) by smtp.gmail.com with ESMTPSA id ch1-20020a0564021bc100b0053e07fe8d98sm2401228edb.79.2023.10.13.08.26.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 13 Oct 2023 08:26:47 -0700 (PDT) Message-ID: Date: Fri, 13 Oct 2023 17:26:46 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: [PINGv2][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=-9.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_BARRACUDACENTRAL,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 > } >