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 A087C385085D for ; Mon, 20 Jun 2022 13:29:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A087C385085D 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-137-3SwCr2dXOAeCpWQopAG_ug-1; Mon, 20 Jun 2022 09:29:41 -0400 X-MC-Unique: 3SwCr2dXOAeCpWQopAG_ug-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B0AF880C913 for ; Mon, 20 Jun 2022 13:29:40 +0000 (UTC) Received: from [10.97.116.35] (ovpn-116-35.gru2.redhat.com [10.97.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 349E59D54 for ; Mon, 20 Jun 2022 13:29:40 +0000 (UTC) Message-ID: Date: Mon, 20 Jun 2022 10:29:38 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: [PINGv5] [PATCH] gdb/testsuite: modernize gdb.base/maint.exp From: Bruno Larsen To: "gdb-patches@sourceware.org" References: <20220509180431.31032-1-blarsen@redhat.com> <8f9fac3c-b195-d90c-7b65-82a146dc8374@redhat.com> <1db403c7-7864-02de-63d7-08ab17e57a3f@redhat.com> <33687f4b-582e-49ef-943c-673c03f0c8fd@redhat.com> In-Reply-To: <33687f4b-582e-49ef-943c-673c03f0c8fd@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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: 8bit X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, BODY_8BITS, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, 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: Mon, 20 Jun 2022 13:29:44 -0000 ping! Cheers! Bruno Larsen On 6/13/22 17:03, Bruno Larsen wrote: > ping! > > Cheers! > Bruno Larsen > > On 6/6/22 09:43, Bruno Larsen wrote: >> ping! >> >> Cheers! >> Bruno Larsen >> >> On 5/30/22 08:14, Bruno Larsen wrote: >>> ping! >>> >>> Cheers! >>> Bruno Larsen >>> >>> On 5/23/22 11:14, Bruno Larsen wrote: >>>> ping >>>> >>>> Cheers! >>>> Bruno Larsen >>>> >>>> On 5/9/22 15:04, Bruno Larsen wrote: >>>>> 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. >>>>> --- >>>>>   gdb/testsuite/gdb.base/maint.exp | 109 ++++++++----------------------- >>>>>   1 file changed, 29 insertions(+), 80 deletions(-) >>>>> >>>>> diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp >>>>> index 45ccdc6584e..2efdda9aed7 100644 >>>>> --- a/gdb/testsuite/gdb.base/maint.exp >>>>> +++ b/gdb/testsuite/gdb.base/maint.exp >>>>> @@ -155,18 +155,10 @@ set have_psyms [expr ! ( $have_gdb_index || $readnow_p )] >>>>>   # 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" } >>>>> -    } >>>>> +gdb_test_multiple "maint check-psymtabs" "maint check-psymtabs" { >>>>> +    -re -wrap "^maint check-psymtabs.*" { >>>>> +    pass "maint check-psymtabs" >>>>>       } >>>>> -    -re ".*$gdb_prompt $"     { fail "maint check-psymtabs" } >>>>> -    timeout         { fail "(timeout) maint check-psymtabs" } >>>>>   } >>>>>   # This command does not produce any output unless there is some problem >>>>> @@ -270,62 +262,38 @@ 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_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.*" { >>>>> +                gdb_test "shell rm -f $psymbols_output" ".*" \ >>>>> +                "${test_name}: shell rm -f psymbols_output" >>>>> +                pass "$test_name 1" >>>>> +            } >>>>> +            -re -wrap ".*main.  .., function, $hex.*" { >>>>>                   gdb_test "shell rm -f $psymbols_output" ".*" \ >>>>>                   "${test_name}: shell rm -f psymbols_output" >>>>> +                pass "$test_name 2" >>>>>               } >>>>> -            -re ".*$gdb_prompt $" { fail "$test_name" } >>>>> -            timeout { fail "$test_name (timeout)" } >>>>> -            } >>>>>           } >>>>> -        -re ".*$gdb_prompt $" { fail "$test_name" } >>>>> -        timeout { fail "$test_name (timeout)" } >>>>>           } >>>>> +    } >>>>>       } >>>>>   } >>>>>   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)" } >>>>>   } >>>>>   # Check that maint print msymbols allows relative pathnames >>>>> @@ -363,31 +331,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"