1 /**********************************************************************
2 * Copyright (c) 2012, 2014 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Bernd Hufmann - Initial API and implementation
11 * Alexandre Montplaisir - Port to JUnit4
12 * Marc-Andre Laperle - Support for creating a live session
13 **********************************************************************/
15 package org
.eclipse
.linuxtools
.lttng2
.control
.ui
.tests
.service
;
17 import static org
.junit
.Assert
.assertEquals
;
18 import static org
.junit
.Assert
.assertNotNull
;
19 import static org
.junit
.Assert
.assertTrue
;
20 import static org
.junit
.Assert
.fail
;
24 import java
.util
.ArrayList
;
25 import java
.util
.HashSet
;
26 import java
.util
.List
;
29 import org
.eclipse
.core
.commands
.ExecutionException
;
30 import org
.eclipse
.core
.runtime
.FileLocator
;
31 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
32 import org
.eclipse
.core
.runtime
.Path
;
33 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.stubs
.service
.CommandShellFactory
;
34 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.stubs
.shells
.LTTngToolsFileShell
;
35 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.IBaseEventInfo
;
36 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.IChannelInfo
;
37 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.IDomainInfo
;
38 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.IEventInfo
;
39 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.IFieldInfo
;
40 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.ISessionInfo
;
41 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.ISnapshotInfo
;
42 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.IUstProviderInfo
;
43 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.LogLevelType
;
44 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.TraceEnablement
;
45 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.TraceEventType
;
46 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.TraceLogLevel
;
47 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.TraceSessionState
;
48 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.impl
.BufferType
;
49 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.impl
.ChannelInfo
;
50 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.impl
.SessionInfo
;
51 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.Activator
;
52 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.logging
.ControlCommandLogger
;
53 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.preferences
.ControlPreferences
;
54 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.service
.ILttngControlService
;
55 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.service
.LTTngControlService
;
56 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.service
.LTTngControlServiceFactory
;
57 import org
.junit
.After
;
58 import org
.junit
.Before
;
59 import org
.junit
.Test
;
60 import org
.osgi
.framework
.FrameworkUtil
;
63 * The class <code>LTTngControlServiceTest</code> contains test for the class
64 * <code>{@link LTTngControlService}</code>.
66 @SuppressWarnings("javadoc")
67 public class LTTngControlServiceTest
{
69 private static final String DIRECTORY
= "testfiles";
70 private static final String TEST_STREAM
= "LTTngServiceTest.cfg";
72 private static final String SCEN_LTTNG_NOT_INSTALLED
= "LttngNotInstalled";
73 private static final String SCEN_LTTNG_VERSION
= "LttngVersion";
74 private static final String SCEN_LTTNG_VERSION_WITH_PROMPT
= "LttngVersionWithPrompt";
75 private static final String SCEN_LTTNG_UNSUPPORTED_VERSION
= "LttngUnsupportedVersion";
76 private static final String SCEN_LTTNG_NO_VERSION
= "LttngNoVersion";
77 private static final String SCEN_NO_SESSION_AVAILABLE
= "NoSessionAvailable";
78 private static final String SCEN_GET_SESSION_NAMES1
= "GetSessionNames1";
79 private static final String SCEN_GET_SESSION_NAME_NOT_EXIST
= "GetSessionNameNotExist";
80 private static final String SCEN_GET_SESSION_NAME_NOT_EXIST_VERBOSE
= "GetSessionNameNotExistVerbose";
81 private static final String SCEN_GET_SESSION_GARBAGE_OUT
= "GetSessionGarbageOut";
82 private static final String SCEN_GET_SESSION1
= "GetSession1";
83 private static final String SCEN_GET_KERNEL_PROVIDER1
= "GetKernelProvider1";
84 private static final String SCEN_LIST_WITH_NO_KERNEL1
= "ListWithNoKernel1";
85 private static final String SCEN_LIST_WITH_NO_KERNEL2
= "ListWithNoKernel2";
86 private static final String SCEN_LIST_WITH_NO_KERNEL_VERBOSE
= "ListWithNoKernelVerbose";
87 private static final String SCEN_GET_UST_PROVIDER1
= "GetUstProvider1";
88 private static final String SCEN_GET_UST_PROVIDER2
= "GetUstProvider2";
89 private static final String SCEN_GET_UST_PROVIDER3
= "GetUstProvider3";
90 private static final String SCEN_LIST_WITH_NO_UST1
= "ListWithNoUst1";
91 private static final String SCEN_LIST_WITH_NO_UST2
= "ListWithNoUst2";
92 private static final String SCEN_LIST_WITH_NO_UST3
= "ListWithNoUst3";
93 private static final String SCEN_LIST_WITH_NO_UST_VERBOSE
= "ListWithNoUstVerbose";
94 private static final String SCEN_CREATE_SESSION1
= "CreateSession1";
95 private static final String SCEN_CREATE_SESSION_WITH_PROMPT
= "CreateSessionWithPrompt";
96 private static final String SCEN_CREATE_SESSION_VARIANTS
= "CreateSessionVariants";
97 private static final String SCEN_DESTROY_SESSION1
= "DestroySession1";
98 private static final String SCEN_DESTROY_SESSION_VERBOSE
= "DestroySessionVerbose";
99 private static final String SCEN_CHANNEL_HANDLING
= "ChannelHandling";
100 private static final String SCEN_EVENT_HANDLING
= "EventHandling";
101 private static final String SCEN_CONTEXT_HANDLING
= "ContextHandling";
102 private static final String SCEN_CONTEXT_ERROR_HANDLING
= "ContextErrorHandling";
103 private static final String SCEN_CALIBRATE_HANDLING
= "CalibrateHandling";
104 private static final String SCEN_CREATE_SESSION_2_1
= "CreateSessionLttng2.1";
105 private static final String SCEN_CREATE_SESSION_VERBOSE_2_1
= "CreateSessionLttngVerbose2.1";
106 private static final String SCEN_CREATE_SNAPSHOT_SESSION
= "CreateSessionSnapshot";
107 private static final String SCEN_CREATE_STREAMED_SNAPSHOT_SESSION
= "CreateSessionStreamedSnapshot";
108 private static final String SCEN_CREATE_SNAPSHOT_SESSION_ERRORS
= "CreateSessionSnapshotErrors";
109 private static final String SCEN_CREATE_LIVE_SESSION
= "CreateSessionLive";
110 private static final String SCEN_CREATE_LIVE_SESSION_ERRORS
= "CreateSessionLiveErrors";
112 // ------------------------------------------------------------------------
114 // ------------------------------------------------------------------------
116 private CommandShellFactory fShellFactory
;
117 private String fTestfile
;
118 private LTTngToolsFileShell fShell
;
119 private ILttngControlService fService
;
121 // ------------------------------------------------------------------------
123 // ------------------------------------------------------------------------
126 * Perform pre-test initialization.
129 * if the initialization fails for some reason
132 public void setUp() throws Exception
{
133 fShellFactory
= CommandShellFactory
.getInstance();
135 URL location
= FileLocator
.find(FrameworkUtil
.getBundle(this.getClass()), new Path(DIRECTORY
+ File
.separator
+ TEST_STREAM
), null);
136 File testfile
= new File(FileLocator
.toFileURL(location
).toURI());
137 fTestfile
= testfile
.getAbsolutePath();
139 fShell
= fShellFactory
.getFileShell();
140 fShell
.loadScenarioFile(fTestfile
);
141 fService
= new LTTngControlService(fShell
);
143 ControlPreferences
.getInstance().init(Activator
.getDefault().getPreferenceStore());
147 public void tearDown() {
149 ControlPreferences
.getInstance().dispose();
152 // ------------------------------------------------------------------------
154 // ------------------------------------------------------------------------
157 public void testVersion() {
159 fShell
.setScenario(SCEN_LTTNG_VERSION
);
160 ILttngControlService service
= LTTngControlServiceFactory
.getInstance().getLttngControlService(fShell
);
161 assertNotNull(service
);
162 assertEquals("2.1.0", service
.getVersionString());
163 } catch (ExecutionException e
) {
164 fail("Exeption thrown " + e
);
169 public void testVersionWithPrompt() {
171 fShell
.setScenario(SCEN_LTTNG_VERSION_WITH_PROMPT
);
172 ILttngControlService service
= LTTngControlServiceFactory
.getInstance().getLttngControlService(fShell
);
173 assertNotNull(service
);
174 assertEquals("2.0.0", service
.getVersionString());
175 } catch (ExecutionException e
) {
176 fail("Exeption thrown " + e
);
181 public void testUnsupportedVersion() {
183 fShell
.setScenario(SCEN_LTTNG_UNSUPPORTED_VERSION
);
184 LTTngControlServiceFactory
.getInstance().getLttngControlService(fShell
);
185 fail("No exeption thrown");
186 } catch (ExecutionException e
) {
192 public void testNoVersion() {
194 fShell
.setScenario(SCEN_LTTNG_NO_VERSION
);
195 LTTngControlServiceFactory
.getInstance().getLttngControlService(fShell
);
196 fail("No exeption thrown");
197 } catch (ExecutionException e
) {
203 public void testLttngNotInstalled() {
205 fShell
.setScenario(SCEN_LTTNG_NOT_INSTALLED
);
206 fService
.getSessionNames(new NullProgressMonitor());
207 fail("No exeption thrown");
208 } catch (ExecutionException e
) {
214 public void testGetSessionNames1() {
216 fShell
.setScenario(SCEN_NO_SESSION_AVAILABLE
);
217 String
[] result
= fService
.getSessionNames(new NullProgressMonitor());
219 assertNotNull(result
);
220 assertEquals(0, result
.length
);
222 } catch (ExecutionException e
) {
228 public void testGetSessionNames2() {
230 fShell
.setScenario(SCEN_GET_SESSION_NAMES1
);
231 String
[] result
= fService
.getSessionNames(new NullProgressMonitor());
233 assertNotNull(result
);
234 assertEquals(2, result
.length
);
235 assertEquals("mysession1", result
[0]);
236 assertEquals("mysession", result
[1]);
238 } catch (ExecutionException e
) {
244 public void testGetSessionNotExist() {
246 fShell
.setScenario(SCEN_GET_SESSION_NAME_NOT_EXIST
);
247 fService
.getSessionNames(new NullProgressMonitor());
248 fail("No exeption thrown");
250 } catch (ExecutionException e
) {
256 public void testGetSessionNotExistVerbose() {
259 fShell
.setScenario(SCEN_GET_SESSION_NAME_NOT_EXIST_VERBOSE
);
260 fService
.getSessionNames(new NullProgressMonitor());
261 fail("No exeption thrown");
263 } catch (ExecutionException e
) {
271 public void testGetSessionNameGarbage() {
273 fShell
.setScenario(SCEN_GET_SESSION_GARBAGE_OUT
);
274 String
[] result
= fService
.getSessionNames(new NullProgressMonitor());
276 assertNotNull(result
);
277 assertEquals(0, result
.length
);
279 } catch (ExecutionException e
) {
285 public void testGetSession1() {
287 fShell
.setScenario(SCEN_GET_SESSION1
);
288 ISessionInfo session
= fService
.getSession("mysession", new NullProgressMonitor());
291 assertNotNull(session
);
292 assertEquals("mysession", session
.getName());
293 assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session
.getSessionPath());
294 assertEquals(TraceSessionState
.ACTIVE
, session
.getSessionState());
296 IDomainInfo
[] domains
= session
.getDomains();
297 assertNotNull(domains
);
298 assertEquals(2, domains
.length
);
300 // Verify Kernel domain
301 assertEquals("Kernel", domains
[0].getName());
302 IChannelInfo
[] channels
= domains
[0].getChannels();
303 assertNotNull(channels
);
304 assertEquals(2, channels
.length
);
306 // Verify Kernel's channel0
307 assertEquals("channel0", channels
[0].getName());
308 assertEquals(4, channels
[0].getNumberOfSubBuffers());
309 assertEquals("splice()", channels
[0].getOutputType());
310 assertEquals(false, channels
[0].isOverwriteMode());
311 assertEquals(200, channels
[0].getReadTimer());
312 assertEquals(TraceEnablement
.ENABLED
, channels
[0].getState());
313 assertEquals(262144, channels
[0].getSubBufferSize());
314 assertEquals(0, channels
[0].getSwitchTimer());
317 IEventInfo
[] channel0Events
= channels
[0].getEvents();
318 assertNotNull(channel0Events
);
319 assertEquals(2, channel0Events
.length
);
320 assertEquals("block_rq_remap", channel0Events
[0].getName());
321 assertEquals(TraceLogLevel
.TRACE_EMERG
, channel0Events
[0].getLogLevel());
322 assertEquals(TraceEventType
.TRACEPOINT
, channel0Events
[0].getEventType());
323 assertEquals(TraceEnablement
.ENABLED
, channel0Events
[0].getState());
325 assertEquals("block_bio_remap", channel0Events
[1].getName());
326 assertEquals(TraceLogLevel
.TRACE_EMERG
, channel0Events
[1].getLogLevel());
327 assertEquals(TraceEventType
.TRACEPOINT
, channel0Events
[1].getEventType());
328 assertEquals(TraceEnablement
.DISABLED
, channel0Events
[1].getState());
330 // Verify Kernel's channel1
331 assertEquals("channel1", channels
[1].getName());
332 assertEquals(4, channels
[1].getNumberOfSubBuffers());
333 assertEquals("splice()", channels
[1].getOutputType());
334 assertEquals(true, channels
[1].isOverwriteMode());
335 assertEquals(400, channels
[1].getReadTimer());
336 assertEquals(TraceEnablement
.DISABLED
, channels
[1].getState());
337 assertEquals(524288, channels
[1].getSubBufferSize());
338 assertEquals(100, channels
[1].getSwitchTimer());
341 IEventInfo
[] channel1Events
= channels
[1].getEvents();
342 assertEquals(0, channel1Events
.length
);
344 // Verify domain UST global
345 assertEquals("UST global", domains
[1].getName());
347 IChannelInfo
[] ustChannels
= domains
[1].getChannels();
349 // Verify UST global's mychannel1
350 assertEquals("mychannel1", ustChannels
[0].getName());
351 assertEquals(8, ustChannels
[0].getNumberOfSubBuffers());
352 assertEquals("mmap()", ustChannels
[0].getOutputType());
353 assertEquals(true, ustChannels
[0].isOverwriteMode());
354 assertEquals(100, ustChannels
[0].getReadTimer());
355 assertEquals(TraceEnablement
.DISABLED
, ustChannels
[0].getState());
356 assertEquals(8192, ustChannels
[0].getSubBufferSize());
357 assertEquals(200, ustChannels
[0].getSwitchTimer());
360 IEventInfo
[] ustEvents
= ustChannels
[0].getEvents();
361 assertEquals(0, ustEvents
.length
);
363 // Verify UST global's channel0
364 assertEquals("channel0", ustChannels
[1].getName());
365 assertEquals(4, ustChannels
[1].getNumberOfSubBuffers());
366 assertEquals("mmap()", ustChannels
[1].getOutputType());
367 assertEquals(false, ustChannels
[1].isOverwriteMode());
368 assertEquals(200, ustChannels
[1].getReadTimer());
369 assertEquals(TraceEnablement
.ENABLED
, ustChannels
[1].getState());
370 assertEquals(4096, ustChannels
[1].getSubBufferSize());
371 assertEquals(0, ustChannels
[1].getSwitchTimer());
374 ustEvents
= ustChannels
[1].getEvents();
375 assertEquals(2, ustEvents
.length
);
377 assertEquals("ust_tests_hello:tptest_sighandler", ustEvents
[0].getName());
378 assertEquals(TraceLogLevel
.TRACE_DEBUG_LINE
, ustEvents
[0].getLogLevel());
379 assertEquals(TraceEventType
.TRACEPOINT
, ustEvents
[0].getEventType());
380 assertEquals(TraceEnablement
.DISABLED
, ustEvents
[0].getState());
382 assertEquals("*", ustEvents
[1].getName());
383 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, ustEvents
[1].getLogLevel());
384 assertEquals(TraceEventType
.TRACEPOINT
, ustEvents
[1].getEventType());
385 assertEquals(TraceEnablement
.ENABLED
, ustEvents
[1].getState());
387 // next session (no detailed information available)
388 session
= fService
.getSession("mysession1", new NullProgressMonitor());
389 assertNotNull(session
);
390 assertEquals("mysession1", session
.getName());
391 assertEquals("/home/user/lttng-traces/mysession1-20120203-133225", session
.getSessionPath());
392 assertEquals(TraceSessionState
.INACTIVE
, session
.getSessionState());
394 domains
= session
.getDomains();
395 assertNotNull(domains
);
396 assertEquals(0, domains
.length
);
397 } catch (ExecutionException e
) {
402 public void testGetKernelProvider() {
404 fShell
.setScenario(SCEN_GET_KERNEL_PROVIDER1
);
405 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
408 assertNotNull(events
);
409 assertEquals(3, events
.size());
411 IBaseEventInfo baseEventInfo
= events
.get(0);
412 assertNotNull(baseEventInfo
);
413 assertEquals("sched_kthread_stop", baseEventInfo
.getName());
414 assertEquals(TraceLogLevel
.TRACE_EMERG
, baseEventInfo
.getLogLevel());
415 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
417 baseEventInfo
= events
.get(1);
418 assertEquals("sched_kthread_stop_ret", baseEventInfo
.getName());
419 assertEquals(TraceLogLevel
.TRACE_EMERG
, baseEventInfo
.getLogLevel());
420 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
422 baseEventInfo
= events
.get(2);
423 assertEquals("sched_wakeup_new", baseEventInfo
.getName());
424 assertEquals(TraceLogLevel
.TRACE_EMERG
, baseEventInfo
.getLogLevel());
425 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
427 } catch (ExecutionException e
) {
433 public void testGetKernelProviderNoKernel1() {
435 fShell
.setScenario(SCEN_LIST_WITH_NO_KERNEL1
);
436 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
439 assertNotNull(events
);
440 assertEquals(0, events
.size());
442 } catch (ExecutionException e
) {
448 public void testGetKernelProviderNoKernel2() {
450 fShell
.setScenario(SCEN_LIST_WITH_NO_KERNEL2
);
451 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
454 assertNotNull(events
);
455 assertEquals(0, events
.size());
457 } catch (ExecutionException e
) {
463 public void testGetKernelProviderNoKernelVerbose() {
466 fShell
.setScenario(SCEN_LIST_WITH_NO_KERNEL_VERBOSE
);
467 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
470 assertNotNull(events
);
471 assertEquals(0, events
.size());
473 } catch (ExecutionException e
) {
481 public void testGetUstProvider() {
483 fShell
.setScenario(SCEN_GET_UST_PROVIDER1
);
484 List
<IUstProviderInfo
> providers
= fService
.getUstProvider();
486 // Check all providers
487 assertNotNull(providers
);
488 assertEquals(2, providers
.size());
490 //Verify first provider
491 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(0).getName());
492 assertEquals(9379, providers
.get(0).getPid());
495 IBaseEventInfo
[] events
= providers
.get(0).getEvents();
496 assertNotNull(events
);
497 assertEquals(2, events
.length
);
499 IBaseEventInfo baseEventInfo
= events
[0];
500 assertNotNull(baseEventInfo
);
501 assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo
.getName());
502 assertEquals(TraceLogLevel
.TRACE_DEBUG_MODULE
, baseEventInfo
.getLogLevel());
503 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
505 baseEventInfo
= events
[1];
506 assertEquals("ust_tests_hello:tptest", baseEventInfo
.getName());
507 assertEquals(TraceLogLevel
.TRACE_INFO
, baseEventInfo
.getLogLevel());
508 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
510 //Verify second provider
511 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(1).getName());
512 assertEquals(4852, providers
.get(1).getPid());
515 events
= providers
.get(1).getEvents();
516 assertNotNull(events
);
517 assertEquals(2, events
.length
);
519 baseEventInfo
= events
[0];
520 assertNotNull(baseEventInfo
);
521 assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo
.getName());
522 assertEquals(TraceLogLevel
.TRACE_WARNING
, baseEventInfo
.getLogLevel());
523 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
525 baseEventInfo
= events
[1];
526 assertEquals("ust_tests_hello:tptest", baseEventInfo
.getName());
527 assertEquals(TraceLogLevel
.TRACE_DEBUG_FUNCTION
, baseEventInfo
.getLogLevel());
528 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
530 } catch (ExecutionException e
) {
536 public void testUstProvider2() {
538 fShell
.setScenario(SCEN_GET_UST_PROVIDER2
);
539 List
<IUstProviderInfo
> providers
= fService
.getUstProvider();
541 assertNotNull(providers
);
542 assertEquals(0, providers
.size());
544 } catch (ExecutionException e
) {
550 public void testGetUstProvider3() {
552 fShell
.setScenario(SCEN_GET_UST_PROVIDER3
);
554 ((LTTngControlService
)fService
).setVersion("2.1.0");
555 List
<IUstProviderInfo
> providers
= fService
.getUstProvider();
557 // Check all providers
558 assertNotNull(providers
);
559 assertEquals(2, providers
.size());
561 //Verify first provider
562 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(0).getName());
563 assertEquals(9379, providers
.get(0).getPid());
566 IBaseEventInfo
[] events
= providers
.get(0).getEvents();
567 assertNotNull(events
);
568 assertEquals(2, events
.length
);
570 IBaseEventInfo baseEventInfo
= events
[0];
571 assertNotNull(baseEventInfo
);
572 IFieldInfo
[] fields
= baseEventInfo
.getFields();
573 assertNotNull(fields
);
574 assertEquals(0, fields
.length
);
576 baseEventInfo
= events
[1];
577 fields
= baseEventInfo
.getFields();
578 assertNotNull(fields
);
579 assertEquals(3, fields
.length
);
580 assertEquals("doublefield", fields
[0].getName());
581 assertEquals("float", fields
[0].getFieldType());
583 assertEquals("floatfield", fields
[1].getName());
584 assertEquals("float", fields
[1].getFieldType());
586 assertEquals("stringfield", fields
[2].getName());
587 assertEquals("string", fields
[2].getFieldType());
589 //Verify second provider
590 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(1).getName());
591 assertEquals(4852, providers
.get(1).getPid());
594 events
= providers
.get(1).getEvents();
595 assertNotNull(events
);
596 assertEquals(2, events
.length
);
598 baseEventInfo
= events
[0];
599 assertNotNull(baseEventInfo
);
600 fields
= baseEventInfo
.getFields();
601 assertNotNull(fields
);
602 assertEquals(0, fields
.length
);
604 baseEventInfo
= events
[1];
605 fields
= baseEventInfo
.getFields();
606 assertNotNull(fields
);
607 assertEquals(3, fields
.length
);
609 assertEquals("doublefield", fields
[0].getName());
610 assertEquals("float", fields
[0].getFieldType());
612 assertEquals("floatfield", fields
[1].getName());
613 assertEquals("float", fields
[1].getFieldType());
615 assertEquals("stringfield", fields
[2].getName());
616 assertEquals("string", fields
[2].getFieldType());
619 ((LTTngControlService
)fService
).setVersion("2.0.0");
621 } catch (ExecutionException e
) {
628 public void testGetKernelProviderNoUst1() {
630 fShell
.setScenario(SCEN_LIST_WITH_NO_UST1
);
631 List
<IUstProviderInfo
> providerList
= fService
.getUstProvider(new NullProgressMonitor());
633 // Verify Provider info
634 assertNotNull(providerList
);
635 assertEquals(0, providerList
.size());
637 } catch (ExecutionException e
) {
644 public void testGetKernelProviderNoUst2() {
647 ((LTTngControlService
)fService
).setVersion("2.1.0");
649 fShell
.setScenario(SCEN_LIST_WITH_NO_UST2
);
650 List
<IUstProviderInfo
> providerList
= fService
.getUstProvider(new NullProgressMonitor());
652 // Verify Provider info
653 assertNotNull(providerList
);
654 assertEquals(0, providerList
.size());
657 ((LTTngControlService
)fService
).setVersion("2.0.0");
659 } catch (ExecutionException e
) {
665 public void testGetKernelProviderNoUst3() {
669 ((LTTngControlService
)fService
).setVersion("2.1.0");
671 fShell
.setScenario(SCEN_LIST_WITH_NO_UST3
);
672 List
<IUstProviderInfo
> providerList
= fService
.getUstProvider(new NullProgressMonitor());
674 // Verify provider info
675 assertNotNull(providerList
);
676 assertEquals(0, providerList
.size());
679 ((LTTngControlService
)fService
).setVersion("2.0.0");
681 } catch (ExecutionException e
) {
687 public void testGetKernelProviderNoUstVerbose() {
692 ((LTTngControlService
)fService
).setVersion("2.1.0");
694 fShell
.setScenario(SCEN_LIST_WITH_NO_UST_VERBOSE
);
695 List
<IUstProviderInfo
> providerList
= fService
.getUstProvider(new NullProgressMonitor());
697 // Verify provider info
698 assertNotNull(providerList
);
699 assertEquals(0, providerList
.size());
702 ((LTTngControlService
)fService
).setVersion("2.0.0");
704 } catch (ExecutionException e
) {
714 public void testCreateSession() {
716 fShell
.setScenario(SCEN_CREATE_SESSION1
);
718 ISessionInfo info
= fService
.createSession(new SessionInfo("mysession2"), new NullProgressMonitor());
720 assertEquals("mysession2", info
.getName());
721 assertNotNull(info
.getSessionPath());
722 assertTrue(info
.getSessionPath().contains("mysession2"));
723 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
724 } catch (ExecutionException e
) {
730 public void testCreateSessionWithPrompt() {
732 // First line has the shell prompt before the command output
733 // This can happen in a real application if the command line is not echoed by the shell.
734 fShell
.setScenario(SCEN_CREATE_SESSION_WITH_PROMPT
);
736 // First line has no shell prompt before the output
737 ISessionInfo info
= fService
.createSession(new SessionInfo("mysession2"), new NullProgressMonitor());
739 assertEquals("mysession2", info
.getName());
740 assertNotNull(info
.getSessionPath());
741 assertTrue(info
.getSessionPath().contains("mysession2"));
742 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
743 } catch (ExecutionException e
) {
749 public void testCreateSessionVariants() {
751 fShell
.setScenario(SCEN_CREATE_SESSION_VARIANTS
);
754 fService
.createSession(new SessionInfo("alreadyExist"), new NullProgressMonitor());
755 fail("No exeption thrown");
756 } catch (ExecutionException e
) {
761 fService
.createSession(new SessionInfo("wrongName"), new NullProgressMonitor());
762 fail("No exeption thrown");
763 } catch (ExecutionException e
) {
768 ISessionInfo sessionInfo
= new SessionInfo("withPath");
769 sessionInfo
.setSessionPath("/home/user/hallo");
770 fService
.createSession(sessionInfo
, new NullProgressMonitor());
771 fail("No exeption thrown");
772 } catch (ExecutionException e
) {
777 ISessionInfo info
= fService
.createSession(new SessionInfo("session with spaces"), new NullProgressMonitor());
779 assertEquals("session with spaces", info
.getName());
780 assertNotNull(info
.getSessionPath());
781 assertTrue(info
.getSessionPath().contains("session with spaces"));
782 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
784 } catch (ExecutionException e
) {
789 ISessionInfo sessionInfo
= new SessionInfo("pathWithSpaces");
790 sessionInfo
.setSessionPath("/home/user/hallo user/here");
791 ISessionInfo info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
793 assertEquals("pathWithSpaces", info
.getName());
794 assertNotNull(info
.getSessionPath());
795 assertTrue(info
.getSessionPath().contains("/home/user/hallo user/here"));
796 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
798 } catch (ExecutionException e
) {
804 public void testDestroySession() {
806 fShell
.setScenario(SCEN_DESTROY_SESSION1
);
807 fService
.destroySession("mysession2", new NullProgressMonitor());
808 } catch (ExecutionException e
) {
814 public void testDestroySessionVerbose() {
817 fShell
.setScenario(SCEN_DESTROY_SESSION_VERBOSE
);
818 fService
.destroySession("mysession2", new NullProgressMonitor());
819 } catch (ExecutionException e
) {
827 public void testCreateChannel() {
829 ((LTTngControlService
)fService
).setVersion("2.2.0");
830 String sessionName
= "mysession2";
831 List
<String
> list
= new ArrayList
<>();
832 String kernelChannel0
= "mychannel0";
833 String kernelChannel1
= "mychannel1";
834 list
.add(kernelChannel0
);
835 list
.add(kernelChannel1
);
837 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
839 // Create/enable/configure 2 kernel channels
840 ChannelInfo chanInfo
= new ChannelInfo("");
841 chanInfo
.setOverwriteMode(true);
842 chanInfo
.setSubBufferSize(16384);
843 chanInfo
.setReadTimer(100);
844 chanInfo
.setSwitchTimer(200);
845 chanInfo
.setNumberOfSubBuffers(2);
846 chanInfo
.setMaxNumberTraceFiles(10);
847 chanInfo
.setMaxSizeTraceFiles(0);
848 fService
.enableChannels(sessionName
, list
, true, chanInfo
, new NullProgressMonitor());
850 // Create/enable/configure 1 UST channel
852 list
.add("ustChannel");
854 chanInfo
= new ChannelInfo("");
855 chanInfo
.setOverwriteMode(true);
856 chanInfo
.setSubBufferSize(32768);
857 chanInfo
.setReadTimer(200);
858 chanInfo
.setSwitchTimer(100);
859 chanInfo
.setNumberOfSubBuffers(1);
860 chanInfo
.setMaxNumberTraceFiles(20);
861 chanInfo
.setMaxSizeTraceFiles(0);
862 fService
.enableChannels(sessionName
, list
, false, chanInfo
, new NullProgressMonitor());
863 ((LTTngControlService
)fService
).setVersion("2.0.0");
865 } catch (ExecutionException e
) {
871 public void testCreateChannelUIDBuffer() {
873 ((LTTngControlService
)fService
).setVersion("2.2.0");
874 String sessionName
= "mysession2";
875 List
<String
> list
= new ArrayList
<>();
876 String USTChannel
= "ustChannel";
877 list
.add(USTChannel
);
878 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
880 ChannelInfo chanInfo
= new ChannelInfo("");
881 chanInfo
.setOverwriteMode(true);
882 chanInfo
.setSubBufferSize(32768);
883 chanInfo
.setReadTimer(200);
884 chanInfo
.setSwitchTimer(100);
885 chanInfo
.setNumberOfSubBuffers(1);
886 chanInfo
.setMaxNumberTraceFiles(20);
887 chanInfo
.setMaxSizeTraceFiles(0);
888 chanInfo
.setBufferType(BufferType
.BUFFER_PER_UID
);
889 fService
.enableChannels(sessionName
, list
, false, chanInfo
, new NullProgressMonitor());
890 ((LTTngControlService
)fService
).setVersion("2.0.0");
892 } catch (ExecutionException e
) {
898 public void testCreateChannelPIDBuffer() {
900 ((LTTngControlService
)fService
).setVersion("2.2.0");
901 String sessionName
= "mysession2";
902 List
<String
> list
= new ArrayList
<>();
903 String USTChannel
= "ustChannel";
904 list
.add(USTChannel
);
905 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
908 ChannelInfo chanInfo
= new ChannelInfo("");
909 chanInfo
.setOverwriteMode(true);
910 chanInfo
.setSubBufferSize(-1);
911 chanInfo
.setReadTimer(-1);
912 chanInfo
.setSwitchTimer(-1);
913 chanInfo
.setNumberOfSubBuffers(-1);
914 chanInfo
.setMaxNumberTraceFiles(-1);
915 chanInfo
.setMaxSizeTraceFiles(-1);
916 chanInfo
.setBufferType(BufferType
.BUFFER_PER_PID
);
918 fService
.enableChannels(sessionName
, list
, false, chanInfo
, new NullProgressMonitor());
919 ((LTTngControlService
)fService
).setVersion("2.0.0");
921 } catch (ExecutionException e
) {
927 public void testDisableChannel() {
930 String sessionName
= "mysession2";
931 List
<String
> list
= new ArrayList
<>();
932 String kernelChannel0
= "mychannel0";
933 String kernelChannel1
= "mychannel1";
934 list
.add(kernelChannel0
);
935 list
.add(kernelChannel1
);
937 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
938 fService
.disableChannels(sessionName
, list
, true, new NullProgressMonitor());
941 list
.add("ustChannel");
942 fService
.disableChannels(sessionName
, list
, false, new NullProgressMonitor());
944 } catch (ExecutionException e
) {
950 public void testEnableChannel() {
953 String sessionName
= "mysession2";
954 List
<String
> list
= new ArrayList
<>();
955 String kernelChannel0
= "mychannel0";
956 String kernelChannel1
= "mychannel1";
957 list
.add(kernelChannel0
);
958 list
.add(kernelChannel1
);
960 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
961 fService
.enableChannels(sessionName
, list
, true, null, new NullProgressMonitor());
963 // Create/enable/configure 1 UST channel
965 list
.add("ustChannel");
967 fService
.enableChannels(sessionName
, list
, false, null, new NullProgressMonitor());
969 } catch (ExecutionException e
) {
975 public void testEnableEvents() {
977 // 1) session name, channel = null, 3 event names, kernel
978 String sessionName
= "mysession2";
979 List
<String
> list
= new ArrayList
<>();
980 String eventName0
= "block_rq_remap";
981 String eventName1
= "block_bio_remap";
982 String eventName2
= "softirq_entry";
983 list
.add(eventName0
);
984 list
.add(eventName1
);
985 list
.add(eventName2
);
986 fShell
.setScenario(SCEN_EVENT_HANDLING
);
987 fService
.enableEvents(sessionName
, null, list
, true, null, new NullProgressMonitor());
989 // 2) session name, channel=mychannel, event name= null, kernel
990 String channelName
= "mychannel";
991 fService
.enableEvents(sessionName
, channelName
, null, true, null, new NullProgressMonitor());
993 // 3) session name, channel=mychannel, 1 event name, ust, no filter
994 String ustEventName
= "ust_tests_hello:tptest_sighandler";
996 list
.add(ustEventName
);
997 fService
.enableEvents(sessionName
, channelName
, list
, false, null, new NullProgressMonitor());
999 // 4) session name, channel = mychannel, no event name, ust, with filter
1000 fService
.enableEvents(sessionName
, channelName
, list
, false, "intfield==10", new NullProgressMonitor());
1002 // 5) session name, channel = mychannel, no event name, ust, no filter
1004 fService
.enableEvents(sessionName
, channelName
, list
, false, null, new NullProgressMonitor());
1006 // TODO add test with filters
1008 } catch (ExecutionException e
) {
1014 public void testEnableSyscalls() {
1016 // 1) session name, channel = null, 3 event names, kernel
1017 String sessionName
= "mysession2";
1018 String channelName
= "mychannel";
1020 fShell
.setScenario(SCEN_EVENT_HANDLING
);
1022 // 1) session name, channel = null
1023 fService
.enableSyscalls(sessionName
, null, new NullProgressMonitor());
1025 // 2) session name, channel = mychannel
1026 fService
.enableSyscalls(sessionName
, channelName
, new NullProgressMonitor());
1028 } catch (ExecutionException e
) {
1034 public void testDynamicProbe() {
1036 // 1) session name, channel = null, 3 event names, kernel
1037 String sessionName
= "mysession2";
1038 String channelName
= "mychannel";
1039 String eventName0
= "myevent0";
1040 String eventName1
= "myevent1";
1041 String functionProbe
= "0xc0101340";
1042 String dynProbe
= "init_post";
1044 fShell
.setScenario(SCEN_EVENT_HANDLING
);
1046 // 1) session name, channel = null, event name, function probe, probe
1047 fService
.enableProbe(sessionName
, null, eventName0
, true, functionProbe
, new NullProgressMonitor());
1049 // 2) session name, channel = mychannel
1050 fService
.enableProbe(sessionName
, channelName
, eventName1
, false, dynProbe
, new NullProgressMonitor());
1052 } catch (ExecutionException e
) {
1058 public void testEnableLogLevel() {
1060 // 1) session name, channel = null, 3 event names, kernel
1061 String sessionName
= "mysession2";
1062 String channelName
= "mychannel";
1063 String eventName4
= "myevent4";
1064 String eventName5
= "myevent5";
1066 fShell
.setScenario(SCEN_EVENT_HANDLING
);
1068 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
1069 fService
.enableLogLevel(sessionName
, null, eventName4
, LogLevelType
.LOGLEVEL_ONLY
, TraceLogLevel
.TRACE_DEBUG
, null, new NullProgressMonitor());
1071 // 2) session name, channel = mychannel, null, loglevel, TRACE_DEBUG_FUNCTION
1072 fService
.enableLogLevel(sessionName
, channelName
, eventName5
, LogLevelType
.LOGLEVEL
, TraceLogLevel
.TRACE_DEBUG_FUNCTION
, null, new NullProgressMonitor());
1074 // TODO add test with filters
1076 } catch (ExecutionException e
) {
1082 public void testAddContext() {
1084 // 1) session name, channel = null, 3 event names, kernel
1085 String sessionName
= "mysession2";
1086 String channelName
= "mychannel";
1087 String eventName
= "ust_tests_hello:tptest_sighandler";
1088 List
<String
> contexts
= new ArrayList
<>();
1089 contexts
.add("prio");
1090 contexts
.add("pid");
1092 fShell
.setScenario(SCEN_CONTEXT_HANDLING
);
1094 List
<String
> availContexts
= fService
.getContextList(new NullProgressMonitor());
1095 assertNotNull(availContexts
);
1096 assertEquals(12, availContexts
.size());
1098 // A very "hard-coded" way to verify but it works ...
1099 Set
<String
> expectedContexts
= new HashSet
<>();
1100 expectedContexts
.add("pid");
1101 expectedContexts
.add("procname");
1102 expectedContexts
.add("prio");
1103 expectedContexts
.add("nice");
1104 expectedContexts
.add("vpid");
1105 expectedContexts
.add("tid");
1106 expectedContexts
.add("pthread_id");
1107 expectedContexts
.add("vtid");
1108 expectedContexts
.add("ppid");
1109 expectedContexts
.add("vppid");
1110 expectedContexts
.add("perf:cpu-cycles");
1111 expectedContexts
.add("perf:cycles");
1113 assertTrue(expectedContexts
.containsAll(availContexts
));
1115 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
1116 fService
.addContexts(sessionName
, channelName
, eventName
, false, contexts
, new NullProgressMonitor());
1118 } catch (ExecutionException e
) {
1124 public void testAddContextFailure() {
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");
1133 fShell
.setScenario(SCEN_CONTEXT_ERROR_HANDLING
);
1135 fService
.getContextList(new NullProgressMonitor());
1136 fail("No exeption generated");
1137 } catch (ExecutionException e
) {
1141 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
1142 fService
.addContexts(sessionName
, channelName
, eventName
, false, contexts
, new NullProgressMonitor());
1143 fail("No exeption generated");
1144 } catch (ExecutionException e
) {
1150 public void testCalibrate() {
1152 fShell
.setScenario(SCEN_CALIBRATE_HANDLING
);
1153 fService
.calibrate(true, new NullProgressMonitor());
1155 } catch (ExecutionException e
) {
1161 public void testCalibrateFailure() {
1163 fShell
.setScenario(SCEN_CALIBRATE_HANDLING
);
1164 fService
.calibrate(false, new NullProgressMonitor());
1165 fail("No exeption generated");
1166 } catch (ExecutionException e
) {
1172 public void testCreateSession2_1() {
1175 fShell
.setScenario(SCEN_CREATE_SESSION_2_1
);
1177 ISessionInfo sessionInfo
= new SessionInfo("mysession");
1178 sessionInfo
.setNetworkUrl("net://172.0.0.1");
1179 sessionInfo
.setStreamedTrace(true);
1180 ISessionInfo info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1181 assertNotNull(info
);
1182 assertEquals("mysession", info
.getName());
1183 assertEquals("net://172.0.0.1", info
.getSessionPath());
1184 assertTrue(info
.isStreamedTrace());
1185 fService
.destroySession("mysession", new NullProgressMonitor());
1187 sessionInfo
= new SessionInfo("mysession");
1188 sessionInfo
.setStreamedTrace(true);
1189 sessionInfo
.setNetworkUrl("file:///tmp");
1190 info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1191 assertNotNull(info
);
1192 assertEquals("mysession", info
.getName());
1193 assertEquals("file:///tmp", info
.getSessionPath());
1194 assertTrue(!info
.isStreamedTrace());
1195 fService
.destroySession("mysession", new NullProgressMonitor());
1197 sessionInfo
= new SessionInfo("mysession");
1198 sessionInfo
.setStreamedTrace(true);
1199 sessionInfo
.setNetworkUrl("file:///tmp");
1200 info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1201 assertNotNull(info
);
1202 assertEquals("mysession", info
.getName());
1203 assertEquals("file:///tmp", info
.getSessionPath());
1204 assertTrue(!info
.isStreamedTrace());
1205 fService
.destroySession("mysession", new NullProgressMonitor());
1207 sessionInfo
= new SessionInfo("mysession");
1208 sessionInfo
.setStreamedTrace(true);
1209 sessionInfo
.setControlUrl("tcp://172.0.0.1");
1210 sessionInfo
.setDataUrl("tcp://172.0.0.1:5343");
1211 info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1212 assertNotNull(info
);
1213 assertEquals("mysession", info
.getName());
1214 assertEquals("", info
.getSessionPath()); // the complete network path is not available at this point
1215 assertTrue(info
.isStreamedTrace());
1216 fService
.destroySession("mysession", new NullProgressMonitor());
1218 sessionInfo
= new SessionInfo("mysession");
1219 sessionInfo
.setStreamedTrace(true);
1220 sessionInfo
.setNetworkUrl("net://172.0.0.1:1234:2345");
1221 info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1222 assertNotNull(info
);
1223 assertEquals("mysession", info
.getName());
1224 assertEquals("net://172.0.0.1:1234:2345", info
.getSessionPath());
1225 assertTrue(info
.isStreamedTrace());
1226 fService
.destroySession("mysession", new NullProgressMonitor());
1230 sessionInfo
= new SessionInfo("mysession");
1231 sessionInfo
.setStreamedTrace(true);
1232 sessionInfo
.setNetworkUrl("net://172.0.0.1");
1233 info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1234 assertNotNull(info
);
1235 assertEquals("mysession", info
.getName());
1236 assertEquals("net://172.0.0.1", info
.getSessionPath());
1237 assertTrue(info
.isStreamedTrace());
1239 fService
.destroySession("mysession", new NullProgressMonitor());
1242 } catch (ExecutionException e
) {
1248 public void testCreateSessionVerbose2_1() {
1250 fShell
.setScenario(SCEN_CREATE_SESSION_VERBOSE_2_1
);
1253 ISessionInfo sessionInfo
= new SessionInfo("mysession");
1254 sessionInfo
.setStreamedTrace(true);
1255 sessionInfo
.setNetworkUrl("net://172.0.0.1");
1256 ISessionInfo info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1257 assertNotNull(info
);
1258 assertEquals("mysession", info
.getName());
1259 assertEquals("net://172.0.0.1", info
.getSessionPath());
1260 assertTrue(info
.isStreamedTrace());
1261 fService
.destroySession("mysession", new NullProgressMonitor());
1262 } catch (ExecutionException e
) {
1270 public void testCreateSnapshotSession() {
1272 fShell
.setScenario(SCEN_CREATE_SNAPSHOT_SESSION
);
1273 ISessionInfo params
= new SessionInfo("mysession");
1274 params
.setSnapshot(true);
1275 ISessionInfo sessionInfo
= fService
.createSession(params
, new NullProgressMonitor());
1276 assertNotNull(sessionInfo
);
1277 assertEquals("mysession", sessionInfo
.getName());
1278 assertTrue(sessionInfo
.isSnapshotSession());
1279 assertEquals("", sessionInfo
.getSessionPath());
1280 assertTrue(!sessionInfo
.isStreamedTrace());
1282 assertEquals(TraceSessionState
.INACTIVE
, sessionInfo
.getSessionState());
1284 String
[] names
= fService
.getSessionNames(new NullProgressMonitor());
1285 assertEquals(names
[0], "mysession");
1287 ISnapshotInfo snapshotInfo
= fService
.getSnapshotInfo("mysession", new NullProgressMonitor());
1288 assertNotNull(snapshotInfo
);
1289 assertEquals("snapshot-1", snapshotInfo
.getName());
1290 assertEquals("/home/user/lttng-traces/mysession-20130913-141651", snapshotInfo
.getSnapshotPath());
1291 assertEquals(1, snapshotInfo
.getId());
1292 assertTrue(!snapshotInfo
.isStreamedSnapshot());
1294 // we need to set the snapshotInfo to so that the session path is set correctly
1295 sessionInfo
.setSnapshotInfo(snapshotInfo
);
1296 assertEquals("/home/user/lttng-traces/mysession-20130913-141651", sessionInfo
.getSessionPath());
1298 fService
.recordSnapshot("mysession", new NullProgressMonitor());
1300 fService
.destroySession("mysession", new NullProgressMonitor());
1302 } catch (ExecutionException e
) {
1307 public void testCreateStreamedSnapshotSession() {
1309 fShell
.setScenario(SCEN_CREATE_STREAMED_SNAPSHOT_SESSION
);
1311 ISessionInfo params
= new SessionInfo("mysession");
1312 params
.setNetworkUrl("net://172.0.0.1");
1313 ISessionInfo sessionInfo
= fService
.createSession(params
, new NullProgressMonitor());
1314 assertNotNull(sessionInfo
);
1315 assertEquals("mysession", sessionInfo
.getName());
1316 assertTrue(sessionInfo
.isSnapshotSession());
1318 assertEquals(TraceSessionState
.INACTIVE
, sessionInfo
.getSessionState());
1319 assertTrue(sessionInfo
.isStreamedTrace());
1321 String
[] names
= fService
.getSessionNames(new NullProgressMonitor());
1322 assertEquals(names
[0], "mysession");
1324 ISnapshotInfo snapshotInfo
= sessionInfo
.getSnapshotInfo();
1325 assertNotNull(sessionInfo
);
1326 assertEquals("snapshot-2", snapshotInfo
.getName());
1327 assertEquals("net4://172.0.0.1:5342/", snapshotInfo
.getSnapshotPath());
1328 assertEquals(2, snapshotInfo
.getId());
1329 assertTrue(snapshotInfo
.isStreamedSnapshot());
1331 // we need to set the snapshotInfo to so that the session path is set correctly
1332 sessionInfo
.setSnapshotInfo(snapshotInfo
);
1333 assertEquals("net4://172.0.0.1:5342/", sessionInfo
.getSessionPath());
1335 fService
.recordSnapshot("mysession", new NullProgressMonitor());
1337 fService
.destroySession("mysession", new NullProgressMonitor());
1339 } catch (ExecutionException e
) {
1345 public void testCreateSnapshotSessionErrors() {
1347 fShell
.setScenario(SCEN_CREATE_SNAPSHOT_SESSION_ERRORS
);
1349 String
[] names
= fService
.getSessionNames(new NullProgressMonitor());
1350 assertEquals(names
[0], "mysession");
1351 } catch (ExecutionException e
) {
1356 fService
.getSnapshotInfo("blabla", new NullProgressMonitor());
1357 fail("getSnapshoInfo() didn't fail");
1358 } catch (ExecutionException e
) {
1363 fService
.recordSnapshot("blabla", new NullProgressMonitor());
1364 fail("getSnapshoInfo() didn't fail");
1365 } catch (ExecutionException e
) {
1370 fService
.recordSnapshot("mysession", new NullProgressMonitor());
1371 fail("getSnapshoInfo() didn't fail");
1372 } catch (ExecutionException e
) {
1378 public void testCreateLiveSession() throws ExecutionException
{
1379 fShell
.setScenario(SCEN_CREATE_LIVE_SESSION
);
1381 ISessionInfo params
= new SessionInfo("mysession");
1382 params
.setLive(true);
1383 params
.setStreamedTrace(true);
1384 params
.setNetworkUrl("net://127.0.0.1");
1385 ISessionInfo sessionInfo
= fService
.createSession(params
, new NullProgressMonitor());
1386 assertNotNull(sessionInfo
);
1387 assertEquals("mysession", sessionInfo
.getName());
1388 assertEquals(TraceSessionState
.INACTIVE
, sessionInfo
.getSessionState());
1389 assertTrue(sessionInfo
.isStreamedTrace());
1390 assertTrue(sessionInfo
.isLive());
1391 assertEquals("net://127.0.0.1", sessionInfo
.getSessionPath());
1392 String
[] names
= fService
.getSessionNames(new NullProgressMonitor());
1393 assertEquals(names
[0], "mysession");
1394 fService
.destroySession("mysession", new NullProgressMonitor());
1398 public void testCreateLiveSessionErrors() {
1400 fShell
.setScenario(SCEN_CREATE_LIVE_SESSION_ERRORS
);
1402 ISessionInfo parameters
= new SessionInfo("mysession");
1403 parameters
.setLive(true);
1404 parameters
.setSnapshot(true);
1405 fService
.createSession(parameters
, new NullProgressMonitor());
1406 fail("createSession() didn't fail");
1407 } catch (ExecutionException e
) {
1412 ISessionInfo parameters
= new SessionInfo("mysession");
1413 parameters
.setNetworkUrl("blah");
1414 parameters
.setLive(true);
1415 fService
.createSession(parameters
, new NullProgressMonitor());
1416 fail("createSession() didn't fail");
1417 } catch (ExecutionException e
) {
1422 ISessionInfo parameters
= new SessionInfo("mysession");
1423 parameters
.setControlUrl("net://127.0.0.1");
1424 parameters
.setLive(true);
1425 fService
.createSession(parameters
, new NullProgressMonitor());
1426 fail("createSession() didn't fail");
1427 } catch (ExecutionException e
) {
1432 private static void enableVerbose() {
1434 ControlCommandLogger
.init(ControlPreferences
.getInstance().getLogfilePath(), false);
1435 ControlPreferences
.getInstance().getPreferenceStore().setDefault(ControlPreferences
.TRACE_CONTROL_LOG_COMMANDS_PREF
, true);
1436 ControlPreferences
.getInstance().getPreferenceStore().setDefault(ControlPreferences
.TRACE_CONTROL_VERBOSE_LEVEL_PREF
, ControlPreferences
.TRACE_CONTROL_VERBOSE_LEVEL_V_V_VERBOSE
);
1439 private static void disableVerbose() {
1440 ControlPreferences
.getInstance().getPreferenceStore().setDefault(ControlPreferences
.TRACE_CONTROL_LOG_COMMANDS_PREF
, false);