aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/lib/cache.exp
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2013-08-13 16:12:04 +0000
committerTom Tromey <tromey@redhat.com>2013-08-13 16:12:04 +0000
commit5e92f71a868595fcefd90ad1737c0f994a58d551 (patch)
tree164562b44da91489f9fd865bda9c5b3706b8ac71 /gdb/testsuite/lib/cache.exp
parent5c30d39a69a4da5d011db4d52c15042561d53ce0 (diff)
downloadgdb-5e92f71a868595fcefd90ad1737c0f994a58d551.zip
gdb-5e92f71a868595fcefd90ad1737c0f994a58d551.tar.gz
gdb-5e92f71a868595fcefd90ad1737c0f994a58d551.tar.bz2
introduce parallel mode
This introduces parallel mode for the test suite. It doesn't fully work yet in the sense that if you do a fully parallel run, you will encounter some file-name clashes, but this has to start somewhere, and it seemed best to add some infrastructure now, so that you can follow along and test subsequent patches if you care to. This patch has two parts. First, it checks for the GDB_PARALLEL variable. If this is set (say, on the runtest command line), then the test suite assumes "parallel mode". In this mode, files are put into a subdirectory named after the test. That is, for DIR/TEST.exp, the outputs are put into ./outputs/DIR/TEST/. This first part has various follow-on changes coming in subsequent patches. This is why the code in this patch also makes "temp" and "cache" directories. Second, this adds an "inotify" mode. If you have the inotifywait command (part of inotify-tools), you can set the GDB_INOTIFY variable. This will tell the test suite to watch for changes outside of the allowed output directories. This mode is useful for debugging the test suite, as it issues a report whenever a possibly parallel-unsafe file open is done. 2013-08-13 Tom Tromey <tromey@redhat.com> Yao Qi <yao@codesourcery.com> * lib/cache.exp (gdb_do_cache): Handle GDB_PARALLEL. * lib/gdb.exp: Handle GDB_PARALLEL. (default_gdb_version): Kill inotify_pid if it exists. (default_gdb_exit): Emit warning if the inotify log is not empty. (standard_output_file): Respect GDB_PARALLEL. (standard_temp_file): Likewise. (gdb_init): Start inotifywait if requested. * gdbint.texinfo (Testsuite): Use @table, not @itemize. Document GDB_PARALLEL and GDB_INOTIFY.
Diffstat (limited to 'gdb/testsuite/lib/cache.exp')
-rw-r--r--gdb/testsuite/lib/cache.exp21
1 files changed, 21 insertions, 0 deletions
diff --git a/gdb/testsuite/lib/cache.exp b/gdb/testsuite/lib/cache.exp
index 1de0dfd..e669ebf 100644
--- a/gdb/testsuite/lib/cache.exp
+++ b/gdb/testsuite/lib/cache.exp
@@ -21,6 +21,7 @@ array set gdb_data_cache {}
proc gdb_do_cache {name} {
global gdb_data_cache objdir
+ global GDB_PARALLEL
# See if some other process wrote the cache file. Cache value per
# "board" to handle runs with multiple options
@@ -33,9 +34,29 @@ proc gdb_do_cache {name} {
return $gdb_data_cache($cache_name)
}
+ if {[info exists GDB_PARALLEL]} {
+ set cache_filename [file join $objdir cache $cache_name]
+ if {[file exists $cache_filename]} {
+ set fd [open $cache_filename]
+ set gdb_data_cache($cache_name) [read -nonewline $fd]
+ close $fd
+ verbose "$name: returning '$gdb_data_cache($cache_name)' from file cache" 2
+ return $gdb_data_cache($cache_name)
+ }
+ }
+
set real_name gdb_real__$name
set gdb_data_cache($cache_name) [uplevel 1 $real_name]
+ if {[info exists GDB_PARALLEL]} {
+ verbose "$name: returning '$gdb_data_cache($cache_name)' and writing file" 2
+ file mkdir [file dirname $cache_filename]
+ # Make sure to write the results file atomically.
+ set fd [open $cache_filename.[pid] w]
+ puts $fd $gdb_data_cache($cache_name)
+ close $fd
+ file rename -force -- $cache_filename.[pid] $cache_filename
+ }
return $gdb_data_cache($cache_name)
}