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 **********************************************************************/
14 package org
.eclipse
.linuxtools
.lttng2
.ui
.tests
.control
.service
;
16 import static org
.junit
.Assert
.assertEquals
;
17 import static org
.junit
.Assert
.assertNotNull
;
18 import static org
.junit
.Assert
.assertTrue
;
19 import static org
.junit
.Assert
.fail
;
23 import java
.util
.ArrayList
;
24 import java
.util
.HashSet
;
25 import java
.util
.List
;
28 import org
.eclipse
.core
.commands
.ExecutionException
;
29 import org
.eclipse
.core
.runtime
.FileLocator
;
30 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
31 import org
.eclipse
.core
.runtime
.Path
;
32 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IBaseEventInfo
;
33 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IChannelInfo
;
34 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IDomainInfo
;
35 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IEventInfo
;
36 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IFieldInfo
;
37 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.ISessionInfo
;
38 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.ISnapshotInfo
;
39 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IUstProviderInfo
;
40 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.LogLevelType
;
41 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceEnablement
;
42 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceEventType
;
43 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceLogLevel
;
44 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceSessionState
;
45 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.impl
.BufferType
;
46 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.impl
.ChannelInfo
;
47 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.impl
.SessionInfo
;
48 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.service
.CommandShellFactory
;
49 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.shells
.LTTngToolsFileShell
;
50 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.Activator
;
51 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.logging
.ControlCommandLogger
;
52 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.preferences
.ControlPreferences
;
53 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.service
.ILttngControlService
;
54 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.service
.LTTngControlService
;
55 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.service
.LTTngControlServiceFactory
;
56 import org
.junit
.After
;
57 import org
.junit
.Before
;
58 import org
.junit
.Test
;
59 import org
.osgi
.framework
.FrameworkUtil
;
62 * The class <code>LTTngControlServiceTest</code> contains test for the class
63 * <code>{@link LTTngControlService}</code>.
65 @SuppressWarnings("javadoc")
66 public class LTTngControlServiceTest
{
68 private static final String DIRECTORY
= "testfiles";
69 private static final String TEST_STREAM
= "LTTngServiceTest.cfg";
71 private static final String SCEN_LTTNG_NOT_INSTALLED
= "LttngNotInstalled";
72 private static final String SCEN_LTTNG_VERSION
= "LttngVersion";
73 private static final String SCEN_LTTNG_VERSION_WITH_PROMPT
= "LttngVersionWithPrompt";
74 private static final String SCEN_LTTNG_UNSUPPORTED_VERSION
= "LttngUnsupportedVersion";
75 private static final String SCEN_LTTNG_NO_VERSION
= "LttngNoVersion";
76 private static final String SCEN_NO_SESSION_AVAILABLE
= "NoSessionAvailable";
77 private static final String SCEN_GET_SESSION_NAMES1
= "GetSessionNames1";
78 private static final String SCEN_GET_SESSION_NAME_NOT_EXIST
= "GetSessionNameNotExist";
79 private static final String SCEN_GET_SESSION_NAME_NOT_EXIST_VERBOSE
= "GetSessionNameNotExistVerbose";
80 private static final String SCEN_GET_SESSION_GARBAGE_OUT
= "GetSessionGarbageOut";
81 private static final String SCEN_GET_SESSION1
= "GetSession1";
82 private static final String SCEN_GET_KERNEL_PROVIDER1
= "GetKernelProvider1";
83 private static final String SCEN_LIST_WITH_NO_KERNEL1
= "ListWithNoKernel1";
84 private static final String SCEN_LIST_WITH_NO_KERNEL2
= "ListWithNoKernel2";
85 private static final String SCEN_LIST_WITH_NO_KERNEL_VERBOSE
= "ListWithNoKernelVerbose";
86 private static final String SCEN_GET_UST_PROVIDER1
= "GetUstProvider1";
87 private static final String SCEN_GET_UST_PROVIDER2
= "GetUstProvider2";
88 private static final String SCEN_GET_UST_PROVIDER3
= "GetUstProvider3";
89 private static final String SCEN_LIST_WITH_NO_UST1
= "ListWithNoUst1";
90 private static final String SCEN_LIST_WITH_NO_UST2
= "ListWithNoUst2";
91 private static final String SCEN_LIST_WITH_NO_UST3
= "ListWithNoUst3";
92 private static final String SCEN_LIST_WITH_NO_UST_VERBOSE
= "ListWithNoUstVerbose";
93 private static final String SCEN_CREATE_SESSION1
= "CreateSession1";
94 private static final String SCEN_CREATE_SESSION_WITH_PROMPT
= "CreateSessionWithPrompt";
95 private static final String SCEN_CREATE_SESSION_VARIANTS
= "CreateSessionVariants";
96 private static final String SCEN_DESTROY_SESSION1
= "DestroySession1";
97 private static final String SCEN_DESTROY_SESSION_VERBOSE
= "DestroySessionVerbose";
98 private static final String SCEN_CHANNEL_HANDLING
= "ChannelHandling";
99 private static final String SCEN_EVENT_HANDLING
= "EventHandling";
100 private static final String SCEN_CONTEXT_HANDLING
= "ContextHandling";
101 private static final String SCEN_CONTEXT_ERROR_HANDLING
= "ContextErrorHandling";
102 private static final String SCEN_CALIBRATE_HANDLING
= "CalibrateHandling";
103 private static final String SCEN_CREATE_SESSION_2_1
= "CreateSessionLttng2.1";
104 private static final String SCEN_CREATE_SESSION_VERBOSE_2_1
= "CreateSessionLttngVerbose2.1";
105 private static final String SCEN_CREATE_SNAPSHOT_SESSION
= "CreateSessionSnapshot";
106 private static final String SCEN_CREATE_STREAMED_SNAPSHOT_SESSION
= "CreateSessionStreamedSnapshot";
107 private static final String SCEN_CREATE_SNAPSHOT_SESSION_ERRORS
= "CreateSessionSnapshotErrors";
109 // ------------------------------------------------------------------------
111 // ------------------------------------------------------------------------
113 private CommandShellFactory fShellFactory
;
114 private String fTestfile
;
115 private LTTngToolsFileShell fShell
;
116 private ILttngControlService fService
;
118 // ------------------------------------------------------------------------
120 // ------------------------------------------------------------------------
123 * Perform pre-test initialization.
126 * if the initialization fails for some reason
129 public void setUp() throws Exception
{
130 fShellFactory
= CommandShellFactory
.getInstance();
132 URL location
= FileLocator
.find(FrameworkUtil
.getBundle(this.getClass()), new Path(DIRECTORY
+ File
.separator
+ TEST_STREAM
), null);
133 File testfile
= new File(FileLocator
.toFileURL(location
).toURI());
134 fTestfile
= testfile
.getAbsolutePath();
136 fShell
= fShellFactory
.getFileShell();
137 fShell
.loadScenarioFile(fTestfile
);
138 fService
= new LTTngControlService(fShell
);
140 ControlPreferences
.getInstance().init(Activator
.getDefault().getPreferenceStore());
144 public void tearDown() {
146 ControlPreferences
.getInstance().dispose();
149 // ------------------------------------------------------------------------
151 // ------------------------------------------------------------------------
154 public void testVersion() {
156 fShell
.setScenario(SCEN_LTTNG_VERSION
);
157 ILttngControlService service
= LTTngControlServiceFactory
.getInstance().getLttngControlService(fShell
);
158 assertNotNull(service
);
159 assertEquals("2.1.0", service
.getVersion());
160 } catch (ExecutionException e
) {
161 fail("Exeption thrown " + e
);
166 public void testVersionWithPrompt() {
168 fShell
.setScenario(SCEN_LTTNG_VERSION_WITH_PROMPT
);
169 ILttngControlService service
= LTTngControlServiceFactory
.getInstance().getLttngControlService(fShell
);
170 assertNotNull(service
);
171 assertEquals("2.0.0", service
.getVersion());
172 } catch (ExecutionException e
) {
173 fail("Exeption thrown " + e
);
178 public void testUnsupportedVersion() {
180 fShell
.setScenario(SCEN_LTTNG_UNSUPPORTED_VERSION
);
181 LTTngControlServiceFactory
.getInstance().getLttngControlService(fShell
);
182 fail("No exeption thrown");
183 } catch (ExecutionException e
) {
189 public void testNoVersion() {
191 fShell
.setScenario(SCEN_LTTNG_NO_VERSION
);
192 LTTngControlServiceFactory
.getInstance().getLttngControlService(fShell
);
193 fail("No exeption thrown");
194 } catch (ExecutionException e
) {
200 public void testLttngNotInstalled() {
202 fShell
.setScenario(SCEN_LTTNG_NOT_INSTALLED
);
203 fService
.getSessionNames(new NullProgressMonitor());
204 fail("No exeption thrown");
205 } catch (ExecutionException e
) {
211 public void testGetSessionNames1() {
213 fShell
.setScenario(SCEN_NO_SESSION_AVAILABLE
);
214 String
[] result
= fService
.getSessionNames(new NullProgressMonitor());
216 assertNotNull(result
);
217 assertEquals(0, result
.length
);
219 } catch (ExecutionException e
) {
225 public void testGetSessionNames2() {
227 fShell
.setScenario(SCEN_GET_SESSION_NAMES1
);
228 String
[] result
= fService
.getSessionNames(new NullProgressMonitor());
230 assertNotNull(result
);
231 assertEquals(2, result
.length
);
232 assertEquals("mysession1", result
[0]);
233 assertEquals("mysession", result
[1]);
235 } catch (ExecutionException e
) {
241 public void testGetSessionNotExist() {
243 fShell
.setScenario(SCEN_GET_SESSION_NAME_NOT_EXIST
);
244 fService
.getSessionNames(new NullProgressMonitor());
245 fail("No exeption thrown");
247 } catch (ExecutionException e
) {
253 public void testGetSessionNotExistVerbose() {
256 fShell
.setScenario(SCEN_GET_SESSION_NAME_NOT_EXIST_VERBOSE
);
257 fService
.getSessionNames(new NullProgressMonitor());
258 fail("No exeption thrown");
260 } catch (ExecutionException e
) {
268 public void testGetSessionNameGarbage() {
270 fShell
.setScenario(SCEN_GET_SESSION_GARBAGE_OUT
);
271 String
[] result
= fService
.getSessionNames(new NullProgressMonitor());
273 assertNotNull(result
);
274 assertEquals(0, result
.length
);
276 } catch (ExecutionException e
) {
282 public void testGetSession1() {
284 fShell
.setScenario(SCEN_GET_SESSION1
);
285 ISessionInfo session
= fService
.getSession("mysession", new NullProgressMonitor());
288 assertNotNull(session
);
289 assertEquals("mysession", session
.getName());
290 assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session
.getSessionPath());
291 assertEquals(TraceSessionState
.ACTIVE
, session
.getSessionState());
293 IDomainInfo
[] domains
= session
.getDomains();
294 assertNotNull(domains
);
295 assertEquals(2, domains
.length
);
297 // Verify Kernel domain
298 assertEquals("Kernel", domains
[0].getName());
299 IChannelInfo
[] channels
= domains
[0].getChannels();
300 assertNotNull(channels
);
301 assertEquals(2, channels
.length
);
303 // Verify Kernel's channel0
304 assertEquals("channel0", channels
[0].getName());
305 assertEquals(4, channels
[0].getNumberOfSubBuffers());
306 assertEquals("splice()", channels
[0].getOutputType());
307 assertEquals(false, channels
[0].isOverwriteMode());
308 assertEquals(200, channels
[0].getReadTimer());
309 assertEquals(TraceEnablement
.ENABLED
, channels
[0].getState());
310 assertEquals(262144, channels
[0].getSubBufferSize());
311 assertEquals(0, channels
[0].getSwitchTimer());
314 IEventInfo
[] channel0Events
= channels
[0].getEvents();
315 assertNotNull(channel0Events
);
316 assertEquals(2, channel0Events
.length
);
317 assertEquals("block_rq_remap", channel0Events
[0].getName());
318 assertEquals(TraceLogLevel
.TRACE_EMERG
, channel0Events
[0].getLogLevel());
319 assertEquals(TraceEventType
.TRACEPOINT
, channel0Events
[0].getEventType());
320 assertEquals(TraceEnablement
.ENABLED
, channel0Events
[0].getState());
322 assertEquals("block_bio_remap", channel0Events
[1].getName());
323 assertEquals(TraceLogLevel
.TRACE_EMERG
, channel0Events
[1].getLogLevel());
324 assertEquals(TraceEventType
.TRACEPOINT
, channel0Events
[1].getEventType());
325 assertEquals(TraceEnablement
.DISABLED
, channel0Events
[1].getState());
327 // Verify Kernel's channel1
328 assertEquals("channel1", channels
[1].getName());
329 assertEquals(4, channels
[1].getNumberOfSubBuffers());
330 assertEquals("splice()", channels
[1].getOutputType());
331 assertEquals(true, channels
[1].isOverwriteMode());
332 assertEquals(400, channels
[1].getReadTimer());
333 assertEquals(TraceEnablement
.DISABLED
, channels
[1].getState());
334 assertEquals(524288, channels
[1].getSubBufferSize());
335 assertEquals(100, channels
[1].getSwitchTimer());
338 IEventInfo
[] channel1Events
= channels
[1].getEvents();
339 assertEquals(0, channel1Events
.length
);
341 // Verify domain UST global
342 assertEquals("UST global", domains
[1].getName());
344 IChannelInfo
[] ustChannels
= domains
[1].getChannels();
346 // Verify UST global's mychannel1
347 assertEquals("mychannel1", ustChannels
[0].getName());
348 assertEquals(8, ustChannels
[0].getNumberOfSubBuffers());
349 assertEquals("mmap()", ustChannels
[0].getOutputType());
350 assertEquals(true, ustChannels
[0].isOverwriteMode());
351 assertEquals(100, ustChannels
[0].getReadTimer());
352 assertEquals(TraceEnablement
.DISABLED
, ustChannels
[0].getState());
353 assertEquals(8192, ustChannels
[0].getSubBufferSize());
354 assertEquals(200, ustChannels
[0].getSwitchTimer());
357 IEventInfo
[] ustEvents
= ustChannels
[0].getEvents();
358 assertEquals(0, ustEvents
.length
);
360 // Verify UST global's channel0
361 assertEquals("channel0", ustChannels
[1].getName());
362 assertEquals(4, ustChannels
[1].getNumberOfSubBuffers());
363 assertEquals("mmap()", ustChannels
[1].getOutputType());
364 assertEquals(false, ustChannels
[1].isOverwriteMode());
365 assertEquals(200, ustChannels
[1].getReadTimer());
366 assertEquals(TraceEnablement
.ENABLED
, ustChannels
[1].getState());
367 assertEquals(4096, ustChannels
[1].getSubBufferSize());
368 assertEquals(0, ustChannels
[1].getSwitchTimer());
371 ustEvents
= ustChannels
[1].getEvents();
372 assertEquals(2, ustEvents
.length
);
374 assertEquals("ust_tests_hello:tptest_sighandler", ustEvents
[0].getName());
375 assertEquals(TraceLogLevel
.TRACE_DEBUG_LINE
, ustEvents
[0].getLogLevel());
376 assertEquals(TraceEventType
.TRACEPOINT
, ustEvents
[0].getEventType());
377 assertEquals(TraceEnablement
.DISABLED
, ustEvents
[0].getState());
379 assertEquals("*", ustEvents
[1].getName());
380 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, ustEvents
[1].getLogLevel());
381 assertEquals(TraceEventType
.TRACEPOINT
, ustEvents
[1].getEventType());
382 assertEquals(TraceEnablement
.ENABLED
, ustEvents
[1].getState());
384 // next session (no detailed information available)
385 session
= fService
.getSession("mysession1", new NullProgressMonitor());
386 assertNotNull(session
);
387 assertEquals("mysession1", session
.getName());
388 assertEquals("/home/user/lttng-traces/mysession1-20120203-133225", session
.getSessionPath());
389 assertEquals(TraceSessionState
.INACTIVE
, session
.getSessionState());
391 domains
= session
.getDomains();
392 assertNotNull(domains
);
393 assertEquals(0, domains
.length
);
394 } catch (ExecutionException e
) {
399 public void testGetKernelProvider() {
401 fShell
.setScenario(SCEN_GET_KERNEL_PROVIDER1
);
402 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
405 assertNotNull(events
);
406 assertEquals(3, events
.size());
408 IBaseEventInfo baseEventInfo
= events
.get(0);
409 assertNotNull(baseEventInfo
);
410 assertEquals("sched_kthread_stop", baseEventInfo
.getName());
411 assertEquals(TraceLogLevel
.TRACE_EMERG
, baseEventInfo
.getLogLevel());
412 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
414 baseEventInfo
= events
.get(1);
415 assertEquals("sched_kthread_stop_ret", baseEventInfo
.getName());
416 assertEquals(TraceLogLevel
.TRACE_EMERG
, baseEventInfo
.getLogLevel());
417 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
419 baseEventInfo
= events
.get(2);
420 assertEquals("sched_wakeup_new", baseEventInfo
.getName());
421 assertEquals(TraceLogLevel
.TRACE_EMERG
, baseEventInfo
.getLogLevel());
422 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
424 } catch (ExecutionException e
) {
430 public void testGetKernelProviderNoKernel1() {
432 fShell
.setScenario(SCEN_LIST_WITH_NO_KERNEL1
);
433 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
436 assertNotNull(events
);
437 assertEquals(0, events
.size());
439 } catch (ExecutionException e
) {
445 public void testGetKernelProviderNoKernel2() {
447 fShell
.setScenario(SCEN_LIST_WITH_NO_KERNEL2
);
448 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
451 assertNotNull(events
);
452 assertEquals(0, events
.size());
454 } catch (ExecutionException e
) {
460 public void testGetKernelProviderNoKernelVerbose() {
463 fShell
.setScenario(SCEN_LIST_WITH_NO_KERNEL_VERBOSE
);
464 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
467 assertNotNull(events
);
468 assertEquals(0, events
.size());
470 } catch (ExecutionException e
) {
478 public void testGetUstProvider() {
480 fShell
.setScenario(SCEN_GET_UST_PROVIDER1
);
481 List
<IUstProviderInfo
> providers
= fService
.getUstProvider();
483 // Check all providers
484 assertNotNull(providers
);
485 assertEquals(2, providers
.size());
487 //Verify first provider
488 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(0).getName());
489 assertEquals(9379, providers
.get(0).getPid());
492 IBaseEventInfo
[] events
= providers
.get(0).getEvents();
493 assertNotNull(events
);
494 assertEquals(2, events
.length
);
496 IBaseEventInfo baseEventInfo
= events
[0];
497 assertNotNull(baseEventInfo
);
498 assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo
.getName());
499 assertEquals(TraceLogLevel
.TRACE_DEBUG_MODULE
, baseEventInfo
.getLogLevel());
500 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
502 baseEventInfo
= events
[1];
503 assertEquals("ust_tests_hello:tptest", baseEventInfo
.getName());
504 assertEquals(TraceLogLevel
.TRACE_INFO
, baseEventInfo
.getLogLevel());
505 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
507 //Verify second provider
508 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(1).getName());
509 assertEquals(4852, providers
.get(1).getPid());
512 events
= providers
.get(1).getEvents();
513 assertNotNull(events
);
514 assertEquals(2, events
.length
);
516 baseEventInfo
= events
[0];
517 assertNotNull(baseEventInfo
);
518 assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo
.getName());
519 assertEquals(TraceLogLevel
.TRACE_WARNING
, baseEventInfo
.getLogLevel());
520 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
522 baseEventInfo
= events
[1];
523 assertEquals("ust_tests_hello:tptest", baseEventInfo
.getName());
524 assertEquals(TraceLogLevel
.TRACE_DEBUG_FUNCTION
, baseEventInfo
.getLogLevel());
525 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
527 } catch (ExecutionException e
) {
533 public void testUstProvider2() {
535 fShell
.setScenario(SCEN_GET_UST_PROVIDER2
);
536 List
<IUstProviderInfo
> providers
= fService
.getUstProvider();
538 assertNotNull(providers
);
539 assertEquals(0, providers
.size());
541 } catch (ExecutionException e
) {
547 public void testGetUstProvider3() {
549 fShell
.setScenario(SCEN_GET_UST_PROVIDER3
);
551 ((LTTngControlService
)fService
).setVersion("2.1.0");
552 List
<IUstProviderInfo
> providers
= fService
.getUstProvider();
554 // Check all providers
555 assertNotNull(providers
);
556 assertEquals(2, providers
.size());
558 //Verify first provider
559 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(0).getName());
560 assertEquals(9379, providers
.get(0).getPid());
563 IBaseEventInfo
[] events
= providers
.get(0).getEvents();
564 assertNotNull(events
);
565 assertEquals(2, events
.length
);
567 IBaseEventInfo baseEventInfo
= events
[0];
568 assertNotNull(baseEventInfo
);
569 IFieldInfo
[] fields
= baseEventInfo
.getFields();
570 assertNotNull(fields
);
571 assertEquals(0, fields
.length
);
573 baseEventInfo
= events
[1];
574 fields
= baseEventInfo
.getFields();
575 assertNotNull(fields
);
576 assertEquals(3, fields
.length
);
577 assertEquals("doublefield", fields
[0].getName());
578 assertEquals("float", fields
[0].getFieldType());
580 assertEquals("floatfield", fields
[1].getName());
581 assertEquals("float", fields
[1].getFieldType());
583 assertEquals("stringfield", fields
[2].getName());
584 assertEquals("string", fields
[2].getFieldType());
586 //Verify second provider
587 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(1).getName());
588 assertEquals(4852, providers
.get(1).getPid());
591 events
= providers
.get(1).getEvents();
592 assertNotNull(events
);
593 assertEquals(2, events
.length
);
595 baseEventInfo
= events
[0];
596 assertNotNull(baseEventInfo
);
597 fields
= baseEventInfo
.getFields();
598 assertNotNull(fields
);
599 assertEquals(0, fields
.length
);
601 baseEventInfo
= events
[1];
602 fields
= baseEventInfo
.getFields();
603 assertNotNull(fields
);
604 assertEquals(3, fields
.length
);
606 assertEquals("doublefield", fields
[0].getName());
607 assertEquals("float", fields
[0].getFieldType());
609 assertEquals("floatfield", fields
[1].getName());
610 assertEquals("float", fields
[1].getFieldType());
612 assertEquals("stringfield", fields
[2].getName());
613 assertEquals("string", fields
[2].getFieldType());
616 ((LTTngControlService
)fService
).setVersion("2.0.0");
618 } catch (ExecutionException e
) {
625 public void testGetKernelProviderNoUst1() {
627 fShell
.setScenario(SCEN_LIST_WITH_NO_UST1
);
628 List
<IUstProviderInfo
> providerList
= fService
.getUstProvider(new NullProgressMonitor());
630 // Verify Provider info
631 assertNotNull(providerList
);
632 assertEquals(0, providerList
.size());
634 } catch (ExecutionException e
) {
641 public void testGetKernelProviderNoUst2() {
644 ((LTTngControlService
)fService
).setVersion("2.1.0");
646 fShell
.setScenario(SCEN_LIST_WITH_NO_UST2
);
647 List
<IUstProviderInfo
> providerList
= fService
.getUstProvider(new NullProgressMonitor());
649 // Verify Provider info
650 assertNotNull(providerList
);
651 assertEquals(0, providerList
.size());
654 ((LTTngControlService
)fService
).setVersion("2.0.0");
656 } catch (ExecutionException e
) {
662 public void testGetKernelProviderNoUst3() {
666 ((LTTngControlService
)fService
).setVersion("2.1.0");
668 fShell
.setScenario(SCEN_LIST_WITH_NO_UST3
);
669 List
<IUstProviderInfo
> providerList
= fService
.getUstProvider(new NullProgressMonitor());
671 // Verify provider info
672 assertNotNull(providerList
);
673 assertEquals(0, providerList
.size());
676 ((LTTngControlService
)fService
).setVersion("2.0.0");
678 } catch (ExecutionException e
) {
684 public void testGetKernelProviderNoUstVerbose() {
689 ((LTTngControlService
)fService
).setVersion("2.1.0");
691 fShell
.setScenario(SCEN_LIST_WITH_NO_UST_VERBOSE
);
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
) {
711 public void testCreateSession() {
713 fShell
.setScenario(SCEN_CREATE_SESSION1
);
715 ISessionInfo info
= fService
.createSession(new SessionInfo("mysession2"), new NullProgressMonitor());
717 assertEquals("mysession2", info
.getName());
718 assertNotNull(info
.getSessionPath());
719 assertTrue(info
.getSessionPath().contains("mysession2"));
720 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
721 } catch (ExecutionException e
) {
727 public void testCreateSessionWithPrompt() {
729 // First line has the shell prompt before the command output
730 // This can happen in a real application if the command line is not echoed by the shell.
731 fShell
.setScenario(SCEN_CREATE_SESSION_WITH_PROMPT
);
733 // First line has no shell prompt before the output
734 ISessionInfo info
= fService
.createSession(new SessionInfo("mysession2"), new NullProgressMonitor());
736 assertEquals("mysession2", info
.getName());
737 assertNotNull(info
.getSessionPath());
738 assertTrue(info
.getSessionPath().contains("mysession2"));
739 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
740 } catch (ExecutionException e
) {
746 public void testCreateSessionVariants() {
748 fShell
.setScenario(SCEN_CREATE_SESSION_VARIANTS
);
751 fService
.createSession(new SessionInfo("alreadyExist"), new NullProgressMonitor());
752 fail("No exeption thrown");
753 } catch (ExecutionException e
) {
758 fService
.createSession(new SessionInfo("wrongName"), new NullProgressMonitor());
759 fail("No exeption thrown");
760 } catch (ExecutionException e
) {
765 ISessionInfo sessionInfo
= new SessionInfo("withPath");
766 sessionInfo
.setSessionPath("/home/user/hallo");
767 fService
.createSession(sessionInfo
, new NullProgressMonitor());
768 fail("No exeption thrown");
769 } catch (ExecutionException e
) {
774 ISessionInfo info
= fService
.createSession(new SessionInfo("session with spaces"), new NullProgressMonitor());
776 assertEquals("session with spaces", info
.getName());
777 assertNotNull(info
.getSessionPath());
778 assertTrue(info
.getSessionPath().contains("session with spaces"));
779 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
781 } catch (ExecutionException e
) {
786 ISessionInfo sessionInfo
= new SessionInfo("pathWithSpaces");
787 sessionInfo
.setSessionPath("/home/user/hallo user/here");
788 ISessionInfo info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
790 assertEquals("pathWithSpaces", info
.getName());
791 assertNotNull(info
.getSessionPath());
792 assertTrue(info
.getSessionPath().contains("/home/user/hallo user/here"));
793 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
795 } catch (ExecutionException e
) {
801 public void testDestroySession() {
803 fShell
.setScenario(SCEN_DESTROY_SESSION1
);
804 fService
.destroySession("mysession2", new NullProgressMonitor());
805 } catch (ExecutionException e
) {
811 public void testDestroySessionVerbose() {
814 fShell
.setScenario(SCEN_DESTROY_SESSION_VERBOSE
);
815 fService
.destroySession("mysession2", new NullProgressMonitor());
816 } catch (ExecutionException e
) {
824 public void testCreateChannel() {
826 ((LTTngControlService
)fService
).setVersion("2.2.0");
827 String sessionName
= "mysession2";
828 List
<String
> list
= new ArrayList
<>();
829 String kernelChannel0
= "mychannel0";
830 String kernelChannel1
= "mychannel1";
831 list
.add(kernelChannel0
);
832 list
.add(kernelChannel1
);
834 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
836 // Create/enable/configure 2 kernel channels
837 ChannelInfo chanInfo
= new ChannelInfo("");
838 chanInfo
.setOverwriteMode(true);
839 chanInfo
.setSubBufferSize(16384);
840 chanInfo
.setReadTimer(100);
841 chanInfo
.setSwitchTimer(200);
842 chanInfo
.setNumberOfSubBuffers(2);
843 chanInfo
.setMaxNumberTraceFiles(10);
844 chanInfo
.setMaxSizeTraceFiles(0);
845 fService
.enableChannels(sessionName
, list
, true, chanInfo
, new NullProgressMonitor());
847 // Create/enable/configure 1 UST channel
849 list
.add("ustChannel");
851 chanInfo
= new ChannelInfo("");
852 chanInfo
.setOverwriteMode(true);
853 chanInfo
.setSubBufferSize(32768);
854 chanInfo
.setReadTimer(200);
855 chanInfo
.setSwitchTimer(100);
856 chanInfo
.setNumberOfSubBuffers(1);
857 chanInfo
.setMaxNumberTraceFiles(20);
858 chanInfo
.setMaxSizeTraceFiles(0);
859 fService
.enableChannels(sessionName
, list
, false, chanInfo
, new NullProgressMonitor());
860 ((LTTngControlService
)fService
).setVersion("2.0.0");
862 } catch (ExecutionException e
) {
868 public void testCreateChannelUIDBuffer() {
870 ((LTTngControlService
)fService
).setVersion("2.2.0");
871 String sessionName
= "mysession2";
872 List
<String
> list
= new ArrayList
<>();
873 String USTChannel
= "ustChannel";
874 list
.add(USTChannel
);
875 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
877 ChannelInfo chanInfo
= new ChannelInfo("");
878 chanInfo
.setOverwriteMode(true);
879 chanInfo
.setSubBufferSize(32768);
880 chanInfo
.setReadTimer(200);
881 chanInfo
.setSwitchTimer(100);
882 chanInfo
.setNumberOfSubBuffers(1);
883 chanInfo
.setMaxNumberTraceFiles(20);
884 chanInfo
.setMaxSizeTraceFiles(0);
885 chanInfo
.setBufferType(BufferType
.BUFFER_PER_UID
);
886 fService
.enableChannels(sessionName
, list
, false, chanInfo
, new NullProgressMonitor());
887 ((LTTngControlService
)fService
).setVersion("2.0.0");
889 } catch (ExecutionException e
) {
895 public void testCreateChannelPIDBuffer() {
897 ((LTTngControlService
)fService
).setVersion("2.2.0");
898 String sessionName
= "mysession2";
899 List
<String
> list
= new ArrayList
<>();
900 String USTChannel
= "ustChannel";
901 list
.add(USTChannel
);
902 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
905 ChannelInfo chanInfo
= new ChannelInfo("");
906 chanInfo
.setOverwriteMode(true);
907 chanInfo
.setSubBufferSize(-1);
908 chanInfo
.setReadTimer(-1);
909 chanInfo
.setSwitchTimer(-1);
910 chanInfo
.setNumberOfSubBuffers(-1);
911 chanInfo
.setMaxNumberTraceFiles(-1);
912 chanInfo
.setMaxSizeTraceFiles(-1);
913 chanInfo
.setBufferType(BufferType
.BUFFER_PER_PID
);
915 fService
.enableChannels(sessionName
, list
, false, chanInfo
, new NullProgressMonitor());
916 ((LTTngControlService
)fService
).setVersion("2.0.0");
918 } catch (ExecutionException e
) {
924 public void testDisableChannel() {
927 String sessionName
= "mysession2";
928 List
<String
> list
= new ArrayList
<>();
929 String kernelChannel0
= "mychannel0";
930 String kernelChannel1
= "mychannel1";
931 list
.add(kernelChannel0
);
932 list
.add(kernelChannel1
);
934 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
935 fService
.disableChannels(sessionName
, list
, true, new NullProgressMonitor());
938 list
.add("ustChannel");
939 fService
.disableChannels(sessionName
, list
, false, new NullProgressMonitor());
941 } catch (ExecutionException e
) {
947 public void testEnableChannel() {
950 String sessionName
= "mysession2";
951 List
<String
> list
= new ArrayList
<>();
952 String kernelChannel0
= "mychannel0";
953 String kernelChannel1
= "mychannel1";
954 list
.add(kernelChannel0
);
955 list
.add(kernelChannel1
);
957 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
958 fService
.enableChannels(sessionName
, list
, true, null, new NullProgressMonitor());
960 // Create/enable/configure 1 UST channel
962 list
.add("ustChannel");
964 fService
.enableChannels(sessionName
, list
, false, null, new NullProgressMonitor());
966 } catch (ExecutionException e
) {
972 public void testEnableEvents() {
974 // 1) session name, channel = null, 3 event names, kernel
975 String sessionName
= "mysession2";
976 List
<String
> list
= new ArrayList
<>();
977 String eventName0
= "block_rq_remap";
978 String eventName1
= "block_bio_remap";
979 String eventName2
= "softirq_entry";
980 list
.add(eventName0
);
981 list
.add(eventName1
);
982 list
.add(eventName2
);
983 fShell
.setScenario(SCEN_EVENT_HANDLING
);
984 fService
.enableEvents(sessionName
, null, list
, true, null, new NullProgressMonitor());
986 // 2) session name, channel=mychannel, event name= null, kernel
987 String channelName
= "mychannel";
988 fService
.enableEvents(sessionName
, channelName
, null, true, null, new NullProgressMonitor());
990 // 3) session name, channel=mychannel, 1 event name, ust, no filter
991 String ustEventName
= "ust_tests_hello:tptest_sighandler";
993 list
.add(ustEventName
);
994 fService
.enableEvents(sessionName
, channelName
, list
, false, null, new NullProgressMonitor());
996 // 4) session name, channel = mychannel, no event name, ust, with filter
997 fService
.enableEvents(sessionName
, channelName
, list
, false, "intfield==10", new NullProgressMonitor());
999 // 5) session name, channel = mychannel, no event name, ust, no filter
1001 fService
.enableEvents(sessionName
, channelName
, list
, false, null, new NullProgressMonitor());
1003 // TODO add test with filters
1005 } catch (ExecutionException e
) {
1011 public void testEnableSyscalls() {
1013 // 1) session name, channel = null, 3 event names, kernel
1014 String sessionName
= "mysession2";
1015 String channelName
= "mychannel";
1017 fShell
.setScenario(SCEN_EVENT_HANDLING
);
1019 // 1) session name, channel = null
1020 fService
.enableSyscalls(sessionName
, null, new NullProgressMonitor());
1022 // 2) session name, channel = mychannel
1023 fService
.enableSyscalls(sessionName
, channelName
, new NullProgressMonitor());
1025 } catch (ExecutionException e
) {
1031 public void testDynamicProbe() {
1033 // 1) session name, channel = null, 3 event names, kernel
1034 String sessionName
= "mysession2";
1035 String channelName
= "mychannel";
1036 String eventName0
= "myevent0";
1037 String eventName1
= "myevent1";
1038 String functionProbe
= "0xc0101340";
1039 String dynProbe
= "init_post";
1041 fShell
.setScenario(SCEN_EVENT_HANDLING
);
1043 // 1) session name, channel = null, event name, function probe, probe
1044 fService
.enableProbe(sessionName
, null, eventName0
, true, functionProbe
, new NullProgressMonitor());
1046 // 2) session name, channel = mychannel
1047 fService
.enableProbe(sessionName
, channelName
, eventName1
, false, dynProbe
, new NullProgressMonitor());
1049 } catch (ExecutionException e
) {
1055 public void testEnableLogLevel() {
1057 // 1) session name, channel = null, 3 event names, kernel
1058 String sessionName
= "mysession2";
1059 String channelName
= "mychannel";
1060 String eventName4
= "myevent4";
1061 String eventName5
= "myevent5";
1063 fShell
.setScenario(SCEN_EVENT_HANDLING
);
1065 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
1066 fService
.enableLogLevel(sessionName
, null, eventName4
, LogLevelType
.LOGLEVEL_ONLY
, TraceLogLevel
.TRACE_DEBUG
, null, new NullProgressMonitor());
1068 // 2) session name, channel = mychannel, null, loglevel, TRACE_DEBUG_FUNCTION
1069 fService
.enableLogLevel(sessionName
, channelName
, eventName5
, LogLevelType
.LOGLEVEL
, TraceLogLevel
.TRACE_DEBUG_FUNCTION
, null, new NullProgressMonitor());
1071 // TODO add test with filters
1073 } catch (ExecutionException e
) {
1079 public void testAddContext() {
1081 // 1) session name, channel = null, 3 event names, kernel
1082 String sessionName
= "mysession2";
1083 String channelName
= "mychannel";
1084 String eventName
= "ust_tests_hello:tptest_sighandler";
1085 List
<String
> contexts
= new ArrayList
<>();
1086 contexts
.add("prio");
1087 contexts
.add("pid");
1089 fShell
.setScenario(SCEN_CONTEXT_HANDLING
);
1091 List
<String
> availContexts
= fService
.getContextList(new NullProgressMonitor());
1092 assertNotNull(availContexts
);
1093 assertEquals(12, availContexts
.size());
1095 // A very "hard-coded" way to verify but it works ...
1096 Set
<String
> expectedContexts
= new HashSet
<>();
1097 expectedContexts
.add("pid");
1098 expectedContexts
.add("procname");
1099 expectedContexts
.add("prio");
1100 expectedContexts
.add("nice");
1101 expectedContexts
.add("vpid");
1102 expectedContexts
.add("tid");
1103 expectedContexts
.add("pthread_id");
1104 expectedContexts
.add("vtid");
1105 expectedContexts
.add("ppid");
1106 expectedContexts
.add("vppid");
1107 expectedContexts
.add("perf:cpu-cycles");
1108 expectedContexts
.add("perf:cycles");
1110 assertTrue(expectedContexts
.containsAll(availContexts
));
1112 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
1113 fService
.addContexts(sessionName
, channelName
, eventName
, false, contexts
, new NullProgressMonitor());
1115 } catch (ExecutionException e
) {
1121 public void testAddContextFailure() {
1123 // 1) session name, channel = null, 3 event names, kernel
1124 String sessionName
= "mysession2";
1125 String channelName
= "mychannel";
1126 String eventName
= "ust_tests_hello:tptest_sighandler";
1127 List
<String
> contexts
= new ArrayList
<>();
1128 contexts
.add("prio");
1129 contexts
.add("pid");
1130 fShell
.setScenario(SCEN_CONTEXT_ERROR_HANDLING
);
1132 fService
.getContextList(new NullProgressMonitor());
1133 fail("No exeption generated");
1134 } catch (ExecutionException e
) {
1138 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
1139 fService
.addContexts(sessionName
, channelName
, eventName
, false, contexts
, new NullProgressMonitor());
1140 fail("No exeption generated");
1141 } catch (ExecutionException e
) {
1147 public void testCalibrate() {
1149 fShell
.setScenario(SCEN_CALIBRATE_HANDLING
);
1150 fService
.calibrate(true, new NullProgressMonitor());
1152 } catch (ExecutionException e
) {
1158 public void testCalibrateFailure() {
1160 fShell
.setScenario(SCEN_CALIBRATE_HANDLING
);
1161 fService
.calibrate(false, new NullProgressMonitor());
1162 fail("No exeption generated");
1163 } catch (ExecutionException e
) {
1169 public void testCreateSession2_1() {
1172 fShell
.setScenario(SCEN_CREATE_SESSION_2_1
);
1174 ISessionInfo sessionInfo
= new SessionInfo("mysession");
1175 sessionInfo
.setNetworkUrl("net://172.0.0.1");
1176 sessionInfo
.setStreamedTrace(true);
1177 ISessionInfo info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1178 assertNotNull(info
);
1179 assertEquals("mysession", info
.getName());
1180 assertEquals("net://172.0.0.1", info
.getSessionPath());
1181 assertTrue(info
.isStreamedTrace());
1182 fService
.destroySession("mysession", new NullProgressMonitor());
1184 sessionInfo
= new SessionInfo("mysession");
1185 sessionInfo
.setStreamedTrace(true);
1186 sessionInfo
.setNetworkUrl("file:///tmp");
1187 info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1188 assertNotNull(info
);
1189 assertEquals("mysession", info
.getName());
1190 assertEquals("file:///tmp", info
.getSessionPath());
1191 assertTrue(!info
.isStreamedTrace());
1192 fService
.destroySession("mysession", new NullProgressMonitor());
1194 sessionInfo
= new SessionInfo("mysession");
1195 sessionInfo
.setStreamedTrace(true);
1196 sessionInfo
.setNetworkUrl("file:///tmp");
1197 info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1198 assertNotNull(info
);
1199 assertEquals("mysession", info
.getName());
1200 assertEquals("file:///tmp", info
.getSessionPath());
1201 assertTrue(!info
.isStreamedTrace());
1202 fService
.destroySession("mysession", new NullProgressMonitor());
1204 sessionInfo
= new SessionInfo("mysession");
1205 sessionInfo
.setStreamedTrace(true);
1206 sessionInfo
.setControlUrl("tcp://172.0.0.1");
1207 sessionInfo
.setDataUrl("tcp://172.0.0.1:5343");
1208 info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1209 assertNotNull(info
);
1210 assertEquals("mysession", info
.getName());
1211 assertEquals("", info
.getSessionPath()); // the complete network path is not available at this point
1212 assertTrue(info
.isStreamedTrace());
1213 fService
.destroySession("mysession", new NullProgressMonitor());
1215 sessionInfo
= new SessionInfo("mysession");
1216 sessionInfo
.setStreamedTrace(true);
1217 sessionInfo
.setNetworkUrl("net://172.0.0.1:1234:2345");
1218 info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1219 assertNotNull(info
);
1220 assertEquals("mysession", info
.getName());
1221 assertEquals("net://172.0.0.1:1234:2345", info
.getSessionPath());
1222 assertTrue(info
.isStreamedTrace());
1223 fService
.destroySession("mysession", new NullProgressMonitor());
1227 sessionInfo
= new SessionInfo("mysession");
1228 sessionInfo
.setStreamedTrace(true);
1229 sessionInfo
.setNetworkUrl("net://172.0.0.1");
1230 info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1231 assertNotNull(info
);
1232 assertEquals("mysession", info
.getName());
1233 assertEquals("net://172.0.0.1", info
.getSessionPath());
1234 assertTrue(info
.isStreamedTrace());
1236 fService
.destroySession("mysession", new NullProgressMonitor());
1239 } catch (ExecutionException e
) {
1245 public void testCreateSessionVerbose2_1() {
1247 fShell
.setScenario(SCEN_CREATE_SESSION_VERBOSE_2_1
);
1250 ISessionInfo sessionInfo
= new SessionInfo("mysession");
1251 sessionInfo
.setStreamedTrace(true);
1252 sessionInfo
.setNetworkUrl("net://172.0.0.1");
1253 ISessionInfo info
= fService
.createSession(sessionInfo
, new NullProgressMonitor());
1254 assertNotNull(info
);
1255 assertEquals("mysession", info
.getName());
1256 assertEquals("net://172.0.0.1", info
.getSessionPath());
1257 assertTrue(info
.isStreamedTrace());
1258 fService
.destroySession("mysession", new NullProgressMonitor());
1259 } catch (ExecutionException e
) {
1267 public void testCreateSnapshotSession() {
1269 fShell
.setScenario(SCEN_CREATE_SNAPSHOT_SESSION
);
1270 ISessionInfo params
= new SessionInfo("mysession");
1271 params
.setSnapshot(true);
1272 ISessionInfo sessionInfo
= fService
.createSession(params
, new NullProgressMonitor());
1273 assertNotNull(sessionInfo
);
1274 assertEquals("mysession", sessionInfo
.getName());
1275 assertTrue(sessionInfo
.isSnapshotSession());
1276 assertEquals("", sessionInfo
.getSessionPath());
1277 assertTrue(!sessionInfo
.isStreamedTrace());
1279 assertEquals(TraceSessionState
.INACTIVE
, sessionInfo
.getSessionState());
1281 String
[] names
= fService
.getSessionNames(new NullProgressMonitor());
1282 assertEquals(names
[0], "mysession");
1284 ISnapshotInfo snapshotInfo
= fService
.getSnapshotInfo("mysession", new NullProgressMonitor());
1285 assertNotNull(snapshotInfo
);
1286 assertEquals("snapshot-1", snapshotInfo
.getName());
1287 assertEquals("/home/user/lttng-traces/mysession-20130913-141651", snapshotInfo
.getSnapshotPath());
1288 assertEquals(1, snapshotInfo
.getId());
1289 assertTrue(!snapshotInfo
.isStreamedSnapshot());
1291 // we need to set the snapshotInfo to so that the session path is set correctly
1292 sessionInfo
.setSnapshotInfo(snapshotInfo
);
1293 assertEquals("/home/user/lttng-traces/mysession-20130913-141651", sessionInfo
.getSessionPath());
1295 fService
.recordSnapshot("mysession", new NullProgressMonitor());
1297 fService
.destroySession("mysession", new NullProgressMonitor());
1299 } catch (ExecutionException e
) {
1304 public void testCreateStreamedSnapshotSession() {
1306 fShell
.setScenario(SCEN_CREATE_STREAMED_SNAPSHOT_SESSION
);
1308 ISessionInfo params
= new SessionInfo("mysession");
1309 params
.setNetworkUrl("net://172.0.0.1");
1310 ISessionInfo sessionInfo
= fService
.createSession(params
, new NullProgressMonitor());
1311 assertNotNull(sessionInfo
);
1312 assertEquals("mysession", sessionInfo
.getName());
1313 assertTrue(sessionInfo
.isSnapshotSession());
1315 assertEquals(TraceSessionState
.INACTIVE
, sessionInfo
.getSessionState());
1316 assertTrue(sessionInfo
.isStreamedTrace());
1318 String
[] names
= fService
.getSessionNames(new NullProgressMonitor());
1319 assertEquals(names
[0], "mysession");
1322 ISnapshotInfo snapshotInfo
= sessionInfo
.getSnapshotInfo();
1323 assertNotNull(sessionInfo
);
1324 assertEquals("snapshot-2", snapshotInfo
.getName());
1325 assertEquals("net4://172.0.0.1:5342/", snapshotInfo
.getSnapshotPath());
1326 assertEquals(2, snapshotInfo
.getId());
1327 assertTrue(snapshotInfo
.isStreamedSnapshot());
1329 // we need to set the snapshotInfo to so that the session path is set correctly
1330 sessionInfo
.setSnapshotInfo(snapshotInfo
);
1331 assertEquals("net4://172.0.0.1:5342/", sessionInfo
.getSessionPath());
1333 fService
.recordSnapshot("mysession", new NullProgressMonitor());
1335 fService
.destroySession("mysession", new NullProgressMonitor());
1337 } catch (ExecutionException e
) {
1344 public void testCreateSnapshotSessionErrors() {
1346 fShell
.setScenario(SCEN_CREATE_SNAPSHOT_SESSION_ERRORS
);
1348 String
[] names
= fService
.getSessionNames(new NullProgressMonitor());
1349 assertEquals(names
[0], "mysession");
1350 } catch (ExecutionException e
) {
1355 fService
.getSnapshotInfo("blabla", new NullProgressMonitor());
1356 fail("getSnapshoInfo() didn't fail");
1357 } catch (ExecutionException e
) {
1362 fService
.recordSnapshot("blabla", new NullProgressMonitor());
1363 fail("getSnapshoInfo() didn't fail");
1364 } catch (ExecutionException e
) {
1369 fService
.recordSnapshot("mysession", new NullProgressMonitor());
1370 fail("getSnapshoInfo() didn't fail");
1371 } catch (ExecutionException e
) {
1376 private static void enableVerbose() {
1378 ControlCommandLogger
.init(ControlPreferences
.getInstance().getLogfilePath(), false);
1379 ControlPreferences
.getInstance().getPreferenceStore().setDefault(ControlPreferences
.TRACE_CONTROL_LOG_COMMANDS_PREF
, true);
1380 ControlPreferences
.getInstance().getPreferenceStore().setDefault(ControlPreferences
.TRACE_CONTROL_VERBOSE_LEVEL_PREF
, ControlPreferences
.TRACE_CONTROL_VERBOSE_LEVEL_V_V_VERBOSE
);
1383 private static void disableVerbose() {
1384 ControlPreferences
.getInstance().getPreferenceStore().setDefault(ControlPreferences
.TRACE_CONTROL_LOG_COMMANDS_PREF
, false);