Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Rajotte Julien2014-08-07 18:16:04 +0000
committerBernd Hufmann2014-08-11 14:58:40 +0000
commitd2b64f2febf954d4808acddcb6a48203560030e6 (patch)
tree30919e3b7d163de289f9360c710fa727793f6df7 /lttng/org.eclipse.linuxtools.lttng2.control.ui.tests
parentdf0a0573515150884289811d683669009892cf94 (diff)
downloadorg.eclipse.linuxtools-d2b64f2febf954d4808acddcb6a48203560030e6.tar.gz
org.eclipse.linuxtools-d2b64f2febf954d4808acddcb6a48203560030e6.tar.xz
org.eclipse.linuxtools-d2b64f2febf954d4808acddcb6a48203560030e6.zip
tmf: lttngControl: Separate STDERR from output and create errorOutput
Refactoring of current function to adjust to change. Modifications to test scenarios to support new error output Change-Id: I457aeed7ae6aba1ce880339c5a9b7f55c6a0e232 Signed-off-by: Jonathan Rajotte Julien <jonathan.rajotte-julien@ericsson.com> Reviewed-on: https://git.eclipse.org/r/31228 Tested-by: Hudson CI Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com> Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Diffstat (limited to 'lttng/org.eclipse.linuxtools.lttng2.control.ui.tests')
-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
5 files changed, 70 insertions, 22 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>

Back to the top