public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v3 1/4] more uses of standard_output_file
  2013-08-02 20:27 [PATCH v3 0/4] introduce test suite "parallel" mode Tom Tromey
@ 2013-08-02 20:27 ` Tom Tromey
  2013-08-02 20:27 ` [PATCH v3 3/4] add caching procs to test suite Tom Tromey
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2013-08-02 20:27 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

A few spots in lib make output files, either in "." or in
$objdir/$subdir.

This patch changes these spots to use standard_output_file.
This help the parallelization project.

	* lib/gdb.exp (build_id_debug_filename_get): Use
	standard_output_file.
	* lib/prelink-support.exp (section_get)
	(build_executable_own_libs): Use standard_output_file.
---
 gdb/testsuite/lib/gdb.exp             | 2 +-
 gdb/testsuite/lib/prelink-support.exp | 7 +++----
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 70b797e..b89c9cd 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -3890,7 +3890,7 @@ proc gdb_skip_xml_test { } {
 # converted to the form: .build-id/ab/cdef1234...89.debug
 # Return "" if no build-id found.
 proc build_id_debug_filename_get { exec } {
-    set tmp "${exec}-tmp"
+    set tmp [standard_output_file "${exec}-tmp"]
     set objcopy_program [transform objcopy]
 
     set result [catch "exec $objcopy_program -j .note.gnu.build-id -O binary $exec $tmp" output]
diff --git a/gdb/testsuite/lib/prelink-support.exp b/gdb/testsuite/lib/prelink-support.exp
index ef99783..f7d813f 100644
--- a/gdb/testsuite/lib/prelink-support.exp
+++ b/gdb/testsuite/lib/prelink-support.exp
@@ -18,9 +18,8 @@
 # for sections ".interp" or ".gnu_debuglink".
 
 proc section_get {exec section} {
-    global objdir
     global subdir
-    set tmp "${objdir}/${subdir}/section_get.tmp"
+    set tmp [standard_output_file section_get.tmp]
     set objcopy_program [transform objcopy]
 
     set command "exec $objcopy_program -O binary --set-section-flags $section=A --change-section-address $section=0 -j $section $exec $tmp"
@@ -117,12 +116,12 @@ proc file_copy {src dest} {
 # with -Wl,-soname,NAME.so are not copied.
 
 proc build_executable_own_libs {testname executable sources options {interp ""} {dir ""}} {
-    global objdir subdir
+    global subdir
 
     if {[build_executable $testname $executable $sources $options] == -1} {
 	return ""
     }
-    set binfile ${objdir}/${subdir}/${executable}
+    set binfile [standard_output_file ${executable}]
 
     set command "ldd $binfile"
     set test "ldd $executable"
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v3 4/4] introduce parallel mode
  2013-08-02 20:27 [PATCH v3 0/4] introduce test suite "parallel" mode Tom Tromey
                   ` (2 preceding siblings ...)
  2013-08-02 20:27 ` [PATCH v3 2/4] add standard_temp_file Tom Tromey
@ 2013-08-02 20:27 ` Tom Tromey
  2013-08-05 14:37 ` [PATCH v3 0/4] introduce test suite "parallel" mode Pedro Alves
  2013-08-13 15:41 ` Tom Tromey
  5 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2013-08-02 20:27 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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 bested 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-07-23  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.
---
 gdb/doc/gdbint.texinfo      | 43 ++++++++++++++++++++++----
 gdb/testsuite/lib/cache.exp | 21 +++++++++++++
 gdb/testsuite/lib/gdb.exp   | 73 +++++++++++++++++++++++++++++++++++++++++++--
 3 files changed, 128 insertions(+), 9 deletions(-)

diff --git a/gdb/doc/gdbint.texinfo b/gdb/doc/gdbint.texinfo
index 60805ad..b0f133f 100644
--- a/gdb/doc/gdbint.texinfo
+++ b/gdb/doc/gdbint.texinfo
@@ -7732,9 +7732,9 @@ UNRESOLVED: gdb.base/example.exp: This test script does not work on a remote hos
 
 Several variables exist to modify the behavior of the testsuite.
 
-@itemize @bullet
+@table @code
 
-@item @code{TRANSCRIPT}
+@item TRANSCRIPT
 
 Sometimes it is convenient to get a transcript of the commands which
 the testsuite sends to @value{GDBN}.  For example, if @value{GDBN}
@@ -7757,7 +7757,7 @@ make check RUNTESTFLAGS=TRANSCRIPT=y
 Note that the transcript is not always complete.  In particular, tests
 of completion can yield partial command lines.
 
-@item @code{GDB}
+@item GDB
 
 Sometimes one wishes to test a different @value{GDBN} than the one in the build
 directory.  For example, one may wish to run the testsuite on
@@ -7767,7 +7767,7 @@ directory.  For example, one may wish to run the testsuite on
 make check RUNTESTFLAGS=GDB=/usr/bin/gdb
 @end smallexample
 
-@item @code{GDBSERVER}
+@item GDBSERVER
 
 When testing a different @value{GDBN}, it is often useful to also test a
 different gdbserver.
@@ -7776,7 +7776,7 @@ different gdbserver.
 make check RUNTESTFLAGS="GDB=/usr/bin/gdb GDBSERVER=/usr/bin/gdbserver"
 @end smallexample
 
-@item @code{INTERNAL_GDBFLAGS}
+@item INTERNAL_GDBFLAGS
 
 When running the testsuite normally one doesn't want whatever is in
 @file{~/.gdbinit} to interfere with the tests, therefore the test harness
@@ -7803,7 +7803,38 @@ HOME=`pwd` runtest \
   INTERNAL_GDBFLAGS=-nw
 @end smallexample
 
-@end itemize
+@item GDB_PARALLEL
+
+When testing natively (that is, not with a remote host), the
+@value{GDBN} test suite can be run in a fully parallel mode.  In this
+mode, each @file{.exp} file can be run separately.  The test suite
+will ensure that all the temporary files created by the test suite do
+not clash, by putting them into separate directories.  This mode is
+primarily intended for use by the @file{Makefile}.
+
+To use this mode, set the @code{GDB_PARALLEL} on the @command{runtest}
+command line.  Before starting the tests, you must ensure that the
+directories @file{cache}, @file{outputs}, and @file{temp} in the test
+suite build directory are either empty or have been deleted.
+@file{cache} in particular is used to share data across invocations of
+@command{runtest}, and files there may affect the test results.  Note
+that the @file{Makefile} automatically does these deletions.
+
+@item GDB_INOTIFY
+
+For debugging parallel mode, it is handy to be able to see when a test
+case writes to a file outside of its designated output directory.
+
+If you have the @samp{inotify-tools} package installed, you can set
+the @code{GDB_INOTIFY} variable on the @command{runtest} command line.
+This will cause the test suite to watch for parallel-unsafe file
+creations and report them, both on @samp{stdout} and in the test suite
+@file{.log} file.
+
+This setting is only meaningful in conjunction with
+@code{GDB_PARALLEL}.
+
+@end table
 
 There are two ways to run the testsuite and pass additional parameters
 to DejaGnu.  The first is with @kbd{make check} and specifying the
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)
 }
 
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index ceaaa41..a2f6a8f 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -112,6 +112,12 @@ proc default_gdb_version {} {
     global GDB
     global INTERNAL_GDBFLAGS GDBFLAGS
     global gdb_prompt
+    global inotify_pid
+
+    if {[info exists inotify_pid]} {
+	eval exec kill $inotify_pid
+    }
+
     set output [remote_exec host "$GDB $INTERNAL_GDBFLAGS --version"]
     set tmp [lindex $output 1]
     set version ""
@@ -1246,6 +1252,7 @@ proc default_gdb_exit {} {
     global INTERNAL_GDBFLAGS GDBFLAGS
     global verbose
     global gdb_spawn_id
+    global inotify_log_file
 
     gdb_stop_suppressing_tests
 
@@ -1255,6 +1262,20 @@ proc default_gdb_exit {} {
 
     verbose "Quitting $GDB $INTERNAL_GDBFLAGS $GDBFLAGS"
 
+    if {[info exists inotify_log_file] && [file exists $inotify_log_file]} {
+	set fd [open $inotify_log_file]
+	set data [read -nonewline $fd]
+	close $fd
+
+	if {[string compare $data ""] != 0} {
+	    warning "parallel-unsafe file creations noticed"
+
+	    # Clear the log.
+	    set fd [open $inotify_log_file w]
+	    close $fd
+	}
+    }
+
     if { [is_remote host] && [board_info host exists fileid] } {
 	send_gdb "quit\n"
 	gdb_expect 10 {
@@ -3349,15 +3370,27 @@ proc default_gdb_init { args } {
 # the directory is returned.
 
 proc standard_output_file {basename} {
-    global objdir subdir
+    global objdir subdir gdb_test_file_name GDB_PARALLEL
 
-    return [file join $objdir $subdir $basename]
+    if {[info exists GDB_PARALLEL]} {
+	set dir [file join $objdir outputs $subdir $gdb_test_file_name]
+	file mkdir $dir
+	return [file join $dir $basename]
+    } else {
+	return [file join $objdir $subdir $basename]
+    }
 }
 
 # Return the name of a file in our standard temporary directory.
 
 proc standard_temp_file {basename} {
-    return $basename
+    global objdir GDB_PARALLEL
+
+    if {[info exists GDB_PARALLEL]} {
+	return [file join $objdir temp $basename]
+    } else {
+	return $basename
+    }
 }
 
 # Set 'testfile', 'srcfile', and 'binfile'.
@@ -3463,6 +3496,31 @@ proc gdb_init { args } {
     global timeout
     set timeout $gdb_test_timeout
 
+    # If GDB_INOTIFY is given, check for writes to '.'.  This is a
+    # debugging tool to help confirm that the test suite is
+    # parallel-safe.  You need "inotifywait" from the
+    # inotify-tools package to use this.
+    global GDB_INOTIFY inotify_pid
+    if {[info exists GDB_INOTIFY] && ![info exists inotify_pid]} {
+	global outdir tool inotify_log_file
+
+	set exclusions {outputs temp gdb[.](log|sum) cache}
+	set exclusion_re ([join $exclusions |])
+
+	set inotify_log_file [standard_temp_file inotify.out]
+	set inotify_pid [exec inotifywait -r -m -e move,create,delete . \
+			     --exclude $exclusion_re \
+			     |& tee -a $outdir/$tool.log $inotify_log_file &]
+
+	# Wait for the watches; hopefully this is long enough.
+	sleep 2
+
+	# Clear the log so that we don't emit a warning the first time
+	# we check it.
+	set fd [open $inotify_log_file w]
+	close $fd
+    }
+
     # Block writes to all banned variables, and invocation of all
     # banned procedures...
     global banned_variables
@@ -4258,6 +4316,15 @@ if {[info exists TRANSCRIPT]} {
   }
 }
 
+# If GDB_PARALLEL exists, then set up the parallel-mode directories.
+if {[info exists GDB_PARALLEL]} {
+    if {[is_remote host]} {
+	unset GDB_PARALLEL
+    } else {
+	file mkdir outputs temp cache
+    }
+}
+
 proc core_find {binfile {deletefiles {}} {arg ""}} {
     global objdir subdir
 
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v3 2/4] add standard_temp_file
  2013-08-02 20:27 [PATCH v3 0/4] introduce test suite "parallel" mode Tom Tromey
  2013-08-02 20:27 ` [PATCH v3 1/4] more uses of standard_output_file Tom Tromey
  2013-08-02 20:27 ` [PATCH v3 3/4] add caching procs to test suite Tom Tromey
@ 2013-08-02 20:27 ` Tom Tromey
  2013-08-02 20:27 ` [PATCH v3 4/4] introduce parallel mode Tom Tromey
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2013-08-02 20:27 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds a new helper proc, standard_temp_file.  This proc takes a
file name and returns a possibly-qualified form.  This lets us make
parallel runs use a directory other than ".", which helps the inotify
mode.

This initial patch introduces the proc and changes a few spots to use
it.

	* lib/gdb.exp (standard_temp_file): New proc.
	(support_complex_tests, is_ilp32_target, is_lp64_target)
	(is_amd64_regs_target, skip_altivec_tests, skip_vsx_tests): Use
	standard_temp_file.
---
 gdb/testsuite/lib/gdb.exp | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index b89c9cd..901ba6a 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -1708,8 +1708,8 @@ proc support_complex_tests {} {
     # Set up, compile, and execute a test program containing _Complex types.
     # Include the current process ID in the file names to prevent conflicts
     # with invocations for multiple testsuites.
-    set src complex[pid].c
-    set exe complex[pid].x
+    set src [standard_temp_file complex[pid].c]
+    set exe [standard_temp_file complex[pid].x]
 
     set f [open $src "w"]
     puts $f "int main() {"
@@ -1798,8 +1798,8 @@ proc is_ilp32_target {} {
     }
 
 
-    set src ilp32[pid].c
-    set obj ilp32[pid].o
+    set src [standard_temp_file ilp32[pid].c]
+    set obj [standard_temp_file ilp32[pid].o]
 
     set f [open $src "w"]
     puts $f "int dummy\[sizeof (int) == 4"
@@ -1836,8 +1836,8 @@ proc is_lp64_target {} {
         return $is_lp64_target_saved($board)
     }
 
-    set src lp64[pid].c
-    set obj lp64[pid].o
+    set src [standard_temp_file lp64[pid].c]
+    set obj [standard_temp_file lp64[pid].o]
 
     set f [open $src "w"]
     puts $f "int dummy\[sizeof (int) == 4"
@@ -1878,8 +1878,8 @@ proc is_amd64_regs_target {} {
         return $is_amd64_regs_target_saved($board)
     }
 
-    set src reg64[pid].s
-    set obj reg64[pid].o
+    set src [standard_temp_file reg64[pid].s]
+    set obj [standard_temp_file reg64[pid].o]
 
     set f [open $src "w"]
     foreach reg \
@@ -1960,8 +1960,8 @@ proc skip_altivec_tests {} {
     # Set up, compile, and execute a test program containing VMX instructions.
     # Include the current process ID in the file names to prevent conflicts
     # with invocations for multiple testsuites.
-    set src vmx[pid].c
-    set exe vmx[pid].x
+    set src [standard_temp_file vmx[pid].c]
+    set exe [standard_temp_file vmx[pid].x]
 
     set f [open $src "w"]
     puts $f "int main() {"
@@ -2046,8 +2046,8 @@ proc skip_vsx_tests {} {
         return 1
     }
 
-    set src vsx[pid].c
-    set exe vsx[pid].x
+    set src [standard_temp_file vsx[pid].c]
+    set exe [standard_temp_file vsx[pid].x]
 
     set f [open $src "w"]
     puts $f "int main() {"
@@ -3401,6 +3401,12 @@ proc standard_output_file {basename} {
     return [file join $objdir $subdir $basename]
 }
 
+# Return the name of a file in our standard temporary directory.
+
+proc standard_temp_file {basename} {
+    return $basename
+}
+
 # Set 'testfile', 'srcfile', and 'binfile'.
 #
 # ARGS is a list of source file specifications.
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v3 0/4] introduce test suite "parallel" mode
@ 2013-08-02 20:27 Tom Tromey
  2013-08-02 20:27 ` [PATCH v3 1/4] more uses of standard_output_file Tom Tromey
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Tom Tromey @ 2013-08-02 20:27 UTC (permalink / raw)
  To: gdb-patches

Revision 3 of the initial parallel mode test suite change.
Revision 2 is here:

    http://sourceware.org/ml/gdb-patches/2013-08/msg00077.html

This revision addresses Pedro's comment about moving the
standard_temp_file calls into a different patch.  I moved them to the
patch that introduces standard_temp_file, which seemed logical.

This also fixes a think in patch #3: a couple of procs did not
actually use gdb_caching_proc, though they were intended to.

Regtested on x86-64 Fedora 18.

Tom

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v3 3/4] add caching procs to test suite
  2013-08-02 20:27 [PATCH v3 0/4] introduce test suite "parallel" mode Tom Tromey
  2013-08-02 20:27 ` [PATCH v3 1/4] more uses of standard_output_file Tom Tromey
@ 2013-08-02 20:27 ` Tom Tromey
  2013-08-02 20:27 ` [PATCH v3 2/4] add standard_temp_file Tom Tromey
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2013-08-02 20:27 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

In the fully parallel mode, each .exp file can be run in parallel (at
least conceptually -- the actual split may not be so severe).  This
means that procs that compute a result and cache it are not going to
function very well.  The test they run will be invoked over and over.

This patch introduces a generic caching mechanism and changes various
result-caching procs to use it.  This is a cleanup to introduce the
basic change; the results aren't written to disk yet.

A caching proc is defined using gdb_caching_proc, which works like
"proc", except that it caches the result of the body.

	* lib/cache.exp: New file.
	* lib/cell.exp (skip_cell_tests): Use gdb_caching_proc.
	* lib/gdb.exp: Load cache.exp.
	(support_complex_tests, is_ilp32_target, is_lp64_target)
	(is_amd64_regs_target, skip_altivec_tests, skip_vsx_tests)
	(gdb_skip_xml_test): Use gdb_caching_proc.
	* lib/opencl.exp (skip_opencl_tests): Use gdb_caching_proc.
---
 gdb/testsuite/lib/cache.exp  |  54 +++++++++++++++++++
 gdb/testsuite/lib/cell.exp   |  20 +++-----
 gdb/testsuite/lib/gdb.exp    | 120 ++++++++++++-------------------------------
 gdb/testsuite/lib/opencl.exp |  24 ++++-----
 4 files changed, 104 insertions(+), 114 deletions(-)
 create mode 100644 gdb/testsuite/lib/cache.exp

diff --git a/gdb/testsuite/lib/cache.exp b/gdb/testsuite/lib/cache.exp
new file mode 100644
index 0000000..1de0dfd
--- /dev/null
+++ b/gdb/testsuite/lib/cache.exp
@@ -0,0 +1,54 @@
+# Copyright 2012, 2013 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+# The in-memory cache.
+array set gdb_data_cache {}
+
+# A helper for gdb_caching_proc that handles the caching.
+
+proc gdb_do_cache {name} {
+    global gdb_data_cache objdir
+
+    # See if some other process wrote the cache file.  Cache value per
+    # "board" to handle runs with multiple options
+    # (e.g. unix/{-m32,-64}) correctly.  We use "file join" here
+    # because we later use this in a real filename.
+    set cache_name [file join [target_info name] $name]
+
+    if {[info exists gdb_data_cache($cache_name)]} {
+	verbose "$name: returning '$gdb_data_cache($cache_name)' from cache" 2
+	return $gdb_data_cache($cache_name)
+    }
+
+    set real_name gdb_real__$name
+    set gdb_data_cache($cache_name) [uplevel 1 $real_name]
+
+    return $gdb_data_cache($cache_name)
+}
+
+# Define a new proc named NAME that takes no arguments.  BODY is the
+# body of the proc.  The proc will evaluate BODY and cache the
+# results, both in memory and, if GDB_PARALLEL is defined, in the
+# filesystem for use across invocations of dejagnu.
+
+proc gdb_caching_proc {name body} {
+    # Define the underlying proc that we'll call.
+    set real_name gdb_real__$name
+    proc $real_name {} $body
+
+    # Define the advertised proc.
+    proc $name {} [list gdb_do_cache $name]
+}
diff --git a/gdb/testsuite/lib/cell.exp b/gdb/testsuite/lib/cell.exp
index e799b7f..9a20f5c 100644
--- a/gdb/testsuite/lib/cell.exp
+++ b/gdb/testsuite/lib/cell.exp
@@ -70,16 +70,10 @@ proc gdb_cell_embedspu {source dest options} {
 
 # Run a test on the target to see if it supports Cell/B.E. hardware.
 # Return 0 if so, 1 if it does not.
-proc skip_cell_tests {} {
-    global skip_cell_tests_saved
+gdb_caching_proc skip_cell_tests {
     global srcdir subdir gdb_prompt inferior_exited_re
 
-    # Use the cached value, if it exists.
     set me "skip_cell_tests"
-    if [info exists skip_cell_tests_saved] {
-        verbose "$me:  returning saved $skip_cell_tests_saved" 2
-        return $skip_cell_tests_saved
-    }
 
     # Set up, compile, and execute a combined Cell/B.E. test program.
     # Include the current process ID in the file names to prevent conflicts
@@ -125,7 +119,7 @@ proc skip_cell_tests {} {
     file delete $exe_spu-embed.o
 
     if { $skip } {
-        return [set skip_cell_tests_saved 1]
+        return 1
     }
 
     # Compilation succeeded so now run it via gdb.
@@ -138,22 +132,22 @@ proc skip_cell_tests {} {
     gdb_expect {
         -re ".*$inferior_exited_re normally.*${gdb_prompt} $" {
             verbose -log "\n$me: Cell/B.E. hardware detected"
-            set skip_cell_tests_saved 0
+            set result 0
         }
         -re ".*$inferior_exited_re with code.*${gdb_prompt} $" {
             verbose -log "\n$me: Cell/B.E. hardware not detected"
-            set skip_cell_tests_saved 1
+            set result 1
         }
         default {
             verbose -log "\n$me Cell/B.E. hardware not detected (default case)"
-            set skip_cell_tests_saved 1
+            set result 1
         }
     }
     gdb_exit
     remote_file build delete $exe
 
-    verbose "$me:  returning $skip_cell_tests_saved" 2
-    return $skip_cell_tests_saved
+    verbose "$me:  returning $result" 2
+    return $result
 }
 
 # Delete all breakpoints and stop on the next new SPU thread
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 901ba6a..ceaaa41 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -26,6 +26,7 @@ if {$tool == ""} {
 }
 
 load_lib libgloss.exp
+load_lib cache.exp
 
 global GDB
 
@@ -1696,15 +1697,7 @@ proc with_test_prefix { prefix body } {
 
 # Return 1 if _Complex types are supported, otherwise, return 0.
 
-proc support_complex_tests {} {
-    global support_complex_tests_saved
-
-    # Use the cached value, if it exists.
-    if [info exists support_complex_tests_saved] {
-        verbose "returning saved $support_complex_tests_saved" 2
-        return $support_complex_tests_saved
-    }
-
+gdb_caching_proc support_complex_tests {
     # Set up, compile, and execute a test program containing _Complex types.
     # Include the current process ID in the file names to prevent conflicts
     # with invocations for multiple testsuites.
@@ -1727,12 +1720,12 @@ proc support_complex_tests {} {
 
     if ![string match "" $lines] then {
         verbose "testfile compilation failed, returning 0" 2
-        set support_complex_tests_saved 0
+        set result 0
     } else {
-	set support_complex_tests_saved 1
+	set result 1
     }
 
-    return $support_complex_tests_saved
+    return $result
 }
 
 # Return 1 if target hardware or OS supports single stepping to signal
@@ -1785,18 +1778,8 @@ proc supports_reverse {} {
 # Return 1 if target is ILP32.
 # This cannot be decided simply from looking at the target string,
 # as it might depend on externally passed compiler options like -m64.
-proc is_ilp32_target {} {
-    global is_ilp32_target_saved
-
-    # Use the cached value, if it exists.  Cache value per "board" to handle
-    # runs with multiple options (e.g. unix/{-m32,-64}) correctly.
+gdb_caching_proc is_ilp32_target {
     set me "is_ilp32_target"
-    set board [target_info name]
-    if [info exists is_ilp32_target_saved($board)] {
-        verbose "$me:  returning saved $is_ilp32_target_saved($board)" 2
-        return $is_ilp32_target_saved($board)
-    }
-
 
     set src [standard_temp_file ilp32[pid].c]
     set obj [standard_temp_file ilp32[pid].o]
@@ -1814,27 +1797,18 @@ proc is_ilp32_target {} {
 
     if ![string match "" $lines] then {
         verbose "$me:  testfile compilation failed, returning 0" 2
-        return [set is_ilp32_target_saved($board) 0]
+        return 0
     }
 
     verbose "$me:  returning 1" 2
-    return [set is_ilp32_target_saved($board) 1]
+    return 1
 }
 
 # Return 1 if target is LP64.
 # This cannot be decided simply from looking at the target string,
 # as it might depend on externally passed compiler options like -m64.
-proc is_lp64_target {} {
-    global is_lp64_target_saved
-
-    # Use the cached value, if it exists.  Cache value per "board" to handle
-    # runs with multiple options (e.g. unix/{-m32,-64}) correctly.
+gdb_caching_proc is_lp64_target {
     set me "is_lp64_target"
-    set board [target_info name]
-    if [info exists is_lp64_target_saved($board)] {
-        verbose "$me:  returning saved $is_lp64_target_saved($board)" 2
-        return $is_lp64_target_saved($board)
-    }
 
     set src [standard_temp_file lp64[pid].c]
     set obj [standard_temp_file lp64[pid].o]
@@ -1852,31 +1826,22 @@ proc is_lp64_target {} {
 
     if ![string match "" $lines] then {
         verbose "$me:  testfile compilation failed, returning 0" 2
-        return [set is_lp64_target_saved($board) 0]
+        return 0
     }
 
     verbose "$me:  returning 1" 2
-    return [set is_lp64_target_saved($board) 1]
+    return 1
 }
 
 # Return 1 if target has x86_64 registers - either amd64 or x32.
 # x32 target identifies as x86_64-*-linux*, therefore it cannot be determined
 # just from the target string.
-proc is_amd64_regs_target {} {
-    global is_amd64_regs_target_saved
-
+gdb_caching_proc is_amd64_regs_target {
     if {![istarget "x86_64-*-*"] && ![istarget "i?86-*"]} {
 	return 0
     }
 
-    # Use the cached value, if it exists.  Cache value per "board" to handle
-    # runs with multiple options (e.g. unix/{-m32,-64}) correctly.
     set me "is_amd64_regs_target"
-    set board [target_info name]
-    if [info exists is_amd64_regs_target_saved($board)] {
-        verbose "$me:  returning saved $is_amd64_regs_target_saved($board)" 2
-        return $is_amd64_regs_target_saved($board)
-    }
 
     set src [standard_temp_file reg64[pid].s]
     set obj [standard_temp_file reg64[pid].o]
@@ -1895,11 +1860,11 @@ proc is_amd64_regs_target {} {
 
     if ![string match "" $lines] then {
         verbose "$me:  testfile compilation failed, returning 0" 2
-        return [set is_amd64_regs_target_saved($board) 0]
+        return 0
     }
 
     verbose "$me:  returning 1" 2
-    return [set is_amd64_regs_target_saved($board) 1]
+    return 1
 }
 
 # Return 1 if this target is an x86 or x86-64 with -m32.
@@ -1925,21 +1890,15 @@ proc support_displaced_stepping {} {
 # Run a test on the target to see if it supports vmx hardware.  Return 0 if so, 
 # 1 if it does not.  Based on 'check_vmx_hw_available' from the GCC testsuite.
 
-proc skip_altivec_tests {} {
-    global skip_vmx_tests_saved
+gdb_caching_proc skip_altivec_tests {
     global srcdir subdir gdb_prompt inferior_exited_re
 
-    # Use the cached value, if it exists.
     set me "skip_altivec_tests"
-    if [info exists skip_vmx_tests_saved] {
-        verbose "$me:  returning saved $skip_vmx_tests_saved" 2
-        return $skip_vmx_tests_saved
-    }
 
     # Some simulators are known to not support VMX instructions.
     if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
         verbose "$me:  target known to not support VMX, returning 1" 2
-        return [set skip_vmx_tests_saved 1]
+        return 1
     }
 
     # Make sure we have a compiler that understands altivec.
@@ -1979,7 +1938,7 @@ proc skip_altivec_tests {} {
 
     if ![string match "" $lines] then {
         verbose "$me:  testfile compilation failed, returning 1" 2
-        return [set skip_vmx_tests_saved 1]
+        return 1
     }
 
     # No error message, compilation succeeded so now run it via gdb.
@@ -1992,43 +1951,37 @@ proc skip_altivec_tests {} {
     gdb_expect {
         -re ".*Illegal instruction.*${gdb_prompt} $" {
             verbose -log "\n$me altivec hardware not detected" 
-            set skip_vmx_tests_saved 1
+            set skip_vmx_tests 1
         }
         -re ".*$inferior_exited_re normally.*${gdb_prompt} $" {
             verbose -log "\n$me: altivec hardware detected" 
-            set skip_vmx_tests_saved 0
+            set skip_vmx_tests 0
         }
         default {
           warning "\n$me: default case taken"
-            set skip_vmx_tests_saved 1
+            set skip_vmx_tests 1
         }
     }
     gdb_exit
     remote_file build delete $exe
 
-    verbose "$me:  returning $skip_vmx_tests_saved" 2
-    return $skip_vmx_tests_saved
+    verbose "$me:  returning $skip_vmx_tests" 2
+    return $skip_vmx_tests
 }
 
 # Run a test on the target to see if it supports vmx hardware.  Return 0 if so,
 # 1 if it does not.  Based on 'check_vmx_hw_available' from the GCC testsuite.
 
-proc skip_vsx_tests {} {
-    global skip_vsx_tests_saved
+gdb_caching_proc skip_vsx_tests {
     global srcdir subdir gdb_prompt inferior_exited_re
 
-    # Use the cached value, if it exists.
     set me "skip_vsx_tests"
-    if [info exists skip_vsx_tests_saved] {
-        verbose "$me:  returning saved $skip_vsx_tests_saved" 2
-        return $skip_vsx_tests_saved
-    }
 
     # Some simulators are known to not support Altivec instructions, so
     # they won't support VSX instructions as well.
     if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
         verbose "$me:  target known to not support VSX, returning 1" 2
-        return [set skip_vsx_tests_saved 1]
+        return 1
     }
 
     # Make sure we have a compiler that understands altivec.
@@ -2066,7 +2019,7 @@ proc skip_vsx_tests {} {
 
     if ![string match "" $lines] then {
         verbose "$me:  testfile compilation failed, returning 1" 2
-        return [set skip_vsx_tests_saved 1]
+        return 1
     }
 
     # No error message, compilation succeeded so now run it via gdb.
@@ -2079,22 +2032,22 @@ proc skip_vsx_tests {} {
     gdb_expect {
         -re ".*Illegal instruction.*${gdb_prompt} $" {
             verbose -log "\n$me VSX hardware not detected"
-            set skip_vsx_tests_saved 1
+            set skip_vsx_tests 1
         }
         -re ".*$inferior_exited_re normally.*${gdb_prompt} $" {
             verbose -log "\n$me: VSX hardware detected"
-            set skip_vsx_tests_saved 0
+            set skip_vsx_tests 0
         }
         default {
           warning "\n$me: default case taken"
-            set skip_vsx_tests_saved 1
+            set skip_vsx_tests 1
         }
     }
     gdb_exit
     remote_file build delete $exe
 
-    verbose "$me:  returning $skip_vsx_tests_saved" 2
-    return $skip_vsx_tests_saved
+    verbose "$me:  returning $skip_vsx_tests" 2
+    return $skip_vsx_tests
 }
 
 # Run a test on the target to see if it supports btrace hardware.  Return 0 if so,
@@ -3855,25 +3808,20 @@ proc gdb_skip_bogus_test { msg } {
 # in the host GDB.
 # NOTE: This must be called while gdb is *not* running.
 
-proc gdb_skip_xml_test { } {
+gdb_caching_proc gdb_skip_xml_test {
     global gdb_prompt
     global srcdir
-    global xml_missing_cached
-
-    if {[info exists xml_missing_cached]} {
-	return $xml_missing_cached
-    }
 
     gdb_start
-    set xml_missing_cached 0
+    set xml_missing 0
     gdb_test_multiple "set tdesc filename ${srcdir}/gdb.xml/trivial.xml" "" {
 	-re ".*XML support was disabled at compile time.*$gdb_prompt $" {
-	    set xml_missing_cached 1
+	    set xml_missing 1
 	}
 	-re ".*$gdb_prompt $" { }
     }
     gdb_exit
-    return $xml_missing_cached
+    return $xml_missing
 }
 
 # Note: the procedure gdb_gnu_strip_debug will produce an executable called
diff --git a/gdb/testsuite/lib/opencl.exp b/gdb/testsuite/lib/opencl.exp
index 5afb3f8..3249139 100644
--- a/gdb/testsuite/lib/opencl.exp
+++ b/gdb/testsuite/lib/opencl.exp
@@ -29,18 +29,11 @@ proc gdb_compile_opencl_hostapp {clsource executable options} {
 
 # Run a test on the target to check if it supports OpenCL. Return 0 if so, 1 if
 # it does not.
-proc skip_opencl_tests {} {
-    global skip_opencl_tests_saved srcdir objdir subdir gdb_prompt
+gdb_caching_proc skip_opencl_tests {
+    global srcdir objdir subdir gdb_prompt
     global inferior_exited_re
 
-    # Use the cached value, if it exists.  Cache value per "board" to handle
-    # runs with multiple options (e.g. unix/{-m32,-64}) correctly.
     set me "skip_opencl_tests"
-    set board [target_info name]
-    if [info exists skip_opencl_tests_saved($board)] {
-        verbose "$me:  returning saved $skip_opencl_tests_saved($board)" 2
-        return $skip_opencl_tests_saved($board)
-    }
 
     # Set up, compile, and execute an OpenCL program.  Include the current
     # process ID in the file name of the executable to prevent conflicts with
@@ -52,8 +45,9 @@ proc skip_opencl_tests {} {
     set compile_flags {debug nowarnings quiet}
 
     if { [gdb_compile_opencl_hostapp "${clprogram}" "${executable}" "${compile_flags}" ] != "" } {
+	remote_file target delete ${clprogram}
         verbose "$me:  compiling OpenCL binary failed, returning 1" 2
-	return [set skip_opencl_tests_saved($board) 1]
+	return 1
     }
 
     # Compilation succeeded so now run it via gdb.
@@ -62,15 +56,15 @@ proc skip_opencl_tests {} {
     gdb_expect 30 {
         -re ".*$inferior_exited_re normally.*${gdb_prompt} $" {
             verbose -log "\n$me: OpenCL support detected"
-            set skip_opencl_tests_saved($board) 0
+            set result 0
         }
         -re ".*$inferior_exited_re code.*${gdb_prompt} $" {
             verbose -log "\n$me: OpenCL support not detected"
-            set skip_opencl_tests_saved($board) 1
+            set result 1
         }
         default {
             verbose -log "\n$me OpenCL support not detected (default case)"
-            set skip_opencl_tests_saved($board) 1
+            set result 1
         }
     }
     gdb_exit
@@ -79,6 +73,6 @@ proc skip_opencl_tests {} {
     # Delete the OpenCL program source file.
     remote_file target delete ${clprogram}
 
-    verbose "$me:  returning $skip_opencl_tests_saved($board)" 2
-    return $skip_opencl_tests_saved($board)
+    verbose "$me:  returning $result" 2
+    return $result
 }
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 0/4] introduce test suite "parallel" mode
  2013-08-02 20:27 [PATCH v3 0/4] introduce test suite "parallel" mode Tom Tromey
                   ` (3 preceding siblings ...)
  2013-08-02 20:27 ` [PATCH v3 4/4] introduce parallel mode Tom Tromey
@ 2013-08-05 14:37 ` Pedro Alves
  2013-08-13 15:41 ` Tom Tromey
  5 siblings, 0 replies; 7+ messages in thread
From: Pedro Alves @ 2013-08-05 14:37 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 08/02/2013 09:27 PM, Tom Tromey wrote:
> Revision 3 of the initial parallel mode test suite change.
> Revision 2 is here:
> 
>     http://sourceware.org/ml/gdb-patches/2013-08/msg00077.html
> 
> This revision addresses Pedro's comment about moving the
> standard_temp_file calls into a different patch.  I moved them to the
> patch that introduces standard_temp_file, which seemed logical.

Thanks, this revision does make it clearer which sort of files
are being considered temporary files.

> 
> This also fixes a think in patch #3: a couple of procs did not
> actually use gdb_caching_proc, though they were intended to.
> 
> Regtested on x86-64 Fedora 18.

I have no further comments.

-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 0/4] introduce test suite "parallel" mode
  2013-08-02 20:27 [PATCH v3 0/4] introduce test suite "parallel" mode Tom Tromey
                   ` (4 preceding siblings ...)
  2013-08-05 14:37 ` [PATCH v3 0/4] introduce test suite "parallel" mode Pedro Alves
@ 2013-08-13 15:41 ` Tom Tromey
  5 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2013-08-13 15:41 UTC (permalink / raw)
  To: gdb-patches

>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:

Tom> Revision 3 of the initial parallel mode test suite change.
Tom> Revision 2 is here:

Tom>     http://sourceware.org/ml/gdb-patches/2013-08/msg00077.html

I'm checking in this series now.

Tom

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-08-13 15:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-02 20:27 [PATCH v3 0/4] introduce test suite "parallel" mode Tom Tromey
2013-08-02 20:27 ` [PATCH v3 1/4] more uses of standard_output_file Tom Tromey
2013-08-02 20:27 ` [PATCH v3 3/4] add caching procs to test suite Tom Tromey
2013-08-02 20:27 ` [PATCH v3 2/4] add standard_temp_file Tom Tromey
2013-08-02 20:27 ` [PATCH v3 4/4] introduce parallel mode Tom Tromey
2013-08-05 14:37 ` [PATCH v3 0/4] introduce test suite "parallel" mode Pedro Alves
2013-08-13 15:41 ` Tom Tromey

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).