lttng: Add ControlService tests for LTTng MI 3.0
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.control.ui.tests / src / org / eclipse / tracecompass / lttng2 / control / ui / tests / service / LTTngControlServiceMi3Test.java
1 /******************************************************************************
2 * Copyright (c) 2016 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *******************************************************************************/
9
10 package org.eclipse.tracecompass.lttng2.control.ui.tests.service;
11
12 import static org.junit.Assert.assertEquals;
13 import static org.junit.Assert.assertNotNull;
14 import static org.junit.Assert.assertTrue;
15 import static org.junit.Assert.fail;
16
17 import java.util.HashSet;
18 import java.util.List;
19 import java.util.Set;
20
21 import org.eclipse.core.commands.ExecutionException;
22 import org.eclipse.core.runtime.NullProgressMonitor;
23 import org.eclipse.tracecompass.internal.lttng2.control.core.model.IChannelInfo;
24 import org.eclipse.tracecompass.internal.lttng2.control.core.model.IDomainInfo;
25 import org.eclipse.tracecompass.internal.lttng2.control.core.model.IEventInfo;
26 import org.eclipse.tracecompass.internal.lttng2.control.core.model.ISessionInfo;
27 import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceChannelOutputType;
28 import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceEnablement;
29 import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceEventType;
30 import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceLogLevel;
31 import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceSessionState;
32 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.ILttngControlService;
33 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.LTTngControlService;
34 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.LTTngControlServiceFactory;
35 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.LTTngControlServiceMI;
36 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.LttngVersion;
37 import org.junit.Test;
38
39 /**
40 * Tests for the MI service when using MI version 3.0
41 */
42 @SuppressWarnings("javadoc")
43 public class LTTngControlServiceMi3Test extends LTTngControlServiceMiTest {
44
45 private static final String MI_TEST_STREAM = "LTTngServiceMi3Test.cfg";
46
47 private static final String SCEN_GET_SESSION_FILTER_EXPRESSION = "GetSessionFilterExpression";
48 private static final String SCEN_LIST_CONTEXT_28 = "ListContext28";
49
50 @Override
51 protected ILttngControlService getControlService() {
52 try {
53 return new LTTngControlServiceMI(getShell(), new LttngVersion("2.8.0"));
54 } catch (ExecutionException e) {
55 return null;
56 }
57 }
58
59 @Override
60 protected String getTestStream() {
61 return MI_TEST_STREAM;
62 }
63
64 @Override
65 public void testVersion() {
66 try {
67 fShell.setScenario(SCEN_LTTNG_VERSION);
68 ILttngControlService service = LTTngControlServiceFactory.getLttngControlService(fShell);
69 assertNotNull(service);
70 assertEquals("2.8.0", service.getVersionString());
71 } catch (ExecutionException e) {
72 fail("Exeption thrown " + e);
73 }
74 }
75
76 @Override
77 public void testVersionWithPrompt() {
78 try {
79 fShell.setScenario(SCEN_LTTNG_VERSION_WITH_PROMPT);
80 ILttngControlService service = LTTngControlServiceFactory.getLttngControlService(fShell);
81 assertNotNull(service);
82 assertEquals("2.8.0", service.getVersionString());
83 } catch (ExecutionException e) {
84 fail("Exeption thrown " + e);
85 }
86 }
87
88 @Override
89 public void testVersionCompiled() {
90 try {
91 fShell.setScenario(SCEN_LTTNG_COMPILED_VERSION);
92 ILttngControlService service = LTTngControlServiceFactory.getLttngControlService(fShell);
93 assertNotNull(service);
94 assertEquals("2.8.0", service.getVersionString());
95 } catch (ExecutionException e) {
96 fail("Exeption thrown " + e);
97 }
98 }
99
100 @Test
101 public void testGetSessionWithFilterExpression() throws ExecutionException {
102 fShell.setScenario(SCEN_GET_SESSION_FILTER_EXPRESSION);
103 ISessionInfo session = fService.getSession("mysession", new NullProgressMonitor());
104
105 // Verify Session
106 assertNotNull(session);
107 assertEquals("mysession", session.getName());
108 assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session.getSessionPath());
109 assertEquals(TraceSessionState.ACTIVE, session.getSessionState());
110
111 IDomainInfo[] domains = session.getDomains();
112 assertNotNull(domains);
113 assertEquals(2, domains.length);
114
115 // Verify Kernel domain
116 assertEquals("Kernel", domains[0].getName());
117 IChannelInfo[] channels = domains[0].getChannels();
118 assertNotNull(channels);
119 assertEquals(1, channels.length);
120
121 // Verify Kernel's channel0
122 assertEquals("channel0", channels[0].getName());
123 assertEquals(4, channels[0].getNumberOfSubBuffers());
124 assertEquals("splice()", channels[0].getOutputType().getInName());
125 assertEquals(TraceChannelOutputType.SPLICE, channels[0].getOutputType());
126 assertEquals(false, channels[0].isOverwriteMode());
127 assertEquals(200, channels[0].getReadTimer());
128 assertEquals(TraceEnablement.ENABLED, channels[0].getState());
129 assertEquals(262144, channels[0].getSubBufferSize());
130 assertEquals(0, channels[0].getSwitchTimer());
131
132 // Verify event info
133 IEventInfo[] channel0Events = channels[0].getEvents();
134 assertNotNull(channel0Events);
135 assertEquals(1, channel0Events.length);
136 assertEquals("block_rq_remap", channel0Events[0].getName());
137 assertEquals(TraceLogLevel.TRACE_EMERG, channel0Events[0].getLogLevel());
138 assertEquals(TraceEventType.TRACEPOINT, channel0Events[0].getEventType());
139 assertEquals(TraceEnablement.ENABLED, channel0Events[0].getState());
140 assertEquals("foo > 10", channel0Events[0].getFilterExpression());
141
142 // Verify domain UST global
143 assertEquals("UST global", domains[1].getName());
144
145 IChannelInfo[] ustChannels = domains[1].getChannels();
146
147 // Verify UST global's channel0
148 assertEquals("channel0", ustChannels[0].getName());
149 assertEquals(4, ustChannels[0].getNumberOfSubBuffers());
150 assertEquals("mmap()", ustChannels[0].getOutputType().getInName());
151 assertEquals(TraceChannelOutputType.MMAP, ustChannels[0].getOutputType());
152 assertEquals(false, ustChannels[0].isOverwriteMode());
153 assertEquals(200, ustChannels[0].getReadTimer());
154 assertEquals(TraceEnablement.ENABLED, ustChannels[0].getState());
155 assertEquals(4096, ustChannels[0].getSubBufferSize());
156 assertEquals(0, ustChannels[0].getSwitchTimer());
157
158 // Verify event info
159 IEventInfo[] ustEvents = ustChannels[0].getEvents();
160 assertEquals(1, ustEvents.length);
161
162 assertEquals("ust_tests_hello:tptest_sighandler", ustEvents[0].getName());
163 assertEquals(TraceLogLevel.TRACE_DEBUG_LINE, ustEvents[0].getLogLevel());
164 assertEquals(TraceEventType.TRACEPOINT, ustEvents[0].getEventType());
165 assertEquals(TraceEnablement.DISABLED, ustEvents[0].getState());
166 assertEquals("foo > 10", ustEvents[0].getFilterExpression());
167 }
168
169 @Test
170 public void testListContext28() throws ExecutionException {
171 ((LTTngControlService)fService).setVersion("2.8.0");
172 fShell.setScenario(SCEN_LIST_CONTEXT_28);
173
174 List<String> availContexts = fService.getContextList(new NullProgressMonitor());
175 assertNotNull(availContexts);
176 assertEquals(12, availContexts.size());
177
178 Set<String> expectedContexts = new HashSet<>();
179 expectedContexts.add("pid");
180 expectedContexts.add("procname");
181 expectedContexts.add("prio");
182 expectedContexts.add("nice");
183 expectedContexts.add("vpid");
184 expectedContexts.add("tid");
185 expectedContexts.add("pthread_id");
186 expectedContexts.add("vtid");
187 expectedContexts.add("ppid");
188 expectedContexts.add("vppid");
189 expectedContexts.add("perf:cpu:cpu-cycles");
190 expectedContexts.add("perf:cpu:cycles");
191
192 assertTrue(expectedContexts.containsAll(availContexts));
193 }
194 }
This page took 0.042233 seconds and 5 git commands to generate.