1 /**********************************************************************
2 * Copyright (c) 2012, 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 * Bernd Hufmann - Initial API and implementation
11 * Alexandre Montplaisir - Port to JUnit4
12 * Marc-Andre Laperle - Support for creating a live session
13 **********************************************************************/
15 package org
.eclipse
.linuxtools
.lttng2
.control
.ui
.tests
.service
;
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
;
24 import java
.util
.ArrayList
;
25 import java
.util
.HashSet
;
26 import java
.util
.List
;
29 import org
.eclipse
.core
.commands
.ExecutionException
;
30 import org
.eclipse
.core
.runtime
.FileLocator
;
31 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
32 import org
.eclipse
.core
.runtime
.Path
;
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
;
44 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.TraceChannelOutputType
;
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
;
58 import org
.junit
.After
;
59 import org
.junit
.Before
;
60 import org
.junit
.Test
;
61 import org
.osgi
.framework
.FrameworkUtil
;
64 * The class <code>LTTngControlServiceTest</code> contains test for the class
65 * <code>{@link LTTngControlService}</code>.
67 @SuppressWarnings("javadoc")
68 public class LTTngControlServiceTest
{
70 private static final String DIRECTORY
= "testfiles";
71 private static final String TEST_STREAM
= "LTTngServiceTest.cfg";
73 private static final String SCEN_LTTNG_NOT_INSTALLED
= "LttngNotInstalled";
74 private static final String SCEN_LTTNG_VERSION
= "LttngVersion";
75 private static final String SCEN_LTTNG_VERSION_WITH_PROMPT
= "LttngVersionWithPrompt";
76 private static final String SCEN_LTTNG_UNSUPPORTED_VERSION
= "LttngUnsupportedVersion";
77 private static final String SCEN_LTTNG_NO_VERSION
= "LttngNoVersion";
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";
81 private static final String SCEN_GET_SESSION_NAME_NOT_EXIST_VERBOSE
= "GetSessionNameNotExistVerbose";
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";
85 private static final String SCEN_LIST_WITH_NO_KERNEL1
= "ListWithNoKernel1";
86 private static final String SCEN_LIST_WITH_NO_KERNEL2
= "ListWithNoKernel2";
87 private static final String SCEN_LIST_WITH_NO_KERNEL_VERBOSE
= "ListWithNoKernelVerbose";
88 private static final String SCEN_GET_UST_PROVIDER1
= "GetUstProvider1";
89 private static final String SCEN_GET_UST_PROVIDER2
= "GetUstProvider2";
90 private static final String SCEN_GET_UST_PROVIDER3
= "GetUstProvider3";
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";
95 private static final String SCEN_CREATE_SESSION1
= "CreateSession1";
96 private static final String SCEN_CREATE_SESSION_WITH_PROMPT
= "CreateSessionWithPrompt";
97 private static final String SCEN_CREATE_SESSION_VARIANTS
= "CreateSessionVariants";
98 private static final String SCEN_DESTROY_SESSION1
= "DestroySession1";
99 private static final String SCEN_DESTROY_SESSION_VERBOSE
= "DestroySessionVerbose";
100 private static final String SCEN_CHANNEL_HANDLING
= "ChannelHandling";
101 private static final String SCEN_EVENT_HANDLING
= "EventHandling";
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";
105 private static final String SCEN_CREATE_SESSION_2_1
= "CreateSessionLttng2.1";
106 private static final String SCEN_CREATE_SESSION_VERBOSE_2_1
= "CreateSessionLttngVerbose2.1";
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";
110 private static final String SCEN_CREATE_LIVE_SESSION
= "CreateSessionLive";
111 private static final String SCEN_CREATE_LIVE_SESSION_ERRORS
= "CreateSessionLiveErrors";
113 // ------------------------------------------------------------------------
115 // ------------------------------------------------------------------------
117 private CommandShellFactory fShellFactory
;
118 private String fTestfile
;
119 private LTTngToolsFileShell fShell
;
120 private ILttngControlService fService
;
122 // ------------------------------------------------------------------------
124 // ------------------------------------------------------------------------
127 * Perform pre-test initialization.
130 * if the initialization fails for some reason
133 public void setUp() throws Exception
{
134 fShellFactory
= CommandShellFactory
.getInstance();
136 URL location
= FileLocator
.find(FrameworkUtil
.getBundle(this.getClass()), new Path(DIRECTORY
+ File
.separator
+ TEST_STREAM
), null);
137 File testfile
= new File(FileLocator
.toFileURL(location
).toURI());
138 fTestfile
= testfile
.getAbsolutePath();
140 fShell
= fShellFactory
.getFileShell();
141 fShell
.loadScenarioFile(fTestfile
);
142 fService
= new LTTngControlService(fShell
);
144 ControlPreferences
.getInstance().init(Activator
.getDefault().getPreferenceStore());
148 public void tearDown() {
150 ControlPreferences
.getInstance().dispose();
153 // ------------------------------------------------------------------------
155 // ------------------------------------------------------------------------
158 public void testVersion() {
160 fShell
.setScenario(SCEN_LTTNG_VERSION
);
161 ILttngControlService service
= LTTngControlServiceFactory
.getInstance().getLttngControlService(fShell
);
162 assertNotNull(service
);
163 assertEquals("2.1.0", service
.getVersionString());
164 } catch (ExecutionException e
) {
165 fail("Exeption thrown " + e
);
170 public void testVersionWithPrompt() {
172 fShell
.setScenario(SCEN_LTTNG_VERSION_WITH_PROMPT
);
173 ILttngControlService service
= LTTngControlServiceFactory
.getInstance().getLttngControlService(fShell
);
174 assertNotNull(service
);
175 assertEquals("2.0.0", service
.getVersionString());
176 } catch (ExecutionException e
) {
177 fail("Exeption thrown " + e
);
182 public void testUnsupportedVersion() {
184 fShell
.setScenario(SCEN_LTTNG_UNSUPPORTED_VERSION
);
185 LTTngControlServiceFactory
.getInstance().getLttngControlService(fShell
);
186 fail("No exeption thrown");
187 } catch (ExecutionException e
) {
193 public void testNoVersion() {
195 fShell
.setScenario(SCEN_LTTNG_NO_VERSION
);
196 LTTngControlServiceFactory
.getInstance().getLttngControlService(fShell
);
197 fail("No exeption thrown");
198 } catch (ExecutionException e
) {
204 public void testLttngNotInstalled() {
206 fShell
.setScenario(SCEN_LTTNG_NOT_INSTALLED
);
207 fService
.getSessionNames(new NullProgressMonitor());
208 fail("No exeption thrown");
209 } catch (ExecutionException e
) {
215 public void testGetSessionNames1() {
217 fShell
.setScenario(SCEN_NO_SESSION_AVAILABLE
);
218 String
[] result
= fService
.getSessionNames(new NullProgressMonitor());
220 assertNotNull(result
);
221 assertEquals(0, result
.length
);
223 } catch (ExecutionException e
) {
229 public void testGetSessionNames2() {
231 fShell
.setScenario(SCEN_GET_SESSION_NAMES1
);
232 String
[] result
= fService
.getSessionNames(new NullProgressMonitor());
234 assertNotNull(result
);
235 assertEquals(2, result
.length
);
236 assertEquals("mysession1", result
[0]);
237 assertEquals("mysession", result
[1]);
239 } catch (ExecutionException e
) {
245 public void testGetSessionNotExist() {
247 fShell
.setScenario(SCEN_GET_SESSION_NAME_NOT_EXIST
);
248 fService
.getSessionNames(new NullProgressMonitor());
249 fail("No exeption thrown");
251 } catch (ExecutionException e
) {
257 public void testGetSessionNotExistVerbose() {
260 fShell
.setScenario(SCEN_GET_SESSION_NAME_NOT_EXIST_VERBOSE
);
261 fService
.getSessionNames(new NullProgressMonitor());
262 fail("No exeption thrown");
264 } catch (ExecutionException e
) {
272 public void testGetSessionNameGarbage() {
274 fShell
.setScenario(SCEN_GET_SESSION_GARBAGE_OUT
);
275 String
[] result
= fService
.getSessionNames(new NullProgressMonitor());
277 assertNotNull(result
);
278 assertEquals(0, result
.length
);
280 } catch (ExecutionException e
) {
286 public void testGetSession1() {
288 fShell
.setScenario(SCEN_GET_SESSION1
);
289 ISessionInfo session
= fService
.getSession("mysession", new NullProgressMonitor());
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());
297 IDomainInfo
[] domains
= session
.getDomains();
298 assertNotNull(domains
);
299 assertEquals(2, domains
.length
);
301 // Verify Kernel domain
302 assertEquals("Kernel", domains
[0].getName());
303 IChannelInfo
[] channels
= domains
[0].getChannels();
304 assertNotNull(channels
);
305 assertEquals(2, channels
.length
);
307 // Verify Kernel's channel0
308 assertEquals("channel0", channels
[0].getName());
309 assertEquals(4, channels
[0].getNumberOfSubBuffers());
310 assertEquals("splice()", channels
[0].getOutputType().getInName());
311 assertEquals(TraceChannelOutputType
.SPLICE
, channels
[0].getOutputType());
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());
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());
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());
332 // Verify Kernel's channel1
333 assertEquals("channel1", channels
[1].getName());
334 assertEquals(4, channels
[1].getNumberOfSubBuffers());
335 assertEquals("splice()", channels
[1].getOutputType().getInName());
336 assertEquals(TraceChannelOutputType
.SPLICE
, channels
[1].getOutputType());
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());
344 IEventInfo
[] channel1Events
= channels
[1].getEvents();
345 assertEquals(0, channel1Events
.length
);
347 // Verify domain UST global
348 assertEquals("UST global", domains
[1].getName());
350 IChannelInfo
[] ustChannels
= domains
[1].getChannels();
352 // Verify UST global's mychannel1
353 assertEquals("mychannel1", ustChannels
[0].getName());
354 assertEquals(8, ustChannels
[0].getNumberOfSubBuffers());
355 assertEquals("mmap()", ustChannels
[0].getOutputType().getInName());
356 assertEquals(TraceChannelOutputType
.MMAP
, ustChannels
[0].getOutputType());
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());
364 IEventInfo
[] ustEvents
= ustChannels
[0].getEvents();
365 assertEquals(0, ustEvents
.length
);
367 // Verify UST global's channel0
368 assertEquals("channel0", ustChannels
[1].getName());
369 assertEquals(4, ustChannels
[1].getNumberOfSubBuffers());
370 assertEquals("mmap()", ustChannels
[1].getOutputType().getInName());
371 assertEquals(TraceChannelOutputType
.MMAP
, ustChannels
[1].getOutputType());
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());
379 ustEvents
= ustChannels
[1].getEvents();
380 assertEquals(2, ustEvents
.length
);
382 assertEquals("ust_tests_hello:tptest_sighandler", ustEvents
[0].getName());
383 assertEquals(TraceLogLevel
.TRACE_DEBUG_LINE
, ustEvents
[0].getLogLevel());
384 assertEquals(TraceEventType
.TRACEPOINT
, ustEvents
[0].getEventType());
385 assertEquals(TraceEnablement
.DISABLED
, ustEvents
[0].getState());
387 assertEquals("*", ustEvents
[1].getName());
388 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, ustEvents
[1].getLogLevel());
389 assertEquals(TraceEventType
.TRACEPOINT
, ustEvents
[1].getEventType());
390 assertEquals(TraceEnablement
.ENABLED
, ustEvents
[1].getState());
392 // next session (no detailed information available)
393 session
= fService
.getSession("mysession1", new NullProgressMonitor());
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());
399 domains
= session
.getDomains();
400 assertNotNull(domains
);
401 assertEquals(0, domains
.length
);
402 } catch (ExecutionException e
) {
407 public void testGetKernelProvider() {
409 fShell
.setScenario(SCEN_GET_KERNEL_PROVIDER1
);
410 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
413 assertNotNull(events
);
414 assertEquals(3, events
.size());
416 IBaseEventInfo baseEventInfo
= events
.get(0);
417 assertNotNull(baseEventInfo
);
418 assertEquals("sched_kthread_stop", baseEventInfo
.getName());
419 assertEquals(TraceLogLevel
.TRACE_EMERG
, baseEventInfo
.getLogLevel());
420 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
422 baseEventInfo
= events
.get(1);
423 assertEquals("sched_kthread_stop_ret", baseEventInfo
.getName());
424 assertEquals(TraceLogLevel
.TRACE_EMERG
, baseEventInfo
.getLogLevel());
425 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
427 baseEventInfo
= events
.get(2);
428 assertEquals("sched_wakeup_new", baseEventInfo
.getName());
429 assertEquals(TraceLogLevel
.TRACE_EMERG
, baseEventInfo
.getLogLevel());
430 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
432 } catch (ExecutionException e
) {
438 public void testGetKernelProviderNoKernel1() {
440 fShell
.setScenario(SCEN_LIST_WITH_NO_KERNEL1
);
441 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
444 assertNotNull(events
);
445 assertEquals(0, events
.size());
447 } catch (ExecutionException e
) {
453 public void testGetKernelProviderNoKernel2() {
455 fShell
.setScenario(SCEN_LIST_WITH_NO_KERNEL2
);
456 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
459 assertNotNull(events
);
460 assertEquals(0, events
.size());
462 } catch (ExecutionException e
) {
468 public void testGetKernelProviderNoKernelVerbose() {
471 fShell
.setScenario(SCEN_LIST_WITH_NO_KERNEL_VERBOSE
);
472 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
475 assertNotNull(events
);
476 assertEquals(0, events
.size());
478 } catch (ExecutionException e
) {
486 public void testGetUstProvider() {
488 fShell
.setScenario(SCEN_GET_UST_PROVIDER1
);
489 List
<IUstProviderInfo
> providers
= fService
.getUstProvider();
491 // Check all providers
492 assertNotNull(providers
);
493 assertEquals(2, providers
.size());
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());
500 IBaseEventInfo
[] events
= providers
.get(0).getEvents();
501 assertNotNull(events
);
502 assertEquals(2, events
.length
);
504 IBaseEventInfo baseEventInfo
= events
[0];
505 assertNotNull(baseEventInfo
);
506 assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo
.getName());
507 assertEquals(TraceLogLevel
.TRACE_DEBUG_MODULE
, baseEventInfo
.getLogLevel());
508 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
510 baseEventInfo
= events
[1];
511 assertEquals("ust_tests_hello:tptest", baseEventInfo
.getName());
512 assertEquals(TraceLogLevel
.TRACE_INFO
, baseEventInfo
.getLogLevel());
513 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
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());
520 events
= providers
.get(1).getEvents();
521 assertNotNull(events
);
522 assertEquals(2, events
.length
);
524 baseEventInfo
= events
[0];
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());
530 baseEventInfo
= events
[1];
531 assertEquals("ust_tests_hello:tptest", baseEventInfo
.getName());
532 assertEquals(TraceLogLevel
.TRACE_DEBUG_FUNCTION
, baseEventInfo
.getLogLevel());
533 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
535 } catch (ExecutionException e
) {
541 public void testUstProvider2() {
543 fShell
.setScenario(SCEN_GET_UST_PROVIDER2
);
544 List
<IUstProviderInfo
> providers
= fService
.getUstProvider();
546 assertNotNull(providers
);
547 assertEquals(0, providers
.size());
549 } catch (ExecutionException e
) {
555 public void testGetUstProvider3() {
557 fShell
.setScenario(SCEN_GET_UST_PROVIDER3
);
559 ((LTTngControlService
)fService
).setVersion("2.1.0");
560 List
<IUstProviderInfo
> providers
= fService
.getUstProvider();
562 // Check all providers
563 assertNotNull(providers
);
564 assertEquals(2, providers
.size());
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());
571 IBaseEventInfo
[] events
= providers
.get(0).getEvents();
572 assertNotNull(events
);
573 assertEquals(2, events
.length
);
575 IBaseEventInfo baseEventInfo
= events
[0];
576 assertNotNull(baseEventInfo
);
577 IFieldInfo
[] fields
= baseEventInfo
.getFields();
578 assertNotNull(fields
);
579 assertEquals(0, fields
.length
);
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());
588 assertEquals("floatfield", fields
[1].getName());
589 assertEquals("float", fields
[1].getFieldType());
591 assertEquals("stringfield", fields
[2].getName());
592 assertEquals("string", fields
[2].getFieldType());
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());
599 events
= providers
.get(1).getEvents();
600 assertNotNull(events
);
601 assertEquals(2, events
.length
);
603 baseEventInfo
= events
[0];
604 assertNotNull(baseEventInfo
);
605 fields
= baseEventInfo
.getFields();
606 assertNotNull(fields
);
607 assertEquals(0, fields
.length
);
609 baseEventInfo
= events
[1];
610 fields
= baseEventInfo
.getFields();
611 assertNotNull(fields
);
612 assertEquals(3, fields
.length
);
614 assertEquals("doublefield", fields
[0].getName());
615 assertEquals("float", fields
[0].getFieldType());
617 assertEquals("floatfield", fields
[1].getName());
618 assertEquals("float", fields
[1].getFieldType());
620 assertEquals("stringfield", fields
[2].getName());
621 assertEquals("string", fields
[2].getFieldType());
624 ((LTTngControlService
)fService
).setVersion("2.0.0");
626 } catch (ExecutionException e
) {
633 public void testGetKernelProviderNoUst1() {
635 fShell
.setScenario(SCEN_LIST_WITH_NO_UST1
);
636 List
<IUstProviderInfo
> providerList
= fService
.getUstProvider(new NullProgressMonitor());
638 // Verify Provider info
639 assertNotNull(providerList
);
640 assertEquals(0, providerList
.size());
642 } catch (ExecutionException e
) {
649 public void testGetKernelProviderNoUst2() {
652 ((LTTngControlService
)fService
).setVersion("2.1.0");
654 fShell
.setScenario(SCEN_LIST_WITH_NO_UST2
);
655 List
<IUstProviderInfo
> providerList
= fService
.getUstProvider(new NullProgressMonitor());
657 // Verify Provider info
658 assertNotNull(providerList
);
659 assertEquals(0, providerList
.size());
662 ((LTTngControlService
)fService
).setVersion("2.0.0");
664 } catch (ExecutionException e
) {
670 public void testGetKernelProviderNoUst3() {
674 ((LTTngControlService
)fService
).setVersion("2.1.0");
676 fShell
.setScenario(SCEN_LIST_WITH_NO_UST3
);
677 List
<IUstProviderInfo
> providerList
= fService
.getUstProvider(new NullProgressMonitor());
679 // Verify provider info
680 assertNotNull(providerList
);
681 assertEquals(0, providerList
.size());
684 ((LTTngControlService
)fService
).setVersion("2.0.0");
686 } catch (ExecutionException e
) {
692 public void testGetKernelProviderNoUstVerbose() {
697 ((LTTngControlService
)fService
).setVersion("2.1.0");
699 fShell
.setScenario(SCEN_LIST_WITH_NO_UST_VERBOSE
);
700 List
<IUstProviderInfo
> providerList
= fService
.getUstProvider(new NullProgressMonitor());
702 // Verify provider info
703 assertNotNull(providerList
);
704 assertEquals(0, providerList
.size());
707 ((LTTngControlService
)fService
).setVersion("2.0.0");
709 } catch (ExecutionException e
) {
719 public void testCreateSession() {
721 fShell
.setScenario(SCEN_CREATE_SESSION1
);
723 ISessionInfo info
= fService
.createSession(new SessionInfo("mysession2"), new NullProgressMonitor());
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
) {
735 public void testCreateSessionWithPrompt() {
737 // First line has the shell prompt before the command output
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
);
741 // First line has no shell prompt before the output
742 ISessionInfo info
= fService
.createSession(new SessionInfo("mysession2"), new NullProgressMonitor());
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
) {
754 public void testCreateSessionVariants() {
756 fShell
.setScenario(SCEN_CREATE_SESSION_VARIANTS
);
759 fService
.createSession(new SessionInfo("alreadyExist"), new NullProgressMonitor());
760 fail("No exeption thrown");
761 } catch (ExecutionException e
) {
766 fService
.createSession(new SessionInfo("wrongName"), new NullProgressMonitor());
767 fail("No exeption thrown");
768 } catch (ExecutionException e
) {
773 ISessionInfo sessionInfo
= new SessionInfo("withPath");
774 sessionInfo
.setSessionPath("/home/user/hallo");
775 fService
.createSession(sessionInfo
, new NullProgressMonitor());
776 fail("No exeption thrown");
777 } catch (ExecutionException e
) {
782 ISessionInfo info
= fService
.createSession(new SessionInfo("session with spaces"), new NullProgressMonitor());
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());
789 } catch (ExecutionException e
) {
794 ISessionInfo sessionInfo
= new SessionInfo("pathWithSpaces");
795 sessionInfo
.setSessionPath("/home/user/hallo user/here");
796 ISessionInfo info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
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());
803 } catch (ExecutionException e
) {
809 public void testDestroySession() {
811 fShell
.setScenario(SCEN_DESTROY_SESSION1
);
812 fService
.destroySession("mysession2", new NullProgressMonitor());
813 } catch (ExecutionException e
) {
819 public void testDestroySessionVerbose() {
822 fShell
.setScenario(SCEN_DESTROY_SESSION_VERBOSE
);
823 fService
.destroySession("mysession2", new NullProgressMonitor());
824 } catch (ExecutionException e
) {
832 public void testCreateChannel() {
834 ((LTTngControlService
)fService
).setVersion("2.2.0");
835 String sessionName
= "mysession2";
836 List
<String
> list
= new ArrayList
<>();
837 String kernelChannel0
= "mychannel0";
838 String kernelChannel1
= "mychannel1";
839 list
.add(kernelChannel0
);
840 list
.add(kernelChannel1
);
842 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
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);
851 chanInfo
.setMaxNumberTraceFiles(10);
852 chanInfo
.setMaxSizeTraceFiles(0);
853 fService
.enableChannels(sessionName
, list
, true, chanInfo
, new NullProgressMonitor());
855 // Create/enable/configure 1 UST channel
857 list
.add("ustChannel");
859 chanInfo
= new ChannelInfo("");
860 chanInfo
.setOverwriteMode(true);
861 chanInfo
.setSubBufferSize(32768);
862 chanInfo
.setReadTimer(200);
863 chanInfo
.setSwitchTimer(100);
864 chanInfo
.setNumberOfSubBuffers(1);
865 chanInfo
.setMaxNumberTraceFiles(20);
866 chanInfo
.setMaxSizeTraceFiles(0);
867 fService
.enableChannels(sessionName
, list
, false, chanInfo
, new NullProgressMonitor());
868 ((LTTngControlService
)fService
).setVersion("2.0.0");
870 } catch (ExecutionException e
) {
876 public void testCreateChannelUIDBuffer() {
878 ((LTTngControlService
)fService
).setVersion("2.2.0");
879 String sessionName
= "mysession2";
880 List
<String
> list
= new ArrayList
<>();
881 String USTChannel
= "ustChannel";
882 list
.add(USTChannel
);
883 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
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);
893 chanInfo
.setBufferType(BufferType
.BUFFER_PER_UID
);
894 fService
.enableChannels(sessionName
, list
, false, chanInfo
, new NullProgressMonitor());
895 ((LTTngControlService
)fService
).setVersion("2.0.0");
897 } catch (ExecutionException e
) {
903 public void testCreateChannelPIDBuffer() {
905 ((LTTngControlService
)fService
).setVersion("2.2.0");
906 String sessionName
= "mysession2";
907 List
<String
> list
= new ArrayList
<>();
908 String USTChannel
= "ustChannel";
909 list
.add(USTChannel
);
910 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
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
);
923 fService
.enableChannels(sessionName
, list
, false, chanInfo
, new NullProgressMonitor());
924 ((LTTngControlService
)fService
).setVersion("2.0.0");
926 } catch (ExecutionException e
) {
932 public void testDisableChannel() {
935 String sessionName
= "mysession2";
936 List
<String
> list
= new ArrayList
<>();
937 String kernelChannel0
= "mychannel0";
938 String kernelChannel1
= "mychannel1";
939 list
.add(kernelChannel0
);
940 list
.add(kernelChannel1
);
942 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
943 fService
.disableChannels(sessionName
, list
, true, new NullProgressMonitor());
946 list
.add("ustChannel");
947 fService
.disableChannels(sessionName
, list
, false, new NullProgressMonitor());
949 } catch (ExecutionException e
) {
955 public void testEnableChannel() {
958 String sessionName
= "mysession2";
959 List
<String
> list
= new ArrayList
<>();
960 String kernelChannel0
= "mychannel0";
961 String kernelChannel1
= "mychannel1";
962 list
.add(kernelChannel0
);
963 list
.add(kernelChannel1
);
965 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
966 fService
.enableChannels(sessionName
, list
, true, null, new NullProgressMonitor());
968 // Create/enable/configure 1 UST channel
970 list
.add("ustChannel");
972 fService
.enableChannels(sessionName
, list
, false, null, new NullProgressMonitor());
974 } catch (ExecutionException e
) {
980 public void testEnableEvents() {
982 // 1) session name, channel = null, 3 event names, kernel
983 String sessionName
= "mysession2";
984 List
<String
> list
= new ArrayList
<>();
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
);
992 fService
.enableEvents(sessionName
, null, list
, true, null, new NullProgressMonitor());
994 // 2) session name, channel=mychannel, event name= null, kernel
995 String channelName
= "mychannel";
996 fService
.enableEvents(sessionName
, channelName
, null, true, null, new NullProgressMonitor());
998 // 3) session name, channel=mychannel, 1 event name, ust, no filter
999 String ustEventName
= "ust_tests_hello:tptest_sighandler";
1001 list
.add(ustEventName
);
1002 fService
.enableEvents(sessionName
, channelName
, list
, false, null, new NullProgressMonitor());
1004 // 4) session name, channel = mychannel, no event name, ust, with filter
1005 fService
.enableEvents(sessionName
, channelName
, list
, false, "intfield==10", new NullProgressMonitor());
1007 // 5) session name, channel = mychannel, no event name, ust, no filter
1009 fService
.enableEvents(sessionName
, channelName
, list
, false, null, new NullProgressMonitor());
1011 // TODO add test with filters
1013 } catch (ExecutionException e
) {
1019 public void testEnableSyscalls() {
1021 // 1) session name, channel = null, 3 event names, kernel
1022 String sessionName
= "mysession2";
1023 String channelName
= "mychannel";
1025 fShell
.setScenario(SCEN_EVENT_HANDLING
);
1027 // 1) session name, channel = null
1028 fService
.enableSyscalls(sessionName
, null, new NullProgressMonitor());
1030 // 2) session name, channel = mychannel
1031 fService
.enableSyscalls(sessionName
, channelName
, new NullProgressMonitor());
1033 } catch (ExecutionException e
) {
1039 public void testDynamicProbe() {
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";
1049 fShell
.setScenario(SCEN_EVENT_HANDLING
);
1051 // 1) session name, channel = null, event name, function probe, probe
1052 fService
.enableProbe(sessionName
, null, eventName0
, true, functionProbe
, new NullProgressMonitor());
1054 // 2) session name, channel = mychannel
1055 fService
.enableProbe(sessionName
, channelName
, eventName1
, false, dynProbe
, new NullProgressMonitor());
1057 } catch (ExecutionException e
) {
1063 public void testEnableLogLevel() {
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";
1071 fShell
.setScenario(SCEN_EVENT_HANDLING
);
1073 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
1074 fService
.enableLogLevel(sessionName
, null, eventName4
, LogLevelType
.LOGLEVEL_ONLY
, TraceLogLevel
.TRACE_DEBUG
, null, new NullProgressMonitor());
1076 // 2) session name, channel = mychannel, null, loglevel, TRACE_DEBUG_FUNCTION
1077 fService
.enableLogLevel(sessionName
, channelName
, eventName5
, LogLevelType
.LOGLEVEL
, TraceLogLevel
.TRACE_DEBUG_FUNCTION
, null, new NullProgressMonitor());
1079 // TODO add test with filters
1081 } catch (ExecutionException e
) {
1087 public void testAddContext() {
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";
1093 List
<String
> contexts
= new ArrayList
<>();
1094 contexts
.add("prio");
1095 contexts
.add("pid");
1097 fShell
.setScenario(SCEN_CONTEXT_HANDLING
);
1099 List
<String
> availContexts
= fService
.getContextList(new NullProgressMonitor());
1100 assertNotNull(availContexts
);
1101 assertEquals(12, availContexts
.size());
1103 // A very "hard-coded" way to verify but it works ...
1104 Set
<String
> expectedContexts
= new HashSet
<>();
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");
1118 assertTrue(expectedContexts
.containsAll(availContexts
));
1120 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
1121 fService
.addContexts(sessionName
, channelName
, eventName
, false, contexts
, new NullProgressMonitor());
1123 } catch (ExecutionException e
) {
1129 public void testAddContextFailure() {
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";
1135 List
<String
> contexts
= new ArrayList
<>();
1136 contexts
.add("prio");
1137 contexts
.add("pid");
1138 fShell
.setScenario(SCEN_CONTEXT_ERROR_HANDLING
);
1140 fService
.getContextList(new NullProgressMonitor());
1141 fail("No exeption generated");
1142 } catch (ExecutionException e
) {
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
) {
1155 public void testCalibrate() {
1157 fShell
.setScenario(SCEN_CALIBRATE_HANDLING
);
1158 fService
.calibrate(true, new NullProgressMonitor());
1160 } catch (ExecutionException e
) {
1166 public void testCalibrateFailure() {
1168 fShell
.setScenario(SCEN_CALIBRATE_HANDLING
);
1169 fService
.calibrate(false, new NullProgressMonitor());
1170 fail("No exeption generated");
1171 } catch (ExecutionException e
) {
1177 public void testCreateSession2_1() {
1180 fShell
.setScenario(SCEN_CREATE_SESSION_2_1
);
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());
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());
1192 sessionInfo
= new SessionInfo("mysession");
1193 sessionInfo
.setStreamedTrace(true);
1194 sessionInfo
.setNetworkUrl("file:///tmp");
1195 info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1196 assertNotNull(info
);
1197 assertEquals("mysession", info
.getName());
1198 assertEquals("file:///tmp", info
.getSessionPath());
1199 assertTrue(!info
.isStreamedTrace());
1200 fService
.destroySession("mysession", new NullProgressMonitor());
1202 sessionInfo
= new SessionInfo("mysession");
1203 sessionInfo
.setStreamedTrace(true);
1204 sessionInfo
.setNetworkUrl("file:///tmp");
1205 info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1206 assertNotNull(info
);
1207 assertEquals("mysession", info
.getName());
1208 assertEquals("file:///tmp", info
.getSessionPath());
1209 assertTrue(!info
.isStreamedTrace());
1210 fService
.destroySession("mysession", new NullProgressMonitor());
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());
1217 assertNotNull(info
);
1218 assertEquals("mysession", info
.getName());
1219 assertEquals("", info
.getSessionPath()); // the complete network path is not available at this point
1220 assertTrue(info
.isStreamedTrace());
1221 fService
.destroySession("mysession", new NullProgressMonitor());
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());
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());
1235 sessionInfo
= new SessionInfo("mysession");
1236 sessionInfo
.setStreamedTrace(true);
1237 sessionInfo
.setNetworkUrl("net://172.0.0.1");
1238 info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1239 assertNotNull(info
);
1240 assertEquals("mysession", info
.getName());
1241 assertEquals("net://172.0.0.1", info
.getSessionPath());
1242 assertTrue(info
.isStreamedTrace());
1244 fService
.destroySession("mysession", new NullProgressMonitor());
1247 } catch (ExecutionException e
) {
1253 public void testCreateSessionVerbose2_1() {
1255 fShell
.setScenario(SCEN_CREATE_SESSION_VERBOSE_2_1
);
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());
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());
1267 } catch (ExecutionException e
) {
1275 public void testCreateSnapshotSession() {
1277 fShell
.setScenario(SCEN_CREATE_SNAPSHOT_SESSION
);
1278 ISessionInfo params
= new SessionInfo("mysession");
1279 params
.setSnapshot(true);
1280 ISessionInfo sessionInfo
= fService
.createSession(params
, new NullProgressMonitor());
1281 assertNotNull(sessionInfo
);
1282 assertEquals("mysession", sessionInfo
.getName());
1283 assertTrue(sessionInfo
.isSnapshotSession());
1284 assertEquals("", sessionInfo
.getSessionPath());
1285 assertTrue(!sessionInfo
.isStreamedTrace());
1287 assertEquals(TraceSessionState
.INACTIVE
, sessionInfo
.getSessionState());
1289 String
[] names
= fService
.getSessionNames(new NullProgressMonitor());
1290 assertEquals(names
[0], "mysession");
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());
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());
1303 fService
.recordSnapshot("mysession", new NullProgressMonitor());
1305 fService
.destroySession("mysession", new NullProgressMonitor());
1307 } catch (ExecutionException e
) {
1312 public void testCreateStreamedSnapshotSession() {
1314 fShell
.setScenario(SCEN_CREATE_STREAMED_SNAPSHOT_SESSION
);
1316 ISessionInfo params
= new SessionInfo("mysession");
1317 params
.setNetworkUrl("net://172.0.0.1");
1318 ISessionInfo sessionInfo
= fService
.createSession(params
, new NullProgressMonitor());
1319 assertNotNull(sessionInfo
);
1320 assertEquals("mysession", sessionInfo
.getName());
1321 assertTrue(sessionInfo
.isSnapshotSession());
1323 assertEquals(TraceSessionState
.INACTIVE
, sessionInfo
.getSessionState());
1324 assertTrue(sessionInfo
.isStreamedTrace());
1326 String
[] names
= fService
.getSessionNames(new NullProgressMonitor());
1327 assertEquals(names
[0], "mysession");
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());
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());
1340 fService
.recordSnapshot("mysession", new NullProgressMonitor());
1342 fService
.destroySession("mysession", new NullProgressMonitor());
1344 } catch (ExecutionException e
) {
1350 public void testCreateSnapshotSessionErrors() {
1352 fShell
.setScenario(SCEN_CREATE_SNAPSHOT_SESSION_ERRORS
);
1354 String
[] names
= fService
.getSessionNames(new NullProgressMonitor());
1355 assertEquals(names
[0], "mysession");
1356 } catch (ExecutionException e
) {
1361 fService
.getSnapshotInfo("blabla", new NullProgressMonitor());
1362 fail("getSnapshoInfo() didn't fail");
1363 } catch (ExecutionException e
) {
1368 fService
.recordSnapshot("blabla", new NullProgressMonitor());
1369 fail("getSnapshoInfo() didn't fail");
1370 } catch (ExecutionException e
) {
1375 fService
.recordSnapshot("mysession", new NullProgressMonitor());
1376 fail("getSnapshoInfo() didn't fail");
1377 } catch (ExecutionException e
) {
1383 public void testCreateLiveSession() throws ExecutionException
{
1384 fShell
.setScenario(SCEN_CREATE_LIVE_SESSION
);
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());
1403 public void testCreateLiveSessionErrors() {
1405 fShell
.setScenario(SCEN_CREATE_LIVE_SESSION_ERRORS
);
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
) {
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
) {
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
) {
1437 private static void enableVerbose() {
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
);
1444 private static void disableVerbose() {
1445 ControlPreferences
.getInstance().getPreferenceStore().setDefault(ControlPreferences
.TRACE_CONTROL_LOG_COMMANDS_PREF
, false);