From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18823 invoked by alias); 17 Apr 2008 20:10:04 -0000 Received: (qmail 18741 invoked by uid 9519); 17 Apr 2008 20:10:03 -0000 Date: Thu, 17 Apr 2008 20:10:00 -0000 Message-ID: <20080417201003.18700.qmail@sourceware.org> From: rmoseley@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Add arguments to multiple start/run runs(bz 5500,5501). X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: f493456a57042ba675656a695cf44ec495fe077f X-Git-Newrev: aae0d7923c971459bbb7019d121f40fb56b58eac 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-q2/txt/msg00133.txt.bz2 The branch, master has been updated via aae0d7923c971459bbb7019d121f40fb56b58eac (commit) from f493456a57042ba675656a695cf44ec495fe077f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit aae0d7923c971459bbb7019d121f40fb56b58eac Author: Rick Moseley Date: Thu Apr 17 15:07:56 2008 -0500 Add arguments to multiple start/run runs(bz 5500,5501). * StartRun.java: Add args to multiple runs for start/run command(bz #5500, 5501). * TestStartCommand.java: Tests for above. * TestRunCommand.java: Ditto. * CLI.java: Fix so output goes to correct queue. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/hpd/CLI.java | 3 +- frysk-core/frysk/hpd/ChangeLog | 8 ++ frysk-core/frysk/hpd/StartRun.java | 114 ++++++++++++++++++++++------ frysk-core/frysk/hpd/TestRunCommand.java | 57 +++++++++++++- frysk-core/frysk/hpd/TestStartCommand.java | 55 ++++++++++++- 5 files changed, 202 insertions(+), 35 deletions(-) First 500 lines of diff: diff --git a/frysk-core/frysk/hpd/CLI.java b/frysk-core/frysk/hpd/CLI.java index 1f30bea..cd02365 100644 --- a/frysk-core/frysk/hpd/CLI.java +++ b/frysk-core/frysk/hpd/CLI.java @@ -157,8 +157,7 @@ public class CLI { while (true) { try { attachedLatch.await(); - outWriter.print("Attached to process "); - outWriter.println(attached); + addMessage("Attached to process " + attached, Message.TYPE_NORMAL); synchronized (this) { attached = -1; attachedLatch = null; diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog index 029315c..7a78133 100644 --- a/frysk-core/frysk/hpd/ChangeLog +++ b/frysk-core/frysk/hpd/ChangeLog @@ -1,3 +1,11 @@ +2008-04-17 Rick Moseley + + * StartRun.java: Add args to multiple runs for start/run + command(bz #5500, 5501). + * TestStartCommand.java: Tests for above. + * TestRunCommand.java: Ditto. + * CLI.java: Fix so output goes to correct queue. + 2008-04-17 Teresa Thomas * WatchCommand.java (WatchpointObserver.updateHit): diff --git a/frysk-core/frysk/hpd/StartRun.java b/frysk-core/frysk/hpd/StartRun.java index 8046540..c5855a2 100644 --- a/frysk-core/frysk/hpd/StartRun.java +++ b/frysk-core/frysk/hpd/StartRun.java @@ -59,7 +59,11 @@ import java.util.List; */ abstract class StartRun extends ParameterizedCommand { - final ArrayList procList = new ArrayList(); + final ArrayList procTaskDataList = new ArrayList(); + + final ArrayList procProcCommand = new ArrayList(); + + final ArrayList procProcArgs = new ArrayList(); PTSet userSet; @@ -134,12 +138,19 @@ abstract class StartRun extends ParameterizedCommand { if (killProcs(cli)) { // See if there are any tasks in the current target set TaskData taskData = null; - Iterator foo = procList.iterator(); + int counter = 0; + Iterator foo = procTaskDataList.iterator(); while (foo.hasNext()) { taskData = (TaskData) foo.next(); - Task task = taskData.getTask(); - run(cli, cmd, task.getProc(), runToBreak, taskData.getParentID()); + String command = (String) procProcCommand.get(counter); + String[] argList = (String[]) procProcArgs.get(counter); + run(cli, cmd, command, argList, runToBreak, + taskData.getParentID()); + counter++; } + procTaskDataList.clear(); + procProcArgs.clear(); + procProcCommand.clear(); return; } // Take care of loaded procs @@ -153,7 +164,8 @@ abstract class StartRun extends ParameterizedCommand { Task task = taskData.getTask(); if (!cli.loadedProcs.isEmpty() && cli.loadedProcs.containsKey(task.getProc())) { - run(cli, cmd, task.getProc(), runToBreak, taskData.getParentID()); + run(cli, cmd, task.getProc().getExeFile().getSysRootedPath(), + task.getProc().getCmdLine(), runToBreak, taskData.getParentID()); synchronized (cli) { cli.loadedProcs.remove(task.getProc()); } @@ -161,7 +173,8 @@ abstract class StartRun extends ParameterizedCommand { // Take care of core procs else if (!cli.coreProcs.isEmpty() && cli.coreProcs.containsKey(task.getProc())) { - run(cli, cmd, task.getProc(), runToBreak, taskData.getParentID()); + run(cli, cmd, task.getProc().getExeFile().getSysRootedPath(), + task.getProc().getCmdLine(), runToBreak, taskData.getParentID()); synchronized (cli) { cli.coreProcs.remove(new Integer(taskData.getParentID())); } @@ -191,12 +204,14 @@ abstract class StartRun extends ParameterizedCommand { Task task = taskData.getTask(); if (task.getProc().getPid() != oldPid && task.getProc().getPid() > 0) { - procList.add(taskData); + procTaskDataList.add(taskData); + procProcCommand.add(task.getProc().getExeFile().getSysRootedPath()); + procProcArgs.add(task.getProc().getCmdLine()); cli.execCommand("kill " + task.getProc().getPid() + "\n"); oldPid = task.getProc().getPid(); } } - if (procList.isEmpty()) + if (procTaskDataList.isEmpty()) return false; return true; @@ -207,13 +222,14 @@ abstract class StartRun extends ParameterizedCommand { * * @param cli is the commandline object * @param cmd is the command object with all the parameters - * @param template is the proc to run + * @param command is a string containing the command to run + * @param argList is a String array with the args from the commandline * @param runToBreak true if the process is to run to the first break point * or until it blows up("run" command), false if it should stop * at the first executable statement("start" command) * @param taskid the internal target set id that should be used for this process */ - private void run(CLI cli, Input cmd, Proc template, boolean runToBreak, + private void run(CLI cli, Input cmd, String command, String[] argList, boolean runToBreak, int taskid) { Runner runner = new Runner(cli); String startrun = ""; @@ -224,20 +240,34 @@ abstract class StartRun extends ParameterizedCommand { switch (cmd.size()) { + // No parameters were passed on the commandline, except maybe "--" case 0: - cli.addMessage(startrun + " with this command: " + - asString(template.getCmdLine()), - Message.TYPE_NORMAL); - Manager.host.requestCreateAttachedProc(template, runner); + /** There is an exception to the rule of cmd.size() being 0 and that + * is when a "--" was entered, CLI removes that but the full command line + * string in the Input object has it. So, if cmd.size() reports 0 + * parameters, check to see if actually a "--" was entered. If it was + * the user wants no args passed to the process this run. + */ + int index = cmd.getFullCommand().indexOf("--"); + if (index != -1) { + cli.addMessage(startrun + " with this commmand: " + + command, Message.TYPE_NORMAL); + Manager.host.requestCreateAttachedProc(createArgList(null, argList), runner); + } + else { + String[] temp = new String[1]; + temp [0] = argList[0]; + cli.addMessage(startrun + " with this commmand: " + + asString("", temp, cmd), Message.TYPE_NORMAL); + Manager.host.requestCreateAttachedProc(createArgList(null, temp), runner); + } break; default: - String[] args = new String[cmd.size() + 1]; - args[0] = template.getCmdLine()[0]; - for (int i = 1; i < args.length; i++) - args[i] = cmd.parameter(i - 1); + String[] args = createArgList(command, cmd.stringArrayValue()); cli.addMessage(startrun + " with this command: " + - asString(args), Message.TYPE_NORMAL); + asString(command, args, cmd), Message.TYPE_NORMAL); + Manager.host.requestCreateAttachedProc(args, runner); } while (true) { @@ -261,18 +291,52 @@ abstract class StartRun extends ParameterizedCommand { } /** + * createArgList takes a path to the executable and an argument list + * and creates a String[] to pass to the create proc method. + * @param command is a String with the path to the executable + * @param argList is a String[] with an argument list + * @return a String[] to pass to Manager.host.createAttachedProc + */ + private String[] createArgList(String command, String[] argList) { + // If command is null, the command is at the begging of argList + // so we need to do nothing + if (command == null) + return argList; + String[] args = new String[argList.length + 1]; + args[0] = command; + if (args.length > 1) { + for (int i = 0; i < argList.length; i++) { + if (i == argList.length - 1 && argList.equals("--")) + args[i + 1] = ""; + else + args[i + 1] = argList[i]; + } + } + return args; + } + /** * 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 + * @param command is the String representing the full command path for + * this process + * @param argList is a String array of arguments to pass to the process to be run + * @param cmd is the current Input command object * @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) - return ""; - StringBuffer b = new StringBuffer(args[0]); - for (int i = 1; i < args.length; i++) { + private String asString(String command, String[] argList, Input cmd) { + String[] args = cmd.stringArrayValue(); + // If there were no args on the commandline, see if there were any + // on a previous run and if there were, use those + if (args == null || args.length <= 0 || args == null) + args = argList; + StringBuffer b = new StringBuffer(command); + // No args entered, return just the command + if (args == null) + return b.toString(); + // args were entered, append to the command + for (int i = 0; i < args.length; i++) { b.append(" "); b.append(args[i]); } diff --git a/frysk-core/frysk/hpd/TestRunCommand.java b/frysk-core/frysk/hpd/TestRunCommand.java index 2b3b8ce..4d91245 100644 --- a/frysk-core/frysk/hpd/TestRunCommand.java +++ b/frysk-core/frysk/hpd/TestRunCommand.java @@ -181,8 +181,8 @@ public class TestRunCommand extends TestLib { e.sendCommandExpectPrompt("load " + Prefix.pkgLibFile("funit-threads-looper").getPath(), "\\[1\\.0\\] Loaded executable file.*"); e.sendCommandExpectPrompt("focus [1.0]", "Creating new HPD notation set.*"); - e.sendCommandExpectPrompt("run", "Attached to process ([0-9]+).*" + - "running.*" + "Running process ([0-9]+).*"); + e.sendCommandExpectPrompt("run", "running.*" + "Attached to process ([0-9]+).*" + + "Running process ([0-9]+).*"); e.sendCommandExpectPrompt("load", "\\[0\\.0\\].*funit-hello.*"); e.send("quit\n"); e.expect("Quitting\\.\\.\\."); @@ -202,8 +202,8 @@ public class TestRunCommand extends TestLib { "\\[1\\.0\\] Loaded executable file.*"); e.sendCommandExpectPrompt("load " + Prefix.pkgLibFile("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]+).*"); + e.sendCommandExpectPrompt("[1.0] run", "Creating new.*" + "running.*" + + "Attached to process ([0-9]+).*" + "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.*" + @@ -213,4 +213,53 @@ public class TestRunCommand extends TestLib { e.expect("Quitting\\.\\.\\."); e.close(); } + + /** + * This test case tests passing of different parameters + * + */ + public void testDiffParams() { + e = new HpdTestbed(); + e.sendCommandExpectPrompt("load " + Prefix.pkgLibFile("funit-threads-looper").getPath(), + "\\[0\\.0\\] Loaded executable file.*"); + e.sendCommandExpectPrompt("run -arg1 -arg2", "running.*-arg1 -arg2.*" + + "Attached to process ([0-9]+).*" + "Running process ([0-9]+).*"); + try { Thread.sleep(500); } catch (Exception e) {} + e.sendCommandExpectPrompt("run -arg3", "running.*-arg3.*" + + "Attached to process ([0-9]+).*" + "Running process ([0-9]+).*"); + try { Thread.sleep(500); } catch (Exception e) {} + e.sendCommandExpectPrompt("run -arg4 -arg5", "running.*-arg4 -arg5.*" + + "Attached to process ([0-9]+).*" + "Running process ([0-9]+).*"); + e.send("quit\n"); + e.expect("Quitting\\.\\.\\."); + e.close(); + } + + /** + * This test case tests passing of "--" to abort passing of any args + * + */ + public void testNoParms() { + e = new HpdTestbed(); + e.sendCommandExpectPrompt("load " + Prefix.pkgLibFile("funit-threads-looper").getPath(), + "\\[0\\.0\\] Loaded executable file.*"); + e.sendCommandExpectPrompt("run -arg1 -arg2", "running.*-arg1 -arg2.*" + + "Attached to process ([0-9]+).*" + "Running process ([0-9]+).*"); + try { Thread.sleep(500); } catch (Exception e) {} + //e.sendCommandExpectPrompt("run --", "running.*threads-looper \\r\\n" + + // "Attached to process ([0-9]+).*" + "Running process ([0-9]+).*"); + e.send("run --\n"); + e.expect("Killing process.*"); + e.expect("\\[0\\.0\\] Loaded executable file.*"); + e.expect("running.*threads-looper\\r\\n"); + e.expect("Attached to process ([0-9]+).*"); + try { Thread.sleep(1000); } catch (Exception e) {} + //e.expect("Running process ([0-9]+).*"); + //try { Thread.sleep(500); } catch (Exception e) {} + //e.sendCommandExpectPrompt("run -arg4 -arg5", "running.*-arg4 -arg5.*" + + // "Attached to process ([0-9]+).*" + "Running process ([0-9]+).*"); + 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 40295a0..43ab03c 100644 --- a/frysk-core/frysk/hpd/TestStartCommand.java +++ b/frysk-core/frysk/hpd/TestStartCommand.java @@ -124,8 +124,7 @@ public class TestStartCommand extends TestLib { e.sendCommandExpectPrompt("load " + Prefix.pkgLibFile("funit-threads-looper").getPath(), "\\[1\\.0\\] Loaded executable file.*"); e.sendCommandExpectPrompt("focus [1.0]", "Creating new HPD notation set.*"); - e.sendCommandExpectPrompt("start", "Attached to process ([0-9]+).*" + - "starting.*"); + e.sendCommandExpectPrompt("start", "starting.*" + "Attached to process ([0-9]+).*"); e.sendCommandExpectPrompt("load", "\\[0\\.0\\].*funit-hello.*"); e.send("quit\n"); e.expect("Quitting\\.\\.\\."); @@ -145,8 +144,8 @@ public class TestStartCommand extends TestLib { "\\[1\\.0\\] Loaded executable file.*"); e.sendCommandExpectPrompt("load " + Prefix.pkgLibFile("funit-threads-looper").getPath(), "\\[2\\.0\\] Loaded executable file.*"); - e.sendCommandExpectPrompt("[1.0] start", "Attached to process ([0-9]+).*" + "Creating new.*" + - "starting.*"); + e.sendCommandExpectPrompt("[1.0] start", "Creating new.*" + + "starting.*" + "Attached to process ([0-9]+).*"); 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.*"); @@ -154,4 +153,52 @@ public class TestStartCommand extends TestLib { e.expect("Quitting\\.\\.\\."); e.close(); } + + /** + * This test case tests passing of different parameters + * + */ + public void testDiffParams() { + e = new HpdTestbed(); + e.sendCommandExpectPrompt("load " + Prefix.pkgLibFile("funit-threads-looper").getPath(), + "\\[0\\.0\\] Loaded executable file.*"); + e.sendCommandExpectPrompt("start -arg1 -arg2", "starting.*-arg1 -arg2.*" + + "Attached to process ([0-9]+).*"); + try { Thread.sleep(500); } catch (Exception e) {} + e.sendCommandExpectPrompt("start -arg3", "starting.*-arg3.*" + + "Attached to process ([0-9]+).*"); + try { Thread.sleep(500); } catch (Exception e) {} + e.sendCommandExpectPrompt("start -arg4 -arg5", "starting.*-arg4 -arg5.*" + + "Attached to process ([0-9]+).*"); + e.send("quit\n"); + e.expect("Quitting\\.\\.\\."); + e.close(); + } + + /** + * This test case tests passing of "--" to abort passing of any args + * + */ + public void testNoParms() { + e = new HpdTestbed(); + e.sendCommandExpectPrompt("load " + Prefix.pkgLibFile("funit-threads-looper").getPath(), + "\\[0\\.0\\] Loaded executable file.*"); + e.sendCommandExpectPrompt("start -arg1 -arg2", "starting.*-arg1 -arg2.*" + + "Attached to process ([0-9]+).*"); + try { Thread.sleep(500); } catch (Exception e) {} + //e.sendCommandExpectPrompt("run --", "running.*threads-looper \\r\\n" + + // "Attached to process ([0-9]+).*" + "Running process ([0-9]+).*"); + e.send("start --\n"); + e.expect("Killing process.*"); + e.expect("\\[0\\.0\\] Loaded executable file.*"); + e.expect("starting.*threads-looper\\r\\n"); + e.expect("Attached to process ([0-9]+).*"); + //try { Thread.sleep(1000); } catch (Exception e) {} + //e.sendCommandExpectPrompt("start -arg4 -arg5", "starting.*-arg4 -arg5.*"); + // "Attached to process ([0-9]+).*"); + try { Thread.sleep(500); } catch (Exception e) {} + e.send("quit\n"); + e.expect("Quitting\\.\\.\\."); + e.close(); + } } \ No newline at end of file hooks/post-receive -- frysk system monitor/debugger