1 /**********************************************************************
2 * Copyright (c) 2012, 2014 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Bernd Hufmann - Initial API and implementation
11 * Alexandre Montplaisir - Port to JUnit4
12 * Marc-Andre Laperle - Support for creating a live session
13 **********************************************************************/
15 package org
.eclipse
.tracecompass
.lttng2
.control
.ui
.tests
.service
;
17 import static org
.junit
.Assert
.assertEquals
;
18 import static org
.junit
.Assert
.assertNotNull
;
19 import static org
.junit
.Assert
.assertTrue
;
20 import static org
.junit
.Assert
.fail
;
24 import java
.util
.ArrayList
;
25 import java
.util
.HashSet
;
26 import java
.util
.List
;
29 import org
.eclipse
.core
.commands
.ExecutionException
;
30 import org
.eclipse
.core
.runtime
.FileLocator
;
31 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
32 import org
.eclipse
.core
.runtime
.Path
;
33 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.IBaseEventInfo
;
34 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.IChannelInfo
;
35 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.IDomainInfo
;
36 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.IEventInfo
;
37 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.IFieldInfo
;
38 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.ISessionInfo
;
39 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.ISnapshotInfo
;
40 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.IUstProviderInfo
;
41 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.LogLevelType
;
42 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceChannelOutputType
;
43 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceEnablement
;
44 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceEventType
;
45 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceLogLevel
;
46 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceSessionState
;
47 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.impl
.BufferType
;
48 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.impl
.ChannelInfo
;
49 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.impl
.SessionInfo
;
50 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.stubs
.service
.CommandShellFactory
;
51 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.stubs
.shells
.LTTngToolsFileShell
;
52 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.Activator
;
53 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.logging
.ControlCommandLogger
;
54 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.preferences
.ControlPreferences
;
55 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.service
.ILttngControlService
;
56 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.service
.LTTngControlService
;
57 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.service
.LTTngControlServiceFactory
;
58 import org
.junit
.After
;
59 import org
.junit
.Before
;
60 import org
.junit
.Test
;
61 import org
.osgi
.framework
.FrameworkUtil
;
64 * The class <code>LTTngControlServiceTest</code> contains test for the class
65 * <code>{@link LTTngControlService}</code>.
67 @SuppressWarnings("javadoc")
68 public class LTTngControlServiceTest
{
70 private static final String DIRECTORY
= "testfiles";
71 private static final String TEST_STREAM
= "LTTngServiceTest.cfg";
73 private static final String SCEN_LTTNG_NOT_INSTALLED
= "LttngNotInstalled";
74 private static final String SCEN_LTTNG_VERSION
= "LttngVersion";
75 private static final String SCEN_LTTNG_VERSION_WITH_PROMPT
= "LttngVersionWithPrompt";
76 private static final String SCEN_LTTNG_UNSUPPORTED_VERSION
= "LttngUnsupportedVersion";
77 private static final String SCEN_LTTNG_NO_VERSION
= "LttngNoVersion";
78 private static final String SCEN_NO_SESSION_AVAILABLE
= "NoSessionAvailable";
79 private static final String SCEN_GET_SESSION_NAMES1
= "GetSessionNames1";
80 private static final String SCEN_GET_SESSION_NAME_NOT_EXIST
= "GetSessionNameNotExist";
81 private static final String SCEN_GET_SESSION_NAME_NOT_EXIST_VERBOSE
= "GetSessionNameNotExistVerbose";
82 protected static final String SCEN_GET_SESSION_GARBAGE_OUT
= "GetSessionGarbageOut";
83 private static final String SCEN_GET_SESSION1
= "GetSession1";
84 private static final String SCEN_GET_KERNEL_PROVIDER1
= "GetKernelProvider1";
85 private static final String SCEN_LIST_WITH_NO_KERNEL1
= "ListWithNoKernel1";
86 private static final String SCEN_LIST_WITH_NO_KERNEL2
= "ListWithNoKernel2";
87 private static final String SCEN_LIST_WITH_NO_KERNEL_VERBOSE
= "ListWithNoKernelVerbose";
88 private static final String SCEN_GET_UST_PROVIDER1
= "GetUstProvider1";
89 private static final String SCEN_GET_UST_PROVIDER2
= "GetUstProvider2";
90 private static final String SCEN_GET_UST_PROVIDER3
= "GetUstProvider3";
91 private static final String SCEN_LIST_WITH_NO_UST1
= "ListWithNoUst1";
92 private static final String SCEN_LIST_WITH_NO_UST2
= "ListWithNoUst2";
93 private static final String SCEN_LIST_WITH_NO_UST3
= "ListWithNoUst3";
94 private static final String SCEN_LIST_WITH_NO_UST_VERBOSE
= "ListWithNoUstVerbose";
95 private static final String SCEN_CREATE_SESSION1
= "CreateSession1";
96 private static final String SCEN_CREATE_SESSION_WITH_PROMPT
= "CreateSessionWithPrompt";
97 private static final String SCEN_CREATE_SESSION_VARIANTS
= "CreateSessionVariants";
98 private static final String SCEN_DESTROY_SESSION1
= "DestroySession1";
99 private static final String SCEN_DESTROY_SESSION_VERBOSE
= "DestroySessionVerbose";
100 private static final String SCEN_CHANNEL_HANDLING
= "ChannelHandling";
101 private static final String SCEN_EVENT_HANDLING
= "EventHandling";
102 private static final String SCEN_CONTEXT_HANDLING
= "ContextHandling";
103 private static final String SCEN_CONTEXT_ERROR_HANDLING
= "ContextErrorHandling";
104 private static final String SCEN_CALIBRATE_HANDLING
= "CalibrateHandling";
105 private static final String SCEN_CREATE_SESSION_2_1
= "CreateSessionLttng2.1";
106 private static final String SCEN_CREATE_SESSION_VERBOSE_2_1
= "CreateSessionLttngVerbose2.1";
107 private static final String SCEN_CREATE_SNAPSHOT_SESSION
= "CreateSessionSnapshot";
108 private static final String SCEN_CREATE_SNAPSHOT_SESSION_2_5
= "CreateSessionSnapshot2.5";
109 private static final String SCEN_CREATE_STREAMED_SNAPSHOT_SESSION
= "CreateSessionStreamedSnapshot";
110 private static final String SCEN_CREATE_SNAPSHOT_SESSION_ERRORS
= "CreateSessionSnapshotErrors";
111 protected static final String SCEN_CREATE_LIVE_SESSION
= "CreateSessionLive";
112 private static final String SCEN_CREATE_LIVE_SESSION_ERRORS
= "CreateSessionLiveErrors";
115 // ------------------------------------------------------------------------
117 // ------------------------------------------------------------------------
119 private CommandShellFactory fShellFactory
;
120 private String fTestfile
;
121 protected LTTngToolsFileShell fShell
;
122 protected ILttngControlService fService
;
124 // ------------------------------------------------------------------------
126 // ------------------------------------------------------------------------
129 * Perform pre-test initialization.
132 * if the initialization fails for some reason
135 public void setUp() throws Exception
{
136 fShellFactory
= CommandShellFactory
.getInstance();
138 URL location
= FileLocator
.find(FrameworkUtil
.getBundle(this.getClass()), new Path(getTestDirectory() + File
.separator
+ getTestStream()), null);
139 File testfile
= new File(FileLocator
.toFileURL(location
).toURI());
140 fTestfile
= testfile
.getAbsolutePath();
142 fShell
= fShellFactory
.getFileShell();
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
);
166 public LTTngToolsFileShell
getfShell() {
173 protected String
getTestStream() {
178 public void tearDown() {
180 ControlPreferences
.getInstance().dispose();
183 // ------------------------------------------------------------------------
185 // ------------------------------------------------------------------------
188 public void testVersion() {
190 fShell
.setScenario(SCEN_LTTNG_VERSION
);
191 ILttngControlService service
= LTTngControlServiceFactory
.getInstance().getLttngControlService(fShell
);
192 assertNotNull(service
);
193 assertEquals("2.1.0", service
.getVersionString());
194 } catch (ExecutionException e
) {
195 fail("Exeption thrown " + e
);
200 public void testVersionWithPrompt() {
202 fShell
.setScenario(SCEN_LTTNG_VERSION_WITH_PROMPT
);
203 ILttngControlService service
= LTTngControlServiceFactory
.getInstance().getLttngControlService(fShell
);
204 assertNotNull(service
);
205 assertEquals("2.0.0", service
.getVersionString());
206 } catch (ExecutionException e
) {
207 fail("Exeption thrown " + e
);
212 public void testUnsupportedVersion() {
214 fShell
.setScenario(SCEN_LTTNG_UNSUPPORTED_VERSION
);
215 LTTngControlServiceFactory
.getInstance().getLttngControlService(fShell
);
216 fail("No exeption thrown");
217 } catch (ExecutionException e
) {
223 public void testNoVersion() {
225 fShell
.setScenario(SCEN_LTTNG_NO_VERSION
);
226 LTTngControlServiceFactory
.getInstance().getLttngControlService(fShell
);
227 fail("No exeption thrown");
228 } catch (ExecutionException e
) {
234 public void testLttngNotInstalled() {
236 fShell
.setScenario(SCEN_LTTNG_NOT_INSTALLED
);
237 fService
.getSessionNames(new NullProgressMonitor());
238 fail("No exeption thrown");
239 } catch (ExecutionException e
) {
245 public void testGetSessionNames1() {
247 fShell
.setScenario(SCEN_NO_SESSION_AVAILABLE
);
248 String
[] result
= fService
.getSessionNames(new NullProgressMonitor());
250 assertNotNull(result
);
251 assertEquals(0, result
.length
);
253 } catch (ExecutionException e
) {
259 public void testGetSessionNames2() {
261 fShell
.setScenario(SCEN_GET_SESSION_NAMES1
);
262 String
[] result
= fService
.getSessionNames(new NullProgressMonitor());
264 assertNotNull(result
);
265 assertEquals(2, result
.length
);
266 assertEquals("mysession1", result
[0]);
267 assertEquals("mysession", result
[1]);
269 } catch (ExecutionException e
) {
275 public void testGetSessionNotExist() {
277 fShell
.setScenario(SCEN_GET_SESSION_NAME_NOT_EXIST
);
278 fService
.getSessionNames(new NullProgressMonitor());
279 fail("No exeption thrown");
281 } catch (ExecutionException e
) {
287 public void testGetSessionNotExistVerbose() {
290 fShell
.setScenario(SCEN_GET_SESSION_NAME_NOT_EXIST_VERBOSE
);
291 fService
.getSessionNames(new NullProgressMonitor());
292 fail("No exeption thrown");
294 } catch (ExecutionException e
) {
302 public void testGetSessionNameGarbage() {
304 fShell
.setScenario(SCEN_GET_SESSION_GARBAGE_OUT
);
305 String
[] result
= fService
.getSessionNames(new NullProgressMonitor());
307 assertNotNull(result
);
308 assertEquals(0, result
.length
);
310 } catch (ExecutionException e
) {
316 public void testGetSession1() {
318 fShell
.setScenario(SCEN_GET_SESSION1
);
319 ISessionInfo session
= fService
.getSession("mysession", new NullProgressMonitor());
322 assertNotNull(session
);
323 assertEquals("mysession", session
.getName());
324 assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session
.getSessionPath());
325 assertEquals(TraceSessionState
.ACTIVE
, session
.getSessionState());
327 IDomainInfo
[] domains
= session
.getDomains();
328 assertNotNull(domains
);
329 assertEquals(2, domains
.length
);
331 // Verify Kernel domain
332 assertEquals("Kernel", domains
[0].getName());
333 IChannelInfo
[] channels
= domains
[0].getChannels();
334 assertNotNull(channels
);
335 assertEquals(2, channels
.length
);
337 // Verify Kernel's channel0
338 assertEquals("channel0", channels
[0].getName());
339 assertEquals(4, channels
[0].getNumberOfSubBuffers());
340 assertEquals("splice()", channels
[0].getOutputType().getInName());
341 assertEquals(TraceChannelOutputType
.SPLICE
, channels
[0].getOutputType());
342 assertEquals(false, channels
[0].isOverwriteMode());
343 assertEquals(200, channels
[0].getReadTimer());
344 assertEquals(TraceEnablement
.ENABLED
, channels
[0].getState());
345 assertEquals(262144, channels
[0].getSubBufferSize());
346 assertEquals(0, channels
[0].getSwitchTimer());
349 IEventInfo
[] channel0Events
= channels
[0].getEvents();
350 assertNotNull(channel0Events
);
351 assertEquals(2, channel0Events
.length
);
352 assertEquals("block_rq_remap", channel0Events
[0].getName());
353 assertEquals(TraceLogLevel
.TRACE_EMERG
, channel0Events
[0].getLogLevel());
354 assertEquals(TraceEventType
.TRACEPOINT
, channel0Events
[0].getEventType());
355 assertEquals(TraceEnablement
.ENABLED
, channel0Events
[0].getState());
357 assertEquals("block_bio_remap", channel0Events
[1].getName());
358 assertEquals(TraceLogLevel
.TRACE_EMERG
, channel0Events
[1].getLogLevel());
359 assertEquals(TraceEventType
.TRACEPOINT
, channel0Events
[1].getEventType());
360 assertEquals(TraceEnablement
.DISABLED
, channel0Events
[1].getState());
362 // Verify Kernel's channel1
363 assertEquals("channel1", channels
[1].getName());
364 assertEquals(4, channels
[1].getNumberOfSubBuffers());
365 assertEquals("splice()", channels
[1].getOutputType().getInName());
366 assertEquals(TraceChannelOutputType
.SPLICE
, channels
[1].getOutputType());
367 assertEquals(true, channels
[1].isOverwriteMode());
368 assertEquals(400, channels
[1].getReadTimer());
369 assertEquals(TraceEnablement
.DISABLED
, channels
[1].getState());
370 assertEquals(524288, channels
[1].getSubBufferSize());
371 assertEquals(100, channels
[1].getSwitchTimer());
374 IEventInfo
[] channel1Events
= channels
[1].getEvents();
375 assertEquals(0, channel1Events
.length
);
377 // Verify domain UST global
378 assertEquals("UST global", domains
[1].getName());
380 IChannelInfo
[] ustChannels
= domains
[1].getChannels();
382 // Verify UST global's mychannel1
383 assertEquals("mychannel1", ustChannels
[0].getName());
384 assertEquals(8, ustChannels
[0].getNumberOfSubBuffers());
385 assertEquals("mmap()", ustChannels
[0].getOutputType().getInName());
386 assertEquals(TraceChannelOutputType
.MMAP
, ustChannels
[0].getOutputType());
387 assertEquals(true, ustChannels
[0].isOverwriteMode());
388 assertEquals(100, ustChannels
[0].getReadTimer());
389 assertEquals(TraceEnablement
.DISABLED
, ustChannels
[0].getState());
390 assertEquals(8192, ustChannels
[0].getSubBufferSize());
391 assertEquals(200, ustChannels
[0].getSwitchTimer());
394 IEventInfo
[] ustEvents
= ustChannels
[0].getEvents();
395 assertEquals(0, ustEvents
.length
);
397 // Verify UST global's channel0
398 assertEquals("channel0", ustChannels
[1].getName());
399 assertEquals(4, ustChannels
[1].getNumberOfSubBuffers());
400 assertEquals("mmap()", ustChannels
[1].getOutputType().getInName());
401 assertEquals(TraceChannelOutputType
.MMAP
, ustChannels
[1].getOutputType());
402 assertEquals(false, ustChannels
[1].isOverwriteMode());
403 assertEquals(200, ustChannels
[1].getReadTimer());
404 assertEquals(TraceEnablement
.ENABLED
, ustChannels
[1].getState());
405 assertEquals(4096, ustChannels
[1].getSubBufferSize());
406 assertEquals(0, ustChannels
[1].getSwitchTimer());
409 ustEvents
= ustChannels
[1].getEvents();
410 assertEquals(2, ustEvents
.length
);
412 assertEquals("ust_tests_hello:tptest_sighandler", ustEvents
[0].getName());
413 assertEquals(TraceLogLevel
.TRACE_DEBUG_LINE
, ustEvents
[0].getLogLevel());
414 assertEquals(TraceEventType
.TRACEPOINT
, ustEvents
[0].getEventType());
415 assertEquals(TraceEnablement
.DISABLED
, ustEvents
[0].getState());
417 assertEquals("*", ustEvents
[1].getName());
418 assertEquals(getAllEventTraceLogLevel(), ustEvents
[1].getLogLevel());
419 assertEquals(TraceEventType
.TRACEPOINT
, ustEvents
[1].getEventType());
420 assertEquals(TraceEnablement
.ENABLED
, ustEvents
[1].getState());
422 // next session (no detailed information available)
423 session
= fService
.getSession("mysession1", new NullProgressMonitor());
424 assertNotNull(session
);
425 assertEquals("mysession1", session
.getName());
426 assertEquals("/home/user/lttng-traces/mysession1-20120203-133225", session
.getSessionPath());
427 assertEquals(TraceSessionState
.INACTIVE
, session
.getSessionState());
429 domains
= session
.getDomains();
430 assertNotNull(domains
);
431 assertEquals(0, domains
.length
);
432 } catch (ExecutionException e
) {
440 protected TraceLogLevel
getAllEventTraceLogLevel() {
441 return TraceLogLevel
.LEVEL_UNKNOWN
;
444 public void testGetKernelProvider() {
446 fShell
.setScenario(SCEN_GET_KERNEL_PROVIDER1
);
447 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
450 assertNotNull(events
);
451 assertEquals(3, events
.size());
453 IBaseEventInfo baseEventInfo
= events
.get(0);
454 assertNotNull(baseEventInfo
);
455 assertEquals("sched_kthread_stop", baseEventInfo
.getName());
456 assertEquals(TraceLogLevel
.TRACE_EMERG
, baseEventInfo
.getLogLevel());
457 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
459 baseEventInfo
= events
.get(1);
460 assertEquals("sched_kthread_stop_ret", baseEventInfo
.getName());
461 assertEquals(TraceLogLevel
.TRACE_EMERG
, baseEventInfo
.getLogLevel());
462 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
464 baseEventInfo
= events
.get(2);
465 assertEquals("sched_wakeup_new", baseEventInfo
.getName());
466 assertEquals(TraceLogLevel
.TRACE_EMERG
, baseEventInfo
.getLogLevel());
467 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
469 } catch (ExecutionException e
) {
475 public void testGetKernelProviderNoKernel1() {
477 fShell
.setScenario(SCEN_LIST_WITH_NO_KERNEL1
);
478 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
481 assertNotNull(events
);
482 assertEquals(0, events
.size());
484 } catch (ExecutionException e
) {
490 public void testGetKernelProviderNoKernel2() {
492 fShell
.setScenario(SCEN_LIST_WITH_NO_KERNEL2
);
493 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
496 assertNotNull(events
);
497 assertEquals(0, events
.size());
499 } catch (ExecutionException e
) {
505 public void testGetKernelProviderNoKernelVerbose() {
508 fShell
.setScenario(SCEN_LIST_WITH_NO_KERNEL_VERBOSE
);
509 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
512 assertNotNull(events
);
513 assertEquals(0, events
.size());
515 } catch (ExecutionException e
) {
523 public void testGetUstProvider() {
525 fShell
.setScenario(SCEN_GET_UST_PROVIDER1
);
526 List
<IUstProviderInfo
> providers
= fService
.getUstProvider();
528 // Check all providers
529 assertNotNull(providers
);
530 assertEquals(2, providers
.size());
532 //Verify first provider
533 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(0).getName());
534 assertEquals(9379, providers
.get(0).getPid());
537 IBaseEventInfo
[] events
= providers
.get(0).getEvents();
538 assertNotNull(events
);
539 assertEquals(2, events
.length
);
541 IBaseEventInfo baseEventInfo
= events
[0];
542 assertNotNull(baseEventInfo
);
543 assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo
.getName());
544 assertEquals(TraceLogLevel
.TRACE_DEBUG_MODULE
, baseEventInfo
.getLogLevel());
545 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
547 baseEventInfo
= events
[1];
548 assertEquals("ust_tests_hello:tptest", baseEventInfo
.getName());
549 assertEquals(TraceLogLevel
.TRACE_INFO
, baseEventInfo
.getLogLevel());
550 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
552 //Verify second provider
553 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(1).getName());
554 assertEquals(4852, providers
.get(1).getPid());
557 events
= providers
.get(1).getEvents();
558 assertNotNull(events
);
559 assertEquals(2, events
.length
);
561 baseEventInfo
= events
[0];
562 assertNotNull(baseEventInfo
);
563 assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo
.getName());
564 assertEquals(TraceLogLevel
.TRACE_WARNING
, baseEventInfo
.getLogLevel());
565 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
567 baseEventInfo
= events
[1];
568 assertEquals("ust_tests_hello:tptest", baseEventInfo
.getName());
569 assertEquals(TraceLogLevel
.TRACE_DEBUG_FUNCTION
, baseEventInfo
.getLogLevel());
570 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
572 } catch (ExecutionException e
) {
578 public void testUstProvider2() {
580 fShell
.setScenario(SCEN_GET_UST_PROVIDER2
);
581 List
<IUstProviderInfo
> providers
= fService
.getUstProvider();
583 assertNotNull(providers
);
584 assertEquals(0, providers
.size());
586 } catch (ExecutionException e
) {
592 public void testGetUstProvider3() {
594 fShell
.setScenario(SCEN_GET_UST_PROVIDER3
);
596 ((LTTngControlService
)fService
).setVersion("2.1.0");
597 List
<IUstProviderInfo
> providers
= fService
.getUstProvider();
599 // Check all providers
600 assertNotNull(providers
);
601 assertEquals(2, providers
.size());
603 //Verify first provider
604 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(0).getName());
605 assertEquals(9379, providers
.get(0).getPid());
608 IBaseEventInfo
[] events
= providers
.get(0).getEvents();
609 assertNotNull(events
);
610 assertEquals(2, events
.length
);
612 IBaseEventInfo baseEventInfo
= events
[0];
613 assertNotNull(baseEventInfo
);
614 IFieldInfo
[] fields
= baseEventInfo
.getFields();
615 assertNotNull(fields
);
616 assertEquals(0, fields
.length
);
618 baseEventInfo
= events
[1];
619 fields
= baseEventInfo
.getFields();
620 assertNotNull(fields
);
621 assertEquals(3, fields
.length
);
622 assertEquals("doublefield", fields
[0].getName());
623 assertEquals("float", fields
[0].getFieldType());
625 assertEquals("floatfield", fields
[1].getName());
626 assertEquals("float", fields
[1].getFieldType());
628 assertEquals("stringfield", fields
[2].getName());
629 assertEquals("string", fields
[2].getFieldType());
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 fields
= baseEventInfo
.getFields();
643 assertNotNull(fields
);
644 assertEquals(0, fields
.length
);
646 baseEventInfo
= events
[1];
647 fields
= baseEventInfo
.getFields();
648 assertNotNull(fields
);
649 assertEquals(3, fields
.length
);
651 assertEquals("doublefield", fields
[0].getName());
652 assertEquals("float", fields
[0].getFieldType());
654 assertEquals("floatfield", fields
[1].getName());
655 assertEquals("float", fields
[1].getFieldType());
657 assertEquals("stringfield", fields
[2].getName());
658 assertEquals("string", fields
[2].getFieldType());
661 ((LTTngControlService
)fService
).setVersion("2.0.0");
663 } catch (ExecutionException e
) {
670 public void testGetKernelProviderNoUst1() {
672 fShell
.setScenario(SCEN_LIST_WITH_NO_UST1
);
673 List
<IUstProviderInfo
> providerList
= fService
.getUstProvider(new NullProgressMonitor());
675 // Verify Provider info
676 assertNotNull(providerList
);
677 assertEquals(0, providerList
.size());
679 } catch (ExecutionException e
) {
686 public void testGetKernelProviderNoUst2() {
689 ((LTTngControlService
)fService
).setVersion("2.1.0");
691 fShell
.setScenario(SCEN_LIST_WITH_NO_UST2
);
692 List
<IUstProviderInfo
> providerList
= fService
.getUstProvider(new NullProgressMonitor());
694 // Verify Provider info
695 assertNotNull(providerList
);
696 assertEquals(0, providerList
.size());
699 ((LTTngControlService
)fService
).setVersion("2.0.0");
701 } catch (ExecutionException e
) {
707 public void testGetKernelProviderNoUst3() {
711 ((LTTngControlService
)fService
).setVersion("2.1.0");
713 fShell
.setScenario(SCEN_LIST_WITH_NO_UST3
);
714 List
<IUstProviderInfo
> providerList
= fService
.getUstProvider(new NullProgressMonitor());
716 // Verify provider info
717 assertNotNull(providerList
);
718 assertEquals(0, providerList
.size());
721 ((LTTngControlService
)fService
).setVersion("2.0.0");
723 } catch (ExecutionException e
) {
729 public void testGetKernelProviderNoUstVerbose() {
734 ((LTTngControlService
)fService
).setVersion("2.1.0");
736 fShell
.setScenario(SCEN_LIST_WITH_NO_UST_VERBOSE
);
737 List
<IUstProviderInfo
> providerList
= fService
.getUstProvider(new NullProgressMonitor());
739 // Verify provider info
740 assertNotNull(providerList
);
741 assertEquals(0, providerList
.size());
744 ((LTTngControlService
)fService
).setVersion("2.0.0");
746 } catch (ExecutionException e
) {
756 public void testCreateSession() {
758 fShell
.setScenario(SCEN_CREATE_SESSION1
);
760 ISessionInfo info
= fService
.createSession(new SessionInfo("mysession2"), new NullProgressMonitor());
762 assertEquals("mysession2", info
.getName());
763 assertNotNull(info
.getSessionPath());
764 assertTrue(info
.getSessionPath().contains("mysession2"));
765 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
766 } catch (ExecutionException e
) {
772 public void testCreateSessionWithPrompt() {
774 // First line has the shell prompt before the command output
775 // This can happen in a real application if the command line is not echoed by the shell.
776 fShell
.setScenario(SCEN_CREATE_SESSION_WITH_PROMPT
);
778 // First line has no shell prompt before the output
779 ISessionInfo info
= fService
.createSession(new SessionInfo("mysession2"), new NullProgressMonitor());
781 assertEquals("mysession2", info
.getName());
782 assertNotNull(info
.getSessionPath());
783 assertTrue(info
.getSessionPath().contains("mysession2"));
784 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
785 } catch (ExecutionException e
) {
791 public void testCreateSessionVariants() {
793 fShell
.setScenario(SCEN_CREATE_SESSION_VARIANTS
);
796 fService
.createSession(new SessionInfo("alreadyExist"), new NullProgressMonitor());
797 fail("No exeption thrown");
798 } catch (ExecutionException e
) {
803 fService
.createSession(new SessionInfo("wrongName"), new NullProgressMonitor());
804 fail("No exeption thrown");
805 } catch (ExecutionException e
) {
810 ISessionInfo sessionInfo
= new SessionInfo("withPath");
811 sessionInfo
.setSessionPath("/home/user/hallo");
812 fService
.createSession(sessionInfo
, new NullProgressMonitor());
813 fail("No exeption thrown");
814 } catch (ExecutionException e
) {
819 ISessionInfo info
= fService
.createSession(new SessionInfo("session with spaces"), new NullProgressMonitor());
821 assertEquals("session with spaces", info
.getName());
822 assertNotNull(info
.getSessionPath());
823 assertTrue(info
.getSessionPath().contains("session with spaces"));
824 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
826 } catch (ExecutionException e
) {
831 ISessionInfo sessionInfo
= new SessionInfo("pathWithSpaces");
832 sessionInfo
.setSessionPath("/home/user/hallo user/here");
833 ISessionInfo info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
835 assertEquals("pathWithSpaces", info
.getName());
836 assertNotNull(info
.getSessionPath());
837 assertTrue(info
.getSessionPath().contains("/home/user/hallo user/here"));
838 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
840 } catch (ExecutionException e
) {
846 public void testDestroySession() {
848 fShell
.setScenario(SCEN_DESTROY_SESSION1
);
849 fService
.destroySession("mysession2", new NullProgressMonitor());
850 } catch (ExecutionException e
) {
856 public void testDestroySessionVerbose() {
859 fShell
.setScenario(SCEN_DESTROY_SESSION_VERBOSE
);
860 fService
.destroySession("mysession2", new NullProgressMonitor());
861 } catch (ExecutionException e
) {
869 public void testCreateChannel() {
871 ((LTTngControlService
)fService
).setVersion("2.2.0");
872 String sessionName
= "mysession2";
873 List
<String
> list
= new ArrayList
<>();
874 String kernelChannel0
= "mychannel0";
875 String kernelChannel1
= "mychannel1";
876 list
.add(kernelChannel0
);
877 list
.add(kernelChannel1
);
879 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
881 // Create/enable/configure 2 kernel channels
882 ChannelInfo chanInfo
= new ChannelInfo("");
883 chanInfo
.setOverwriteMode(true);
884 chanInfo
.setSubBufferSize(16384);
885 chanInfo
.setReadTimer(100);
886 chanInfo
.setSwitchTimer(200);
887 chanInfo
.setNumberOfSubBuffers(2);
888 chanInfo
.setMaxNumberTraceFiles(10);
889 chanInfo
.setMaxSizeTraceFiles(0);
890 fService
.enableChannels(sessionName
, list
, true, chanInfo
, new NullProgressMonitor());
892 // Create/enable/configure 1 UST channel
894 list
.add("ustChannel");
896 chanInfo
= new ChannelInfo("");
897 chanInfo
.setOverwriteMode(true);
898 chanInfo
.setSubBufferSize(32768);
899 chanInfo
.setReadTimer(200);
900 chanInfo
.setSwitchTimer(100);
901 chanInfo
.setNumberOfSubBuffers(1);
902 chanInfo
.setMaxNumberTraceFiles(20);
903 chanInfo
.setMaxSizeTraceFiles(0);
904 fService
.enableChannels(sessionName
, list
, false, chanInfo
, new NullProgressMonitor());
905 ((LTTngControlService
)fService
).setVersion("2.0.0");
907 } catch (ExecutionException e
) {
913 public void testCreateChannelUIDBuffer() {
915 ((LTTngControlService
)fService
).setVersion("2.2.0");
916 String sessionName
= "mysession2";
917 List
<String
> list
= new ArrayList
<>();
918 String USTChannel
= "ustChannel";
919 list
.add(USTChannel
);
920 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
922 ChannelInfo chanInfo
= new ChannelInfo("");
923 chanInfo
.setOverwriteMode(true);
924 chanInfo
.setSubBufferSize(32768);
925 chanInfo
.setReadTimer(200);
926 chanInfo
.setSwitchTimer(100);
927 chanInfo
.setNumberOfSubBuffers(1);
928 chanInfo
.setMaxNumberTraceFiles(20);
929 chanInfo
.setMaxSizeTraceFiles(0);
930 chanInfo
.setBufferType(BufferType
.BUFFER_PER_UID
);
931 fService
.enableChannels(sessionName
, list
, false, chanInfo
, new NullProgressMonitor());
932 ((LTTngControlService
)fService
).setVersion("2.0.0");
934 } catch (ExecutionException e
) {
940 public void testCreateChannelPIDBuffer() {
942 ((LTTngControlService
)fService
).setVersion("2.2.0");
943 String sessionName
= "mysession2";
944 List
<String
> list
= new ArrayList
<>();
945 String USTChannel
= "ustChannel";
946 list
.add(USTChannel
);
947 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
950 ChannelInfo chanInfo
= new ChannelInfo("");
951 chanInfo
.setOverwriteMode(true);
952 chanInfo
.setSubBufferSize(-1);
953 chanInfo
.setReadTimer(-1);
954 chanInfo
.setSwitchTimer(-1);
955 chanInfo
.setNumberOfSubBuffers(-1);
956 chanInfo
.setMaxNumberTraceFiles(-1);
957 chanInfo
.setMaxSizeTraceFiles(-1);
958 chanInfo
.setBufferType(BufferType
.BUFFER_PER_PID
);
960 fService
.enableChannels(sessionName
, list
, false, chanInfo
, new NullProgressMonitor());
961 ((LTTngControlService
)fService
).setVersion("2.0.0");
963 } catch (ExecutionException e
) {
969 public void testDisableChannel() {
972 String sessionName
= "mysession2";
973 List
<String
> list
= new ArrayList
<>();
974 String kernelChannel0
= "mychannel0";
975 String kernelChannel1
= "mychannel1";
976 list
.add(kernelChannel0
);
977 list
.add(kernelChannel1
);
979 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
980 fService
.disableChannels(sessionName
, list
, true, new NullProgressMonitor());
983 list
.add("ustChannel");
984 fService
.disableChannels(sessionName
, list
, false, new NullProgressMonitor());
986 } catch (ExecutionException e
) {
992 public void testEnableChannel() {
995 String sessionName
= "mysession2";
996 List
<String
> list
= new ArrayList
<>();
997 String kernelChannel0
= "mychannel0";
998 String kernelChannel1
= "mychannel1";
999 list
.add(kernelChannel0
);
1000 list
.add(kernelChannel1
);
1002 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
1003 fService
.enableChannels(sessionName
, list
, true, null, new NullProgressMonitor());
1005 // Create/enable/configure 1 UST channel
1007 list
.add("ustChannel");
1009 fService
.enableChannels(sessionName
, list
, false, null, new NullProgressMonitor());
1011 } catch (ExecutionException e
) {
1017 public void testEnableEvents() {
1019 // 1) session name, channel = null, 3 event names, kernel
1020 String sessionName
= "mysession2";
1021 List
<String
> list
= new ArrayList
<>();
1022 String eventName0
= "block_rq_remap";
1023 String eventName1
= "block_bio_remap";
1024 String eventName2
= "softirq_entry";
1025 list
.add(eventName0
);
1026 list
.add(eventName1
);
1027 list
.add(eventName2
);
1028 fShell
.setScenario(SCEN_EVENT_HANDLING
);
1029 fService
.enableEvents(sessionName
, null, list
, true, null, new NullProgressMonitor());
1031 // 2) session name, channel=mychannel, event name= null, kernel
1032 String channelName
= "mychannel";
1033 fService
.enableEvents(sessionName
, channelName
, null, true, null, new NullProgressMonitor());
1035 // 3) session name, channel=mychannel, 1 event name, ust, no filter
1036 String ustEventName
= "ust_tests_hello:tptest_sighandler";
1038 list
.add(ustEventName
);
1039 fService
.enableEvents(sessionName
, channelName
, list
, false, null, new NullProgressMonitor());
1041 // 4) session name, channel = mychannel, no event name, ust, with filter
1042 fService
.enableEvents(sessionName
, channelName
, list
, false, "intfield==10", new NullProgressMonitor());
1044 // 5) session name, channel = mychannel, no event name, ust, no filter
1046 fService
.enableEvents(sessionName
, channelName
, list
, false, null, new NullProgressMonitor());
1048 // TODO add test with filters
1050 } catch (ExecutionException e
) {
1056 public void testEnableSyscalls() {
1058 // 1) session name, channel = null, 3 event names, kernel
1059 String sessionName
= "mysession2";
1060 String channelName
= "mychannel";
1062 fShell
.setScenario(SCEN_EVENT_HANDLING
);
1064 // 1) session name, channel = null
1065 fService
.enableSyscalls(sessionName
, null, new NullProgressMonitor());
1067 // 2) session name, channel = mychannel
1068 fService
.enableSyscalls(sessionName
, channelName
, new NullProgressMonitor());
1070 } catch (ExecutionException e
) {
1076 public void testDynamicProbe() {
1078 // 1) session name, channel = null, 3 event names, kernel
1079 String sessionName
= "mysession2";
1080 String channelName
= "mychannel";
1081 String eventName0
= "myevent0";
1082 String eventName1
= "myevent1";
1083 String functionProbe
= "0xc0101340";
1084 String dynProbe
= "init_post";
1086 fShell
.setScenario(SCEN_EVENT_HANDLING
);
1088 // 1) session name, channel = null, event name, function probe, probe
1089 fService
.enableProbe(sessionName
, null, eventName0
, true, functionProbe
, new NullProgressMonitor());
1091 // 2) session name, channel = mychannel
1092 fService
.enableProbe(sessionName
, channelName
, eventName1
, false, dynProbe
, new NullProgressMonitor());
1094 } catch (ExecutionException e
) {
1100 public void testEnableLogLevel() {
1102 // 1) session name, channel = null, 3 event names, kernel
1103 String sessionName
= "mysession2";
1104 String channelName
= "mychannel";
1105 String eventName4
= "myevent4";
1106 String eventName5
= "myevent5";
1108 fShell
.setScenario(SCEN_EVENT_HANDLING
);
1110 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
1111 fService
.enableLogLevel(sessionName
, null, eventName4
, LogLevelType
.LOGLEVEL_ONLY
, TraceLogLevel
.TRACE_DEBUG
, null, new NullProgressMonitor());
1113 // 2) session name, channel = mychannel, null, loglevel, TRACE_DEBUG_FUNCTION
1114 fService
.enableLogLevel(sessionName
, channelName
, eventName5
, LogLevelType
.LOGLEVEL
, TraceLogLevel
.TRACE_DEBUG_FUNCTION
, null, new NullProgressMonitor());
1116 // TODO add test with filters
1118 } catch (ExecutionException e
) {
1124 public void testAddContext() {
1126 // 1) session name, channel = null, 3 event names, kernel
1127 String sessionName
= "mysession2";
1128 String channelName
= "mychannel";
1129 String eventName
= "ust_tests_hello:tptest_sighandler";
1130 List
<String
> contexts
= new ArrayList
<>();
1131 contexts
.add("prio");
1132 contexts
.add("pid");
1134 fShell
.setScenario(SCEN_CONTEXT_HANDLING
);
1136 List
<String
> availContexts
= fService
.getContextList(new NullProgressMonitor());
1137 assertNotNull(availContexts
);
1138 assertEquals(12, availContexts
.size());
1140 // A very "hard-coded" way to verify but it works ...
1141 Set
<String
> expectedContexts
= new HashSet
<>();
1142 expectedContexts
.add("pid");
1143 expectedContexts
.add("procname");
1144 expectedContexts
.add("prio");
1145 expectedContexts
.add("nice");
1146 expectedContexts
.add("vpid");
1147 expectedContexts
.add("tid");
1148 expectedContexts
.add("pthread_id");
1149 expectedContexts
.add("vtid");
1150 expectedContexts
.add("ppid");
1151 expectedContexts
.add("vppid");
1152 expectedContexts
.add("perf:cpu-cycles");
1153 expectedContexts
.add("perf:cycles");
1155 assertTrue(expectedContexts
.containsAll(availContexts
));
1157 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
1158 fService
.addContexts(sessionName
, channelName
, eventName
, false, contexts
, new NullProgressMonitor());
1160 } catch (ExecutionException e
) {
1166 public void testAddContextFailure() {
1168 // 1) session name, channel = null, 3 event names, kernel
1169 String sessionName
= "mysession2";
1170 String channelName
= "mychannel";
1171 String eventName
= "ust_tests_hello:tptest_sighandler";
1172 List
<String
> contexts
= new ArrayList
<>();
1173 contexts
.add("prio");
1174 contexts
.add("pid");
1175 fShell
.setScenario(SCEN_CONTEXT_ERROR_HANDLING
);
1177 fService
.getContextList(new NullProgressMonitor());
1178 fail("No exeption generated");
1179 } catch (ExecutionException e
) {
1183 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
1184 fService
.addContexts(sessionName
, channelName
, eventName
, false, contexts
, new NullProgressMonitor());
1185 fail("No exeption generated");
1186 } catch (ExecutionException e
) {
1192 public void testCalibrate() {
1194 fShell
.setScenario(SCEN_CALIBRATE_HANDLING
);
1195 fService
.calibrate(true, new NullProgressMonitor());
1197 } catch (ExecutionException e
) {
1203 public void testCalibrateFailure() {
1205 fShell
.setScenario(SCEN_CALIBRATE_HANDLING
);
1206 fService
.calibrate(false, new NullProgressMonitor());
1207 fail("No exeption generated");
1208 } catch (ExecutionException e
) {
1214 public void testCreateSession2_1() {
1217 fShell
.setScenario(SCEN_CREATE_SESSION_2_1
);
1219 ISessionInfo sessionInfo
= new SessionInfo("mysession");
1220 sessionInfo
.setNetworkUrl("net://172.0.0.1");
1221 sessionInfo
.setStreamedTrace(true);
1222 ISessionInfo info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1223 assertNotNull(info
);
1224 assertEquals("mysession", info
.getName());
1225 assertEquals("net://172.0.0.1", info
.getSessionPath());
1226 assertTrue(info
.isStreamedTrace());
1227 fService
.destroySession("mysession", new NullProgressMonitor());
1229 sessionInfo
= new SessionInfo("mysession");
1230 sessionInfo
.setStreamedTrace(true);
1231 sessionInfo
.setNetworkUrl("file:///tmp");
1232 info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1233 assertNotNull(info
);
1234 assertEquals("mysession", info
.getName());
1235 assertEquals("file:///tmp", info
.getSessionPath());
1236 assertTrue(!info
.isStreamedTrace());
1237 fService
.destroySession("mysession", new NullProgressMonitor());
1239 sessionInfo
= new SessionInfo("mysession");
1240 sessionInfo
.setStreamedTrace(true);
1241 sessionInfo
.setNetworkUrl("file:///tmp");
1242 info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1243 assertNotNull(info
);
1244 assertEquals("mysession", info
.getName());
1245 assertEquals("file:///tmp", info
.getSessionPath());
1246 assertTrue(!info
.isStreamedTrace());
1247 fService
.destroySession("mysession", new NullProgressMonitor());
1249 sessionInfo
= new SessionInfo("mysession");
1250 sessionInfo
.setStreamedTrace(true);
1251 sessionInfo
.setControlUrl("tcp://172.0.0.1");
1252 sessionInfo
.setDataUrl("tcp://172.0.0.1:5343");
1253 info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1254 assertNotNull(info
);
1255 assertEquals("mysession", info
.getName());
1256 assertEquals("", info
.getSessionPath()); // the complete network path is not available at this point
1257 assertTrue(info
.isStreamedTrace());
1258 fService
.destroySession("mysession", new NullProgressMonitor());
1260 sessionInfo
= new SessionInfo("mysession");
1261 sessionInfo
.setStreamedTrace(true);
1262 sessionInfo
.setNetworkUrl("net://172.0.0.1:1234:2345");
1263 info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1264 assertNotNull(info
);
1265 assertEquals("mysession", info
.getName());
1266 assertEquals("net://172.0.0.1:1234:2345", info
.getSessionPath());
1267 assertTrue(info
.isStreamedTrace());
1268 fService
.destroySession("mysession", new NullProgressMonitor());
1272 sessionInfo
= new SessionInfo("mysession");
1273 sessionInfo
.setStreamedTrace(true);
1274 sessionInfo
.setNetworkUrl("net://172.0.0.1");
1275 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());
1281 fService
.destroySession("mysession", new NullProgressMonitor());
1284 } catch (ExecutionException e
) {
1290 public void testCreateSessionVerbose2_1() {
1292 fShell
.setScenario(SCEN_CREATE_SESSION_VERBOSE_2_1
);
1295 ISessionInfo sessionInfo
= new SessionInfo("mysession");
1296 sessionInfo
.setStreamedTrace(true);
1297 sessionInfo
.setNetworkUrl("net://172.0.0.1");
1298 ISessionInfo info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1299 assertNotNull(info
);
1300 assertEquals("mysession", info
.getName());
1301 assertEquals("net://172.0.0.1", info
.getSessionPath());
1302 assertTrue(info
.isStreamedTrace());
1303 fService
.destroySession("mysession", new NullProgressMonitor());
1304 } catch (ExecutionException e
) {
1312 public void testCreateSnapshotSession() {
1314 fShell
.setScenario(SCEN_CREATE_SNAPSHOT_SESSION
);
1315 ISessionInfo params
= new SessionInfo("mysession");
1316 params
.setSnapshot(true);
1317 ISessionInfo sessionInfo
= fService
.createSession(params
, new NullProgressMonitor());
1318 assertNotNull(sessionInfo
);
1319 assertEquals("mysession", sessionInfo
.getName());
1320 assertTrue(sessionInfo
.isSnapshotSession());
1321 assertEquals("", sessionInfo
.getSessionPath());
1322 assertTrue(!sessionInfo
.isStreamedTrace());
1324 assertEquals(TraceSessionState
.INACTIVE
, sessionInfo
.getSessionState());
1326 String
[] names
= fService
.getSessionNames(new NullProgressMonitor());
1327 assertEquals(names
[0], "mysession");
1329 ISnapshotInfo snapshotInfo
= fService
.getSnapshotInfo("mysession", new NullProgressMonitor());
1330 assertNotNull(snapshotInfo
);
1331 assertEquals("snapshot-1", snapshotInfo
.getName());
1332 assertEquals("/home/user/lttng-traces/mysession-20130913-141651", snapshotInfo
.getSnapshotPath());
1333 assertEquals(1, snapshotInfo
.getId());
1334 assertTrue(!snapshotInfo
.isStreamedSnapshot());
1336 // we need to set the snapshotInfo to so that the session path is set correctly
1337 sessionInfo
.setSnapshotInfo(snapshotInfo
);
1338 assertEquals("/home/user/lttng-traces/mysession-20130913-141651", sessionInfo
.getSessionPath());
1340 fService
.recordSnapshot("mysession", new NullProgressMonitor());
1342 fService
.destroySession("mysession", new NullProgressMonitor());
1344 } catch (ExecutionException e
) {
1350 public void testCreateSnapshotSession2_5() {
1352 fShell
.setScenario(SCEN_CREATE_SNAPSHOT_SESSION_2_5
);
1353 ISessionInfo params
= new SessionInfo("mysession");
1354 params
.setSnapshot(true);
1355 ISessionInfo sessionInfo
= fService
.createSession(params
, new NullProgressMonitor());
1356 assertNotNull(sessionInfo
);
1357 assertEquals("mysession", sessionInfo
.getName());
1358 assertTrue(sessionInfo
.isSnapshotSession());
1359 assertEquals("", sessionInfo
.getSessionPath());
1360 assertTrue(!sessionInfo
.isStreamedTrace());
1362 assertEquals(TraceSessionState
.INACTIVE
, sessionInfo
.getSessionState());
1364 String
[] names
= fService
.getSessionNames(new NullProgressMonitor());
1365 assertEquals(names
[0], "mysession");
1367 ISnapshotInfo snapshotInfo
= fService
.getSnapshotInfo("mysession", new NullProgressMonitor());
1368 assertNotNull(snapshotInfo
);
1369 assertEquals("snapshot-1", snapshotInfo
.getName());
1370 assertEquals("/home/user/lttng-traces/mysession-20130913-141651", snapshotInfo
.getSnapshotPath());
1371 assertEquals(1, snapshotInfo
.getId());
1372 assertTrue(!snapshotInfo
.isStreamedSnapshot());
1374 // we need to set the snapshotInfo to so that the session path is set correctly
1375 sessionInfo
.setSnapshotInfo(snapshotInfo
);
1376 assertEquals("/home/user/lttng-traces/mysession-20130913-141651", sessionInfo
.getSessionPath());
1378 fService
.recordSnapshot("mysession", new NullProgressMonitor());
1380 fService
.destroySession("mysession", new NullProgressMonitor());
1382 } catch (ExecutionException e
) {
1387 public void testCreateStreamedSnapshotSession() {
1389 fShell
.setScenario(SCEN_CREATE_STREAMED_SNAPSHOT_SESSION
);
1391 ISessionInfo params
= new SessionInfo("mysession");
1392 params
.setNetworkUrl("net://172.0.0.1");
1393 ISessionInfo sessionInfo
= fService
.createSession(params
, new NullProgressMonitor());
1394 assertNotNull(sessionInfo
);
1395 assertEquals("mysession", sessionInfo
.getName());
1396 assertTrue(sessionInfo
.isSnapshotSession());
1398 assertEquals(TraceSessionState
.INACTIVE
, sessionInfo
.getSessionState());
1399 assertTrue(sessionInfo
.isStreamedTrace());
1401 String
[] names
= fService
.getSessionNames(new NullProgressMonitor());
1402 assertEquals(names
[0], "mysession");
1404 ISnapshotInfo snapshotInfo
= sessionInfo
.getSnapshotInfo();
1405 assertNotNull(sessionInfo
);
1406 assertEquals("snapshot-2", snapshotInfo
.getName());
1407 assertEquals("net4://172.0.0.1:5342/", snapshotInfo
.getSnapshotPath());
1408 assertEquals(2, snapshotInfo
.getId());
1409 assertTrue(snapshotInfo
.isStreamedSnapshot());
1411 // we need to set the snapshotInfo to so that the session path is set correctly
1412 sessionInfo
.setSnapshotInfo(snapshotInfo
);
1413 assertEquals("net4://172.0.0.1:5342/", sessionInfo
.getSessionPath());
1415 fService
.recordSnapshot("mysession", new NullProgressMonitor());
1417 fService
.destroySession("mysession", new NullProgressMonitor());
1419 } catch (ExecutionException e
) {
1425 public void testCreateSnapshotSessionErrors() {
1427 fShell
.setScenario(SCEN_CREATE_SNAPSHOT_SESSION_ERRORS
);
1429 String
[] names
= fService
.getSessionNames(new NullProgressMonitor());
1430 assertEquals(names
[0], "mysession");
1431 } catch (ExecutionException e
) {
1436 fService
.getSnapshotInfo("blabla", new NullProgressMonitor());
1437 fail("getSnapshoInfo() didn't fail");
1438 } catch (ExecutionException e
) {
1443 fService
.recordSnapshot("blabla", new NullProgressMonitor());
1444 fail("getSnapshoInfo() didn't fail");
1445 } catch (ExecutionException e
) {
1450 fService
.recordSnapshot("mysession", new NullProgressMonitor());
1451 fail("getSnapshoInfo() didn't fail");
1452 } catch (ExecutionException e
) {
1458 public void testCreateLiveSession() throws ExecutionException
{
1459 fShell
.setScenario(SCEN_CREATE_LIVE_SESSION
);
1461 ISessionInfo params
= new SessionInfo("mysession");
1462 params
.setLive(true);
1463 params
.setStreamedTrace(true);
1464 params
.setNetworkUrl("net://127.0.0.1");
1465 ISessionInfo sessionInfo
= fService
.createSession(params
, new NullProgressMonitor());
1466 assertNotNull(sessionInfo
);
1467 assertEquals("mysession", sessionInfo
.getName());
1468 assertEquals(TraceSessionState
.INACTIVE
, sessionInfo
.getSessionState());
1469 assertTrue(sessionInfo
.isStreamedTrace());
1470 assertTrue(sessionInfo
.isLive());
1471 assertEquals("net://127.0.0.1", sessionInfo
.getSessionPath());
1472 String
[] names
= fService
.getSessionNames(new NullProgressMonitor());
1473 assertEquals(names
[0], "mysession");
1474 fService
.destroySession("mysession", new NullProgressMonitor());
1478 public void testCreateLiveSessionErrors() {
1480 fShell
.setScenario(SCEN_CREATE_LIVE_SESSION_ERRORS
);
1482 ISessionInfo parameters
= new SessionInfo("mysession");
1483 parameters
.setLive(true);
1484 parameters
.setSnapshot(true);
1485 fService
.createSession(parameters
, new NullProgressMonitor());
1486 fail("createSession() didn't fail");
1487 } catch (ExecutionException e
) {
1492 ISessionInfo parameters
= new SessionInfo("mysession");
1493 parameters
.setNetworkUrl("blah");
1494 parameters
.setLive(true);
1495 fService
.createSession(parameters
, new NullProgressMonitor());
1496 fail("createSession() didn't fail");
1497 } catch (ExecutionException e
) {
1502 ISessionInfo parameters
= new SessionInfo("mysession");
1503 parameters
.setControlUrl("net://127.0.0.1");
1504 parameters
.setLive(true);
1505 fService
.createSession(parameters
, new NullProgressMonitor());
1506 fail("createSession() didn't fail");
1507 } catch (ExecutionException e
) {
1512 private static void enableVerbose() {
1514 ControlCommandLogger
.init(ControlPreferences
.getInstance().getLogfilePath(), false);
1515 ControlPreferences
.getInstance().getPreferenceStore().setDefault(ControlPreferences
.TRACE_CONTROL_LOG_COMMANDS_PREF
, true);
1516 ControlPreferences
.getInstance().getPreferenceStore().setDefault(ControlPreferences
.TRACE_CONTROL_VERBOSE_LEVEL_PREF
, ControlPreferences
.TRACE_CONTROL_VERBOSE_LEVEL_V_V_VERBOSE
);
1519 private static void disableVerbose() {
1520 ControlPreferences
.getInstance().getPreferenceStore().setDefault(ControlPreferences
.TRACE_CONTROL_LOG_COMMANDS_PREF
, false);