1 /**********************************************************************
2 * Copyright (c) 2012 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 **********************************************************************/
12 package org
.eclipse
.linuxtools
.lttng2
.ui
.tests
.control
.service
;
16 import java
.util
.ArrayList
;
17 import java
.util
.HashSet
;
18 import java
.util
.List
;
21 import junit
.framework
.TestCase
;
23 import org
.eclipse
.core
.commands
.ExecutionException
;
24 import org
.eclipse
.core
.runtime
.FileLocator
;
25 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
26 import org
.eclipse
.core
.runtime
.Path
;
27 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IBaseEventInfo
;
28 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IChannelInfo
;
29 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IDomainInfo
;
30 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IEventInfo
;
31 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IFieldInfo
;
32 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.ISessionInfo
;
33 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IUstProviderInfo
;
34 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.LogLevelType
;
35 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceEnablement
;
36 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceEventType
;
37 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceLogLevel
;
38 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceSessionState
;
39 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.impl
.ChannelInfo
;
40 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.service
.CommandShellFactory
;
41 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.shells
.LTTngToolsFileShell
;
42 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.service
.ILttngControlService
;
43 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.service
.LTTngControlService
;
44 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.service
.LTTngControlServiceFactory
;
45 import org
.osgi
.framework
.FrameworkUtil
;
47 * The class <code>LTTngControlServiceTest</code> contains test for the class <code>{@link LTTngControlService}</code>.
49 @SuppressWarnings({"nls", "javadoc"})
50 public class LTTngControlServiceTest
extends TestCase
{
52 private static final String DIRECTORY
= "testfiles";
53 private static final String TEST_STREAM
= "LTTngServiceTest.cfg";
55 private static final String SCEN_LTTNG_NOT_INSTALLED
= "LttngNotInstalled";
56 private static final String SCEN_LTTNG_VERSION
= "LttngVersion";
57 private static final String SCEN_LTTNG_VERSION_WITH_PROMPT
= "LttngVersionWithPrompt";
58 private static final String SCEN_LTTNG_UNSUPPORTED_VERSION
= "LttngUnsupportedVersion";
59 private static final String SCEN_LTTNG_NO_VERSION
= "LttngNoVersion";
60 private static final String SCEN_NO_SESSION_AVAILABLE
= "NoSessionAvailable";
61 private static final String SCEN_GET_SESSION_NAMES1
= "GetSessionNames1";
62 private static final String SCEN_GET_SESSION_NAME_NOT_EXIST
= "GetSessionNameNotExist";
63 private static final String SCEN_GET_SESSION_GARBAGE_OUT
= "GetSessionGarbageOut";
64 private static final String SCEN_GET_SESSION1
= "GetSession1";
65 private static final String SCEN_GET_KERNEL_PROVIDER1
= "GetKernelProvider1";
66 private static final String SCEN_LIST_WITH_NO_KERNEL1
= "ListWithNoKernel1";
67 private static final String SCEN_LIST_WITH_NO_KERNEL2
= "ListWithNoKernel2";
68 private static final String SCEN_GET_UST_PROVIDER1
= "GetUstProvider1";
69 private static final String SCEN_GET_UST_PROVIDER2
= "GetUstProvider2";
70 private static final String SCEN_GET_UST_PROVIDER3
= "GetUstProvider3";
71 private static final String SCEN_CREATE_SESSION1
= "CreateSession1";
72 private static final String SCEN_CREATE_SESSION_WITH_PROMPT
= "CreateSessionWithPrompt";
73 private static final String SCEN_CREATE_SESSION_VARIANTS
= "CreateSessionVariants";
74 private static final String SCEN_DESTROY_SESSION1
= "DestroySession1";
75 private static final String SCEN_CHANNEL_HANDLING
= "ChannelHandling";
76 private static final String SCEN_EVENT_HANDLING
= "EventHandling";
77 private static final String SCEN_CONTEXT_HANDLING
= "ContextHandling";
78 private static final String SCEN_CONTEXT_ERROR_HANDLING
= "ContextErrorHandling";
79 private static final String SCEN_CALIBRATE_HANDLING
= "CalibrateHandling";
81 // ------------------------------------------------------------------------
83 // ------------------------------------------------------------------------
84 private CommandShellFactory fShellFactory
;
85 private String fTestfile
;
86 private LTTngToolsFileShell fShell
;
87 private ILttngControlService fService
;
90 // ------------------------------------------------------------------------
92 // ------------------------------------------------------------------------
94 // ------------------------------------------------------------------------
96 // ------------------------------------------------------------------------
98 * Perform pre-test initialization.
100 * @throws Exception if the initialization fails for some reason
104 public void setUp() throws Exception
{
106 fShellFactory
= CommandShellFactory
.getInstance();
108 URL location
= FileLocator
.find(FrameworkUtil
.getBundle(this.getClass()), new Path(DIRECTORY
+ File
.separator
+ TEST_STREAM
), null);
109 File testfile
= new File(FileLocator
.toFileURL(location
).toURI());
110 fTestfile
= testfile
.getAbsolutePath();
112 fShell
= fShellFactory
.getFileShell();
113 fShell
.loadScenarioFile(fTestfile
);
114 fService
= new LTTngControlService(fShell
);
118 * Perform post-test clean-up.
120 * @throws Exception if the clean-up fails for some reason
124 public void tearDown() throws Exception
{
127 // ------------------------------------------------------------------------
129 // ------------------------------------------------------------------------
131 public void testVersion() {
133 fShell
.setScenario(SCEN_LTTNG_VERSION
);
134 ILttngControlService service
= LTTngControlServiceFactory
.getInstance().getLttngControlService(fShell
);
135 assertNotNull(service
);
136 assertEquals("2.1.0", service
.getVersion());
137 } catch (ExecutionException e
) {
138 fail("Exeption thrown " + e
);
142 public void testVersionWithPrompt() {
144 fShell
.setScenario(SCEN_LTTNG_VERSION_WITH_PROMPT
);
145 ILttngControlService service
= LTTngControlServiceFactory
.getInstance().getLttngControlService(fShell
);
146 assertNotNull(service
);
147 assertEquals("2.0.0", service
.getVersion());
148 } catch (ExecutionException e
) {
149 fail("Exeption thrown " + e
);
153 public void testUnsupportedVersion() {
155 fShell
.setScenario(SCEN_LTTNG_UNSUPPORTED_VERSION
);
156 LTTngControlServiceFactory
.getInstance().getLttngControlService(fShell
);
157 fail("No exeption thrown");
158 } catch (ExecutionException e
) {
163 public void testNoVersion() {
165 fShell
.setScenario(SCEN_LTTNG_NO_VERSION
);
166 LTTngControlServiceFactory
.getInstance().getLttngControlService(fShell
);
167 fail("No exeption thrown");
168 } catch (ExecutionException e
) {
173 public void testLttngNotInstalled() {
175 fShell
.setScenario(SCEN_LTTNG_NOT_INSTALLED
);
176 fService
.getSessionNames(new NullProgressMonitor());
177 fail("No exeption thrown");
178 } catch (ExecutionException e
) {
183 public void testGetSessionNames1() {
185 fShell
.setScenario(SCEN_NO_SESSION_AVAILABLE
);
186 String
[] result
= fService
.getSessionNames(new NullProgressMonitor());
188 assertNotNull(result
);
189 assertEquals(0, result
.length
);
191 } catch (ExecutionException e
) {
196 public void testGetSessionNames2() {
198 fShell
.setScenario(SCEN_GET_SESSION_NAMES1
);
199 String
[] result
= fService
.getSessionNames(new NullProgressMonitor());
201 assertNotNull(result
);
202 assertEquals(2, result
.length
);
203 assertEquals("mysession1", result
[0]);
204 assertEquals("mysession", result
[1]);
206 } 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
) {
222 public void testGetSessionNameGarbage() {
224 fShell
.setScenario(SCEN_GET_SESSION_GARBAGE_OUT
);
225 String
[] result
= fService
.getSessionNames(new NullProgressMonitor());
227 assertNotNull(result
);
228 assertEquals(0, result
.length
);
230 } catch (ExecutionException e
) {
235 public void testGetSession1() {
237 fShell
.setScenario(SCEN_GET_SESSION1
);
238 ISessionInfo session
= fService
.getSession("mysession", new NullProgressMonitor());
241 assertNotNull(session
);
242 assertEquals("mysession", session
.getName());
243 assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session
.getSessionPath());
244 assertEquals(TraceSessionState
.ACTIVE
, session
.getSessionState());
246 IDomainInfo
[] domains
= session
.getDomains();
247 assertNotNull(domains
);
248 assertEquals(2, domains
.length
);
250 // Verify Kernel domain
251 assertEquals("Kernel", domains
[0].getName());
252 IChannelInfo
[] channels
= domains
[0].getChannels();
253 assertNotNull(channels
);
254 assertEquals(2, channels
.length
);
256 // Verify Kernel's channel0
257 assertEquals("channel0", channels
[0].getName());
258 assertEquals(4, channels
[0].getNumberOfSubBuffers());
259 assertEquals("splice()", channels
[0].getOutputType());
260 assertEquals(false, channels
[0].isOverwriteMode());
261 assertEquals(200, channels
[0].getReadTimer());
262 assertEquals(TraceEnablement
.ENABLED
, channels
[0].getState());
263 assertEquals(262144, channels
[0].getSubBufferSize());
264 assertEquals(0, channels
[0].getSwitchTimer());
267 IEventInfo
[] channel0Events
= channels
[0].getEvents();
268 assertNotNull(channel0Events
);
269 assertEquals(2, channel0Events
.length
);
270 assertEquals("block_rq_remap", channel0Events
[0].getName());
271 assertEquals(TraceLogLevel
.TRACE_EMERG
, channel0Events
[0].getLogLevel());
272 assertEquals(TraceEventType
.TRACEPOINT
, channel0Events
[0].getEventType());
273 assertEquals(TraceEnablement
.ENABLED
, channel0Events
[0].getState());
275 assertEquals("block_bio_remap", channel0Events
[1].getName());
276 assertEquals(TraceLogLevel
.TRACE_EMERG
, channel0Events
[1].getLogLevel());
277 assertEquals(TraceEventType
.TRACEPOINT
, channel0Events
[1].getEventType());
278 assertEquals(TraceEnablement
.DISABLED
, channel0Events
[1].getState());
280 // Verify Kernel's channel1
281 assertEquals("channel1", channels
[1].getName());
282 assertEquals(4, channels
[1].getNumberOfSubBuffers());
283 assertEquals("splice()", channels
[1].getOutputType());
284 assertEquals(true, channels
[1].isOverwriteMode());
285 assertEquals(400, channels
[1].getReadTimer());
286 assertEquals(TraceEnablement
.DISABLED
, channels
[1].getState());
287 assertEquals(524288, channels
[1].getSubBufferSize());
288 assertEquals(100, channels
[1].getSwitchTimer());
291 IEventInfo
[] channel1Events
= channels
[1].getEvents();
292 assertEquals(0, channel1Events
.length
);
294 // Verify domain UST global
295 assertEquals("UST global", domains
[1].getName());
297 IChannelInfo
[] ustChannels
= domains
[1].getChannels();
299 // Verify UST global's mychannel1
300 assertEquals("mychannel1", ustChannels
[0].getName());
301 assertEquals(8, ustChannels
[0].getNumberOfSubBuffers());
302 assertEquals("mmap()", ustChannels
[0].getOutputType());
303 assertEquals(true, ustChannels
[0].isOverwriteMode());
304 assertEquals(100, ustChannels
[0].getReadTimer());
305 assertEquals(TraceEnablement
.DISABLED
, ustChannels
[0].getState());
306 assertEquals(8192, ustChannels
[0].getSubBufferSize());
307 assertEquals(200, ustChannels
[0].getSwitchTimer());
310 IEventInfo
[] ustEvents
= ustChannels
[0].getEvents();
311 assertEquals(0, ustEvents
.length
);
313 // Verify UST global's channel0
314 assertEquals("channel0", ustChannels
[1].getName());
315 assertEquals(4, ustChannels
[1].getNumberOfSubBuffers());
316 assertEquals("mmap()", ustChannels
[1].getOutputType());
317 assertEquals(false, ustChannels
[1].isOverwriteMode());
318 assertEquals(200, ustChannels
[1].getReadTimer());
319 assertEquals(TraceEnablement
.ENABLED
, ustChannels
[1].getState());
320 assertEquals(4096, ustChannels
[1].getSubBufferSize());
321 assertEquals(0, ustChannels
[1].getSwitchTimer());
324 ustEvents
= ustChannels
[1].getEvents();
325 assertEquals(2, ustEvents
.length
);
327 assertEquals("ust_tests_hello:tptest_sighandler", ustEvents
[0].getName());
328 assertEquals(TraceLogLevel
.TRACE_DEBUG_LINE
, ustEvents
[0].getLogLevel());
329 assertEquals(TraceEventType
.TRACEPOINT
, ustEvents
[0].getEventType());
330 assertEquals(TraceEnablement
.DISABLED
, ustEvents
[0].getState());
332 assertEquals("*", ustEvents
[1].getName());
333 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, ustEvents
[1].getLogLevel());
334 assertEquals(TraceEventType
.TRACEPOINT
, ustEvents
[1].getEventType());
335 assertEquals(TraceEnablement
.ENABLED
, ustEvents
[1].getState());
337 // next session (no detailed information available)
338 session
= fService
.getSession("mysession1", new NullProgressMonitor());
339 assertNotNull(session
);
340 assertEquals("mysession1", session
.getName());
341 assertEquals("/home/user/lttng-traces/mysession1-20120203-133225", session
.getSessionPath());
342 assertEquals(TraceSessionState
.INACTIVE
, session
.getSessionState());
344 domains
= session
.getDomains();
345 assertNotNull(domains
);
346 assertEquals(0, domains
.length
);
347 } catch (ExecutionException e
) {
352 public void testGetKernelProvider() {
354 fShell
.setScenario(SCEN_GET_KERNEL_PROVIDER1
);
355 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
358 assertNotNull(events
);
359 assertEquals(3, events
.size());
361 IBaseEventInfo baseEventInfo
= events
.get(0);
362 assertNotNull(baseEventInfo
);
363 assertEquals("sched_kthread_stop", baseEventInfo
.getName());
364 assertEquals(TraceLogLevel
.TRACE_EMERG
, baseEventInfo
.getLogLevel());
365 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
367 baseEventInfo
= events
.get(1);
368 assertEquals("sched_kthread_stop_ret", baseEventInfo
.getName());
369 assertEquals(TraceLogLevel
.TRACE_EMERG
, baseEventInfo
.getLogLevel());
370 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
372 baseEventInfo
= events
.get(2);
373 assertEquals("sched_wakeup_new", baseEventInfo
.getName());
374 assertEquals(TraceLogLevel
.TRACE_EMERG
, baseEventInfo
.getLogLevel());
375 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
377 } catch (ExecutionException e
) {
382 public void testGetKernelProviderNoKernel1() {
384 fShell
.setScenario(SCEN_LIST_WITH_NO_KERNEL1
);
385 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
388 assertNotNull(events
);
389 assertEquals(0, events
.size());
391 } catch (ExecutionException e
) {
396 public void testGetKernelProviderNoKernel2() {
398 fShell
.setScenario(SCEN_LIST_WITH_NO_KERNEL2
);
399 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
402 assertNotNull(events
);
403 assertEquals(0, events
.size());
405 } catch (ExecutionException e
) {
411 public void testGetUstProvider() {
413 fShell
.setScenario(SCEN_GET_UST_PROVIDER1
);
414 List
<IUstProviderInfo
> providers
= fService
.getUstProvider();
416 // Check all providers
417 assertNotNull(providers
);
418 assertEquals(2, providers
.size());
420 //Verify first provider
421 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(0).getName());
422 assertEquals(9379, providers
.get(0).getPid());
425 IBaseEventInfo
[] events
= providers
.get(0).getEvents();
426 assertNotNull(events
);
427 assertEquals(2, events
.length
);
429 IBaseEventInfo baseEventInfo
= events
[0];
430 assertNotNull(baseEventInfo
);
431 assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo
.getName());
432 assertEquals(TraceLogLevel
.TRACE_DEBUG_MODULE
, baseEventInfo
.getLogLevel());
433 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
435 baseEventInfo
= events
[1];
436 assertEquals("ust_tests_hello:tptest", baseEventInfo
.getName());
437 assertEquals(TraceLogLevel
.TRACE_INFO
, baseEventInfo
.getLogLevel());
438 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
440 //Verify second provider
441 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(1).getName());
442 assertEquals(4852, providers
.get(1).getPid());
445 events
= providers
.get(1).getEvents();
446 assertNotNull(events
);
447 assertEquals(2, events
.length
);
449 baseEventInfo
= events
[0];
450 assertNotNull(baseEventInfo
);
451 assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo
.getName());
452 assertEquals(TraceLogLevel
.TRACE_WARNING
, baseEventInfo
.getLogLevel());
453 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
455 baseEventInfo
= events
[1];
456 assertEquals("ust_tests_hello:tptest", baseEventInfo
.getName());
457 assertEquals(TraceLogLevel
.TRACE_DEBUG_FUNCTION
, baseEventInfo
.getLogLevel());
458 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
460 } catch (ExecutionException e
) {
465 public void testUstProvider2() {
467 fShell
.setScenario(SCEN_GET_UST_PROVIDER2
);
468 List
<IUstProviderInfo
> providers
= fService
.getUstProvider();
470 assertNotNull(providers
);
471 assertEquals(0, providers
.size());
473 } catch (ExecutionException e
) {
478 public void testGetUstProvider3() {
480 fShell
.setScenario(SCEN_GET_UST_PROVIDER3
);
482 ((LTTngControlService
)fService
).setVersion("2.1.0");
483 List
<IUstProviderInfo
> providers
= fService
.getUstProvider();
485 // Check all providers
486 assertNotNull(providers
);
487 assertEquals(2, providers
.size());
489 //Verify first provider
490 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(0).getName());
491 assertEquals(9379, providers
.get(0).getPid());
494 IBaseEventInfo
[] events
= providers
.get(0).getEvents();
495 assertNotNull(events
);
496 assertEquals(2, events
.length
);
498 IBaseEventInfo baseEventInfo
= events
[0];
499 assertNotNull(baseEventInfo
);
500 IFieldInfo
[] fields
= baseEventInfo
.getFields();
501 assertNotNull(fields
);
502 assertEquals(0, fields
.length
);
504 baseEventInfo
= events
[1];
505 fields
= baseEventInfo
.getFields();
506 assertNotNull(fields
);
507 assertEquals(3, fields
.length
);
508 assertEquals("doublefield", fields
[0].getName());
509 assertEquals("float", fields
[0].getFieldType());
511 assertEquals("floatfield", fields
[1].getName());
512 assertEquals("float", fields
[1].getFieldType());
514 assertEquals("stringfield", fields
[2].getName());
515 assertEquals("string", fields
[2].getFieldType());
517 //Verify second provider
518 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(1).getName());
519 assertEquals(4852, providers
.get(1).getPid());
522 events
= providers
.get(1).getEvents();
523 assertNotNull(events
);
524 assertEquals(2, events
.length
);
526 baseEventInfo
= events
[0];
527 assertNotNull(baseEventInfo
);
528 fields
= baseEventInfo
.getFields();
529 assertNotNull(fields
);
530 assertEquals(0, fields
.length
);
532 baseEventInfo
= events
[1];
533 fields
= baseEventInfo
.getFields();
534 assertNotNull(fields
);
535 assertEquals(3, fields
.length
);
537 assertEquals("doublefield", fields
[0].getName());
538 assertEquals("float", fields
[0].getFieldType());
540 assertEquals("floatfield", fields
[1].getName());
541 assertEquals("float", fields
[1].getFieldType());
543 assertEquals("stringfield", fields
[2].getName());
544 assertEquals("string", fields
[2].getFieldType());
547 ((LTTngControlService
)fService
).setVersion("2.0.0");
549 } catch (ExecutionException e
) {
554 public void testCreateSession() {
556 fShell
.setScenario(SCEN_CREATE_SESSION1
);
558 ISessionInfo info
= fService
.createSession("mysession2", null, new NullProgressMonitor());
560 assertEquals("mysession2", info
.getName());
561 assertNotNull(info
.getSessionPath());
562 assertTrue(info
.getSessionPath().contains("mysession2"));
563 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
564 } catch (ExecutionException e
) {
569 public void testCreateSessionWithPrompt() {
571 // First line has the shell prompt before the command output
572 // This can happen in a real application if the command line is not echoed by the shell.
573 fShell
.setScenario(SCEN_CREATE_SESSION_WITH_PROMPT
);
575 // First line has no shell prompt before the output
576 ISessionInfo info
= fService
.createSession("mysession2", null, new NullProgressMonitor());
578 assertEquals("mysession2", info
.getName());
579 assertNotNull(info
.getSessionPath());
580 assertTrue(info
.getSessionPath().contains("mysession2"));
581 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
582 } catch (ExecutionException e
) {
588 public void testCreateSessionVariants() {
590 fShell
.setScenario(SCEN_CREATE_SESSION_VARIANTS
);
593 fService
.createSession("alreadyExist", null, new NullProgressMonitor());
594 fail("No exeption thrown");
595 } catch (ExecutionException e
) {
600 fService
.createSession("wrongName", null, new NullProgressMonitor());
601 fail("No exeption thrown");
602 } catch (ExecutionException e
) {
607 fService
.createSession("withPath", "/home/user/hallo", new NullProgressMonitor());
608 fail("No exeption thrown");
609 } catch (ExecutionException e
) {
614 ISessionInfo info
= fService
.createSession("session with spaces", null, new NullProgressMonitor());
616 assertEquals("session with spaces", info
.getName());
617 assertNotNull(info
.getSessionPath());
618 assertTrue(info
.getSessionPath().contains("session with spaces"));
619 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
621 } catch (ExecutionException e
) {
626 ISessionInfo info
= fService
.createSession("pathWithSpaces", "/home/user/hallo user/here", new NullProgressMonitor());
628 assertEquals("pathWithSpaces", info
.getName());
629 assertNotNull(info
.getSessionPath());
630 assertTrue(info
.getSessionPath().contains("/home/user/hallo user/here"));
631 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
633 } catch (ExecutionException e
) {
638 public void testDestroySession() {
640 fShell
.setScenario(SCEN_DESTROY_SESSION1
);
641 fService
.destroySession("mysession2", new NullProgressMonitor());
642 } catch (ExecutionException e
) {
647 public void testCreateChannel() {
650 String sessionName
= "mysession2";
651 List
<String
> list
= new ArrayList
<String
>();
652 String kernelChannel0
= "mychannel0";
653 String kernelChannel1
= "mychannel1";
654 list
.add(kernelChannel0
);
655 list
.add(kernelChannel1
);
657 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
659 // Create/enable/configure 2 kernel channels
660 ChannelInfo chanInfo
= new ChannelInfo("");
661 chanInfo
.setOverwriteMode(true);
662 chanInfo
.setSubBufferSize(16384);
663 chanInfo
.setReadTimer(100);
664 chanInfo
.setSwitchTimer(200);
665 chanInfo
.setNumberOfSubBuffers(2);
666 fService
.enableChannels(sessionName
, list
, true, chanInfo
, new NullProgressMonitor());
668 // Create/enable/configure 1 UST channel
670 list
.add("ustChannel");
672 chanInfo
= new ChannelInfo("");
673 chanInfo
.setOverwriteMode(true);
674 chanInfo
.setSubBufferSize(32768);
675 chanInfo
.setReadTimer(200);
676 chanInfo
.setSwitchTimer(100);
677 chanInfo
.setNumberOfSubBuffers(1);
678 fService
.enableChannels(sessionName
, list
, false, chanInfo
, new NullProgressMonitor());
680 } catch (ExecutionException e
) {
685 public void testDisableChannel() {
688 String sessionName
= "mysession2";
689 List
<String
> list
= new ArrayList
<String
>();
690 String kernelChannel0
= "mychannel0";
691 String kernelChannel1
= "mychannel1";
692 list
.add(kernelChannel0
);
693 list
.add(kernelChannel1
);
695 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
696 fService
.disableChannels(sessionName
, list
, true, new NullProgressMonitor());
699 list
.add("ustChannel");
700 fService
.disableChannels(sessionName
, list
, false, new NullProgressMonitor());
702 } catch (ExecutionException e
) {
707 public void testEnableChannel() {
710 String sessionName
= "mysession2";
711 List
<String
> list
= new ArrayList
<String
>();
712 String kernelChannel0
= "mychannel0";
713 String kernelChannel1
= "mychannel1";
714 list
.add(kernelChannel0
);
715 list
.add(kernelChannel1
);
717 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
718 fService
.enableChannels(sessionName
, list
, true, null, new NullProgressMonitor());
720 // Create/enable/configure 1 UST channel
722 list
.add("ustChannel");
724 fService
.enableChannels(sessionName
, list
, false, null, new NullProgressMonitor());
726 } catch (ExecutionException e
) {
731 // public void tesEnableChannelNoTracer() {
733 // ILttngControlService service = new LTTngControlService(fShellFactory.getShellForChannelNoTracer());
734 // service.getSessionNames(new NullProgressMonitor());
735 // fail("No exeption thrown");
737 // } catch (ExecutionException e) {
742 public void testEnableEvents() {
744 // 1) session name, channel = null, 3 event names, kernel
745 String sessionName
= "mysession2";
746 List
<String
> list
= new ArrayList
<String
>();
747 String eventName0
= "block_rq_remap";
748 String eventName1
= "block_bio_remap";
749 String eventName2
= "softirq_entry";
750 list
.add(eventName0
);
751 list
.add(eventName1
);
752 list
.add(eventName2
);
753 fShell
.setScenario(SCEN_EVENT_HANDLING
);
754 fService
.enableEvents(sessionName
, null, list
, true, null, new NullProgressMonitor());
756 // 2) session name, channel=mychannel, event name= null, kernel
757 String channelName
= "mychannel";
758 fService
.enableEvents(sessionName
, channelName
, null, true, null, new NullProgressMonitor());
760 // 3) session name, channel=mychannel, 1 event name, ust, no filter
761 String ustEventName
= "ust_tests_hello:tptest_sighandler";
763 list
.add(ustEventName
);
764 fService
.enableEvents(sessionName
, channelName
, list
, false, null, new NullProgressMonitor());
766 // 4) session name, channel = mychannel, no event name, ust, with filter
767 fService
.enableEvents(sessionName
, channelName
, list
, false, "intfield==10", new NullProgressMonitor());
769 // 5) session name, channel = mychannel, no event name, ust, no filter
771 fService
.enableEvents(sessionName
, channelName
, list
, false, null, new NullProgressMonitor());
773 // TODO add test with filters
775 } catch (ExecutionException e
) {
780 public void testEnableSyscalls() {
782 // 1) session name, channel = null, 3 event names, kernel
783 String sessionName
= "mysession2";
784 String channelName
= "mychannel";
786 fShell
.setScenario(SCEN_EVENT_HANDLING
);
788 // 1) session name, channel = null
789 fService
.enableSyscalls(sessionName
, null, new NullProgressMonitor());
791 // 2) session name, channel = mychannel
792 fService
.enableSyscalls(sessionName
, channelName
, new NullProgressMonitor());
794 } catch (ExecutionException e
) {
799 public void testDynamicProbe() {
801 // 1) session name, channel = null, 3 event names, kernel
802 String sessionName
= "mysession2";
803 String channelName
= "mychannel";
804 String eventName0
= "myevent0";
805 String eventName1
= "myevent1";
806 String functionProbe
= "0xc0101340";
807 String dynProbe
= "init_post";
809 fShell
.setScenario(SCEN_EVENT_HANDLING
);
811 // 1) session name, channel = null, event name, function probe, probe
812 fService
.enableProbe(sessionName
, null, eventName0
, true, functionProbe
, new NullProgressMonitor());
814 // 2) session name, channel = mychannel
815 fService
.enableProbe(sessionName
, channelName
, eventName1
, false, dynProbe
, new NullProgressMonitor());
817 } catch (ExecutionException e
) {
822 public void testEnableLogLevel() {
824 // 1) session name, channel = null, 3 event names, kernel
825 String sessionName
= "mysession2";
826 String channelName
= "mychannel";
827 String eventName4
= "myevent4";
828 String eventName5
= "myevent5";
830 fShell
.setScenario(SCEN_EVENT_HANDLING
);
832 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
833 fService
.enableLogLevel(sessionName
, null, eventName4
, LogLevelType
.LOGLEVEL_ONLY
, TraceLogLevel
.TRACE_DEBUG
, null, new NullProgressMonitor());
835 // 2) session name, channel = mychannel, null, loglevel, TRACE_DEBUG_FUNCTION
836 fService
.enableLogLevel(sessionName
, channelName
, eventName5
, LogLevelType
.LOGLEVEL
, TraceLogLevel
.TRACE_DEBUG_FUNCTION
, null, new NullProgressMonitor());
838 // TODO add test with filters
840 } catch (ExecutionException e
) {
845 public void testAddContext() {
847 // 1) session name, channel = null, 3 event names, kernel
848 String sessionName
= "mysession2";
849 String channelName
= "mychannel";
850 String eventName
= "ust_tests_hello:tptest_sighandler";
851 List
<String
> contexts
= new ArrayList
<String
>();
852 contexts
.add("prio");
855 fShell
.setScenario(SCEN_CONTEXT_HANDLING
);
857 List
<String
> availContexts
= fService
.getContextList(new NullProgressMonitor());
858 assertNotNull(availContexts
);
859 assertEquals(12, availContexts
.size());
861 // A very "hard-coded" way to verify but it works ...
862 Set
<String
> expectedContexts
= new HashSet
<String
>();
863 expectedContexts
.add("pid");
864 expectedContexts
.add("procname");
865 expectedContexts
.add("prio");
866 expectedContexts
.add("nice");
867 expectedContexts
.add("vpid");
868 expectedContexts
.add("tid");
869 expectedContexts
.add("pthread_id");
870 expectedContexts
.add("vtid");
871 expectedContexts
.add("ppid");
872 expectedContexts
.add("vppid");
873 expectedContexts
.add("perf:cpu-cycles");
874 expectedContexts
.add("perf:cycles");
876 assertTrue(expectedContexts
.containsAll(availContexts
));
878 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
879 fService
.addContexts(sessionName
, channelName
, eventName
, false, contexts
, new NullProgressMonitor());
881 } catch (ExecutionException e
) {
886 public void testAddContextFailure() {
888 // 1) session name, channel = null, 3 event names, kernel
889 String sessionName
= "mysession2";
890 String channelName
= "mychannel";
891 String eventName
= "ust_tests_hello:tptest_sighandler";
892 List
<String
> contexts
= new ArrayList
<String
>();
893 contexts
.add("prio");
895 fShell
.setScenario(SCEN_CONTEXT_ERROR_HANDLING
);
897 fService
.getContextList(new NullProgressMonitor());
898 fail("No exeption generated");
899 } catch (ExecutionException e
) {
903 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
904 fService
.addContexts(sessionName
, channelName
, eventName
, false, contexts
, new NullProgressMonitor());
905 fail("No exeption generated");
906 } catch (ExecutionException e
) {
911 public void testCalibrate() {
913 fShell
.setScenario(SCEN_CALIBRATE_HANDLING
);
914 fService
.calibrate(true, new NullProgressMonitor());
916 } catch (ExecutionException e
) {
921 public void testCalibrateFailure() {
924 fShell
.setScenario(SCEN_CALIBRATE_HANDLING
);
925 fService
.calibrate(false, new NullProgressMonitor());
926 fail("No exeption generated");
927 } catch (ExecutionException e
) {