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]

Harness bug fixes


This patch fixes bugs brought to my attention by Raif.

The TimeoutWatcher class now has a method that allows the timer to be
stopped, so the timer used to make sure the BootClasspath auto-detector
doesn't hang is stopped and no longer interferes with the test run
causing a spurious FAIL result.

Also, every time a test calls one of the check() methods, the timer is
reset.  This way tests are killed if they are hung, but not if they are
just lengthy (in that they involve a lot of calls to check()).  If the
test does A LOT (>60 seconds worth) of work between calls to check() it
will still be considered a hang and will be killed.


2006-06-19  Anthony Balkissoon  <abalkiss@redhat.com>

	* Harness.java:
	(getBootclasspath): When the auto detector returns, stop the timeout
	watcher.
	(printHelpMessage): Replaced reference to old --with-test-java with the
	correct --with-vm.
	(initProcess): Replace the runner_watcher after confirming the startup 
	of the RunnerProcess.  This way the runner_watcher will not time out 
	before the first real test is run.
	(runTest): Added code to handle a timer reset request from the 
	RunnerProcess.
	(TimeoutWatcher.shouldContinue): New field.
	(TimeoutWatcher.stop): New method.
	(TimeoutWatcher.run): Added reference to shouldContinue to allow this 
	method to be stopped.
	* RunnerProcess.java:
	(check2): Send a message to the Harness requesting a reset of the
	timer.

--Tony
Index: Harness.java
===================================================================
RCS file: /cvs/mauve/mauve/Harness.java,v
retrieving revision 1.9
diff -u -r1.9 Harness.java
--- Harness.java	14 Jun 2006 19:28:27 -0000	1.9
+++ Harness.java	19 Jun 2006 17:46:27 -0000
@@ -491,10 +491,16 @@
             {
               bcpOutput = br.readLine();
               if (bcpOutput == null)
-                // This means the auto-detection failed.
-                return null;
+                {
+                  // This means the auto-detection failed.
+                  tw.stop();
+                  return null;
+                }
               if (bcpOutput.startsWith("BCP_FINDER:"))
-                return bcpOutput.substring(11);
+                {
+                  tw.stop();
+                  return bcpOutput.substring(11);
+                }
               else
                 System.out.println(bcpOutput);
             }
@@ -554,9 +560,9 @@
       
       // Test Run Options.
       "Test Run Options:\n" +      
-      "  -vm [vmpath]:        specify the vm on which to run the tests." +
+      "  -vm [vmpath]:            specify the vm on which to run the tests." +
       "It is strongly recommended" + align + "that you use this option or " +
-      "use the --with-test-java option when running" + align + "configure.  " +
+      "use the --with-vm option when running" + align + "configure.  " +
       "See the README file for more details.\n" +      
       "  -compile [yes|no]:       specify whether or not to compile the " +
       "tests before running them.  This" + align + "overrides the configure" +
@@ -634,16 +640,21 @@
         runner_in = 
           new BufferedReader
           (new InputStreamReader(runnerProcess.getInputStream()));                
-        // Create a timer to watch this new process.
-        runner_watcher = new TimeoutWatcher(runner_timeout);
       }
     catch (IOException e)
       {
         System.err.println("Problems invoking RunnerProcess: " + e);
         System.exit(1);
       }
-    
+
+    // Create a timer to watch this new process.  After confirming the
+    // RunnerProcess started properly, we create a new runner_watcher 
+    // because it may be a while before we run the next test (due to 
+    // preprocessing and compilation) and we don't want the runner_watcher
+    // to time out.
+    runner_watcher = new TimeoutWatcher(runner_timeout);    
     runTest("_confirm_startup_");
+    runner_watcher = new TimeoutWatcher(runner_timeout);
   }
   
   /**
@@ -783,12 +794,22 @@
               if (outputFromTest.startsWith("RunnerProcess:"))
                 {
                   invalidTest = false;
-                  // This means the test finished properly, now have to see if
-                  // it passed or failed.
-                  if (outputFromTest.endsWith("pass"))
-                    temp = 0;
+                  // This means the RunnerProcess has sent us back some
+                  // information.  This could be telling us that a check() call
+                  // was made and we should reset the timer, or that the 
+                  // test passed, or failed, or that it wasn't a test.
+                  if (outputFromTest.endsWith("restart-timer"))
+                    runner_watcher.reset();
+                  else if (outputFromTest.endsWith("pass"))
+                    {
+                      temp = 0;
+                      break;
+                    }
                   else if (outputFromTest.endsWith("fail"))
-                    temp = 1;
+                    {
+                      temp = 1;
+                      break;
+                    }
                   else if (outputFromTest.endsWith("not-a-test"))
                     {
                       // Temporarily decrease the total number of tests,
@@ -797,8 +818,8 @@
                       invalidTest = true;
                       total_tests--;
                       temp = 0;
-                    }
-                  break;
+                      break;
+                    }                  
                 } 
               else if (outputFromTest.equals("_startup_okay_") || 
                   outputFromTest.equals("_data_dump_okay_"))
@@ -1077,7 +1098,8 @@
   {
     private long millisToWait;
     private Thread watcherThread;
-    boolean loop = true;
+    private boolean loop = true;
+    private boolean shouldContinue = true;
     
     /**
      * Creates a new TimeoutWatcher that will wait for <code>millis</code>
@@ -1100,6 +1122,16 @@
     }
     
     /**
+     * Stops the run() method.
+     *
+     */
+    public synchronized void stop()
+    {
+      shouldContinue = false;
+      notify();
+    }
+    
+    /**
      * Return true if the watcher thread is currently counting down.
      * @return true if the watcher thread is alive
      */
@@ -1121,7 +1153,7 @@
     public synchronized void run()
     {
       Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
-      while (loop)
+      while (loop && shouldContinue)
         {
           // We set loop to false here, it will get reset to true if 
           // reset() is called from the main Harness thread.
@@ -1133,11 +1165,14 @@
           catch (InterruptedException ie)
           {}
         }
-      // The test is hung, set testIsHung to true so the process will be 
-      // destroyed and restarted.
-      synchronized (runner_lock)
+      if (shouldContinue)
         {
-          testIsHung = true;
+          // The test is hung, set testIsHung to true so the process will be 
+          // destroyed and restarted.      
+          synchronized (runner_lock)
+          {
+            testIsHung = true;
+          }
         }
     }
   }
Index: RunnerProcess.java
===================================================================
RCS file: /cvs/mauve/mauve/RunnerProcess.java,v
retrieving revision 1.5
diff -u -r1.5 RunnerProcess.java
--- RunnerProcess.java	14 Jun 2006 19:28:27 -0000	1.5
+++ RunnerProcess.java	19 Jun 2006 17:46:27 -0000
@@ -40,7 +40,6 @@
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.Reader;
-import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.net.URL;
 import java.net.URLClassLoader;
@@ -556,6 +555,10 @@
    */
   private void check2(boolean result)
   {
+    // Send a message to the Harness to let it know the current test
+    // isn't hung, to restart the timer.
+    System.out.println("RunnerProcess:restart-timer");
+    
     // If the test failed we have to print out some explanation.
     StackTraceElement[] st = new Throwable().getStackTrace();
     String desc = getDescription(st);

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