[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.
This commit is contained in:
Tom de Vries 2022-11-16 11:19:48 +01:00
parent a715464cd2
commit 24eb586f5c
3 changed files with 32 additions and 8 deletions

View File

@ -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"

View File

@ -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
}

View File

@ -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