This is the mail archive of the frysk@sources.redhat.com mailing list for the frysk 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]

Make TestBreakpoints deterministic


Hi,

The following patch makes TestBreakpoint deterministically PASS on both
my FC5 (x86_64) and FC6test (x86) boxes:

2006-08-21  Mark Wielaard  <mark@klomp.org>

        * TestBreakpoints.java: Implements Observer.
        (procTerminated): New boolean field.
        (setup): Add observableProcRemoved to manager.host.
        (tearDown): Make sure proc is really gone.
        (update): New method.

It seems that under fc6 kernels procs are kept around longer than under
fc5. So we were seeing "about to terminate" procs under fc6 when
restarting the eventloop, which we weren't seeing under fc5 because they
were always already gone. You do sometimes observe this with fc5
kernels, you will get a WARNING: No task for pid XXX from LinuxHost, but
in those cases it seems the terminated event has already happened, or is
never delivered to us. Under fc6 we then will get a terminated event,
which upset this test.

I am still seeing lots of FAILs on my FC6 machine, so it might be that
something similar is generally needed and should go into TestLib.

Cheers,

Mark
Index: frysk/proc/TestBreakpoints.java
===================================================================
RCS file: /cvs/frysk/frysk-core/frysk/proc/TestBreakpoints.java,v
retrieving revision 1.1
diff -u -r1.1 TestBreakpoints.java
--- frysk/proc/TestBreakpoints.java	15 Aug 2006 17:16:58 -0000	1.1
+++ frysk/proc/TestBreakpoints.java	21 Aug 2006 13:33:04 -0000
@@ -40,9 +40,12 @@
 package frysk.proc;
 
 import java.io.*;
+import java.util.Observable;
+import java.util.Observer;
 
 public class TestBreakpoints
   extends TestLib
+  implements Observer
 {
   // Process id and Proc representation of our test program.
   int pid;
@@ -63,6 +66,9 @@
   boolean exitSignal;
   int exitValue;
 
+  // Whether the proc has really terminited (cannot be seen by the host).
+  boolean procTerminated;
+
   // Monitor to notify and wait on for state of event changes..
   static Object monitor = new Object();
 
@@ -91,6 +97,10 @@
 
     attached = false;
     terminating = false;
+    procTerminated = false;
+
+    // Monitor so we know the proc has really left the building.
+    Manager.host.observableProcRemovedXXX.addObserver(this);
 
     // Start an EventLoop so we don't have to poll for events all the time.
     eventloop = new EventLoopRunner();
@@ -104,6 +114,22 @@
    */
   public void tearDown()
   {
+    // Make sure proc is gone.
+    synchronized (monitor)
+      {
+	while (!procTerminated)
+          {
+            try
+              {
+		monitor.wait();
+              }
+            catch (InterruptedException ie)
+              {
+		// Ignored
+              }
+          }
+      }
+
     // Make sure event loop is gone.
     eventloop.requestStop();
     synchronized (monitor)
@@ -125,6 +151,22 @@
     super.tearDown();
   }
 
+  // Called by the Host when procs are removed.
+  // Used to monitor whether or not our proc has truely left the building.
+  public void update(Observable o, Object obj)
+  {
+    Proc p = (Proc) obj;
+    if (p.equals(proc))
+      {
+	synchronized (monitor)
+	  {
+	    procTerminated = true;
+	    monitor.notifyAll();
+	  }
+      }
+  }
+
+
   public void testHitAndRun() throws IOException
   {
     String line;

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