[binutils-gdb] ld/testsuite: don't leave temporary files in main dir
Jan Beulich
jbeulich@sourceware.org
Fri Mar 13 09:33:12 GMT 2026
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1f5a34b2e05200dc96c27be165e33a7793cc8c85
commit 1f5a34b2e05200dc96c27be165e33a7793cc8c85
Author: Jan Beulich <jbeulich@suse.com>
Date: Fri Mar 13 10:32:19 2026 +0100
ld/testsuite: don't leave temporary files in main dir
Leaving files in tmpdir/ is generally okay (often intended and helpful),
but the main directory really shouldn't be cluttered.
Diff:
---
ld/testsuite/ld-arm/arm-elf.exp | 2 +-
ld/testsuite/ld-bootstrap/bootstrap.exp | 1 +
ld/testsuite/ld-elf/linux-x86.exp | 10 ++++------
ld/testsuite/ld-elf/retain2.d | 2 +-
ld/testsuite/ld-elf/retain5.d | 2 +-
ld/testsuite/ld-ifunc/ifunc.exp | 22 +++++++++++++---------
ld/testsuite/ld-scripts/map-address.exp | 2 ++
ld/testsuite/ld-unique/unique.exp | 10 ++++++----
ld/testsuite/lib/ld-lib.exp | 2 ++
9 files changed, 31 insertions(+), 22 deletions(-)
diff --git a/ld/testsuite/ld-arm/arm-elf.exp b/ld/testsuite/ld-arm/arm-elf.exp
index da0932ab416..ad27c1f86c9 100644
--- a/ld/testsuite/ld-arm/arm-elf.exp
+++ b/ld/testsuite/ld-arm/arm-elf.exp
@@ -244,7 +244,7 @@ set tmp {
{"Relocation boundaries" "-defsym x=0 -defsym y=0 -defsym _start=0" "" "" {reloc-boundaries.s}
{{objdump -s reloc-boundaries.d}}
"reloc-boundaries"}
- {"Data only mapping symbols" "-T data-only-map.ld -Map map" "" "" {data-only-map.s}
+ {"Data only mapping symbols" "-T data-only-map.ld" "" "" {data-only-map.s}
{{objdump -dr data-only-map.d}}
"data-only-map"}
}
diff --git a/ld/testsuite/ld-bootstrap/bootstrap.exp b/ld/testsuite/ld-bootstrap/bootstrap.exp
index ed3c1bf4d99..84a59f2ae6e 100644
--- a/ld/testsuite/ld-bootstrap/bootstrap.exp
+++ b/ld/testsuite/ld-bootstrap/bootstrap.exp
@@ -50,6 +50,7 @@ if [info exists plugins] then {
} else {
set plugins "no"
}
+remote_file host delete plugin-support
# LD can have plugin support even if BFD does not.
if [check_plugin_api_available] {
diff --git a/ld/testsuite/ld-elf/linux-x86.exp b/ld/testsuite/ld-elf/linux-x86.exp
index e271ff938a3..fe05040937a 100644
--- a/ld/testsuite/ld-elf/linux-x86.exp
+++ b/ld/testsuite/ld-elf/linux-x86.exp
@@ -329,9 +329,8 @@ proc check_pr25749a {testname srcfilea srcfileb cflags ldflags lderror} {
# Suppress warning for unsupported attribute from older GCC.
append cflags " -w"
- exec cp $srcdir/$subdir/$srcfilea $srcfilea
- exec chmod +w $srcfilea
- set pr25749_bin "$objcopy -B $output_arch -I binary -O $output_target $srcfilea tmpdir/pr25749-bin.o"
+ set prefix "--binary-symbol-prefix _binary_[string map {- _ . _} $srcfilea]"
+ set pr25749_bin "$objcopy -B $output_arch -I binary $prefix -O $output_target $srcdir/$subdir/$srcfilea tmpdir/pr25749-bin.o"
send_log "$pr25749_bin\n"
set got [remote_exec host "$pr25749_bin"]
if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
@@ -433,9 +432,8 @@ proc check_pr25749b {testname srcfilea srcfileb cflags ldflags dsoldflags args}
}
}
- exec cp $srcdir/$subdir/$srcfilea $srcfilea
- exec chmod +w $srcfilea
- set pr25749_bin "$objcopy -B $output_arch -I binary -O $output_target $srcfilea tmpdir/pr25749-bin.o"
+ set prefix "--binary-symbol-prefix _binary_[string map {- _ . _} $srcfilea]"
+ set pr25749_bin "$objcopy -B $output_arch -I binary $prefix -O $output_target $srcdir/$subdir/$srcfilea tmpdir/pr25749-bin.o"
send_log "$pr25749_bin\n"
set got [remote_exec host "$pr25749_bin"]
if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
diff --git a/ld/testsuite/ld-elf/retain2.d b/ld/testsuite/ld-elf/retain2.d
index 1bd7aaf074d..1ab3d854f50 100644
--- a/ld/testsuite/ld-elf/retain2.d
+++ b/ld/testsuite/ld-elf/retain2.d
@@ -1,5 +1,5 @@
#name: SHF_GNU_RETAIN 2 (remove SHF_GNU_RETAIN sections by placing in /DISCARD/)
#source: retain1.s
-#ld: -e _start -Map=retain2.map --gc-sections --script=retain2.ld --no-warn-rwx-segments
+#ld: -e _start -Map=tmpdir/retain2.map --gc-sections --script=retain2.ld --no-warn-rwx-segments
#map: retain2.map
#notarget: ![supports_gnu_osabi] ![check_gc_sections_available]
diff --git a/ld/testsuite/ld-elf/retain5.d b/ld/testsuite/ld-elf/retain5.d
index 9759531d657..f5026f54c2f 100644
--- a/ld/testsuite/ld-elf/retain5.d
+++ b/ld/testsuite/ld-elf/retain5.d
@@ -1,6 +1,6 @@
#name: SHF_GNU_RETAIN 5 (don't pull SHF_GNU_RETAIN section out of lib)
#source: retain5main.s
-#ld: --gc-sections -e _start -Ltmpdir -lretain5 -Map=retain5.map
+#ld: --gc-sections -e _start -Ltmpdir -lretain5 -Map=tmpdir/retain5.map
#notarget: ![supports_gnu_osabi] ![check_gc_sections_available]
#map: retain5.map
#DUMPPROG: nm
diff --git a/ld/testsuite/ld-ifunc/ifunc.exp b/ld/testsuite/ld-ifunc/ifunc.exp
index a7da88b3710..37cbf78840e 100644
--- a/ld/testsuite/ld-ifunc/ifunc.exp
+++ b/ld/testsuite/ld-ifunc/ifunc.exp
@@ -86,7 +86,8 @@ proc check_osabi { binary_file expected_osabi } {
global READELF
global READELFFLAGS
- catch "exec $READELF $READELFFLAGS --file-header $binary_file > readelf.out" got
+ set tmpfile [file dirname $binary_file]/readelf.out
+ catch "exec $READELF $READELFFLAGS --file-header $binary_file > $tmpfile" got
if ![string match "" $got] then {
verbose "proc check_osabi: Readelf produced unexpected out processing $binary_file: $got"
@@ -94,7 +95,7 @@ proc check_osabi { binary_file expected_osabi } {
}
if { ![regexp "\n\[ \]*OS/ABI:\[ \]*(.+)\n\[ \]*ABI" \
- [file_contents readelf.out] nil osabi] } {
+ [file_contents $tmpfile] nil osabi] } {
verbose "proc check_osabi: Readelf failed to extract an ELF header from $binary_file"
return 0
}
@@ -114,7 +115,8 @@ proc contains_ifunc_symbol { binary_file } {
global READELF
global READELFFLAGS
- catch "exec $READELF $READELFFLAGS --symbols $binary_file > readelf.out" got
+ set tmpfile [file dirname $binary_file]/readelf.out
+ catch "exec $READELF $READELFFLAGS --symbols $binary_file > $tmpfile" got
if ![string match "" $got] then {
verbose "proc contains_ifunc_symbol: Readelf produced unexpected out processing $binary_file: $got"
@@ -125,7 +127,7 @@ proc contains_ifunc_symbol { binary_file } {
# 58: 0000000000400600 30 IFUNC GLOBAL DEFAULT 12 library_func2
# with perhaps some other info between the visibility and section
- if { ![regexp ".*\[ \]*IFUNC\[ \]+GLOBAL\[ \]+DEFAULT .* \[UND0-9\]+\[ \]+library_func2\n" [file_contents readelf.out]] } {
+ if { ![regexp ".*\[ \]*IFUNC\[ \]+GLOBAL\[ \]+DEFAULT .* \[UND0-9\]+\[ \]+library_func2\n" [file_contents $tmpfile]] } {
return 0
}
@@ -140,7 +142,8 @@ proc contains_irelative_reloc { binary_file } {
global READELF
global READELFFLAGS
- catch "exec $READELF $READELFFLAGS --relocs --wide $binary_file > readelf.out" got
+ set tmpfile [file dirname $binary_file]/readelf.out
+ catch "exec $READELF $READELFFLAGS --relocs --wide $binary_file > $tmpfile" got
if ![string match "" $got] then {
verbose "proc contains_irelative_reloc: Readelf produced unexpected out processing $binary_file: $got"
@@ -152,7 +155,7 @@ proc contains_irelative_reloc { binary_file } {
# 080496f4 0000002a R_386_IRELATIVE
- if { ![regexp "\[0-9a-f\]+\[ \]+\[0-9a-f\]+\[ \]+R_(\[_0-9A-Z\]+_IREL(|ATIVE)|PARISC_IPLT).*\n" [file_contents readelf.out]] } {
+ if { ![regexp "\[0-9a-f\]+\[ \]+\[0-9a-f\]+\[ \]+R_(\[_0-9A-Z\]+_IREL(|ATIVE)|PARISC_IPLT).*\n" [file_contents $tmpfile]] } {
return 0
}
@@ -165,19 +168,20 @@ proc contains_ifunc_reloc { binary_file } {
global READELF
global READELFFLAGS
- catch "exec $READELF $READELFFLAGS --relocs $binary_file > readelf.out" got
+ set tmpfile [file dirname $binary_file]/readelf.out
+ catch "exec $READELF $READELFFLAGS --relocs $binary_file > $tmpfile" got
if ![string match "" $got] then {
verbose "proc contains_ifunc_reloc: Readelf produced unexpected out processing $binary_file: $got"
return -1
}
- if [string match "" [file_contents readelf.out]] then {
+ if [string match "" [file_contents $tmpfile]] then {
verbose "No relocs found in $binary_file"
return 0
}
- if { ![regexp "\\(\\)" [file_contents readelf.out]] } {
+ if { ![regexp "\\(\\)" [file_contents $tmpfile]] } {
return 0
}
diff --git a/ld/testsuite/ld-scripts/map-address.exp b/ld/testsuite/ld-scripts/map-address.exp
index 12277f9733b..1ff7a48fbd8 100644
--- a/ld/testsuite/ld-scripts/map-address.exp
+++ b/ld/testsuite/ld-scripts/map-address.exp
@@ -122,6 +122,8 @@ if {[regexp_diff \
pass $testname
}
+remote_file host delete fred
+
if { [is_elf_format] } {
set testname "map with locals"
diff --git a/ld/testsuite/ld-unique/unique.exp b/ld/testsuite/ld-unique/unique.exp
index e9b8c7ba528..b978c90b669 100644
--- a/ld/testsuite/ld-unique/unique.exp
+++ b/ld/testsuite/ld-unique/unique.exp
@@ -54,7 +54,8 @@ proc check_osabi { binary_file expected_osabi } {
global READELF
global READELFFLAGS
- catch "exec $READELF $READELFFLAGS --file-header $binary_file > readelf.out" got
+ set tmpfile [file dirname $binary_file]/readelf.out
+ catch "exec $READELF $READELFFLAGS --file-header $binary_file > $tmpfile" got
if ![string match "" $got] then {
verbose "proc check_osabi: Readelf produced unexpected out processing $binary_file: $got"
@@ -62,7 +63,7 @@ proc check_osabi { binary_file expected_osabi } {
}
if { ![regexp "\n\[ \]*OS/ABI:\[ \]*(.+)\n\[ \]*ABI" \
- [file_contents readelf.out] nil osabi] } {
+ [file_contents $tmpfile] nil osabi] } {
verbose "proc check_osabi: Readelf failed to extract an ELF header from $binary_file"
return 0
}
@@ -82,7 +83,8 @@ proc contains_unique_symbol { binary_file } {
global READELF
global READELFFLAGS
- catch "exec $READELF $READELFFLAGS --symbols $binary_file > readelf.out" got
+ set tmpfile [file dirname $binary_file]/readelf.out
+ catch "exec $READELF $READELFFLAGS --symbols $binary_file > $tmpfile" got
if ![string match "" $got] then {
verbose "proc contains_unique_symbol: Readelf produced unexpected out processing $binary_file: $got"
@@ -92,7 +94,7 @@ proc contains_unique_symbol { binary_file } {
# Look for a line like this:
# 54: 0000000000400474 4 OBJECT UNIQUE DEFAULT 13 a
- if { ![regexp ".*\[ \]*OBJECT\[ \]+UNIQUE\[ \]+DEFAULT\[ \]+\[UND0-9\]+\[ \]+\[ab\]_val\n" [file_contents readelf.out]] } {
+ if { ![regexp ".*\[ \]*OBJECT\[ \]+UNIQUE\[ \]+DEFAULT\[ \]+\[UND0-9\]+\[ \]+\[ab\]_val\n" [file_contents $tmpfile]] } {
return 0
}
diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp
index 1fd4692c2c0..d37d33cd96c 100644
--- a/ld/testsuite/lib/ld-lib.exp
+++ b/ld/testsuite/lib/ld-lib.exp
@@ -1141,8 +1141,10 @@ proc run_cc_link_tests { ldtests } {
if { [regexp_diff "dump.out" "$srcdir/$subdir/$dumpfile"] } then {
verbose -log "output is [file_contents "dump.out"]" 2
set failed 1
+ file delete "dump.out"
break
}
+ file delete "dump.out"
}
}
}
More information about the Binutils-cvs
mailing list