1 /**********************************************************************
2 * Copyright (c) 2014 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
10 * Jonathan Rajotte - Support of machine interface
11 **********************************************************************/
13 package org
.eclipse
.tracecompass
.lttng2
.control
.ui
.tests
.service
;
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
;
21 import java
.util
.List
;
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
.TraceChannelOutputType
;
30 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceEnablement
;
31 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceEventType
;
32 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceLogLevel
;
33 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceSessionState
;
34 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.impl
.SessionInfo
;
35 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.service
.ILttngControlService
;
36 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.service
.LTTngControlServiceConstants
;
37 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.service
.LTTngControlServiceMI
;
38 import org
.junit
.Test
;
44 public class LTTngControlServiceMiTest
extends LTTngControlServiceTest
{
46 private static final String MI_TEST_STREAM
= "LTTngServiceMiTest.cfg";
48 private static final String SCEN_SESSION_WITH_SYSCALLS
= "GetSessionWithSyscalls";
51 protected ILttngControlService
getControlService() {
53 URL resource
= LTTngControlServiceMI
.class.getResource(LTTngControlServiceConstants
.MI_XSD_FILENAME
);
54 return new LTTngControlServiceMI(getShell(), resource
);
55 } catch (ExecutionException e
) {
61 public void testGetSessionNameGarbage() {
63 fShell
.setScenario(SCEN_GET_SESSION_GARBAGE_OUT
);
64 fService
.getSessionNames(new NullProgressMonitor());
65 } catch (ExecutionException e
) {
66 // Success. Parsing of garbage result in an ExecutionException
67 // generated by the XML document parser: Unable to parse the xml
73 public void testCreateLiveSession() throws ExecutionException
{
74 fShell
.setScenario(SCEN_CREATE_LIVE_SESSION
);
76 ISessionInfo params
= new SessionInfo("mysession");
78 params
.setStreamedTrace(true);
79 params
.setNetworkUrl("net://127.0.0.1");
80 ISessionInfo sessionInfo
= fService
.createSession(params
, new NullProgressMonitor());
81 assertNotNull(sessionInfo
);
82 assertEquals("mysession", sessionInfo
.getName());
83 assertEquals(TraceSessionState
.INACTIVE
, sessionInfo
.getSessionState());
84 assertTrue(sessionInfo
.isStreamedTrace());
85 assertTrue(sessionInfo
.isLive());
86 assertEquals("tcp4://127.0.0.1:5342/ [data: 5343]", sessionInfo
.getSessionPath());
87 List
<String
> names
= fService
.getSessionNames(new NullProgressMonitor());
88 assertEquals(names
.get(0), "mysession");
89 fService
.destroySession("mysession", new NullProgressMonitor());
93 protected String
getTestStream() {
94 return MI_TEST_STREAM
;
98 protected TraceLogLevel
getAllEventTraceLogLevel() {
99 return TraceLogLevel
.TRACE_DEBUG
;
103 public void testGetKernelProviderNoUstVerbose() {
104 // Verbose mode in machine interface is deactivated. This test is
109 public void testCreateSession2_1() {
110 // 2.1 is not supported by mi. This test is ignored.
114 public void testGetKernelProviderNoUst3() {
115 // Verbose mode in machine interface is deactivated. This test is
120 public void testGetKernelProviderNoKernelVerbose() {
121 // Verbose mode in machine interface is deactivated. This test is
126 public void testCreateSessionVerbose2_1() {
127 // Verbose mode in machine interface is deactivated. This test is
132 public void testDestroySessionVerbose() {
133 // Verbose mode in machine interface is deactivated. This test is
138 public void testCreateSessionWithPrompt() {
139 // TODO Investigate if this case can happen in production. If yes than
140 // we need to rethinks the MI fetching and parsing.
144 public void testAddContext() {
145 // TODO This does not use mi feature.And currently the context enabling
150 public void testAddContextFailure() {
151 // TODO This does not use mi feature.And currently the context enabling
156 public void testCreateSnapshotSession2_5() {
157 // not applicable for MI
161 * Tests the listing of syscalls
164 public void testListSycallEvents() {
166 fShell
.setScenario(SCEN_SESSION_WITH_SYSCALLS
);
167 ISessionInfo session
= fService
.getSession("mysession", new NullProgressMonitor());
170 assertNotNull(session
);
171 assertEquals("mysession", session
.getName());
172 assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session
.getSessionPath());
173 assertEquals(TraceSessionState
.INACTIVE
, session
.getSessionState());
175 IDomainInfo
[] domains
= session
.getDomains();
176 assertNotNull(domains
);
177 assertEquals(1, domains
.length
);
179 // Verify Kernel domain
180 assertEquals("Kernel", domains
[0].getName());
181 IChannelInfo
[] channels
= domains
[0].getChannels();
182 assertNotNull(channels
);
183 assertEquals(1, channels
.length
);
185 // Verify Kernel's channel0
186 assertEquals("channel0", channels
[0].getName());
187 assertEquals(4, channels
[0].getNumberOfSubBuffers());
188 assertEquals("splice()", channels
[0].getOutputType().getInName());
189 assertEquals(TraceChannelOutputType
.SPLICE
, channels
[0].getOutputType());
190 assertEquals(false, channels
[0].isOverwriteMode());
191 assertEquals(200, channels
[0].getReadTimer());
192 assertEquals(TraceEnablement
.ENABLED
, channels
[0].getState());
193 assertEquals(262144, channels
[0].getSubBufferSize());
194 assertEquals(0, channels
[0].getSwitchTimer());
197 IEventInfo
[] channel0Events
= channels
[0].getEvents();
198 assertNotNull(channel0Events
);
199 assertEquals(2, channel0Events
.length
);
200 assertEquals("read", channel0Events
[0].getName());
201 assertEquals(TraceEventType
.SYSCALL
, channel0Events
[0].getEventType());
202 assertEquals(TraceEnablement
.ENABLED
, channel0Events
[0].getState());
204 assertEquals("write", channel0Events
[1].getName());
205 assertEquals(TraceEventType
.SYSCALL
, channel0Events
[1].getEventType());
206 assertEquals(TraceEnablement
.ENABLED
, channel0Events
[1].getState());
207 } catch (ExecutionException e
) {