lttng: Add schema for LTTng MI 3.0 (LTTng 2.8)
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.control.ui.tests / src / org / eclipse / tracecompass / lttng2 / control / ui / tests / service / LTTngControlServiceMiTest.java
index ce11fba59ad03819b804d7d729096afa7a196cad..01abe382543665800029408b3f9446400fb1fa72 100644 (file)
@@ -17,8 +17,9 @@ import static org.junit.Assert.assertNotNull;
 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,26 +35,30 @@ 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.LTTngControlServiceConstants;
+import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.LTTngControlService;
 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.LTTngControlServiceMI;
+import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.LttngVersion;
+import org.junit.Ignore;
 import org.junit.Test;
 
 /**
  * @author ejorajo
  *
  */
+@SuppressWarnings("javadoc")
 public class LTTngControlServiceMiTest extends LTTngControlServiceTest {
 
     private static final String MI_TEST_STREAM = "LTTngServiceMiTest.cfg";
 
     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() {
         try {
-            URL resource = LTTngControlServiceMI.class.getResource(LTTngControlServiceConstants.MI_XSD_FILENAME);
-            return new LTTngControlServiceMI(getShell(), resource);
+            return new LTTngControlServiceMI(getShell(), new LttngVersion("2.7.0"));
         } catch (ExecutionException e) {
             return null;
         }
@@ -72,6 +77,7 @@ public class LTTngControlServiceMiTest extends LTTngControlServiceTest {
     }
 
     @Override
+    @Ignore
     public void testCreateLiveSession() throws ExecutionException {
         fShell.setScenario(SCEN_CREATE_LIVE_SESSION);
 
@@ -154,6 +160,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
@@ -304,4 +336,76 @@ public class LTTngControlServiceMiTest extends LTTngControlServiceTest {
             fail(e.toString());
         }
     }
+
+    @Test
+    public void testGetSessionWithFilterExpression() throws ExecutionException {
+        // FIXME: Disable scheme validation for now until MI 3.0 is integrated
+        LTTngControlServiceMI service = new LTTngControlServiceMI(getShell(), null);
+
+        fShell.setScenario(SCEN_GET_SESSION_FILTER_EXPRESSION);
+        ISessionInfo session = service.getSession("mysession", new NullProgressMonitor());
+
+        // Verify Session
+        assertNotNull(session);
+        assertEquals("mysession", session.getName());
+        assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session.getSessionPath());
+        assertEquals(TraceSessionState.ACTIVE, session.getSessionState());
+
+        IDomainInfo[] domains = session.getDomains();
+        assertNotNull(domains);
+        assertEquals(2, domains.length);
+
+        // Verify Kernel domain
+        assertEquals("Kernel", domains[0].getName());
+        IChannelInfo[] channels =  domains[0].getChannels();
+        assertNotNull(channels);
+        assertEquals(1, channels.length);
+
+        // Verify Kernel's channel0
+        assertEquals("channel0", channels[0].getName());
+        assertEquals(4, channels[0].getNumberOfSubBuffers());
+        assertEquals("splice()", channels[0].getOutputType().getInName());
+        assertEquals(TraceChannelOutputType.SPLICE, channels[0].getOutputType());
+        assertEquals(false, channels[0].isOverwriteMode());
+        assertEquals(200, channels[0].getReadTimer());
+        assertEquals(TraceEnablement.ENABLED, channels[0].getState());
+        assertEquals(262144, channels[0].getSubBufferSize());
+        assertEquals(0, channels[0].getSwitchTimer());
+
+        // Verify event info
+        IEventInfo[] channel0Events = channels[0].getEvents();
+        assertNotNull(channel0Events);
+        assertEquals(1, channel0Events.length);
+        assertEquals("block_rq_remap", channel0Events[0].getName());
+        assertEquals(TraceLogLevel.TRACE_EMERG, channel0Events[0].getLogLevel());
+        assertEquals(TraceEventType.TRACEPOINT, channel0Events[0].getEventType());
+        assertEquals(TraceEnablement.ENABLED, channel0Events[0].getState());
+        assertEquals("foo > 10", channel0Events[0].getFilterExpression());
+
+        // Verify domain UST global
+        assertEquals("UST global", domains[1].getName());
+
+        IChannelInfo[] ustChannels =  domains[1].getChannels();
+
+        // Verify UST global's channel0
+        assertEquals("channel0", ustChannels[0].getName());
+        assertEquals(4, ustChannels[0].getNumberOfSubBuffers());
+        assertEquals("mmap()", ustChannels[0].getOutputType().getInName());
+        assertEquals(TraceChannelOutputType.MMAP, ustChannels[0].getOutputType());
+        assertEquals(false, ustChannels[0].isOverwriteMode());
+        assertEquals(200, ustChannels[0].getReadTimer());
+        assertEquals(TraceEnablement.ENABLED, ustChannels[0].getState());
+        assertEquals(4096, ustChannels[0].getSubBufferSize());
+        assertEquals(0, ustChannels[0].getSwitchTimer());
+
+        // Verify event info
+        IEventInfo[] ustEvents = ustChannels[0].getEvents();
+        assertEquals(1, ustEvents.length);
+
+        assertEquals("ust_tests_hello:tptest_sighandler", ustEvents[0].getName());
+        assertEquals(TraceLogLevel.TRACE_DEBUG_LINE, ustEvents[0].getLogLevel());
+        assertEquals(TraceEventType.TRACEPOINT, ustEvents[0].getEventType());
+        assertEquals(TraceEnablement.DISABLED, ustEvents[0].getState());
+        assertEquals("foo > 10", ustEvents[0].getFilterExpression());
+    }
 }
This page took 0.027846 seconds and 5 git commands to generate.