From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3214 invoked by alias); 31 Mar 2008 17:21:29 -0000 Received: (qmail 3188 invoked by uid 9519); 31 Mar 2008 17:21:28 -0000 Date: Mon, 31 Mar 2008 17:21:00 -0000 Message-ID: <20080331172128.3173.qmail@sourceware.org> From: rmoseley@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Allow HPD notation for start/run command. X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 9ef6466d481de2a984018cdefc4722d65bbf690a X-Git-Newrev: 7cce31266c351358182feda857399c9b3142522a Mailing-List: contact frysk-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: frysk-cvs-owner@sourceware.org Reply-To: frysk@sourceware.org X-SW-Source: 2008-q1/txt/msg00433.txt.bz2 The branch, master has been updated via 7cce31266c351358182feda857399c9b3142522a (commit) from 9ef6466d481de2a984018cdefc4722d65bbf690a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 7cce31266c351358182feda857399c9b3142522a Author: Rick Moseley Date: Mon Mar 31 12:20:10 2008 -0500 Allow HPD notation for start/run command. * StartRun.java: Add ability to start/run with hpd notation. * TestRunCommand.java: Add test for above. * TestStartCommand.java: Ditto. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/hpd/ChangeLog | 6 ++++ frysk-core/frysk/hpd/StartRun.java | 35 +++++++++++++++++++++------ frysk-core/frysk/hpd/TestRunCommand.java | 25 ++++++++++++++++++++ frysk-core/frysk/hpd/TestStartCommand.java | 23 ++++++++++++++++++ 4 files changed, 81 insertions(+), 8 deletions(-) First 500 lines of diff: diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog index ee8662f..12e6daa 100644 --- a/frysk-core/frysk/hpd/ChangeLog +++ b/frysk-core/frysk/hpd/ChangeLog @@ -1,3 +1,9 @@ +2008-03-31 Rick Moseley + + * StartRun.java: Add ability to start/run with hpd notation. + * TestRunCommand.java: Add test for above. + * TestStartCommand.java: Ditto. + 2008-03-25 Rick Moseley * StartRun.java: Kill all processes on a re-run before diff --git a/frysk-core/frysk/hpd/StartRun.java b/frysk-core/frysk/hpd/StartRun.java index bc3fdb4..8046540 100644 --- a/frysk-core/frysk/hpd/StartRun.java +++ b/frysk-core/frysk/hpd/StartRun.java @@ -61,6 +61,8 @@ abstract class StartRun extends ParameterizedCommand { final ArrayList procList = new ArrayList(); + PTSet userSet; + StartRun(String command, String help1, String help2) { super(command, help1, help2); } @@ -126,6 +128,8 @@ abstract class StartRun extends ParameterizedCommand { public void interpretCmd(CLI cli, Input cmd, Object options, boolean runToBreak) { + + userSet = cli.getCommandPTSet(cmd); // See if there are any tasks to be killed if (killProcs(cli)) { // See if there are any tasks in the current target set @@ -139,7 +143,7 @@ abstract class StartRun extends ParameterizedCommand { return; } // Take care of loaded procs - Iterator foo = cli.targetset.getTaskData(); + Iterator foo = userSet.getTaskData(); if (!foo.hasNext()) { cli.addMessage("No procs in targetset to run", Message.TYPE_NORMAL); return; @@ -170,10 +174,12 @@ abstract class StartRun extends ParameterizedCommand { * killProcs loops through the current target set to see if there are any * tasks to kill, the philosophy being that all tasks should be killed before * + * @param cli is the command line object + * @return true if there were procs to kill, false if there weren't */ private boolean killProcs(CLI cli) { - Iterator foo = cli.targetset.getTaskData(); + Iterator foo = userSet.getTaskData(); // No procs in target set return false if (!foo.hasNext()) { return false; @@ -211,16 +217,21 @@ abstract class StartRun extends ParameterizedCommand { int taskid) { Runner runner = new Runner(cli); String startrun = ""; - if (runToBreak) - startrun = "running"; - else - startrun = "starting"; - if (cmd.size() == 0) { + if (runToBreak) + startrun = "running"; + else + startrun = "starting"; + + switch (cmd.size()) { + + case 0: cli.addMessage(startrun + " with this command: " + asString(template.getCmdLine()), Message.TYPE_NORMAL); Manager.host.requestCreateAttachedProc(template, runner); - } else { + break; + + default: String[] args = new String[cmd.size() + 1]; args[0] = template.getCmdLine()[0]; for (int i = 1; i < args.length; i++) @@ -248,6 +259,14 @@ abstract class StartRun extends ParameterizedCommand { cli.taskID = -1; } } + + /** + * asString takes an array of arguments and converts it to a single + * string of args as would be appropriate for a commandline + * @param args is an array of arguments to pass to the process to be run + * @return a String of args that are to be passed to the process + * on the commandline + */ private String asString(String[] args) { if (args == null || args.length <= 0) diff --git a/frysk-core/frysk/hpd/TestRunCommand.java b/frysk-core/frysk/hpd/TestRunCommand.java index 1c769bb..7513d35 100644 --- a/frysk-core/frysk/hpd/TestRunCommand.java +++ b/frysk-core/frysk/hpd/TestRunCommand.java @@ -188,4 +188,29 @@ public class TestRunCommand extends TestLib { e.expect("Quitting\\.\\.\\."); e.close(); } + + /** + * This test case gives the run command a specific targetset to run + * + */ + + public void testRunHpdParam() { + e = new HpdTestbed(); + e.sendCommandExpectPrompt("load " + Config.getPkgLibFile("funit-hello").getPath(), + "\\[0\\.0\\] Loaded executable file.*"); + e.sendCommandExpectPrompt("load " + Config.getPkgLibFile("funit-threads-looper").getPath(), + "\\[1\\.0\\] Loaded executable file.*"); + e.sendCommandExpectPrompt("load " + Config.getPkgLibFile("funit-threads-looper").getPath(), + "\\[2\\.0\\] Loaded executable file.*"); + e.sendCommandExpectPrompt("[1.0] run", "Attached to process ([0-9]+).*" + "Creating new.*" + + "running.*" + "Running process ([0-9]+).*"); + try { Thread.sleep(1000); } catch (Exception e) {} + //e.sendCommandExpectPrompt("load", "\\[0\\.0\\].*funit-hello.*\\[2\\.0\\].*funit-threads.*"); + e.sendCommandExpectPrompt("focus", "Target set.*\\[0\\.0\\]\t\t0\t0.*" + + "\\[1\\.0\\]\t\t([0-9]+).*\\t([0-9]+).*\\[1\\.1\\]\t\t([0-9]+)\t([0-9]+).*" + + "\\[2\\.0\\]\t\t0\t0.*"); + e.send("quit\n"); + e.expect("Quitting\\.\\.\\."); + e.close(); + } } \ No newline at end of file diff --git a/frysk-core/frysk/hpd/TestStartCommand.java b/frysk-core/frysk/hpd/TestStartCommand.java index 87aa2b9..5c64e56 100644 --- a/frysk-core/frysk/hpd/TestStartCommand.java +++ b/frysk-core/frysk/hpd/TestStartCommand.java @@ -131,4 +131,27 @@ public class TestStartCommand extends TestLib { e.expect("Quitting\\.\\.\\."); e.close(); } + + /** + * This test case gives the start command a specific targetset to run + * + */ + + public void testRunHpdParam() { + e = new HpdTestbed(); + e.sendCommandExpectPrompt("load " + Config.getPkgLibFile("funit-hello").getPath(), + "\\[0\\.0\\] Loaded executable file.*"); + e.sendCommandExpectPrompt("load " + Config.getPkgLibFile("funit-threads-looper").getPath(), + "\\[1\\.0\\] Loaded executable file.*"); + e.sendCommandExpectPrompt("load " + Config.getPkgLibFile("funit-threads-looper").getPath(), + "\\[2\\.0\\] Loaded executable file.*"); + e.sendCommandExpectPrompt("[1.0] start", "Attached to process ([0-9]+).*" + "Creating new.*" + + "starting.*"); + try { Thread.sleep(1000); } catch (Exception e) {} + e.sendCommandExpectPrompt("focus", "Target set.*\\[0\\.0\\]\t\t0\t0.*" + + "\\[1\\.0\\]\t\t([0-9]+).*\\t([0-9]+).*\\[2\\.0\\]\t\t0\t0.*"); + e.send("quit\n"); + e.expect("Quitting\\.\\.\\."); + e.close(); + } } \ No newline at end of file hooks/post-receive -- frysk system monitor/debugger