1 /******************************************************************************
2 * Copyright (c) 2016 Ericsson
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 *******************************************************************************/
10 package org
.eclipse
.tracecompass
.lttng2
.control
.ui
.tests
.service
;
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
;
17 import java
.util
.HashSet
;
18 import java
.util
.List
;
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
;
40 * Tests for the MI service when using MI version 3.0
42 @SuppressWarnings("javadoc")
43 public class LTTngControlServiceMi3Test
extends LTTngControlServiceMiTest
{
45 private static final String MI_TEST_STREAM
= "LTTngServiceMi3Test.cfg";
47 private static final String SCEN_GET_SESSION_FILTER_EXPRESSION
= "GetSessionFilterExpression";
48 private static final String SCEN_LIST_CONTEXT_28
= "ListContext28";
51 protected ILttngControlService
getControlService() {
53 return new LTTngControlServiceMI(getShell(), new LttngVersion("2.8.0"));
54 } catch (ExecutionException e
) {
60 protected String
getTestStream() {
61 return MI_TEST_STREAM
;
65 public void testVersion() {
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
);
77 public void testVersionWithPrompt() {
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
);
89 public void testVersionCompiled() {
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
);
101 public void testGetSessionWithFilterExpression() throws ExecutionException
{
102 fShell
.setScenario(SCEN_GET_SESSION_FILTER_EXPRESSION
);
103 ISessionInfo session
= fService
.getSession("mysession", new NullProgressMonitor());
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());
111 IDomainInfo
[] domains
= session
.getDomains();
112 assertNotNull(domains
);
113 assertEquals(2, domains
.length
);
115 // Verify Kernel domain
116 assertEquals("Kernel", domains
[0].getName());
117 IChannelInfo
[] channels
= domains
[0].getChannels();
118 assertNotNull(channels
);
119 assertEquals(1, channels
.length
);
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());
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());
142 // Verify domain UST global
143 assertEquals("UST global", domains
[1].getName());
145 IChannelInfo
[] ustChannels
= domains
[1].getChannels();
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());
159 IEventInfo
[] ustEvents
= ustChannels
[0].getEvents();
160 assertEquals(1, ustEvents
.length
);
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());
170 public void testListContext28() throws ExecutionException
{
171 ((LTTngControlService
)fService
).setVersion("2.8.0");
172 fShell
.setScenario(SCEN_LIST_CONTEXT_28
);
174 List
<String
> availContexts
= fService
.getContextList(new NullProgressMonitor());
175 assertNotNull(availContexts
);
176 assertEquals(12, availContexts
.size());
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");
192 assertTrue(expectedContexts
.containsAll(availContexts
));