1 /**********************************************************************
2 * Copyright (c) 2012, 2015 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
.tracecompass
.lttng2
.control
.ui
.tests
.service
;
17 import static org
.junit
.Assert
.assertEquals
;
18 import static org
.junit
.Assert
.assertFalse
;
19 import static org
.junit
.Assert
.assertNotNull
;
20 import static org
.junit
.Assert
.assertTrue
;
21 import static org
.junit
.Assert
.fail
;
25 import java
.util
.ArrayList
;
26 import java
.util
.HashSet
;
27 import java
.util
.List
;
30 import org
.eclipse
.core
.commands
.ExecutionException
;
31 import org
.eclipse
.core
.runtime
.FileLocator
;
32 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
33 import org
.eclipse
.core
.runtime
.Path
;
34 import org
.eclipse
.jdt
.annotation
.NonNull
;
35 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.IBaseEventInfo
;
36 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.IChannelInfo
;
37 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.IDomainInfo
;
38 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.IEventInfo
;
39 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.IFieldInfo
;
40 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.ISessionInfo
;
41 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.ISnapshotInfo
;
42 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.IUstProviderInfo
;
43 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.LogLevelType
;
44 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceChannelOutputType
;
45 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceEnablement
;
46 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceEventType
;
47 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceLogLevel
;
48 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceSessionState
;
49 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.impl
.BufferType
;
50 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.impl
.ChannelInfo
;
51 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.impl
.SessionInfo
;
52 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.stubs
.shells
.LTTngToolsFileShell
;
53 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.Activator
;
54 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.logging
.ControlCommandLogger
;
55 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.preferences
.ControlPreferences
;
56 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.service
.ILttngControlService
;
57 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.service
.LTTngControlService
;
58 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.service
.LTTngControlServiceFactory
;
59 import org
.junit
.After
;
60 import org
.junit
.Before
;
61 import org
.junit
.Test
;
62 import org
.osgi
.framework
.FrameworkUtil
;
65 * The class <code>LTTngControlServiceTest</code> contains test for the class
66 * <code>{@link LTTngControlService}</code>.
68 @SuppressWarnings("javadoc")
69 public class LTTngControlServiceTest
{
71 private static final String DIRECTORY
= "testfiles";
72 private static final String TEST_STREAM
= "LTTngServiceTest.cfg";
74 private static final String SCEN_LTTNG_NOT_INSTALLED
= "LttngNotInstalled";
75 private static final String SCEN_LTTNG_VERSION
= "LttngVersion";
76 private static final String SCEN_LTTNG_VERSION_WITH_PROMPT
= "LttngVersionWithPrompt";
77 private static final String SCEN_LTTNG_UNSUPPORTED_VERSION
= "LttngUnsupportedVersion";
78 private static final String SCEN_LTTNG_NO_VERSION
= "LttngNoVersion";
79 private static final String SCEN_LTTNG_COMPILED_VERSION
= "LttngVersionCompiled";
80 private static final String SCEN_NO_SESSION_AVAILABLE
= "NoSessionAvailable";
81 private static final String SCEN_GET_SESSION_NAMES1
= "GetSessionNames1";
82 private static final String SCEN_GET_SESSION_WITH_GROUP
= "GetSessionWithTracingGroup";
83 private static final String SCEN_GET_SESSION_NAME_NOT_EXIST
= "GetSessionNameNotExist";
84 private static final String SCEN_GET_SESSION_NAME_NOT_EXIST_VERBOSE
= "GetSessionNameNotExistVerbose";
85 protected static final String SCEN_GET_SESSION_GARBAGE_OUT
= "GetSessionGarbageOut";
86 private static final String SCEN_GET_SESSION1
= "GetSession1";
87 private static final String SCEN_GET_SESSION_WITH_LIVE
= "GetSessionWithLiveInterval";
88 private static final String SCEN_GET_KERNEL_PROVIDER1
= "GetKernelProvider1";
89 private static final String SCEN_LIST_WITH_NO_KERNEL1
= "ListWithNoKernel1";
90 private static final String SCEN_LIST_WITH_NO_KERNEL2
= "ListWithNoKernel2";
91 private static final String SCEN_LIST_WITH_NO_KERNEL_VERBOSE
= "ListWithNoKernelVerbose";
92 private static final String SCEN_GET_UST_PROVIDER1
= "GetUstProvider1";
93 private static final String SCEN_GET_UST_PROVIDER2
= "GetUstProvider2";
94 private static final String SCEN_GET_UST_PROVIDER3
= "GetUstProvider3";
95 private static final String SCEN_LIST_WITH_NO_UST1
= "ListWithNoUst1";
96 private static final String SCEN_LIST_WITH_NO_UST2
= "ListWithNoUst2";
97 private static final String SCEN_LIST_WITH_NO_UST3
= "ListWithNoUst3";
98 private static final String SCEN_LIST_WITH_NO_UST_VERBOSE
= "ListWithNoUstVerbose";
99 private static final String SCEN_CREATE_SESSION1
= "CreateSession1";
100 private static final String SCEN_CREATE_SESSION_WITH_PROMPT
= "CreateSessionWithPrompt";
101 private static final String SCEN_CREATE_SESSION_VARIANTS
= "CreateSessionVariants";
102 private static final String SCEN_DESTROY_SESSION1
= "DestroySession1";
103 private static final String SCEN_DESTROY_SESSION_VERBOSE
= "DestroySessionVerbose";
104 private static final String SCEN_CHANNEL_HANDLING
= "ChannelHandling";
105 private static final String SCEN_EVENT_HANDLING
= "EventHandling";
106 private static final String SCEN_CONTEXT_HANDLING
= "ContextHandling";
107 private static final String SCEN_CONTEXT_ERROR_HANDLING
= "ContextErrorHandling";
108 private static final String SCEN_CREATE_SESSION_2_1
= "CreateSessionLttng2.1";
109 private static final String SCEN_CREATE_SESSION_VERBOSE_2_1
= "CreateSessionLttngVerbose2.1";
110 private static final String SCEN_CREATE_SNAPSHOT_SESSION
= "CreateSessionSnapshot";
111 private static final String SCEN_CREATE_SNAPSHOT_SESSION_2_5
= "CreateSessionSnapshot2.5";
112 private static final String SCEN_CREATE_STREAMED_SNAPSHOT_SESSION
= "CreateSessionStreamedSnapshot";
113 private static final String SCEN_CREATE_SNAPSHOT_SESSION_ERRORS
= "CreateSessionSnapshotErrors";
114 protected static final String SCEN_CREATE_LIVE_SESSION
= "CreateSessionLive";
115 private static final String SCEN_CREATE_LIVE_SESSION_ERRORS
= "CreateSessionLiveErrors";
116 private static final String SCEN_SESSION_PROFILES
= "SessionProfile";
120 // ------------------------------------------------------------------------
122 // ------------------------------------------------------------------------
123 private String fTestfile
;
124 protected final @NonNull LTTngToolsFileShell fShell
= new LTTngToolsFileShell();
125 protected ILttngControlService fService
;
127 // ------------------------------------------------------------------------
129 // ------------------------------------------------------------------------
132 * Perform pre-test initialization.
135 * if the initialization fails for some reason
138 public void setUp() throws Exception
{
139 URL location
= FileLocator
.find(FrameworkUtil
.getBundle(this.getClass()), new Path(getTestDirectory() + File
.separator
+ getTestStream()), null);
140 File testfile
= new File(FileLocator
.toFileURL(location
).toURI());
141 fTestfile
= testfile
.getAbsolutePath();
142 fShell
.loadScenarioFile(fTestfile
);
143 fService
= getControlService();
144 if (fService
== null) {
145 throw new Exception("Unable to obtain a valid ControlService");
148 ControlPreferences
.getInstance().init(Activator
.getDefault().getPreferenceStore());
152 * @return the string of the test directory to use
154 protected String
getTestDirectory() {
159 * @return the LttngCon
161 protected ILttngControlService
getControlService() {
162 return new LTTngControlService(fShell
);
166 * @return the shell implementation
168 public @NonNull LTTngToolsFileShell
getShell() {
175 protected String
getTestStream() {
180 public void tearDown() {
182 ControlPreferences
.getInstance().dispose();
185 // ------------------------------------------------------------------------
187 // ------------------------------------------------------------------------
190 public void testVersion() {
192 fShell
.setScenario(SCEN_LTTNG_VERSION
);
193 ILttngControlService service
= LTTngControlServiceFactory
.getLttngControlService(fShell
);
194 assertNotNull(service
);
195 assertEquals("2.1.0", service
.getVersionString());
196 } catch (ExecutionException e
) {
197 fail("Exeption thrown " + e
);
202 public void testVersionWithPrompt() {
204 fShell
.setScenario(SCEN_LTTNG_VERSION_WITH_PROMPT
);
205 ILttngControlService service
= LTTngControlServiceFactory
.getLttngControlService(fShell
);
206 assertNotNull(service
);
207 assertEquals("2.0.0", service
.getVersionString());
208 } catch (ExecutionException e
) {
209 fail("Exeption thrown " + e
);
213 @Test(expected
=ExecutionException
.class)
214 public void testUnsupportedVersion() throws ExecutionException
{
215 fShell
.setScenario(SCEN_LTTNG_UNSUPPORTED_VERSION
);
216 LTTngControlServiceFactory
.getLttngControlService(fShell
);
220 public void testNoVersion() {
222 fShell
.setScenario(SCEN_LTTNG_NO_VERSION
);
223 LTTngControlServiceFactory
.getLttngControlService(fShell
);
224 fail("No exeption thrown");
225 } catch (ExecutionException e
) {
231 public void testVersionCompiled() {
233 fShell
.setScenario(SCEN_LTTNG_COMPILED_VERSION
);
234 ILttngControlService service
= LTTngControlServiceFactory
.getLttngControlService(fShell
);
235 assertNotNull(service
);
236 assertEquals("2.5.0", service
.getVersionString());
237 } catch (ExecutionException e
) {
238 fail("Exeption thrown " + e
);
244 public void testLttngNotInstalled() {
246 fShell
.setScenario(SCEN_LTTNG_NOT_INSTALLED
);
247 fService
.getSessionNames(new NullProgressMonitor());
248 fail("No exeption thrown");
249 } catch (ExecutionException e
) {
255 public void testGetSessionNames1() {
257 fShell
.setScenario(SCEN_NO_SESSION_AVAILABLE
);
258 List
<String
> result
= fService
.getSessionNames(new NullProgressMonitor());
260 assertNotNull(result
);
261 assertEquals(0, result
.size());
263 } catch (ExecutionException e
) {
269 public void testGetSessionNames2() {
271 fShell
.setScenario(SCEN_GET_SESSION_NAMES1
);
272 List
<String
> result
= fService
.getSessionNames(new NullProgressMonitor());
274 assertNotNull(result
);
275 assertEquals(2, result
.size());
276 assertEquals("mysession1", result
.get(0));
277 assertEquals("mysession", result
.get(1));
279 } catch (ExecutionException e
) {
285 public void testGetSessionNamesWithTracingGroup() {
287 fShell
.setScenario(SCEN_GET_SESSION_WITH_GROUP
);
288 ControlPreferences
.getInstance().getPreferenceStore().setValue(
289 ControlPreferences
.TRACE_CONTROL_TRACING_GROUP_PREF
, "group");
291 List
<String
> result
= fService
.getSessionNames(new NullProgressMonitor());
293 assertNotNull(result
);
294 assertEquals(2, result
.size());
295 assertEquals("mysession1", result
.get(0));
296 assertEquals("mysession", result
.get(1));
298 ControlCommandLogger
.init(ControlPreferences
.getInstance().getLogfilePath(), false);
299 ControlPreferences
.getInstance().getPreferenceStore().setValue(
300 ControlPreferences
.TRACE_CONTROL_TRACING_GROUP_PREF
, ControlPreferences
.TRACE_CONTROL_DEFAULT_TRACING_GROUP
);
303 } catch (ExecutionException e
) {
310 public void testGetSessionNotExist() {
312 fShell
.setScenario(SCEN_GET_SESSION_NAME_NOT_EXIST
);
313 fService
.getSessionNames(new NullProgressMonitor());
314 fail("No exeption thrown");
316 } catch (ExecutionException e
) {
322 public void testGetSessionNotExistVerbose() {
325 fShell
.setScenario(SCEN_GET_SESSION_NAME_NOT_EXIST_VERBOSE
);
326 fService
.getSessionNames(new NullProgressMonitor());
327 fail("No exeption thrown");
329 } catch (ExecutionException e
) {
337 public void testGetSessionNameGarbage() {
339 fShell
.setScenario(SCEN_GET_SESSION_GARBAGE_OUT
);
340 List
<String
> result
= fService
.getSessionNames(new NullProgressMonitor());
342 assertNotNull(result
);
343 assertEquals(0, result
.size());
345 } catch (ExecutionException e
) {
351 public void testGetSession1() {
353 fShell
.setScenario(SCEN_GET_SESSION1
);
354 ISessionInfo session
= fService
.getSession("mysession", new NullProgressMonitor());
357 assertNotNull(session
);
358 assertEquals("mysession", session
.getName());
359 assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session
.getSessionPath());
360 assertEquals(TraceSessionState
.ACTIVE
, session
.getSessionState());
362 IDomainInfo
[] domains
= session
.getDomains();
363 assertNotNull(domains
);
364 assertEquals(2, domains
.length
);
366 // Verify Kernel domain
367 assertEquals("Kernel", domains
[0].getName());
368 IChannelInfo
[] channels
= domains
[0].getChannels();
369 assertNotNull(channels
);
370 assertEquals(2, channels
.length
);
372 // Verify Kernel's channel0
373 assertEquals("channel0", channels
[0].getName());
374 assertEquals(4, channels
[0].getNumberOfSubBuffers());
375 assertEquals("splice()", channels
[0].getOutputType().getInName());
376 assertEquals(TraceChannelOutputType
.SPLICE
, channels
[0].getOutputType());
377 assertEquals(false, channels
[0].isOverwriteMode());
378 assertEquals(200, channels
[0].getReadTimer());
379 assertEquals(TraceEnablement
.ENABLED
, channels
[0].getState());
380 assertEquals(262144, channels
[0].getSubBufferSize());
381 assertEquals(0, channels
[0].getSwitchTimer());
384 IEventInfo
[] channel0Events
= channels
[0].getEvents();
385 assertNotNull(channel0Events
);
386 assertEquals(2, channel0Events
.length
);
387 assertEquals("block_rq_remap", channel0Events
[0].getName());
388 assertEquals(TraceLogLevel
.TRACE_EMERG
, channel0Events
[0].getLogLevel());
389 assertEquals(TraceEventType
.TRACEPOINT
, channel0Events
[0].getEventType());
390 assertEquals(TraceEnablement
.ENABLED
, channel0Events
[0].getState());
392 assertEquals("block_bio_remap", channel0Events
[1].getName());
393 assertEquals(TraceLogLevel
.TRACE_EMERG
, channel0Events
[1].getLogLevel());
394 assertEquals(TraceEventType
.TRACEPOINT
, channel0Events
[1].getEventType());
395 assertEquals(TraceEnablement
.DISABLED
, channel0Events
[1].getState());
397 // Verify Kernel's channel1
398 assertEquals("channel1", channels
[1].getName());
399 assertEquals(4, channels
[1].getNumberOfSubBuffers());
400 assertEquals("splice()", channels
[1].getOutputType().getInName());
401 assertEquals(TraceChannelOutputType
.SPLICE
, channels
[1].getOutputType());
402 assertEquals(true, channels
[1].isOverwriteMode());
403 assertEquals(400, channels
[1].getReadTimer());
404 assertEquals(TraceEnablement
.DISABLED
, channels
[1].getState());
405 assertEquals(524288, channels
[1].getSubBufferSize());
406 assertEquals(100, channels
[1].getSwitchTimer());
409 IEventInfo
[] channel1Events
= channels
[1].getEvents();
410 assertEquals(0, channel1Events
.length
);
412 // Verify domain UST global
413 assertEquals("UST global", domains
[1].getName());
415 IChannelInfo
[] ustChannels
= domains
[1].getChannels();
417 // Verify UST global's mychannel1
418 assertEquals("mychannel1", ustChannels
[0].getName());
419 assertEquals(8, ustChannels
[0].getNumberOfSubBuffers());
420 assertEquals("mmap()", ustChannels
[0].getOutputType().getInName());
421 assertEquals(TraceChannelOutputType
.MMAP
, ustChannels
[0].getOutputType());
422 assertEquals(true, ustChannels
[0].isOverwriteMode());
423 assertEquals(100, ustChannels
[0].getReadTimer());
424 assertEquals(TraceEnablement
.DISABLED
, ustChannels
[0].getState());
425 assertEquals(8192, ustChannels
[0].getSubBufferSize());
426 assertEquals(200, ustChannels
[0].getSwitchTimer());
429 IEventInfo
[] ustEvents
= ustChannels
[0].getEvents();
430 assertEquals(0, ustEvents
.length
);
432 // Verify UST global's channel0
433 assertEquals("channel0", ustChannels
[1].getName());
434 assertEquals(4, ustChannels
[1].getNumberOfSubBuffers());
435 assertEquals("mmap()", ustChannels
[1].getOutputType().getInName());
436 assertEquals(TraceChannelOutputType
.MMAP
, ustChannels
[1].getOutputType());
437 assertEquals(false, ustChannels
[1].isOverwriteMode());
438 assertEquals(200, ustChannels
[1].getReadTimer());
439 assertEquals(TraceEnablement
.ENABLED
, ustChannels
[1].getState());
440 assertEquals(4096, ustChannels
[1].getSubBufferSize());
441 assertEquals(0, ustChannels
[1].getSwitchTimer());
444 ustEvents
= ustChannels
[1].getEvents();
445 assertEquals(2, ustEvents
.length
);
447 assertEquals("ust_tests_hello:tptest_sighandler", ustEvents
[0].getName());
448 assertEquals(TraceLogLevel
.TRACE_DEBUG_LINE
, ustEvents
[0].getLogLevel());
449 assertEquals(TraceEventType
.TRACEPOINT
, ustEvents
[0].getEventType());
450 assertEquals(TraceEnablement
.DISABLED
, ustEvents
[0].getState());
452 assertEquals("*", ustEvents
[1].getName());
453 assertEquals(getAllEventTraceLogLevel(), ustEvents
[1].getLogLevel());
454 assertEquals(TraceEventType
.TRACEPOINT
, ustEvents
[1].getEventType());
455 assertEquals(TraceEnablement
.ENABLED
, ustEvents
[1].getState());
457 // next session (no detailed information available)
458 session
= fService
.getSession("mysession1", new NullProgressMonitor());
459 assertNotNull(session
);
460 assertEquals("mysession1", session
.getName());
461 assertEquals("/home/user/lttng-traces/mysession1-20120203-133225", session
.getSessionPath());
462 assertEquals(TraceSessionState
.INACTIVE
, session
.getSessionState());
464 domains
= session
.getDomains();
465 assertNotNull(domains
);
466 assertEquals(0, domains
.length
);
467 } catch (ExecutionException e
) {
473 public void testGetSessionWithLive() {
475 fShell
.setScenario(SCEN_GET_SESSION_WITH_LIVE
);
477 // Verify Session (snapshot session, non-live)
478 ISessionInfo session
= fService
.getSession("mysession", new NullProgressMonitor());
479 assertNotNull(session
);
480 assertEquals("mysession", session
.getName());
481 assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session
.getSessionPath());
482 assertEquals(TraceSessionState
.INACTIVE
, session
.getSessionState());
483 assertFalse(session
.isLive());
485 // Verify Session (regular session, non-live)
486 session
= fService
.getSession("mysession1", new NullProgressMonitor());
487 assertNotNull(session
);
488 assertEquals("mysession1", session
.getName());
489 assertEquals("/home/user/lttng-traces/mysession1-20120129-084256", session
.getSessionPath());
490 assertEquals(TraceSessionState
.ACTIVE
, session
.getSessionState());
491 assertFalse(session
.isLive());
493 // Verify Session (regular session, live)
494 session
= fService
.getSession("mysession2", new NullProgressMonitor());
495 assertNotNull(session
);
496 assertEquals("mysession2", session
.getName());
497 assertEquals("tcp4://172.0.0.1:5342/ [data: 5343]", session
.getSessionPath());
498 assertEquals("net://127.0.0.1", session
.getLiveUrl());
499 assertEquals(Integer
.valueOf(5344), session
.getLivePort());
500 assertEquals(1000000, session
.getLiveDelay());
501 assertEquals(TraceSessionState
.INACTIVE
, session
.getSessionState());
502 assertTrue(session
.isLive());
504 } catch (ExecutionException e
) {
512 protected TraceLogLevel
getAllEventTraceLogLevel() {
513 return TraceLogLevel
.LEVEL_UNKNOWN
;
516 public void testGetKernelProvider() {
518 fShell
.setScenario(SCEN_GET_KERNEL_PROVIDER1
);
519 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
522 assertNotNull(events
);
523 assertEquals(3, events
.size());
525 IBaseEventInfo baseEventInfo
= events
.get(0);
526 assertNotNull(baseEventInfo
);
527 assertEquals("sched_kthread_stop", baseEventInfo
.getName());
528 assertEquals(TraceLogLevel
.TRACE_EMERG
, baseEventInfo
.getLogLevel());
529 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
531 baseEventInfo
= events
.get(1);
532 assertEquals("sched_kthread_stop_ret", baseEventInfo
.getName());
533 assertEquals(TraceLogLevel
.TRACE_EMERG
, baseEventInfo
.getLogLevel());
534 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
536 baseEventInfo
= events
.get(2);
537 assertEquals("sched_wakeup_new", baseEventInfo
.getName());
538 assertEquals(TraceLogLevel
.TRACE_EMERG
, baseEventInfo
.getLogLevel());
539 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
541 } catch (ExecutionException e
) {
547 public void testGetKernelProviderNoKernel1() {
549 fShell
.setScenario(SCEN_LIST_WITH_NO_KERNEL1
);
550 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
553 assertNotNull(events
);
554 assertEquals(0, events
.size());
556 } catch (ExecutionException e
) {
562 public void testGetKernelProviderNoKernel2() {
564 fShell
.setScenario(SCEN_LIST_WITH_NO_KERNEL2
);
565 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
568 assertNotNull(events
);
569 assertEquals(0, events
.size());
571 } catch (ExecutionException e
) {
577 public void testGetKernelProviderNoKernelVerbose() {
580 fShell
.setScenario(SCEN_LIST_WITH_NO_KERNEL_VERBOSE
);
581 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
584 assertNotNull(events
);
585 assertEquals(0, events
.size());
587 } catch (ExecutionException e
) {
595 public void testGetUstProvider() {
597 fShell
.setScenario(SCEN_GET_UST_PROVIDER1
);
598 List
<IUstProviderInfo
> providers
= fService
.getUstProvider();
600 // Check all providers
601 assertNotNull(providers
);
602 assertEquals(2, providers
.size());
604 //Verify first provider
605 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(0).getName());
606 assertEquals(9379, providers
.get(0).getPid());
609 IBaseEventInfo
[] events
= providers
.get(0).getEvents();
610 assertNotNull(events
);
611 assertEquals(2, events
.length
);
613 IBaseEventInfo baseEventInfo
= events
[0];
614 assertNotNull(baseEventInfo
);
615 assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo
.getName());
616 assertEquals(TraceLogLevel
.TRACE_DEBUG_MODULE
, baseEventInfo
.getLogLevel());
617 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
619 baseEventInfo
= events
[1];
620 assertEquals("ust_tests_hello:tptest", baseEventInfo
.getName());
621 assertEquals(TraceLogLevel
.TRACE_INFO
, baseEventInfo
.getLogLevel());
622 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
624 //Verify second provider
625 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(1).getName());
626 assertEquals(4852, providers
.get(1).getPid());
629 events
= providers
.get(1).getEvents();
630 assertNotNull(events
);
631 assertEquals(2, events
.length
);
633 baseEventInfo
= events
[0];
634 assertNotNull(baseEventInfo
);
635 assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo
.getName());
636 assertEquals(TraceLogLevel
.TRACE_WARNING
, baseEventInfo
.getLogLevel());
637 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
639 baseEventInfo
= events
[1];
640 assertEquals("ust_tests_hello:tptest", baseEventInfo
.getName());
641 assertEquals(TraceLogLevel
.TRACE_DEBUG_FUNCTION
, baseEventInfo
.getLogLevel());
642 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
644 } catch (ExecutionException e
) {
650 public void testUstProvider2() {
652 fShell
.setScenario(SCEN_GET_UST_PROVIDER2
);
653 List
<IUstProviderInfo
> providers
= fService
.getUstProvider();
655 assertNotNull(providers
);
656 assertEquals(0, providers
.size());
658 } catch (ExecutionException e
) {
664 public void testGetUstProvider3() {
666 fShell
.setScenario(SCEN_GET_UST_PROVIDER3
);
668 ((LTTngControlService
)fService
).setVersion("2.1.0");
669 List
<IUstProviderInfo
> providers
= fService
.getUstProvider();
671 // Check all providers
672 assertNotNull(providers
);
673 assertEquals(2, providers
.size());
675 //Verify first provider
676 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(0).getName());
677 assertEquals(9379, providers
.get(0).getPid());
680 IBaseEventInfo
[] events
= providers
.get(0).getEvents();
681 assertNotNull(events
);
682 assertEquals(2, events
.length
);
684 IBaseEventInfo baseEventInfo
= events
[0];
685 assertNotNull(baseEventInfo
);
686 IFieldInfo
[] fields
= baseEventInfo
.getFields();
687 assertNotNull(fields
);
688 assertEquals(0, fields
.length
);
690 baseEventInfo
= events
[1];
691 fields
= baseEventInfo
.getFields();
692 assertNotNull(fields
);
693 assertEquals(3, fields
.length
);
694 assertEquals("doublefield", fields
[0].getName());
695 assertEquals("float", fields
[0].getFieldType());
697 assertEquals("floatfield", fields
[1].getName());
698 assertEquals("float", fields
[1].getFieldType());
700 assertEquals("stringfield", fields
[2].getName());
701 assertEquals("string", fields
[2].getFieldType());
703 //Verify second provider
704 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(1).getName());
705 assertEquals(4852, providers
.get(1).getPid());
708 events
= providers
.get(1).getEvents();
709 assertNotNull(events
);
710 assertEquals(2, events
.length
);
712 baseEventInfo
= events
[0];
713 assertNotNull(baseEventInfo
);
714 fields
= baseEventInfo
.getFields();
715 assertNotNull(fields
);
716 assertEquals(0, fields
.length
);
718 baseEventInfo
= events
[1];
719 fields
= baseEventInfo
.getFields();
720 assertNotNull(fields
);
721 assertEquals(3, fields
.length
);
723 assertEquals("doublefield", fields
[0].getName());
724 assertEquals("float", fields
[0].getFieldType());
726 assertEquals("floatfield", fields
[1].getName());
727 assertEquals("float", fields
[1].getFieldType());
729 assertEquals("stringfield", fields
[2].getName());
730 assertEquals("string", fields
[2].getFieldType());
733 ((LTTngControlService
)fService
).setVersion("2.0.0");
735 } catch (ExecutionException e
) {
742 public void testGetKernelProviderNoUst1() {
744 fShell
.setScenario(SCEN_LIST_WITH_NO_UST1
);
745 List
<IUstProviderInfo
> providerList
= fService
.getUstProvider(new NullProgressMonitor());
747 // Verify Provider info
748 assertNotNull(providerList
);
749 assertEquals(0, providerList
.size());
751 } catch (ExecutionException e
) {
758 public void testGetKernelProviderNoUst2() {
761 ((LTTngControlService
)fService
).setVersion("2.1.0");
763 fShell
.setScenario(SCEN_LIST_WITH_NO_UST2
);
764 List
<IUstProviderInfo
> providerList
= fService
.getUstProvider(new NullProgressMonitor());
766 // Verify Provider info
767 assertNotNull(providerList
);
768 assertEquals(0, providerList
.size());
771 ((LTTngControlService
)fService
).setVersion("2.0.0");
773 } catch (ExecutionException e
) {
779 public void testGetKernelProviderNoUst3() {
783 ((LTTngControlService
)fService
).setVersion("2.1.0");
785 fShell
.setScenario(SCEN_LIST_WITH_NO_UST3
);
786 List
<IUstProviderInfo
> providerList
= fService
.getUstProvider(new NullProgressMonitor());
788 // Verify provider info
789 assertNotNull(providerList
);
790 assertEquals(0, providerList
.size());
793 ((LTTngControlService
)fService
).setVersion("2.0.0");
795 } catch (ExecutionException e
) {
801 public void testGetKernelProviderNoUstVerbose() {
806 ((LTTngControlService
)fService
).setVersion("2.1.0");
808 fShell
.setScenario(SCEN_LIST_WITH_NO_UST_VERBOSE
);
809 List
<IUstProviderInfo
> providerList
= fService
.getUstProvider(new NullProgressMonitor());
811 // Verify provider info
812 assertNotNull(providerList
);
813 assertEquals(0, providerList
.size());
816 ((LTTngControlService
)fService
).setVersion("2.0.0");
818 } catch (ExecutionException e
) {
828 public void testCreateSession() {
830 fShell
.setScenario(SCEN_CREATE_SESSION1
);
832 ISessionInfo info
= fService
.createSession(new SessionInfo("mysession2"), new NullProgressMonitor());
834 assertEquals("mysession2", info
.getName());
835 assertNotNull(info
.getSessionPath());
836 assertTrue(info
.getSessionPath().contains("mysession2"));
837 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
838 } catch (ExecutionException e
) {
844 public void testCreateSessionWithPrompt() {
846 // First line has the shell prompt before the command output
847 // This can happen in a real application if the command line is not echoed by the shell.
848 fShell
.setScenario(SCEN_CREATE_SESSION_WITH_PROMPT
);
850 // First line has no shell prompt before the output
851 ISessionInfo info
= fService
.createSession(new SessionInfo("mysession2"), new NullProgressMonitor());
853 assertEquals("mysession2", info
.getName());
854 assertNotNull(info
.getSessionPath());
855 assertTrue(info
.getSessionPath().contains("mysession2"));
856 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
857 } catch (ExecutionException e
) {
863 public void testCreateSessionVariants() {
865 fShell
.setScenario(SCEN_CREATE_SESSION_VARIANTS
);
868 fService
.createSession(new SessionInfo("alreadyExist"), new NullProgressMonitor());
869 fail("No exeption thrown");
870 } catch (ExecutionException e
) {
875 fService
.createSession(new SessionInfo("wrongName"), new NullProgressMonitor());
876 fail("No exeption thrown");
877 } catch (ExecutionException e
) {
882 ISessionInfo sessionInfo
= new SessionInfo("withPath");
883 sessionInfo
.setSessionPath("/home/user/hallo");
884 fService
.createSession(sessionInfo
, new NullProgressMonitor());
885 fail("No exeption thrown");
886 } catch (ExecutionException e
) {
891 ISessionInfo info
= fService
.createSession(new SessionInfo("session with spaces"), new NullProgressMonitor());
893 assertEquals("session with spaces", info
.getName());
894 assertNotNull(info
.getSessionPath());
895 assertTrue(info
.getSessionPath().contains("session with spaces"));
896 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
898 } catch (ExecutionException e
) {
903 ISessionInfo sessionInfo
= new SessionInfo("pathWithSpaces");
904 sessionInfo
.setSessionPath("/home/user/hallo user/here");
905 ISessionInfo info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
907 assertEquals("pathWithSpaces", info
.getName());
908 assertNotNull(info
.getSessionPath());
909 assertTrue(info
.getSessionPath().contains("/home/user/hallo user/here"));
910 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
912 } catch (ExecutionException e
) {
918 public void testDestroySession() {
920 fShell
.setScenario(SCEN_DESTROY_SESSION1
);
921 fService
.destroySession("mysession2", new NullProgressMonitor());
922 } catch (ExecutionException e
) {
928 public void testDestroySessionVerbose() {
931 fShell
.setScenario(SCEN_DESTROY_SESSION_VERBOSE
);
932 fService
.destroySession("mysession2", new NullProgressMonitor());
933 } catch (ExecutionException e
) {
941 public void testCreateChannel() {
943 ((LTTngControlService
)fService
).setVersion("2.2.0");
944 String sessionName
= "mysession2";
945 List
<String
> list
= new ArrayList
<>();
946 String kernelChannel0
= "mychannel0";
947 String kernelChannel1
= "mychannel1";
948 list
.add(kernelChannel0
);
949 list
.add(kernelChannel1
);
951 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
953 // Create/enable/configure 2 kernel channels
954 ChannelInfo chanInfo
= new ChannelInfo("");
955 chanInfo
.setOverwriteMode(true);
956 chanInfo
.setSubBufferSize(16384);
957 chanInfo
.setReadTimer(100);
958 chanInfo
.setSwitchTimer(200);
959 chanInfo
.setNumberOfSubBuffers(2);
960 chanInfo
.setMaxNumberTraceFiles(10);
961 chanInfo
.setMaxSizeTraceFiles(0);
962 fService
.enableChannels(sessionName
, list
, true, chanInfo
, new NullProgressMonitor());
964 // Create/enable/configure 1 UST channel
966 list
.add("ustChannel");
968 chanInfo
= new ChannelInfo("");
969 chanInfo
.setOverwriteMode(true);
970 chanInfo
.setSubBufferSize(32768);
971 chanInfo
.setReadTimer(200);
972 chanInfo
.setSwitchTimer(100);
973 chanInfo
.setNumberOfSubBuffers(1);
974 chanInfo
.setMaxNumberTraceFiles(20);
975 chanInfo
.setMaxSizeTraceFiles(0);
976 fService
.enableChannels(sessionName
, list
, false, chanInfo
, new NullProgressMonitor());
977 ((LTTngControlService
)fService
).setVersion("2.0.0");
979 } catch (ExecutionException e
) {
985 public void testCreateChannelUIDBuffer() {
987 ((LTTngControlService
)fService
).setVersion("2.2.0");
988 String sessionName
= "mysession2";
989 List
<String
> list
= new ArrayList
<>();
990 String USTChannel
= "ustChannel";
991 list
.add(USTChannel
);
992 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
994 ChannelInfo chanInfo
= new ChannelInfo("");
995 chanInfo
.setOverwriteMode(true);
996 chanInfo
.setSubBufferSize(32768);
997 chanInfo
.setReadTimer(200);
998 chanInfo
.setSwitchTimer(100);
999 chanInfo
.setNumberOfSubBuffers(1);
1000 chanInfo
.setMaxNumberTraceFiles(20);
1001 chanInfo
.setMaxSizeTraceFiles(0);
1002 chanInfo
.setBufferType(BufferType
.BUFFER_PER_UID
);
1003 fService
.enableChannels(sessionName
, list
, false, chanInfo
, new NullProgressMonitor());
1004 ((LTTngControlService
)fService
).setVersion("2.0.0");
1006 } catch (ExecutionException e
) {
1012 public void testCreateChannelPIDBuffer() {
1014 ((LTTngControlService
)fService
).setVersion("2.2.0");
1015 String sessionName
= "mysession2";
1016 List
<String
> list
= new ArrayList
<>();
1017 String USTChannel
= "ustChannel";
1018 list
.add(USTChannel
);
1019 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
1022 ChannelInfo chanInfo
= new ChannelInfo("");
1023 chanInfo
.setOverwriteMode(true);
1024 chanInfo
.setSubBufferSize(-1);
1025 chanInfo
.setReadTimer(-1);
1026 chanInfo
.setSwitchTimer(-1);
1027 chanInfo
.setNumberOfSubBuffers(-1);
1028 chanInfo
.setMaxNumberTraceFiles(-1);
1029 chanInfo
.setMaxSizeTraceFiles(-1);
1030 chanInfo
.setBufferType(BufferType
.BUFFER_PER_PID
);
1032 fService
.enableChannels(sessionName
, list
, false, chanInfo
, new NullProgressMonitor());
1033 ((LTTngControlService
)fService
).setVersion("2.0.0");
1035 } catch (ExecutionException e
) {
1041 public void testDisableChannel() {
1044 String sessionName
= "mysession2";
1045 List
<String
> list
= new ArrayList
<>();
1046 String kernelChannel0
= "mychannel0";
1047 String kernelChannel1
= "mychannel1";
1048 list
.add(kernelChannel0
);
1049 list
.add(kernelChannel1
);
1051 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
1052 fService
.disableChannels(sessionName
, list
, true, new NullProgressMonitor());
1055 list
.add("ustChannel");
1056 fService
.disableChannels(sessionName
, list
, false, new NullProgressMonitor());
1058 } catch (ExecutionException e
) {
1064 public void testEnableChannel() {
1067 String sessionName
= "mysession2";
1068 List
<String
> list
= new ArrayList
<>();
1069 String kernelChannel0
= "mychannel0";
1070 String kernelChannel1
= "mychannel1";
1071 list
.add(kernelChannel0
);
1072 list
.add(kernelChannel1
);
1074 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
1075 fService
.enableChannels(sessionName
, list
, true, null, new NullProgressMonitor());
1077 // Create/enable/configure 1 UST channel
1079 list
.add("ustChannel");
1081 fService
.enableChannels(sessionName
, list
, false, null, new NullProgressMonitor());
1083 } catch (ExecutionException e
) {
1089 public void testEnableEvents() {
1091 // 1) session name, channel = null, 3 event names, kernel
1092 String sessionName
= "mysession2";
1093 List
<String
> list
= new ArrayList
<>();
1094 String eventName0
= "block_rq_remap";
1095 String eventName1
= "block_bio_remap";
1096 String eventName2
= "softirq_entry";
1097 list
.add(eventName0
);
1098 list
.add(eventName1
);
1099 list
.add(eventName2
);
1100 fShell
.setScenario(SCEN_EVENT_HANDLING
);
1101 fService
.enableEvents(sessionName
, null, list
, true, null, new NullProgressMonitor());
1103 // 2) session name, channel=mychannel, event name= null, kernel
1104 String channelName
= "mychannel";
1105 fService
.enableEvents(sessionName
, channelName
, null, true, null, new NullProgressMonitor());
1107 // 3) session name, channel=mychannel, 1 event name, ust, no filter
1108 String ustEventName
= "ust_tests_hello:tptest_sighandler";
1110 list
.add(ustEventName
);
1111 fService
.enableEvents(sessionName
, channelName
, list
, false, null, new NullProgressMonitor());
1113 // 4) session name, channel = mychannel, no event name, ust, with filter
1114 fService
.enableEvents(sessionName
, channelName
, list
, false, "intfield==10", new NullProgressMonitor());
1116 // 5) session name, channel = mychannel, no event name, ust, no filter
1118 fService
.enableEvents(sessionName
, channelName
, list
, false, null, new NullProgressMonitor());
1120 // TODO add test with filters
1122 } catch (ExecutionException e
) {
1128 public void testEnableSyscalls() {
1130 // 1) session name, channel = null, 3 event names, kernel
1131 String sessionName
= "mysession2";
1132 String channelName
= "mychannel";
1134 fShell
.setScenario(SCEN_EVENT_HANDLING
);
1136 // 1) session name, channel = null
1137 fService
.enableSyscalls(sessionName
, null, new NullProgressMonitor());
1139 // 2) session name, channel = mychannel
1140 fService
.enableSyscalls(sessionName
, channelName
, new NullProgressMonitor());
1142 } catch (ExecutionException e
) {
1148 public void testDynamicProbe() {
1150 // 1) session name, channel = null, 3 event names, kernel
1151 String sessionName
= "mysession2";
1152 String channelName
= "mychannel";
1153 String eventName0
= "myevent0";
1154 String eventName1
= "myevent1";
1155 String functionProbe
= "0xc0101340";
1156 String dynProbe
= "init_post";
1158 fShell
.setScenario(SCEN_EVENT_HANDLING
);
1160 // 1) session name, channel = null, event name, function probe, probe
1161 fService
.enableProbe(sessionName
, null, eventName0
, true, functionProbe
, new NullProgressMonitor());
1163 // 2) session name, channel = mychannel
1164 fService
.enableProbe(sessionName
, channelName
, eventName1
, false, dynProbe
, new NullProgressMonitor());
1166 } catch (ExecutionException e
) {
1172 public void testEnableLogLevel() {
1174 // 1) session name, channel = null, 3 event names, kernel
1175 String sessionName
= "mysession2";
1176 String channelName
= "mychannel";
1177 String eventName4
= "myevent4";
1178 String eventName5
= "myevent5";
1180 fShell
.setScenario(SCEN_EVENT_HANDLING
);
1182 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
1183 fService
.enableLogLevel(sessionName
, null, eventName4
, LogLevelType
.LOGLEVEL_ONLY
, TraceLogLevel
.TRACE_DEBUG
, null, new NullProgressMonitor());
1185 // 2) session name, channel = mychannel, null, loglevel, TRACE_DEBUG_FUNCTION
1186 fService
.enableLogLevel(sessionName
, channelName
, eventName5
, LogLevelType
.LOGLEVEL
, TraceLogLevel
.TRACE_DEBUG_FUNCTION
, null, new NullProgressMonitor());
1188 // TODO add test with filters
1190 } catch (ExecutionException e
) {
1196 public void testAddContext() {
1198 // 1) session name, channel = null, 3 event names, kernel
1199 String sessionName
= "mysession2";
1200 String channelName
= "mychannel";
1201 String eventName
= "ust_tests_hello:tptest_sighandler";
1202 List
<String
> contexts
= new ArrayList
<>();
1203 contexts
.add("prio");
1204 contexts
.add("pid");
1206 fShell
.setScenario(SCEN_CONTEXT_HANDLING
);
1208 List
<String
> availContexts
= fService
.getContextList(new NullProgressMonitor());
1209 assertNotNull(availContexts
);
1210 assertEquals(12, availContexts
.size());
1212 // A very "hard-coded" way to verify but it works ...
1213 Set
<String
> expectedContexts
= new HashSet
<>();
1214 expectedContexts
.add("pid");
1215 expectedContexts
.add("procname");
1216 expectedContexts
.add("prio");
1217 expectedContexts
.add("nice");
1218 expectedContexts
.add("vpid");
1219 expectedContexts
.add("tid");
1220 expectedContexts
.add("pthread_id");
1221 expectedContexts
.add("vtid");
1222 expectedContexts
.add("ppid");
1223 expectedContexts
.add("vppid");
1224 expectedContexts
.add("perf:cpu-cycles");
1225 expectedContexts
.add("perf:cycles");
1227 assertTrue(expectedContexts
.containsAll(availContexts
));
1229 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
1230 fService
.addContexts(sessionName
, channelName
, eventName
, false, contexts
, new NullProgressMonitor());
1232 } catch (ExecutionException e
) {
1238 public void testAddContextFailure() {
1240 // 1) session name, channel = null, 3 event names, kernel
1241 String sessionName
= "mysession2";
1242 String channelName
= "mychannel";
1243 String eventName
= "ust_tests_hello:tptest_sighandler";
1244 List
<String
> contexts
= new ArrayList
<>();
1245 contexts
.add("prio");
1246 contexts
.add("pid");
1247 fShell
.setScenario(SCEN_CONTEXT_ERROR_HANDLING
);
1249 fService
.getContextList(new NullProgressMonitor());
1250 fail("No exeption generated");
1251 } catch (ExecutionException e
) {
1255 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
1256 fService
.addContexts(sessionName
, channelName
, eventName
, false, contexts
, new NullProgressMonitor());
1257 fail("No exeption generated");
1258 } catch (ExecutionException e
) {
1264 public void testCreateSession2_1() {
1267 fShell
.setScenario(SCEN_CREATE_SESSION_2_1
);
1269 ISessionInfo sessionInfo
= new SessionInfo("mysession");
1270 sessionInfo
.setNetworkUrl("net://172.0.0.1");
1271 sessionInfo
.setStreamedTrace(true);
1272 ISessionInfo info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1273 assertNotNull(info
);
1274 assertEquals("mysession", info
.getName());
1275 assertEquals("net://172.0.0.1", info
.getSessionPath());
1276 assertTrue(info
.isStreamedTrace());
1277 fService
.destroySession("mysession", new NullProgressMonitor());
1279 sessionInfo
= new SessionInfo("mysession");
1280 sessionInfo
.setStreamedTrace(true);
1281 sessionInfo
.setNetworkUrl("file:///tmp");
1282 info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1283 assertNotNull(info
);
1284 assertEquals("mysession", info
.getName());
1285 assertEquals("file:///tmp", info
.getSessionPath());
1286 assertTrue(!info
.isStreamedTrace());
1287 fService
.destroySession("mysession", new NullProgressMonitor());
1289 sessionInfo
= new SessionInfo("mysession");
1290 sessionInfo
.setStreamedTrace(true);
1291 sessionInfo
.setNetworkUrl("file:///tmp");
1292 info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1293 assertNotNull(info
);
1294 assertEquals("mysession", info
.getName());
1295 assertEquals("file:///tmp", info
.getSessionPath());
1296 assertTrue(!info
.isStreamedTrace());
1297 fService
.destroySession("mysession", new NullProgressMonitor());
1299 sessionInfo
= new SessionInfo("mysession");
1300 sessionInfo
.setStreamedTrace(true);
1301 sessionInfo
.setControlUrl("tcp://172.0.0.1");
1302 sessionInfo
.setDataUrl("tcp://172.0.0.1:5343");
1303 info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1304 assertNotNull(info
);
1305 assertEquals("mysession", info
.getName());
1306 assertEquals("", info
.getSessionPath()); // the complete network path is not available at this point
1307 assertTrue(info
.isStreamedTrace());
1308 fService
.destroySession("mysession", new NullProgressMonitor());
1310 sessionInfo
= new SessionInfo("mysession");
1311 sessionInfo
.setStreamedTrace(true);
1312 sessionInfo
.setNetworkUrl("net://172.0.0.1:1234:2345");
1313 info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1314 assertNotNull(info
);
1315 assertEquals("mysession", info
.getName());
1316 assertEquals("net://172.0.0.1:1234:2345", info
.getSessionPath());
1317 assertTrue(info
.isStreamedTrace());
1318 fService
.destroySession("mysession", new NullProgressMonitor());
1322 sessionInfo
= new SessionInfo("mysession");
1323 sessionInfo
.setStreamedTrace(true);
1324 sessionInfo
.setNetworkUrl("net://172.0.0.1");
1325 info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1326 assertNotNull(info
);
1327 assertEquals("mysession", info
.getName());
1328 assertEquals("net://172.0.0.1", info
.getSessionPath());
1329 assertTrue(info
.isStreamedTrace());
1331 fService
.destroySession("mysession", new NullProgressMonitor());
1334 } catch (ExecutionException e
) {
1340 public void testCreateSessionVerbose2_1() {
1342 fShell
.setScenario(SCEN_CREATE_SESSION_VERBOSE_2_1
);
1345 ISessionInfo sessionInfo
= new SessionInfo("mysession");
1346 sessionInfo
.setStreamedTrace(true);
1347 sessionInfo
.setNetworkUrl("net://172.0.0.1");
1348 ISessionInfo info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1349 assertNotNull(info
);
1350 assertEquals("mysession", info
.getName());
1351 assertEquals("net://172.0.0.1", info
.getSessionPath());
1352 assertTrue(info
.isStreamedTrace());
1353 fService
.destroySession("mysession", new NullProgressMonitor());
1354 } catch (ExecutionException e
) {
1362 public void testCreateSnapshotSession() {
1364 fShell
.setScenario(SCEN_CREATE_SNAPSHOT_SESSION
);
1365 ISessionInfo params
= new SessionInfo("mysession");
1366 params
.setSnapshot(true);
1367 ISessionInfo sessionInfo
= fService
.createSession(params
, new NullProgressMonitor());
1368 assertNotNull(sessionInfo
);
1369 assertEquals("mysession", sessionInfo
.getName());
1370 assertTrue(sessionInfo
.isSnapshotSession());
1371 assertEquals("", sessionInfo
.getSessionPath());
1372 assertTrue(!sessionInfo
.isStreamedTrace());
1374 assertEquals(TraceSessionState
.INACTIVE
, sessionInfo
.getSessionState());
1376 List
<String
> names
= fService
.getSessionNames(new NullProgressMonitor());
1377 assertEquals(names
.get(0), "mysession");
1379 ISnapshotInfo snapshotInfo
= fService
.getSnapshotInfo("mysession", new NullProgressMonitor());
1380 assertNotNull(snapshotInfo
);
1381 assertEquals("snapshot-1", snapshotInfo
.getName());
1382 assertEquals("/home/user/lttng-traces/mysession-20130913-141651", snapshotInfo
.getSnapshotPath());
1383 assertEquals(1, snapshotInfo
.getId());
1384 assertTrue(!snapshotInfo
.isStreamedSnapshot());
1386 // we need to set the snapshotInfo to so that the session path is set correctly
1387 sessionInfo
.setSnapshotInfo(snapshotInfo
);
1388 assertEquals("/home/user/lttng-traces/mysession-20130913-141651", sessionInfo
.getSessionPath());
1390 fService
.recordSnapshot("mysession", new NullProgressMonitor());
1392 fService
.destroySession("mysession", new NullProgressMonitor());
1394 } catch (ExecutionException e
) {
1400 public void testCreateSnapshotSession2_5() {
1402 fShell
.setScenario(SCEN_CREATE_SNAPSHOT_SESSION_2_5
);
1403 ISessionInfo params
= new SessionInfo("mysession");
1404 params
.setSnapshot(true);
1405 ISessionInfo sessionInfo
= fService
.createSession(params
, new NullProgressMonitor());
1406 assertNotNull(sessionInfo
);
1407 assertEquals("mysession", sessionInfo
.getName());
1408 assertTrue(sessionInfo
.isSnapshotSession());
1409 assertEquals("", sessionInfo
.getSessionPath());
1410 assertTrue(!sessionInfo
.isStreamedTrace());
1412 assertEquals(TraceSessionState
.INACTIVE
, sessionInfo
.getSessionState());
1414 List
<String
> names
= fService
.getSessionNames(new NullProgressMonitor());
1415 assertEquals(names
.get(0), "mysession");
1417 ISnapshotInfo snapshotInfo
= fService
.getSnapshotInfo("mysession", new NullProgressMonitor());
1418 assertNotNull(snapshotInfo
);
1419 assertEquals("snapshot-1", snapshotInfo
.getName());
1420 assertEquals("/home/user/lttng-traces/mysession-20130913-141651", snapshotInfo
.getSnapshotPath());
1421 assertEquals(1, snapshotInfo
.getId());
1422 assertTrue(!snapshotInfo
.isStreamedSnapshot());
1424 // we need to set the snapshotInfo to so that the session path is set correctly
1425 sessionInfo
.setSnapshotInfo(snapshotInfo
);
1426 assertEquals("/home/user/lttng-traces/mysession-20130913-141651", sessionInfo
.getSessionPath());
1428 fService
.recordSnapshot("mysession", new NullProgressMonitor());
1430 fService
.destroySession("mysession", new NullProgressMonitor());
1432 } catch (ExecutionException e
) {
1437 public void testCreateStreamedSnapshotSession() {
1439 fShell
.setScenario(SCEN_CREATE_STREAMED_SNAPSHOT_SESSION
);
1441 ISessionInfo params
= new SessionInfo("mysession");
1442 params
.setNetworkUrl("net://172.0.0.1");
1443 ISessionInfo sessionInfo
= fService
.createSession(params
, new NullProgressMonitor());
1444 assertNotNull(sessionInfo
);
1445 assertEquals("mysession", sessionInfo
.getName());
1446 assertTrue(sessionInfo
.isSnapshotSession());
1448 assertEquals(TraceSessionState
.INACTIVE
, sessionInfo
.getSessionState());
1449 assertTrue(sessionInfo
.isStreamedTrace());
1451 List
<String
> names
= fService
.getSessionNames(new NullProgressMonitor());
1452 assertEquals(names
.get(0), "mysession");
1454 ISnapshotInfo snapshotInfo
= sessionInfo
.getSnapshotInfo();
1455 assertNotNull(sessionInfo
);
1456 assertEquals("snapshot-2", snapshotInfo
.getName());
1457 assertEquals("net4://172.0.0.1:5342/", snapshotInfo
.getSnapshotPath());
1458 assertEquals(2, snapshotInfo
.getId());
1459 assertTrue(snapshotInfo
.isStreamedSnapshot());
1461 // we need to set the snapshotInfo to so that the session path is set correctly
1462 sessionInfo
.setSnapshotInfo(snapshotInfo
);
1463 assertEquals("net4://172.0.0.1:5342/", sessionInfo
.getSessionPath());
1465 fService
.recordSnapshot("mysession", new NullProgressMonitor());
1467 fService
.destroySession("mysession", new NullProgressMonitor());
1469 } catch (ExecutionException e
) {
1475 public void testCreateSnapshotSessionErrors() {
1477 fShell
.setScenario(SCEN_CREATE_SNAPSHOT_SESSION_ERRORS
);
1479 List
<String
> names
= fService
.getSessionNames(new NullProgressMonitor());
1480 assertEquals(names
.get(0), "mysession");
1481 } catch (ExecutionException e
) {
1486 fService
.getSnapshotInfo("blabla", new NullProgressMonitor());
1487 fail("getSnapshoInfo() didn't fail");
1488 } catch (ExecutionException e
) {
1493 fService
.recordSnapshot("blabla", new NullProgressMonitor());
1494 fail("getSnapshoInfo() didn't fail");
1495 } catch (ExecutionException e
) {
1500 fService
.recordSnapshot("mysession", new NullProgressMonitor());
1501 fail("getSnapshoInfo() didn't fail");
1502 } catch (ExecutionException e
) {
1508 public void testCreateLiveSession() throws ExecutionException
{
1509 fShell
.setScenario(SCEN_CREATE_LIVE_SESSION
);
1511 ISessionInfo params
= new SessionInfo("mysession");
1512 params
.setLive(true);
1513 params
.setStreamedTrace(true);
1514 params
.setNetworkUrl("net://127.0.0.1");
1515 ISessionInfo sessionInfo
= fService
.createSession(params
, new NullProgressMonitor());
1516 assertNotNull(sessionInfo
);
1517 assertEquals("mysession", sessionInfo
.getName());
1518 assertEquals(TraceSessionState
.INACTIVE
, sessionInfo
.getSessionState());
1519 assertTrue(sessionInfo
.isStreamedTrace());
1520 assertTrue(sessionInfo
.isLive());
1521 assertEquals("net://127.0.0.1", sessionInfo
.getSessionPath());
1522 List
<String
> names
= fService
.getSessionNames(new NullProgressMonitor());
1523 assertEquals(names
.get(0), "mysession");
1524 fService
.destroySession("mysession", new NullProgressMonitor());
1528 public void testCreateLiveSessionErrors() {
1530 fShell
.setScenario(SCEN_CREATE_LIVE_SESSION_ERRORS
);
1532 ISessionInfo parameters
= new SessionInfo("mysession");
1533 parameters
.setLive(true);
1534 parameters
.setSnapshot(true);
1535 fService
.createSession(parameters
, new NullProgressMonitor());
1536 fail("createSession() didn't fail");
1537 } catch (ExecutionException e
) {
1542 ISessionInfo parameters
= new SessionInfo("mysession");
1543 parameters
.setNetworkUrl("blah");
1544 parameters
.setLive(true);
1545 fService
.createSession(parameters
, new NullProgressMonitor());
1546 fail("createSession() didn't fail");
1547 } catch (ExecutionException e
) {
1552 ISessionInfo parameters
= new SessionInfo("mysession");
1553 parameters
.setControlUrl("net://127.0.0.1");
1554 parameters
.setLive(true);
1555 fService
.createSession(parameters
, new NullProgressMonitor());
1556 fail("createSession() didn't fail");
1557 } catch (ExecutionException e
) {
1563 public void testSessionProfile() {
1564 fShell
.setScenario(SCEN_SESSION_PROFILES
);
1565 final String profile
= "/home/user/.lttng/sessions/mysession.lttng";
1567 fService
.loadSession(profile
, false, new NullProgressMonitor());
1568 } catch (ExecutionException e
) {
1569 fail("load session failed: " + e
);
1573 fService
.loadSession(profile
, true, new NullProgressMonitor());
1574 } catch (ExecutionException e
) {
1575 fail("load session failed: " + e
);
1579 fService
.saveSession(null, null, false, new NullProgressMonitor());
1580 } catch (ExecutionException e
) {
1581 fail("save session failed: " + e
);
1584 final String sessionName
= "mysession";
1586 fService
.saveSession(sessionName
, null, false, new NullProgressMonitor());
1587 } catch (ExecutionException e
) {
1588 fail("save session failed: " + e
);
1592 fService
.saveSession(sessionName
, null, true, new NullProgressMonitor());
1593 } catch (ExecutionException e
) {
1594 fail("save session failed: " + e
);
1598 fService
.saveSession(sessionName
, "/tmp/test", true, new NullProgressMonitor());
1599 } catch (ExecutionException e
) {
1600 fail("save session failed: " + e
);
1604 private static void enableVerbose() {
1606 ControlCommandLogger
.init(ControlPreferences
.getInstance().getLogfilePath(), false);
1607 ControlPreferences
.getInstance().getPreferenceStore().setDefault(ControlPreferences
.TRACE_CONTROL_LOG_COMMANDS_PREF
, true);
1608 ControlPreferences
.getInstance().getPreferenceStore().setDefault(ControlPreferences
.TRACE_CONTROL_VERBOSE_LEVEL_PREF
, ControlPreferences
.TRACE_CONTROL_VERBOSE_LEVEL_V_V_VERBOSE
);
1611 private static void disableVerbose() {
1612 ControlPreferences
.getInstance().getPreferenceStore().setDefault(ControlPreferences
.TRACE_CONTROL_LOG_COMMANDS_PREF
, false);