From 182e9b8fbfc925ac36b536806865b9dea24048b8 Mon Sep 17 00:00:00 2001 From: Marc-Andre Laperle Date: Mon, 18 Apr 2016 13:43:41 -0400 Subject: [PATCH] lttng: Fix not being able to get available context with LTTng 2.8 'lttng add-context -h' was replaced with 'lttng add-context --list' in LTTng 2.8 Bug: 491933 Change-Id: If277b86410a5d19cfa53531b03dfb5b7350c4c5b Signed-off-by: Marc-Andre Laperle Reviewed-on: https://git.eclipse.org/r/70894 Reviewed-by: Hudson CI --- .../service/LTTngControlServiceMiTest.java | 31 +++++++++++++++++++ .../testfiles/LTTngServiceMiTest.cfg | 29 +++++++++++++++++ .../service/LTTngControlServiceConstants.java | 7 ++++- .../views/service/LTTngControlServiceMI.java | 10 ++++++ 4 files changed, 76 insertions(+), 1 deletion(-) diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/src/org/eclipse/tracecompass/lttng2/control/ui/tests/service/LTTngControlServiceMiTest.java b/lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/src/org/eclipse/tracecompass/lttng2/control/ui/tests/service/LTTngControlServiceMiTest.java index 3d06be2b6b..06f479036a 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/src/org/eclipse/tracecompass/lttng2/control/ui/tests/service/LTTngControlServiceMiTest.java +++ b/lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/src/org/eclipse/tracecompass/lttng2/control/ui/tests/service/LTTngControlServiceMiTest.java @@ -18,7 +18,9 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.net.URL; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.runtime.NullProgressMonitor; @@ -34,6 +36,7 @@ import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceLogLevel import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceSessionState; import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.SessionInfo; import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.ILttngControlService; +import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.LTTngControlService; import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.LTTngControlServiceConstants; import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.LTTngControlServiceMI; import org.junit.Ignore; @@ -43,6 +46,7 @@ import org.junit.Test; * @author ejorajo * */ +@SuppressWarnings("javadoc") public class LTTngControlServiceMiTest extends LTTngControlServiceTest { private static final String MI_TEST_STREAM = "LTTngServiceMiTest.cfg"; @@ -50,6 +54,7 @@ public class LTTngControlServiceMiTest extends LTTngControlServiceTest { private static final String SCEN_SESSION_WITH_SYSCALLS = "GetSessionWithSyscalls"; private static final String SCEN_LIST_SESSION_2_7_COMPAT = "ListSession2.7Compat"; private static final String SCEN_GET_SESSION_FILTER_EXPRESSION = "GetSessionFilterExpression"; + private static final String SCEN_LIST_CONTEXT_28 = "ListContext28"; @Override protected ILttngControlService getControlService() { @@ -157,6 +162,32 @@ public class LTTngControlServiceMiTest extends LTTngControlServiceTest { // is wrong for 2.6. } + @Test + public void testListContext28() throws ExecutionException { + ((LTTngControlService)fService).setVersion("2.8.0"); + fShell.setScenario(SCEN_LIST_CONTEXT_28); + + List availContexts = fService.getContextList(new NullProgressMonitor()); + assertNotNull(availContexts); + assertEquals(12, availContexts.size()); + + Set expectedContexts = new HashSet<>(); + expectedContexts.add("pid"); + expectedContexts.add("procname"); + expectedContexts.add("prio"); + expectedContexts.add("nice"); + expectedContexts.add("vpid"); + expectedContexts.add("tid"); + expectedContexts.add("pthread_id"); + expectedContexts.add("vtid"); + expectedContexts.add("ppid"); + expectedContexts.add("vppid"); + expectedContexts.add("perf:cpu:cpu-cycles"); + expectedContexts.add("perf:cpu:cycles"); + + assertTrue(expectedContexts.containsAll(availContexts)); + } + @Override public void testCreateSnapshotSession2_5() { // not applicable for MI diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/testfiles/LTTngServiceMiTest.cfg b/lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/testfiles/LTTngServiceMiTest.cfg index 969cee7491..e88b05f327 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/testfiles/LTTngServiceMiTest.cfg +++ b/lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/testfiles/LTTngServiceMiTest.cfg @@ -1990,6 +1990,35 @@ UST context pid added to event sched_kthread_stop_ret channel mychannel +#################################################################### +# Scenario: Test "lttng --mi xml add-context --list" +#################################################################### + + +ListContext28 + + +lttng --mi xml add-context --list + + +0 + + +pid +procname +prio +nice +vpid +tid +pthread_id +vtid +ppid +vppid +perf:cpu:cpu-cycles +perf:cpu:cycles + + + ContextErrorHandling diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlServiceConstants.java b/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlServiceConstants.java index 9b161045a7..934c1de7a2 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlServiceConstants.java +++ b/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlServiceConstants.java @@ -244,9 +244,14 @@ public interface LTTngControlServiceConstants { */ String OPTION_READ_TIMER = "--read-timer"; //$NON-NLS-1$ /** - * Command line option for printing the help of a specif command + * Command line option for printing the help of a specific command */ String OPTION_HELP = "-h"; //$NON-NLS-1$ + /** + * Command line option for listing things. For example listing available + * context. + */ + String OPTION_LIST = "--list"; //$NON-NLS-1$ /** * Command line option for listing the fields of UST tracepoints */ diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlServiceMI.java b/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlServiceMI.java index bb36ea6059..4fadc2f2f0 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlServiceMI.java +++ b/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlServiceMI.java @@ -981,4 +981,14 @@ public class LTTngControlServiceMI extends LTTngControlService { return node; } + @Override + public @NonNull List getContextList(IProgressMonitor monitor) throws ExecutionException { + if (!isVersionSupported("2.8.0")) { //$NON-NLS-1$) + return super.getContextList(monitor); + } + + ICommandInput command = createCommand(LTTngControlServiceConstants.COMMAND_ADD_CONTEXT, LTTngControlServiceConstants.OPTION_LIST); + ICommandResult result = executeCommand(command, monitor); + return result.getOutput(); + } } -- 2.34.1