public inbox for frysk-cvs@sourceware.org help / color / mirror / Atom feed
From: cagney@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Delete use of observableProcAddedXXX. Date: Tue, 11 Mar 2008 16:19:00 -0000 [thread overview] Message-ID: <20080311161952.9529.qmail@sourceware.org> (raw) The branch, master has been updated via 15d2084c166e81a45a349b81467cc726a7506a15 (commit) via 6a7327aa17c4ffeed7b2ccad15cb179134aceddd (commit) from f21c86aac743a2a3c201e78d8167b90e5791bd6d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 15d2084c166e81a45a349b81467cc726a7506a15 Author: Andrew Cagney <cagney@redhat.com> Date: Tue Mar 11 12:18:32 2008 -0400 Delete use of observableProcAddedXXX. frysk-core/frysk/proc/ChangeLog 2008-03-11 Andrew Cagney <cagney@redhat.com> * TestFindProc.java (ProcCounter): Delete. (doFindProc(SlaveOffspring)): Replace doFindProc(SlaveOffspring,int). commit 6a7327aa17c4ffeed7b2ccad15cb179134aceddd Author: Andrew Cagney <cagney@redhat.com> Date: Tue Mar 11 11:58:54 2008 -0400 Remove use of ProcCounter. 2008-03-11 Andrew Cagney <cagney@redhat.com> * TestRun.java: Do not use ProcCounter. Use StopEventLoopWhenProcTerminates. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/proc/ChangeLog | 6 ++ frysk-core/frysk/proc/TestFindProc.java | 89 +++++++++--------------------- frysk-core/frysk/proc/TestRun.java | 15 +---- 3 files changed, 36 insertions(+), 74 deletions(-) First 500 lines of diff: diff --git a/frysk-core/frysk/proc/ChangeLog b/frysk-core/frysk/proc/ChangeLog index 3e6df24..5385f0b 100644 --- a/frysk-core/frysk/proc/ChangeLog +++ b/frysk-core/frysk/proc/ChangeLog @@ -1,5 +1,11 @@ 2008-03-11 Andrew Cagney <cagney@redhat.com> + * TestFindProc.java (ProcCounter): Delete. + (doFindProc(SlaveOffspring)): Replace doFindProc(SlaveOffspring,int). + + * TestRun.java: Do not use ProcCounter. Use + StopEventLoopWhenProcTerminates. + * StressTestAbandon.java: Update to match Offspring. * TestProcTasksObserver.java: Ditto. * TestProcGet.java: Ditto. diff --git a/frysk-core/frysk/proc/TestFindProc.java b/frysk-core/frysk/proc/TestFindProc.java index d140c8a..d9326b5 100644 --- a/frysk-core/frysk/proc/TestFindProc.java +++ b/frysk-core/frysk/proc/TestFindProc.java @@ -40,38 +40,23 @@ package frysk.proc; -import java.util.Observable; import frysk.rsl.Log; -import java.util.Observer; import frysk.testbed.TestLib; import frysk.testbed.SlaveOffspring; public class TestFindProc extends TestLib { private static final Log fine = Log.fine(TestFindProc.class); - class ProcCounter - implements Observer - { - - int count = 0; - public void update (Observable o, Object arg) - { - count++; - } - public int getCount () - { - return count; - } - } - class MyFinder implements FindProc { private final int expectedId; + Proc proc; public MyFinder(int pid) { expectedId = pid; } public void procFound(Proc proc) { fine.log("procFound", proc, "parent", proc.getParent()); assertEquals("procId", expectedId, proc.getPid()); + this.proc = proc; Manager.eventLoop.requestStop(); } public void procNotFound(int pid) { @@ -79,54 +64,34 @@ public class TestFindProc extends TestLib { } } - public void testFindProcDetached () - { - SlaveOffspring ackProc = SlaveOffspring.createChild(); - doFindProc(ackProc, 1); - } + public void testFindProcDetached() { + SlaveOffspring ackProc = SlaveOffspring.createChild(); + doFindProc(ackProc); + } - public void testFindProcAttached () - { - SlaveOffspring ackProc = SlaveOffspring.createAttachedChild(); - - //expect no additional processes to be added to the procPool. - doFindProc(ackProc, 0); - } + public void testFindProcAttached() { + SlaveOffspring ackProc = SlaveOffspring.createAttachedChild(); + //expect no additional processes to be added to the procPool. + doFindProc(ackProc); + } - public void testFindProcAckDaemon () - { - SlaveOffspring ackProc = SlaveOffspring.createDaemon(); - doFindProc(ackProc, 1); - } - - public void doFindProc (SlaveOffspring ackProc, int expectedCount) - { - - ProcCounter o = new ProcCounter(); - Manager.host.observableProcAddedXXX.addObserver(o); - - - /* - * This finds out how many processes are associated with the frysk process. - * For example: init->gnome terminal->bash->frysk. - */ - Manager.host.getSelf(); - int preFind = o.getCount(); - - - /* - * Find out how many processes are associated with the test process. - * Should be just the one. - */ - FindProc finder = new MyFinder(ackProc.getPid().intValue()); - Manager.host.requestProc(ackProc.getPid().intValue(), finder); - assertRunUntilStop("testFindProc"); - - int postFind = o.getCount(); + public void testFindProcAckDaemon() { + SlaveOffspring ackProc = SlaveOffspring.createDaemon(); + doFindProc(ackProc); + } - assertEquals(expectedCount, postFind - preFind); - - } + private void doFindProc(SlaveOffspring ackProc) { + // This finds out how many processes are associated with the + // frysk process. For example: init->gnome + // terminal->bash->frysk. + Manager.host.getSelf(); + // Find out how many processes are associated with the test + // process. Should be just the one. + MyFinder finder = new MyFinder(ackProc.getPid().intValue()); + Manager.host.requestProc(ackProc.getPid().intValue(), finder); + assertRunUntilStop("testFindProc"); + assertNotNull("finder got proc", finder.proc); + } public void testFindAndRefreshFailed() { FindProc finder = new FindProc() { diff --git a/frysk-core/frysk/proc/TestRun.java b/frysk-core/frysk/proc/TestRun.java index c9957a9..ff3c2d4 100644 --- a/frysk-core/frysk/proc/TestRun.java +++ b/frysk-core/frysk/proc/TestRun.java @@ -41,12 +41,10 @@ package frysk.proc; import frysk.testbed.TearDownFile; -import frysk.testbed.ProcCounter; import frysk.testbed.TestLib; -import frysk.testbed.StopEventLoopWhenProcRemoved; +import frysk.testbed.StopEventLoopWhenProcTerminates; import frysk.testbed.TaskSet; import frysk.testbed.TaskObserverBase; -import frysk.sys.Pid; /** * Check that a program can be run to completion. A scratch file is @@ -65,10 +63,6 @@ public class TestRun TearDownFile tmpFile = TearDownFile.create(); assertNotNull("temporary file", tmpFile); - // Add an observer that counts the number of proc create - // events. - ProcCounter procCounter = new ProcCounter(Pid.get().intValue()); - // Observe TaskObserver.Attached events; when any occur indicate // that the curresponding task should continue. class TaskCreatedContinuedObserver extends TaskObserverBase @@ -93,13 +87,10 @@ public class TestRun assertRunUntilStop("run \"rm\" to entry for tid"); // Once the proc destroyed has been seen stop the event loop. - new StopEventLoopWhenProcRemoved(createdObserver.proc); + new StopEventLoopWhenProcTerminates(createdObserver.proc); // Run the event loop, cap it at 5 seconds. assertRunUntilStop("run \"rm\" to exit"); - - assertEquals("processes added", 1, procCounter.added.size()); - assertEquals("processes removed", 1, procCounter.removed.size()); assertFalse("the file exists", tmpFile.stillExists()); } @@ -146,7 +137,7 @@ public class TestRun assertTrue("tmp file exists", tmpFile.stillExists()); // Once the proc destroyed has been seen stop the event loop. - new StopEventLoopWhenProcRemoved(createdObserver.proc); + new StopEventLoopWhenProcTerminates(createdObserver.proc); // Unblock the attached task and resume the event loop. This // will allow the "rm" command to run to completion. hooks/post-receive -- frysk system monitor/debugger
reply other threads:[~2008-03-11 16:19 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=20080311161952.9529.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: linkBe 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).