ctf: Move plugins to their own sub-directory
[deliverable/tracecompass.git] / 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.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;
39
40 /**
41 * @author ejorajo
42 *
43 */
44 public class LTTngControlServiceMiTest extends LTTngControlServiceTest {
45
46 private static final String MI_TEST_STREAM = "LTTngServiceMiTest.cfg";
47
48 private static final String SCEN_SESSION_WITH_SYSCALLS = "GetSessionWithSyscalls";
49
50 @Override
51 protected ILttngControlService getControlService() {
52 try {
53 URL resource = LTTngControlServiceMI.class.getResource(LTTngControlServiceConstants.MI_XSD_FILENAME);
54 return new LTTngControlServiceMI(getShell(), resource);
55 } catch (ExecutionException e) {
56 return null;
57 }
58 }
59
60 @Override
61 public void testGetSessionNameGarbage() {
62 try {
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
68 // document.
69 }
70 }
71
72 @Override
73 public void testCreateLiveSession() throws ExecutionException {
74 fShell.setScenario(SCEN_CREATE_LIVE_SESSION);
75
76 ISessionInfo params = new SessionInfo("mysession");
77 params.setLive(true);
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());
90 }
91
92 @Override
93 protected String getTestStream() {
94 return MI_TEST_STREAM;
95 }
96
97 @Override
98 protected TraceLogLevel getAllEventTraceLogLevel() {
99 return TraceLogLevel.TRACE_DEBUG;
100 }
101
102 @Override
103 public void testGetKernelProviderNoUstVerbose() {
104 // Verbose mode in machine interface is deactivated. This test is
105 // ignored.
106 }
107
108 @Override
109 public void testCreateSession2_1() {
110 // 2.1 is not supported by mi. This test is ignored.
111 }
112
113 @Override
114 public void testGetKernelProviderNoUst3() {
115 // Verbose mode in machine interface is deactivated. This test is
116 // ignored.
117 }
118
119 @Override
120 public void testGetKernelProviderNoKernelVerbose() {
121 // Verbose mode in machine interface is deactivated. This test is
122 // ignored.
123 }
124
125 @Override
126 public void testCreateSessionVerbose2_1() {
127 // Verbose mode in machine interface is deactivated. This test is
128 // ignored.
129 }
130
131 @Override
132 public void testDestroySessionVerbose() {
133 // Verbose mode in machine interface is deactivated. This test is
134 // ignored.
135 }
136
137 @Override
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.
141 }
142
143 @Override
144 public void testAddContext() {
145 // TODO This does not use mi feature.And currently the context enabling
146 // is wrong for 2.6.
147 }
148
149 @Override
150 public void testAddContextFailure() {
151 // TODO This does not use mi feature.And currently the context enabling
152 // is wrong for 2.6.
153 }
154
155 @Override
156 public void testCreateSnapshotSession2_5() {
157 // not applicable for MI
158 }
159
160 /**
161 * Tests the listing of syscalls
162 */
163 @Test
164 public void testListSycallEvents() {
165 try {
166 fShell.setScenario(SCEN_SESSION_WITH_SYSCALLS);
167 ISessionInfo session = fService.getSession("mysession", new NullProgressMonitor());
168
169 // Verify Session
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());
174
175 IDomainInfo[] domains = session.getDomains();
176 assertNotNull(domains);
177 assertEquals(1, domains.length);
178
179 // Verify Kernel domain
180 assertEquals("Kernel", domains[0].getName());
181 IChannelInfo[] channels = domains[0].getChannels();
182 assertNotNull(channels);
183 assertEquals(1, channels.length);
184
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());
195
196 // Verify event info
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());
203
204 assertEquals("write", channel0Events[1].getName());
205 assertEquals(TraceEventType.SYSCALL, channel0Events[1].getEventType());
206 assertEquals(TraceEnablement.ENABLED, channel0Events[1].getState());
207 } catch (ExecutionException e) {
208 fail(e.toString());
209 }
210 }
211 }
This page took 0.035468 seconds and 5 git commands to generate.