lttng: Fix filters not shown with 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
1 /**********************************************************************
2 * Copyright (c) 2014 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 * Contributors:
10 * Jonathan Rajotte - Support of machine interface
11 **********************************************************************/
12
13 package org.eclipse.tracecompass.lttng2.control.ui.tests.service;
14
15 import static org.junit.Assert.assertEquals;
16 import static org.junit.Assert.assertNotNull;
17 import static org.junit.Assert.assertTrue;
18 import static org.junit.Assert.fail;
19
20 import java.net.URL;
21 import java.util.List;
22
23 import org.eclipse.core.commands.ExecutionException;
24 import org.eclipse.core.runtime.NullProgressMonitor;
25 import org.eclipse.tracecompass.internal.lttng2.control.core.model.IChannelInfo;
26 import org.eclipse.tracecompass.internal.lttng2.control.core.model.IDomainInfo;
27 import org.eclipse.tracecompass.internal.lttng2.control.core.model.IEventInfo;
28 import org.eclipse.tracecompass.internal.lttng2.control.core.model.ISessionInfo;
29 import org.eclipse.tracecompass.internal.lttng2.control.core.model.LogLevelType;
30 import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceChannelOutputType;
31 import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceEnablement;
32 import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceEventType;
33 import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceLogLevel;
34 import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceSessionState;
35 import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.SessionInfo;
36 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.ILttngControlService;
37 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.LTTngControlServiceConstants;
38 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.LTTngControlServiceMI;
39 import org.junit.Ignore;
40 import org.junit.Test;
41
42 /**
43 * @author ejorajo
44 *
45 */
46 public class LTTngControlServiceMiTest extends LTTngControlServiceTest {
47
48 private static final String MI_TEST_STREAM = "LTTngServiceMiTest.cfg";
49
50 private static final String SCEN_SESSION_WITH_SYSCALLS = "GetSessionWithSyscalls";
51 private static final String SCEN_LIST_SESSION_2_7_COMPAT = "ListSession2.7Compat";
52 private static final String SCEN_GET_SESSION_FILTER_EXPRESSION = "GetSessionFilterExpression";
53
54 @Override
55 protected ILttngControlService getControlService() {
56 try {
57 URL resource = LTTngControlServiceMI.class.getResource(LTTngControlServiceConstants.MI_XSD_FILENAME);
58 return new LTTngControlServiceMI(getShell(), resource);
59 } catch (ExecutionException e) {
60 return null;
61 }
62 }
63
64 @Override
65 public void testGetSessionNameGarbage() {
66 try {
67 fShell.setScenario(SCEN_GET_SESSION_GARBAGE_OUT);
68 fService.getSessionNames(new NullProgressMonitor());
69 } catch (ExecutionException e) {
70 // Success. Parsing of garbage result in an ExecutionException
71 // generated by the XML document parser: Unable to parse the xml
72 // document.
73 }
74 }
75
76 @Override
77 @Ignore
78 public void testCreateLiveSession() throws ExecutionException {
79 fShell.setScenario(SCEN_CREATE_LIVE_SESSION);
80
81 ISessionInfo params = new SessionInfo("mysession");
82 params.setLive(true);
83 params.setStreamedTrace(true);
84 params.setNetworkUrl("net://127.0.0.1");
85 ISessionInfo sessionInfo = fService.createSession(params, new NullProgressMonitor());
86 assertNotNull(sessionInfo);
87 assertEquals("mysession", sessionInfo.getName());
88 assertEquals(TraceSessionState.INACTIVE, sessionInfo.getSessionState());
89 assertTrue(sessionInfo.isStreamedTrace());
90 assertTrue(sessionInfo.isLive());
91 assertEquals("tcp4://127.0.0.1:5342/ [data: 5343]", sessionInfo.getSessionPath());
92 List<String> names = fService.getSessionNames(new NullProgressMonitor());
93 assertEquals(names.get(0), "mysession");
94 fService.destroySession("mysession", new NullProgressMonitor());
95 }
96
97 @Override
98 protected String getTestStream() {
99 return MI_TEST_STREAM;
100 }
101
102 @Override
103 protected TraceLogLevel getAllEventTraceLogLevel() {
104 return TraceLogLevel.TRACE_DEBUG;
105 }
106
107 @Override
108 public void testGetKernelProviderNoUstVerbose() {
109 // Verbose mode in machine interface is deactivated. This test is
110 // ignored.
111 }
112
113 @Override
114 public void testCreateSession2_1() {
115 // 2.1 is not supported by mi. This test is ignored.
116 }
117
118 @Override
119 public void testGetKernelProviderNoUst3() {
120 // Verbose mode in machine interface is deactivated. This test is
121 // ignored.
122 }
123
124 @Override
125 public void testGetKernelProviderNoKernelVerbose() {
126 // Verbose mode in machine interface is deactivated. This test is
127 // ignored.
128 }
129
130 @Override
131 public void testCreateSessionVerbose2_1() {
132 // Verbose mode in machine interface is deactivated. This test is
133 // ignored.
134 }
135
136 @Override
137 public void testDestroySessionVerbose() {
138 // Verbose mode in machine interface is deactivated. This test is
139 // ignored.
140 }
141
142 @Override
143 public void testCreateSessionWithPrompt() {
144 // TODO Investigate if this case can happen in production. If yes than
145 // we need to rethinks the MI fetching and parsing.
146 }
147
148 @Override
149 public void testAddContext() {
150 // TODO This does not use mi feature.And currently the context enabling
151 // is wrong for 2.6.
152 }
153
154 @Override
155 public void testAddContextFailure() {
156 // TODO This does not use mi feature.And currently the context enabling
157 // is wrong for 2.6.
158 }
159
160 @Override
161 public void testCreateSnapshotSession2_5() {
162 // not applicable for MI
163 }
164
165 /**
166 * Tests the listing of syscalls
167 */
168 @Test
169 public void testListSycallEvents() {
170 try {
171 fShell.setScenario(SCEN_SESSION_WITH_SYSCALLS);
172 ISessionInfo session = fService.getSession("mysession", new NullProgressMonitor());
173
174 // Verify Session
175 assertNotNull(session);
176 assertEquals("mysession", session.getName());
177 assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session.getSessionPath());
178 assertEquals(TraceSessionState.INACTIVE, session.getSessionState());
179
180 IDomainInfo[] domains = session.getDomains();
181 assertNotNull(domains);
182 assertEquals(1, domains.length);
183
184 // Verify Kernel domain
185 assertEquals("Kernel", domains[0].getName());
186 IChannelInfo[] channels = domains[0].getChannels();
187 assertNotNull(channels);
188 assertEquals(1, channels.length);
189
190 // Verify Kernel's channel0
191 assertEquals("channel0", channels[0].getName());
192 assertEquals(4, channels[0].getNumberOfSubBuffers());
193 assertEquals("splice()", channels[0].getOutputType().getInName());
194 assertEquals(TraceChannelOutputType.SPLICE, channels[0].getOutputType());
195 assertEquals(false, channels[0].isOverwriteMode());
196 assertEquals(200, channels[0].getReadTimer());
197 assertEquals(TraceEnablement.ENABLED, channels[0].getState());
198 assertEquals(262144, channels[0].getSubBufferSize());
199 assertEquals(0, channels[0].getSwitchTimer());
200
201 // Verify event info
202 IEventInfo[] channel0Events = channels[0].getEvents();
203 assertNotNull(channel0Events);
204 assertEquals(2, channel0Events.length);
205 assertEquals("read", channel0Events[0].getName());
206 assertEquals(TraceEventType.SYSCALL, channel0Events[0].getEventType());
207 assertEquals(TraceEnablement.ENABLED, channel0Events[0].getState());
208
209 assertEquals("write", channel0Events[1].getName());
210 assertEquals(TraceEventType.SYSCALL, channel0Events[1].getEventType());
211 assertEquals(TraceEnablement.ENABLED, channel0Events[1].getState());
212 } catch (ExecutionException e) {
213 fail(e.toString());
214 }
215 }
216
217 /**
218 * Test List session for lttng 2.7.
219 *
220 * This is to make sure that it is possible to parse the output of a session
221 * create on a target with LTTng 2.7 installed.
222 *
223 *
224 */
225 @Test
226 public void testListSessionCompatibility_2_7() {
227
228 /*
229 Note the session was created with basic commands:
230 lttng create mysession
231 lttng enable-event -a -k -s mysession
232 lttng enable-channel channel0 -u -s mysession --buffers-pid
233 lttng enable-event -a -u -s mysession -c channel0 --tracepoint
234 lttng add-context -u -t vtid -t procname
235 */
236
237 try {
238 fShell.setScenario(SCEN_LIST_SESSION_2_7_COMPAT);
239 ISessionInfo session = fService.getSession("mysession", new NullProgressMonitor());
240
241 // Verify Session
242 assertNotNull(session);
243 assertEquals("mysession", session.getName());
244 assertEquals("/home/user/lttng-traces/mysession-20151020-085614", session.getSessionPath());
245 assertEquals(TraceSessionState.INACTIVE, session.getSessionState());
246
247 IDomainInfo[] domains = session.getDomains();
248 assertNotNull(domains);
249 assertEquals(2, domains.length);
250
251 // Verify Kernel domain
252 assertEquals("Kernel", domains[0].getName());
253 IChannelInfo[] channels = domains[0].getChannels();
254 assertNotNull(channels);
255 assertEquals(1, channels.length);
256
257 // Verify Kernel's channel0
258 assertEquals("channel0", channels[0].getName());
259 assertEquals(4, channels[0].getNumberOfSubBuffers());
260 assertEquals("splice()", channels[0].getOutputType().getInName());
261 assertEquals(TraceChannelOutputType.SPLICE, channels[0].getOutputType());
262 assertEquals(false, channels[0].isOverwriteMode());
263 assertEquals(200000, channels[0].getReadTimer());
264 assertEquals(TraceEnablement.ENABLED, channels[0].getState());
265 assertEquals(262144, channels[0].getSubBufferSize());
266 assertEquals(0, channels[0].getSwitchTimer());
267
268 // Verify event info
269 IEventInfo[] channel0Events = channels[0].getEvents();
270 assertNotNull(channel0Events);
271 assertEquals(2, channel0Events.length);
272 assertEquals("*", channel0Events[0].getName());
273 assertEquals(TraceEventType.SYSCALL, channel0Events[0].getEventType());
274 assertEquals(TraceEnablement.ENABLED, channel0Events[0].getState());
275
276 assertEquals("*", channel0Events[1].getName());
277 assertEquals(TraceLogLevel.TRACE_EMERG, channel0Events[1].getLogLevel());
278 assertEquals(LogLevelType.LOGLEVEL_ALL, channel0Events[1].getLogLevelType());
279 assertEquals(TraceEventType.TRACEPOINT, channel0Events[1].getEventType());
280 assertEquals(TraceEnablement.ENABLED, channel0Events[1].getState());
281
282 // Verify domain UST global
283 assertEquals("UST global", domains[1].getName());
284
285 IChannelInfo[] ustChannels = domains[1].getChannels();
286
287 // Verify UST global's channel0
288 assertEquals("channel0", ustChannels[0].getName());
289 assertEquals(4, ustChannels[0].getNumberOfSubBuffers());
290 assertEquals("mmap()", ustChannels[0].getOutputType().getInName());
291 assertEquals(TraceChannelOutputType.MMAP, ustChannels[0].getOutputType());
292 assertEquals(false, ustChannels[0].isOverwriteMode());
293 assertEquals(0, ustChannels[0].getReadTimer());
294 assertEquals(TraceEnablement.ENABLED, ustChannels[0].getState());
295 assertEquals(4096, ustChannels[0].getSubBufferSize());
296 assertEquals(0, ustChannels[0].getSwitchTimer());
297
298 // Verify event info
299 IEventInfo[] ustEvents = ustChannels[0].getEvents();
300 assertEquals(1, ustEvents.length);
301
302 assertEquals("*", ustEvents[0].getName());
303 assertEquals(TraceEventType.TRACEPOINT, ustEvents[0].getEventType());
304 assertEquals(TraceEnablement.ENABLED, ustEvents[0].getState());
305
306 } catch (ExecutionException e) {
307 fail(e.toString());
308 }
309 }
310
311 @Test
312 public void testGetSessionWithFilterExpression() throws ExecutionException {
313 // FIXME: Disable scheme validation for now until MI 3.0 is integrated
314 LTTngControlServiceMI service = new LTTngControlServiceMI(getShell(), null);
315
316 fShell.setScenario(SCEN_GET_SESSION_FILTER_EXPRESSION);
317 ISessionInfo session = service.getSession("mysession", new NullProgressMonitor());
318
319 // Verify Session
320 assertNotNull(session);
321 assertEquals("mysession", session.getName());
322 assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session.getSessionPath());
323 assertEquals(TraceSessionState.ACTIVE, session.getSessionState());
324
325 IDomainInfo[] domains = session.getDomains();
326 assertNotNull(domains);
327 assertEquals(2, domains.length);
328
329 // Verify Kernel domain
330 assertEquals("Kernel", domains[0].getName());
331 IChannelInfo[] channels = domains[0].getChannels();
332 assertNotNull(channels);
333 assertEquals(1, channels.length);
334
335 // Verify Kernel's channel0
336 assertEquals("channel0", channels[0].getName());
337 assertEquals(4, channels[0].getNumberOfSubBuffers());
338 assertEquals("splice()", channels[0].getOutputType().getInName());
339 assertEquals(TraceChannelOutputType.SPLICE, channels[0].getOutputType());
340 assertEquals(false, channels[0].isOverwriteMode());
341 assertEquals(200, channels[0].getReadTimer());
342 assertEquals(TraceEnablement.ENABLED, channels[0].getState());
343 assertEquals(262144, channels[0].getSubBufferSize());
344 assertEquals(0, channels[0].getSwitchTimer());
345
346 // Verify event info
347 IEventInfo[] channel0Events = channels[0].getEvents();
348 assertNotNull(channel0Events);
349 assertEquals(1, channel0Events.length);
350 assertEquals("block_rq_remap", channel0Events[0].getName());
351 assertEquals(TraceLogLevel.TRACE_EMERG, channel0Events[0].getLogLevel());
352 assertEquals(TraceEventType.TRACEPOINT, channel0Events[0].getEventType());
353 assertEquals(TraceEnablement.ENABLED, channel0Events[0].getState());
354 assertEquals("foo > 10", channel0Events[0].getFilterExpression());
355
356 // Verify domain UST global
357 assertEquals("UST global", domains[1].getName());
358
359 IChannelInfo[] ustChannels = domains[1].getChannels();
360
361 // Verify UST global's channel0
362 assertEquals("channel0", ustChannels[0].getName());
363 assertEquals(4, ustChannels[0].getNumberOfSubBuffers());
364 assertEquals("mmap()", ustChannels[0].getOutputType().getInName());
365 assertEquals(TraceChannelOutputType.MMAP, ustChannels[0].getOutputType());
366 assertEquals(false, ustChannels[0].isOverwriteMode());
367 assertEquals(200, ustChannels[0].getReadTimer());
368 assertEquals(TraceEnablement.ENABLED, ustChannels[0].getState());
369 assertEquals(4096, ustChannels[0].getSubBufferSize());
370 assertEquals(0, ustChannels[0].getSwitchTimer());
371
372 // Verify event info
373 IEventInfo[] ustEvents = ustChannels[0].getEvents();
374 assertEquals(1, ustEvents.length);
375
376 assertEquals("ust_tests_hello:tptest_sighandler", ustEvents[0].getName());
377 assertEquals(TraceLogLevel.TRACE_DEBUG_LINE, ustEvents[0].getLogLevel());
378 assertEquals(TraceEventType.TRACEPOINT, ustEvents[0].getEventType());
379 assertEquals(TraceEnablement.DISABLED, ustEvents[0].getState());
380 assertEquals("foo > 10", ustEvents[0].getFilterExpression());
381 }
382 }
This page took 0.109352 seconds and 6 git commands to generate.