public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
From: cagney@sourceware.org
To: frysk-cvs@sourceware.org
Subject: [SCM]  master: Eliminate use of StopEventLoopWhenProcRemoved.
Date: Thu, 13 Mar 2008 20:15:00 -0000	[thread overview]
Message-ID: <20080313201539.32628.qmail@sourceware.org> (raw)

The branch, master has been updated
       via  14c618d591647a1efe0d8e53186d88f1c56d7615 (commit)
      from  da5b7c5879878f20054299b104ef714de870994c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 14c618d591647a1efe0d8e53186d88f1c56d7615
Author: Andrew Cagney <cagney@redhat.com>
Date:   Thu Mar 13 16:14:05 2008 -0400

    Eliminate use of StopEventLoopWhenProcRemoved.
    
    frysk-core/frysk/proc/ChangeLog
    2008-03-13  Andrew Cagney  <cagney@redhat.com>
    
    	* TestTaskTerminateObserver.java: Do not use
    	StopEventLoopWhenProcRemoved.

-----------------------------------------------------------------------

Summary of changes:
 frysk-core/frysk/proc/ChangeLog                    |    3 +
 .../frysk/proc/TestTaskTerminateObserver.java      |   61 +++++++++++--------
 2 files changed, 38 insertions(+), 26 deletions(-)

First 500 lines of diff:
diff --git a/frysk-core/frysk/proc/ChangeLog b/frysk-core/frysk/proc/ChangeLog
index bad283d..a959021 100644
--- a/frysk-core/frysk/proc/ChangeLog
+++ b/frysk-core/frysk/proc/ChangeLog
@@ -1,5 +1,8 @@
 2008-03-13  Andrew Cagney  <cagney@redhat.com>
 
+	* TestTaskTerminateObserver.java: Do not use
+	StopEventLoopWhenProcRemoved.
+
 	* TestProcGet.java: Use StopEventLoopWhenProcTerminated.
 
 2008-03-12  Andrew Cagney  <cagney@redhat.com>
diff --git a/frysk-core/frysk/proc/TestTaskTerminateObserver.java b/frysk-core/frysk/proc/TestTaskTerminateObserver.java
index 38c5a96..ffb1a61 100644
--- a/frysk-core/frysk/proc/TestTaskTerminateObserver.java
+++ b/frysk-core/frysk/proc/TestTaskTerminateObserver.java
@@ -42,7 +42,6 @@ package frysk.proc;
 import frysk.sys.Pid;
 import frysk.isa.signals.Signal;
 import frysk.testbed.TestLib;
-import frysk.testbed.StopEventLoopWhenProcRemoved;
 import frysk.testbed.TaskObserverBase;
 import frysk.testbed.DaemonBlockedAtEntry;
 import frysk.testbed.SynchronizedOffspring;
@@ -59,9 +58,13 @@ public class TestTaskTerminateObserver
     /**
      * Save the Terminating, and Terminated values as they pass by.
      */
-    class Terminate extends TaskObserverBase
+    private class Terminate extends TaskObserverBase
 	implements TaskObserver.Terminating, TaskObserver.Terminated
     {
+	private final boolean stopOnTerminatingEvent;
+	Terminate(boolean stopOnTerminatingEvent) {
+	    this.stopOnTerminatingEvent = stopOnTerminatingEvent;
+	}
 	int terminating = INVALID;
 	int terminated = INVALID;
 	public Action updateTerminating(Task task, Signal signal, int value) {
@@ -70,6 +73,8 @@ public class TestTaskTerminateObserver
 	    } else {
 		terminating = value;
 	    }
+	    if (stopOnTerminatingEvent)
+		Manager.eventLoop.requestStop();
 	    return Action.CONTINUE;
 	}
 	public Action updateTerminated(Task task, Signal signal, int value) {
@@ -78,6 +83,7 @@ public class TestTaskTerminateObserver
 	    } else {
 		terminated = value;
 	    }
+	    Manager.eventLoop.requestStop();
 	    return Action.CONTINUE;
 	}
     }
@@ -93,12 +99,15 @@ public class TestTaskTerminateObserver
 		Integer.toString(expected)
 	    });
 	
-	// Bail once it has exited.
-	new StopEventLoopWhenProcRemoved(child);
-	
-	// Set up an observer that watches for both Terminating and
-	// Terminated events.
-	Terminate terminate = new Terminate();
+	// Set up an observer that watches for both Terminating and/or
+	// Terminated events; and requests a stop when the last
+	// expected event arrives.
+	if (terminated == INVALID && terminating == INVALID) {
+	    // Must watch at least one; otherwise won't know when to
+	    // stop the test!
+	    fail("test-case botch");
+	}
+	Terminate terminate = new Terminate(terminated == INVALID);
 	if (terminated != INVALID) {
 	    child.getMainTask().requestAddTerminatedObserver(terminate);
 	}
@@ -188,35 +197,19 @@ public class TestTaskTerminateObserver
 	terminated(- frysk.sys.Signal.HUP.intValue());
     }
 
-    class TerminatingCounter extends TaskObserverBase
-	implements TaskObserver.Terminating
-    {
-	int count;
-	public void addedTo (Object o) {
-	    Manager.eventLoop.requestStop();
-	}
-	public Action updateTerminating(Task task, Signal signal, int value) {
-	    count++;
-	    task.requestUnblock(this);
-	    return Action.BLOCK;
-	}
-    }
-
     /**
      * Check that a process with a task, that has exited, but not yet
      * been joined (i.e., in the 'X' state) can be attached and than
      * followed through to its termination.
      */
     public void testAttachToUnJoinedTask () {
-	final int timeout = 5; // XXX: Should be constant in TestLib.
-
 	SynchronizedOffspring daemon = new SynchronizedOffspring
 	    (SynchronizedOffspring.START_ACK,
 	     new String[]{
 		getExecPath ("funit-threadexit"),
 		Integer.toString(Pid.get().intValue()),
 		Integer.toString(SynchronizedOffspring.START_ACK.intValue()),
-		Integer.toString(timeout), // Seconds
+		Integer.toString(getTimeoutSeconds()), // Seconds
 	    });
 
 	// Find the main task, and get a terminate observer bound to
@@ -231,11 +224,27 @@ public class TestTaskTerminateObserver
 	// the way through to being removed so that both terminating
 	// and terminated events are seen by this test.
 	daemon.signal(frysk.sys.Signal.TERM);
-	new StopEventLoopWhenProcRemoved(daemon);
 	assertRunUntilStop("terminate process");
 
 	// Check that there was a terminate event.
 	assertEquals("Number of terminating processes", 1,
 		     terminatingCounter.count);
     }
+
+    private static class TerminatingCounter
+	extends TaskObserverBase
+	implements TaskObserver.Terminating
+    {
+	int count;
+	public void addedTo (Object o) {
+	    Manager.eventLoop.requestStop();
+	}
+	public Action updateTerminating(Task task, Signal signal, int value) {
+	    count++;
+	    task.requestUnblock(this);
+	    Manager.eventLoop.requestStop();
+	    return Action.BLOCK;
+	}
+    }
+
 }


hooks/post-receive
--
frysk system monitor/debugger


                 reply	other threads:[~2008-03-13 20:15 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20080313201539.32628.qmail@sourceware.org \
    --to=cagney@sourceware.org \
    --cc=frysk-cvs@sourceware.org \
    --cc=frysk@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).