This is the mail archive of the mauve-patches@sourceware.org mailing list for the Mauve project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: Harness with no busy-waiting


Hi Anthony,

On Tue, 2006-06-27 at 15:04 -0400, Anthony Balkissoon wrote:
> Okay, here's a second attempt, no Sockets, no tricks.

I like it thanks!

I did have two small issues that took me a while to track down.
Sometimes the readLine() would throw an IOException after the process
was destroyed so I made an IOException do the same thing thing as if the
readLine() returned null. And sometimes there was a race condition
between the setting up a new RunnerProcess and the TimeoutWatcher
destroying the old one (the Process.destroy() could take some time). So
I added the Process as an explicit field of the TimeoutWatcher so that
it would only destroy the Process it is watching.

2006-06-30  Mark Wielaard  <mark@klomp.org>

        * Harness.java (initProcess): Initialize TimeoutWatcher with
        runnerProcess.
        (runAllTests): Treat IOException as timeout.
        (TimeoutWatcher.runnerProcess): New field.
        (TimeoutWatcher.run): Close streams of runnerProcess.

Committed,

Mark
Index: Harness.java
===================================================================
RCS file: /cvs/mauve/mauve/Harness.java,v
retrieving revision 1.16
diff -u -r1.16 Harness.java
--- Harness.java	27 Jun 2006 20:53:35 -0000	1.16
+++ Harness.java	30 Jun 2006 23:06:52 -0000
@@ -645,10 +645,10 @@
     // to time out.
     if (runner_watcher != null)
       runner_watcher.stop();
-    runner_watcher = new TimeoutWatcher(runner_timeout);    
+    runner_watcher = new TimeoutWatcher(runner_timeout, runnerProcess);
     runTest("_confirm_startup_");
     runner_watcher.stop();
-    runner_watcher = new TimeoutWatcher(runner_timeout);
+    runner_watcher = new TimeoutWatcher(runner_timeout, runnerProcess);
   }
   
   /**
@@ -811,6 +811,9 @@
         }
         catch (IOException e)
         {
+          initProcess(harnessArgs);
+          temp = -1;
+          break;
         }
       }
     if (temp == -1)
@@ -1079,16 +1082,19 @@
     private boolean loop = true;
     private boolean shouldContinue = true;
     
+    private final Process runnerProcess;
+
     /**
      * Creates a new TimeoutWatcher that will wait for <code>millis</code>
      * milliseconds once started.
      * @param millis the number of milliseconds to wait before declaring the 
      * test as hung
      */
-    public TimeoutWatcher(long millis)
+    public TimeoutWatcher(long millis, Process runnerProcess)
     {
       millisToWait = millis;
       watcherThread = new Thread(this);
+      this.runnerProcess = runnerProcess;
     }
     
     /**
@@ -1148,10 +1154,10 @@
           // The test is hung, destroy and restart the RunnerProcess.      
           try
           {
-            runnerProcess.destroy();
-            runner_in.close();
-            runner_in_err.close();
-            runner_out.close();
+            this.runnerProcess.destroy();
+            this.runnerProcess.getInputStream().close();
+            this.runnerProcess.getErrorStream().close();
+            this.runnerProcess.getOutputStream().close();
           }
           catch (IOException e)
           {

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]