Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng2/control/stubs/shells/LTTngToolsFileShell.java54
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng2/control/stubs/shells/TestCommandShell.java2
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/testfiles/CreateTreeTest2.cfg2
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/testfiles/LTTngServiceTest.cfg32
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/testfiles/ListInfoTest.cfg2
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/remote/CommandResult.java21
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/remote/CommandShell.java5
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/remote/ICommandResult.java15
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/LTTngControlService.java34
9 files changed, 128 insertions, 39 deletions
diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng2/control/stubs/shells/LTTngToolsFileShell.java b/lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng2/control/stubs/shells/LTTngToolsFileShell.java
index babebe29da..3f262b6c04 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng2/control/stubs/shells/LTTngToolsFileShell.java
+++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng2/control/stubs/shells/LTTngToolsFileShell.java
@@ -42,6 +42,8 @@ public class LTTngToolsFileShell extends TestCommandShell {
private final static String RESULT_KEY = "<COMMAND_RESULT>";
private final static String OUTPUT_KEY = "<COMMAND_OUTPUT>";
private final static String OUTPUT_END_KEY = "</COMMAND_OUTPUT>";
+ private final static String ERROR_OUTPUT_KEY = "<COMMAND_ERROR_OUTPUT>";
+ private final static String ERROR_OUTPUT_END_KEY = "</COMMAND_ERROR_OUTPUT>";
private final static String COMMENT_KEY = "#.*";
private final static Pattern LTTNG_LIST_SESSION_PATTERN = Pattern.compile("lttng\\s+list\\s+(.+)");
@@ -58,32 +60,37 @@ public class LTTngToolsFileShell extends TestCommandShell {
/**
* Parse a scenario file with the format:
- * <SCENARIO>
+ * <pre>
+ * &lt;SCENARIO&gt;
* ScenarioName
*
- * <COMMAND_INPUT>
+ * &lt;COMMAND_INPUT&gt;
* Command
- * </COMAND_INPUT>
+ * &lt;/COMAND_INPUT&gt;
*
- * <COMMAND_RESULT>
+ * &lt;COMMAND_RESULT&gt;
* CommandResult
- * </COMMAND_RESULT>
+ * &lt;/COMMAND_RESULT&gt;
*
- * <COMMAND_OUTPUT>
+ * &lt;COMMAND_OUTPUT&gt;
* CommandOutput
- * </COMMAND_OUTPUT>
+ * &lt;COMMAND_ERROR_OUTPUT&gt;
+ * CommandErrorOutput
+ * &lt;/COMMAND_ERROR_OUTPUT&gt;
+ * &lt;/COMMAND_OUTPUT&gt;
*
- * </SCENARIO>
+ * &lt;/SCENARIO&gt;
*
* Where: ScenarioName - is the scenario name
* Command - the command line string
* CommandResult - the result integer of the command (0 for success, 1 for failure)
* ComandOutput - the command output string (multi-line possible)
+ * ComandErrorOutput - the command error output string (multi-line possible)
*
* Note: 1) There can be many scenarios per file
* 2) There can be many (Command-CommandResult-CommandOutput) triples per scenario
* 3) Lines starting with # will be ignored (comments)
- *
+ * <pre>
* @param scenariofile - path to scenario file
* @throws Exception
*/
@@ -132,8 +139,10 @@ public class LTTngToolsFileShell extends TestCommandShell {
Map<String, ICommandResult> commandMap = new HashMap<>();
fScenarioMap.put(scenario, commandMap);
List<String> output = null;
+ List<String> errorOutput = null;
String input = null;
boolean inOutput = false;
+ boolean inErrorOutput = false;
int result = 0;
tmpSessionNameMap.clear();
while ((strLine = br.readLine()) != null) {
@@ -172,6 +181,7 @@ public class LTTngToolsFileShell extends TestCommandShell {
} else if (INPUT_END_KEY.equals(strLine)) {
// Initialize output array
output = new ArrayList<>();
+ errorOutput = new ArrayList<>();
} else if (RESULT_KEY.equals(strLine)) {
strLine = br.readLine();
// Ignore comments
@@ -182,25 +192,26 @@ public class LTTngToolsFileShell extends TestCommandShell {
result = Integer.parseInt(strLine);
} else if (OUTPUT_END_KEY.equals(strLine)) {
// Save output/result in command map
- if (output != null) {
- commandMap.put(input, new CommandResult(result, output.toArray(new String[output.size()])));
+ if (output != null && errorOutput != null) {
+ commandMap.put(input, new CommandResult(result, output.toArray(new String[output.size()]), errorOutput.toArray(new String[errorOutput.size()])));
}
inOutput = false;
} else if (OUTPUT_KEY.equals(strLine)) {
// first line of output
inOutput = true;
- strLine = br.readLine();
-
- // Ignore comments
+ } else if (ERROR_OUTPUT_KEY.equals(strLine)) {
+ // first line of output
+ inErrorOutput = true;
+ } else if (ERROR_OUTPUT_END_KEY.equals(strLine)) {
+ inErrorOutput = false;
+ } else if (inOutput) {
while (isComment(strLine)) {
strLine = br.readLine();
}
- if (output != null) {
- output.add(strLine);
- }
- } else if (inOutput) {
- // subsequent lines of output
- if (output != null) {
+ // lines of output/error output
+ if (errorOutput != null && inErrorOutput) {
+ errorOutput.add(strLine);
+ } else if (output != null) {
output.add(strLine);
}
}
@@ -247,9 +258,10 @@ public class LTTngToolsFileShell extends TestCommandShell {
String[] output = new String[1];
output[0] = String.valueOf("Command not found");
- CommandResult result = new CommandResult(0, null);
+ CommandResult result = new CommandResult(0, null, null);
// For verification of setters of class CommandResult
result.setOutput(output);
+ result.setErrorOutput(output);
result.setResult(1);
return result;
}
diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng2/control/stubs/shells/TestCommandShell.java b/lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng2/control/stubs/shells/TestCommandShell.java
index 86b39e2dad..998e72eb30 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng2/control/stubs/shells/TestCommandShell.java
+++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng2/control/stubs/shells/TestCommandShell.java
@@ -45,6 +45,6 @@ public class TestCommandShell implements ICommandShell {
if (fIsConnected) {
}
- return new CommandResult(0, new String[0]);
+ return new CommandResult(0, new String[0], new String[0]);
}
}
diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/testfiles/CreateTreeTest2.cfg b/lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/testfiles/CreateTreeTest2.cfg
index dde430a336..929dc44a25 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/testfiles/CreateTreeTest2.cfg
+++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/testfiles/CreateTreeTest2.cfg
@@ -280,7 +280,9 @@ lttng enable-channel mychannel -u -s mysession -C 1024 -W 10
0
</COMMAND_RESULT>
<COMMAND_OUTPUT>
+<COMMAND_ERROR_OUTPUT>
Warning: Tracefile size rounded up from (1024) to subbuffer size (8388608)
+</COMMAND_ERROR_OUTPUT>
UST channel mychannel enabled for session mysession
</COMMAND_OUTPUT>
diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/testfiles/LTTngServiceTest.cfg b/lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/testfiles/LTTngServiceTest.cfg
index 22a69e988c..9d519f92eb 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/testfiles/LTTngServiceTest.cfg
+++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/testfiles/LTTngServiceTest.cfg
@@ -21,7 +21,9 @@ lttng list
1
</COMMAND_RESULT>
<COMMAND_OUTPUT>
+<COMMAND_ERROR_OUTPUT>
Command not found
+</COMMAND_ERROR_OUTPUT>
</COMMAND_OUTPUT>
</SCENARIO>
@@ -151,7 +153,9 @@ lttng list test
</COMMAND_RESULT>
<COMMAND_OUTPUT>
Session test not found
+<COMMAND_ERROR_OUTPUT>
Error: Session name not found
+</COMMAND_ERROR_OUTPUT>
</COMMAND_OUTPUT>
</SCENARIO>
@@ -169,8 +173,10 @@ lttng -vvv list test
<COMMAND_OUTPUT>
DEBUG2: Session name: test [in cmd_list() at commands/list.c:618]
DEBUG1: Session count 1 [in list_sessions() at commands/list.c:485]
+<COMMAND_ERROR_OUTPUT>
Error: Session 'test' not found
Error: Command error
+</COMMAND_ERROR_OUTPUT>
DEBUG1: Clean exit [in clean_exit() at lttng.c:165]
</COMMAND_OUTPUT>
</SCENARIO>
@@ -319,7 +325,9 @@ lttng list -k
</COMMAND_RESULT>
<COMMAND_OUTPUT>
Spawning session daemon
+<COMMAND_ERROR_OUTPUT>
Error: Unable to list kernel events
+</COMMAND_ERROR_OUTPUT>
</COMMAND_OUTPUT>
</SCENARIO>
@@ -335,7 +343,9 @@ lttng list -k
1
</COMMAND_RESULT>
<COMMAND_OUTPUT>
+<COMMAND_ERROR_OUTPUT>
Error: Unable to list kernel events
+</COMMAND_ERROR_OUTPUT>
</COMMAND_OUTPUT>
</SCENARIO>
@@ -353,7 +363,9 @@ lttng -vvv list -k
<COMMAND_OUTPUT>
DEBUG2: Session name: (null) [in cmd_list() at commands/list.c:618]
DEBUG1: Getting kernel tracing events [in list_kernel_events() at commands/list.c:309]
+<COMMAND_ERROR_OUTPUT>
Error: Unable to list kernel events
+</COMMAND_ERROR_OUTPUT>
DEBUG1: Clean exit [in clean_exit() at lttng.c:165]
</COMMAND_OUTPUT>
</SCENARIO>
@@ -435,8 +447,10 @@ lttng list -u -f
</COMMAND_RESULT>
<COMMAND_OUTPUT>
Spawning a session daemon
+<COMMAND_ERROR_OUTPUT>
Error: Unable to list UST events: Listing UST events failed
Error: Command Error
+</COMMAND_ERROR_OUTPUT>
</COMMAND_OUTPUT>
</SCENARIO>
@@ -452,8 +466,10 @@ lttng list -u -f
1
</COMMAND_RESULT>
<COMMAND_OUTPUT>
+<COMMAND_ERROR_OUTPUT>
Error: Unable to list UST events: Listing UST events failed
Error: Command Error
+</COMMAND_ERROR_OUTPUT>
</COMMAND_OUTPUT>
</SCENARIO>
@@ -472,8 +488,10 @@ lttng -vvv list -u -f
DEBUG2: Session name: (null) [in cmd_list() at commands/list.c:618]
DEBUG1: Getting kernel tracing events [in list_kernel_events() at commands/list.c:309]
Spawning a session daemon
+<COMMAND_ERROR_OUTPUT>
Error: Unable to list UST events: Listing UST events failed
Error: Command Error
+</COMMAND_ERROR_OUTPUT>
DEBUG1: Clean exit [in clean_exit() at lttng.c:165]
</COMMAND_OUTPUT>
</SCENARIO>
@@ -559,7 +577,9 @@ lttng create alreadyExist
1
</COMMAND_RESULT>
<COMMAND_OUTPUT>
+<COMMAND_ERROR_OUTPUT>
Error: Session name already exist
+</COMMAND_ERROR_OUTPUT>
</COMMAND_OUTPUT>
<COMMAND_INPUT>
@@ -1271,7 +1291,9 @@ lttng snapshot list-output -s blabla
1
</COMMAND_RESULT>
<COMMAND_OUTPUT>
+<COMMAND_ERROR_OUTPUT>
Error: Session name not found
+</COMMAND_ERROR_OUTPUT>
</COMMAND_OUTPUT>
#------------------------------------------------------------------------------
#next is not an error case but good to be tested
@@ -1293,7 +1315,9 @@ lttng snapshot record -s blabla
1
</COMMAND_RESULT>
<COMMAND_OUTPUT>
+<COMMAND_ERROR_OUTPUT>
Error: Session name not found
+</COMMAND_ERROR_OUTPUT>
</COMMAND_OUTPUT>
#------------------------------------------------------------------------------
<COMMAND_INPUT>
@@ -1303,7 +1327,9 @@ lttng snapshot record -s mysession
1
</COMMAND_RESULT>
<COMMAND_OUTPUT>
+<COMMAND_ERROR_OUTPUT>
Error: Session needs to be started once
+</COMMAND_ERROR_OUTPUT>
</COMMAND_OUTPUT>
</SCENARIO>
@@ -1361,8 +1387,10 @@ lttng create mysession --live --snapshot
1
</COMMAND_RESULT>
<COMMAND_OUTPUT>
+<COMMAND_ERROR_OUTPUT>
Error: Snapshot and live modes are mutually exclusive.
Error: Command error
+</COMMAND_ERROR_OUTPUT>
</COMMAND_OUTPUT>
#------------------------------------------------------------------------------
<COMMAND_INPUT>
@@ -1372,9 +1400,11 @@ lttng create mysession --live -U blah
1
</COMMAND_RESULT>
<COMMAND_OUTPUT>
+<COMMAND_ERROR_OUTPUT>
Error: URI parse unknown protocol blah
Error: Unable to parse the URL blah
Error: Invalid parameter
+</COMMAND_ERROR_OUTPUT>
</COMMAND_OUTPUT>
#------------------------------------------------------------------------------
<COMMAND_INPUT>
@@ -1384,7 +1414,9 @@ lttng create mysession --live -C net://127.0.0.1
1
</COMMAND_RESULT>
<COMMAND_OUTPUT>
+<COMMAND_ERROR_OUTPUT>
Error: You need both control and data URL.
Error: Command error
+</COMMAND_ERROR_OUTPUT>
</COMMAND_OUTPUT>
</SCENARIO> \ No newline at end of file
diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/testfiles/ListInfoTest.cfg b/lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/testfiles/ListInfoTest.cfg
index e7abfcd912..4329c6f5bc 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/testfiles/ListInfoTest.cfg
+++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/testfiles/ListInfoTest.cfg
@@ -215,7 +215,9 @@ lttng list -k
1
</COMMAND_RESULT>
<COMMAND_OUTPUT>
+<COMMAND_ERROR_OUTPUT>
Error: Unable to list kernel events
+</COMMAND_ERROR_OUTPUT>
</COMMAND_OUTPUT>
<COMMAND_INPUT>
diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/remote/CommandResult.java b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/remote/CommandResult.java
index 3ae6cd0af4..9b7c0b545d 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/remote/CommandResult.java
+++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/remote/CommandResult.java
@@ -34,6 +34,7 @@ public class CommandResult implements ICommandResult {
* The output as String array.
*/
private String[] fOutput = new String[0];
+ private String[] fErrorOutput = new String[0];
// ------------------------------------------------------------------------
// Constructor
@@ -46,12 +47,17 @@ public class CommandResult implements ICommandResult {
* The result of the command
* @param output
* The output, as an array of strings
+ * @param errorOutput
+ * THe error output as an array of strings
*/
- public CommandResult(int result, String[] output) {
+ public CommandResult(int result, String[] output, String[] errorOutput) {
fResult = result;
if (output != null) {
fOutput = Arrays.copyOf(output, output.length);
}
+ if (errorOutput != null) {
+ fErrorOutput = Arrays.copyOf(errorOutput, errorOutput.length);
+ }
}
// ------------------------------------------------------------------------
@@ -80,4 +86,17 @@ public class CommandResult implements ICommandResult {
fOutput = Arrays.copyOf(output, output.length);
}
}
+
+ @Override
+ public String[] getErrorOutput() {
+ return Arrays.copyOf(fErrorOutput, fErrorOutput.length);
+ }
+
+ @Override
+ public void setErrorOutput(String[] output) {
+ fErrorOutput = new String[0];
+ if (output != null) {
+ fErrorOutput = Arrays.copyOf(output, output.length);
+ }
+ }
} \ No newline at end of file
diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/remote/CommandShell.java b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/remote/CommandShell.java
index 2a94a9c1f1..04d3938b3c 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/remote/CommandShell.java
+++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/remote/CommandShell.java
@@ -137,6 +137,7 @@ public class CommandShell implements ICommandShell {
@Override
public CommandResult call() throws IOException, CancellationException {
final ArrayList<String> result = new ArrayList<>();
+ final ArrayList<String> errorResult = new ArrayList<>();
synchronized (fHostShell) {
// Initialize return value which will be updated in isAliasEchoResult()
@@ -189,12 +190,12 @@ public class CommandShell implements ICommandShell {
if (fReturnValue != 0) {
while(fErrorBufferReader.ready()) {
if ((nextLine = fErrorBufferReader.readLine()) != null) {
- result.add(nextLine);
+ errorResult.add(nextLine);
}
}
}
}
- return new CommandResult(fReturnValue, result.toArray(new String[result.size()]));
+ return new CommandResult(fReturnValue, result.toArray(new String[result.size()]), errorResult.toArray(new String[errorResult.size()]));
}
});
diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/remote/ICommandResult.java b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/remote/ICommandResult.java
index 3b23d358b0..be1d2abe33 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/remote/ICommandResult.java
+++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/remote/ICommandResult.java
@@ -46,4 +46,19 @@ public interface ICommandResult {
* The output (as an array of Strings) to assign
*/
void setOutput(String[] output);
+
+ /**
+ * The error output of the command.
+ *
+ * @return returns the command error output.
+ */
+ String[] getErrorOutput();
+
+ /**
+ * Sets the command output.
+ *
+ * @param output
+ * The output (as an array of Strings) to assign
+ */
+ void setErrorOutput(String[] output);
} \ No newline at end of file
diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/LTTngControlService.java b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/LTTngControlService.java
index 9af28be07a..bcce1d163c 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/LTTngControlService.java
+++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/LTTngControlService.java
@@ -296,7 +296,7 @@ public class LTTngControlService implements ILttngControlService {
List<IBaseEventInfo> events = new ArrayList<>();
- if (result.getOutput() != null) {
+ if (result.getErrorOutput() != null) {
// Ignore the following 2 cases:
// Spawning a session daemon
// Error: Unable to list kernel events
@@ -304,8 +304,8 @@ public class LTTngControlService implements ILttngControlService {
// Error: Unable to list kernel events
//
int index = 0;
- while (index < result.getOutput().length) {
- String line = result.getOutput()[index];
+ while (index < result.getErrorOutput().length) {
+ String line = result.getErrorOutput()[index];
Matcher matcher = LTTngControlServiceConstants.LIST_KERNEL_NO_KERNEL_PROVIDER_PATTERN.matcher(line);
if (matcher.matches()) {
return events;
@@ -347,7 +347,7 @@ public class LTTngControlService implements ILttngControlService {
return allProviders;
}
- if (result.getOutput() != null) {
+ if (result.getErrorOutput() != null) {
// Ignore the following 2 cases:
// Spawning a session daemon
// Error: Unable to list UST events: Listing UST events failed
@@ -355,8 +355,8 @@ public class LTTngControlService implements ILttngControlService {
// Error: Unable to list UST events: Listing UST events failed
//
int index = 0;
- while (index < result.getOutput().length) {
- String line = result.getOutput()[index];
+ while (index < result.getErrorOutput().length) {
+ String line = result.getErrorOutput()[index];
Matcher matcher = LTTngControlServiceConstants.LIST_UST_NO_UST_PROVIDER_PATTERN.matcher(line);
if (matcher.matches()) {
return allProviders;
@@ -575,13 +575,13 @@ public class LTTngControlService implements ILttngControlService {
StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_DESTROY_SESSION, newName);
ICommandResult result = executeCommand(command.toString(), monitor, false);
- String[] output = result.getOutput();
+ String[] errorOutput = result.getErrorOutput();
boolean isError = isError(result);
- if (isError && (output != null)) {
+ if (isError && (errorOutput != null)) {
int index = 0;
- while (index < output.length) {
- String line = output[index];
+ while (index < errorOutput.length) {
+ String line = errorOutput[index];
Matcher matcher = LTTngControlServiceConstants.SESSION_NOT_FOUND_ERROR_PATTERN.matcher(line);
if (matcher.matches()) {
// Don't treat this as an error
@@ -1032,14 +1032,15 @@ public class LTTngControlService implements ILttngControlService {
*/
protected boolean isError(ICommandResult result) {
// Check return code and length of returned strings
- if ((result.getResult()) != 0 || (result.getOutput().length < 1)) {
+
+ if ((result.getResult()) != 0) {
return true;
}
// Look for error pattern
int index = 0;
- while (index < result.getOutput().length) {
- String line = result.getOutput()[index];
+ while (index < result.getErrorOutput().length) {
+ String line = result.getErrorOutput()[index];
Matcher matcher = LTTngControlServiceConstants.ERROR_PATTERN.matcher(line);
if (matcher.matches()) {
return true;
@@ -1058,10 +1059,11 @@ public class LTTngControlService implements ILttngControlService {
* @return - the formatted output
*/
public static String formatOutput(ICommandResult result) {
- if ((result == null) || result.getOutput() == null || result.getOutput().length == 0) {
+ if ((result == null) || ((result.getOutput() == null || result.getOutput().length == 0) && (result.getErrorOutput() == null || result.getErrorOutput().length == 0))) {
return ""; //$NON-NLS-1$
}
String[] output = result.getOutput();
+ String[] errorOutput = result.getErrorOutput();
StringBuffer ret = new StringBuffer();
ret.append("Return Value: "); //$NON-NLS-1$
ret.append(result.getResult());
@@ -1069,6 +1071,10 @@ public class LTTngControlService implements ILttngControlService {
for (int i = 0; i < output.length; i++) {
ret.append(output[i]).append("\n"); //$NON-NLS-1$
}
+ ret.append("Error stream:\n"); //$NON-NLS-1$
+ for (int i = 0; i < errorOutput.length; i++) {
+ ret.append(errorOutput[i]).append("\n"); //$NON-NLS-1$
+ }
return ret.toString();
}

Back to the top