lttng: Fix not being able to get available context with LTTng 2.8
authorMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Mon, 18 Apr 2016 17:43:41 +0000 (13:43 -0400)
committerMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Thu, 21 Apr 2016 17:44:15 +0000 (13:44 -0400)
'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 <marc-andre.laperle@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/70894
Reviewed-by: Hudson CI
lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/src/org/eclipse/tracecompass/lttng2/control/ui/tests/service/LTTngControlServiceMiTest.java
lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/testfiles/LTTngServiceMiTest.cfg
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlServiceConstants.java
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlServiceMI.java

index 3d06be2b6b25f2679cada89ad879626fc9c361a8..06f479036a5db3509c2c56cc9bfcf431bdab198b 100644 (file)
@@ -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<String> availContexts = fService.getContextList(new NullProgressMonitor());
+        assertNotNull(availContexts);
+        assertEquals(12, availContexts.size());
+
+        Set<String> 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
index 969cee7491668eec05f08c846eba3d110625599d..e88b05f3277a8bd5a5eedf7d45d5807641ecff20 100644 (file)
@@ -1990,6 +1990,35 @@ UST context pid added to event sched_kthread_stop_ret channel mychannel
 </COMMAND_OUTPUT>
 </SCENARIO>
 
+####################################################################
+# Scenario: Test "lttng --mi xml add-context --list"
+####################################################################
+
+<SCENARIO>
+ListContext28
+
+<COMMAND_INPUT>
+lttng --mi xml add-context --list
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+pid
+procname
+prio
+nice
+vpid
+tid
+pthread_id
+vtid
+ppid
+vppid
+perf:cpu:cpu-cycles
+perf:cpu:cycles
+</COMMAND_OUTPUT>
+</SCENARIO>
+
 <SCENARIO>
 ContextErrorHandling
 
index 9b161045a7feb99a897b5c76db403176e6aff5e7..934c1de7a2192d2e63e78b7785584097c4c79a91 100644 (file)
@@ -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
      */
index bb36ea6059d043b48cf4bc8f0868d497bea85a07..4fadc2f2f058fb3487b9fe9b5fa6d7116bed284b 100644 (file)
@@ -981,4 +981,14 @@ public class LTTngControlServiceMI extends LTTngControlService {
         return node;
     }
 
+    @Override
+    public @NonNull List<String> 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();
+    }
 }
This page took 0.027162 seconds and 5 git commands to generate.