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
.Ignore
;
62 import org
.junit
.Test
;
63 import org
.osgi
.framework
.FrameworkUtil
;
66 * The class <code>LTTngControlServiceTest</code> contains test for the class
67 * <code>{@link LTTngControlService}</code>.
69 @SuppressWarnings("javadoc")
70 public class LTTngControlServiceTest
{
72 private static final String DIRECTORY
= "testfiles";
73 private static final String TEST_STREAM
= "LTTngServiceTest.cfg";
75 private static final String SCEN_LTTNG_NOT_INSTALLED
= "LttngNotInstalled";
76 protected static final String SCEN_LTTNG_VERSION
= "LttngVersion";
77 protected static final String SCEN_LTTNG_VERSION_WITH_PROMPT
= "LttngVersionWithPrompt";
78 private static final String SCEN_LTTNG_UNSUPPORTED_VERSION
= "LttngUnsupportedVersion";
79 private static final String SCEN_LTTNG_NO_VERSION
= "LttngNoVersion";
80 protected static final String SCEN_LTTNG_COMPILED_VERSION
= "LttngVersionCompiled";
81 private static final String SCEN_NO_SESSION_AVAILABLE
= "NoSessionAvailable";
82 private static final String SCEN_GET_SESSION_NAMES1
= "GetSessionNames1";
83 private static final String SCEN_GET_SESSION_WITH_GROUP
= "GetSessionWithTracingGroup";
84 private static final String SCEN_GET_SESSION_NAME_NOT_EXIST
= "GetSessionNameNotExist";
85 private static final String SCEN_GET_SESSION_NAME_NOT_EXIST_VERBOSE
= "GetSessionNameNotExistVerbose";
86 protected static final String SCEN_GET_SESSION_GARBAGE_OUT
= "GetSessionGarbageOut";
87 private static final String SCEN_GET_SESSION1
= "GetSession1";
88 private static final String SCEN_GET_SESSION_WITH_LIVE
= "GetSessionWithLiveInterval";
89 private static final String SCEN_GET_KERNEL_PROVIDER1
= "GetKernelProvider1";
90 private static final String SCEN_LIST_WITH_NO_KERNEL1
= "ListWithNoKernel1";
91 private static final String SCEN_LIST_WITH_NO_KERNEL2
= "ListWithNoKernel2";
92 private static final String SCEN_LIST_WITH_NO_KERNEL_VERBOSE
= "ListWithNoKernelVerbose";
93 private static final String SCEN_GET_UST_PROVIDER1
= "GetUstProvider1";
94 private static final String SCEN_GET_UST_PROVIDER2
= "GetUstProvider2";
95 private static final String SCEN_GET_UST_PROVIDER3
= "GetUstProvider3";
96 private static final String SCEN_LIST_WITH_NO_UST1
= "ListWithNoUst1";
97 private static final String SCEN_LIST_WITH_NO_UST2
= "ListWithNoUst2";
98 private static final String SCEN_LIST_WITH_NO_UST3
= "ListWithNoUst3";
99 private static final String SCEN_LIST_WITH_NO_UST_VERBOSE
= "ListWithNoUstVerbose";
100 private static final String SCEN_CREATE_SESSION1
= "CreateSession1";
101 private static final String SCEN_CREATE_SESSION_WITH_PROMPT
= "CreateSessionWithPrompt";
102 private static final String SCEN_CREATE_SESSION_VARIANTS
= "CreateSessionVariants";
103 private static final String SCEN_DESTROY_SESSION1
= "DestroySession1";
104 private static final String SCEN_DESTROY_SESSION_VERBOSE
= "DestroySessionVerbose";
105 private static final String SCEN_CHANNEL_HANDLING
= "ChannelHandling";
106 private static final String SCEN_EVENT_HANDLING
= "EventHandling";
107 private static final String SCEN_CONTEXT_HANDLING
= "ContextHandling";
108 private static final String SCEN_CONTEXT_ERROR_HANDLING
= "ContextErrorHandling";
109 private static final String SCEN_CREATE_SESSION_2_1
= "CreateSessionLttng2.1";
110 private static final String SCEN_CREATE_SESSION_VERBOSE_2_1
= "CreateSessionLttngVerbose2.1";
111 private static final String SCEN_CREATE_SNAPSHOT_SESSION
= "CreateSessionSnapshot";
112 private static final String SCEN_CREATE_SNAPSHOT_SESSION_2_5
= "CreateSessionSnapshot2.5";
113 private static final String SCEN_CREATE_STREAMED_SNAPSHOT_SESSION
= "CreateSessionStreamedSnapshot";
114 private static final String SCEN_CREATE_SNAPSHOT_SESSION_ERRORS
= "CreateSessionSnapshotErrors";
115 protected static final String SCEN_CREATE_LIVE_SESSION
= "CreateSessionLive";
116 private static final String SCEN_CREATE_LIVE_SESSION_ERRORS
= "CreateSessionLiveErrors";
117 private static final String SCEN_SESSION_PROFILES
= "SessionProfile";
121 // ------------------------------------------------------------------------
123 // ------------------------------------------------------------------------
124 private String fTestfile
;
125 protected final @NonNull LTTngToolsFileShell fShell
= new LTTngToolsFileShell();
126 protected ILttngControlService fService
;
128 // ------------------------------------------------------------------------
130 // ------------------------------------------------------------------------
133 * Perform pre-test initialization.
136 * if the initialization fails for some reason
139 public void setUp() throws Exception
{
140 URL location
= FileLocator
.find(FrameworkUtil
.getBundle(this.getClass()), new Path(getTestDirectory() + File
.separator
+ getTestStream()), null);
141 File testfile
= new File(FileLocator
.toFileURL(location
).toURI());
142 fTestfile
= testfile
.getAbsolutePath();
143 fShell
.loadScenarioFile(fTestfile
);
144 fService
= getControlService();
145 if (fService
== null) {
146 throw new Exception("Unable to obtain a valid ControlService");
149 ControlPreferences
.getInstance().init(Activator
.getDefault().getPreferenceStore());
153 * @return the string of the test directory to use
155 protected String
getTestDirectory() {
160 * @return the LttngCon
162 protected ILttngControlService
getControlService() {
163 return new LTTngControlService(fShell
);
167 * @return the shell implementation
169 public @NonNull LTTngToolsFileShell
getShell() {
176 protected String
getTestStream() {
181 public void tearDown() {
183 ControlPreferences
.getInstance().dispose();
186 // ------------------------------------------------------------------------
188 // ------------------------------------------------------------------------
191 public void testVersion() {
193 fShell
.setScenario(SCEN_LTTNG_VERSION
);
194 ILttngControlService service
= LTTngControlServiceFactory
.getLttngControlService(fShell
);
195 assertNotNull(service
);
196 assertEquals("2.1.0", service
.getVersionString());
197 } catch (ExecutionException e
) {
198 fail("Exeption thrown " + e
);
203 public void testVersionWithPrompt() {
205 fShell
.setScenario(SCEN_LTTNG_VERSION_WITH_PROMPT
);
206 ILttngControlService service
= LTTngControlServiceFactory
.getLttngControlService(fShell
);
207 assertNotNull(service
);
208 assertEquals("2.0.0", service
.getVersionString());
209 } catch (ExecutionException e
) {
210 fail("Exeption thrown " + e
);
214 @Test(expected
=ExecutionException
.class)
215 public void testUnsupportedVersion() throws ExecutionException
{
216 fShell
.setScenario(SCEN_LTTNG_UNSUPPORTED_VERSION
);
217 LTTngControlServiceFactory
.getLttngControlService(fShell
);
221 public void testNoVersion() {
223 fShell
.setScenario(SCEN_LTTNG_NO_VERSION
);
224 LTTngControlServiceFactory
.getLttngControlService(fShell
);
225 fail("No exeption thrown");
226 } catch (ExecutionException e
) {
232 public void testVersionCompiled() {
234 fShell
.setScenario(SCEN_LTTNG_COMPILED_VERSION
);
235 ILttngControlService service
= LTTngControlServiceFactory
.getLttngControlService(fShell
);
236 assertNotNull(service
);
237 assertEquals("2.5.0", service
.getVersionString());
238 } catch (ExecutionException e
) {
239 fail("Exeption thrown " + e
);
245 public void testLttngNotInstalled() {
247 fShell
.setScenario(SCEN_LTTNG_NOT_INSTALLED
);
248 fService
.getSessionNames(new NullProgressMonitor());
249 fail("No exeption thrown");
250 } catch (ExecutionException e
) {
256 public void testGetSessionNames1() {
258 fShell
.setScenario(SCEN_NO_SESSION_AVAILABLE
);
259 List
<String
> result
= fService
.getSessionNames(new NullProgressMonitor());
261 assertNotNull(result
);
262 assertEquals(0, result
.size());
264 } catch (ExecutionException e
) {
270 public void testGetSessionNames2() {
272 fShell
.setScenario(SCEN_GET_SESSION_NAMES1
);
273 List
<String
> result
= fService
.getSessionNames(new NullProgressMonitor());
275 assertNotNull(result
);
276 assertEquals(2, result
.size());
277 assertEquals("mysession1", result
.get(0));
278 assertEquals("mysession", result
.get(1));
280 } catch (ExecutionException e
) {
286 public void testGetSessionNamesWithTracingGroup() {
288 fShell
.setScenario(SCEN_GET_SESSION_WITH_GROUP
);
289 ControlPreferences
.getInstance().getPreferenceStore().setValue(
290 ControlPreferences
.TRACE_CONTROL_TRACING_GROUP_PREF
, "group");
292 List
<String
> result
= fService
.getSessionNames(new NullProgressMonitor());
294 assertNotNull(result
);
295 assertEquals(2, result
.size());
296 assertEquals("mysession1", result
.get(0));
297 assertEquals("mysession", result
.get(1));
299 ControlCommandLogger
.init(ControlPreferences
.getInstance().getLogfilePath(), false);
300 ControlPreferences
.getInstance().getPreferenceStore().setValue(
301 ControlPreferences
.TRACE_CONTROL_TRACING_GROUP_PREF
, ControlPreferences
.TRACE_CONTROL_DEFAULT_TRACING_GROUP
);
304 } catch (ExecutionException e
) {
311 public void testGetSessionNotExist() {
313 fShell
.setScenario(SCEN_GET_SESSION_NAME_NOT_EXIST
);
314 fService
.getSessionNames(new NullProgressMonitor());
315 fail("No exeption thrown");
317 } catch (ExecutionException e
) {
323 public void testGetSessionNotExistVerbose() {
326 fShell
.setScenario(SCEN_GET_SESSION_NAME_NOT_EXIST_VERBOSE
);
327 fService
.getSessionNames(new NullProgressMonitor());
328 fail("No exeption thrown");
330 } catch (ExecutionException e
) {
338 public void testGetSessionNameGarbage() {
340 fShell
.setScenario(SCEN_GET_SESSION_GARBAGE_OUT
);
341 List
<String
> result
= fService
.getSessionNames(new NullProgressMonitor());
343 assertNotNull(result
);
344 assertEquals(0, result
.size());
346 } catch (ExecutionException e
) {
352 public void testGetSession1() {
354 fShell
.setScenario(SCEN_GET_SESSION1
);
355 ISessionInfo session
= fService
.getSession("mysession", new NullProgressMonitor());
358 assertNotNull(session
);
359 assertEquals("mysession", session
.getName());
360 assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session
.getSessionPath());
361 assertEquals(TraceSessionState
.ACTIVE
, session
.getSessionState());
363 IDomainInfo
[] domains
= session
.getDomains();
364 assertNotNull(domains
);
365 assertEquals(2, domains
.length
);
367 // Verify Kernel domain
368 assertEquals("Kernel", domains
[0].getName());
369 IChannelInfo
[] channels
= domains
[0].getChannels();
370 assertNotNull(channels
);
371 assertEquals(2, channels
.length
);
373 // Verify Kernel's channel0
374 assertEquals("channel0", channels
[0].getName());
375 assertEquals(4, channels
[0].getNumberOfSubBuffers());
376 assertEquals("splice()", channels
[0].getOutputType().getInName());
377 assertEquals(TraceChannelOutputType
.SPLICE
, channels
[0].getOutputType());
378 assertEquals(false, channels
[0].isOverwriteMode());
379 assertEquals(200, channels
[0].getReadTimer());
380 assertEquals(TraceEnablement
.ENABLED
, channels
[0].getState());
381 assertEquals(262144, channels
[0].getSubBufferSize());
382 assertEquals(0, channels
[0].getSwitchTimer());
385 IEventInfo
[] channel0Events
= channels
[0].getEvents();
386 assertNotNull(channel0Events
);
387 assertEquals(2, channel0Events
.length
);
388 assertEquals("block_rq_remap", channel0Events
[0].getName());
389 assertEquals(TraceLogLevel
.TRACE_EMERG
, channel0Events
[0].getLogLevel());
390 assertEquals(TraceEventType
.TRACEPOINT
, channel0Events
[0].getEventType());
391 assertEquals(TraceEnablement
.ENABLED
, channel0Events
[0].getState());
393 assertEquals("block_bio_remap", channel0Events
[1].getName());
394 assertEquals(TraceLogLevel
.TRACE_EMERG
, channel0Events
[1].getLogLevel());
395 assertEquals(TraceEventType
.TRACEPOINT
, channel0Events
[1].getEventType());
396 assertEquals(TraceEnablement
.DISABLED
, channel0Events
[1].getState());
398 // Verify Kernel's channel1
399 assertEquals("channel1", channels
[1].getName());
400 assertEquals(4, channels
[1].getNumberOfSubBuffers());
401 assertEquals("splice()", channels
[1].getOutputType().getInName());
402 assertEquals(TraceChannelOutputType
.SPLICE
, channels
[1].getOutputType());
403 assertEquals(true, channels
[1].isOverwriteMode());
404 assertEquals(400, channels
[1].getReadTimer());
405 assertEquals(TraceEnablement
.DISABLED
, channels
[1].getState());
406 assertEquals(524288, channels
[1].getSubBufferSize());
407 assertEquals(100, channels
[1].getSwitchTimer());
410 IEventInfo
[] channel1Events
= channels
[1].getEvents();
411 assertEquals(0, channel1Events
.length
);
413 // Verify domain UST global
414 assertEquals("UST global", domains
[1].getName());
416 IChannelInfo
[] ustChannels
= domains
[1].getChannels();
418 // Verify UST global's mychannel1
419 assertEquals("mychannel1", ustChannels
[0].getName());
420 assertEquals(8, ustChannels
[0].getNumberOfSubBuffers());
421 assertEquals("mmap()", ustChannels
[0].getOutputType().getInName());
422 assertEquals(TraceChannelOutputType
.MMAP
, ustChannels
[0].getOutputType());
423 assertEquals(true, ustChannels
[0].isOverwriteMode());
424 assertEquals(100, ustChannels
[0].getReadTimer());
425 assertEquals(TraceEnablement
.DISABLED
, ustChannels
[0].getState());
426 assertEquals(8192, ustChannels
[0].getSubBufferSize());
427 assertEquals(200, ustChannels
[0].getSwitchTimer());
430 IEventInfo
[] ustEvents
= ustChannels
[0].getEvents();
431 assertEquals(0, ustEvents
.length
);
433 // Verify UST global's channel0
434 assertEquals("channel0", ustChannels
[1].getName());
435 assertEquals(4, ustChannels
[1].getNumberOfSubBuffers());
436 assertEquals("mmap()", ustChannels
[1].getOutputType().getInName());
437 assertEquals(TraceChannelOutputType
.MMAP
, ustChannels
[1].getOutputType());
438 assertEquals(false, ustChannels
[1].isOverwriteMode());
439 assertEquals(200, ustChannels
[1].getReadTimer());
440 assertEquals(TraceEnablement
.ENABLED
, ustChannels
[1].getState());
441 assertEquals(4096, ustChannels
[1].getSubBufferSize());
442 assertEquals(0, ustChannels
[1].getSwitchTimer());
445 ustEvents
= ustChannels
[1].getEvents();
446 assertEquals(2, ustEvents
.length
);
448 assertEquals("ust_tests_hello:tptest_sighandler", ustEvents
[0].getName());
449 assertEquals(TraceLogLevel
.TRACE_DEBUG_LINE
, ustEvents
[0].getLogLevel());
450 assertEquals(TraceEventType
.TRACEPOINT
, ustEvents
[0].getEventType());
451 assertEquals(TraceEnablement
.DISABLED
, ustEvents
[0].getState());
453 assertEquals("*", ustEvents
[1].getName());
454 assertEquals(getAllEventTraceLogLevel(), ustEvents
[1].getLogLevel());
455 assertEquals(TraceEventType
.TRACEPOINT
, ustEvents
[1].getEventType());
456 assertEquals(TraceEnablement
.ENABLED
, ustEvents
[1].getState());
458 // next session (no detailed information available)
459 session
= fService
.getSession("mysession1", new NullProgressMonitor());
460 assertNotNull(session
);
461 assertEquals("mysession1", session
.getName());
462 assertEquals("/home/user/lttng-traces/mysession1-20120203-133225", session
.getSessionPath());
463 assertEquals(TraceSessionState
.INACTIVE
, session
.getSessionState());
465 domains
= session
.getDomains();
466 assertNotNull(domains
);
467 assertEquals(0, domains
.length
);
468 } catch (ExecutionException e
) {
475 public void testGetSessionWithLive() {
477 fShell
.setScenario(SCEN_GET_SESSION_WITH_LIVE
);
479 // Verify Session (snapshot session, non-live)
480 ISessionInfo session
= fService
.getSession("mysession", new NullProgressMonitor());
481 assertNotNull(session
);
482 assertEquals("mysession", session
.getName());
483 assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session
.getSessionPath());
484 assertEquals(TraceSessionState
.INACTIVE
, session
.getSessionState());
485 assertFalse(session
.isLive());
487 // Verify Session (regular session, non-live)
488 session
= fService
.getSession("mysession1", new NullProgressMonitor());
489 assertNotNull(session
);
490 assertEquals("mysession1", session
.getName());
491 assertEquals("/home/user/lttng-traces/mysession1-20120129-084256", session
.getSessionPath());
492 assertEquals(TraceSessionState
.ACTIVE
, session
.getSessionState());
493 assertFalse(session
.isLive());
495 // Verify Session (regular session, live)
496 session
= fService
.getSession("mysession2", new NullProgressMonitor());
497 assertNotNull(session
);
498 assertEquals("mysession2", session
.getName());
499 assertEquals("tcp4://172.0.0.1:5342/ [data: 5343]", session
.getSessionPath());
500 assertEquals("net://127.0.0.1", session
.getLiveUrl());
501 assertEquals(Integer
.valueOf(5344), session
.getLivePort());
502 assertEquals(1000000, session
.getLiveDelay());
503 assertEquals(TraceSessionState
.INACTIVE
, session
.getSessionState());
504 assertTrue(session
.isLive());
506 } catch (ExecutionException e
) {
514 protected TraceLogLevel
getAllEventTraceLogLevel() {
515 return TraceLogLevel
.LEVEL_UNKNOWN
;
518 public void testGetKernelProvider() {
520 fShell
.setScenario(SCEN_GET_KERNEL_PROVIDER1
);
521 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
524 assertNotNull(events
);
525 assertEquals(3, events
.size());
527 IBaseEventInfo baseEventInfo
= events
.get(0);
528 assertNotNull(baseEventInfo
);
529 assertEquals("sched_kthread_stop", baseEventInfo
.getName());
530 assertEquals(TraceLogLevel
.TRACE_EMERG
, baseEventInfo
.getLogLevel());
531 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
533 baseEventInfo
= events
.get(1);
534 assertEquals("sched_kthread_stop_ret", baseEventInfo
.getName());
535 assertEquals(TraceLogLevel
.TRACE_EMERG
, baseEventInfo
.getLogLevel());
536 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
538 baseEventInfo
= events
.get(2);
539 assertEquals("sched_wakeup_new", baseEventInfo
.getName());
540 assertEquals(TraceLogLevel
.TRACE_EMERG
, baseEventInfo
.getLogLevel());
541 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
543 } catch (ExecutionException e
) {
549 public void testGetKernelProviderNoKernel1() {
551 fShell
.setScenario(SCEN_LIST_WITH_NO_KERNEL1
);
552 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
555 assertNotNull(events
);
556 assertEquals(0, events
.size());
558 } catch (ExecutionException e
) {
564 public void testGetKernelProviderNoKernel2() {
566 fShell
.setScenario(SCEN_LIST_WITH_NO_KERNEL2
);
567 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
570 assertNotNull(events
);
571 assertEquals(0, events
.size());
573 } catch (ExecutionException e
) {
579 public void testGetKernelProviderNoKernelVerbose() {
582 fShell
.setScenario(SCEN_LIST_WITH_NO_KERNEL_VERBOSE
);
583 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
586 assertNotNull(events
);
587 assertEquals(0, events
.size());
589 } catch (ExecutionException e
) {
597 public void testGetUstProvider() {
599 fShell
.setScenario(SCEN_GET_UST_PROVIDER1
);
600 List
<IUstProviderInfo
> providers
= fService
.getUstProvider();
602 // Check all providers
603 assertNotNull(providers
);
604 assertEquals(2, providers
.size());
606 //Verify first provider
607 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(0).getName());
608 assertEquals(9379, providers
.get(0).getPid());
611 IBaseEventInfo
[] events
= providers
.get(0).getEvents();
612 assertNotNull(events
);
613 assertEquals(2, events
.length
);
615 IBaseEventInfo baseEventInfo
= events
[0];
616 assertNotNull(baseEventInfo
);
617 assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo
.getName());
618 assertEquals(TraceLogLevel
.TRACE_DEBUG_MODULE
, baseEventInfo
.getLogLevel());
619 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
621 baseEventInfo
= events
[1];
622 assertEquals("ust_tests_hello:tptest", baseEventInfo
.getName());
623 assertEquals(TraceLogLevel
.TRACE_INFO
, baseEventInfo
.getLogLevel());
624 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
626 //Verify second provider
627 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(1).getName());
628 assertEquals(4852, providers
.get(1).getPid());
631 events
= providers
.get(1).getEvents();
632 assertNotNull(events
);
633 assertEquals(2, events
.length
);
635 baseEventInfo
= events
[0];
636 assertNotNull(baseEventInfo
);
637 assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo
.getName());
638 assertEquals(TraceLogLevel
.TRACE_WARNING
, baseEventInfo
.getLogLevel());
639 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
641 baseEventInfo
= events
[1];
642 assertEquals("ust_tests_hello:tptest", baseEventInfo
.getName());
643 assertEquals(TraceLogLevel
.TRACE_DEBUG_FUNCTION
, baseEventInfo
.getLogLevel());
644 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
646 } catch (ExecutionException e
) {
652 public void testUstProvider2() {
654 fShell
.setScenario(SCEN_GET_UST_PROVIDER2
);
655 List
<IUstProviderInfo
> providers
= fService
.getUstProvider();
657 assertNotNull(providers
);
658 assertEquals(0, providers
.size());
660 } catch (ExecutionException e
) {
666 public void testGetUstProvider3() {
668 fShell
.setScenario(SCEN_GET_UST_PROVIDER3
);
670 ((LTTngControlService
)fService
).setVersion("2.1.0");
671 List
<IUstProviderInfo
> providers
= fService
.getUstProvider();
673 // Check all providers
674 assertNotNull(providers
);
675 assertEquals(2, providers
.size());
677 //Verify first provider
678 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(0).getName());
679 assertEquals(9379, providers
.get(0).getPid());
682 IBaseEventInfo
[] events
= providers
.get(0).getEvents();
683 assertNotNull(events
);
684 assertEquals(2, events
.length
);
686 IBaseEventInfo baseEventInfo
= events
[0];
687 assertNotNull(baseEventInfo
);
688 IFieldInfo
[] fields
= baseEventInfo
.getFields();
689 assertNotNull(fields
);
690 assertEquals(0, fields
.length
);
692 baseEventInfo
= events
[1];
693 fields
= baseEventInfo
.getFields();
694 assertNotNull(fields
);
695 assertEquals(3, fields
.length
);
696 assertEquals("doublefield", fields
[0].getName());
697 assertEquals("float", fields
[0].getFieldType());
699 assertEquals("floatfield", fields
[1].getName());
700 assertEquals("float", fields
[1].getFieldType());
702 assertEquals("stringfield", fields
[2].getName());
703 assertEquals("string", fields
[2].getFieldType());
705 //Verify second provider
706 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(1).getName());
707 assertEquals(4852, providers
.get(1).getPid());
710 events
= providers
.get(1).getEvents();
711 assertNotNull(events
);
712 assertEquals(2, events
.length
);
714 baseEventInfo
= events
[0];
715 assertNotNull(baseEventInfo
);
716 fields
= baseEventInfo
.getFields();
717 assertNotNull(fields
);
718 assertEquals(0, fields
.length
);
720 baseEventInfo
= events
[1];
721 fields
= baseEventInfo
.getFields();
722 assertNotNull(fields
);
723 assertEquals(3, fields
.length
);
725 assertEquals("doublefield", fields
[0].getName());
726 assertEquals("float", fields
[0].getFieldType());
728 assertEquals("floatfield", fields
[1].getName());
729 assertEquals("float", fields
[1].getFieldType());
731 assertEquals("stringfield", fields
[2].getName());
732 assertEquals("string", fields
[2].getFieldType());
735 ((LTTngControlService
)fService
).setVersion("2.0.0");
737 } catch (ExecutionException e
) {
744 public void testGetKernelProviderNoUst1() {
746 fShell
.setScenario(SCEN_LIST_WITH_NO_UST1
);
747 List
<IUstProviderInfo
> providerList
= fService
.getUstProvider(new NullProgressMonitor());
749 // Verify Provider info
750 assertNotNull(providerList
);
751 assertEquals(0, providerList
.size());
753 } catch (ExecutionException e
) {
760 public void testGetKernelProviderNoUst2() {
763 ((LTTngControlService
)fService
).setVersion("2.1.0");
765 fShell
.setScenario(SCEN_LIST_WITH_NO_UST2
);
766 List
<IUstProviderInfo
> providerList
= fService
.getUstProvider(new NullProgressMonitor());
768 // Verify Provider info
769 assertNotNull(providerList
);
770 assertEquals(0, providerList
.size());
773 ((LTTngControlService
)fService
).setVersion("2.0.0");
775 } catch (ExecutionException e
) {
781 public void testGetKernelProviderNoUst3() {
785 ((LTTngControlService
)fService
).setVersion("2.1.0");
787 fShell
.setScenario(SCEN_LIST_WITH_NO_UST3
);
788 List
<IUstProviderInfo
> providerList
= fService
.getUstProvider(new NullProgressMonitor());
790 // Verify provider info
791 assertNotNull(providerList
);
792 assertEquals(0, providerList
.size());
795 ((LTTngControlService
)fService
).setVersion("2.0.0");
797 } catch (ExecutionException e
) {
803 public void testGetKernelProviderNoUstVerbose() {
808 ((LTTngControlService
)fService
).setVersion("2.1.0");
810 fShell
.setScenario(SCEN_LIST_WITH_NO_UST_VERBOSE
);
811 List
<IUstProviderInfo
> providerList
= fService
.getUstProvider(new NullProgressMonitor());
813 // Verify provider info
814 assertNotNull(providerList
);
815 assertEquals(0, providerList
.size());
818 ((LTTngControlService
)fService
).setVersion("2.0.0");
820 } catch (ExecutionException e
) {
830 public void testCreateSession() {
832 fShell
.setScenario(SCEN_CREATE_SESSION1
);
834 ISessionInfo info
= fService
.createSession(new SessionInfo("mysession2"), new NullProgressMonitor());
836 assertEquals("mysession2", info
.getName());
837 assertNotNull(info
.getSessionPath());
838 assertTrue(info
.getSessionPath().contains("mysession2"));
839 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
840 } catch (ExecutionException e
) {
846 public void testCreateSessionWithPrompt() {
848 // First line has the shell prompt before the command output
849 // This can happen in a real application if the command line is not echoed by the shell.
850 fShell
.setScenario(SCEN_CREATE_SESSION_WITH_PROMPT
);
852 // First line has no shell prompt before the output
853 ISessionInfo info
= fService
.createSession(new SessionInfo("mysession2"), new NullProgressMonitor());
855 assertEquals("mysession2", info
.getName());
856 assertNotNull(info
.getSessionPath());
857 assertTrue(info
.getSessionPath().contains("mysession2"));
858 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
859 } catch (ExecutionException e
) {
865 public void testCreateSessionVariants() {
867 fShell
.setScenario(SCEN_CREATE_SESSION_VARIANTS
);
870 fService
.createSession(new SessionInfo("alreadyExist"), new NullProgressMonitor());
871 fail("No exeption thrown");
872 } catch (ExecutionException e
) {
877 fService
.createSession(new SessionInfo("wrongName"), new NullProgressMonitor());
878 fail("No exeption thrown");
879 } catch (ExecutionException e
) {
884 ISessionInfo sessionInfo
= new SessionInfo("withPath");
885 sessionInfo
.setSessionPath("/home/user/hallo");
886 fService
.createSession(sessionInfo
, new NullProgressMonitor());
887 fail("No exeption thrown");
888 } catch (ExecutionException e
) {
893 ISessionInfo info
= fService
.createSession(new SessionInfo("session with spaces"), new NullProgressMonitor());
895 assertEquals("session with spaces", info
.getName());
896 assertNotNull(info
.getSessionPath());
897 assertTrue(info
.getSessionPath().contains("session with spaces"));
898 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
900 } catch (ExecutionException e
) {
905 ISessionInfo sessionInfo
= new SessionInfo("pathWithSpaces");
906 sessionInfo
.setSessionPath("/home/user/hallo user/here");
907 ISessionInfo info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
909 assertEquals("pathWithSpaces", info
.getName());
910 assertNotNull(info
.getSessionPath());
911 assertTrue(info
.getSessionPath().contains("/home/user/hallo user/here"));
912 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
914 } catch (ExecutionException e
) {
920 public void testDestroySession() {
922 fShell
.setScenario(SCEN_DESTROY_SESSION1
);
923 fService
.destroySession("mysession2", new NullProgressMonitor());
924 } catch (ExecutionException e
) {
930 public void testDestroySessionVerbose() {
933 fShell
.setScenario(SCEN_DESTROY_SESSION_VERBOSE
);
934 fService
.destroySession("mysession2", new NullProgressMonitor());
935 } catch (ExecutionException e
) {
943 public void testCreateChannel() {
945 ((LTTngControlService
)fService
).setVersion("2.2.0");
946 String sessionName
= "mysession2";
947 List
<String
> list
= new ArrayList
<>();
948 String kernelChannel0
= "mychannel0";
949 String kernelChannel1
= "mychannel1";
950 list
.add(kernelChannel0
);
951 list
.add(kernelChannel1
);
953 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
955 // Create/enable/configure 2 kernel channels
956 ChannelInfo chanInfo
= new ChannelInfo("");
957 chanInfo
.setOverwriteMode(true);
958 chanInfo
.setSubBufferSize(16384);
959 chanInfo
.setReadTimer(100);
960 chanInfo
.setSwitchTimer(200);
961 chanInfo
.setNumberOfSubBuffers(2);
962 chanInfo
.setMaxNumberTraceFiles(10);
963 chanInfo
.setMaxSizeTraceFiles(0);
964 fService
.enableChannels(sessionName
, list
, true, chanInfo
, new NullProgressMonitor());
966 // Create/enable/configure 1 UST channel
968 list
.add("ustChannel");
970 chanInfo
= new ChannelInfo("");
971 chanInfo
.setOverwriteMode(true);
972 chanInfo
.setSubBufferSize(32768);
973 chanInfo
.setReadTimer(200);
974 chanInfo
.setSwitchTimer(100);
975 chanInfo
.setNumberOfSubBuffers(1);
976 chanInfo
.setMaxNumberTraceFiles(20);
977 chanInfo
.setMaxSizeTraceFiles(0);
978 fService
.enableChannels(sessionName
, list
, false, chanInfo
, new NullProgressMonitor());
979 ((LTTngControlService
)fService
).setVersion("2.0.0");
981 } catch (ExecutionException e
) {
987 public void testCreateChannelUIDBuffer() {
989 ((LTTngControlService
)fService
).setVersion("2.2.0");
990 String sessionName
= "mysession2";
991 List
<String
> list
= new ArrayList
<>();
992 String USTChannel
= "ustChannel";
993 list
.add(USTChannel
);
994 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
996 ChannelInfo chanInfo
= new ChannelInfo("");
997 chanInfo
.setOverwriteMode(true);
998 chanInfo
.setSubBufferSize(32768);
999 chanInfo
.setReadTimer(200);
1000 chanInfo
.setSwitchTimer(100);
1001 chanInfo
.setNumberOfSubBuffers(1);
1002 chanInfo
.setMaxNumberTraceFiles(20);
1003 chanInfo
.setMaxSizeTraceFiles(0);
1004 chanInfo
.setBufferType(BufferType
.BUFFER_PER_UID
);
1005 fService
.enableChannels(sessionName
, list
, false, chanInfo
, new NullProgressMonitor());
1006 ((LTTngControlService
)fService
).setVersion("2.0.0");
1008 } catch (ExecutionException e
) {
1014 public void testCreateChannelPIDBuffer() {
1016 ((LTTngControlService
)fService
).setVersion("2.2.0");
1017 String sessionName
= "mysession2";
1018 List
<String
> list
= new ArrayList
<>();
1019 String USTChannel
= "ustChannel";
1020 list
.add(USTChannel
);
1021 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
1024 ChannelInfo chanInfo
= new ChannelInfo("");
1025 chanInfo
.setOverwriteMode(true);
1026 chanInfo
.setSubBufferSize(-1);
1027 chanInfo
.setReadTimer(-1);
1028 chanInfo
.setSwitchTimer(-1);
1029 chanInfo
.setNumberOfSubBuffers(-1);
1030 chanInfo
.setMaxNumberTraceFiles(-1);
1031 chanInfo
.setMaxSizeTraceFiles(-1);
1032 chanInfo
.setBufferType(BufferType
.BUFFER_PER_PID
);
1034 fService
.enableChannels(sessionName
, list
, false, chanInfo
, new NullProgressMonitor());
1035 ((LTTngControlService
)fService
).setVersion("2.0.0");
1037 } catch (ExecutionException e
) {
1043 public void testDisableChannel() {
1046 String sessionName
= "mysession2";
1047 List
<String
> list
= new ArrayList
<>();
1048 String kernelChannel0
= "mychannel0";
1049 String kernelChannel1
= "mychannel1";
1050 list
.add(kernelChannel0
);
1051 list
.add(kernelChannel1
);
1053 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
1054 fService
.disableChannels(sessionName
, list
, true, new NullProgressMonitor());
1057 list
.add("ustChannel");
1058 fService
.disableChannels(sessionName
, list
, false, new NullProgressMonitor());
1060 } catch (ExecutionException e
) {
1066 public void testEnableChannel() {
1069 String sessionName
= "mysession2";
1070 List
<String
> list
= new ArrayList
<>();
1071 String kernelChannel0
= "mychannel0";
1072 String kernelChannel1
= "mychannel1";
1073 list
.add(kernelChannel0
);
1074 list
.add(kernelChannel1
);
1076 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
1077 fService
.enableChannels(sessionName
, list
, true, null, new NullProgressMonitor());
1079 // Create/enable/configure 1 UST channel
1081 list
.add("ustChannel");
1083 fService
.enableChannels(sessionName
, list
, false, null, new NullProgressMonitor());
1085 } catch (ExecutionException e
) {
1091 public void testEnableEvents() {
1093 // 1) session name, channel = null, 3 event names, kernel
1094 String sessionName
= "mysession2";
1095 List
<String
> list
= new ArrayList
<>();
1096 String eventName0
= "block_rq_remap";
1097 String eventName1
= "block_bio_remap";
1098 String eventName2
= "softirq_entry";
1099 list
.add(eventName0
);
1100 list
.add(eventName1
);
1101 list
.add(eventName2
);
1102 fShell
.setScenario(SCEN_EVENT_HANDLING
);
1103 fService
.enableEvents(sessionName
, null, list
, true, null, new NullProgressMonitor());
1105 // 2) session name, channel=mychannel, event name= null, kernel
1106 String channelName
= "mychannel";
1107 fService
.enableEvents(sessionName
, channelName
, null, true, null, new NullProgressMonitor());
1109 // 3) session name, channel=mychannel, 1 event name, ust, no filter
1110 String ustEventName
= "ust_tests_hello:tptest_sighandler";
1112 list
.add(ustEventName
);
1113 fService
.enableEvents(sessionName
, channelName
, list
, false, null, new NullProgressMonitor());
1115 // 4) session name, channel = mychannel, no event name, ust, with filter
1116 fService
.enableEvents(sessionName
, channelName
, list
, false, "intfield==10", new NullProgressMonitor());
1118 // 5) session name, channel = mychannel, no event name, ust, no filter
1120 fService
.enableEvents(sessionName
, channelName
, list
, false, null, new NullProgressMonitor());
1122 // 6) session name, channel = null,
1123 fService
.enableEvents(sessionName
, null, ILttngControlService
.ALL_EVENTS
, true, null, new NullProgressMonitor());
1125 } catch (ExecutionException e
) {
1131 public void testEnableSyscalls() {
1133 // 1) session name, channel = null, 3 event names, kernel
1134 String sessionName
= "mysession2";
1135 String channelName
= "mychannel";
1137 fShell
.setScenario(SCEN_EVENT_HANDLING
);
1139 // 1) session name, channel = null
1140 fService
.enableSyscalls(sessionName
, null, new NullProgressMonitor());
1142 // 2) session name, channel = mychannel
1143 fService
.enableSyscalls(sessionName
, channelName
, new NullProgressMonitor());
1145 } catch (ExecutionException e
) {
1151 public void testDynamicProbe() {
1153 // 1) session name, channel = null, 3 event names, kernel
1154 String sessionName
= "mysession2";
1155 String channelName
= "mychannel";
1156 String eventName0
= "myevent0";
1157 String eventName1
= "myevent1";
1158 String functionProbe
= "0xc0101340";
1159 String dynProbe
= "init_post";
1161 fShell
.setScenario(SCEN_EVENT_HANDLING
);
1163 // 1) session name, channel = null, event name, function probe, probe
1164 fService
.enableProbe(sessionName
, null, eventName0
, true, functionProbe
, new NullProgressMonitor());
1166 // 2) session name, channel = mychannel
1167 fService
.enableProbe(sessionName
, channelName
, eventName1
, false, dynProbe
, new NullProgressMonitor());
1169 } catch (ExecutionException e
) {
1175 public void testEnableLogLevel() {
1177 // 1) session name, channel = null, 3 event names, kernel
1178 String sessionName
= "mysession2";
1179 String channelName
= "mychannel";
1180 String eventName4
= "myevent4";
1181 String eventName5
= "myevent5";
1183 fShell
.setScenario(SCEN_EVENT_HANDLING
);
1185 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
1186 fService
.enableLogLevel(sessionName
, null, eventName4
, LogLevelType
.LOGLEVEL_ONLY
, TraceLogLevel
.TRACE_DEBUG
, null, new NullProgressMonitor());
1188 // 2) session name, channel = mychannel, null, loglevel, TRACE_DEBUG_FUNCTION
1189 fService
.enableLogLevel(sessionName
, channelName
, eventName5
, LogLevelType
.LOGLEVEL
, TraceLogLevel
.TRACE_DEBUG_FUNCTION
, null, new NullProgressMonitor());
1191 // TODO add test with filters
1193 } catch (ExecutionException e
) {
1199 public void testAddContext() {
1201 // 1) session name, channel = null, 3 event names, kernel
1202 String sessionName
= "mysession2";
1203 String channelName
= "mychannel";
1204 String eventName
= "ust_tests_hello:tptest_sighandler";
1205 List
<String
> contexts
= new ArrayList
<>();
1206 contexts
.add("prio");
1207 contexts
.add("pid");
1209 fShell
.setScenario(SCEN_CONTEXT_HANDLING
);
1211 List
<String
> availContexts
= fService
.getContextList(new NullProgressMonitor());
1212 assertNotNull(availContexts
);
1213 assertEquals(12, availContexts
.size());
1215 // A very "hard-coded" way to verify but it works ...
1216 Set
<String
> expectedContexts
= new HashSet
<>();
1217 expectedContexts
.add("pid");
1218 expectedContexts
.add("procname");
1219 expectedContexts
.add("prio");
1220 expectedContexts
.add("nice");
1221 expectedContexts
.add("vpid");
1222 expectedContexts
.add("tid");
1223 expectedContexts
.add("pthread_id");
1224 expectedContexts
.add("vtid");
1225 expectedContexts
.add("ppid");
1226 expectedContexts
.add("vppid");
1227 expectedContexts
.add("perf:cpu-cycles");
1228 expectedContexts
.add("perf:cycles");
1230 assertTrue(expectedContexts
.containsAll(availContexts
));
1232 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
1233 fService
.addContexts(sessionName
, channelName
, eventName
, false, contexts
, new NullProgressMonitor());
1235 } catch (ExecutionException e
) {
1241 public void testAddContextFailure() {
1243 // 1) session name, channel = null, 3 event names, kernel
1244 String sessionName
= "mysession2";
1245 String channelName
= "mychannel";
1246 String eventName
= "ust_tests_hello:tptest_sighandler";
1247 List
<String
> contexts
= new ArrayList
<>();
1248 contexts
.add("prio");
1249 contexts
.add("pid");
1250 fShell
.setScenario(SCEN_CONTEXT_ERROR_HANDLING
);
1252 fService
.getContextList(new NullProgressMonitor());
1253 fail("No exeption generated");
1254 } catch (ExecutionException e
) {
1258 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
1259 fService
.addContexts(sessionName
, channelName
, eventName
, false, contexts
, new NullProgressMonitor());
1260 fail("No exeption generated");
1261 } catch (ExecutionException e
) {
1267 public void testCreateSession2_1() {
1270 fShell
.setScenario(SCEN_CREATE_SESSION_2_1
);
1272 ISessionInfo sessionInfo
= new SessionInfo("mysession");
1273 sessionInfo
.setNetworkUrl("net://172.0.0.1");
1274 sessionInfo
.setStreamedTrace(true);
1275 ISessionInfo info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1276 assertNotNull(info
);
1277 assertEquals("mysession", info
.getName());
1278 assertEquals("net://172.0.0.1", info
.getSessionPath());
1279 assertTrue(info
.isStreamedTrace());
1280 fService
.destroySession("mysession", new NullProgressMonitor());
1282 sessionInfo
= new SessionInfo("mysession");
1283 sessionInfo
.setStreamedTrace(true);
1284 sessionInfo
.setNetworkUrl("file:///tmp");
1285 info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1286 assertNotNull(info
);
1287 assertEquals("mysession", info
.getName());
1288 assertEquals("file:///tmp", info
.getSessionPath());
1289 assertTrue(!info
.isStreamedTrace());
1290 fService
.destroySession("mysession", new NullProgressMonitor());
1292 sessionInfo
= new SessionInfo("mysession");
1293 sessionInfo
.setStreamedTrace(true);
1294 sessionInfo
.setNetworkUrl("file:///tmp");
1295 info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1296 assertNotNull(info
);
1297 assertEquals("mysession", info
.getName());
1298 assertEquals("file:///tmp", info
.getSessionPath());
1299 assertTrue(!info
.isStreamedTrace());
1300 fService
.destroySession("mysession", new NullProgressMonitor());
1302 sessionInfo
= new SessionInfo("mysession");
1303 sessionInfo
.setStreamedTrace(true);
1304 sessionInfo
.setControlUrl("tcp://172.0.0.1");
1305 sessionInfo
.setDataUrl("tcp://172.0.0.1:5343");
1306 info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1307 assertNotNull(info
);
1308 assertEquals("mysession", info
.getName());
1309 assertEquals("", info
.getSessionPath()); // the complete network path is not available at this point
1310 assertTrue(info
.isStreamedTrace());
1311 fService
.destroySession("mysession", new NullProgressMonitor());
1313 sessionInfo
= new SessionInfo("mysession");
1314 sessionInfo
.setStreamedTrace(true);
1315 sessionInfo
.setNetworkUrl("net://172.0.0.1:1234:2345");
1316 info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1317 assertNotNull(info
);
1318 assertEquals("mysession", info
.getName());
1319 assertEquals("net://172.0.0.1:1234:2345", info
.getSessionPath());
1320 assertTrue(info
.isStreamedTrace());
1321 fService
.destroySession("mysession", new NullProgressMonitor());
1325 sessionInfo
= new SessionInfo("mysession");
1326 sessionInfo
.setStreamedTrace(true);
1327 sessionInfo
.setNetworkUrl("net://172.0.0.1");
1328 info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1329 assertNotNull(info
);
1330 assertEquals("mysession", info
.getName());
1331 assertEquals("net://172.0.0.1", info
.getSessionPath());
1332 assertTrue(info
.isStreamedTrace());
1334 fService
.destroySession("mysession", new NullProgressMonitor());
1337 } catch (ExecutionException e
) {
1343 public void testCreateSessionVerbose2_1() {
1345 fShell
.setScenario(SCEN_CREATE_SESSION_VERBOSE_2_1
);
1348 ISessionInfo sessionInfo
= new SessionInfo("mysession");
1349 sessionInfo
.setStreamedTrace(true);
1350 sessionInfo
.setNetworkUrl("net://172.0.0.1");
1351 ISessionInfo info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1352 assertNotNull(info
);
1353 assertEquals("mysession", info
.getName());
1354 assertEquals("net://172.0.0.1", info
.getSessionPath());
1355 assertTrue(info
.isStreamedTrace());
1356 fService
.destroySession("mysession", new NullProgressMonitor());
1357 } catch (ExecutionException e
) {
1365 public void testCreateSnapshotSession() {
1367 fShell
.setScenario(SCEN_CREATE_SNAPSHOT_SESSION
);
1368 ISessionInfo params
= new SessionInfo("mysession");
1369 params
.setSnapshot(true);
1370 ISessionInfo sessionInfo
= fService
.createSession(params
, new NullProgressMonitor());
1371 assertNotNull(sessionInfo
);
1372 assertEquals("mysession", sessionInfo
.getName());
1373 assertTrue(sessionInfo
.isSnapshotSession());
1374 assertEquals("", sessionInfo
.getSessionPath());
1375 assertTrue(!sessionInfo
.isStreamedTrace());
1377 assertEquals(TraceSessionState
.INACTIVE
, sessionInfo
.getSessionState());
1379 List
<String
> names
= fService
.getSessionNames(new NullProgressMonitor());
1380 assertEquals(names
.get(0), "mysession");
1382 ISnapshotInfo snapshotInfo
= fService
.getSnapshotInfo("mysession", new NullProgressMonitor());
1383 assertNotNull(snapshotInfo
);
1384 assertEquals("snapshot-1", snapshotInfo
.getName());
1385 assertEquals("/home/user/lttng-traces/mysession-20130913-141651", snapshotInfo
.getSnapshotPath());
1386 assertEquals(1, snapshotInfo
.getId());
1387 assertTrue(!snapshotInfo
.isStreamedSnapshot());
1389 // we need to set the snapshotInfo to so that the session path is set correctly
1390 sessionInfo
.setSnapshotInfo(snapshotInfo
);
1391 assertEquals("/home/user/lttng-traces/mysession-20130913-141651", sessionInfo
.getSessionPath());
1393 fService
.recordSnapshot("mysession", new NullProgressMonitor());
1395 fService
.destroySession("mysession", new NullProgressMonitor());
1397 } catch (ExecutionException e
) {
1403 public void testCreateSnapshotSession2_5() {
1405 fShell
.setScenario(SCEN_CREATE_SNAPSHOT_SESSION_2_5
);
1406 ISessionInfo params
= new SessionInfo("mysession");
1407 params
.setSnapshot(true);
1408 ISessionInfo sessionInfo
= fService
.createSession(params
, new NullProgressMonitor());
1409 assertNotNull(sessionInfo
);
1410 assertEquals("mysession", sessionInfo
.getName());
1411 assertTrue(sessionInfo
.isSnapshotSession());
1412 assertEquals("", sessionInfo
.getSessionPath());
1413 assertTrue(!sessionInfo
.isStreamedTrace());
1415 assertEquals(TraceSessionState
.INACTIVE
, sessionInfo
.getSessionState());
1417 List
<String
> names
= fService
.getSessionNames(new NullProgressMonitor());
1418 assertEquals(names
.get(0), "mysession");
1420 ISnapshotInfo snapshotInfo
= fService
.getSnapshotInfo("mysession", new NullProgressMonitor());
1421 assertNotNull(snapshotInfo
);
1422 assertEquals("snapshot-1", snapshotInfo
.getName());
1423 assertEquals("/home/user/lttng-traces/mysession-20130913-141651", snapshotInfo
.getSnapshotPath());
1424 assertEquals(1, snapshotInfo
.getId());
1425 assertTrue(!snapshotInfo
.isStreamedSnapshot());
1427 // we need to set the snapshotInfo to so that the session path is set correctly
1428 sessionInfo
.setSnapshotInfo(snapshotInfo
);
1429 assertEquals("/home/user/lttng-traces/mysession-20130913-141651", sessionInfo
.getSessionPath());
1431 fService
.recordSnapshot("mysession", new NullProgressMonitor());
1433 fService
.destroySession("mysession", new NullProgressMonitor());
1435 } catch (ExecutionException e
) {
1440 public void testCreateStreamedSnapshotSession() {
1442 fShell
.setScenario(SCEN_CREATE_STREAMED_SNAPSHOT_SESSION
);
1444 ISessionInfo params
= new SessionInfo("mysession");
1445 params
.setNetworkUrl("net://172.0.0.1");
1446 ISessionInfo sessionInfo
= fService
.createSession(params
, new NullProgressMonitor());
1447 assertNotNull(sessionInfo
);
1448 assertEquals("mysession", sessionInfo
.getName());
1449 assertTrue(sessionInfo
.isSnapshotSession());
1451 assertEquals(TraceSessionState
.INACTIVE
, sessionInfo
.getSessionState());
1452 assertTrue(sessionInfo
.isStreamedTrace());
1454 List
<String
> names
= fService
.getSessionNames(new NullProgressMonitor());
1455 assertEquals(names
.get(0), "mysession");
1457 ISnapshotInfo snapshotInfo
= sessionInfo
.getSnapshotInfo();
1458 assertNotNull(sessionInfo
);
1459 assertEquals("snapshot-2", snapshotInfo
.getName());
1460 assertEquals("net4://172.0.0.1:5342/", snapshotInfo
.getSnapshotPath());
1461 assertEquals(2, snapshotInfo
.getId());
1462 assertTrue(snapshotInfo
.isStreamedSnapshot());
1464 // we need to set the snapshotInfo to so that the session path is set correctly
1465 sessionInfo
.setSnapshotInfo(snapshotInfo
);
1466 assertEquals("net4://172.0.0.1:5342/", sessionInfo
.getSessionPath());
1468 fService
.recordSnapshot("mysession", new NullProgressMonitor());
1470 fService
.destroySession("mysession", new NullProgressMonitor());
1472 } catch (ExecutionException e
) {
1478 public void testCreateSnapshotSessionErrors() {
1480 fShell
.setScenario(SCEN_CREATE_SNAPSHOT_SESSION_ERRORS
);
1482 List
<String
> names
= fService
.getSessionNames(new NullProgressMonitor());
1483 assertEquals(names
.get(0), "mysession");
1484 } catch (ExecutionException e
) {
1489 fService
.getSnapshotInfo("blabla", new NullProgressMonitor());
1490 fail("getSnapshoInfo() didn't fail");
1491 } catch (ExecutionException e
) {
1496 fService
.recordSnapshot("blabla", new NullProgressMonitor());
1497 fail("getSnapshoInfo() didn't fail");
1498 } catch (ExecutionException e
) {
1503 fService
.recordSnapshot("mysession", new NullProgressMonitor());
1504 fail("getSnapshoInfo() didn't fail");
1505 } catch (ExecutionException e
) {
1512 public void testCreateLiveSession() throws ExecutionException
{
1513 fShell
.setScenario(SCEN_CREATE_LIVE_SESSION
);
1515 ISessionInfo params
= new SessionInfo("mysession");
1516 params
.setLive(true);
1517 params
.setStreamedTrace(true);
1518 params
.setNetworkUrl("net://127.0.0.1");
1519 ISessionInfo sessionInfo
= fService
.createSession(params
, new NullProgressMonitor());
1520 assertNotNull(sessionInfo
);
1521 assertEquals("mysession", sessionInfo
.getName());
1522 assertEquals(TraceSessionState
.INACTIVE
, sessionInfo
.getSessionState());
1523 assertTrue(sessionInfo
.isStreamedTrace());
1524 assertTrue(sessionInfo
.isLive());
1525 assertEquals("net://127.0.0.1", sessionInfo
.getSessionPath());
1526 List
<String
> names
= fService
.getSessionNames(new NullProgressMonitor());
1527 assertEquals(names
.get(0), "mysession");
1528 fService
.destroySession("mysession", new NullProgressMonitor());
1533 public void testCreateLiveSessionErrors() {
1535 fShell
.setScenario(SCEN_CREATE_LIVE_SESSION_ERRORS
);
1537 ISessionInfo parameters
= new SessionInfo("mysession");
1538 parameters
.setLive(true);
1539 parameters
.setSnapshot(true);
1540 fService
.createSession(parameters
, new NullProgressMonitor());
1541 fail("createSession() didn't fail");
1542 } catch (ExecutionException e
) {
1547 ISessionInfo parameters
= new SessionInfo("mysession");
1548 parameters
.setNetworkUrl("blah");
1549 parameters
.setLive(true);
1550 fService
.createSession(parameters
, new NullProgressMonitor());
1551 fail("createSession() didn't fail");
1552 } catch (ExecutionException e
) {
1557 ISessionInfo parameters
= new SessionInfo("mysession");
1558 parameters
.setControlUrl("net://127.0.0.1");
1559 parameters
.setLive(true);
1560 fService
.createSession(parameters
, new NullProgressMonitor());
1561 fail("createSession() didn't fail");
1562 } catch (ExecutionException e
) {
1568 public void testSessionProfile() {
1569 fShell
.setScenario(SCEN_SESSION_PROFILES
);
1570 final String profile
= "/home/user/.lttng/sessions/mysession.lttng";
1572 fService
.loadSession(profile
, false, new NullProgressMonitor());
1573 } catch (ExecutionException e
) {
1574 fail("load session failed: " + e
);
1578 fService
.loadSession(profile
, true, new NullProgressMonitor());
1579 } catch (ExecutionException e
) {
1580 fail("load session failed: " + e
);
1584 fService
.saveSession(null, null, false, new NullProgressMonitor());
1585 } catch (ExecutionException e
) {
1586 fail("save session failed: " + e
);
1589 final String sessionName
= "mysession";
1591 fService
.saveSession(sessionName
, null, false, new NullProgressMonitor());
1592 } catch (ExecutionException e
) {
1593 fail("save session failed: " + e
);
1597 fService
.saveSession(sessionName
, null, true, new NullProgressMonitor());
1598 } catch (ExecutionException e
) {
1599 fail("save session failed: " + e
);
1603 fService
.saveSession(sessionName
, "/tmp/test", true, new NullProgressMonitor());
1604 } catch (ExecutionException e
) {
1605 fail("save session failed: " + e
);
1609 private static void enableVerbose() {
1611 ControlCommandLogger
.init(ControlPreferences
.getInstance().getLogfilePath(), false);
1612 ControlPreferences
.getInstance().getPreferenceStore().setDefault(ControlPreferences
.TRACE_CONTROL_LOG_COMMANDS_PREF
, true);
1613 ControlPreferences
.getInstance().getPreferenceStore().setDefault(ControlPreferences
.TRACE_CONTROL_VERBOSE_LEVEL_PREF
, ControlPreferences
.TRACE_CONTROL_VERBOSE_LEVEL_V_V_VERBOSE
);
1616 private static void disableVerbose() {
1617 ControlPreferences
.getInstance().getPreferenceStore().setDefault(ControlPreferences
.TRACE_CONTROL_LOG_COMMANDS_PREF
, false);