From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 868253858D37 for ; Tue, 29 Nov 2022 16:28:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 868253858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id C57941F8A3; Tue, 29 Nov 2022 16:28:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1669739335; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GZSyc6/OG37+hOWvrnEI2H6dCsxmjH4Y/JMbW5dEPtA=; b=SFgmGMrCQvpPTdCM9/dLG8cXOEq7elP7FSpFUwZ4NBfNVo+TcoMoM4HrJ9YcHkSgq2RdKB 3AXnegBwxapIDveLX8hvDtLpbSpiDqo18ND7KLPUQ4DDYC9TPQ0L2Nmy5DpO16y63tKogR tMOvOfGFh9iFwjgtOI0Lfgsnqw8ztnQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1669739335; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GZSyc6/OG37+hOWvrnEI2H6dCsxmjH4Y/JMbW5dEPtA=; b=bcbs/Ul9BRHkdXzM2BYaoKKgWqNxkt15EBfY7LKTxXzY/CuXfx2cI6tOWWokwfTwb0ahxL wyKJekMKtSo7jvCw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A15E813428; Tue, 29 Nov 2022 16:28:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id yXbAJUczhmPKFQAAMHmgww (envelope-from ); Tue, 29 Nov 2022 16:28:55 +0000 Message-ID: <7ddb7298-d036-52bb-933f-f225157735a0@suse.de> Date: Tue, 29 Nov 2022 17:28:55 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH 2/2] gdb/testsuite: make gdb_unload use gdb_test_multiple Content-Language: en-US To: Simon Marchi , gdb-patches@sourceware.org Cc: Simon Marchi References: <20221122155546.599061-1-simon.marchi@efficios.com> <20221122155546.599061-2-simon.marchi@efficios.com> From: Tom de Vries In-Reply-To: <20221122155546.599061-2-simon.marchi@efficios.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,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: On 11/22/22 16:55, Simon Marchi via Gdb-patches wrote: > From: Simon Marchi > > In the failure seen by Philippe here: > > https://inbox.sourceware.org/gdb-patches/20221120173024.3647464-1-philippe.waroquiers@skynet.be/ > > gdb_unload crashed GDB, leaving no trace in the test results. Change it > to use gdb_test_multiple, so that it leaves an UNRESOLVED result. I > think it is good practice anyway. > Agreed. I do remember some cases where I had to downgrade from gdb_test_multiple to gdb_expect, but I guess for the common case gdb_test_multiple is the best. > Make it return the result of gdb_test_multiple directly, change > gdb.python/py-objfile.exp accordingly. > > Change gdb.base/endian.exp as well to avoid duplicate test names. > > Change gdb.base/gnu-debugdata.exp to avoid recording a test result, > since gdb_unload does it already now. > LGTM. Thanks, - Tom > Change-Id: I59a1e4947691330797e6ce23277942547c437a48 > --- > gdb/testsuite/gdb.base/endian.exp | 6 ++--- > gdb/testsuite/gdb.base/gnu-debugdata.exp | 7 ++--- > gdb/testsuite/gdb.python/py-objfile.exp | 9 ++++--- > gdb/testsuite/lib/gdb.exp | 34 ++++++++++-------------- > 4 files changed, 24 insertions(+), 32 deletions(-) > > diff --git a/gdb/testsuite/gdb.base/endian.exp b/gdb/testsuite/gdb.base/endian.exp > index 05cf1280bad0..daa49b516545 100644 > --- a/gdb/testsuite/gdb.base/endian.exp > +++ b/gdb/testsuite/gdb.base/endian.exp > @@ -59,7 +59,7 @@ if { [gdb_test_multiple "show endian" "$test" { > > # Now check that the automatic endianness is updated > # according to the executable selected. > -gdb_unload > +gdb_unload "unload 1" > gdb_test "set endian big" "$en_set big endian\\." \ > "override target endianness big" > gdb_test "set endian auto" "$en_auto \\\(currently big endian\\\)\\." \ > @@ -69,7 +69,7 @@ gdb_file_cmd $binfile > gdb_test "show endian" "$en_auto \\\(currently $endian endian\\\)\\." \ > "previously big default executable endianness" > > -gdb_unload > +gdb_unload "unload 2" > gdb_test "show endian" "$en_auto \\\(currently $endian endian\\\)\\." \ > "previously big default no executable endianness" > gdb_test "set endian little" "$en_set little endian\\." \ > @@ -81,6 +81,6 @@ gdb_file_cmd $binfile > gdb_test "show endian" "$en_auto \\\(currently $endian endian\\\)\\." \ > "previously little default executable endianness" > > -gdb_unload > +gdb_unload "unload 3" > gdb_test "show endian" "$en_auto \\\(currently $endian endian\\\)\\." \ > "previously little default no executable endianness" > diff --git a/gdb/testsuite/gdb.base/gnu-debugdata.exp b/gdb/testsuite/gdb.base/gnu-debugdata.exp > index 732eadcbd306..0900e2fc2d86 100644 > --- a/gdb/testsuite/gdb.base/gnu-debugdata.exp > +++ b/gdb/testsuite/gdb.base/gnu-debugdata.exp > @@ -150,10 +150,7 @@ if {$gdb_file_cmd_debug_info == "lzma"} { > } > > # Be sure to test the 'close' method on the MiniDebugInfo BFD. > -if {[gdb_unload]} { > - fail "unload MiniDebugInfo" > -} else { > - pass "unload MiniDebugInfo" > -} > +# gdb_unload records a pass/fail. > +gdb_unload > > gdb_exit > diff --git a/gdb/testsuite/gdb.python/py-objfile.exp b/gdb/testsuite/gdb.python/py-objfile.exp > index 9565c16af96b..f42bc5fb9f0f 100644 > --- a/gdb/testsuite/gdb.python/py-objfile.exp > +++ b/gdb/testsuite/gdb.python/py-objfile.exp > @@ -92,7 +92,9 @@ gdb_test "python print (objfile.progspace)" "" \ > "Get objfile program space" > gdb_test "python print (objfile.is_valid())" "True" \ > "Get objfile validity" > -gdb_unload > + > +gdb_unload "unload 1" > + > gdb_test "python print (objfile.is_valid())" "False" \ > "Get objfile validity after unload" > > @@ -103,9 +105,8 @@ gdb_test "python print (objfile.random_attribute)" "42" \ > > # Verify invalid objfile handling. > > -if { [gdb_unload] < 0 } { > - fail "unload all files" > - return -1 > +if { [gdb_unload "unload 2"] != 0 } { > + return > } > > gdb_test "python print(objfile.filename)" "None" \ > diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp > index fcd54c88f251..264d3ff435b3 100644 > --- a/gdb/testsuite/lib/gdb.exp > +++ b/gdb/testsuite/lib/gdb.exp > @@ -311,38 +311,32 @@ proc gdb_version { } { > return [default_gdb_version] > } > > -# > # gdb_unload -- unload a file if one is loaded > -# Return 0 on success, -1 on error. > # > +# Returns the same as gdb_test_multiple. > > -proc gdb_unload {} { > +proc gdb_unload { {msg "file"} } { > global GDB > global gdb_prompt > - send_gdb "file\n" > - gdb_expect 60 { > - -re "No executable file now\[^\r\n\]*\[\r\n\]" { exp_continue } > - -re "No symbol file now\[^\r\n\]*\[\r\n\]" { exp_continue } > - -re "A program is being debugged already.*Are you sure you want to change the file.*y or n. $" { > + return [gdb_test_multiple "file" $msg { > + -re "A program is being debugged already.\r\nAre you sure you want to change the file. .y or n. $" { > send_gdb "y\n" answer > exp_continue > } > - -re "Discard symbol table from .*y or n.*$" { > - send_gdb "y\n" answer > + > + -re "No executable file now\\.\r\n" { > exp_continue > } > - -re "$gdb_prompt $" {} > - -re "A problem internal to GDB has been detected" { > - perror "Couldn't unload file in $GDB (GDB internal error)." > - gdb_internal_error_resync > - return -1 > + > + -re "Discard symbol table from `.*'. .y or n. $" { > + send_gdb "y\n" answer > + exp_continue > } > - timeout { > - perror "couldn't unload file in $GDB (timeout)." > - return -1 > + > + -re -wrap "No symbol file now\\." { > + pass $gdb_test_name > } > - } > - return 0 > + }] > } > > # Many of the tests depend on setting breakpoints at various places and