Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@redhat.com>
Subject: [PATCH 2/4] introduce parallel mode
Date: Wed, 17 Jul 2013 14:59:00 -0000	[thread overview]
Message-ID: <1374073124-23602-3-git-send-email-tromey@redhat.com> (raw)
In-Reply-To: <1374073124-23602-1-git-send-email-tromey@redhat.com>

This introduces parallel mode for the test suite.

It doesn't work yet -- there are many patches to go -- but it 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.

	* lib/gdb.exp: Handle GDB_PARALLEL and GDB_INOTIFY.
	(default_gdb_version): Kill inotify_pid if it exists.
	(standard_output_file): Respect GDB_PARALLEL.
---
 gdb/testsuite/lib/gdb.exp | 35 +++++++++++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 1ca4354..b12f466 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -111,6 +111,12 @@ proc default_gdb_version {} {
     global GDB
     global INTERNAL_GDBFLAGS GDBFLAGS
     global gdb_prompt
+    global inotify_pid
+
+    if {[info exists inotify_pid]} {
+	exec kill $inotify_pid
+    }
+
     set output [remote_exec host "$GDB $INTERNAL_GDBFLAGS --version"]
     set tmp [lindex $output 1]
     set version ""
@@ -3379,9 +3385,15 @@ 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]
+    }
 }
 
 # Set 'testfile', 'srcfile', and 'binfile'.
@@ -4287,6 +4299,25 @@ if {[info exists TRANSCRIPT]} {
   }
 }
 
+# If GDB_PARALLEL exists, then set up the parallel-mode directories.
+if {[info exists GDB_PARALLEL]} {
+    file mkdir outputs temp cache
+
+    # 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.
+    if {[info exists GDB_INOTIFY]} {
+	set exclusions {outputs temp gdb[.](log|sum) cache}
+	set exclusion_re ([join $exclusions |])
+
+	set inotify_pid [exec inotifywait -r -m -e move,create,delete . \
+			     --exclude $exclusion_re &]
+	# Wait for the watches; hopefully this is long enough.
+	sleep 2
+    }
+}
+
 proc core_find {binfile {deletefiles {}} {arg ""}} {
     global objdir subdir
 
-- 
1.8.1.4


  reply	other threads:[~2013-07-17 14:58 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-17 14:58 [PATCH 0/4] introduce test suite "parallel" mode Tom Tromey
2013-07-17 14:59 ` Tom Tromey [this message]
2013-07-18 12:42   ` [PATCH 2/4] introduce parallel mode Yao Qi
2013-07-18 13:36     ` Tom Tromey
2013-07-18 22:22       ` Yao Qi
2013-08-01 19:45         ` Tom Tromey
2013-08-01 20:58           ` Tom Tromey
2013-08-02  6:23           ` Yao Qi
2013-08-02  8:41           ` Pedro Alves
2013-08-02 15:02             ` Tom Tromey
2013-08-01 16:56   ` Pedro Alves
2013-07-17 14:59 ` [PATCH 3/4] add standard_temp_file Tom Tromey
2013-07-17 14:59 ` [PATCH 1/4] more uses of standard_output_file Tom Tromey
2013-07-17 14:59 ` [PATCH 4/4] add caching procs to test suite Tom Tromey
2013-08-01 17:10   ` Pedro Alves
2013-08-01 17:58     ` Tom Tromey
2013-08-01 17:14 ` [PATCH 0/4] introduce test suite "parallel" mode Pedro Alves
2013-08-01 19:22   ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1374073124-23602-3-git-send-email-tromey@redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox