public inbox for frysk-cvs@sourceware.org help / color / mirror / Atom feed
From: cagney@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Use frysk.rsl in frysk.expunit; add -trace option. Date: Mon, 17 Dec 2007 20:02:00 -0000 [thread overview] Message-ID: <20071217200224.16771.qmail@sourceware.org> (raw) The branch, master has been updated via cf9bc42a978d8ee5984df226a9d741236af14a8a (commit) from 32ee0c47a82aabc7959c2806dd18364dc1d25e95 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit cf9bc42a978d8ee5984df226a9d741236af14a8a Author: Andrew Cagney <cagney@redhat.com> Date: Mon Dec 17 15:01:38 2007 -0500 Use frysk.rsl in frysk.expunit; add -trace option. frysk-sys/frysk/ChangeLog 2007-12-17 cagney <cagney@redhat.com> * EventLogger.java (addConsoleOptions(Parser)): Add LogOption. frysk-sys/frysk/expunit/ChangeLog 2007-12-17 cagney <cagney@redhat.com> * Expect.java: Use frysk.rsl.Log. frysk-sys/frysk/rsl/ChangeLog 2007-12-17 cagney <cagney@redhat.com> * Log.java (log(...)): Rename message(...). (log(Object,String)): New. (log(Object,String,Object,String,Object)): New. (log(Object,String,long,String,Object[])): New. (log(Object,String,Object,String,Object,String,String[])): New. * TestLog.java: Update. ----------------------------------------------------------------------- Summary of changes: frysk-sys/frysk/ChangeLog | 4 + frysk-sys/frysk/EventLogger.java | 2 + frysk-sys/frysk/expunit/ChangeLog | 2 + frysk-sys/frysk/expunit/Expect.java | 116 ++++++++++++++--------------------- frysk-sys/frysk/rsl/ChangeLog | 9 +++ frysk-sys/frysk/rsl/Log.java | 64 ++++++++++++++++---- frysk-sys/frysk/rsl/TestLog.java | 4 +- 7 files changed, 118 insertions(+), 83 deletions(-) First 500 lines of diff: diff --git a/frysk-sys/frysk/ChangeLog b/frysk-sys/frysk/ChangeLog index f2541c0..2e094d8 100644 --- a/frysk-sys/frysk/ChangeLog +++ b/frysk-sys/frysk/ChangeLog @@ -1,3 +1,7 @@ +2007-12-17 cagney <cagney@redhat.com> + + * EventLogger.java (addConsoleOptions(Parser)): Add LogOption. + 2007-10-30 Andrew Cagney <cagney@redhat.com> * cni/Config.cxx-in: Rename cni/Config.cxxin. diff --git a/frysk-sys/frysk/EventLogger.java b/frysk-sys/frysk/EventLogger.java index 132cbeb..16e34f6 100644 --- a/frysk-sys/frysk/EventLogger.java +++ b/frysk-sys/frysk/EventLogger.java @@ -56,6 +56,7 @@ import java.io.FileInputStream; import java.util.logging.Formatter; import java.util.logging.FileHandler; import java.util.logging.SimpleFormatter; +import frysk.rsl.LogOption; /** * The event logger for internal state. @@ -231,5 +232,6 @@ public class EventLogger verbose = true; } }); + parser.add(new LogOption("trace")); } } diff --git a/frysk-sys/frysk/expunit/ChangeLog b/frysk-sys/frysk/expunit/ChangeLog index 6041ae4..da96d7d 100644 --- a/frysk-sys/frysk/expunit/ChangeLog +++ b/frysk-sys/frysk/expunit/ChangeLog @@ -1,5 +1,7 @@ 2007-12-17 cagney <cagney@redhat.com> + * Expect.java: Use frysk.rsl.Log. + * MatchException.java (getMessage()): Fix typo; print match element. * MatchException.java: New. diff --git a/frysk-sys/frysk/expunit/Expect.java b/frysk-sys/frysk/expunit/Expect.java index c39918f..eeed7ec 100644 --- a/frysk-sys/frysk/expunit/Expect.java +++ b/frysk-sys/frysk/expunit/Expect.java @@ -43,10 +43,9 @@ import frysk.sys.Errno; import frysk.sys.ProcessIdentifier; import frysk.sys.PseudoTerminal; import frysk.sys.Signal; -import java.util.logging.Level; -import java.util.logging.Logger; +import frysk.rsl.Log; +import frysk.rsl.Level; import java.io.File; -import java.util.Arrays; /** * Simple expect like framework, that works within JUnit. @@ -59,7 +58,8 @@ import java.util.Arrays; public class Expect { - static protected Logger logger = Logger.getLogger("frysk"); + static protected Log fine = Log.get(Expect.class, Level.FINE); + static private Log finest = Log.get(Expect.class, Level.FINEST); private final PseudoTerminal child = new PseudoTerminal (); private ProcessIdentifier pid = null; @@ -68,23 +68,16 @@ public class Expect * Create an expect instance running the specified program args[0] * and args. */ - public Expect (String[] args) - { - pid = child.addChild (args); - logger.log (Level.FINE, "{0} new {1} pid {2} args {3}\n", - new Object[] { - this, - child, - pid, - Arrays.asList(args) - }); + public Expect(String[] args) { + pid = child.addChild(args); + fine.log(this, "new", child, "pid", pid, "args", args); } /** * Create an expect instance running PROGRAM with no arguments. - * - * Turns out that doing this is common and it saves the hassle of - * creating an argument list. + * + * Turns out that doing this is common and it saves the hassle of creating + * an argument list. */ public Expect(File program) { this(new String[] { program.getAbsolutePath() }); @@ -107,18 +100,16 @@ public class Expect * XXX: This drains all outstanding WAITPID events, and SIGCHLD * events. */ - public void close () - { + public void close() { if (pid != null) { - logger.log (Level.FINE, "{0} close\n", this); - child.close (); + fine.log(this, "close"); + child.close(); try { - pid.kill (); - } - catch (Errno e) { + pid.kill(); + } catch (Errno e) { // Toss it, as cleanup. } - pid.blockingDrain (); + pid.blockingDrain(); } pid = null; Signal.CHLD.drain(); @@ -187,80 +178,68 @@ public class Expect /** * Send "string" to the child process. */ - public void send (String string) - { - logger.log (Level.FINE, - "{0} send <<{1}>>\n", - new Object[] { this, string }); - byte[] bytes = string.getBytes (); - child.write (bytes, 0, bytes.length); + public void send(String string) { + fine.log(this, "send", (Object)string); + byte[] bytes = string.getBytes(); + child.write(bytes, 0, bytes.length); } /** * Expect one of the specified patterns; throw TimeoutException if - * timeoutSecond expires; throw EofException if end-of-file is - * encountered. - * - * This is package visible so that TestExpect can use it, but no - * one else. + * timeoutSecond expires; throw EofException if end-of-file is encountered. + * + * This is package visible so that TestExpect can use it, but no one else. */ - void expectMilliseconds (long timeoutMilliseconds, Match[] matches) - { - final long endTime = (System.currentTimeMillis () - + timeoutMilliseconds); + void expectMilliseconds(long timeoutMilliseconds, Match[] matches) { + final long endTime = (System.currentTimeMillis() + timeoutMilliseconds); + fine.log(this, "expect timeout", timeoutMilliseconds, "match", matches); while (true) { if (matches != null) { for (int i = 0; i < matches.length; i++) { Match p = matches[i]; if (p != null) { - logger.log (Level.FINE, - "{0} find <<{1}>> in <<{2}>>?\n", - new Object[] { this, p, output }); - if (p.find (output)) { - logger.log (Level.FINE, - "{0} match <<{1}>>\n", - new Object[] { this, p.group () }); - p.execute (); + finest.log(this, "find", (Object) p, "in", + (Object) output); + if (p.find(output)) { + fine.log(this, "match", (Object) p.group()); + p.execute(); // Remove everying up to and including what // matched. - if (p.end () >= 0) - output = output.substring (p.end ()); + if (p.end() >= 0) + output = output.substring(p.end()); return; } } } } if (eof) { - logger.log (Level.FINE, "{0} match EOF\n", this); + fine.log(this, "match EOF"); throw new EndOfFileException(matches, output); } - long timeRemaining = endTime - System.currentTimeMillis (); + long timeRemaining = endTime - System.currentTimeMillis(); if (timeRemaining <= 0) { - logger.log (Level.FINE, "{0} match TIMEOUT\n", this); - throw new TimeoutException(timeoutMilliseconds / 1000, - matches, output); + fine.log(this, "match TIMEOUT"); + throw new TimeoutException(timeoutMilliseconds / 1000, matches, + output); } - logger.log (Level.FINE, - "{0} poll for {1,number,integer} milliseconds\n", - new Object[] { this, new Long (timeRemaining) }); - if (child.ready (timeRemaining)) { + finest.log(this, "poll for [milliseconds]", timeRemaining); + if (child.ready(timeRemaining)) { byte[] bytes = new byte[100]; - int nr = child.read (bytes, 0, bytes.length); + int nr = child.read(bytes, 0, bytes.length); switch (nr) { case -1: - logger.log (Level.FINE, "{0} poll -> EOF\n", this); + finest.log(this, "poll -> EOF"); eof = true; break; case 0: - logger.log (Level.FINE, "{0} poll -> no data!\n", this); + finest.log(this, "poll -> no data!"); break; default: - String read = new String (bytes, 0, nr); + String read = new String(bytes, 0, nr); output = output + read; - logger.log (Level.FINE, - "{0} poll -> <<{1}>> giving <<{2}>>\n", - new Object[] { this, read, output }); + finest.log(this, "poll -> ", (Object) read, "giving", + (Object) output); break; } } @@ -269,8 +248,7 @@ public class Expect /** * Expect one of the specified patterns; throw TimeoutException if - * timeoutSecond expires; throw EofException if end-of-file is - * encountered. + * timeoutSecond expires; throw EofException if end-of-file is encountered. */ public void expect (long timeoutSeconds, Match[] matches) { diff --git a/frysk-sys/frysk/rsl/ChangeLog b/frysk-sys/frysk/rsl/ChangeLog index 68c7dae..201f560 100644 --- a/frysk-sys/frysk/rsl/ChangeLog +++ b/frysk-sys/frysk/rsl/ChangeLog @@ -1,3 +1,12 @@ +2007-12-17 cagney <cagney@redhat.com> + + * Log.java (log(...)): Rename message(...). + (log(Object,String)): New. + (log(Object,String,Object,String,Object)): New. + (log(Object,String,long,String,Object[])): New. + (log(Object,String,Object,String,Object,String,String[])): New. + * TestLog.java: Update. + 2007-12-10 Andrew Cagney <cagney@redhat.com> * Tree.java (Tree(String,String,Level)): Added Level parameter. diff --git a/frysk-sys/frysk/rsl/Log.java b/frysk-sys/frysk/rsl/Log.java index 15b33e6..9336d90 100644 --- a/frysk-sys/frysk/rsl/Log.java +++ b/frysk-sys/frysk/rsl/Log.java @@ -275,16 +275,23 @@ public final class Log { } // Add at will and on demand. - public void message(String p1) { + public void log(String p1) { if (!logging) return; prefix(); print(p1); postfix(); } + + public void log(Object self, String p1) { + if (!logging) + return; + print(p1); + postfix(); + } // Add at will and on demand. - public void message(Object self, String p1, int p2) { + public void log(Object self, String p1, int p2) { if (!logging) return; prefix(self); @@ -294,7 +301,7 @@ public final class Log { } // Add at will and on demand. - public void message(Object self, String p1, long p2) { + public void log(Object self, String p1, long p2) { if (!logging) return; prefix(self); @@ -304,7 +311,7 @@ public final class Log { } // Add at will and on demand. - public void message(Object self, String p1, String p2) { + public void log(Object self, String p1, String p2) { if (!logging) return; prefix(self); @@ -314,7 +321,7 @@ public final class Log { } // Add at will and on demand. - public void message(Object self, String p1, Object p2) { + public void log(Object self, String p1, Object p2) { if (!logging) return; prefix(self); @@ -324,7 +331,7 @@ public final class Log { } // Add at will and on demand. - public void message(Object self, String p1, int[] p2) { + public void log(Object self, String p1, int[] p2) { if (!logging) return; prefix(self); @@ -334,7 +341,7 @@ public final class Log { } // Add at will and on demand. - public void message(Object self, String p1, long[] p2) { + public void log(Object self, String p1, long[] p2) { if (!logging) return; prefix(self); @@ -344,7 +351,7 @@ public final class Log { } // Add at will and on demand. - public void message(Object self, String p1, String[] p2) { + public void log(Object self, String p1, String[] p2) { if (!logging) return; prefix(self); @@ -354,7 +361,7 @@ public final class Log { } // Add at will and on demand. - public void message(Object self, String p1, Object[] p2) { + public void log(Object self, String p1, Object[] p2) { if (!logging) return; prefix(self); @@ -364,7 +371,7 @@ public final class Log { } // Add at will and on demand. - public void message(Object self, String p1, Throwable p2) { + public void log(Object self, String p1, Throwable p2) { if (!logging) return; prefix(self); @@ -374,7 +381,7 @@ public final class Log { } // Add at will and on demand. - public void message(Object self, String p1, Throwable[] p2) { + public void log(Object self, String p1, Throwable[] p2) { if (!logging) return; prefix(self); @@ -383,5 +390,38 @@ public final class Log { postfix(); } - + public void log(Object self, String p1, long p2, String p3, Object[] p4) { + if (!logging) + return; + prefix(self); + print(p1); + print(p2); + print(p3); + print(p4); + postfix(); + } + public void log(Object self, String p1, Object p2, String p3, Object p4) { + if (!logging) + return; + prefix(self); + print(p1); + print(p2); + print(p3); + print(p4); + postfix(); + } + + public void log(Object self, String p1, Object p2, String p3, Object p4, + String p5, String[] p6) { + if (!logging) + return; + prefix(self); + print(p1); + print(p2); + print(p3); + print(p4); + print(p5); + print(p6); + postfix(); + } } diff --git a/frysk-sys/frysk/rsl/TestLog.java b/frysk-sys/frysk/rsl/TestLog.java index 8ae76ac..971a255 100644 --- a/frysk-sys/frysk/rsl/TestLog.java +++ b/frysk-sys/frysk/rsl/TestLog.java @@ -51,11 +51,11 @@ public class TestLog extends TestCase { private Tree root; public void setUp() { - log.message("setUp"); + log.log("setUp"); root = new Tree(); } public void tearDown() { - log.message("tearDown"); + log.log("tearDown"); root = null; } private Tree get(String path) { hooks/post-receive -- frysk system monitor/debugger
reply other threads:[~2007-12-17 20:02 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=20071217200224.16771.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).