From patchwork Wed Nov 16 10:20:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 60689 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 01CF03959CA0 for ; Wed, 16 Nov 2022 10:20:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 01CF03959CA0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668594056; bh=uc3wv/Y5wl+koIK+VTGSX13Of7bRj55qac22dt7K+QE=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=HRVtKtL9ktInEtrjx1XON4MgmzTFXb1GMYdXOm5YWUS+1pIXrHeDKeE4Gj+QhVm+W sOGaiJ24tI+eXsY8GD6T06d+fIVFFV6BVMFyDKcl+OzJUYCnYshiHNHOo5klooHzT0 Pcn6yzowUm8LhoGr3UwLTGX04Ej4+VNngL6r2b0o= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id DCC1E395380C for ; Wed, 16 Nov 2022 10:20:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DCC1E395380C 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 0E0B31F917 for ; Wed, 16 Nov 2022 10:20:29 +0000 (UTC) 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 EE89213480 for ; Wed, 16 Nov 2022 10:20:28 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id LXQROWy5dGO6TAAAMHmgww (envelope-from ) for ; Wed, 16 Nov 2022 10:20:28 +0000 To: gdb-patches@sourceware.org Subject: [pushed 1/2] [gdb/testsuite] Fix gdb.arch/ppc64-symtab-cordic.exp without bzip2 Date: Wed, 16 Nov 2022 11:20:27 +0100 Message-Id: <20221116102028.18591-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, 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 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-Patchwork-Original-From: Tom de Vries via Gdb-patches From: Tom de Vries Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" After de-installing bzip2, I run into: ... Running ppc64-symtab-cordic.exp ... sh: bzip2: command not found PATH: gdb.arch/ppc64-symtab-cordic.exp: failed bzip2 for \ src/gdb/testsuite/gdb.arch/cordic.ko.bz2 ... Fix these by: - using remote_exec instead of catch system, and - using file tail in the untested message. I've tried making output redirection work with remote_exec, but that seems to be broken, so we now: - copy the file $f.bz2 into the desired location $dir/$f.bz2, and - decompress the bz2 file using "bzip2 -df $dir/$f.bz2", resulting in a file $dir/$f. Factor out new function decompress_bz2 to make the test-case less verbose, and also use it in gdb.arch/i386-biarch-core.exp. Tested on x86_64-linux, without and with bzip2 installed. --- gdb/testsuite/gdb.arch/i386-biarch-core.exp | 5 +++-- .../gdb.arch/ppc64-symtab-cordic.exp | 13 ++++++----- gdb/testsuite/lib/gdb.exp | 22 +++++++++++++++++++ 3 files changed, 32 insertions(+), 8 deletions(-) base-commit: a715464cd2e25c8bf46190cc8bde9267c9ab6ac0 diff --git a/gdb/testsuite/gdb.arch/i386-biarch-core.exp b/gdb/testsuite/gdb.arch/i386-biarch-core.exp index 607a3aaaf85..e1f65900379 100644 --- a/gdb/testsuite/gdb.arch/i386-biarch-core.exp +++ b/gdb/testsuite/gdb.arch/i386-biarch-core.exp @@ -45,14 +45,15 @@ gdb_test_multiple "complete set gnutarget " $test { } set corebz2file ${srcdir}/${subdir}/${testfile}.core.bz2 -set corefile [standard_output_file ${testfile}.core] # Entry point of the original executable. set address 0x400078 -if {[catch "system \"bzip2 -dc ${corebz2file} >${corefile}\""] != 0} { +set corefile [decompress_bz2 $corebz2file] +if { $corefile == "" } { untested "failed bzip2" return -1 } + file stat ${corefile} corestat if {$corestat(size) != 102400} { untested "bzip2 produces invalid result" diff --git a/gdb/testsuite/gdb.arch/ppc64-symtab-cordic.exp b/gdb/testsuite/gdb.arch/ppc64-symtab-cordic.exp index 5d2e1255d45..4464177b547 100644 --- a/gdb/testsuite/gdb.arch/ppc64-symtab-cordic.exp +++ b/gdb/testsuite/gdb.arch/ppc64-symtab-cordic.exp @@ -24,16 +24,17 @@ if { [lsearch -exact $supported_archs "powerpc:common64"] == -1 } { standard_testfile set kobz2file ${srcdir}/${subdir}/cordic.ko.bz2 -set kofile [standard_output_file cordic.ko] set kodebugbz2file ${srcdir}/${subdir}/cordic.ko.debug.bz2 -set kodebugfile [standard_output_file cordic.ko.debug] -if {[catch "system \"bzip2 -dc ${kobz2file} >${kofile}\""] != 0} { - untested "failed bzip2 for ${kobz2file}" +set kofile [decompress_bz2 $kobz2file] +if { $kofile == "" } { + untested "failed bzip2 for [file tail $kobz2file]" return -1 } -if {[catch "system \"bzip2 -dc ${kodebugbz2file} >${kodebugfile}\""] != 0} { - untested "failed bzip2 for ${kodebugbz2file}" + +set kodebugfile [decompress_bz2 $kodebugbz2file] +if { $kodebugfile == "" } { + untested "failed bzip2 for [file tail $kodebugbz2file]" return -1 } diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 698b3f4bd79..f540770189d 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -9291,5 +9291,27 @@ gdb_caching_proc have_epilogue_line_info { } } +# Decompress file BZ2, and return it. + +proc decompress_bz2 { bz2 } { + set copy [standard_output_file [file tail $bz2]] + set copy [remote_download build $bz2 $copy] + if { $copy == "" } { + return $copy + } + + set res [remote_exec build "bzip2" "-df $copy"] + if { [lindex $res 0] == -1 } { + return "" + } + + set copy [regsub {.bz2$} $copy ""] + if { ![remote_file build exists $copy] } { + return "" + } + + return $copy +} + # Always load compatibility stuff. load_lib future.exp From patchwork Wed Nov 16 10:20:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 60688 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C76B63959C87 for ; Wed, 16 Nov 2022 10:20:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C76B63959C87 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668594055; bh=nBkn24IOITagtDHliRxyva3Q71tC8kETzSOJWSnzLM0=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=G3ArswfVeU7sc9Oemmx8g7/cyBrPHHTYEeXMWWW9aEZSblO1uq9KzaNl5QaBippsT XcdjyIEn7hnVO6nOM2H2KTl7V+m1JcNfPvUxWbGQTrqRs5C6zjfCQLx9r8AvybWkxq T1u1S0PcS2qxBgetq5ouzt1/wJWky1zHl79crjmY= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 0ADAF3954C63 for ; Wed, 16 Nov 2022 10:20:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0ADAF3954C63 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-out1.suse.de (Postfix) with ESMTPS id 2F10F336EA for ; Wed, 16 Nov 2022 10:20:29 +0000 (UTC) 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 1712E13480 for ; Wed, 16 Nov 2022 10:20:29 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id KKt4BG25dGO6TAAAMHmgww (envelope-from ) for ; Wed, 16 Nov 2022 10:20:29 +0000 To: gdb-patches@sourceware.org Subject: [pushed 2/2] [gdb/testsuite] Modernize gdb.arch/i386-biarch-core.exp Date: Wed, 16 Nov 2022 11:20:28 +0100 Message-Id: <20221116102028.18591-2-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221116102028.18591-1-tdevries@suse.de> References: <20221116102028.18591-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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 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-Patchwork-Original-From: Tom de Vries via Gdb-patches From: Tom de Vries Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" I noticed in test-case gdb.arch/i386-biarch-core.exp that we run into the completion limit for "complete set gnutarget": ... set gnutarget vms-libtxt^M set gnutarget *** List may be truncated, max-completions reached. ***^M (gdb) PASS: gdb.arch/i386-biarch-core.exp: complete set gnutarget ... Fix this by using get_set_option_choices. Also use get_set_option_choices for "complete set architecture i386", which required extending get_set_option_choices to accept a second argument, such that we can do: ... set archs [get_set_option_choices "set architecture" "i386"] ... because this returns an empty list: ... set archs [get_set_option_choices "set architecture i386"] ... because it does "complete set architecture i386 ". Also clean up the explicit gdb_exit/gdb_start and use clean_restart instead. Tested on x86_64-linux. --- gdb/testsuite/gdb.arch/i386-biarch-core.exp | 29 +++++---------------- gdb/testsuite/lib/gdb.exp | 18 ++++++++++--- 2 files changed, 21 insertions(+), 26 deletions(-) diff --git a/gdb/testsuite/gdb.arch/i386-biarch-core.exp b/gdb/testsuite/gdb.arch/i386-biarch-core.exp index e1f65900379..95e60d0b552 100644 --- a/gdb/testsuite/gdb.arch/i386-biarch-core.exp +++ b/gdb/testsuite/gdb.arch/i386-biarch-core.exp @@ -28,20 +28,12 @@ if { ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] } then { standard_testfile -gdb_exit -gdb_start -gdb_reinitialize_dir $srcdir/$subdir +clean_restart -set test "complete set gnutarget" -gdb_test_multiple "complete set gnutarget " $test { - -re "set gnutarget elf64-little\r\n(.*\r\n)?$gdb_prompt $" { - pass $test - } - -re "\r\n$gdb_prompt $" { - pass $test - untested ".text is readable" - return - } +set gnutargets [get_set_option_choices "set gnutarget"] +if { [lsearch -exact $gnutargets elf64-little] == -1 } { + untested ".text is readable" + return } set corebz2file ${srcdir}/${subdir}/${testfile}.core.bz2 @@ -62,15 +54,8 @@ if {$corestat(size) != 102400} { # First check if this particular GDB supports i386, otherwise we should not # expect the i386 core file to be loaded successfully. -set supports_arch_i386 1 -set test "complete set architecture i386" -gdb_test_multiple $test $test { - -re "\r\nset architecture i386\r\n(.*\r\n)?$gdb_prompt $" { - } - -re "\r\n$gdb_prompt $" { - set supports_arch_i386 0 - } -} +set archs [get_set_option_choices "set architecture" "i386"] +set supports_arch_i386 [expr [lsearch -exact $archs i386] != -1] # Wrongly built GDB complains by: # "..." is not a core dump: File format not recognized diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index f540770189d..042d7ade59f 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -9146,13 +9146,23 @@ gdb_caching_proc has_hw_wp_support { return $has_hw_wp_support } -# Return a list of all the accepted values of the set command SET_CMD. +# Return a list of all the accepted values of the set command +# "SET_CMD SET_ARG". +# For example get_set_option_choices "set architecture" "i386". -proc get_set_option_choices {set_cmd} { +proc get_set_option_choices { set_cmd {set_arg ""} } { set values {} - set cmd "complete $set_cmd " - set test "complete $set_cmd" + if { $set_arg == "" } { + # Add trailing space to signal that we need completion of the choices, + # not of set_cmd itself. + set cmd "complete $set_cmd " + } else { + set cmd "complete $set_cmd $set_arg" + } + + # Set test name without trailing space. + set test [string trim $cmd] with_set max-completions unlimited { gdb_test_multiple $cmd $test {