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
.Arrays
;
27 import java
.util
.HashSet
;
28 import java
.util
.List
;
31 import org
.eclipse
.core
.commands
.ExecutionException
;
32 import org
.eclipse
.core
.runtime
.FileLocator
;
33 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
34 import org
.eclipse
.core
.runtime
.Path
;
35 import org
.eclipse
.jdt
.annotation
.NonNull
;
36 import org
.eclipse
.jdt
.annotation
.Nullable
;
37 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.IBaseEventInfo
;
38 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.IChannelInfo
;
39 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.IDomainInfo
;
40 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.IEventInfo
;
41 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.IFieldInfo
;
42 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.ISessionInfo
;
43 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.ISnapshotInfo
;
44 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.IUstProviderInfo
;
45 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.LogLevelType
;
46 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceChannelOutputType
;
47 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceDomainType
;
48 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceEnablement
;
49 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceEventType
;
50 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceLogLevel
;
51 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceSessionState
;
52 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.impl
.BufferType
;
53 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.impl
.ChannelInfo
;
54 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.impl
.SessionInfo
;
55 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.stubs
.shells
.LTTngToolsFileShell
;
56 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.Activator
;
57 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.logging
.ControlCommandLogger
;
58 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.preferences
.ControlPreferences
;
59 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.service
.ILttngControlService
;
60 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.service
.LTTngControlService
;
61 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.service
.LTTngControlServiceFactory
;
62 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.service
.LttngVersion
;
63 import org
.junit
.After
;
64 import org
.junit
.Before
;
65 import org
.junit
.Ignore
;
66 import org
.junit
.Test
;
67 import org
.osgi
.framework
.FrameworkUtil
;
70 * The class <code>LTTngControlServiceTest</code> contains test for the class
71 * <code>{@link LTTngControlService}</code>.
73 @SuppressWarnings("javadoc")
74 public class LTTngControlServiceTest
{
76 private static final String DIRECTORY
= "testfiles";
77 private static final String TEST_STREAM
= "LTTngServiceTest.cfg";
79 private static final String SCEN_LTTNG_NOT_INSTALLED
= "LttngNotInstalled";
80 protected static final String SCEN_LTTNG_VERSION
= "LttngVersion";
81 protected static final String SCEN_LTTNG_VERSION_WITH_PROMPT
= "LttngVersionWithPrompt";
82 private static final String SCEN_LTTNG_UNSUPPORTED_VERSION
= "LttngUnsupportedVersion";
83 private static final String SCEN_LTTNG_NO_VERSION
= "LttngNoVersion";
84 protected static final String SCEN_LTTNG_COMPILED_VERSION
= "LttngVersionCompiled";
85 private static final String SCEN_NO_SESSION_AVAILABLE
= "NoSessionAvailable";
86 private static final String SCEN_GET_SESSION_NAMES1
= "GetSessionNames1";
87 private static final String SCEN_GET_SESSION_WITH_GROUP
= "GetSessionWithTracingGroup";
88 private static final String SCEN_GET_SESSION_NAME_NOT_EXIST
= "GetSessionNameNotExist";
89 private static final String SCEN_GET_SESSION_NAME_NOT_EXIST_VERBOSE
= "GetSessionNameNotExistVerbose";
90 protected static final String SCEN_GET_SESSION_GARBAGE_OUT
= "GetSessionGarbageOut";
91 private static final String SCEN_GET_SESSION1
= "GetSession1";
92 private static final String SCEN_GET_SESSION_WITH_LIVE
= "GetSessionWithLiveInterval";
93 private static final String SCEN_GET_KERNEL_PROVIDER1
= "GetKernelProvider1";
94 private static final String SCEN_LIST_WITH_NO_KERNEL1
= "ListWithNoKernel1";
95 private static final String SCEN_LIST_WITH_NO_KERNEL2
= "ListWithNoKernel2";
96 private static final String SCEN_LIST_WITH_NO_KERNEL_VERBOSE
= "ListWithNoKernelVerbose";
97 private static final String SCEN_GET_UST_PROVIDER1
= "GetUstProvider1";
98 private static final String SCEN_GET_UST_PROVIDER2
= "GetUstProvider2";
99 private static final String SCEN_GET_UST_PROVIDER3
= "GetUstProvider3";
100 private static final String SCEN_LIST_WITH_NO_UST1
= "ListWithNoUst1";
101 private static final String SCEN_LIST_WITH_NO_UST2
= "ListWithNoUst2";
102 private static final String SCEN_LIST_WITH_NO_UST3
= "ListWithNoUst3";
103 private static final String SCEN_LIST_WITH_NO_UST_VERBOSE
= "ListWithNoUstVerbose";
104 private static final String SCEN_CREATE_SESSION1
= "CreateSession1";
105 private static final String SCEN_CREATE_SESSION_WITH_PROMPT
= "CreateSessionWithPrompt";
106 private static final String SCEN_CREATE_SESSION_VARIANTS
= "CreateSessionVariants";
107 private static final String SCEN_DESTROY_SESSION1
= "DestroySession1";
108 private static final String SCEN_DESTROY_SESSION_VERBOSE
= "DestroySessionVerbose";
109 private static final String SCEN_CHANNEL_HANDLING
= "ChannelHandling";
110 private static final String SCEN_EVENT_HANDLING
= "EventHandling";
111 private static final String SCEN_EVENT_EXCLUDED
= "EventExcluded";
112 private static final String SCEN_CONTEXT_HANDLING
= "ContextHandling";
113 private static final String SCEN_CONTEXT_ERROR_HANDLING
= "ContextErrorHandling";
114 private static final String SCEN_CREATE_SESSION_2_1
= "CreateSessionLttng2.1";
115 private static final String SCEN_CREATE_SESSION_VERBOSE_2_1
= "CreateSessionLttngVerbose2.1";
116 private static final String SCEN_CREATE_SNAPSHOT_SESSION
= "CreateSessionSnapshot";
117 private static final String SCEN_CREATE_SNAPSHOT_SESSION_2_5
= "CreateSessionSnapshot2.5";
118 private static final String SCEN_CREATE_STREAMED_SNAPSHOT_SESSION
= "CreateSessionStreamedSnapshot";
119 private static final String SCEN_CREATE_SNAPSHOT_SESSION_ERRORS
= "CreateSessionSnapshotErrors";
120 protected static final String SCEN_CREATE_LIVE_SESSION
= "CreateSessionLive";
121 private static final String SCEN_CREATE_LIVE_SESSION_ERRORS
= "CreateSessionLiveErrors";
122 private static final String SCEN_SESSION_PROFILES
= "SessionProfile";
126 // ------------------------------------------------------------------------
128 // ------------------------------------------------------------------------
129 private String fTestfile
;
130 protected final @NonNull LTTngToolsFileShell fShell
= new LTTngToolsFileShell();
131 protected ILttngControlService fService
;
133 // ------------------------------------------------------------------------
135 // ------------------------------------------------------------------------
138 * Perform pre-test initialization.
141 * if the initialization fails for some reason
144 public void setUp() throws Exception
{
145 URL location
= FileLocator
.find(FrameworkUtil
.getBundle(this.getClass()), new Path(getTestDirectory() + File
.separator
+ getTestStream()), null);
146 File testfile
= new File(FileLocator
.toFileURL(location
).toURI());
147 fTestfile
= testfile
.getAbsolutePath();
148 fShell
.loadScenarioFile(fTestfile
);
149 fService
= getControlService();
150 if (fService
== null) {
151 throw new Exception("Unable to obtain a valid ControlService");
154 ControlPreferences
.getInstance().init(Activator
.getDefault().getPreferenceStore());
158 * @return the string of the test directory to use
160 protected String
getTestDirectory() {
165 * @return the LttngCon
167 protected ILttngControlService
getControlService() {
168 return new LTTngControlService(fShell
);
172 * @return the shell implementation
174 public @NonNull LTTngToolsFileShell
getShell() {
181 protected String
getTestStream() {
186 public void tearDown() {
188 ControlPreferences
.getInstance().dispose();
191 // ------------------------------------------------------------------------
193 // ------------------------------------------------------------------------
196 public void testVersion() {
198 fShell
.setScenario(SCEN_LTTNG_VERSION
);
199 ILttngControlService service
= LTTngControlServiceFactory
.getLttngControlService(fShell
);
200 assertNotNull(service
);
201 assertEquals("2.1.0", service
.getVersionString());
202 } catch (ExecutionException e
) {
203 fail("Exeption thrown " + e
);
208 public void testVersionWithPrompt() {
210 fShell
.setScenario(SCEN_LTTNG_VERSION_WITH_PROMPT
);
211 ILttngControlService service
= LTTngControlServiceFactory
.getLttngControlService(fShell
);
212 assertNotNull(service
);
213 assertEquals("2.0.0", service
.getVersionString());
214 } catch (ExecutionException e
) {
215 fail("Exeption thrown " + e
);
219 @Test(expected
=ExecutionException
.class)
220 public void testUnsupportedVersion() throws ExecutionException
{
221 fShell
.setScenario(SCEN_LTTNG_UNSUPPORTED_VERSION
);
222 LTTngControlServiceFactory
.getLttngControlService(fShell
);
226 public void testNoVersion() {
228 fShell
.setScenario(SCEN_LTTNG_NO_VERSION
);
229 LTTngControlServiceFactory
.getLttngControlService(fShell
);
230 fail("No exeption thrown");
231 } catch (ExecutionException e
) {
237 public void testVersionCompiled() {
239 fShell
.setScenario(SCEN_LTTNG_COMPILED_VERSION
);
240 ILttngControlService service
= LTTngControlServiceFactory
.getLttngControlService(fShell
);
241 assertNotNull(service
);
242 assertEquals("2.5.0", service
.getVersionString());
243 } catch (ExecutionException e
) {
244 fail("Exeption thrown " + e
);
250 public void testLttngNotInstalled() {
252 fShell
.setScenario(SCEN_LTTNG_NOT_INSTALLED
);
253 fService
.getSessionNames(new NullProgressMonitor());
254 fail("No exeption thrown");
255 } catch (ExecutionException e
) {
261 public void testGetSessionNames1() {
263 fShell
.setScenario(SCEN_NO_SESSION_AVAILABLE
);
264 List
<String
> result
= fService
.getSessionNames(new NullProgressMonitor());
266 assertNotNull(result
);
267 assertEquals(0, result
.size());
269 } catch (ExecutionException e
) {
275 public void testGetSessionNames2() {
277 fShell
.setScenario(SCEN_GET_SESSION_NAMES1
);
278 List
<String
> result
= fService
.getSessionNames(new NullProgressMonitor());
280 assertNotNull(result
);
281 assertEquals(2, result
.size());
282 assertEquals("mysession1", result
.get(0));
283 assertEquals("mysession", result
.get(1));
285 } catch (ExecutionException e
) {
291 public void testGetSessionNamesWithTracingGroup() {
293 fShell
.setScenario(SCEN_GET_SESSION_WITH_GROUP
);
294 ControlPreferences
.getInstance().getPreferenceStore().setValue(
295 ControlPreferences
.TRACE_CONTROL_TRACING_GROUP_PREF
, "group");
297 List
<String
> result
= fService
.getSessionNames(new NullProgressMonitor());
299 assertNotNull(result
);
300 assertEquals(2, result
.size());
301 assertEquals("mysession1", result
.get(0));
302 assertEquals("mysession", result
.get(1));
304 ControlCommandLogger
.init(ControlPreferences
.getInstance().getLogfilePath(), false);
305 ControlPreferences
.getInstance().getPreferenceStore().setValue(
306 ControlPreferences
.TRACE_CONTROL_TRACING_GROUP_PREF
, ControlPreferences
.TRACE_CONTROL_DEFAULT_TRACING_GROUP
);
309 } catch (ExecutionException e
) {
316 public void testGetSessionNotExist() {
318 fShell
.setScenario(SCEN_GET_SESSION_NAME_NOT_EXIST
);
319 fService
.getSessionNames(new NullProgressMonitor());
320 fail("No exeption thrown");
322 } catch (ExecutionException e
) {
328 public void testGetSessionNotExistVerbose() {
331 fShell
.setScenario(SCEN_GET_SESSION_NAME_NOT_EXIST_VERBOSE
);
332 fService
.getSessionNames(new NullProgressMonitor());
333 fail("No exeption thrown");
335 } catch (ExecutionException e
) {
343 public void testGetSessionNameGarbage() {
345 fShell
.setScenario(SCEN_GET_SESSION_GARBAGE_OUT
);
346 List
<String
> result
= fService
.getSessionNames(new NullProgressMonitor());
348 assertNotNull(result
);
349 assertEquals(0, result
.size());
351 } catch (ExecutionException e
) {
357 public void testGetSession1() {
359 fShell
.setScenario(SCEN_GET_SESSION1
);
360 ISessionInfo session
= fService
.getSession("mysession", new NullProgressMonitor());
363 assertNotNull(session
);
364 assertEquals("mysession", session
.getName());
365 assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session
.getSessionPath());
366 assertEquals(TraceSessionState
.ACTIVE
, session
.getSessionState());
368 IDomainInfo
[] domains
= session
.getDomains();
369 assertNotNull(domains
);
370 assertEquals(2, domains
.length
);
372 // Verify Kernel domain
373 assertEquals("Kernel", domains
[0].getName());
374 IChannelInfo
[] channels
= domains
[0].getChannels();
375 assertNotNull(channels
);
376 assertEquals(2, channels
.length
);
378 // Verify Kernel's channel0
379 assertEquals("channel0", channels
[0].getName());
380 assertEquals(4, channels
[0].getNumberOfSubBuffers());
381 assertEquals("splice()", channels
[0].getOutputType().getInName());
382 assertEquals(TraceChannelOutputType
.SPLICE
, channels
[0].getOutputType());
383 assertEquals(false, channels
[0].isOverwriteMode());
384 assertEquals(200, channels
[0].getReadTimer());
385 assertEquals(TraceEnablement
.ENABLED
, channels
[0].getState());
386 assertEquals(262144, channels
[0].getSubBufferSize());
387 assertEquals(0, channels
[0].getSwitchTimer());
390 IEventInfo
[] channel0Events
= channels
[0].getEvents();
391 assertNotNull(channel0Events
);
392 assertEquals(2, channel0Events
.length
);
393 assertEquals("block_rq_remap", channel0Events
[0].getName());
394 assertEquals(TraceLogLevel
.TRACE_EMERG
, channel0Events
[0].getLogLevel());
395 assertEquals(TraceEventType
.TRACEPOINT
, channel0Events
[0].getEventType());
396 assertEquals(TraceEnablement
.ENABLED
, channel0Events
[0].getState());
398 assertEquals("block_bio_remap", channel0Events
[1].getName());
399 assertEquals(TraceLogLevel
.TRACE_EMERG
, channel0Events
[1].getLogLevel());
400 assertEquals(TraceEventType
.TRACEPOINT
, channel0Events
[1].getEventType());
401 assertEquals(TraceEnablement
.DISABLED
, channel0Events
[1].getState());
403 // Verify Kernel's channel1
404 assertEquals("channel1", channels
[1].getName());
405 assertEquals(4, channels
[1].getNumberOfSubBuffers());
406 assertEquals("splice()", channels
[1].getOutputType().getInName());
407 assertEquals(TraceChannelOutputType
.SPLICE
, channels
[1].getOutputType());
408 assertEquals(true, channels
[1].isOverwriteMode());
409 assertEquals(400, channels
[1].getReadTimer());
410 assertEquals(TraceEnablement
.DISABLED
, channels
[1].getState());
411 assertEquals(524288, channels
[1].getSubBufferSize());
412 assertEquals(100, channels
[1].getSwitchTimer());
415 IEventInfo
[] channel1Events
= channels
[1].getEvents();
416 assertEquals(0, channel1Events
.length
);
418 // Verify domain UST global
419 assertEquals("UST global", domains
[1].getName());
421 IChannelInfo
[] ustChannels
= domains
[1].getChannels();
423 // Verify UST global's mychannel1
424 assertEquals("mychannel1", ustChannels
[0].getName());
425 assertEquals(8, ustChannels
[0].getNumberOfSubBuffers());
426 assertEquals("mmap()", ustChannels
[0].getOutputType().getInName());
427 assertEquals(TraceChannelOutputType
.MMAP
, ustChannels
[0].getOutputType());
428 assertEquals(true, ustChannels
[0].isOverwriteMode());
429 assertEquals(100, ustChannels
[0].getReadTimer());
430 assertEquals(TraceEnablement
.DISABLED
, ustChannels
[0].getState());
431 assertEquals(8192, ustChannels
[0].getSubBufferSize());
432 assertEquals(200, ustChannels
[0].getSwitchTimer());
435 IEventInfo
[] ustEvents
= ustChannels
[0].getEvents();
436 assertEquals(0, ustEvents
.length
);
438 // Verify UST global's channel0
439 assertEquals("channel0", ustChannels
[1].getName());
440 assertEquals(4, ustChannels
[1].getNumberOfSubBuffers());
441 assertEquals("mmap()", ustChannels
[1].getOutputType().getInName());
442 assertEquals(TraceChannelOutputType
.MMAP
, ustChannels
[1].getOutputType());
443 assertEquals(false, ustChannels
[1].isOverwriteMode());
444 assertEquals(200, ustChannels
[1].getReadTimer());
445 assertEquals(TraceEnablement
.ENABLED
, ustChannels
[1].getState());
446 assertEquals(4096, ustChannels
[1].getSubBufferSize());
447 assertEquals(0, ustChannels
[1].getSwitchTimer());
450 ustEvents
= ustChannels
[1].getEvents();
451 assertEquals(2, ustEvents
.length
);
453 assertEquals("ust_tests_hello:tptest_sighandler", ustEvents
[0].getName());
454 assertEquals(TraceLogLevel
.TRACE_DEBUG_LINE
, ustEvents
[0].getLogLevel());
455 assertEquals(TraceEventType
.TRACEPOINT
, ustEvents
[0].getEventType());
456 assertEquals(TraceEnablement
.DISABLED
, ustEvents
[0].getState());
458 assertEquals("*", ustEvents
[1].getName());
459 assertEquals(getAllEventTraceLogLevel(), ustEvents
[1].getLogLevel());
460 assertEquals(TraceEventType
.TRACEPOINT
, ustEvents
[1].getEventType());
461 assertEquals(TraceEnablement
.ENABLED
, ustEvents
[1].getState());
463 // next session (no detailed information available)
464 session
= fService
.getSession("mysession1", new NullProgressMonitor());
465 assertNotNull(session
);
466 assertEquals("mysession1", session
.getName());
467 assertEquals("/home/user/lttng-traces/mysession1-20120203-133225", session
.getSessionPath());
468 assertEquals(TraceSessionState
.INACTIVE
, session
.getSessionState());
470 domains
= session
.getDomains();
471 assertNotNull(domains
);
472 assertEquals(0, domains
.length
);
473 } catch (ExecutionException e
) {
480 public void testGetSessionWithLive() {
482 fShell
.setScenario(SCEN_GET_SESSION_WITH_LIVE
);
484 // Verify Session (snapshot session, non-live)
485 ISessionInfo session
= fService
.getSession("mysession", new NullProgressMonitor());
486 assertNotNull(session
);
487 assertEquals("mysession", session
.getName());
488 assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session
.getSessionPath());
489 assertEquals(TraceSessionState
.INACTIVE
, session
.getSessionState());
490 assertFalse(session
.isLive());
492 // Verify Session (regular session, non-live)
493 session
= fService
.getSession("mysession1", new NullProgressMonitor());
494 assertNotNull(session
);
495 assertEquals("mysession1", session
.getName());
496 assertEquals("/home/user/lttng-traces/mysession1-20120129-084256", session
.getSessionPath());
497 assertEquals(TraceSessionState
.ACTIVE
, session
.getSessionState());
498 assertFalse(session
.isLive());
500 // Verify Session (regular session, live)
501 session
= fService
.getSession("mysession2", new NullProgressMonitor());
502 assertNotNull(session
);
503 assertEquals("mysession2", session
.getName());
504 assertEquals("tcp4://172.0.0.1:5342/ [data: 5343]", session
.getSessionPath());
505 assertEquals("net://127.0.0.1", session
.getLiveUrl());
506 assertEquals(Integer
.valueOf(5344), session
.getLivePort());
507 assertEquals(1000000, session
.getLiveDelay());
508 assertEquals(TraceSessionState
.INACTIVE
, session
.getSessionState());
509 assertTrue(session
.isLive());
511 } catch (ExecutionException e
) {
519 protected TraceLogLevel
getAllEventTraceLogLevel() {
520 return TraceLogLevel
.LEVEL_UNKNOWN
;
523 public void testGetKernelProvider() {
525 fShell
.setScenario(SCEN_GET_KERNEL_PROVIDER1
);
526 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
529 assertNotNull(events
);
530 assertEquals(3, events
.size());
532 IBaseEventInfo baseEventInfo
= events
.get(0);
533 assertNotNull(baseEventInfo
);
534 assertEquals("sched_kthread_stop", baseEventInfo
.getName());
535 assertEquals(TraceLogLevel
.TRACE_EMERG
, baseEventInfo
.getLogLevel());
536 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
538 baseEventInfo
= events
.get(1);
539 assertEquals("sched_kthread_stop_ret", baseEventInfo
.getName());
540 assertEquals(TraceLogLevel
.TRACE_EMERG
, baseEventInfo
.getLogLevel());
541 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
543 baseEventInfo
= events
.get(2);
544 assertEquals("sched_wakeup_new", baseEventInfo
.getName());
545 assertEquals(TraceLogLevel
.TRACE_EMERG
, baseEventInfo
.getLogLevel());
546 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
548 } catch (ExecutionException e
) {
554 public void testGetKernelProviderNoKernel1() {
556 fShell
.setScenario(SCEN_LIST_WITH_NO_KERNEL1
);
557 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
560 assertNotNull(events
);
561 assertEquals(0, events
.size());
563 } catch (ExecutionException e
) {
569 public void testGetKernelProviderNoKernel2() {
571 fShell
.setScenario(SCEN_LIST_WITH_NO_KERNEL2
);
572 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
575 assertNotNull(events
);
576 assertEquals(0, events
.size());
578 } catch (ExecutionException e
) {
584 public void testGetKernelProviderNoKernelVerbose() {
587 fShell
.setScenario(SCEN_LIST_WITH_NO_KERNEL_VERBOSE
);
588 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
591 assertNotNull(events
);
592 assertEquals(0, events
.size());
594 } catch (ExecutionException e
) {
602 public void testGetUstProvider() {
604 fShell
.setScenario(SCEN_GET_UST_PROVIDER1
);
605 List
<IUstProviderInfo
> providers
= fService
.getUstProvider();
607 // Check all providers
608 assertNotNull(providers
);
609 assertEquals(2, providers
.size());
611 //Verify first provider
612 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(0).getName());
613 assertEquals(9379, providers
.get(0).getPid());
616 IBaseEventInfo
[] events
= providers
.get(0).getEvents();
617 assertNotNull(events
);
618 assertEquals(2, events
.length
);
620 IBaseEventInfo baseEventInfo
= events
[0];
621 assertNotNull(baseEventInfo
);
622 assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo
.getName());
623 assertEquals(TraceLogLevel
.TRACE_DEBUG_MODULE
, baseEventInfo
.getLogLevel());
624 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
626 baseEventInfo
= events
[1];
627 assertEquals("ust_tests_hello:tptest", baseEventInfo
.getName());
628 assertEquals(TraceLogLevel
.TRACE_INFO
, baseEventInfo
.getLogLevel());
629 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
631 //Verify second provider
632 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(1).getName());
633 assertEquals(4852, providers
.get(1).getPid());
636 events
= providers
.get(1).getEvents();
637 assertNotNull(events
);
638 assertEquals(2, events
.length
);
640 baseEventInfo
= events
[0];
641 assertNotNull(baseEventInfo
);
642 assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo
.getName());
643 assertEquals(TraceLogLevel
.TRACE_WARNING
, baseEventInfo
.getLogLevel());
644 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
646 baseEventInfo
= events
[1];
647 assertEquals("ust_tests_hello:tptest", baseEventInfo
.getName());
648 assertEquals(TraceLogLevel
.TRACE_DEBUG_FUNCTION
, baseEventInfo
.getLogLevel());
649 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
651 } catch (ExecutionException e
) {
657 public void testUstProvider2() {
659 fShell
.setScenario(SCEN_GET_UST_PROVIDER2
);
660 List
<IUstProviderInfo
> providers
= fService
.getUstProvider();
662 assertNotNull(providers
);
663 assertEquals(0, providers
.size());
665 } catch (ExecutionException e
) {
671 public void testGetUstProvider3() {
673 fShell
.setScenario(SCEN_GET_UST_PROVIDER3
);
675 ((LTTngControlService
)fService
).setVersion("2.1.0");
676 List
<IUstProviderInfo
> providers
= fService
.getUstProvider();
678 // Check all providers
679 assertNotNull(providers
);
680 assertEquals(2, providers
.size());
682 //Verify first provider
683 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(0).getName());
684 assertEquals(9379, providers
.get(0).getPid());
687 IBaseEventInfo
[] events
= providers
.get(0).getEvents();
688 assertNotNull(events
);
689 assertEquals(2, events
.length
);
691 IBaseEventInfo baseEventInfo
= events
[0];
692 assertNotNull(baseEventInfo
);
693 IFieldInfo
[] fields
= baseEventInfo
.getFields();
694 assertNotNull(fields
);
695 assertEquals(0, fields
.length
);
697 baseEventInfo
= events
[1];
698 fields
= baseEventInfo
.getFields();
699 assertNotNull(fields
);
700 assertEquals(3, fields
.length
);
701 assertEquals("doublefield", fields
[0].getName());
702 assertEquals("float", fields
[0].getFieldType());
704 assertEquals("floatfield", fields
[1].getName());
705 assertEquals("float", fields
[1].getFieldType());
707 assertEquals("stringfield", fields
[2].getName());
708 assertEquals("string", fields
[2].getFieldType());
710 //Verify second provider
711 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(1).getName());
712 assertEquals(4852, providers
.get(1).getPid());
715 events
= providers
.get(1).getEvents();
716 assertNotNull(events
);
717 assertEquals(2, events
.length
);
719 baseEventInfo
= events
[0];
720 assertNotNull(baseEventInfo
);
721 fields
= baseEventInfo
.getFields();
722 assertNotNull(fields
);
723 assertEquals(0, fields
.length
);
725 baseEventInfo
= events
[1];
726 fields
= baseEventInfo
.getFields();
727 assertNotNull(fields
);
728 assertEquals(3, fields
.length
);
730 assertEquals("doublefield", fields
[0].getName());
731 assertEquals("float", fields
[0].getFieldType());
733 assertEquals("floatfield", fields
[1].getName());
734 assertEquals("float", fields
[1].getFieldType());
736 assertEquals("stringfield", fields
[2].getName());
737 assertEquals("string", fields
[2].getFieldType());
740 ((LTTngControlService
)fService
).setVersion("2.0.0");
742 } catch (ExecutionException e
) {
749 public void testGetKernelProviderNoUst1() {
751 fShell
.setScenario(SCEN_LIST_WITH_NO_UST1
);
752 List
<IUstProviderInfo
> providerList
= fService
.getUstProvider(new NullProgressMonitor());
754 // Verify Provider info
755 assertNotNull(providerList
);
756 assertEquals(0, providerList
.size());
758 } catch (ExecutionException e
) {
765 public void testGetKernelProviderNoUst2() {
768 ((LTTngControlService
)fService
).setVersion("2.1.0");
770 fShell
.setScenario(SCEN_LIST_WITH_NO_UST2
);
771 List
<IUstProviderInfo
> providerList
= fService
.getUstProvider(new NullProgressMonitor());
773 // Verify Provider info
774 assertNotNull(providerList
);
775 assertEquals(0, providerList
.size());
778 ((LTTngControlService
)fService
).setVersion("2.0.0");
780 } catch (ExecutionException e
) {
786 public void testGetKernelProviderNoUst3() {
790 ((LTTngControlService
)fService
).setVersion("2.1.0");
792 fShell
.setScenario(SCEN_LIST_WITH_NO_UST3
);
793 List
<IUstProviderInfo
> providerList
= fService
.getUstProvider(new NullProgressMonitor());
795 // Verify provider info
796 assertNotNull(providerList
);
797 assertEquals(0, providerList
.size());
800 ((LTTngControlService
)fService
).setVersion("2.0.0");
802 } catch (ExecutionException e
) {
808 public void testGetKernelProviderNoUstVerbose() {
813 ((LTTngControlService
)fService
).setVersion("2.1.0");
815 fShell
.setScenario(SCEN_LIST_WITH_NO_UST_VERBOSE
);
816 List
<IUstProviderInfo
> providerList
= fService
.getUstProvider(new NullProgressMonitor());
818 // Verify provider info
819 assertNotNull(providerList
);
820 assertEquals(0, providerList
.size());
823 ((LTTngControlService
)fService
).setVersion("2.0.0");
825 } catch (ExecutionException e
) {
835 public void testCreateSession() {
837 fShell
.setScenario(SCEN_CREATE_SESSION1
);
839 ISessionInfo info
= fService
.createSession(new SessionInfo("mysession2"), new NullProgressMonitor());
841 assertEquals("mysession2", info
.getName());
842 assertNotNull(info
.getSessionPath());
843 assertTrue(info
.getSessionPath().contains("mysession2"));
844 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
845 } catch (ExecutionException e
) {
851 public void testCreateSessionWithPrompt() {
853 // First line has the shell prompt before the command output
854 // This can happen in a real application if the command line is not echoed by the shell.
855 fShell
.setScenario(SCEN_CREATE_SESSION_WITH_PROMPT
);
857 // First line has no shell prompt before the output
858 ISessionInfo info
= fService
.createSession(new SessionInfo("mysession2"), new NullProgressMonitor());
860 assertEquals("mysession2", info
.getName());
861 assertNotNull(info
.getSessionPath());
862 assertTrue(info
.getSessionPath().contains("mysession2"));
863 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
864 } catch (ExecutionException e
) {
870 public void testCreateSessionVariants() {
872 fShell
.setScenario(SCEN_CREATE_SESSION_VARIANTS
);
875 fService
.createSession(new SessionInfo("alreadyExist"), new NullProgressMonitor());
876 fail("No exeption thrown");
877 } catch (ExecutionException e
) {
882 fService
.createSession(new SessionInfo("wrongName"), new NullProgressMonitor());
883 fail("No exeption thrown");
884 } catch (ExecutionException e
) {
889 ISessionInfo sessionInfo
= new SessionInfo("withPath");
890 sessionInfo
.setSessionPath("/home/user/hallo");
891 fService
.createSession(sessionInfo
, new NullProgressMonitor());
892 fail("No exeption thrown");
893 } catch (ExecutionException e
) {
898 ISessionInfo info
= fService
.createSession(new SessionInfo("session with spaces"), new NullProgressMonitor());
900 assertEquals("session with spaces", info
.getName());
901 assertNotNull(info
.getSessionPath());
902 assertTrue(info
.getSessionPath().contains("session with spaces"));
903 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
905 } catch (ExecutionException e
) {
910 ISessionInfo sessionInfo
= new SessionInfo("pathWithSpaces");
911 sessionInfo
.setSessionPath("/home/user/hallo user/here");
912 ISessionInfo info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
914 assertEquals("pathWithSpaces", info
.getName());
915 assertNotNull(info
.getSessionPath());
916 assertTrue(info
.getSessionPath().contains("/home/user/hallo user/here"));
917 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
919 } catch (ExecutionException e
) {
925 public void testDestroySession() {
927 fShell
.setScenario(SCEN_DESTROY_SESSION1
);
928 fService
.destroySession("mysession2", new NullProgressMonitor());
929 } catch (ExecutionException e
) {
935 public void testDestroySessionVerbose() {
938 fShell
.setScenario(SCEN_DESTROY_SESSION_VERBOSE
);
939 fService
.destroySession("mysession2", new NullProgressMonitor());
940 } catch (ExecutionException e
) {
948 public void testCreateChannel() {
950 ((LTTngControlService
)fService
).setVersion("2.2.0");
951 String sessionName
= "mysession2";
952 List
<String
> list
= new ArrayList
<>();
953 String kernelChannel0
= "mychannel0";
954 String kernelChannel1
= "mychannel1";
955 list
.add(kernelChannel0
);
956 list
.add(kernelChannel1
);
958 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
960 // Create/enable/configure 2 kernel channels
961 ChannelInfo chanInfo
= new ChannelInfo("");
962 chanInfo
.setOverwriteMode(true);
963 chanInfo
.setSubBufferSize(16384);
964 chanInfo
.setReadTimer(100);
965 chanInfo
.setSwitchTimer(200);
966 chanInfo
.setNumberOfSubBuffers(2);
967 chanInfo
.setMaxNumberTraceFiles(10);
968 chanInfo
.setMaxSizeTraceFiles(0);
969 fService
.enableChannels(sessionName
, list
, TraceDomainType
.KERNEL
, chanInfo
, new NullProgressMonitor());
971 // Create/enable/configure 1 UST channel
973 list
.add("ustChannel");
975 chanInfo
= new ChannelInfo("");
976 chanInfo
.setOverwriteMode(true);
977 chanInfo
.setSubBufferSize(32768);
978 chanInfo
.setReadTimer(200);
979 chanInfo
.setSwitchTimer(100);
980 chanInfo
.setNumberOfSubBuffers(1);
981 chanInfo
.setMaxNumberTraceFiles(20);
982 chanInfo
.setMaxSizeTraceFiles(0);
983 fService
.enableChannels(sessionName
, list
, TraceDomainType
.UST
, chanInfo
, new NullProgressMonitor());
984 ((LTTngControlService
)fService
).setVersion("2.0.0");
986 } catch (ExecutionException e
) {
992 public void testCreateChannelUIDBuffer() {
994 ((LTTngControlService
)fService
).setVersion("2.2.0");
995 String sessionName
= "mysession2";
996 List
<String
> list
= new ArrayList
<>();
997 String USTChannel
= "ustChannel";
998 list
.add(USTChannel
);
999 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
1001 ChannelInfo chanInfo
= new ChannelInfo("");
1002 chanInfo
.setOverwriteMode(true);
1003 chanInfo
.setSubBufferSize(32768);
1004 chanInfo
.setReadTimer(200);
1005 chanInfo
.setSwitchTimer(100);
1006 chanInfo
.setNumberOfSubBuffers(1);
1007 chanInfo
.setMaxNumberTraceFiles(20);
1008 chanInfo
.setMaxSizeTraceFiles(0);
1009 chanInfo
.setBufferType(BufferType
.BUFFER_PER_UID
);
1010 fService
.enableChannels(sessionName
, list
, TraceDomainType
.UST
, chanInfo
, new NullProgressMonitor());
1011 ((LTTngControlService
)fService
).setVersion("2.0.0");
1013 } catch (ExecutionException e
) {
1019 public void testCreateChannelPIDBuffer() {
1021 ((LTTngControlService
)fService
).setVersion("2.2.0");
1022 String sessionName
= "mysession2";
1023 List
<String
> list
= new ArrayList
<>();
1024 String USTChannel
= "ustChannel";
1025 list
.add(USTChannel
);
1026 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
1029 ChannelInfo chanInfo
= new ChannelInfo("");
1030 chanInfo
.setOverwriteMode(true);
1031 chanInfo
.setSubBufferSize(-1);
1032 chanInfo
.setReadTimer(-1);
1033 chanInfo
.setSwitchTimer(-1);
1034 chanInfo
.setNumberOfSubBuffers(-1);
1035 chanInfo
.setMaxNumberTraceFiles(-1);
1036 chanInfo
.setMaxSizeTraceFiles(-1);
1037 chanInfo
.setBufferType(BufferType
.BUFFER_PER_PID
);
1039 fService
.enableChannels(sessionName
, list
, TraceDomainType
.UST
, chanInfo
, new NullProgressMonitor());
1040 ((LTTngControlService
)fService
).setVersion("2.0.0");
1042 } catch (ExecutionException e
) {
1048 public void testDisableChannel() {
1051 String sessionName
= "mysession2";
1052 List
<String
> list
= new ArrayList
<>();
1053 String kernelChannel0
= "mychannel0";
1054 String kernelChannel1
= "mychannel1";
1055 list
.add(kernelChannel0
);
1056 list
.add(kernelChannel1
);
1058 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
1059 fService
.disableChannels(sessionName
, list
, TraceDomainType
.KERNEL
, new NullProgressMonitor());
1062 list
.add("ustChannel");
1063 fService
.disableChannels(sessionName
, list
, TraceDomainType
.UST
, new NullProgressMonitor());
1065 } catch (ExecutionException e
) {
1071 public void testEnableChannel() {
1074 String sessionName
= "mysession2";
1075 List
<String
> list
= new ArrayList
<>();
1076 String kernelChannel0
= "mychannel0";
1077 String kernelChannel1
= "mychannel1";
1078 list
.add(kernelChannel0
);
1079 list
.add(kernelChannel1
);
1081 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
1082 fService
.enableChannels(sessionName
, list
, TraceDomainType
.KERNEL
, null, new NullProgressMonitor());
1084 // Create/enable/configure 1 UST channel
1086 list
.add("ustChannel");
1088 fService
.enableChannels(sessionName
, list
, TraceDomainType
.UST
, null, new NullProgressMonitor());
1090 } catch (ExecutionException e
) {
1096 public void testEnableEvents() {
1098 String sessionName
= "mysession2";
1099 String channelName
= "mychannel";
1101 List
<String
> eventList
= new ArrayList
<>();
1102 List
<String
> excludeList
= new ArrayList
<>();
1104 String eventName0
= "block_rq_remap";
1105 String eventName1
= "block_bio_remap";
1106 String eventName2
= "softirq_entry";
1107 String ustEventName0
= "ust_tests_hello:tptest_sighandler";
1108 String ustEventName1
= "ust_tests_bye:tptest_sighandler";
1109 String ustEventWildcard
= "ust*";
1111 fShell
.setScenario(SCEN_EVENT_HANDLING
);
1113 // 1) session name, channel = null, 3 event names, kernel
1114 eventList
.add(eventName0
);
1115 eventList
.add(eventName1
);
1116 eventList
.add(eventName2
);
1117 fService
.enableEvents(sessionName
, null, eventList
, TraceDomainType
.KERNEL
, null, null, new NullProgressMonitor());
1119 // 2) session name, channel = mychannel, event name= null, kernel
1120 fService
.enableEvents(sessionName
, channelName
, null, TraceDomainType
.KERNEL
, null, null, new NullProgressMonitor());
1122 // 3) session name, channel = mychannel, 1 event name, ust, no filter
1124 eventList
.add(ustEventName0
);
1125 fService
.enableEvents(sessionName
, channelName
, eventList
, TraceDomainType
.UST
, null, null, new NullProgressMonitor());
1127 // 4) session name, channel = mychannel, no event name, ust, with filter
1128 fService
.enableEvents(sessionName
, channelName
, eventList
, TraceDomainType
.UST
, "intfield==10", null, new NullProgressMonitor());
1130 // 5) session name, channel = mychannel, no event name, ust, no filter
1132 fService
.enableEvents(sessionName
, channelName
, eventList
, TraceDomainType
.UST
, null, null, new NullProgressMonitor());
1134 // 6) session name, channel = null,
1135 fService
.enableEvents(sessionName
, null, ILttngControlService
.ALL_EVENTS
, TraceDomainType
.KERNEL
, null, null, new NullProgressMonitor());
1137 // 7) session name, channel = mychannel, all events, ust, exclude 1 event
1138 excludeList
.add(ustEventName0
);
1139 fService
.enableEvents(sessionName
, channelName
, null, TraceDomainType
.UST
, null, excludeList
, new NullProgressMonitor());
1141 // 8) session name, channel = mychannel, all events, ust, exclude 2 events
1142 excludeList
.add(ustEventName1
);
1143 fService
.enableEvents(sessionName
, channelName
, null, TraceDomainType
.UST
, null, excludeList
, new NullProgressMonitor());
1145 // 9) session name, channel = mychannel, enable 'ust*', ust, exclude 2 events
1146 eventList
.add(ustEventWildcard
);
1147 fService
.enableEvents(sessionName
, channelName
, eventList
, TraceDomainType
.UST
, null, excludeList
, new NullProgressMonitor());
1149 // 10) session name, channel = mychannel, enable 'ust*', ust, with filter, exclude 2 events
1150 fService
.enableEvents(sessionName
, channelName
, eventList
, TraceDomainType
.UST
, "ust==\"Challenger\"", excludeList
, new NullProgressMonitor());
1152 } catch (ExecutionException e
) {
1158 public void testEventExcluded() {
1160 String sessionName
= "mysession2";
1161 String channelName
= "mychannel";
1163 List
<String
> eventList
= new ArrayList
<>();
1164 List
<String
> excludeList
= new ArrayList
<>();
1166 String ustEventName0
= "ust_tests_hello:tptest_sighandler";
1167 String ustEventName1
= "ust_tests_bye:tptest_sighandler";
1168 String ustEventWildcard
= "ust*";
1171 LttngVersion version
= fService
.getVersion();
1172 fShell
.setScenario(SCEN_EVENT_EXCLUDED
);
1174 // 1) 1 event excluded
1175 eventList
.add(ustEventWildcard
);
1176 excludeList
.add(ustEventName0
);
1177 fService
.enableEvents(sessionName
, channelName
, eventList
, TraceDomainType
.UST
, null, excludeList
, new NullProgressMonitor());
1180 ISessionInfo session
= fService
.getSession(sessionName
, new NullProgressMonitor());
1181 assertNotNull(session
);
1182 IEventInfo eventInfo
= session
.getDomains()[0].getChannels()[0].getEvents()[0];
1183 assertNotNull(eventInfo
);
1184 // version 2.8 and above supports the excluded events list
1185 if (version
.getMajor() > 1 && version
.getMinor() > 7) {
1186 assertTrue(eventInfo
.getExcludedEvents().contains(ustEventName0
));
1188 assertEquals("has exclusions", eventInfo
.getExcludedEvents());
1191 // 2) 2 events excluded
1192 excludeList
.add(ustEventName1
);
1193 fService
.enableEvents(sessionName
, channelName
, eventList
, TraceDomainType
.UST
, null, excludeList
, new NullProgressMonitor());
1195 session
= fService
.getSession(sessionName
, new NullProgressMonitor());
1196 assertNotNull(session
);
1197 eventInfo
= session
.getDomains()[0].getChannels()[0].getEvents()[0];
1198 assertNotNull(eventInfo
);
1200 // version 2.8 and above supports the excluded events list
1201 if (version
.getMajor() > 1 && version
.getMinor() > 7) {
1202 assertTrue(eventInfo
.getExcludedEvents().contains(ustEventName0
));
1203 assertTrue(eventInfo
.getExcludedEvents().contains(ustEventName1
));
1205 assertEquals("has exclusions", eventInfo
.getExcludedEvents());
1208 // 3) 2 events excluded and using a filter
1209 fService
.enableEvents(sessionName
, channelName
, eventList
, TraceDomainType
.UST
, "ust==\"Challenger\"", excludeList
, new NullProgressMonitor());
1211 session
= fService
.getSession(sessionName
, new NullProgressMonitor());
1212 assertNotNull(session
);
1213 eventInfo
= session
.getDomains()[0].getChannels()[0].getEvents()[0];
1214 assertNotNull(eventInfo
);
1216 // version 2.8 and above supports the excluded events list
1217 if (version
.getMajor() > 1 && version
.getMinor() > 7) {
1218 assertTrue(eventInfo
.getExcludedEvents().contains(ustEventName0
));
1219 assertTrue(eventInfo
.getExcludedEvents().contains(ustEventName1
));
1221 assertEquals("has exclusions", eventInfo
.getExcludedEvents());
1224 if (version
.getMajor() > 1 && version
.getMinor() > 7) {
1225 assertTrue(eventInfo
.getFilterExpression().equals("ust==Challenger"));
1227 assertEquals("with filter", eventInfo
.getFilterExpression());
1230 } catch (ExecutionException e
) {
1236 public void testEnableSyscalls() {
1238 // 1) session name, channel = null, 3 event names, kernel
1239 String sessionName
= "mysession2";
1240 String channelName
= "mychannel";
1241 List
<String
> syscalls
= new ArrayList
<>();
1243 fShell
.setScenario(SCEN_EVENT_HANDLING
);
1245 // 1) session name, channel = null, syscall = all
1246 fService
.enableSyscalls(sessionName
, null, null, new NullProgressMonitor());
1248 // 2) session name, channel = mychannel, syscall = all
1249 fService
.enableSyscalls(sessionName
, channelName
, null, new NullProgressMonitor());
1251 // 3) session name, channel = mychannel, syscall = close
1252 syscalls
.add("close");
1253 fService
.enableSyscalls(sessionName
, channelName
, syscalls
, new NullProgressMonitor());
1255 // 4) session name, channel = mychannel, syscall = close,read,write
1256 syscalls
.add("read");
1257 syscalls
.add("write");
1258 fService
.enableSyscalls(sessionName
, channelName
, syscalls
, new NullProgressMonitor());
1260 } catch (ExecutionException e
) {
1266 public void testDynamicProbe() {
1268 // 1) session name, channel = null, 3 event names, kernel
1269 String sessionName
= "mysession2";
1270 String channelName
= "mychannel";
1271 String eventName0
= "myevent0";
1272 String eventName1
= "myevent1";
1273 String functionProbe
= "0xc0101340";
1274 String dynProbe
= "init_post";
1276 fShell
.setScenario(SCEN_EVENT_HANDLING
);
1278 // 1) session name, channel = null, event name, function probe, probe
1279 fService
.enableProbe(sessionName
, null, eventName0
, true, functionProbe
, new NullProgressMonitor());
1281 // 2) session name, channel = mychannel
1282 fService
.enableProbe(sessionName
, channelName
, eventName1
, false, dynProbe
, new NullProgressMonitor());
1284 } catch (ExecutionException e
) {
1290 public void testEnableLogLevel() {
1292 // 1) session name, channel = null, 3 event names, kernel
1293 String sessionName
= "mysession2";
1294 String channelName
= "mychannel";
1295 String eventName4
= "myevent4";
1296 String eventName5
= "myevent5";
1298 fShell
.setScenario(SCEN_EVENT_HANDLING
);
1300 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
1301 fService
.enableLogLevel(sessionName
, null, Arrays
.asList(eventName4
), LogLevelType
.LOGLEVEL_ONLY
, TraceLogLevel
.TRACE_DEBUG
, null, TraceDomainType
.UST
, new NullProgressMonitor());
1303 // 2) session name, channel = mychannel, null, loglevel, TRACE_DEBUG_FUNCTION
1304 fService
.enableLogLevel(sessionName
, channelName
, Arrays
.asList(eventName5
), LogLevelType
.LOGLEVEL
, TraceLogLevel
.TRACE_DEBUG_FUNCTION
, null, TraceDomainType
.UST
, new NullProgressMonitor());
1306 // TODO add test with filters
1308 } catch (ExecutionException e
) {
1314 public void testAddContext() {
1316 // 1) session name, channel = null, 3 event names, kernel
1317 String sessionName
= "mysession2";
1318 String channelName
= "mychannel";
1319 String eventName
= "ust_tests_hello:tptest_sighandler";
1320 List
<String
> contexts
= new ArrayList
<>();
1321 contexts
.add("prio");
1322 contexts
.add("pid");
1324 fShell
.setScenario(SCEN_CONTEXT_HANDLING
);
1326 List
<String
> availContexts
= fService
.getContextList(new NullProgressMonitor());
1327 assertNotNull(availContexts
);
1328 assertEquals(12, availContexts
.size());
1330 // A very "hard-coded" way to verify but it works ...
1331 Set
<String
> expectedContexts
= new HashSet
<>();
1332 expectedContexts
.add("pid");
1333 expectedContexts
.add("procname");
1334 expectedContexts
.add("prio");
1335 expectedContexts
.add("nice");
1336 expectedContexts
.add("vpid");
1337 expectedContexts
.add("tid");
1338 expectedContexts
.add("pthread_id");
1339 expectedContexts
.add("vtid");
1340 expectedContexts
.add("ppid");
1341 expectedContexts
.add("vppid");
1342 expectedContexts
.add("perf:cpu-cycles");
1343 expectedContexts
.add("perf:cycles");
1345 assertTrue(expectedContexts
.containsAll(availContexts
));
1347 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
1348 fService
.addContexts(sessionName
, channelName
, eventName
, TraceDomainType
.UST
, contexts
, new NullProgressMonitor());
1350 } catch (ExecutionException e
) {
1356 public void testAddContextFailure() {
1358 // 1) session name, channel = null, 3 event names, kernel
1359 String sessionName
= "mysession2";
1360 String channelName
= "mychannel";
1361 String eventName
= "ust_tests_hello:tptest_sighandler";
1362 List
<String
> contexts
= new ArrayList
<>();
1363 contexts
.add("prio");
1364 contexts
.add("pid");
1365 fShell
.setScenario(SCEN_CONTEXT_ERROR_HANDLING
);
1367 fService
.getContextList(new NullProgressMonitor());
1368 fail("No exeption generated");
1369 } catch (ExecutionException e
) {
1373 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
1374 fService
.addContexts(sessionName
, channelName
, eventName
, TraceDomainType
.UST
, contexts
, new NullProgressMonitor());
1375 fail("No exeption generated");
1376 } catch (ExecutionException e
) {
1382 public void testCreateSession2_1() {
1385 fShell
.setScenario(SCEN_CREATE_SESSION_2_1
);
1387 ISessionInfo sessionInfo
= new SessionInfo("mysession");
1388 sessionInfo
.setNetworkUrl("net://172.0.0.1");
1389 sessionInfo
.setStreamedTrace(true);
1390 ISessionInfo info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1391 assertNotNull(info
);
1392 assertEquals("mysession", info
.getName());
1393 assertEquals("net://172.0.0.1", info
.getSessionPath());
1394 assertTrue(info
.isStreamedTrace());
1395 fService
.destroySession("mysession", new NullProgressMonitor());
1397 sessionInfo
= new SessionInfo("mysession");
1398 sessionInfo
.setStreamedTrace(true);
1399 sessionInfo
.setNetworkUrl("file:///tmp");
1400 info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1401 assertNotNull(info
);
1402 assertEquals("mysession", info
.getName());
1403 assertEquals("file:///tmp", info
.getSessionPath());
1404 assertTrue(!info
.isStreamedTrace());
1405 fService
.destroySession("mysession", new NullProgressMonitor());
1407 sessionInfo
= new SessionInfo("mysession");
1408 sessionInfo
.setStreamedTrace(true);
1409 sessionInfo
.setNetworkUrl("file:///tmp");
1410 info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1411 assertNotNull(info
);
1412 assertEquals("mysession", info
.getName());
1413 assertEquals("file:///tmp", info
.getSessionPath());
1414 assertTrue(!info
.isStreamedTrace());
1415 fService
.destroySession("mysession", new NullProgressMonitor());
1417 sessionInfo
= new SessionInfo("mysession");
1418 sessionInfo
.setStreamedTrace(true);
1419 sessionInfo
.setControlUrl("tcp://172.0.0.1");
1420 sessionInfo
.setDataUrl("tcp://172.0.0.1:5343");
1421 info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1422 assertNotNull(info
);
1423 assertEquals("mysession", info
.getName());
1424 assertEquals("", info
.getSessionPath()); // the complete network path is not available at this point
1425 assertTrue(info
.isStreamedTrace());
1426 fService
.destroySession("mysession", new NullProgressMonitor());
1428 sessionInfo
= new SessionInfo("mysession");
1429 sessionInfo
.setStreamedTrace(true);
1430 sessionInfo
.setNetworkUrl("net://172.0.0.1:1234:2345");
1431 info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1432 assertNotNull(info
);
1433 assertEquals("mysession", info
.getName());
1434 assertEquals("net://172.0.0.1:1234:2345", info
.getSessionPath());
1435 assertTrue(info
.isStreamedTrace());
1436 fService
.destroySession("mysession", new NullProgressMonitor());
1440 sessionInfo
= new SessionInfo("mysession");
1441 sessionInfo
.setStreamedTrace(true);
1442 sessionInfo
.setNetworkUrl("net://172.0.0.1");
1443 info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1444 assertNotNull(info
);
1445 assertEquals("mysession", info
.getName());
1446 assertEquals("net://172.0.0.1", info
.getSessionPath());
1447 assertTrue(info
.isStreamedTrace());
1449 fService
.destroySession("mysession", new NullProgressMonitor());
1452 } catch (ExecutionException e
) {
1458 public void testCreateSessionVerbose2_1() {
1460 fShell
.setScenario(SCEN_CREATE_SESSION_VERBOSE_2_1
);
1463 ISessionInfo sessionInfo
= new SessionInfo("mysession");
1464 sessionInfo
.setStreamedTrace(true);
1465 sessionInfo
.setNetworkUrl("net://172.0.0.1");
1466 ISessionInfo info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1467 assertNotNull(info
);
1468 assertEquals("mysession", info
.getName());
1469 assertEquals("net://172.0.0.1", info
.getSessionPath());
1470 assertTrue(info
.isStreamedTrace());
1471 fService
.destroySession("mysession", new NullProgressMonitor());
1472 } catch (ExecutionException e
) {
1480 public void testCreateSnapshotSession() {
1482 fShell
.setScenario(SCEN_CREATE_SNAPSHOT_SESSION
);
1483 ISessionInfo params
= new SessionInfo("mysession");
1484 params
.setSnapshot(true);
1485 ISessionInfo sessionInfo
= fService
.createSession(params
, new NullProgressMonitor());
1486 assertNotNull(sessionInfo
);
1487 assertEquals("mysession", sessionInfo
.getName());
1488 assertTrue(sessionInfo
.isSnapshotSession());
1489 assertEquals("", sessionInfo
.getSessionPath());
1490 assertTrue(!sessionInfo
.isStreamedTrace());
1492 assertEquals(TraceSessionState
.INACTIVE
, sessionInfo
.getSessionState());
1494 List
<String
> names
= fService
.getSessionNames(new NullProgressMonitor());
1495 assertEquals(names
.get(0), "mysession");
1497 ISnapshotInfo snapshotInfo
= fService
.getSnapshotInfo("mysession", new NullProgressMonitor());
1498 assertNotNull(snapshotInfo
);
1499 assertEquals("snapshot-1", snapshotInfo
.getName());
1500 assertEquals("/home/user/lttng-traces/mysession-20130913-141651", snapshotInfo
.getSnapshotPath());
1501 assertEquals(1, snapshotInfo
.getId());
1502 assertTrue(!snapshotInfo
.isStreamedSnapshot());
1504 // we need to set the snapshotInfo to so that the session path is set correctly
1505 sessionInfo
.setSnapshotInfo(snapshotInfo
);
1506 assertEquals("/home/user/lttng-traces/mysession-20130913-141651", sessionInfo
.getSessionPath());
1508 fService
.recordSnapshot("mysession", new NullProgressMonitor());
1510 fService
.destroySession("mysession", new NullProgressMonitor());
1512 } catch (ExecutionException e
) {
1518 public void testCreateSnapshotSession2_5() {
1520 fShell
.setScenario(SCEN_CREATE_SNAPSHOT_SESSION_2_5
);
1521 ISessionInfo params
= new SessionInfo("mysession");
1522 params
.setSnapshot(true);
1523 ISessionInfo sessionInfo
= fService
.createSession(params
, new NullProgressMonitor());
1524 assertNotNull(sessionInfo
);
1525 assertEquals("mysession", sessionInfo
.getName());
1526 assertTrue(sessionInfo
.isSnapshotSession());
1527 assertEquals("", sessionInfo
.getSessionPath());
1528 assertTrue(!sessionInfo
.isStreamedTrace());
1530 assertEquals(TraceSessionState
.INACTIVE
, sessionInfo
.getSessionState());
1532 List
<String
> names
= fService
.getSessionNames(new NullProgressMonitor());
1533 assertEquals(names
.get(0), "mysession");
1535 ISnapshotInfo snapshotInfo
= fService
.getSnapshotInfo("mysession", new NullProgressMonitor());
1536 assertNotNull(snapshotInfo
);
1537 assertEquals("snapshot-1", snapshotInfo
.getName());
1538 assertEquals("/home/user/lttng-traces/mysession-20130913-141651", snapshotInfo
.getSnapshotPath());
1539 assertEquals(1, snapshotInfo
.getId());
1540 assertTrue(!snapshotInfo
.isStreamedSnapshot());
1542 // we need to set the snapshotInfo to so that the session path is set correctly
1543 sessionInfo
.setSnapshotInfo(snapshotInfo
);
1544 assertEquals("/home/user/lttng-traces/mysession-20130913-141651", sessionInfo
.getSessionPath());
1546 fService
.recordSnapshot("mysession", new NullProgressMonitor());
1548 fService
.destroySession("mysession", new NullProgressMonitor());
1550 } catch (ExecutionException e
) {
1555 public void testCreateStreamedSnapshotSession() {
1557 fShell
.setScenario(SCEN_CREATE_STREAMED_SNAPSHOT_SESSION
);
1559 ISessionInfo params
= new SessionInfo("mysession");
1560 params
.setNetworkUrl("net://172.0.0.1");
1561 ISessionInfo sessionInfo
= fService
.createSession(params
, new NullProgressMonitor());
1562 assertNotNull(sessionInfo
);
1563 assertEquals("mysession", sessionInfo
.getName());
1564 assertTrue(sessionInfo
.isSnapshotSession());
1566 assertEquals(TraceSessionState
.INACTIVE
, sessionInfo
.getSessionState());
1567 assertTrue(sessionInfo
.isStreamedTrace());
1569 List
<String
> names
= fService
.getSessionNames(new NullProgressMonitor());
1570 assertEquals(names
.get(0), "mysession");
1572 ISnapshotInfo snapshotInfo
= sessionInfo
.getSnapshotInfo();
1573 assertNotNull(sessionInfo
);
1574 assertEquals("snapshot-2", snapshotInfo
.getName());
1575 assertEquals("net4://172.0.0.1:5342/", snapshotInfo
.getSnapshotPath());
1576 assertEquals(2, snapshotInfo
.getId());
1577 assertTrue(snapshotInfo
.isStreamedSnapshot());
1579 // we need to set the snapshotInfo to so that the session path is set correctly
1580 sessionInfo
.setSnapshotInfo(snapshotInfo
);
1581 assertEquals("net4://172.0.0.1:5342/", sessionInfo
.getSessionPath());
1583 fService
.recordSnapshot("mysession", new NullProgressMonitor());
1585 fService
.destroySession("mysession", new NullProgressMonitor());
1587 } catch (ExecutionException e
) {
1593 public void testCreateSnapshotSessionErrors() {
1595 fShell
.setScenario(SCEN_CREATE_SNAPSHOT_SESSION_ERRORS
);
1597 List
<String
> names
= fService
.getSessionNames(new NullProgressMonitor());
1598 assertEquals(names
.get(0), "mysession");
1599 } catch (ExecutionException e
) {
1604 fService
.getSnapshotInfo("blabla", new NullProgressMonitor());
1605 fail("getSnapshoInfo() didn't fail");
1606 } catch (ExecutionException e
) {
1611 fService
.recordSnapshot("blabla", new NullProgressMonitor());
1612 fail("getSnapshoInfo() didn't fail");
1613 } catch (ExecutionException e
) {
1618 fService
.recordSnapshot("mysession", new NullProgressMonitor());
1619 fail("getSnapshoInfo() didn't fail");
1620 } catch (ExecutionException e
) {
1627 public void testCreateLiveSession() throws ExecutionException
{
1628 fShell
.setScenario(SCEN_CREATE_LIVE_SESSION
);
1630 ISessionInfo params
= new SessionInfo("mysession");
1631 params
.setLive(true);
1632 params
.setStreamedTrace(true);
1633 params
.setNetworkUrl("net://127.0.0.1");
1634 ISessionInfo sessionInfo
= fService
.createSession(params
, new NullProgressMonitor());
1635 assertNotNull(sessionInfo
);
1636 assertEquals("mysession", sessionInfo
.getName());
1637 assertEquals(TraceSessionState
.INACTIVE
, sessionInfo
.getSessionState());
1638 assertTrue(sessionInfo
.isStreamedTrace());
1639 assertTrue(sessionInfo
.isLive());
1640 assertEquals("net://127.0.0.1", sessionInfo
.getSessionPath());
1641 List
<String
> names
= fService
.getSessionNames(new NullProgressMonitor());
1642 assertEquals(names
.get(0), "mysession");
1643 fService
.destroySession("mysession", new NullProgressMonitor());
1648 public void testCreateLiveSessionErrors() {
1650 fShell
.setScenario(SCEN_CREATE_LIVE_SESSION_ERRORS
);
1652 ISessionInfo parameters
= new SessionInfo("mysession");
1653 parameters
.setLive(true);
1654 parameters
.setSnapshot(true);
1655 fService
.createSession(parameters
, new NullProgressMonitor());
1656 fail("createSession() didn't fail");
1657 } catch (ExecutionException e
) {
1662 ISessionInfo parameters
= new SessionInfo("mysession");
1663 parameters
.setNetworkUrl("blah");
1664 parameters
.setLive(true);
1665 fService
.createSession(parameters
, new NullProgressMonitor());
1666 fail("createSession() didn't fail");
1667 } catch (ExecutionException e
) {
1672 ISessionInfo parameters
= new SessionInfo("mysession");
1673 parameters
.setControlUrl("net://127.0.0.1");
1674 parameters
.setLive(true);
1675 fService
.createSession(parameters
, new NullProgressMonitor());
1676 fail("createSession() didn't fail");
1677 } catch (ExecutionException e
) {
1683 public void testSessionProfile() {
1684 fShell
.setScenario(SCEN_SESSION_PROFILES
);
1685 final String profile
= "/home/user/.lttng/sessions/mysession.lttng";
1687 fService
.loadSession(profile
, false, new NullProgressMonitor());
1688 } catch (ExecutionException e
) {
1689 fail("load session failed: " + e
);
1693 fService
.loadSession(profile
, true, new NullProgressMonitor());
1694 } catch (ExecutionException e
) {
1695 fail("load session failed: " + e
);
1699 fService
.saveSession(null, null, false, new NullProgressMonitor());
1700 } catch (ExecutionException e
) {
1701 fail("save session failed: " + e
);
1704 final String sessionName
= "mysession";
1706 fService
.saveSession(sessionName
, null, false, new NullProgressMonitor());
1707 } catch (ExecutionException e
) {
1708 fail("save session failed: " + e
);
1712 fService
.saveSession(sessionName
, null, true, new NullProgressMonitor());
1713 } catch (ExecutionException e
) {
1714 fail("save session failed: " + e
);
1718 fService
.saveSession(sessionName
, "/tmp/test", true, new NullProgressMonitor());
1719 } catch (ExecutionException e
) {
1720 fail("save session failed: " + e
);
1724 private static void enableVerbose() {
1726 ControlCommandLogger
.init(ControlPreferences
.getInstance().getLogfilePath(), false);
1727 ControlPreferences
.getInstance().getPreferenceStore().setDefault(ControlPreferences
.TRACE_CONTROL_LOG_COMMANDS_PREF
, true);
1728 ControlPreferences
.getInstance().getPreferenceStore().setDefault(ControlPreferences
.TRACE_CONTROL_VERBOSE_LEVEL_PREF
, ControlPreferences
.TRACE_CONTROL_VERBOSE_LEVEL_V_V_VERBOSE
);
1731 private static void disableVerbose() {
1732 ControlPreferences
.getInstance().getPreferenceStore().setDefault(ControlPreferences
.TRACE_CONTROL_LOG_COMMANDS_PREF
, false);