diff options
author | Tom de Vries <tdevries@suse.de> | 2020-03-06 18:03:01 +0100 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2020-03-06 18:03:01 +0100 |
commit | 436b5e99c8eef55433f2c1de35d8f960425aa4c1 (patch) | |
tree | daa48dfa8928d6d145a188d50a5a6881d8fccb39 /gdb | |
parent | 31bf18645d98b4d3d7357353be840e320649a67d (diff) | |
download | fsf-binutils-gdb-436b5e99c8eef55433f2c1de35d8f960425aa4c1.zip fsf-binutils-gdb-436b5e99c8eef55433f2c1de35d8f960425aa4c1.tar.gz fsf-binutils-gdb-436b5e99c8eef55433f2c1de35d8f960425aa4c1.tar.bz2 |
[gdb/testsuite] Fix "text file busy" errors with cc-with-tweaks.exp
When using target board cc-with-gdb-index.exp and running tests in parallel,
we run into:
...
gdb compile failed, gdb/contrib/gdb-add-index.sh: line 86: \
build/gdb/testsuite/gdb.sh: Text file busy
...
The problem is that because of the parallel test run, gdb.sh is created for
every single test-case, and eventually gdb.sh is overwritten while being
executed.
Fix this by creating gdb.sh only once.
Tested on x86_64-linux with target board cc-with-gdb-index.exp, using both a
serial and parallel -j 5 test run.
gdb/testsuite/ChangeLog:
2020-03-06 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (tentative_rename, cached_file): New proc.
* boards/cc-with-tweaks.exp: Use cached_file to create gdb.sh.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/testsuite/boards/cc-with-tweaks.exp | 6 | ||||
-rw-r--r-- | gdb/testsuite/lib/gdb.exp | 42 |
3 files changed, 49 insertions, 4 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index f1c9b2c..912cdf3 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2020-03-06 Tom de Vries <tdevries@suse.de> + * lib/gdb.exp (tentative_rename, cached_file): New proc. + * boards/cc-with-tweaks.exp: Use cached_file to create gdb.sh. + +2020-03-06 Tom de Vries <tdevries@suse.de> + * README: Fix "the the". * gdb.base/dprintf.exp: Same. diff --git a/gdb/testsuite/boards/cc-with-tweaks.exp b/gdb/testsuite/boards/cc-with-tweaks.exp index a60507a..8701ccd 100644 --- a/gdb/testsuite/boards/cc-with-tweaks.exp +++ b/gdb/testsuite/boards/cc-with-tweaks.exp @@ -69,7 +69,5 @@ if ![info exists F77_FOR_TARGET] { } set F77_FOR_TARGET "$contrib_dir/cc-with-tweaks.sh $CC_WITH_TWEAKS_FLAGS $F77_FOR_TARGET" -set pwd [exec pwd -P] -exec echo $GDB $INTERNAL_GDBFLAGS $GDBFLAGS \"\$@\" > $pwd/gdb.sh -exec chmod +x gdb.sh -set env(GDB) $pwd/gdb.sh +set env(GDB) \ + [cached_file gdb.sh "$GDB $INTERNAL_GDBFLAGS $GDBFLAGS \"\$@\"" 1] diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index f8f404f..55e5858 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -4929,6 +4929,48 @@ proc standard_temp_file {basename} { return [file join $dir $basename] } +# Rename file A to file B, if B does not already exists. Otherwise, leave B +# as is and delete A. Return 1 if rename happened. + +proc tentative_rename { a b } { + global errorInfo errorCode + set code [catch {file rename -- $a $b} result] + if { $code == 1 && [lindex $errorCode 0] == "POSIX" \ + && [lindex $errorCode 1] == "EEXIST" } { + file delete $a + return 0 + } + if {$code == 1} { + return -code error -errorinfo $errorInfo -errorcode $errorCode $result + } elseif {$code > 1} { + return -code $code $result + } + return 1 +} + +# Create a file with name FILENAME and contents TXT in the cache directory. +# If EXECUTABLE, mark the new file for execution. + +proc cached_file { filename txt {executable 0}} { + set filename [make_gdb_parallel_path cache $filename] + + if { [file exists $filename] } { + return $filename + } + + set tmp_filename $filename.[pid] + set fd [open $tmp_filename w] + puts $fd $txt + close $fd + + if { $executable } { + exec chmod +x $tmp_filename + } + tentative_rename $tmp_filename $filename + + return $filename +} + # Set 'testfile', 'srcfile', and 'binfile'. # # ARGS is a list of source file specifications. |