From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1879) id F416F3858C50; Tue, 29 Nov 2022 16:44:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F416F3858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669740261; bh=VKBdVPPN0tkwkJHaUQ7K++Ebwd1+sUVyf/tXIlkitJ0=; h=From:To:Subject:Date:From; b=wkB7eNga3v4NC5M1ZZxsodRbp8uRlM1aq2VmGc8CGvRbG1wEEVSWPldLR54cqYPnK TPRNbwHUWza+YLZc2aQqXO13+YZ/7bGA4slitn4h+6nmWAdoaJYcfCkXKhZDeYQPGh ZacLC20v8jzhRMmHDGkV5MTxSQGxRZWMqgFXNlwo= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Simon Marchi To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/testsuite: make gdb_unload use gdb_test_multiple X-Act-Checkin: binutils-gdb X-Git-Author: Simon Marchi X-Git-Refname: refs/heads/master X-Git-Oldrev: d56614a9925791b15d7052eb4c798ab24a724611 X-Git-Newrev: f432d5ef2b955b2f8f1f7c1de727b9e43b846976 Message-Id: <20221129164420.F416F3858C50@sourceware.org> Date: Tue, 29 Nov 2022 16:44:20 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Df432d5ef2b95= 5b2f8f1f7c1de727b9e43b846976 commit f432d5ef2b955b2f8f1f7c1de727b9e43b846976 Author: Simon Marchi Date: Mon Nov 21 09:30:55 2022 -0500 gdb/testsuite: make gdb_unload use gdb_test_multiple =20 In the failure seen by Philippe here: =20 https://inbox.sourceware.org/gdb-patches/20221120173024.3647464-1-phi= lippe.waroquiers@skynet.be/ =20 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. =20 Make it return the result of gdb_test_multiple directly, change gdb.python/py-objfile.exp accordingly. =20 Change gdb.base/endian.exp as well to avoid duplicate test names. =20 Change gdb.base/gnu-debugdata.exp to avoid recording a test result, since gdb_unload does it already now. =20 Change-Id: I59a1e4947691330797e6ce23277942547c437a48 Approved-By: Tom de Vries Diff: --- 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/end= ian.exp index 05cf1280bad..daa49b51654 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" { =20 # 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" =20 -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" =20 -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.b= ase/gnu-debugdata.exp index 732eadcbd30..0900e2fc2d8 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 =3D=3D "lzma"} { } =20 # 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 =20 gdb_exit diff --git a/gdb/testsuite/gdb.python/py-objfile.exp b/gdb/testsuite/gdb.py= thon/py-objfile.exp index 80f2e794947..9af841c60db 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" =20 @@ -103,9 +105,8 @@ gdb_test "python print (objfile.random_attribute)" "42"= \ =20 # Verify invalid objfile handling. =20 -if { [gdb_unload] < 0 } { - fail "unload all files" - return -1 +if { [gdb_unload "unload 2"] !=3D 0 } { + return } =20 gdb_test "python print(objfile.filename)" "None" \ diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index e193a20768c..23e3cc0c2d4 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -311,38 +311,32 @@ proc gdb_version { } { return [default_gdb_version] } =20 -# # gdb_unload -- unload a file if one is loaded -# Return 0 on success, -1 on error. # +# Returns the same as gdb_test_multiple. =20 -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 cha= nge 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 + }] } =20 # Many of the tests depend on setting breakpoints at various places and