public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tom de Vries <vries@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] [gdb/testsuite] Fix gdb.arch/ppc64-symtab-cordic.exp without bzip2
Date: Wed, 16 Nov 2022 10:19:53 +0000 (GMT)	[thread overview]
Message-ID: <20221116101953.3BCF23954C63@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=24eb586f5c5ec119424b7bede66ada9cc94cace4

commit 24eb586f5c5ec119424b7bede66ada9cc94cace4
Author: Tom de Vries <tdevries@suse.de>
Date:   Wed Nov 16 11:19:48 2022 +0100

    [gdb/testsuite] Fix gdb.arch/ppc64-symtab-cordic.exp without bzip2
    
    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.

Diff:
---
 gdb/testsuite/gdb.arch/i386-biarch-core.exp    |  5 +++--
 gdb/testsuite/gdb.arch/ppc64-symtab-cordic.exp | 13 +++++++------
 gdb/testsuite/lib/gdb.exp                      | 22 ++++++++++++++++++++++
 3 files changed, 32 insertions(+), 8 deletions(-)

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

                 reply	other threads:[~2022-11-16 10:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221116101953.3BCF23954C63@sourceware.org \
    --to=vries@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).