Commit | Line | Data |
---|---|---|
eb1bab5b | 1 | /********************************************************************** |
60ae41e1 | 2 | * Copyright (c) 2012, 2014 Ericsson |
cfdb727a | 3 | * |
eb1bab5b BH |
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 | |
cfdb727a AM |
8 | * |
9 | * Contributors: | |
eb1bab5b | 10 | * Bernd Hufmann - Initial API and implementation |
2ba3d0a1 | 11 | * Alexandre Montplaisir - Port to JUnit4 |
81d5dc3a | 12 | * Marc-Andre Laperle - Support for creating a live session |
eb1bab5b | 13 | **********************************************************************/ |
2ba3d0a1 | 14 | |
8e8c0226 | 15 | package org.eclipse.linuxtools.lttng2.control.ui.tests.service; |
eb1bab5b | 16 | |
d128c979 BH |
17 | import static org.junit.Assert.assertEquals; |
18 | import static org.junit.Assert.assertNotNull; | |
19 | import static org.junit.Assert.assertTrue; | |
20 | import static org.junit.Assert.fail; | |
2ba3d0a1 | 21 | |
d132bcc7 BH |
22 | import java.io.File; |
23 | import java.net.URL; | |
24 | import java.util.ArrayList; | |
4ea599a5 | 25 | import java.util.HashSet; |
eb1bab5b | 26 | import java.util.List; |
4ea599a5 | 27 | import java.util.Set; |
eb1bab5b | 28 | |
eb1bab5b | 29 | import org.eclipse.core.commands.ExecutionException; |
d132bcc7 | 30 | import org.eclipse.core.runtime.FileLocator; |
bbb3538a | 31 | import org.eclipse.core.runtime.NullProgressMonitor; |
d132bcc7 | 32 | import org.eclipse.core.runtime.Path; |
8e8c0226 AM |
33 | import org.eclipse.linuxtools.internal.lttng2.control.stubs.service.CommandShellFactory; |
34 | import org.eclipse.linuxtools.internal.lttng2.control.stubs.shells.LTTngToolsFileShell; | |
35 | import org.eclipse.linuxtools.internal.lttng2.control.core.model.IBaseEventInfo; | |
36 | import org.eclipse.linuxtools.internal.lttng2.control.core.model.IChannelInfo; | |
37 | import org.eclipse.linuxtools.internal.lttng2.control.core.model.IDomainInfo; | |
38 | import org.eclipse.linuxtools.internal.lttng2.control.core.model.IEventInfo; | |
39 | import org.eclipse.linuxtools.internal.lttng2.control.core.model.IFieldInfo; | |
40 | import org.eclipse.linuxtools.internal.lttng2.control.core.model.ISessionInfo; | |
41 | import org.eclipse.linuxtools.internal.lttng2.control.core.model.ISnapshotInfo; | |
42 | import org.eclipse.linuxtools.internal.lttng2.control.core.model.IUstProviderInfo; | |
43 | import org.eclipse.linuxtools.internal.lttng2.control.core.model.LogLevelType; | |
0ad9fc89 | 44 | import org.eclipse.linuxtools.internal.lttng2.control.core.model.TraceChannelOutputType; |
8e8c0226 AM |
45 | import org.eclipse.linuxtools.internal.lttng2.control.core.model.TraceEnablement; |
46 | import org.eclipse.linuxtools.internal.lttng2.control.core.model.TraceEventType; | |
47 | import org.eclipse.linuxtools.internal.lttng2.control.core.model.TraceLogLevel; | |
48 | import org.eclipse.linuxtools.internal.lttng2.control.core.model.TraceSessionState; | |
49 | import org.eclipse.linuxtools.internal.lttng2.control.core.model.impl.BufferType; | |
50 | import org.eclipse.linuxtools.internal.lttng2.control.core.model.impl.ChannelInfo; | |
51 | import org.eclipse.linuxtools.internal.lttng2.control.core.model.impl.SessionInfo; | |
52 | import org.eclipse.linuxtools.internal.lttng2.control.ui.Activator; | |
53 | import org.eclipse.linuxtools.internal.lttng2.control.ui.views.logging.ControlCommandLogger; | |
54 | import org.eclipse.linuxtools.internal.lttng2.control.ui.views.preferences.ControlPreferences; | |
55 | import org.eclipse.linuxtools.internal.lttng2.control.ui.views.service.ILttngControlService; | |
56 | import org.eclipse.linuxtools.internal.lttng2.control.ui.views.service.LTTngControlService; | |
57 | import org.eclipse.linuxtools.internal.lttng2.control.ui.views.service.LTTngControlServiceFactory; | |
d128c979 | 58 | import org.junit.After; |
2ba3d0a1 AM |
59 | import org.junit.Before; |
60 | import org.junit.Test; | |
9269df72 | 61 | import org.osgi.framework.FrameworkUtil; |
2ba3d0a1 | 62 | |
eb1bab5b | 63 | /** |
2ba3d0a1 AM |
64 | * The class <code>LTTngControlServiceTest</code> contains test for the class |
65 | * <code>{@link LTTngControlService}</code>. | |
eb1bab5b | 66 | */ |
4e0b52e0 | 67 | @SuppressWarnings("javadoc") |
2ba3d0a1 | 68 | public class LTTngControlServiceTest { |
d132bcc7 BH |
69 | |
70 | private static final String DIRECTORY = "testfiles"; | |
71 | private static final String TEST_STREAM = "LTTngServiceTest.cfg"; | |
cfdb727a | 72 | |
d132bcc7 | 73 | private static final String SCEN_LTTNG_NOT_INSTALLED = "LttngNotInstalled"; |
276c17e7 | 74 | private static final String SCEN_LTTNG_VERSION = "LttngVersion"; |
d6fc6e1b | 75 | private static final String SCEN_LTTNG_VERSION_WITH_PROMPT = "LttngVersionWithPrompt"; |
276c17e7 BH |
76 | private static final String SCEN_LTTNG_UNSUPPORTED_VERSION = "LttngUnsupportedVersion"; |
77 | private static final String SCEN_LTTNG_NO_VERSION = "LttngNoVersion"; | |
d132bcc7 BH |
78 | private static final String SCEN_NO_SESSION_AVAILABLE = "NoSessionAvailable"; |
79 | private static final String SCEN_GET_SESSION_NAMES1 = "GetSessionNames1"; | |
80 | private static final String SCEN_GET_SESSION_NAME_NOT_EXIST = "GetSessionNameNotExist"; | |
d128c979 | 81 | private static final String SCEN_GET_SESSION_NAME_NOT_EXIST_VERBOSE = "GetSessionNameNotExistVerbose"; |
d132bcc7 BH |
82 | private static final String SCEN_GET_SESSION_GARBAGE_OUT = "GetSessionGarbageOut"; |
83 | private static final String SCEN_GET_SESSION1 = "GetSession1"; | |
84 | private static final String SCEN_GET_KERNEL_PROVIDER1 = "GetKernelProvider1"; | |
a07c7629 BH |
85 | private static final String SCEN_LIST_WITH_NO_KERNEL1 = "ListWithNoKernel1"; |
86 | private static final String SCEN_LIST_WITH_NO_KERNEL2 = "ListWithNoKernel2"; | |
d128c979 | 87 | private static final String SCEN_LIST_WITH_NO_KERNEL_VERBOSE = "ListWithNoKernelVerbose"; |
d132bcc7 BH |
88 | private static final String SCEN_GET_UST_PROVIDER1 = "GetUstProvider1"; |
89 | private static final String SCEN_GET_UST_PROVIDER2 = "GetUstProvider2"; | |
d4514365 | 90 | private static final String SCEN_GET_UST_PROVIDER3 = "GetUstProvider3"; |
f3e2f354 BH |
91 | private static final String SCEN_LIST_WITH_NO_UST1 = "ListWithNoUst1"; |
92 | private static final String SCEN_LIST_WITH_NO_UST2 = "ListWithNoUst2"; | |
93 | private static final String SCEN_LIST_WITH_NO_UST3 = "ListWithNoUst3"; | |
94 | private static final String SCEN_LIST_WITH_NO_UST_VERBOSE = "ListWithNoUstVerbose"; | |
d132bcc7 | 95 | private static final String SCEN_CREATE_SESSION1 = "CreateSession1"; |
d6fc6e1b | 96 | private static final String SCEN_CREATE_SESSION_WITH_PROMPT = "CreateSessionWithPrompt"; |
d132bcc7 BH |
97 | private static final String SCEN_CREATE_SESSION_VARIANTS = "CreateSessionVariants"; |
98 | private static final String SCEN_DESTROY_SESSION1 = "DestroySession1"; | |
d128c979 | 99 | private static final String SCEN_DESTROY_SESSION_VERBOSE = "DestroySessionVerbose"; |
d132bcc7 BH |
100 | private static final String SCEN_CHANNEL_HANDLING = "ChannelHandling"; |
101 | private static final String SCEN_EVENT_HANDLING = "EventHandling"; | |
4ea599a5 BH |
102 | private static final String SCEN_CONTEXT_HANDLING = "ContextHandling"; |
103 | private static final String SCEN_CONTEXT_ERROR_HANDLING = "ContextErrorHandling"; | |
104 | private static final String SCEN_CALIBRATE_HANDLING = "CalibrateHandling"; | |
f3b33d40 | 105 | private static final String SCEN_CREATE_SESSION_2_1 = "CreateSessionLttng2.1"; |
d128c979 | 106 | private static final String SCEN_CREATE_SESSION_VERBOSE_2_1 = "CreateSessionLttngVerbose2.1"; |
589d0d33 BH |
107 | private static final String SCEN_CREATE_SNAPSHOT_SESSION = "CreateSessionSnapshot"; |
108 | private static final String SCEN_CREATE_STREAMED_SNAPSHOT_SESSION = "CreateSessionStreamedSnapshot"; | |
109 | private static final String SCEN_CREATE_SNAPSHOT_SESSION_ERRORS = "CreateSessionSnapshotErrors"; | |
81d5dc3a MAL |
110 | private static final String SCEN_CREATE_LIVE_SESSION = "CreateSessionLive"; |
111 | private static final String SCEN_CREATE_LIVE_SESSION_ERRORS = "CreateSessionLiveErrors"; | |
d132bcc7 | 112 | |
eb1bab5b BH |
113 | // ------------------------------------------------------------------------ |
114 | // Test data | |
115 | // ------------------------------------------------------------------------ | |
2ba3d0a1 | 116 | |
d132bcc7 BH |
117 | private CommandShellFactory fShellFactory; |
118 | private String fTestfile; | |
119 | private LTTngToolsFileShell fShell; | |
120 | private ILttngControlService fService; | |
121 | ||
eb1bab5b BH |
122 | // ------------------------------------------------------------------------ |
123 | // Housekeeping | |
124 | // ------------------------------------------------------------------------ | |
2ba3d0a1 | 125 | |
eb1bab5b BH |
126 | /** |
127 | * Perform pre-test initialization. | |
128 | * | |
2ba3d0a1 AM |
129 | * @throws Exception |
130 | * if the initialization fails for some reason | |
eb1bab5b | 131 | */ |
2ba3d0a1 | 132 | @Before |
eb1bab5b | 133 | public void setUp() throws Exception { |
eb1bab5b | 134 | fShellFactory = CommandShellFactory.getInstance(); |
d132bcc7 | 135 | |
9269df72 | 136 | URL location = FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path(DIRECTORY + File.separator + TEST_STREAM), null); |
d132bcc7 BH |
137 | File testfile = new File(FileLocator.toFileURL(location).toURI()); |
138 | fTestfile = testfile.getAbsolutePath(); | |
cfdb727a | 139 | |
d132bcc7 BH |
140 | fShell = fShellFactory.getFileShell(); |
141 | fShell.loadScenarioFile(fTestfile); | |
142 | fService = new LTTngControlService(fShell); | |
d128c979 BH |
143 | |
144 | ControlPreferences.getInstance().init(Activator.getDefault().getPreferenceStore()); | |
145 | } | |
146 | ||
147 | @After | |
148 | public void tearDown() { | |
149 | disableVerbose(); | |
150 | ControlPreferences.getInstance().dispose(); | |
eb1bab5b BH |
151 | } |
152 | ||
eb1bab5b BH |
153 | // ------------------------------------------------------------------------ |
154 | // Test Cases | |
155 | // ------------------------------------------------------------------------ | |
cfdb727a | 156 | |
2ba3d0a1 | 157 | @Test |
276c17e7 BH |
158 | public void testVersion() { |
159 | try { | |
160 | fShell.setScenario(SCEN_LTTNG_VERSION); | |
cfdb727a | 161 | ILttngControlService service = LTTngControlServiceFactory.getInstance().getLttngControlService(fShell); |
276c17e7 | 162 | assertNotNull(service); |
0df4af5f | 163 | assertEquals("2.1.0", service.getVersionString()); |
276c17e7 BH |
164 | } catch (ExecutionException e) { |
165 | fail("Exeption thrown " + e); | |
166 | } | |
167 | } | |
cfdb727a | 168 | |
2ba3d0a1 | 169 | @Test |
d6fc6e1b BH |
170 | public void testVersionWithPrompt() { |
171 | try { | |
172 | fShell.setScenario(SCEN_LTTNG_VERSION_WITH_PROMPT); | |
173 | ILttngControlService service = LTTngControlServiceFactory.getInstance().getLttngControlService(fShell); | |
174 | assertNotNull(service); | |
0df4af5f | 175 | assertEquals("2.0.0", service.getVersionString()); |
d6fc6e1b BH |
176 | } catch (ExecutionException e) { |
177 | fail("Exeption thrown " + e); | |
178 | } | |
179 | } | |
a07c7629 | 180 | |
2ba3d0a1 | 181 | @Test |
276c17e7 BH |
182 | public void testUnsupportedVersion() { |
183 | try { | |
184 | fShell.setScenario(SCEN_LTTNG_UNSUPPORTED_VERSION); | |
cfdb727a | 185 | LTTngControlServiceFactory.getInstance().getLttngControlService(fShell); |
276c17e7 BH |
186 | fail("No exeption thrown"); |
187 | } catch (ExecutionException e) { | |
188 | // success | |
189 | } | |
190 | } | |
191 | ||
2ba3d0a1 | 192 | @Test |
276c17e7 BH |
193 | public void testNoVersion() { |
194 | try { | |
195 | fShell.setScenario(SCEN_LTTNG_NO_VERSION); | |
cfdb727a | 196 | LTTngControlServiceFactory.getInstance().getLttngControlService(fShell); |
276c17e7 BH |
197 | fail("No exeption thrown"); |
198 | } catch (ExecutionException e) { | |
199 | // success | |
200 | } | |
201 | } | |
202 | ||
2ba3d0a1 | 203 | @Test |
276c17e7 | 204 | public void testLttngNotInstalled() { |
eb1bab5b | 205 | try { |
d132bcc7 BH |
206 | fShell.setScenario(SCEN_LTTNG_NOT_INSTALLED); |
207 | fService.getSessionNames(new NullProgressMonitor()); | |
eb1bab5b | 208 | fail("No exeption thrown"); |
eb1bab5b BH |
209 | } catch (ExecutionException e) { |
210 | // success | |
211 | } | |
212 | } | |
cfdb727a | 213 | |
2ba3d0a1 | 214 | @Test |
eb1bab5b BH |
215 | public void testGetSessionNames1() { |
216 | try { | |
d132bcc7 BH |
217 | fShell.setScenario(SCEN_NO_SESSION_AVAILABLE); |
218 | String[] result = fService.getSessionNames(new NullProgressMonitor()); | |
eb1bab5b BH |
219 | |
220 | assertNotNull(result); | |
221 | assertEquals(0, result.length); | |
cfdb727a | 222 | |
eb1bab5b BH |
223 | } catch (ExecutionException e) { |
224 | fail(e.toString()); | |
225 | } | |
226 | } | |
d132bcc7 | 227 | |
2ba3d0a1 | 228 | @Test |
eb1bab5b BH |
229 | public void testGetSessionNames2() { |
230 | try { | |
d132bcc7 BH |
231 | fShell.setScenario(SCEN_GET_SESSION_NAMES1); |
232 | String[] result = fService.getSessionNames(new NullProgressMonitor()); | |
eb1bab5b BH |
233 | |
234 | assertNotNull(result); | |
235 | assertEquals(2, result.length); | |
236 | assertEquals("mysession1", result[0]); | |
237 | assertEquals("mysession", result[1]); | |
cfdb727a | 238 | |
eb1bab5b BH |
239 | } catch (ExecutionException e) { |
240 | fail(e.toString()); | |
241 | } | |
242 | } | |
d132bcc7 | 243 | |
2ba3d0a1 | 244 | @Test |
eb1bab5b BH |
245 | public void testGetSessionNotExist() { |
246 | try { | |
d132bcc7 BH |
247 | fShell.setScenario(SCEN_GET_SESSION_NAME_NOT_EXIST); |
248 | fService.getSessionNames(new NullProgressMonitor()); | |
eb1bab5b | 249 | fail("No exeption thrown"); |
cfdb727a | 250 | |
eb1bab5b BH |
251 | } catch (ExecutionException e) { |
252 | // success | |
253 | } | |
254 | } | |
cfdb727a | 255 | |
d128c979 BH |
256 | @Test |
257 | public void testGetSessionNotExistVerbose() { | |
258 | try { | |
259 | enableVerbose(); | |
260 | fShell.setScenario(SCEN_GET_SESSION_NAME_NOT_EXIST_VERBOSE); | |
261 | fService.getSessionNames(new NullProgressMonitor()); | |
262 | fail("No exeption thrown"); | |
263 | ||
264 | } catch (ExecutionException e) { | |
265 | // success | |
266 | } finally { | |
267 | disableVerbose(); | |
268 | } | |
269 | } | |
270 | ||
2ba3d0a1 | 271 | @Test |
eb1bab5b BH |
272 | public void testGetSessionNameGarbage() { |
273 | try { | |
d132bcc7 BH |
274 | fShell.setScenario(SCEN_GET_SESSION_GARBAGE_OUT); |
275 | String[] result = fService.getSessionNames(new NullProgressMonitor()); | |
eb1bab5b BH |
276 | |
277 | assertNotNull(result); | |
278 | assertEquals(0, result.length); | |
cfdb727a | 279 | |
eb1bab5b BH |
280 | } catch (ExecutionException e) { |
281 | fail(e.toString()); | |
282 | } | |
283 | } | |
cfdb727a | 284 | |
2ba3d0a1 | 285 | @Test |
eb1bab5b BH |
286 | public void testGetSession1() { |
287 | try { | |
d132bcc7 BH |
288 | fShell.setScenario(SCEN_GET_SESSION1); |
289 | ISessionInfo session = fService.getSession("mysession", new NullProgressMonitor()); | |
eb1bab5b BH |
290 | |
291 | // Verify Session | |
292 | assertNotNull(session); | |
293 | assertEquals("mysession", session.getName()); | |
294 | assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session.getSessionPath()); | |
295 | assertEquals(TraceSessionState.ACTIVE, session.getSessionState()); | |
cfdb727a | 296 | |
eb1bab5b BH |
297 | IDomainInfo[] domains = session.getDomains(); |
298 | assertNotNull(domains); | |
299 | assertEquals(2, domains.length); | |
cfdb727a | 300 | |
eb1bab5b BH |
301 | // Verify Kernel domain |
302 | assertEquals("Kernel", domains[0].getName()); | |
303 | IChannelInfo[] channels = domains[0].getChannels(); | |
304 | assertNotNull(channels); | |
305 | assertEquals(2, channels.length); | |
306 | ||
cfdb727a | 307 | // Verify Kernel's channel0 |
eb1bab5b BH |
308 | assertEquals("channel0", channels[0].getName()); |
309 | assertEquals(4, channels[0].getNumberOfSubBuffers()); | |
0ad9fc89 JRJ |
310 | assertEquals("splice()", channels[0].getOutputType().getInName()); |
311 | assertEquals(TraceChannelOutputType.SPLICE, channels[0].getOutputType()); | |
eb1bab5b BH |
312 | assertEquals(false, channels[0].isOverwriteMode()); |
313 | assertEquals(200, channels[0].getReadTimer()); | |
314 | assertEquals(TraceEnablement.ENABLED, channels[0].getState()); | |
315 | assertEquals(262144, channels[0].getSubBufferSize()); | |
316 | assertEquals(0, channels[0].getSwitchTimer()); | |
cfdb727a | 317 | |
eb1bab5b BH |
318 | // Verify event info |
319 | IEventInfo[] channel0Events = channels[0].getEvents(); | |
320 | assertNotNull(channel0Events); | |
321 | assertEquals(2, channel0Events.length); | |
322 | assertEquals("block_rq_remap", channel0Events[0].getName()); | |
323 | assertEquals(TraceLogLevel.TRACE_EMERG, channel0Events[0].getLogLevel()); | |
324 | assertEquals(TraceEventType.TRACEPOINT, channel0Events[0].getEventType()); | |
325 | assertEquals(TraceEnablement.ENABLED, channel0Events[0].getState()); | |
cfdb727a | 326 | |
eb1bab5b BH |
327 | assertEquals("block_bio_remap", channel0Events[1].getName()); |
328 | assertEquals(TraceLogLevel.TRACE_EMERG, channel0Events[1].getLogLevel()); | |
329 | assertEquals(TraceEventType.TRACEPOINT, channel0Events[1].getEventType()); | |
330 | assertEquals(TraceEnablement.DISABLED, channel0Events[1].getState()); | |
cfdb727a AM |
331 | |
332 | // Verify Kernel's channel1 | |
eb1bab5b BH |
333 | assertEquals("channel1", channels[1].getName()); |
334 | assertEquals(4, channels[1].getNumberOfSubBuffers()); | |
0ad9fc89 JRJ |
335 | assertEquals("splice()", channels[1].getOutputType().getInName()); |
336 | assertEquals(TraceChannelOutputType.SPLICE, channels[1].getOutputType()); | |
eb1bab5b BH |
337 | assertEquals(true, channels[1].isOverwriteMode()); |
338 | assertEquals(400, channels[1].getReadTimer()); | |
339 | assertEquals(TraceEnablement.DISABLED, channels[1].getState()); | |
340 | assertEquals(524288, channels[1].getSubBufferSize()); | |
341 | assertEquals(100, channels[1].getSwitchTimer()); | |
cfdb727a | 342 | |
eb1bab5b BH |
343 | // Verify event info |
344 | IEventInfo[] channel1Events = channels[1].getEvents(); | |
345 | assertEquals(0, channel1Events.length); | |
cfdb727a | 346 | |
eb1bab5b BH |
347 | // Verify domain UST global |
348 | assertEquals("UST global", domains[1].getName()); | |
cfdb727a | 349 | |
eb1bab5b | 350 | IChannelInfo[] ustChannels = domains[1].getChannels(); |
cfdb727a AM |
351 | |
352 | // Verify UST global's mychannel1 | |
eb1bab5b BH |
353 | assertEquals("mychannel1", ustChannels[0].getName()); |
354 | assertEquals(8, ustChannels[0].getNumberOfSubBuffers()); | |
0ad9fc89 JRJ |
355 | assertEquals("mmap()", ustChannels[0].getOutputType().getInName()); |
356 | assertEquals(TraceChannelOutputType.MMAP, ustChannels[0].getOutputType()); | |
eb1bab5b BH |
357 | assertEquals(true, ustChannels[0].isOverwriteMode()); |
358 | assertEquals(100, ustChannels[0].getReadTimer()); | |
359 | assertEquals(TraceEnablement.DISABLED, ustChannels[0].getState()); | |
360 | assertEquals(8192, ustChannels[0].getSubBufferSize()); | |
361 | assertEquals(200, ustChannels[0].getSwitchTimer()); | |
cfdb727a | 362 | |
eb1bab5b BH |
363 | // Verify event info |
364 | IEventInfo[] ustEvents = ustChannels[0].getEvents(); | |
365 | assertEquals(0, ustEvents.length); | |
366 | ||
cfdb727a | 367 | // Verify UST global's channel0 |
eb1bab5b BH |
368 | assertEquals("channel0", ustChannels[1].getName()); |
369 | assertEquals(4, ustChannels[1].getNumberOfSubBuffers()); | |
0ad9fc89 JRJ |
370 | assertEquals("mmap()", ustChannels[1].getOutputType().getInName()); |
371 | assertEquals(TraceChannelOutputType.MMAP, ustChannels[1].getOutputType()); | |
eb1bab5b BH |
372 | assertEquals(false, ustChannels[1].isOverwriteMode()); |
373 | assertEquals(200, ustChannels[1].getReadTimer()); | |
374 | assertEquals(TraceEnablement.ENABLED, ustChannels[1].getState()); | |
375 | assertEquals(4096, ustChannels[1].getSubBufferSize()); | |
376 | assertEquals(0, ustChannels[1].getSwitchTimer()); | |
cfdb727a | 377 | |
eb1bab5b BH |
378 | // Verify event info |
379 | ustEvents = ustChannels[1].getEvents(); | |
380 | assertEquals(2, ustEvents.length); | |
cfdb727a | 381 | |
eb1bab5b | 382 | assertEquals("ust_tests_hello:tptest_sighandler", ustEvents[0].getName()); |
4775bcbf | 383 | assertEquals(TraceLogLevel.TRACE_DEBUG_LINE, ustEvents[0].getLogLevel()); |
eb1bab5b BH |
384 | assertEquals(TraceEventType.TRACEPOINT, ustEvents[0].getEventType()); |
385 | assertEquals(TraceEnablement.DISABLED, ustEvents[0].getState()); | |
cfdb727a | 386 | |
eb1bab5b | 387 | assertEquals("*", ustEvents[1].getName()); |
4775bcbf | 388 | assertEquals(TraceLogLevel.LEVEL_UNKNOWN, ustEvents[1].getLogLevel()); |
eb1bab5b BH |
389 | assertEquals(TraceEventType.TRACEPOINT, ustEvents[1].getEventType()); |
390 | assertEquals(TraceEnablement.ENABLED, ustEvents[1].getState()); | |
cfdb727a | 391 | |
eb1bab5b | 392 | // next session (no detailed information available) |
d132bcc7 | 393 | session = fService.getSession("mysession1", new NullProgressMonitor()); |
eb1bab5b BH |
394 | assertNotNull(session); |
395 | assertEquals("mysession1", session.getName()); | |
396 | assertEquals("/home/user/lttng-traces/mysession1-20120203-133225", session.getSessionPath()); | |
397 | assertEquals(TraceSessionState.INACTIVE, session.getSessionState()); | |
cfdb727a | 398 | |
eb1bab5b BH |
399 | domains = session.getDomains(); |
400 | assertNotNull(domains); | |
401 | assertEquals(0, domains.length); | |
402 | } catch (ExecutionException e) { | |
403 | fail(e.toString()); | |
404 | } | |
405 | } | |
406 | ||
407 | public void testGetKernelProvider() { | |
408 | try { | |
d132bcc7 BH |
409 | fShell.setScenario(SCEN_GET_KERNEL_PROVIDER1); |
410 | List<IBaseEventInfo> events = fService.getKernelProvider(new NullProgressMonitor()); | |
eb1bab5b BH |
411 | |
412 | // Verify event info | |
413 | assertNotNull(events); | |
414 | assertEquals(3, events.size()); | |
cfdb727a AM |
415 | |
416 | IBaseEventInfo baseEventInfo = events.get(0); | |
eb1bab5b BH |
417 | assertNotNull(baseEventInfo); |
418 | assertEquals("sched_kthread_stop", baseEventInfo.getName()); | |
419 | assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel()); | |
420 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); | |
cfdb727a AM |
421 | |
422 | baseEventInfo = events.get(1); | |
eb1bab5b BH |
423 | assertEquals("sched_kthread_stop_ret", baseEventInfo.getName()); |
424 | assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel()); | |
425 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); | |
cfdb727a AM |
426 | |
427 | baseEventInfo = events.get(2); | |
eb1bab5b BH |
428 | assertEquals("sched_wakeup_new", baseEventInfo.getName()); |
429 | assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel()); | |
430 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); | |
431 | ||
432 | } catch (ExecutionException e) { | |
433 | fail(e.toString()); | |
434 | } | |
435 | } | |
436 | ||
2ba3d0a1 | 437 | @Test |
a07c7629 BH |
438 | public void testGetKernelProviderNoKernel1() { |
439 | try { | |
440 | fShell.setScenario(SCEN_LIST_WITH_NO_KERNEL1); | |
441 | List<IBaseEventInfo> events = fService.getKernelProvider(new NullProgressMonitor()); | |
442 | ||
443 | // Verify event info | |
444 | assertNotNull(events); | |
445 | assertEquals(0, events.size()); | |
446 | ||
447 | } catch (ExecutionException e) { | |
448 | fail(e.toString()); | |
449 | } | |
450 | } | |
451 | ||
2ba3d0a1 | 452 | @Test |
a07c7629 BH |
453 | public void testGetKernelProviderNoKernel2() { |
454 | try { | |
455 | fShell.setScenario(SCEN_LIST_WITH_NO_KERNEL2); | |
456 | List<IBaseEventInfo> events = fService.getKernelProvider(new NullProgressMonitor()); | |
457 | ||
458 | // Verify event info | |
459 | assertNotNull(events); | |
460 | assertEquals(0, events.size()); | |
461 | ||
462 | } catch (ExecutionException e) { | |
463 | fail(e.toString()); | |
464 | } | |
465 | } | |
466 | ||
d128c979 BH |
467 | @Test |
468 | public void testGetKernelProviderNoKernelVerbose() { | |
469 | try { | |
470 | enableVerbose(); | |
471 | fShell.setScenario(SCEN_LIST_WITH_NO_KERNEL_VERBOSE); | |
472 | List<IBaseEventInfo> events = fService.getKernelProvider(new NullProgressMonitor()); | |
473 | ||
474 | // Verify event info | |
475 | assertNotNull(events); | |
476 | assertEquals(0, events.size()); | |
477 | ||
478 | } catch (ExecutionException e) { | |
479 | fail(e.toString()); | |
480 | } finally { | |
481 | disableVerbose(); | |
482 | } | |
483 | } | |
484 | ||
2ba3d0a1 | 485 | @Test |
eb1bab5b BH |
486 | public void testGetUstProvider() { |
487 | try { | |
d132bcc7 BH |
488 | fShell.setScenario(SCEN_GET_UST_PROVIDER1); |
489 | List<IUstProviderInfo> providers = fService.getUstProvider(); | |
eb1bab5b BH |
490 | |
491 | // Check all providers | |
492 | assertNotNull(providers); | |
493 | assertEquals(2, providers.size()); | |
cfdb727a | 494 | |
eb1bab5b BH |
495 | //Verify first provider |
496 | assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers.get(0).getName()); | |
497 | assertEquals(9379, providers.get(0).getPid()); | |
cfdb727a | 498 | |
eb1bab5b BH |
499 | // Verify event info |
500 | IBaseEventInfo[] events = providers.get(0).getEvents(); | |
501 | assertNotNull(events); | |
502 | assertEquals(2, events.length); | |
503 | ||
cfdb727a | 504 | IBaseEventInfo baseEventInfo = events[0]; |
eb1bab5b BH |
505 | assertNotNull(baseEventInfo); |
506 | assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo.getName()); | |
4775bcbf | 507 | assertEquals(TraceLogLevel.TRACE_DEBUG_MODULE, baseEventInfo.getLogLevel()); |
eb1bab5b | 508 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); |
cfdb727a AM |
509 | |
510 | baseEventInfo = events[1]; | |
eb1bab5b BH |
511 | assertEquals("ust_tests_hello:tptest", baseEventInfo.getName()); |
512 | assertEquals(TraceLogLevel.TRACE_INFO, baseEventInfo.getLogLevel()); | |
513 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); | |
514 | ||
515 | //Verify second provider | |
516 | assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers.get(1).getName()); | |
517 | assertEquals(4852, providers.get(1).getPid()); | |
cfdb727a | 518 | |
eb1bab5b BH |
519 | // Verify event info |
520 | events = providers.get(1).getEvents(); | |
521 | assertNotNull(events); | |
522 | assertEquals(2, events.length); | |
523 | ||
cfdb727a | 524 | baseEventInfo = events[0]; |
eb1bab5b BH |
525 | assertNotNull(baseEventInfo); |
526 | assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo.getName()); | |
527 | assertEquals(TraceLogLevel.TRACE_WARNING, baseEventInfo.getLogLevel()); | |
528 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); | |
cfdb727a AM |
529 | |
530 | baseEventInfo = events[1]; | |
eb1bab5b | 531 | assertEquals("ust_tests_hello:tptest", baseEventInfo.getName()); |
4775bcbf | 532 | assertEquals(TraceLogLevel.TRACE_DEBUG_FUNCTION, baseEventInfo.getLogLevel()); |
eb1bab5b BH |
533 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); |
534 | ||
535 | } catch (ExecutionException e) { | |
536 | fail(e.toString()); | |
537 | } | |
538 | } | |
d132bcc7 | 539 | |
2ba3d0a1 | 540 | @Test |
eb1bab5b BH |
541 | public void testUstProvider2() { |
542 | try { | |
d132bcc7 BH |
543 | fShell.setScenario(SCEN_GET_UST_PROVIDER2); |
544 | List<IUstProviderInfo> providers = fService.getUstProvider(); | |
eb1bab5b BH |
545 | |
546 | assertNotNull(providers); | |
547 | assertEquals(0, providers.size()); | |
cfdb727a | 548 | |
eb1bab5b BH |
549 | } catch (ExecutionException e) { |
550 | fail(e.toString()); | |
551 | } | |
552 | } | |
d132bcc7 | 553 | |
2ba3d0a1 | 554 | @Test |
d4514365 BH |
555 | public void testGetUstProvider3() { |
556 | try { | |
557 | fShell.setScenario(SCEN_GET_UST_PROVIDER3); | |
558 | // Set version | |
559 | ((LTTngControlService)fService).setVersion("2.1.0"); | |
560 | List<IUstProviderInfo> providers = fService.getUstProvider(); | |
561 | ||
562 | // Check all providers | |
563 | assertNotNull(providers); | |
564 | assertEquals(2, providers.size()); | |
565 | ||
566 | //Verify first provider | |
567 | assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers.get(0).getName()); | |
568 | assertEquals(9379, providers.get(0).getPid()); | |
569 | ||
570 | // Verify event info | |
571 | IBaseEventInfo[] events = providers.get(0).getEvents(); | |
572 | assertNotNull(events); | |
573 | assertEquals(2, events.length); | |
574 | ||
575 | IBaseEventInfo baseEventInfo = events[0]; | |
576 | assertNotNull(baseEventInfo); | |
577 | IFieldInfo[] fields = baseEventInfo.getFields(); | |
578 | assertNotNull(fields); | |
579 | assertEquals(0, fields.length); | |
580 | ||
581 | baseEventInfo = events[1]; | |
582 | fields = baseEventInfo.getFields(); | |
583 | assertNotNull(fields); | |
584 | assertEquals(3, fields.length); | |
585 | assertEquals("doublefield", fields[0].getName()); | |
586 | assertEquals("float", fields[0].getFieldType()); | |
587 | ||
588 | assertEquals("floatfield", fields[1].getName()); | |
589 | assertEquals("float", fields[1].getFieldType()); | |
590 | ||
591 | assertEquals("stringfield", fields[2].getName()); | |
592 | assertEquals("string", fields[2].getFieldType()); | |
593 | ||
594 | //Verify second provider | |
595 | assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers.get(1).getName()); | |
596 | assertEquals(4852, providers.get(1).getPid()); | |
597 | ||
598 | // Verify event info | |
599 | events = providers.get(1).getEvents(); | |
600 | assertNotNull(events); | |
601 | assertEquals(2, events.length); | |
602 | ||
603 | baseEventInfo = events[0]; | |
604 | assertNotNull(baseEventInfo); | |
605 | fields = baseEventInfo.getFields(); | |
606 | assertNotNull(fields); | |
607 | assertEquals(0, fields.length); | |
608 | ||
609 | baseEventInfo = events[1]; | |
610 | fields = baseEventInfo.getFields(); | |
611 | assertNotNull(fields); | |
612 | assertEquals(3, fields.length); | |
613 | ||
614 | assertEquals("doublefield", fields[0].getName()); | |
615 | assertEquals("float", fields[0].getFieldType()); | |
616 | ||
617 | assertEquals("floatfield", fields[1].getName()); | |
618 | assertEquals("float", fields[1].getFieldType()); | |
619 | ||
620 | assertEquals("stringfield", fields[2].getName()); | |
621 | assertEquals("string", fields[2].getFieldType()); | |
622 | ||
623 | // Reset version | |
624 | ((LTTngControlService)fService).setVersion("2.0.0"); | |
625 | ||
626 | } catch (ExecutionException e) { | |
627 | fail(e.toString()); | |
628 | } | |
629 | } | |
630 | ||
f3e2f354 BH |
631 | |
632 | @Test | |
633 | public void testGetKernelProviderNoUst1() { | |
634 | try { | |
635 | fShell.setScenario(SCEN_LIST_WITH_NO_UST1); | |
636 | List<IUstProviderInfo> providerList = fService.getUstProvider(new NullProgressMonitor()); | |
637 | ||
638 | // Verify Provider info | |
639 | assertNotNull(providerList); | |
640 | assertEquals(0, providerList.size()); | |
641 | ||
642 | } catch (ExecutionException e) { | |
643 | fail(e.toString()); | |
644 | } | |
645 | } | |
646 | ||
647 | ||
648 | @Test | |
649 | public void testGetKernelProviderNoUst2() { | |
650 | try { | |
651 | // Set version | |
652 | ((LTTngControlService)fService).setVersion("2.1.0"); | |
653 | ||
654 | fShell.setScenario(SCEN_LIST_WITH_NO_UST2); | |
655 | List<IUstProviderInfo> providerList = fService.getUstProvider(new NullProgressMonitor()); | |
656 | ||
657 | // Verify Provider info | |
658 | assertNotNull(providerList); | |
659 | assertEquals(0, providerList.size()); | |
660 | ||
661 | // Reset version | |
662 | ((LTTngControlService)fService).setVersion("2.0.0"); | |
663 | ||
664 | } catch (ExecutionException e) { | |
665 | fail(e.toString()); | |
666 | } | |
667 | } | |
668 | ||
669 | @Test | |
670 | public void testGetKernelProviderNoUst3() { | |
671 | try { | |
672 | ||
673 | // Set version | |
674 | ((LTTngControlService)fService).setVersion("2.1.0"); | |
675 | ||
676 | fShell.setScenario(SCEN_LIST_WITH_NO_UST3); | |
677 | List<IUstProviderInfo> providerList = fService.getUstProvider(new NullProgressMonitor()); | |
678 | ||
679 | // Verify provider info | |
680 | assertNotNull(providerList); | |
681 | assertEquals(0, providerList.size()); | |
682 | ||
683 | // Reset version | |
684 | ((LTTngControlService)fService).setVersion("2.0.0"); | |
685 | ||
686 | } catch (ExecutionException e) { | |
687 | fail(e.toString()); | |
688 | } | |
689 | } | |
690 | ||
691 | @Test | |
692 | public void testGetKernelProviderNoUstVerbose() { | |
693 | try { | |
694 | enableVerbose(); | |
695 | ||
696 | // Set version | |
697 | ((LTTngControlService)fService).setVersion("2.1.0"); | |
698 | ||
699 | fShell.setScenario(SCEN_LIST_WITH_NO_UST_VERBOSE); | |
700 | List<IUstProviderInfo> providerList = fService.getUstProvider(new NullProgressMonitor()); | |
701 | ||
702 | // Verify provider info | |
703 | assertNotNull(providerList); | |
704 | assertEquals(0, providerList.size()); | |
705 | ||
706 | // Reset version | |
707 | ((LTTngControlService)fService).setVersion("2.0.0"); | |
708 | ||
709 | } catch (ExecutionException e) { | |
710 | fail(e.toString()); | |
711 | } finally { | |
712 | disableVerbose(); | |
713 | } | |
714 | } | |
715 | ||
716 | ||
717 | ||
2ba3d0a1 | 718 | @Test |
bbb3538a BH |
719 | public void testCreateSession() { |
720 | try { | |
d132bcc7 BH |
721 | fShell.setScenario(SCEN_CREATE_SESSION1); |
722 | ||
f7d4d450 | 723 | ISessionInfo info = fService.createSession(new SessionInfo("mysession2"), new NullProgressMonitor()); |
bbb3538a BH |
724 | assertNotNull(info); |
725 | assertEquals("mysession2", info.getName()); | |
726 | assertNotNull(info.getSessionPath()); | |
727 | assertTrue(info.getSessionPath().contains("mysession2")); | |
728 | assertEquals(TraceSessionState.INACTIVE, info.getSessionState()); | |
729 | } catch (ExecutionException e) { | |
730 | fail(e.toString()); | |
731 | } | |
732 | } | |
d132bcc7 | 733 | |
2ba3d0a1 | 734 | @Test |
d6fc6e1b BH |
735 | public void testCreateSessionWithPrompt() { |
736 | try { | |
a07c7629 | 737 | // First line has the shell prompt before the command output |
d6fc6e1b BH |
738 | // This can happen in a real application if the command line is not echoed by the shell. |
739 | fShell.setScenario(SCEN_CREATE_SESSION_WITH_PROMPT); | |
740 | ||
741 | // First line has no shell prompt before the output | |
f7d4d450 | 742 | ISessionInfo info = fService.createSession(new SessionInfo("mysession2"), new NullProgressMonitor()); |
d6fc6e1b BH |
743 | assertNotNull(info); |
744 | assertEquals("mysession2", info.getName()); | |
745 | assertNotNull(info.getSessionPath()); | |
746 | assertTrue(info.getSessionPath().contains("mysession2")); | |
747 | assertEquals(TraceSessionState.INACTIVE, info.getSessionState()); | |
748 | } catch (ExecutionException e) { | |
749 | fail(e.toString()); | |
750 | } | |
751 | } | |
752 | ||
2ba3d0a1 | 753 | @Test |
d132bcc7 BH |
754 | public void testCreateSessionVariants() { |
755 | ||
756 | fShell.setScenario(SCEN_CREATE_SESSION_VARIANTS); | |
757 | ||
bbb3538a | 758 | try { |
f7d4d450 | 759 | fService.createSession(new SessionInfo("alreadyExist"), new NullProgressMonitor()); |
bbb3538a BH |
760 | fail("No exeption thrown"); |
761 | } catch (ExecutionException e) { | |
762 | // success | |
763 | } | |
cfdb727a | 764 | |
bbb3538a | 765 | try { |
f7d4d450 | 766 | fService.createSession(new SessionInfo("wrongName"), new NullProgressMonitor()); |
bbb3538a BH |
767 | fail("No exeption thrown"); |
768 | } catch (ExecutionException e) { | |
769 | // success | |
cfdb727a | 770 | } |
bbb3538a BH |
771 | |
772 | try { | |
f7d4d450 MAL |
773 | ISessionInfo sessionInfo = new SessionInfo("withPath"); |
774 | sessionInfo.setSessionPath("/home/user/hallo"); | |
775 | fService.createSession(sessionInfo, new NullProgressMonitor()); | |
bbb3538a BH |
776 | fail("No exeption thrown"); |
777 | } catch (ExecutionException e) { | |
778 | // success | |
cfdb727a | 779 | } |
bbb3538a BH |
780 | |
781 | try { | |
f7d4d450 | 782 | ISessionInfo info = fService.createSession(new SessionInfo("session with spaces"), new NullProgressMonitor()); |
bbb3538a BH |
783 | assertNotNull(info); |
784 | assertEquals("session with spaces", info.getName()); | |
785 | assertNotNull(info.getSessionPath()); | |
786 | assertTrue(info.getSessionPath().contains("session with spaces")); | |
787 | assertEquals(TraceSessionState.INACTIVE, info.getSessionState()); | |
cfdb727a | 788 | |
bbb3538a BH |
789 | } catch (ExecutionException e) { |
790 | fail(e.toString()); | |
cfdb727a | 791 | } |
bbb3538a BH |
792 | |
793 | try { | |
f7d4d450 MAL |
794 | ISessionInfo sessionInfo = new SessionInfo("pathWithSpaces"); |
795 | sessionInfo.setSessionPath("/home/user/hallo user/here"); | |
796 | ISessionInfo info = fService.createSession(sessionInfo, new NullProgressMonitor()); | |
bbb3538a BH |
797 | assertNotNull(info); |
798 | assertEquals("pathWithSpaces", info.getName()); | |
799 | assertNotNull(info.getSessionPath()); | |
800 | assertTrue(info.getSessionPath().contains("/home/user/hallo user/here")); | |
801 | assertEquals(TraceSessionState.INACTIVE, info.getSessionState()); | |
cfdb727a | 802 | |
bbb3538a BH |
803 | } catch (ExecutionException e) { |
804 | fail(e.toString()); | |
cfdb727a | 805 | } |
bbb3538a BH |
806 | } |
807 | ||
2ba3d0a1 | 808 | @Test |
9d8a90ad | 809 | public void testDestroySession() { |
bbb3538a | 810 | try { |
d132bcc7 BH |
811 | fShell.setScenario(SCEN_DESTROY_SESSION1); |
812 | fService.destroySession("mysession2", new NullProgressMonitor()); | |
bbb3538a BH |
813 | } catch (ExecutionException e) { |
814 | fail(e.toString()); | |
cfdb727a | 815 | } |
bbb3538a | 816 | } |
d132bcc7 | 817 | |
d128c979 BH |
818 | @Test |
819 | public void testDestroySessionVerbose() { | |
820 | try { | |
821 | enableVerbose(); | |
822 | fShell.setScenario(SCEN_DESTROY_SESSION_VERBOSE); | |
823 | fService.destroySession("mysession2", new NullProgressMonitor()); | |
824 | } catch (ExecutionException e) { | |
825 | fail(e.toString()); | |
826 | } finally { | |
827 | disableVerbose(); | |
828 | } | |
829 | } | |
830 | ||
2ba3d0a1 | 831 | @Test |
d132bcc7 BH |
832 | public void testCreateChannel() { |
833 | try { | |
83051fc3 | 834 | ((LTTngControlService)fService).setVersion("2.2.0"); |
d132bcc7 | 835 | String sessionName = "mysession2"; |
e0838ca1 | 836 | List<String> list = new ArrayList<>(); |
d132bcc7 BH |
837 | String kernelChannel0 = "mychannel0"; |
838 | String kernelChannel1 = "mychannel1"; | |
839 | list.add(kernelChannel0); | |
840 | list.add(kernelChannel1); | |
cfdb727a | 841 | |
d132bcc7 | 842 | fShell.setScenario(SCEN_CHANNEL_HANDLING); |
cfdb727a | 843 | |
d132bcc7 BH |
844 | // Create/enable/configure 2 kernel channels |
845 | ChannelInfo chanInfo = new ChannelInfo(""); | |
846 | chanInfo.setOverwriteMode(true); | |
847 | chanInfo.setSubBufferSize(16384); | |
848 | chanInfo.setReadTimer(100); | |
849 | chanInfo.setSwitchTimer(200); | |
850 | chanInfo.setNumberOfSubBuffers(2); | |
e799e5f3 SD |
851 | chanInfo.setMaxNumberTraceFiles(10); |
852 | chanInfo.setMaxSizeTraceFiles(0); | |
d132bcc7 | 853 | fService.enableChannels(sessionName, list, true, chanInfo, new NullProgressMonitor()); |
cfdb727a | 854 | |
d132bcc7 BH |
855 | // Create/enable/configure 1 UST channel |
856 | list.clear(); | |
857 | list.add("ustChannel"); | |
cfdb727a | 858 | |
d132bcc7 BH |
859 | chanInfo = new ChannelInfo(""); |
860 | chanInfo.setOverwriteMode(true); | |
861 | chanInfo.setSubBufferSize(32768); | |
862 | chanInfo.setReadTimer(200); | |
863 | chanInfo.setSwitchTimer(100); | |
864 | chanInfo.setNumberOfSubBuffers(1); | |
e799e5f3 SD |
865 | chanInfo.setMaxNumberTraceFiles(20); |
866 | chanInfo.setMaxSizeTraceFiles(0); | |
867 | fService.enableChannels(sessionName, list, false, chanInfo, new NullProgressMonitor()); | |
83051fc3 | 868 | ((LTTngControlService)fService).setVersion("2.0.0"); |
e799e5f3 SD |
869 | |
870 | } catch (ExecutionException e) { | |
871 | fail(e.toString()); | |
872 | } | |
873 | } | |
874 | ||
875 | @Test | |
876 | public void testCreateChannelUIDBuffer() { | |
877 | try { | |
83051fc3 | 878 | ((LTTngControlService)fService).setVersion("2.2.0"); |
e799e5f3 | 879 | String sessionName = "mysession2"; |
e0838ca1 | 880 | List<String> list = new ArrayList<>(); |
e799e5f3 SD |
881 | String USTChannel = "ustChannel"; |
882 | list.add(USTChannel); | |
883 | fShell.setScenario(SCEN_CHANNEL_HANDLING); | |
884 | ||
885 | ChannelInfo chanInfo = new ChannelInfo(""); | |
886 | chanInfo.setOverwriteMode(true); | |
887 | chanInfo.setSubBufferSize(32768); | |
888 | chanInfo.setReadTimer(200); | |
889 | chanInfo.setSwitchTimer(100); | |
890 | chanInfo.setNumberOfSubBuffers(1); | |
891 | chanInfo.setMaxNumberTraceFiles(20); | |
892 | chanInfo.setMaxSizeTraceFiles(0); | |
83051fc3 | 893 | chanInfo.setBufferType(BufferType.BUFFER_PER_UID); |
d132bcc7 | 894 | fService.enableChannels(sessionName, list, false, chanInfo, new NullProgressMonitor()); |
83051fc3 BH |
895 | ((LTTngControlService)fService).setVersion("2.0.0"); |
896 | ||
897 | } catch (ExecutionException e) { | |
898 | fail(e.toString()); | |
899 | } | |
900 | } | |
901 | ||
902 | @Test | |
903 | public void testCreateChannelPIDBuffer() { | |
904 | try { | |
905 | ((LTTngControlService)fService).setVersion("2.2.0"); | |
906 | String sessionName = "mysession2"; | |
e0838ca1 | 907 | List<String> list = new ArrayList<>(); |
83051fc3 BH |
908 | String USTChannel = "ustChannel"; |
909 | list.add(USTChannel); | |
910 | fShell.setScenario(SCEN_CHANNEL_HANDLING); | |
911 | ||
912 | ||
913 | ChannelInfo chanInfo = new ChannelInfo(""); | |
914 | chanInfo.setOverwriteMode(true); | |
915 | chanInfo.setSubBufferSize(-1); | |
916 | chanInfo.setReadTimer(-1); | |
917 | chanInfo.setSwitchTimer(-1); | |
918 | chanInfo.setNumberOfSubBuffers(-1); | |
919 | chanInfo.setMaxNumberTraceFiles(-1); | |
920 | chanInfo.setMaxSizeTraceFiles(-1); | |
921 | chanInfo.setBufferType(BufferType.BUFFER_PER_PID); | |
922 | ||
923 | fService.enableChannels(sessionName, list, false, chanInfo, new NullProgressMonitor()); | |
924 | ((LTTngControlService)fService).setVersion("2.0.0"); | |
d132bcc7 BH |
925 | |
926 | } catch (ExecutionException e) { | |
927 | fail(e.toString()); | |
928 | } | |
929 | } | |
930 | ||
2ba3d0a1 | 931 | @Test |
d132bcc7 BH |
932 | public void testDisableChannel() { |
933 | try { | |
934 | ||
935 | String sessionName = "mysession2"; | |
e0838ca1 | 936 | List<String> list = new ArrayList<>(); |
d132bcc7 BH |
937 | String kernelChannel0 = "mychannel0"; |
938 | String kernelChannel1 = "mychannel1"; | |
939 | list.add(kernelChannel0); | |
940 | list.add(kernelChannel1); | |
cfdb727a | 941 | |
d132bcc7 BH |
942 | fShell.setScenario(SCEN_CHANNEL_HANDLING); |
943 | fService.disableChannels(sessionName, list, true, new NullProgressMonitor()); | |
cfdb727a | 944 | |
d132bcc7 BH |
945 | list.clear(); |
946 | list.add("ustChannel"); | |
947 | fService.disableChannels(sessionName, list, false, new NullProgressMonitor()); | |
948 | ||
949 | } catch (ExecutionException e) { | |
950 | fail(e.toString()); | |
951 | } | |
952 | } | |
cfdb727a | 953 | |
2ba3d0a1 | 954 | @Test |
d132bcc7 BH |
955 | public void testEnableChannel() { |
956 | try { | |
957 | ||
958 | String sessionName = "mysession2"; | |
e0838ca1 | 959 | List<String> list = new ArrayList<>(); |
d132bcc7 BH |
960 | String kernelChannel0 = "mychannel0"; |
961 | String kernelChannel1 = "mychannel1"; | |
962 | list.add(kernelChannel0); | |
963 | list.add(kernelChannel1); | |
cfdb727a | 964 | |
d132bcc7 BH |
965 | fShell.setScenario(SCEN_CHANNEL_HANDLING); |
966 | fService.enableChannels(sessionName, list, true, null, new NullProgressMonitor()); | |
cfdb727a | 967 | |
d132bcc7 BH |
968 | // Create/enable/configure 1 UST channel |
969 | list.clear(); | |
970 | list.add("ustChannel"); | |
cfdb727a | 971 | |
d132bcc7 BH |
972 | fService.enableChannels(sessionName, list, false, null, new NullProgressMonitor()); |
973 | ||
974 | } catch (ExecutionException e) { | |
975 | fail(e.toString()); | |
976 | } | |
977 | } | |
cfdb727a | 978 | |
2ba3d0a1 | 979 | @Test |
d132bcc7 BH |
980 | public void testEnableEvents() { |
981 | try { | |
982 | // 1) session name, channel = null, 3 event names, kernel | |
983 | String sessionName = "mysession2"; | |
e0838ca1 | 984 | List<String> list = new ArrayList<>(); |
d132bcc7 BH |
985 | String eventName0 = "block_rq_remap"; |
986 | String eventName1 = "block_bio_remap"; | |
987 | String eventName2 = "softirq_entry"; | |
988 | list.add(eventName0); | |
989 | list.add(eventName1); | |
990 | list.add(eventName2); | |
991 | fShell.setScenario(SCEN_EVENT_HANDLING); | |
d4514365 | 992 | fService.enableEvents(sessionName, null, list, true, null, new NullProgressMonitor()); |
cfdb727a | 993 | |
d132bcc7 BH |
994 | // 2) session name, channel=mychannel, event name= null, kernel |
995 | String channelName = "mychannel"; | |
d4514365 | 996 | fService.enableEvents(sessionName, channelName, null, true, null, new NullProgressMonitor()); |
bbb3538a | 997 | |
d4514365 | 998 | // 3) session name, channel=mychannel, 1 event name, ust, no filter |
d132bcc7 BH |
999 | String ustEventName = "ust_tests_hello:tptest_sighandler"; |
1000 | list.clear(); | |
1001 | list.add(ustEventName); | |
d4514365 | 1002 | fService.enableEvents(sessionName, channelName, list, false, null, new NullProgressMonitor()); |
cfdb727a | 1003 | |
d4514365 BH |
1004 | // 4) session name, channel = mychannel, no event name, ust, with filter |
1005 | fService.enableEvents(sessionName, channelName, list, false, "intfield==10", new NullProgressMonitor()); | |
1006 | ||
1007 | // 5) session name, channel = mychannel, no event name, ust, no filter | |
d132bcc7 | 1008 | list.clear(); |
d4514365 BH |
1009 | fService.enableEvents(sessionName, channelName, list, false, null, new NullProgressMonitor()); |
1010 | ||
1011 | // TODO add test with filters | |
cfdb727a | 1012 | |
d132bcc7 BH |
1013 | } catch (ExecutionException e) { |
1014 | fail(e.toString()); | |
1015 | } | |
1016 | } | |
cfdb727a | 1017 | |
2ba3d0a1 | 1018 | @Test |
d132bcc7 BH |
1019 | public void testEnableSyscalls() { |
1020 | try { | |
1021 | // 1) session name, channel = null, 3 event names, kernel | |
1022 | String sessionName = "mysession2"; | |
1023 | String channelName = "mychannel"; | |
cfdb727a | 1024 | |
d132bcc7 BH |
1025 | fShell.setScenario(SCEN_EVENT_HANDLING); |
1026 | ||
cfdb727a | 1027 | // 1) session name, channel = null |
d132bcc7 BH |
1028 | fService.enableSyscalls(sessionName, null, new NullProgressMonitor()); |
1029 | ||
1030 | // 2) session name, channel = mychannel | |
1031 | fService.enableSyscalls(sessionName, channelName, new NullProgressMonitor()); | |
cfdb727a | 1032 | |
d132bcc7 BH |
1033 | } catch (ExecutionException e) { |
1034 | fail(e.toString()); | |
1035 | } | |
1036 | } | |
1037 | ||
2ba3d0a1 | 1038 | @Test |
d132bcc7 BH |
1039 | public void testDynamicProbe() { |
1040 | try { | |
1041 | // 1) session name, channel = null, 3 event names, kernel | |
1042 | String sessionName = "mysession2"; | |
1043 | String channelName = "mychannel"; | |
1044 | String eventName0 = "myevent0"; | |
1045 | String eventName1 = "myevent1"; | |
1046 | String functionProbe = "0xc0101340"; | |
1047 | String dynProbe = "init_post"; | |
cfdb727a | 1048 | |
d132bcc7 BH |
1049 | fShell.setScenario(SCEN_EVENT_HANDLING); |
1050 | ||
cfdb727a | 1051 | // 1) session name, channel = null, event name, function probe, probe |
d132bcc7 BH |
1052 | fService.enableProbe(sessionName, null, eventName0, true, functionProbe, new NullProgressMonitor()); |
1053 | ||
1054 | // 2) session name, channel = mychannel | |
1055 | fService.enableProbe(sessionName, channelName, eventName1, false, dynProbe, new NullProgressMonitor()); | |
cfdb727a | 1056 | |
d132bcc7 BH |
1057 | } catch (ExecutionException e) { |
1058 | fail(e.toString()); | |
1059 | } | |
1060 | } | |
1061 | ||
2ba3d0a1 | 1062 | @Test |
d132bcc7 BH |
1063 | public void testEnableLogLevel() { |
1064 | try { | |
1065 | // 1) session name, channel = null, 3 event names, kernel | |
1066 | String sessionName = "mysession2"; | |
1067 | String channelName = "mychannel"; | |
1068 | String eventName4 = "myevent4"; | |
1069 | String eventName5 = "myevent5"; | |
cfdb727a | 1070 | |
d132bcc7 | 1071 | fShell.setScenario(SCEN_EVENT_HANDLING); |
cfdb727a | 1072 | |
d132bcc7 | 1073 | // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG |
d4514365 | 1074 | fService.enableLogLevel(sessionName, null, eventName4, LogLevelType.LOGLEVEL_ONLY, TraceLogLevel.TRACE_DEBUG, null, new NullProgressMonitor()); |
d132bcc7 BH |
1075 | |
1076 | // 2) session name, channel = mychannel, null, loglevel, TRACE_DEBUG_FUNCTION | |
d4514365 BH |
1077 | fService.enableLogLevel(sessionName, channelName, eventName5, LogLevelType.LOGLEVEL, TraceLogLevel.TRACE_DEBUG_FUNCTION, null, new NullProgressMonitor()); |
1078 | ||
1079 | // TODO add test with filters | |
d132bcc7 BH |
1080 | |
1081 | } catch (ExecutionException e) { | |
1082 | fail(e.toString()); | |
1083 | } | |
1084 | } | |
cfdb727a | 1085 | |
2ba3d0a1 | 1086 | @Test |
4ea599a5 BH |
1087 | public void testAddContext() { |
1088 | try { | |
1089 | // 1) session name, channel = null, 3 event names, kernel | |
1090 | String sessionName = "mysession2"; | |
1091 | String channelName = "mychannel"; | |
1092 | String eventName = "ust_tests_hello:tptest_sighandler"; | |
e0838ca1 | 1093 | List<String> contexts = new ArrayList<>(); |
4ea599a5 BH |
1094 | contexts.add("prio"); |
1095 | contexts.add("pid"); | |
1096 | ||
1097 | fShell.setScenario(SCEN_CONTEXT_HANDLING); | |
1098 | ||
1099 | List<String> availContexts = fService.getContextList(new NullProgressMonitor()); | |
1100 | assertNotNull(availContexts); | |
1101 | assertEquals(12, availContexts.size()); | |
1102 | ||
cfdb727a | 1103 | // A very "hard-coded" way to verify but it works ... |
e0838ca1 | 1104 | Set<String> expectedContexts = new HashSet<>(); |
4ea599a5 BH |
1105 | expectedContexts.add("pid"); |
1106 | expectedContexts.add("procname"); | |
1107 | expectedContexts.add("prio"); | |
1108 | expectedContexts.add("nice"); | |
1109 | expectedContexts.add("vpid"); | |
1110 | expectedContexts.add("tid"); | |
1111 | expectedContexts.add("pthread_id"); | |
1112 | expectedContexts.add("vtid"); | |
1113 | expectedContexts.add("ppid"); | |
1114 | expectedContexts.add("vppid"); | |
1115 | expectedContexts.add("perf:cpu-cycles"); | |
1116 | expectedContexts.add("perf:cycles"); | |
cfdb727a | 1117 | |
4ea599a5 | 1118 | assertTrue(expectedContexts.containsAll(availContexts)); |
cfdb727a | 1119 | |
4ea599a5 BH |
1120 | // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG |
1121 | fService.addContexts(sessionName, channelName, eventName, false, contexts, new NullProgressMonitor()); | |
1122 | ||
1123 | } catch (ExecutionException e) { | |
1124 | fail(e.toString()); | |
1125 | } | |
1126 | } | |
1127 | ||
2ba3d0a1 | 1128 | @Test |
4ea599a5 BH |
1129 | public void testAddContextFailure() { |
1130 | ||
1131 | // 1) session name, channel = null, 3 event names, kernel | |
1132 | String sessionName = "mysession2"; | |
1133 | String channelName = "mychannel"; | |
1134 | String eventName = "ust_tests_hello:tptest_sighandler"; | |
e0838ca1 | 1135 | List<String> contexts = new ArrayList<>(); |
4ea599a5 BH |
1136 | contexts.add("prio"); |
1137 | contexts.add("pid"); | |
1138 | fShell.setScenario(SCEN_CONTEXT_ERROR_HANDLING); | |
1139 | try { | |
1140 | fService.getContextList(new NullProgressMonitor()); | |
1141 | fail("No exeption generated"); | |
1142 | } catch (ExecutionException e) { | |
1143 | // success | |
cfdb727a | 1144 | } |
4ea599a5 BH |
1145 | try { |
1146 | // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG | |
1147 | fService.addContexts(sessionName, channelName, eventName, false, contexts, new NullProgressMonitor()); | |
1148 | fail("No exeption generated"); | |
1149 | } catch (ExecutionException e) { | |
1150 | // success | |
cfdb727a | 1151 | } |
4ea599a5 BH |
1152 | } |
1153 | ||
2ba3d0a1 | 1154 | @Test |
4ea599a5 BH |
1155 | public void testCalibrate() { |
1156 | try { | |
1157 | fShell.setScenario(SCEN_CALIBRATE_HANDLING); | |
1158 | fService.calibrate(true, new NullProgressMonitor()); | |
1159 | ||
1160 | } catch (ExecutionException e) { | |
1161 | fail(e.toString()); | |
1162 | } | |
1163 | } | |
1164 | ||
2ba3d0a1 | 1165 | @Test |
4ea599a5 | 1166 | public void testCalibrateFailure() { |
4ea599a5 BH |
1167 | try { |
1168 | fShell.setScenario(SCEN_CALIBRATE_HANDLING); | |
1169 | fService.calibrate(false, new NullProgressMonitor()); | |
1170 | fail("No exeption generated"); | |
1171 | } catch (ExecutionException e) { | |
1172 | // success | |
cfdb727a | 1173 | } |
4ea599a5 | 1174 | } |
cfdb727a | 1175 | |
a30e79fe | 1176 | @Test |
f3b33d40 BH |
1177 | public void testCreateSession2_1() { |
1178 | ||
1179 | try { | |
1180 | fShell.setScenario(SCEN_CREATE_SESSION_2_1); | |
1181 | ||
f7d4d450 MAL |
1182 | ISessionInfo sessionInfo = new SessionInfo("mysession"); |
1183 | sessionInfo.setNetworkUrl("net://172.0.0.1"); | |
1184 | sessionInfo.setStreamedTrace(true); | |
1185 | ISessionInfo info = fService.createSession(sessionInfo, new NullProgressMonitor()); | |
f3b33d40 BH |
1186 | assertNotNull(info); |
1187 | assertEquals("mysession", info.getName()); | |
1188 | assertEquals("net://172.0.0.1", info.getSessionPath()); | |
1189 | assertTrue(info.isStreamedTrace()); | |
1190 | fService.destroySession("mysession", new NullProgressMonitor()); | |
1191 | ||
f7d4d450 MAL |
1192 | sessionInfo = new SessionInfo("mysession"); |
1193 | sessionInfo.setStreamedTrace(true); | |
1194 | sessionInfo.setNetworkUrl("file:///tmp"); | |
1195 | info = fService.createSession(sessionInfo, new NullProgressMonitor()); | |
f3b33d40 BH |
1196 | assertNotNull(info); |
1197 | assertEquals("mysession", info.getName()); | |
1198 | assertEquals("file:///tmp", info.getSessionPath()); | |
d128c979 | 1199 | assertTrue(!info.isStreamedTrace()); |
f3b33d40 BH |
1200 | fService.destroySession("mysession", new NullProgressMonitor()); |
1201 | ||
f7d4d450 MAL |
1202 | sessionInfo = new SessionInfo("mysession"); |
1203 | sessionInfo.setStreamedTrace(true); | |
1204 | sessionInfo.setNetworkUrl("file:///tmp"); | |
1205 | info = fService.createSession(sessionInfo, new NullProgressMonitor()); | |
f3b33d40 BH |
1206 | assertNotNull(info); |
1207 | assertEquals("mysession", info.getName()); | |
1208 | assertEquals("file:///tmp", info.getSessionPath()); | |
d128c979 | 1209 | assertTrue(!info.isStreamedTrace()); |
f3b33d40 BH |
1210 | fService.destroySession("mysession", new NullProgressMonitor()); |
1211 | ||
f7d4d450 MAL |
1212 | sessionInfo = new SessionInfo("mysession"); |
1213 | sessionInfo.setStreamedTrace(true); | |
1214 | sessionInfo.setControlUrl("tcp://172.0.0.1"); | |
1215 | sessionInfo.setDataUrl("tcp://172.0.0.1:5343"); | |
1216 | info = fService.createSession(sessionInfo, new NullProgressMonitor()); | |
f3b33d40 BH |
1217 | assertNotNull(info); |
1218 | assertEquals("mysession", info.getName()); | |
d128c979 | 1219 | assertEquals("", info.getSessionPath()); // the complete network path is not available at this point |
f3b33d40 BH |
1220 | assertTrue(info.isStreamedTrace()); |
1221 | fService.destroySession("mysession", new NullProgressMonitor()); | |
1222 | ||
f7d4d450 MAL |
1223 | sessionInfo = new SessionInfo("mysession"); |
1224 | sessionInfo.setStreamedTrace(true); | |
1225 | sessionInfo.setNetworkUrl("net://172.0.0.1:1234:2345"); | |
1226 | info = fService.createSession(sessionInfo, new NullProgressMonitor()); | |
f3b33d40 BH |
1227 | assertNotNull(info); |
1228 | assertEquals("mysession", info.getName()); | |
1229 | assertEquals("net://172.0.0.1:1234:2345", info.getSessionPath()); | |
1230 | assertTrue(info.isStreamedTrace()); | |
1231 | fService.destroySession("mysession", new NullProgressMonitor()); | |
1232 | ||
d128c979 BH |
1233 | // verbose |
1234 | enableVerbose(); | |
f7d4d450 MAL |
1235 | sessionInfo = new SessionInfo("mysession"); |
1236 | sessionInfo.setStreamedTrace(true); | |
1237 | sessionInfo.setNetworkUrl("net://172.0.0.1"); | |
1238 | info = fService.createSession(sessionInfo, new NullProgressMonitor()); | |
d128c979 BH |
1239 | assertNotNull(info); |
1240 | assertEquals("mysession", info.getName()); | |
1241 | assertEquals("net://172.0.0.1", info.getSessionPath()); | |
1242 | assertTrue(info.isStreamedTrace()); | |
1243 | disableVerbose(); | |
1244 | fService.destroySession("mysession", new NullProgressMonitor()); | |
1245 | ||
1246 | ||
1247 | } catch (ExecutionException e) { | |
1248 | fail(e.toString()); | |
1249 | } | |
1250 | } | |
1251 | ||
1252 | @Test | |
1253 | public void testCreateSessionVerbose2_1() { | |
1254 | try { | |
1255 | fShell.setScenario(SCEN_CREATE_SESSION_VERBOSE_2_1); | |
1256 | ||
1257 | enableVerbose(); | |
f7d4d450 MAL |
1258 | ISessionInfo sessionInfo = new SessionInfo("mysession"); |
1259 | sessionInfo.setStreamedTrace(true); | |
1260 | sessionInfo.setNetworkUrl("net://172.0.0.1"); | |
1261 | ISessionInfo info = fService.createSession(sessionInfo, new NullProgressMonitor()); | |
d128c979 BH |
1262 | assertNotNull(info); |
1263 | assertEquals("mysession", info.getName()); | |
1264 | assertEquals("net://172.0.0.1", info.getSessionPath()); | |
1265 | assertTrue(info.isStreamedTrace()); | |
1266 | fService.destroySession("mysession", new NullProgressMonitor()); | |
f3b33d40 BH |
1267 | } catch (ExecutionException e) { |
1268 | fail(e.toString()); | |
d128c979 BH |
1269 | } finally { |
1270 | disableVerbose(); | |
f3b33d40 BH |
1271 | } |
1272 | } | |
d128c979 | 1273 | |
589d0d33 BH |
1274 | @Test |
1275 | public void testCreateSnapshotSession() { | |
1276 | try { | |
1277 | fShell.setScenario(SCEN_CREATE_SNAPSHOT_SESSION); | |
f7d4d450 MAL |
1278 | ISessionInfo params = new SessionInfo("mysession"); |
1279 | params.setSnapshot(true); | |
1280 | ISessionInfo sessionInfo = fService.createSession(params, new NullProgressMonitor()); | |
589d0d33 BH |
1281 | assertNotNull(sessionInfo); |
1282 | assertEquals("mysession", sessionInfo.getName()); | |
1283 | assertTrue(sessionInfo.isSnapshotSession()); | |
1284 | assertEquals("", sessionInfo.getSessionPath()); | |
1285 | assertTrue(!sessionInfo.isStreamedTrace()); | |
1286 | ||
1287 | assertEquals(TraceSessionState.INACTIVE, sessionInfo.getSessionState()); | |
1288 | ||
1289 | String[] names = fService.getSessionNames(new NullProgressMonitor()); | |
1290 | assertEquals(names[0], "mysession"); | |
1291 | ||
1292 | ISnapshotInfo snapshotInfo = fService.getSnapshotInfo("mysession", new NullProgressMonitor()); | |
1293 | assertNotNull(snapshotInfo); | |
1294 | assertEquals("snapshot-1", snapshotInfo.getName()); | |
1295 | assertEquals("/home/user/lttng-traces/mysession-20130913-141651", snapshotInfo.getSnapshotPath()); | |
1296 | assertEquals(1, snapshotInfo.getId()); | |
1297 | assertTrue(!snapshotInfo.isStreamedSnapshot()); | |
1298 | ||
1299 | // we need to set the snapshotInfo to so that the session path is set correctly | |
1300 | sessionInfo.setSnapshotInfo(snapshotInfo); | |
1301 | assertEquals("/home/user/lttng-traces/mysession-20130913-141651", sessionInfo.getSessionPath()); | |
1302 | ||
1303 | fService.recordSnapshot("mysession", new NullProgressMonitor()); | |
1304 | ||
1305 | fService.destroySession("mysession", new NullProgressMonitor()); | |
1306 | ||
1307 | } catch (ExecutionException e) { | |
1308 | fail(e.toString()); | |
1309 | } | |
1310 | } | |
1311 | ||
1312 | public void testCreateStreamedSnapshotSession() { | |
1313 | try { | |
1314 | fShell.setScenario(SCEN_CREATE_STREAMED_SNAPSHOT_SESSION); | |
1315 | ||
f7d4d450 MAL |
1316 | ISessionInfo params = new SessionInfo("mysession"); |
1317 | params.setNetworkUrl("net://172.0.0.1"); | |
1318 | ISessionInfo sessionInfo = fService.createSession(params, new NullProgressMonitor()); | |
589d0d33 BH |
1319 | assertNotNull(sessionInfo); |
1320 | assertEquals("mysession", sessionInfo.getName()); | |
1321 | assertTrue(sessionInfo.isSnapshotSession()); | |
1322 | ||
1323 | assertEquals(TraceSessionState.INACTIVE, sessionInfo.getSessionState()); | |
1324 | assertTrue(sessionInfo.isStreamedTrace()); | |
1325 | ||
1326 | String[] names = fService.getSessionNames(new NullProgressMonitor()); | |
1327 | assertEquals(names[0], "mysession"); | |
1328 | ||
589d0d33 BH |
1329 | ISnapshotInfo snapshotInfo = sessionInfo.getSnapshotInfo(); |
1330 | assertNotNull(sessionInfo); | |
1331 | assertEquals("snapshot-2", snapshotInfo.getName()); | |
1332 | assertEquals("net4://172.0.0.1:5342/", snapshotInfo.getSnapshotPath()); | |
1333 | assertEquals(2, snapshotInfo.getId()); | |
1334 | assertTrue(snapshotInfo.isStreamedSnapshot()); | |
1335 | ||
1336 | // we need to set the snapshotInfo to so that the session path is set correctly | |
1337 | sessionInfo.setSnapshotInfo(snapshotInfo); | |
1338 | assertEquals("net4://172.0.0.1:5342/", sessionInfo.getSessionPath()); | |
1339 | ||
1340 | fService.recordSnapshot("mysession", new NullProgressMonitor()); | |
1341 | ||
1342 | fService.destroySession("mysession", new NullProgressMonitor()); | |
1343 | ||
1344 | } catch (ExecutionException e) { | |
1345 | fail(e.toString()); | |
1346 | } | |
1347 | } | |
1348 | ||
589d0d33 BH |
1349 | @Test |
1350 | public void testCreateSnapshotSessionErrors() { | |
1351 | try { | |
1352 | fShell.setScenario(SCEN_CREATE_SNAPSHOT_SESSION_ERRORS); | |
1353 | ||
1354 | String[] names = fService.getSessionNames(new NullProgressMonitor()); | |
1355 | assertEquals(names[0], "mysession"); | |
1356 | } catch (ExecutionException e) { | |
1357 | fail(e.toString()); | |
1358 | } | |
1359 | ||
1360 | try { | |
1361 | fService.getSnapshotInfo("blabla", new NullProgressMonitor()); | |
1362 | fail("getSnapshoInfo() didn't fail"); | |
1363 | } catch (ExecutionException e) { | |
1364 | // successful | |
1365 | } | |
1366 | ||
1367 | try { | |
1368 | fService.recordSnapshot("blabla", new NullProgressMonitor()); | |
1369 | fail("getSnapshoInfo() didn't fail"); | |
1370 | } catch (ExecutionException e) { | |
1371 | // successful | |
1372 | } | |
1373 | ||
1374 | try { | |
1375 | fService.recordSnapshot("mysession", new NullProgressMonitor()); | |
1376 | fail("getSnapshoInfo() didn't fail"); | |
1377 | } catch (ExecutionException e) { | |
1378 | // successful | |
1379 | } | |
1380 | } | |
1381 | ||
81d5dc3a MAL |
1382 | @Test |
1383 | public void testCreateLiveSession() throws ExecutionException { | |
1384 | fShell.setScenario(SCEN_CREATE_LIVE_SESSION); | |
1385 | ||
1386 | ISessionInfo params = new SessionInfo("mysession"); | |
1387 | params.setLive(true); | |
1388 | params.setStreamedTrace(true); | |
1389 | params.setNetworkUrl("net://127.0.0.1"); | |
1390 | ISessionInfo sessionInfo = fService.createSession(params, new NullProgressMonitor()); | |
1391 | assertNotNull(sessionInfo); | |
1392 | assertEquals("mysession", sessionInfo.getName()); | |
1393 | assertEquals(TraceSessionState.INACTIVE, sessionInfo.getSessionState()); | |
1394 | assertTrue(sessionInfo.isStreamedTrace()); | |
1395 | assertTrue(sessionInfo.isLive()); | |
1396 | assertEquals("net://127.0.0.1", sessionInfo.getSessionPath()); | |
1397 | String[] names = fService.getSessionNames(new NullProgressMonitor()); | |
1398 | assertEquals(names[0], "mysession"); | |
1399 | fService.destroySession("mysession", new NullProgressMonitor()); | |
1400 | } | |
1401 | ||
1402 | @Test | |
1403 | public void testCreateLiveSessionErrors() { | |
1404 | try { | |
1405 | fShell.setScenario(SCEN_CREATE_LIVE_SESSION_ERRORS); | |
1406 | ||
1407 | ISessionInfo parameters = new SessionInfo("mysession"); | |
1408 | parameters.setLive(true); | |
1409 | parameters.setSnapshot(true); | |
1410 | fService.createSession(parameters, new NullProgressMonitor()); | |
1411 | fail("createSession() didn't fail"); | |
1412 | } catch (ExecutionException e) { | |
1413 | // successful | |
1414 | } | |
1415 | ||
1416 | try { | |
1417 | ISessionInfo parameters = new SessionInfo("mysession"); | |
1418 | parameters.setNetworkUrl("blah"); | |
1419 | parameters.setLive(true); | |
1420 | fService.createSession(parameters, new NullProgressMonitor()); | |
1421 | fail("createSession() didn't fail"); | |
1422 | } catch (ExecutionException e) { | |
1423 | // successful | |
1424 | } | |
1425 | ||
1426 | try { | |
1427 | ISessionInfo parameters = new SessionInfo("mysession"); | |
1428 | parameters.setControlUrl("net://127.0.0.1"); | |
1429 | parameters.setLive(true); | |
1430 | fService.createSession(parameters, new NullProgressMonitor()); | |
1431 | fail("createSession() didn't fail"); | |
1432 | } catch (ExecutionException e) { | |
1433 | // successful | |
1434 | } | |
1435 | } | |
1436 | ||
d128c979 BH |
1437 | private static void enableVerbose() { |
1438 | // verbose | |
1439 | ControlCommandLogger.init(ControlPreferences.getInstance().getLogfilePath(), false); | |
1440 | ControlPreferences.getInstance().getPreferenceStore().setDefault(ControlPreferences.TRACE_CONTROL_LOG_COMMANDS_PREF, true); | |
1441 | ControlPreferences.getInstance().getPreferenceStore().setDefault(ControlPreferences.TRACE_CONTROL_VERBOSE_LEVEL_PREF, ControlPreferences.TRACE_CONTROL_VERBOSE_LEVEL_V_V_VERBOSE); | |
1442 | } | |
1443 | ||
1444 | private static void disableVerbose() { | |
1445 | ControlPreferences.getInstance().getPreferenceStore().setDefault(ControlPreferences.TRACE_CONTROL_LOG_COMMANDS_PREF, false); | |
1446 | } | |
1447 | ||
1448 | ||
eb1bab5b | 1449 | } |