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 441F4384D1BE for ; Fri, 24 Jun 2022 13:21:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 441F4384D1BE Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-654-E7C6y_lhPDmmVQ8BBZC1eQ-1; Fri, 24 Jun 2022 09:21:01 -0400 X-MC-Unique: E7C6y_lhPDmmVQ8BBZC1eQ-1 Received: by mail-wm1-f69.google.com with SMTP id j20-20020a05600c1c1400b0039c747a1e5aso1463978wms.9 for ; Fri, 24 Jun 2022 06:21:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:in-reply-to:references:date :message-id:mime-version; bh=FUYtiXWoxZ9GwngRRHRCb8hXXZ0zCD37+ZA8QxbZCwY=; b=TgiSwU8fq5GiLzJtJy501wQRyp5BKGgDKTM4ZOL12kCrMA8/ikK+gpnOq58Gz9SrCq k2MBhHtaAn6TpR3HyGDtO+SwmaDtAF2JowfM+jAXfh/2qzTlCxV/posP8xRlSUsG1FXV SbLbwyvzXz89nnQKZwMqRNIZkfZ6/mgfmR9DzIeAJqqU7yWLwYl1x4FdUxZIh8VTE/hZ 2sxCnGffg1On/CGzZUNETde8hXRxKgoXgo+V2i+2JZCykFfkUDg1d0SVRu/zURnGnzf6 oQvsozzD+KYB0lLU9OKtSTOnVyCdX7TK7EkRNb3mGDG/YoBC7pbZ1hH7+MAvNX58qfdO kaRw== X-Gm-Message-State: AJIora8paZwSDLUltRBQp0ZQtxcidB9Afjr/LIrhGGI0mPw/oG0bJNPJ q9+qmgUQUmfHoUZaNcshWX0VHJxpLkEaW7RT/aQ2nx6Q5GziRX8MQL3CFuDc0EBbcOlM/pidTXy 53nloU6Ieh3FoHA00Nc57hw== X-Received: by 2002:a5d:64e2:0:b0:21b:b1ab:254e with SMTP id g2-20020a5d64e2000000b0021bb1ab254emr3447410wri.451.1656076860301; Fri, 24 Jun 2022 06:21:00 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sGCVU/PYChw2G5RbgEcjQXCghUINwonjSVa1QfGVqjiu3zHNi7yDc/5nFCzGhJab/JrcJd7A== X-Received: by 2002:a5d:64e2:0:b0:21b:b1ab:254e with SMTP id g2-20020a5d64e2000000b0021bb1ab254emr3447385wri.451.1656076860015; Fri, 24 Jun 2022 06:21:00 -0700 (PDT) Received: from localhost ([195.213.152.79]) by smtp.gmail.com with ESMTPSA id r68-20020a1c2b47000000b0039c4b518df4sm3485582wmr.5.2022.06.24.06.20.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jun 2022 06:20:59 -0700 (PDT) From: Andrew Burgess To: Bruno Larsen , gdb-patches@sourceware.org Subject: Re: [PATCH] gdb/testsuite: modernize gdb.base/maint.exp In-Reply-To: <20220621194520.34682-1-blarsen@redhat.com> References: <87edzic8v1.fsf@redhat.com> <20220621194520.34682-1-blarsen@redhat.com> Date: Fri, 24 Jun 2022 14:20:58 +0100 Message-ID: <87k096b3k5.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=-12.6 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, 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Jun 2022 13:21:07 -0000 Bruno Larsen via Gdb-patches writes: > gdb.base/maint.exp was using several gdb_expect statements, probably > because this test case predates the existance of gdb_test_multiple. This > commit updates the test case to use gdb_test_multiple, making it more > resilient to internal errors and such. > > The only gdb_expect left in the testcase is one that specifically looks > for an internal error being triggered as a PASS. > --- > > Changes for v2: > - Addressed Andrew's comments > - rebased on current master. > > --- > > gdb/testsuite/gdb.base/maint.exp | 130 +++++++++++-------------------- > 1 file changed, 46 insertions(+), 84 deletions(-) > > diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp > index 2817c6eafb9..31b999073f9 100644 > --- a/gdb/testsuite/gdb.base/maint.exp > +++ b/gdb/testsuite/gdb.base/maint.exp > @@ -151,22 +151,28 @@ set have_psyms [expr ! ( $have_gdb_index || $readnow_p )] > # unless there is some problem with the symtabs and psymtabs > # so that branch will really never be covered in this tests here!! > # > +# When there is a problem, there may be loads of output, which can > +# overwhelm the expect buffer. Splitting it seems to fix those > +# issues. > + > +set seen_command 0 set seen_command false > +gdb_test_multiple "maint check-psymtabs" "" { > + -re "^maint check-psymtabs\r\n" { > + set seen_command 1 set seen_command true > + exp_continue > + } > > -# guo: on linux this command output is huge. for some reason splitting up > -# the regexp checks works. > -# > -send_gdb "maint check-psymtabs\n" > -gdb_expect { > - -re "^maint check-psymtabs" { > - gdb_expect { > - -re "$gdb_prompt $" { > - pass "maint check-psymtabs" > - } > - timeout { fail "(timeout) maint check-psymtabs" } > + -re "^$gdb_prompt $" { > + if { $seen_command == 1 } { > + pass "maint check-psymtabs" > + } else { > + fail $gdb_test_name > } You could use just: gdb_assert { $seen_command } here. Or maybe: gdb_assert { $seen_command } $gdb_test_name Or possibly even: gdb_assert { $seen_command } pass $gdb_test_name I think option #2 would be my pick, but whatever you prefer is fine I think. > } > - -re ".*$gdb_prompt $" { fail "maint check-psymtabs" } > - timeout { fail "(timeout) maint check-psymtabs" } > + > + -re "^\[^\r\n\]+\r\n" { > + exp_continue > + } > } > > # This command does not produce any output unless there is some problem > @@ -272,62 +278,37 @@ if { $have_psyms } { > "maint print psymbols -pc" \ > "maint print psymbols -pc main $psymbols_output"] > foreach { test_name command } $test_list { > - send_gdb "$command\n" > - gdb_expect { > - -re "^maint print psymbols \[^\n\]*\r\n$gdb_prompt $" { > - send_gdb "shell ls $psymbols_output\n" > - gdb_expect { > - -re "$psymbols_output_re\r\n$gdb_prompt $" { > - # We want this grep to be as specific as possible, > - # so it's less likely to match symbol file names in > - # psymbols_output. Yes, this actually happened; > - # poor expect got tons of output, and timed out > - # trying to match it. --- Jim Blandy > - send_gdb "shell grep 'main.*function' $psymbols_output\n" > - gdb_expect { > - -re ".main., function, $hex.*$gdb_prompt $" { > - pass "$test_name 1" > - } > - -re ".*main. .., function, $hex.*$gdb_prompt $" { > - pass "$test_name 2" > - } > - -re ".*$gdb_prompt $" { fail "$test_name" } > - timeout { fail "$test_name (timeout)" } > - } > - gdb_test "shell rm -f $psymbols_output" ".*" \ > - "${test_name}: shell rm -f psymbols_output" > + gdb_test_multiple "$command" "$test_name" { > + -re -wrap "^maint print psymbols \[^\n\]*" { > + gdb_test_multiple "shell grep 'main.*function' $psymbols_output" \ > + "$test_name internal" { > + -re -wrap ".main., function, $hex.*" { > + pass "$test_name, pattern 1" > + } > + -re -wrap ".*main. .., function, $hex.*" { > + pass "$test_name, pattern 2" > } > - -re ".*$gdb_prompt $" { fail "$test_name" } > - timeout { fail "$test_name (timeout)" } > - } > } > - -re ".*$gdb_prompt $" { fail "$test_name" } > - timeout { fail "$test_name (timeout)" } > } > + } > + gdb_test "shell rm -f $psymbols_output" ".*" \ > + "${test_name}: shell rm -f psymbols_output" > } > } > > > set msymbols_output [standard_output_file msymbols_output] > set msymbols_output_re [string_to_regexp $msymbols_output] > -send_gdb "maint print msymbols -objfile ${binfile} $msymbols_output\n" > -gdb_expect { > - -re "^maint print msymbols \[^\n\]*\r\n$gdb_prompt $" { > - send_gdb "shell ls $msymbols_output\n" > - gdb_expect { > - -re "$msymbols_output_re\r\n$gdb_prompt $" { > - gdb_test "shell grep factorial $msymbols_output" \ > - "\\\[ *$decimal\\\] \[tT\]\[ \t\]+$hex \\.?factorial.*" \ > - "maint print msymbols, absolute pathname" > - gdb_test "shell rm -f $msymbols_output" ".*" \ > - "shell rm -f msymbols_output" > - } > - -re ".*$gdb_prompt $" { fail "maint print msymbols" } > - timeout { fail "maint print msymbols (timeout)" } > - } > +gdb_test_multiple "maint print msymbols -objfile ${binfile} $msymbols_output" \ > + "printing msymbols" { > + > + -re -wrap "^maint print msymbols \[^\n\]*" { > + gdb_test "shell grep factorial $msymbols_output" \ > + "\\\[ *$decimal\\\] \[tT\]\[ \t\]+$hex \\.?factorial.*" \ > + "maint print msymbols, absolute pathname" > + gdb_test "shell rm -f $msymbols_output" ".*" \ > + "shell rm -f msymbols_output" > } > - -re ".*$gdb_prompt $" { fail "maint print msymbols" } > - timeout { fail "maint print msymbols (timeout)" } > } I think this block can be simplified to just: gdb_test_no_output "maint print msymbols -objfile ${binfile} $msymbols_output" \ "maint print symbols, write to output file" gdb_test "shell grep factorial $msymbols_output" \ "\\\[ *$decimal\\\] \[tT\]\[ \t\]+$hex \\.?factorial.*" \ "maint print msymbols, absolute pathname" gdb_test "shell rm -f $msymbols_output" ".*" \ "shell rm -f msymbols_output" I think this patch is fine with these changes made. Thanks, Andrew > > # Check that maint print msymbols allows relative pathnames > @@ -365,31 +346,12 @@ set test_list [list \ > "maint print symbols -pc" \ > "maint print symbols -pc main $symbols_output"] > foreach { test_name command } $test_list { > - send_gdb "$command\n" > - gdb_expect { > - -re "^maint print symbols \[^\n\]*\r\n$gdb_prompt $" { > - send_gdb "shell ls $symbols_output\n" > - gdb_expect { > - -re "$symbols_output_re\r\n$gdb_prompt $" { > - # See comments for `maint print psymbols'. > - send_gdb "shell grep 'main(.*block' $symbols_output\n" > - gdb_expect { > - -re "int main\\(int, char \\*\\*, char \\*\\*\\); block.*$gdb_prompt $" { > - pass "$test_name" > - } > - -re ".*$gdb_prompt $" { fail "$test_name" } > - timeout { fail "$test_name (timeout)" } > - } > - gdb_test "shell rm -f $symbols_output" ".*" \ > - "$test_name: shell rm -f symbols_output" > - } > - -re ".*$gdb_prompt $" { fail "$test_name" } > - timeout { fail "$test_name (timeout)" } > - } > - } > - -re ".*$gdb_prompt $" { fail "$test_name" } > - timeout { fail "$test_name (timeout)" } > - } > + gdb_test_no_output "$command" "$test_name generate" > + gdb_test "shell grep 'main(.*block' $symbols_output"\ > + "int main\\(int, char \\*\\*, char \\*\\*\\); block.*"\ > + "$test_name read" > + gdb_test "shell rm -f $symbols_output" ".*" \ > + "$test_name: shell rm -f symbols_output" > } > > set msg "maint print type" > -- > 2.31.1