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.133.124]) by sourceware.org (Postfix) with ESMTPS id 1C0BD3858D20 for ; Tue, 2 May 2023 11:13:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1C0BD3858D20 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=1683026019; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=wuGwex22UtV6tahX5HG17YW9K8OcYMMvU0epJtCSfpA=; b=gwqXX04qxQER/AAUn4Yav1/YlckuQECvO/BZQERuxyZj7WJvXGbgXAukAgXpTLQPx70qng OUhNV9uMrIvH9IaupniiM6TwVuHkVKr47sDf0Oxs8Sjvr5vZ09Hde8PQ3nM8T86u0m3HQh wV+qgnPmp9/Q22S0MK+kUCPgYcKsodo= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-638-axVqbpU5MxyDqoLNjVnFLw-1; Tue, 02 May 2023 07:13:38 -0400 X-MC-Unique: axVqbpU5MxyDqoLNjVnFLw-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-306311a2b99so616224f8f.1 for ; Tue, 02 May 2023 04:13:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683026017; x=1685618017; h=mime-version:message-id:date:references:in-reply-to:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wuGwex22UtV6tahX5HG17YW9K8OcYMMvU0epJtCSfpA=; b=Piiqjuw3rnuv9ym+o4yu2MaK9Mnjo8ESPVk+EA/+2suNOrlV3yOo7wQzaVLHq83GTK iAnM6aWCcdGl9rT5ESCuVqCJu8a+cjA4AndyHUU5YKxVLqCo+QNdrkIZehb84zXI70Z3 da93qKp2ckyIRkXdsEZ49/XNWdaF/XH3CNmrxVdkMeMgDA0DI/1mkZC94pTeC8k2kgRI e7K/kQO26nCSIUw0V9ksYLtRDVCAGVGrOGabj2dzFx2364dBaswc6pPRkeQPRE2Dd17n q9nzYY9TPijQx7h9U8YK/eG6oeThRtMEiOpHeBCQVgBHLGyO0otSEYKbkSCpmVKG+YKs FC9g== X-Gm-Message-State: AC+VfDxSaUF0nAbz5YAVEozClXdVzgrG3wDcV1zVO7lrmZPvcUBNdTZ0 RkZpucCaxXr2Vq4MbRXYXKqOyP4zEoa4+B2Bly6nQXizjCsW7yd6z2LxWxqnMpylX2ZLUj/v3hm XnMOM/mMid/R482XGI89Jdsl7JYkD5w== X-Received: by 2002:adf:f1cf:0:b0:2f9:4fe9:74e7 with SMTP id z15-20020adff1cf000000b002f94fe974e7mr11331023wro.70.1683026017096; Tue, 02 May 2023 04:13:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ftCHerm9sj2uGXYpApzrs9hOqz1jvz1J8ra7YKgWq85TzpFF0cRO8WDDKPCOeXB7fkA4mqA== X-Received: by 2002:adf:f1cf:0:b0:2f9:4fe9:74e7 with SMTP id z15-20020adff1cf000000b002f94fe974e7mr11331011wro.70.1683026016641; Tue, 02 May 2023 04:13:36 -0700 (PDT) Received: from localhost (11.72.115.87.dyn.plus.net. [87.115.72.11]) by smtp.gmail.com with ESMTPSA id f12-20020a5d4dcc000000b0030630de6fbdsm3862823wru.13.2023.05.02.04.13.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 May 2023 04:13:36 -0700 (PDT) From: Andrew Burgess To: Tom de Vries , gdb-patches@sourceware.org Subject: Re: [PATCH 4/5] gdb/testsuite: change newline patterns used in gdb_test In-Reply-To: <14333280-6e66-0cc5-7e34-46176588ee37@suse.de> References: <464e64e3a3483c228f0a73c778bcaf79e4595abd.1680293848.git.aburgess@redhat.com> <7552d3ad-c148-f0ea-b219-dd2d9458de0c@suse.de> <871qk09l5j.fsf@redhat.com> <14333280-6e66-0cc5-7e34-46176588ee37@suse.de> Date: Tue, 02 May 2023 12:13:35 +0100 Message-ID: <87ttwv7zq8.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain 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,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE 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: Tom de Vries writes: > On 5/1/23 16:33, Andrew Burgess wrote: >> Tom de Vries writes: >> >>> On 3/31/23 22:20, Andrew Burgess via Gdb-patches wrote: >>>> This commit makes two changes to how we match newline characters in >>>> the gdb_test proc. >>> >>> Hi, >>> >>> the -wrap used in gdb_test_multiple is defined in terms of gdb_test >>> semantics, but it doesn't seem to have been updated to match the new >>> behaviour in gdb_test. >>> >>> I've filed a PR about this regression ( >>> https://sourceware.org/bugzilla/show_bug.cgi?id=30403 ). >> >> Sorry for any problems caused. I'm not working today, but if this has >> not been addressed, I'll look at this on Tuesday. > > AFAIU it's a silent regression, so there are no problems in term of > FAILs, it's just that more work is required. > > FWIW, I think the root cause for introducing this regression silently is > that we try to implement the same thing in two different locations, and > it's just easy for things to get out of sync. I recently fixed > something similar in commit 4fa173cfd79 ("[gdb/testsuite] Fix -wrap in > presence of -prompt in gdb_test_multiple"), that's why I noticed it. So I believe the patch below brings gdb_test_multiple with '-wrap' back into line with gdb_test. I also updated a couple of other places that used the same (old) gdb_test pattern. There were nowhere near as many regressions with this change as with gdb_test. Let me know what you think. Thanks, Andrew --- commit 807658d7a9a32632554006e822ae8645cc4cabb6 Author: Andrew Burgess Date: Tue May 2 10:56:55 2023 +0100 gdb/testsuite: more newline pattern cleanup After this commit: commit e2f620135d92f7cd670af4e524fffec7ac307666 Date: Thu Mar 30 13:26:25 2023 +0100 gdb/testsuite: change newline patterns used in gdb_test It was pointed out in PR gdb/30403 that the same patterns can be found in other lib/gdb.exp procs and that it would probably be a good idea if these procs remained in sync with gdb_test. Actually, the bug specifically calls out gdb_test_multiple when using with '-wrap', but I found a couple of other locations in gdb_continue_to_breakpoint, gdb_test_multiline, get_valueof, and get_local_valueof. In all these locations one or both of the following issues are addressed: 1. A leading pattern of '[\r\n]*' is pointless. If there is a newline it will be matched, but if there is not then the testsuite doesn't care. Also, as expect is happy to skip non-matched output at the start of a pattern, if there is a newline expect is happy to skip over it before matching the rest. As such, this leading pattern is removed. 2. Using '\[\r\n\]*$gdb_prompt' means that we will swallow unexpected blank lines at the end of a command's output, but also, if the pattern from the test script ends with a '\r', '\n', or '.' then these will partially match the trailing newline, with the remainder of the newline matched by the pattern from gdb.exp. This split matching doesn't add any value, it's just something that has appeared as a consequence of how gdb.exp was originally written. In this case the '\[\r\n\]*' is replaced with '\r\n'. I've rerun the testsuite and fixed the regressions that I saw, these were places where GDB emits a blank line at the end of the command output, which we now need to explicitly match in the test script, this was for: gdb.dwarf2/dw2-out-of-range-end-of-seq.exp gdb.guile/guile.exp gdb.python/python.exp Or a location where the test script was matching part of the newline sequence, while gdb.exp was previously matching the remainder of the newline sequence. Now we rely on gdb.exp to match the complete newline sequence, this was for: gdb.base/commands.exp Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30403 diff --git a/gdb/testsuite/gdb.base/commands.exp b/gdb/testsuite/gdb.base/commands.exp index ec2015ebef5..36918ed1a3f 100644 --- a/gdb/testsuite/gdb.base/commands.exp +++ b/gdb/testsuite/gdb.base/commands.exp @@ -725,7 +725,7 @@ maintenance deprecate set qqq_aaa" proc_with_prefix deprecated_command_alias_help_test {} { gdb_test_multiline "define real_command" \ - "define real_command" "End with a line saying just \"end\".." \ + "define real_command" "End with a line saying just \"end\"\\." \ "print 1" "" \ "end" "" diff --git a/gdb/testsuite/gdb.dwarf2/dw2-out-of-range-end-of-seq.exp b/gdb/testsuite/gdb.dwarf2/dw2-out-of-range-end-of-seq.exp index bd3ea5b5d54..d2c28a87923 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-out-of-range-end-of-seq.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-out-of-range-end-of-seq.exp @@ -88,7 +88,7 @@ gdb_test_multiple "maint info line-table $srcfile$" $test { -re -wrap "END *0x0*1 *$hex *Y *\r\n.*" { fail $gdb_test_name } - -re -wrap "END *$hex *$hex *Y *" { + -re -wrap "END *$hex *$hex *Y *\r\n" { pass $gdb_test_name } } diff --git a/gdb/testsuite/gdb.guile/guile.exp b/gdb/testsuite/gdb.guile/guile.exp index 7d0c063583d..ee8b2718178 100644 --- a/gdb/testsuite/gdb.guile/guile.exp +++ b/gdb/testsuite/gdb.guile/guile.exp @@ -63,7 +63,7 @@ gdb_test_multiline "show guile command" \ "(print 23)" "" \ "end" "" \ "end" "" \ - "show user zzq" "User command \"zzq\":.* guile.*\\(print 23\\).* end" + "show user zzq" "User command \"zzq\":.* guile.*\\(print 23\\).* end\r\n" gdb_test "source $host_source2_scm" "yes" "source source2.scm" diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp index 7e9ddaa6fcd..584e52c0661 100644 --- a/gdb/testsuite/gdb.python/python.exp +++ b/gdb/testsuite/gdb.python/python.exp @@ -80,7 +80,7 @@ gdb_test_multiline "show python command" \ "print (23)" "" \ "end" "" \ "end" "" \ - "show user zzq" "User command \"zzq\":.* python.*print \\(23\\).* end" + "show user zzq" "User command \"zzq\":.* python.*print \\(23\\).* end\r\n" gdb_test_multiline "indented multi-line python command" \ "python" "" \ diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index aed7e2d043c..50c10333df1 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -818,7 +818,7 @@ proc gdb_continue_to_breakpoint {name {location_pattern .*}} { -re "(?:Breakpoint|Temporary breakpoint) .* (at|in) $location_pattern\r\n$gdb_prompt $" { pass $full_name } - -re "\[\r\n\]*(?:$kfail_pattern)\[\r\n\]+$gdb_prompt $" { + -re "(?:$kfail_pattern)\r\n$gdb_prompt $" { kfail "gdb/25038" $full_name } } @@ -1126,7 +1126,7 @@ proc gdb_test_multiple { command message args } { if { $wrap_pattern } { # Wrap subst_item as is done for the gdb_test PATTERN argument. lappend $current_list \ - "\[\r\n\]*(?:$subst_item)\[\r\n\]+$prompt_regexp" + "(?:$subst_item)\r\n$prompt_regexp" set wrap_pattern 0 } else { lappend $current_list $subst_item @@ -1384,7 +1384,7 @@ proc gdb_test_multiline { name args } { foreach {input result} $args { incr inputnr if {[gdb_test_multiple $input "$name: input $inputnr: $input" { - -re "\[\r\n\]*($result)\[\r\n\]+($gdb_prompt | *>)$" { + -re "($result)\r\n($gdb_prompt | *>)$" { pass $gdb_test_name } }]} { @@ -7746,7 +7746,7 @@ proc get_valueof { fmt exp default {test ""} } { set val ${default} gdb_test_multiple "print${fmt} ${exp}" "$test" { - -re "\\$\[0-9\]* = (\[^\r\n\]*)\[\r\n\]*$gdb_prompt $" { + -re "\\$\[0-9\]* = (\[^\r\n\]*)\r\n$gdb_prompt $" { set val $expect_out(1,string) pass "$test" } @@ -7770,7 +7770,7 @@ proc get_local_valueof { exp default {test ""} } { set val ${default} gdb_test_multiple "info locals ${exp}" "$test" { - -re "$exp = (\[^\r\n\]*)\[\r\n\]*$gdb_prompt $" { + -re "$exp = (\[^\r\n\]*)\r\n$gdb_prompt $" { set val $expect_out(1,string) pass "$test" }