1 /**********************************************************************
2 * Copyright (c) 2012, 2013 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
.*;
20 import java
.util
.ArrayList
;
21 import java
.util
.HashSet
;
22 import java
.util
.List
;
25 import org
.eclipse
.core
.commands
.ExecutionException
;
26 import org
.eclipse
.core
.runtime
.FileLocator
;
27 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
28 import org
.eclipse
.core
.runtime
.Path
;
29 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IBaseEventInfo
;
30 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IChannelInfo
;
31 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IDomainInfo
;
32 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IEventInfo
;
33 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IFieldInfo
;
34 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.ISessionInfo
;
35 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IUstProviderInfo
;
36 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.LogLevelType
;
37 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceEnablement
;
38 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceEventType
;
39 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceLogLevel
;
40 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceSessionState
;
41 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.impl
.ChannelInfo
;
42 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.service
.CommandShellFactory
;
43 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.shells
.LTTngToolsFileShell
;
44 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.service
.ILttngControlService
;
45 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.service
.LTTngControlService
;
46 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.service
.LTTngControlServiceFactory
;
47 import org
.junit
.Before
;
48 import org
.junit
.Test
;
49 import org
.osgi
.framework
.FrameworkUtil
;
52 * The class <code>LTTngControlServiceTest</code> contains test for the class
53 * <code>{@link LTTngControlService}</code>.
55 @SuppressWarnings({"nls", "javadoc"})
56 public class LTTngControlServiceTest
{
58 private static final String DIRECTORY
= "testfiles";
59 private static final String TEST_STREAM
= "LTTngServiceTest.cfg";
61 private static final String SCEN_LTTNG_NOT_INSTALLED
= "LttngNotInstalled";
62 private static final String SCEN_LTTNG_VERSION
= "LttngVersion";
63 private static final String SCEN_LTTNG_VERSION_WITH_PROMPT
= "LttngVersionWithPrompt";
64 private static final String SCEN_LTTNG_UNSUPPORTED_VERSION
= "LttngUnsupportedVersion";
65 private static final String SCEN_LTTNG_NO_VERSION
= "LttngNoVersion";
66 private static final String SCEN_NO_SESSION_AVAILABLE
= "NoSessionAvailable";
67 private static final String SCEN_GET_SESSION_NAMES1
= "GetSessionNames1";
68 private static final String SCEN_GET_SESSION_NAME_NOT_EXIST
= "GetSessionNameNotExist";
69 private static final String SCEN_GET_SESSION_GARBAGE_OUT
= "GetSessionGarbageOut";
70 private static final String SCEN_GET_SESSION1
= "GetSession1";
71 private static final String SCEN_GET_KERNEL_PROVIDER1
= "GetKernelProvider1";
72 private static final String SCEN_LIST_WITH_NO_KERNEL1
= "ListWithNoKernel1";
73 private static final String SCEN_LIST_WITH_NO_KERNEL2
= "ListWithNoKernel2";
74 private static final String SCEN_GET_UST_PROVIDER1
= "GetUstProvider1";
75 private static final String SCEN_GET_UST_PROVIDER2
= "GetUstProvider2";
76 private static final String SCEN_GET_UST_PROVIDER3
= "GetUstProvider3";
77 private static final String SCEN_CREATE_SESSION1
= "CreateSession1";
78 private static final String SCEN_CREATE_SESSION_WITH_PROMPT
= "CreateSessionWithPrompt";
79 private static final String SCEN_CREATE_SESSION_VARIANTS
= "CreateSessionVariants";
80 private static final String SCEN_DESTROY_SESSION1
= "DestroySession1";
81 private static final String SCEN_CHANNEL_HANDLING
= "ChannelHandling";
82 private static final String SCEN_EVENT_HANDLING
= "EventHandling";
83 private static final String SCEN_CONTEXT_HANDLING
= "ContextHandling";
84 private static final String SCEN_CONTEXT_ERROR_HANDLING
= "ContextErrorHandling";
85 private static final String SCEN_CALIBRATE_HANDLING
= "CalibrateHandling";
87 // ------------------------------------------------------------------------
89 // ------------------------------------------------------------------------
91 private CommandShellFactory fShellFactory
;
92 private String fTestfile
;
93 private LTTngToolsFileShell fShell
;
94 private ILttngControlService fService
;
96 // ------------------------------------------------------------------------
98 // ------------------------------------------------------------------------
101 * Perform pre-test initialization.
104 * if the initialization fails for some reason
107 public void setUp() throws Exception
{
108 fShellFactory
= CommandShellFactory
.getInstance();
110 URL location
= FileLocator
.find(FrameworkUtil
.getBundle(this.getClass()), new Path(DIRECTORY
+ File
.separator
+ TEST_STREAM
), null);
111 File testfile
= new File(FileLocator
.toFileURL(location
).toURI());
112 fTestfile
= testfile
.getAbsolutePath();
114 fShell
= fShellFactory
.getFileShell();
115 fShell
.loadScenarioFile(fTestfile
);
116 fService
= new LTTngControlService(fShell
);
119 // ------------------------------------------------------------------------
121 // ------------------------------------------------------------------------
124 public void testVersion() {
126 fShell
.setScenario(SCEN_LTTNG_VERSION
);
127 ILttngControlService service
= LTTngControlServiceFactory
.getInstance().getLttngControlService(fShell
);
128 assertNotNull(service
);
129 assertEquals("2.1.0", service
.getVersion());
130 } catch (ExecutionException e
) {
131 fail("Exeption thrown " + e
);
136 public void testVersionWithPrompt() {
138 fShell
.setScenario(SCEN_LTTNG_VERSION_WITH_PROMPT
);
139 ILttngControlService service
= LTTngControlServiceFactory
.getInstance().getLttngControlService(fShell
);
140 assertNotNull(service
);
141 assertEquals("2.0.0", service
.getVersion());
142 } catch (ExecutionException e
) {
143 fail("Exeption thrown " + e
);
148 public void testUnsupportedVersion() {
150 fShell
.setScenario(SCEN_LTTNG_UNSUPPORTED_VERSION
);
151 LTTngControlServiceFactory
.getInstance().getLttngControlService(fShell
);
152 fail("No exeption thrown");
153 } catch (ExecutionException e
) {
159 public void testNoVersion() {
161 fShell
.setScenario(SCEN_LTTNG_NO_VERSION
);
162 LTTngControlServiceFactory
.getInstance().getLttngControlService(fShell
);
163 fail("No exeption thrown");
164 } catch (ExecutionException e
) {
170 public void testLttngNotInstalled() {
172 fShell
.setScenario(SCEN_LTTNG_NOT_INSTALLED
);
173 fService
.getSessionNames(new NullProgressMonitor());
174 fail("No exeption thrown");
175 } catch (ExecutionException e
) {
181 public void testGetSessionNames1() {
183 fShell
.setScenario(SCEN_NO_SESSION_AVAILABLE
);
184 String
[] result
= fService
.getSessionNames(new NullProgressMonitor());
186 assertNotNull(result
);
187 assertEquals(0, result
.length
);
189 } catch (ExecutionException e
) {
195 public void testGetSessionNames2() {
197 fShell
.setScenario(SCEN_GET_SESSION_NAMES1
);
198 String
[] result
= fService
.getSessionNames(new NullProgressMonitor());
200 assertNotNull(result
);
201 assertEquals(2, result
.length
);
202 assertEquals("mysession1", result
[0]);
203 assertEquals("mysession", result
[1]);
205 } catch (ExecutionException e
) {
211 public void testGetSessionNotExist() {
213 fShell
.setScenario(SCEN_GET_SESSION_NAME_NOT_EXIST
);
214 fService
.getSessionNames(new NullProgressMonitor());
215 fail("No exeption thrown");
217 } catch (ExecutionException e
) {
223 public void testGetSessionNameGarbage() {
225 fShell
.setScenario(SCEN_GET_SESSION_GARBAGE_OUT
);
226 String
[] result
= fService
.getSessionNames(new NullProgressMonitor());
228 assertNotNull(result
);
229 assertEquals(0, result
.length
);
231 } catch (ExecutionException e
) {
237 public void testGetSession1() {
239 fShell
.setScenario(SCEN_GET_SESSION1
);
240 ISessionInfo session
= fService
.getSession("mysession", new NullProgressMonitor());
243 assertNotNull(session
);
244 assertEquals("mysession", session
.getName());
245 assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session
.getSessionPath());
246 assertEquals(TraceSessionState
.ACTIVE
, session
.getSessionState());
248 IDomainInfo
[] domains
= session
.getDomains();
249 assertNotNull(domains
);
250 assertEquals(2, domains
.length
);
252 // Verify Kernel domain
253 assertEquals("Kernel", domains
[0].getName());
254 IChannelInfo
[] channels
= domains
[0].getChannels();
255 assertNotNull(channels
);
256 assertEquals(2, channels
.length
);
258 // Verify Kernel's channel0
259 assertEquals("channel0", channels
[0].getName());
260 assertEquals(4, channels
[0].getNumberOfSubBuffers());
261 assertEquals("splice()", channels
[0].getOutputType());
262 assertEquals(false, channels
[0].isOverwriteMode());
263 assertEquals(200, channels
[0].getReadTimer());
264 assertEquals(TraceEnablement
.ENABLED
, channels
[0].getState());
265 assertEquals(262144, channels
[0].getSubBufferSize());
266 assertEquals(0, channels
[0].getSwitchTimer());
269 IEventInfo
[] channel0Events
= channels
[0].getEvents();
270 assertNotNull(channel0Events
);
271 assertEquals(2, channel0Events
.length
);
272 assertEquals("block_rq_remap", channel0Events
[0].getName());
273 assertEquals(TraceLogLevel
.TRACE_EMERG
, channel0Events
[0].getLogLevel());
274 assertEquals(TraceEventType
.TRACEPOINT
, channel0Events
[0].getEventType());
275 assertEquals(TraceEnablement
.ENABLED
, channel0Events
[0].getState());
277 assertEquals("block_bio_remap", channel0Events
[1].getName());
278 assertEquals(TraceLogLevel
.TRACE_EMERG
, channel0Events
[1].getLogLevel());
279 assertEquals(TraceEventType
.TRACEPOINT
, channel0Events
[1].getEventType());
280 assertEquals(TraceEnablement
.DISABLED
, channel0Events
[1].getState());
282 // Verify Kernel's channel1
283 assertEquals("channel1", channels
[1].getName());
284 assertEquals(4, channels
[1].getNumberOfSubBuffers());
285 assertEquals("splice()", channels
[1].getOutputType());
286 assertEquals(true, channels
[1].isOverwriteMode());
287 assertEquals(400, channels
[1].getReadTimer());
288 assertEquals(TraceEnablement
.DISABLED
, channels
[1].getState());
289 assertEquals(524288, channels
[1].getSubBufferSize());
290 assertEquals(100, channels
[1].getSwitchTimer());
293 IEventInfo
[] channel1Events
= channels
[1].getEvents();
294 assertEquals(0, channel1Events
.length
);
296 // Verify domain UST global
297 assertEquals("UST global", domains
[1].getName());
299 IChannelInfo
[] ustChannels
= domains
[1].getChannels();
301 // Verify UST global's mychannel1
302 assertEquals("mychannel1", ustChannels
[0].getName());
303 assertEquals(8, ustChannels
[0].getNumberOfSubBuffers());
304 assertEquals("mmap()", ustChannels
[0].getOutputType());
305 assertEquals(true, ustChannels
[0].isOverwriteMode());
306 assertEquals(100, ustChannels
[0].getReadTimer());
307 assertEquals(TraceEnablement
.DISABLED
, ustChannels
[0].getState());
308 assertEquals(8192, ustChannels
[0].getSubBufferSize());
309 assertEquals(200, ustChannels
[0].getSwitchTimer());
312 IEventInfo
[] ustEvents
= ustChannels
[0].getEvents();
313 assertEquals(0, ustEvents
.length
);
315 // Verify UST global's channel0
316 assertEquals("channel0", ustChannels
[1].getName());
317 assertEquals(4, ustChannels
[1].getNumberOfSubBuffers());
318 assertEquals("mmap()", ustChannels
[1].getOutputType());
319 assertEquals(false, ustChannels
[1].isOverwriteMode());
320 assertEquals(200, ustChannels
[1].getReadTimer());
321 assertEquals(TraceEnablement
.ENABLED
, ustChannels
[1].getState());
322 assertEquals(4096, ustChannels
[1].getSubBufferSize());
323 assertEquals(0, ustChannels
[1].getSwitchTimer());
326 ustEvents
= ustChannels
[1].getEvents();
327 assertEquals(2, ustEvents
.length
);
329 assertEquals("ust_tests_hello:tptest_sighandler", ustEvents
[0].getName());
330 assertEquals(TraceLogLevel
.TRACE_DEBUG_LINE
, ustEvents
[0].getLogLevel());
331 assertEquals(TraceEventType
.TRACEPOINT
, ustEvents
[0].getEventType());
332 assertEquals(TraceEnablement
.DISABLED
, ustEvents
[0].getState());
334 assertEquals("*", ustEvents
[1].getName());
335 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, ustEvents
[1].getLogLevel());
336 assertEquals(TraceEventType
.TRACEPOINT
, ustEvents
[1].getEventType());
337 assertEquals(TraceEnablement
.ENABLED
, ustEvents
[1].getState());
339 // next session (no detailed information available)
340 session
= fService
.getSession("mysession1", new NullProgressMonitor());
341 assertNotNull(session
);
342 assertEquals("mysession1", session
.getName());
343 assertEquals("/home/user/lttng-traces/mysession1-20120203-133225", session
.getSessionPath());
344 assertEquals(TraceSessionState
.INACTIVE
, session
.getSessionState());
346 domains
= session
.getDomains();
347 assertNotNull(domains
);
348 assertEquals(0, domains
.length
);
349 } catch (ExecutionException e
) {
354 public void testGetKernelProvider() {
356 fShell
.setScenario(SCEN_GET_KERNEL_PROVIDER1
);
357 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
360 assertNotNull(events
);
361 assertEquals(3, events
.size());
363 IBaseEventInfo baseEventInfo
= events
.get(0);
364 assertNotNull(baseEventInfo
);
365 assertEquals("sched_kthread_stop", baseEventInfo
.getName());
366 assertEquals(TraceLogLevel
.TRACE_EMERG
, baseEventInfo
.getLogLevel());
367 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
369 baseEventInfo
= events
.get(1);
370 assertEquals("sched_kthread_stop_ret", baseEventInfo
.getName());
371 assertEquals(TraceLogLevel
.TRACE_EMERG
, baseEventInfo
.getLogLevel());
372 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
374 baseEventInfo
= events
.get(2);
375 assertEquals("sched_wakeup_new", baseEventInfo
.getName());
376 assertEquals(TraceLogLevel
.TRACE_EMERG
, baseEventInfo
.getLogLevel());
377 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
379 } catch (ExecutionException e
) {
385 public void testGetKernelProviderNoKernel1() {
387 fShell
.setScenario(SCEN_LIST_WITH_NO_KERNEL1
);
388 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
391 assertNotNull(events
);
392 assertEquals(0, events
.size());
394 } catch (ExecutionException e
) {
400 public void testGetKernelProviderNoKernel2() {
402 fShell
.setScenario(SCEN_LIST_WITH_NO_KERNEL2
);
403 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
406 assertNotNull(events
);
407 assertEquals(0, events
.size());
409 } catch (ExecutionException e
) {
415 public void testGetUstProvider() {
417 fShell
.setScenario(SCEN_GET_UST_PROVIDER1
);
418 List
<IUstProviderInfo
> providers
= fService
.getUstProvider();
420 // Check all providers
421 assertNotNull(providers
);
422 assertEquals(2, providers
.size());
424 //Verify first provider
425 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(0).getName());
426 assertEquals(9379, providers
.get(0).getPid());
429 IBaseEventInfo
[] events
= providers
.get(0).getEvents();
430 assertNotNull(events
);
431 assertEquals(2, events
.length
);
433 IBaseEventInfo baseEventInfo
= events
[0];
434 assertNotNull(baseEventInfo
);
435 assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo
.getName());
436 assertEquals(TraceLogLevel
.TRACE_DEBUG_MODULE
, baseEventInfo
.getLogLevel());
437 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
439 baseEventInfo
= events
[1];
440 assertEquals("ust_tests_hello:tptest", baseEventInfo
.getName());
441 assertEquals(TraceLogLevel
.TRACE_INFO
, baseEventInfo
.getLogLevel());
442 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
444 //Verify second provider
445 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(1).getName());
446 assertEquals(4852, providers
.get(1).getPid());
449 events
= providers
.get(1).getEvents();
450 assertNotNull(events
);
451 assertEquals(2, events
.length
);
453 baseEventInfo
= events
[0];
454 assertNotNull(baseEventInfo
);
455 assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo
.getName());
456 assertEquals(TraceLogLevel
.TRACE_WARNING
, baseEventInfo
.getLogLevel());
457 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
459 baseEventInfo
= events
[1];
460 assertEquals("ust_tests_hello:tptest", baseEventInfo
.getName());
461 assertEquals(TraceLogLevel
.TRACE_DEBUG_FUNCTION
, baseEventInfo
.getLogLevel());
462 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
464 } catch (ExecutionException e
) {
470 public void testUstProvider2() {
472 fShell
.setScenario(SCEN_GET_UST_PROVIDER2
);
473 List
<IUstProviderInfo
> providers
= fService
.getUstProvider();
475 assertNotNull(providers
);
476 assertEquals(0, providers
.size());
478 } catch (ExecutionException e
) {
484 public void testGetUstProvider3() {
486 fShell
.setScenario(SCEN_GET_UST_PROVIDER3
);
488 ((LTTngControlService
)fService
).setVersion("2.1.0");
489 List
<IUstProviderInfo
> providers
= fService
.getUstProvider();
491 // Check all providers
492 assertNotNull(providers
);
493 assertEquals(2, providers
.size());
495 //Verify first provider
496 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(0).getName());
497 assertEquals(9379, providers
.get(0).getPid());
500 IBaseEventInfo
[] events
= providers
.get(0).getEvents();
501 assertNotNull(events
);
502 assertEquals(2, events
.length
);
504 IBaseEventInfo baseEventInfo
= events
[0];
505 assertNotNull(baseEventInfo
);
506 IFieldInfo
[] fields
= baseEventInfo
.getFields();
507 assertNotNull(fields
);
508 assertEquals(0, fields
.length
);
510 baseEventInfo
= events
[1];
511 fields
= baseEventInfo
.getFields();
512 assertNotNull(fields
);
513 assertEquals(3, fields
.length
);
514 assertEquals("doublefield", fields
[0].getName());
515 assertEquals("float", fields
[0].getFieldType());
517 assertEquals("floatfield", fields
[1].getName());
518 assertEquals("float", fields
[1].getFieldType());
520 assertEquals("stringfield", fields
[2].getName());
521 assertEquals("string", fields
[2].getFieldType());
523 //Verify second provider
524 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(1).getName());
525 assertEquals(4852, providers
.get(1).getPid());
528 events
= providers
.get(1).getEvents();
529 assertNotNull(events
);
530 assertEquals(2, events
.length
);
532 baseEventInfo
= events
[0];
533 assertNotNull(baseEventInfo
);
534 fields
= baseEventInfo
.getFields();
535 assertNotNull(fields
);
536 assertEquals(0, fields
.length
);
538 baseEventInfo
= events
[1];
539 fields
= baseEventInfo
.getFields();
540 assertNotNull(fields
);
541 assertEquals(3, fields
.length
);
543 assertEquals("doublefield", fields
[0].getName());
544 assertEquals("float", fields
[0].getFieldType());
546 assertEquals("floatfield", fields
[1].getName());
547 assertEquals("float", fields
[1].getFieldType());
549 assertEquals("stringfield", fields
[2].getName());
550 assertEquals("string", fields
[2].getFieldType());
553 ((LTTngControlService
)fService
).setVersion("2.0.0");
555 } catch (ExecutionException e
) {
561 public void testCreateSession() {
563 fShell
.setScenario(SCEN_CREATE_SESSION1
);
565 ISessionInfo info
= fService
.createSession("mysession2", null, new NullProgressMonitor());
567 assertEquals("mysession2", info
.getName());
568 assertNotNull(info
.getSessionPath());
569 assertTrue(info
.getSessionPath().contains("mysession2"));
570 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
571 } catch (ExecutionException e
) {
577 public void testCreateSessionWithPrompt() {
579 // First line has the shell prompt before the command output
580 // This can happen in a real application if the command line is not echoed by the shell.
581 fShell
.setScenario(SCEN_CREATE_SESSION_WITH_PROMPT
);
583 // First line has no shell prompt before the output
584 ISessionInfo info
= fService
.createSession("mysession2", null, new NullProgressMonitor());
586 assertEquals("mysession2", info
.getName());
587 assertNotNull(info
.getSessionPath());
588 assertTrue(info
.getSessionPath().contains("mysession2"));
589 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
590 } catch (ExecutionException e
) {
596 public void testCreateSessionVariants() {
598 fShell
.setScenario(SCEN_CREATE_SESSION_VARIANTS
);
601 fService
.createSession("alreadyExist", null, new NullProgressMonitor());
602 fail("No exeption thrown");
603 } catch (ExecutionException e
) {
608 fService
.createSession("wrongName", null, new NullProgressMonitor());
609 fail("No exeption thrown");
610 } catch (ExecutionException e
) {
615 fService
.createSession("withPath", "/home/user/hallo", new NullProgressMonitor());
616 fail("No exeption thrown");
617 } catch (ExecutionException e
) {
622 ISessionInfo info
= fService
.createSession("session with spaces", null, new NullProgressMonitor());
624 assertEquals("session with spaces", info
.getName());
625 assertNotNull(info
.getSessionPath());
626 assertTrue(info
.getSessionPath().contains("session with spaces"));
627 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
629 } catch (ExecutionException e
) {
634 ISessionInfo info
= fService
.createSession("pathWithSpaces", "/home/user/hallo user/here", new NullProgressMonitor());
636 assertEquals("pathWithSpaces", info
.getName());
637 assertNotNull(info
.getSessionPath());
638 assertTrue(info
.getSessionPath().contains("/home/user/hallo user/here"));
639 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
641 } catch (ExecutionException e
) {
647 public void testDestroySession() {
649 fShell
.setScenario(SCEN_DESTROY_SESSION1
);
650 fService
.destroySession("mysession2", new NullProgressMonitor());
651 } catch (ExecutionException e
) {
657 public void testCreateChannel() {
660 String sessionName
= "mysession2";
661 List
<String
> list
= new ArrayList
<String
>();
662 String kernelChannel0
= "mychannel0";
663 String kernelChannel1
= "mychannel1";
664 list
.add(kernelChannel0
);
665 list
.add(kernelChannel1
);
667 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
669 // Create/enable/configure 2 kernel channels
670 ChannelInfo chanInfo
= new ChannelInfo("");
671 chanInfo
.setOverwriteMode(true);
672 chanInfo
.setSubBufferSize(16384);
673 chanInfo
.setReadTimer(100);
674 chanInfo
.setSwitchTimer(200);
675 chanInfo
.setNumberOfSubBuffers(2);
676 fService
.enableChannels(sessionName
, list
, true, chanInfo
, new NullProgressMonitor());
678 // Create/enable/configure 1 UST channel
680 list
.add("ustChannel");
682 chanInfo
= new ChannelInfo("");
683 chanInfo
.setOverwriteMode(true);
684 chanInfo
.setSubBufferSize(32768);
685 chanInfo
.setReadTimer(200);
686 chanInfo
.setSwitchTimer(100);
687 chanInfo
.setNumberOfSubBuffers(1);
688 fService
.enableChannels(sessionName
, list
, false, chanInfo
, new NullProgressMonitor());
690 } catch (ExecutionException e
) {
696 public void testDisableChannel() {
699 String sessionName
= "mysession2";
700 List
<String
> list
= new ArrayList
<String
>();
701 String kernelChannel0
= "mychannel0";
702 String kernelChannel1
= "mychannel1";
703 list
.add(kernelChannel0
);
704 list
.add(kernelChannel1
);
706 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
707 fService
.disableChannels(sessionName
, list
, true, new NullProgressMonitor());
710 list
.add("ustChannel");
711 fService
.disableChannels(sessionName
, list
, false, new NullProgressMonitor());
713 } catch (ExecutionException e
) {
719 public void testEnableChannel() {
722 String sessionName
= "mysession2";
723 List
<String
> list
= new ArrayList
<String
>();
724 String kernelChannel0
= "mychannel0";
725 String kernelChannel1
= "mychannel1";
726 list
.add(kernelChannel0
);
727 list
.add(kernelChannel1
);
729 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
730 fService
.enableChannels(sessionName
, list
, true, null, new NullProgressMonitor());
732 // Create/enable/configure 1 UST channel
734 list
.add("ustChannel");
736 fService
.enableChannels(sessionName
, list
, false, null, new NullProgressMonitor());
738 } catch (ExecutionException e
) {
743 // public void tesEnableChannelNoTracer() {
745 // ILttngControlService service = new LTTngControlService(fShellFactory.getShellForChannelNoTracer());
746 // service.getSessionNames(new NullProgressMonitor());
747 // fail("No exeption thrown");
749 // } catch (ExecutionException e) {
755 public void testEnableEvents() {
757 // 1) session name, channel = null, 3 event names, kernel
758 String sessionName
= "mysession2";
759 List
<String
> list
= new ArrayList
<String
>();
760 String eventName0
= "block_rq_remap";
761 String eventName1
= "block_bio_remap";
762 String eventName2
= "softirq_entry";
763 list
.add(eventName0
);
764 list
.add(eventName1
);
765 list
.add(eventName2
);
766 fShell
.setScenario(SCEN_EVENT_HANDLING
);
767 fService
.enableEvents(sessionName
, null, list
, true, null, new NullProgressMonitor());
769 // 2) session name, channel=mychannel, event name= null, kernel
770 String channelName
= "mychannel";
771 fService
.enableEvents(sessionName
, channelName
, null, true, null, new NullProgressMonitor());
773 // 3) session name, channel=mychannel, 1 event name, ust, no filter
774 String ustEventName
= "ust_tests_hello:tptest_sighandler";
776 list
.add(ustEventName
);
777 fService
.enableEvents(sessionName
, channelName
, list
, false, null, new NullProgressMonitor());
779 // 4) session name, channel = mychannel, no event name, ust, with filter
780 fService
.enableEvents(sessionName
, channelName
, list
, false, "intfield==10", new NullProgressMonitor());
782 // 5) session name, channel = mychannel, no event name, ust, no filter
784 fService
.enableEvents(sessionName
, channelName
, list
, false, null, new NullProgressMonitor());
786 // TODO add test with filters
788 } catch (ExecutionException e
) {
794 public void testEnableSyscalls() {
796 // 1) session name, channel = null, 3 event names, kernel
797 String sessionName
= "mysession2";
798 String channelName
= "mychannel";
800 fShell
.setScenario(SCEN_EVENT_HANDLING
);
802 // 1) session name, channel = null
803 fService
.enableSyscalls(sessionName
, null, new NullProgressMonitor());
805 // 2) session name, channel = mychannel
806 fService
.enableSyscalls(sessionName
, channelName
, new NullProgressMonitor());
808 } catch (ExecutionException e
) {
814 public void testDynamicProbe() {
816 // 1) session name, channel = null, 3 event names, kernel
817 String sessionName
= "mysession2";
818 String channelName
= "mychannel";
819 String eventName0
= "myevent0";
820 String eventName1
= "myevent1";
821 String functionProbe
= "0xc0101340";
822 String dynProbe
= "init_post";
824 fShell
.setScenario(SCEN_EVENT_HANDLING
);
826 // 1) session name, channel = null, event name, function probe, probe
827 fService
.enableProbe(sessionName
, null, eventName0
, true, functionProbe
, new NullProgressMonitor());
829 // 2) session name, channel = mychannel
830 fService
.enableProbe(sessionName
, channelName
, eventName1
, false, dynProbe
, new NullProgressMonitor());
832 } catch (ExecutionException e
) {
838 public void testEnableLogLevel() {
840 // 1) session name, channel = null, 3 event names, kernel
841 String sessionName
= "mysession2";
842 String channelName
= "mychannel";
843 String eventName4
= "myevent4";
844 String eventName5
= "myevent5";
846 fShell
.setScenario(SCEN_EVENT_HANDLING
);
848 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
849 fService
.enableLogLevel(sessionName
, null, eventName4
, LogLevelType
.LOGLEVEL_ONLY
, TraceLogLevel
.TRACE_DEBUG
, null, new NullProgressMonitor());
851 // 2) session name, channel = mychannel, null, loglevel, TRACE_DEBUG_FUNCTION
852 fService
.enableLogLevel(sessionName
, channelName
, eventName5
, LogLevelType
.LOGLEVEL
, TraceLogLevel
.TRACE_DEBUG_FUNCTION
, null, new NullProgressMonitor());
854 // TODO add test with filters
856 } catch (ExecutionException e
) {
862 public void testAddContext() {
864 // 1) session name, channel = null, 3 event names, kernel
865 String sessionName
= "mysession2";
866 String channelName
= "mychannel";
867 String eventName
= "ust_tests_hello:tptest_sighandler";
868 List
<String
> contexts
= new ArrayList
<String
>();
869 contexts
.add("prio");
872 fShell
.setScenario(SCEN_CONTEXT_HANDLING
);
874 List
<String
> availContexts
= fService
.getContextList(new NullProgressMonitor());
875 assertNotNull(availContexts
);
876 assertEquals(12, availContexts
.size());
878 // A very "hard-coded" way to verify but it works ...
879 Set
<String
> expectedContexts
= new HashSet
<String
>();
880 expectedContexts
.add("pid");
881 expectedContexts
.add("procname");
882 expectedContexts
.add("prio");
883 expectedContexts
.add("nice");
884 expectedContexts
.add("vpid");
885 expectedContexts
.add("tid");
886 expectedContexts
.add("pthread_id");
887 expectedContexts
.add("vtid");
888 expectedContexts
.add("ppid");
889 expectedContexts
.add("vppid");
890 expectedContexts
.add("perf:cpu-cycles");
891 expectedContexts
.add("perf:cycles");
893 assertTrue(expectedContexts
.containsAll(availContexts
));
895 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
896 fService
.addContexts(sessionName
, channelName
, eventName
, false, contexts
, new NullProgressMonitor());
898 } catch (ExecutionException e
) {
904 public void testAddContextFailure() {
906 // 1) session name, channel = null, 3 event names, kernel
907 String sessionName
= "mysession2";
908 String channelName
= "mychannel";
909 String eventName
= "ust_tests_hello:tptest_sighandler";
910 List
<String
> contexts
= new ArrayList
<String
>();
911 contexts
.add("prio");
913 fShell
.setScenario(SCEN_CONTEXT_ERROR_HANDLING
);
915 fService
.getContextList(new NullProgressMonitor());
916 fail("No exeption generated");
917 } catch (ExecutionException e
) {
921 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
922 fService
.addContexts(sessionName
, channelName
, eventName
, false, contexts
, new NullProgressMonitor());
923 fail("No exeption generated");
924 } catch (ExecutionException e
) {
930 public void testCalibrate() {
932 fShell
.setScenario(SCEN_CALIBRATE_HANDLING
);
933 fService
.calibrate(true, new NullProgressMonitor());
935 } catch (ExecutionException e
) {
941 public void testCalibrateFailure() {
943 fShell
.setScenario(SCEN_CALIBRATE_HANDLING
);
944 fService
.calibrate(false, new NullProgressMonitor());
945 fail("No exeption generated");
946 } catch (ExecutionException e
) {