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
.ISessionInfo
;
32 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IUstProviderInfo
;
33 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.LogLevelType
;
34 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceEnablement
;
35 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceEventType
;
36 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceLogLevel
;
37 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceSessionState
;
38 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.impl
.ChannelInfo
;
39 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.service
.CommandShellFactory
;
40 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.shells
.LTTngToolsFileShell
;
41 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.service
.ILttngControlService
;
42 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.service
.LTTngControlService
;
43 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.service
.LTTngControlServiceFactory
;
44 import org
.osgi
.framework
.FrameworkUtil
;
46 * The class <code>LTTngControlServiceTest</code> contains test for the class <code>{@link LTTngControlService}</code>.
48 @SuppressWarnings({"nls", "javadoc"})
49 public class LTTngControlServiceTest
extends TestCase
{
51 private static final String DIRECTORY
= "testfiles";
52 private static final String TEST_STREAM
= "LTTngServiceTest.cfg";
54 private static final String SCEN_LTTNG_NOT_INSTALLED
= "LttngNotInstalled";
55 private static final String SCEN_LTTNG_VERSION
= "LttngVersion";
56 private static final String SCEN_LTTNG_VERSION_WITH_PROMPT
= "LttngVersionWithPrompt";
57 private static final String SCEN_LTTNG_UNSUPPORTED_VERSION
= "LttngUnsupportedVersion";
58 private static final String SCEN_LTTNG_NO_VERSION
= "LttngNoVersion";
59 private static final String SCEN_NO_SESSION_AVAILABLE
= "NoSessionAvailable";
60 private static final String SCEN_GET_SESSION_NAMES1
= "GetSessionNames1";
61 private static final String SCEN_GET_SESSION_NAME_NOT_EXIST
= "GetSessionNameNotExist";
62 private static final String SCEN_GET_SESSION_GARBAGE_OUT
= "GetSessionGarbageOut";
63 private static final String SCEN_GET_SESSION1
= "GetSession1";
64 private static final String SCEN_GET_KERNEL_PROVIDER1
= "GetKernelProvider1";
65 private static final String SCEN_LIST_WITH_NO_KERNEL1
= "ListWithNoKernel1";
66 private static final String SCEN_LIST_WITH_NO_KERNEL2
= "ListWithNoKernel2";
67 private static final String SCEN_GET_UST_PROVIDER1
= "GetUstProvider1";
68 private static final String SCEN_GET_UST_PROVIDER2
= "GetUstProvider2";
69 private static final String SCEN_CREATE_SESSION1
= "CreateSession1";
70 private static final String SCEN_CREATE_SESSION_WITH_PROMPT
= "CreateSessionWithPrompt";
71 private static final String SCEN_CREATE_SESSION_VARIANTS
= "CreateSessionVariants";
72 private static final String SCEN_DESTROY_SESSION1
= "DestroySession1";
73 private static final String SCEN_CHANNEL_HANDLING
= "ChannelHandling";
74 private static final String SCEN_EVENT_HANDLING
= "EventHandling";
75 private static final String SCEN_CONTEXT_HANDLING
= "ContextHandling";
76 private static final String SCEN_CONTEXT_ERROR_HANDLING
= "ContextErrorHandling";
77 private static final String SCEN_CALIBRATE_HANDLING
= "CalibrateHandling";
79 // ------------------------------------------------------------------------
81 // ------------------------------------------------------------------------
82 private CommandShellFactory fShellFactory
;
83 private String fTestfile
;
84 private LTTngToolsFileShell fShell
;
85 private ILttngControlService fService
;
88 // ------------------------------------------------------------------------
90 // ------------------------------------------------------------------------
92 // ------------------------------------------------------------------------
94 // ------------------------------------------------------------------------
96 * Perform pre-test initialization.
98 * @throws Exception if the initialization fails for some reason
102 public void setUp() throws Exception
{
104 fShellFactory
= CommandShellFactory
.getInstance();
106 URL location
= FileLocator
.find(FrameworkUtil
.getBundle(this.getClass()), new Path(DIRECTORY
+ File
.separator
+ TEST_STREAM
), null);
107 File testfile
= new File(FileLocator
.toFileURL(location
).toURI());
108 fTestfile
= testfile
.getAbsolutePath();
110 fShell
= fShellFactory
.getFileShell();
111 fShell
.loadScenarioFile(fTestfile
);
112 fService
= new LTTngControlService(fShell
);
116 * Perform post-test clean-up.
118 * @throws Exception if the clean-up fails for some reason
122 public void tearDown() throws Exception
{
125 // ------------------------------------------------------------------------
127 // ------------------------------------------------------------------------
129 public void testVersion() {
131 fShell
.setScenario(SCEN_LTTNG_VERSION
);
132 ILttngControlService service
= LTTngControlServiceFactory
.getInstance().getLttngControlService(fShell
);
133 assertNotNull(service
);
134 assertEquals("2.0.0", service
.getVersion());
135 } catch (ExecutionException e
) {
136 fail("Exeption thrown " + e
);
140 public void testVersionWithPrompt() {
142 fShell
.setScenario(SCEN_LTTNG_VERSION_WITH_PROMPT
);
143 ILttngControlService service
= LTTngControlServiceFactory
.getInstance().getLttngControlService(fShell
);
144 assertNotNull(service
);
145 assertEquals("2.0.0", service
.getVersion());
146 } catch (ExecutionException e
) {
147 fail("Exeption thrown " + e
);
151 public void testUnsupportedVersion() {
153 fShell
.setScenario(SCEN_LTTNG_UNSUPPORTED_VERSION
);
154 LTTngControlServiceFactory
.getInstance().getLttngControlService(fShell
);
155 fail("No exeption thrown");
156 } catch (ExecutionException e
) {
161 public void testNoVersion() {
163 fShell
.setScenario(SCEN_LTTNG_NO_VERSION
);
164 LTTngControlServiceFactory
.getInstance().getLttngControlService(fShell
);
165 fail("No exeption thrown");
166 } catch (ExecutionException e
) {
171 public void testLttngNotInstalled() {
173 fShell
.setScenario(SCEN_LTTNG_NOT_INSTALLED
);
174 fService
.getSessionNames(new NullProgressMonitor());
175 fail("No exeption thrown");
176 } 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
) {
194 public void testGetSessionNames2() {
196 fShell
.setScenario(SCEN_GET_SESSION_NAMES1
);
197 String
[] result
= fService
.getSessionNames(new NullProgressMonitor());
199 assertNotNull(result
);
200 assertEquals(2, result
.length
);
201 assertEquals("mysession1", result
[0]);
202 assertEquals("mysession", result
[1]);
204 } catch (ExecutionException e
) {
209 public void testGetSessionNotExist() {
211 fShell
.setScenario(SCEN_GET_SESSION_NAME_NOT_EXIST
);
212 fService
.getSessionNames(new NullProgressMonitor());
213 fail("No exeption thrown");
215 } catch (ExecutionException e
) {
220 public void testGetSessionNameGarbage() {
222 fShell
.setScenario(SCEN_GET_SESSION_GARBAGE_OUT
);
223 String
[] result
= fService
.getSessionNames(new NullProgressMonitor());
225 assertNotNull(result
);
226 assertEquals(0, result
.length
);
228 } catch (ExecutionException e
) {
233 public void testGetSession1() {
235 fShell
.setScenario(SCEN_GET_SESSION1
);
236 ISessionInfo session
= fService
.getSession("mysession", new NullProgressMonitor());
239 assertNotNull(session
);
240 assertEquals("mysession", session
.getName());
241 assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session
.getSessionPath());
242 assertEquals(TraceSessionState
.ACTIVE
, session
.getSessionState());
244 IDomainInfo
[] domains
= session
.getDomains();
245 assertNotNull(domains
);
246 assertEquals(2, domains
.length
);
248 // Verify Kernel domain
249 assertEquals("Kernel", domains
[0].getName());
250 IChannelInfo
[] channels
= domains
[0].getChannels();
251 assertNotNull(channels
);
252 assertEquals(2, channels
.length
);
254 // Verify Kernel's channel0
255 assertEquals("channel0", channels
[0].getName());
256 assertEquals(4, channels
[0].getNumberOfSubBuffers());
257 assertEquals("splice()", channels
[0].getOutputType());
258 assertEquals(false, channels
[0].isOverwriteMode());
259 assertEquals(200, channels
[0].getReadTimer());
260 assertEquals(TraceEnablement
.ENABLED
, channels
[0].getState());
261 assertEquals(262144, channels
[0].getSubBufferSize());
262 assertEquals(0, channels
[0].getSwitchTimer());
265 IEventInfo
[] channel0Events
= channels
[0].getEvents();
266 assertNotNull(channel0Events
);
267 assertEquals(2, channel0Events
.length
);
268 assertEquals("block_rq_remap", channel0Events
[0].getName());
269 assertEquals(TraceLogLevel
.TRACE_EMERG
, channel0Events
[0].getLogLevel());
270 assertEquals(TraceEventType
.TRACEPOINT
, channel0Events
[0].getEventType());
271 assertEquals(TraceEnablement
.ENABLED
, channel0Events
[0].getState());
273 assertEquals("block_bio_remap", channel0Events
[1].getName());
274 assertEquals(TraceLogLevel
.TRACE_EMERG
, channel0Events
[1].getLogLevel());
275 assertEquals(TraceEventType
.TRACEPOINT
, channel0Events
[1].getEventType());
276 assertEquals(TraceEnablement
.DISABLED
, channel0Events
[1].getState());
278 // Verify Kernel's channel1
279 assertEquals("channel1", channels
[1].getName());
280 assertEquals(4, channels
[1].getNumberOfSubBuffers());
281 assertEquals("splice()", channels
[1].getOutputType());
282 assertEquals(true, channels
[1].isOverwriteMode());
283 assertEquals(400, channels
[1].getReadTimer());
284 assertEquals(TraceEnablement
.DISABLED
, channels
[1].getState());
285 assertEquals(524288, channels
[1].getSubBufferSize());
286 assertEquals(100, channels
[1].getSwitchTimer());
289 IEventInfo
[] channel1Events
= channels
[1].getEvents();
290 assertEquals(0, channel1Events
.length
);
292 // Verify domain UST global
293 assertEquals("UST global", domains
[1].getName());
295 IChannelInfo
[] ustChannels
= domains
[1].getChannels();
297 // Verify UST global's mychannel1
298 assertEquals("mychannel1", ustChannels
[0].getName());
299 assertEquals(8, ustChannels
[0].getNumberOfSubBuffers());
300 assertEquals("mmap()", ustChannels
[0].getOutputType());
301 assertEquals(true, ustChannels
[0].isOverwriteMode());
302 assertEquals(100, ustChannels
[0].getReadTimer());
303 assertEquals(TraceEnablement
.DISABLED
, ustChannels
[0].getState());
304 assertEquals(8192, ustChannels
[0].getSubBufferSize());
305 assertEquals(200, ustChannels
[0].getSwitchTimer());
308 IEventInfo
[] ustEvents
= ustChannels
[0].getEvents();
309 assertEquals(0, ustEvents
.length
);
311 // Verify UST global's channel0
312 assertEquals("channel0", ustChannels
[1].getName());
313 assertEquals(4, ustChannels
[1].getNumberOfSubBuffers());
314 assertEquals("mmap()", ustChannels
[1].getOutputType());
315 assertEquals(false, ustChannels
[1].isOverwriteMode());
316 assertEquals(200, ustChannels
[1].getReadTimer());
317 assertEquals(TraceEnablement
.ENABLED
, ustChannels
[1].getState());
318 assertEquals(4096, ustChannels
[1].getSubBufferSize());
319 assertEquals(0, ustChannels
[1].getSwitchTimer());
322 ustEvents
= ustChannels
[1].getEvents();
323 assertEquals(2, ustEvents
.length
);
325 assertEquals("ust_tests_hello:tptest_sighandler", ustEvents
[0].getName());
326 assertEquals(TraceLogLevel
.TRACE_DEBUG_LINE
, ustEvents
[0].getLogLevel());
327 assertEquals(TraceEventType
.TRACEPOINT
, ustEvents
[0].getEventType());
328 assertEquals(TraceEnablement
.DISABLED
, ustEvents
[0].getState());
330 assertEquals("*", ustEvents
[1].getName());
331 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, ustEvents
[1].getLogLevel());
332 assertEquals(TraceEventType
.TRACEPOINT
, ustEvents
[1].getEventType());
333 assertEquals(TraceEnablement
.ENABLED
, ustEvents
[1].getState());
335 // next session (no detailed information available)
336 session
= fService
.getSession("mysession1", new NullProgressMonitor());
337 assertNotNull(session
);
338 assertEquals("mysession1", session
.getName());
339 assertEquals("/home/user/lttng-traces/mysession1-20120203-133225", session
.getSessionPath());
340 assertEquals(TraceSessionState
.INACTIVE
, session
.getSessionState());
342 domains
= session
.getDomains();
343 assertNotNull(domains
);
344 assertEquals(0, domains
.length
);
345 } catch (ExecutionException e
) {
350 public void testGetKernelProvider() {
352 fShell
.setScenario(SCEN_GET_KERNEL_PROVIDER1
);
353 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
356 assertNotNull(events
);
357 assertEquals(3, events
.size());
359 IBaseEventInfo baseEventInfo
= events
.get(0);
360 assertNotNull(baseEventInfo
);
361 assertEquals("sched_kthread_stop", baseEventInfo
.getName());
362 assertEquals(TraceLogLevel
.TRACE_EMERG
, baseEventInfo
.getLogLevel());
363 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
365 baseEventInfo
= events
.get(1);
366 assertEquals("sched_kthread_stop_ret", baseEventInfo
.getName());
367 assertEquals(TraceLogLevel
.TRACE_EMERG
, baseEventInfo
.getLogLevel());
368 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
370 baseEventInfo
= events
.get(2);
371 assertEquals("sched_wakeup_new", baseEventInfo
.getName());
372 assertEquals(TraceLogLevel
.TRACE_EMERG
, baseEventInfo
.getLogLevel());
373 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
375 } catch (ExecutionException e
) {
380 public void testGetKernelProviderNoKernel1() {
382 fShell
.setScenario(SCEN_LIST_WITH_NO_KERNEL1
);
383 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
386 assertNotNull(events
);
387 assertEquals(0, events
.size());
389 } catch (ExecutionException e
) {
394 public void testGetKernelProviderNoKernel2() {
396 fShell
.setScenario(SCEN_LIST_WITH_NO_KERNEL2
);
397 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
400 assertNotNull(events
);
401 assertEquals(0, events
.size());
403 } catch (ExecutionException e
) {
409 public void testGetUstProvider() {
411 fShell
.setScenario(SCEN_GET_UST_PROVIDER1
);
412 List
<IUstProviderInfo
> providers
= fService
.getUstProvider();
414 // Check all providers
415 assertNotNull(providers
);
416 assertEquals(2, providers
.size());
418 //Verify first provider
419 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(0).getName());
420 assertEquals(9379, providers
.get(0).getPid());
423 IBaseEventInfo
[] events
= providers
.get(0).getEvents();
424 assertNotNull(events
);
425 assertEquals(2, events
.length
);
427 IBaseEventInfo baseEventInfo
= events
[0];
428 assertNotNull(baseEventInfo
);
429 assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo
.getName());
430 assertEquals(TraceLogLevel
.TRACE_DEBUG_MODULE
, baseEventInfo
.getLogLevel());
431 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
433 baseEventInfo
= events
[1];
434 assertEquals("ust_tests_hello:tptest", baseEventInfo
.getName());
435 assertEquals(TraceLogLevel
.TRACE_INFO
, baseEventInfo
.getLogLevel());
436 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
438 //Verify second provider
439 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(1).getName());
440 assertEquals(4852, providers
.get(1).getPid());
443 events
= providers
.get(1).getEvents();
444 assertNotNull(events
);
445 assertEquals(2, events
.length
);
447 baseEventInfo
= events
[0];
448 assertNotNull(baseEventInfo
);
449 assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo
.getName());
450 assertEquals(TraceLogLevel
.TRACE_WARNING
, baseEventInfo
.getLogLevel());
451 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
453 baseEventInfo
= events
[1];
454 assertEquals("ust_tests_hello:tptest", baseEventInfo
.getName());
455 assertEquals(TraceLogLevel
.TRACE_DEBUG_FUNCTION
, baseEventInfo
.getLogLevel());
456 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
458 } catch (ExecutionException e
) {
463 public void testUstProvider2() {
465 fShell
.setScenario(SCEN_GET_UST_PROVIDER2
);
466 List
<IUstProviderInfo
> providers
= fService
.getUstProvider();
468 assertNotNull(providers
);
469 assertEquals(0, providers
.size());
471 } catch (ExecutionException e
) {
476 public void testCreateSession() {
478 fShell
.setScenario(SCEN_CREATE_SESSION1
);
480 ISessionInfo info
= fService
.createSession("mysession2", null, new NullProgressMonitor());
482 assertEquals("mysession2", info
.getName());
483 assertNotNull(info
.getSessionPath());
484 assertTrue(info
.getSessionPath().contains("mysession2"));
485 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
486 } catch (ExecutionException e
) {
491 public void testCreateSessionWithPrompt() {
493 // First line has the shell prompt before the command output
494 // This can happen in a real application if the command line is not echoed by the shell.
495 fShell
.setScenario(SCEN_CREATE_SESSION_WITH_PROMPT
);
497 // First line has no shell prompt before the output
498 ISessionInfo info
= fService
.createSession("mysession2", null, new NullProgressMonitor());
500 assertEquals("mysession2", info
.getName());
501 assertNotNull(info
.getSessionPath());
502 assertTrue(info
.getSessionPath().contains("mysession2"));
503 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
504 } catch (ExecutionException e
) {
510 public void testCreateSessionVariants() {
512 fShell
.setScenario(SCEN_CREATE_SESSION_VARIANTS
);
515 fService
.createSession("alreadyExist", null, new NullProgressMonitor());
516 fail("No exeption thrown");
517 } catch (ExecutionException e
) {
522 fService
.createSession("wrongName", null, new NullProgressMonitor());
523 fail("No exeption thrown");
524 } catch (ExecutionException e
) {
529 fService
.createSession("withPath", "/home/user/hallo", new NullProgressMonitor());
530 fail("No exeption thrown");
531 } catch (ExecutionException e
) {
536 ISessionInfo info
= fService
.createSession("session with spaces", null, new NullProgressMonitor());
538 assertEquals("session with spaces", info
.getName());
539 assertNotNull(info
.getSessionPath());
540 assertTrue(info
.getSessionPath().contains("session with spaces"));
541 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
543 } catch (ExecutionException e
) {
548 ISessionInfo info
= fService
.createSession("pathWithSpaces", "/home/user/hallo user/here", new NullProgressMonitor());
550 assertEquals("pathWithSpaces", info
.getName());
551 assertNotNull(info
.getSessionPath());
552 assertTrue(info
.getSessionPath().contains("/home/user/hallo user/here"));
553 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
555 } catch (ExecutionException e
) {
560 public void testDestroySession() {
562 fShell
.setScenario(SCEN_DESTROY_SESSION1
);
563 fService
.destroySession("mysession2", new NullProgressMonitor());
564 } catch (ExecutionException e
) {
569 public void testCreateChannel() {
572 String sessionName
= "mysession2";
573 List
<String
> list
= new ArrayList
<String
>();
574 String kernelChannel0
= "mychannel0";
575 String kernelChannel1
= "mychannel1";
576 list
.add(kernelChannel0
);
577 list
.add(kernelChannel1
);
579 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
581 // Create/enable/configure 2 kernel channels
582 ChannelInfo chanInfo
= new ChannelInfo("");
583 chanInfo
.setOverwriteMode(true);
584 chanInfo
.setSubBufferSize(16384);
585 chanInfo
.setReadTimer(100);
586 chanInfo
.setSwitchTimer(200);
587 chanInfo
.setNumberOfSubBuffers(2);
588 fService
.enableChannels(sessionName
, list
, true, chanInfo
, new NullProgressMonitor());
590 // Create/enable/configure 1 UST channel
592 list
.add("ustChannel");
594 chanInfo
= new ChannelInfo("");
595 chanInfo
.setOverwriteMode(true);
596 chanInfo
.setSubBufferSize(32768);
597 chanInfo
.setReadTimer(200);
598 chanInfo
.setSwitchTimer(100);
599 chanInfo
.setNumberOfSubBuffers(1);
600 fService
.enableChannels(sessionName
, list
, false, chanInfo
, new NullProgressMonitor());
602 } catch (ExecutionException e
) {
607 public void testDisableChannel() {
610 String sessionName
= "mysession2";
611 List
<String
> list
= new ArrayList
<String
>();
612 String kernelChannel0
= "mychannel0";
613 String kernelChannel1
= "mychannel1";
614 list
.add(kernelChannel0
);
615 list
.add(kernelChannel1
);
617 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
618 fService
.disableChannels(sessionName
, list
, true, new NullProgressMonitor());
621 list
.add("ustChannel");
622 fService
.disableChannels(sessionName
, list
, false, new NullProgressMonitor());
624 } catch (ExecutionException e
) {
629 public void testEnableChannel() {
632 String sessionName
= "mysession2";
633 List
<String
> list
= new ArrayList
<String
>();
634 String kernelChannel0
= "mychannel0";
635 String kernelChannel1
= "mychannel1";
636 list
.add(kernelChannel0
);
637 list
.add(kernelChannel1
);
639 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
640 fService
.enableChannels(sessionName
, list
, true, null, new NullProgressMonitor());
642 // Create/enable/configure 1 UST channel
644 list
.add("ustChannel");
646 fService
.enableChannels(sessionName
, list
, false, null, new NullProgressMonitor());
648 } catch (ExecutionException e
) {
653 // public void tesEnableChannelNoTracer() {
655 // ILttngControlService service = new LTTngControlService(fShellFactory.getShellForChannelNoTracer());
656 // service.getSessionNames(new NullProgressMonitor());
657 // fail("No exeption thrown");
659 // } catch (ExecutionException e) {
664 public void testEnableEvents() {
666 // 1) session name, channel = null, 3 event names, kernel
667 String sessionName
= "mysession2";
668 List
<String
> list
= new ArrayList
<String
>();
669 String eventName0
= "block_rq_remap";
670 String eventName1
= "block_bio_remap";
671 String eventName2
= "softirq_entry";
672 list
.add(eventName0
);
673 list
.add(eventName1
);
674 list
.add(eventName2
);
675 fShell
.setScenario(SCEN_EVENT_HANDLING
);
676 fService
.enableEvents(sessionName
, null, list
, true, new NullProgressMonitor());
678 // 2) session name, channel=mychannel, event name= null, kernel
679 String channelName
= "mychannel";
680 fService
.enableEvents(sessionName
, channelName
, null, true, new NullProgressMonitor());
682 // 3) session name, channel=mychannel, 1 event name, ust
683 String ustEventName
= "ust_tests_hello:tptest_sighandler";
685 list
.add(ustEventName
);
686 fService
.enableEvents(sessionName
, channelName
, list
, false, new NullProgressMonitor());
688 // 4) session name, channel = mychannel, no event name, ust
690 fService
.enableEvents(sessionName
, channelName
, list
, false, new NullProgressMonitor());
692 } catch (ExecutionException e
) {
697 public void testEnableSyscalls() {
699 // 1) session name, channel = null, 3 event names, kernel
700 String sessionName
= "mysession2";
701 String channelName
= "mychannel";
703 fShell
.setScenario(SCEN_EVENT_HANDLING
);
705 // 1) session name, channel = null
706 fService
.enableSyscalls(sessionName
, null, new NullProgressMonitor());
708 // 2) session name, channel = mychannel
709 fService
.enableSyscalls(sessionName
, channelName
, new NullProgressMonitor());
711 } catch (ExecutionException e
) {
716 public void testDynamicProbe() {
718 // 1) session name, channel = null, 3 event names, kernel
719 String sessionName
= "mysession2";
720 String channelName
= "mychannel";
721 String eventName0
= "myevent0";
722 String eventName1
= "myevent1";
723 String functionProbe
= "0xc0101340";
724 String dynProbe
= "init_post";
726 fShell
.setScenario(SCEN_EVENT_HANDLING
);
728 // 1) session name, channel = null, event name, function probe, probe
729 fService
.enableProbe(sessionName
, null, eventName0
, true, functionProbe
, new NullProgressMonitor());
731 // 2) session name, channel = mychannel
732 fService
.enableProbe(sessionName
, channelName
, eventName1
, false, dynProbe
, new NullProgressMonitor());
734 } catch (ExecutionException e
) {
739 public void testEnableLogLevel() {
741 // 1) session name, channel = null, 3 event names, kernel
742 String sessionName
= "mysession2";
743 String channelName
= "mychannel";
744 String eventName4
= "myevent4";
745 String eventName5
= "myevent5";
747 fShell
.setScenario(SCEN_EVENT_HANDLING
);
749 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
750 fService
.enableLogLevel(sessionName
, null, eventName4
, LogLevelType
.LOGLEVEL_ONLY
, TraceLogLevel
.TRACE_DEBUG
, new NullProgressMonitor());
752 // 2) session name, channel = mychannel, null, loglevel, TRACE_DEBUG_FUNCTION
753 fService
.enableLogLevel(sessionName
, channelName
, eventName5
, LogLevelType
.LOGLEVEL
, TraceLogLevel
.TRACE_DEBUG_FUNCTION
, new NullProgressMonitor());
755 } catch (ExecutionException e
) {
760 public void testAddContext() {
762 // 1) session name, channel = null, 3 event names, kernel
763 String sessionName
= "mysession2";
764 String channelName
= "mychannel";
765 String eventName
= "ust_tests_hello:tptest_sighandler";
766 List
<String
> contexts
= new ArrayList
<String
>();
767 contexts
.add("prio");
770 fShell
.setScenario(SCEN_CONTEXT_HANDLING
);
772 List
<String
> availContexts
= fService
.getContextList(new NullProgressMonitor());
773 assertNotNull(availContexts
);
774 assertEquals(12, availContexts
.size());
776 // A very "hard-coded" way to verify but it works ...
777 Set
<String
> expectedContexts
= new HashSet
<String
>();
778 expectedContexts
.add("pid");
779 expectedContexts
.add("procname");
780 expectedContexts
.add("prio");
781 expectedContexts
.add("nice");
782 expectedContexts
.add("vpid");
783 expectedContexts
.add("tid");
784 expectedContexts
.add("pthread_id");
785 expectedContexts
.add("vtid");
786 expectedContexts
.add("ppid");
787 expectedContexts
.add("vppid");
788 expectedContexts
.add("perf:cpu-cycles");
789 expectedContexts
.add("perf:cycles");
791 assertTrue(expectedContexts
.containsAll(availContexts
));
793 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
794 fService
.addContexts(sessionName
, channelName
, eventName
, false, contexts
, new NullProgressMonitor());
796 } catch (ExecutionException e
) {
801 public void testAddContextFailure() {
803 // 1) session name, channel = null, 3 event names, kernel
804 String sessionName
= "mysession2";
805 String channelName
= "mychannel";
806 String eventName
= "ust_tests_hello:tptest_sighandler";
807 List
<String
> contexts
= new ArrayList
<String
>();
808 contexts
.add("prio");
810 fShell
.setScenario(SCEN_CONTEXT_ERROR_HANDLING
);
812 fService
.getContextList(new NullProgressMonitor());
813 fail("No exeption generated");
814 } catch (ExecutionException e
) {
818 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
819 fService
.addContexts(sessionName
, channelName
, eventName
, false, contexts
, new NullProgressMonitor());
820 fail("No exeption generated");
821 } catch (ExecutionException e
) {
826 public void testCalibrate() {
828 fShell
.setScenario(SCEN_CALIBRATE_HANDLING
);
829 fService
.calibrate(true, new NullProgressMonitor());
831 } catch (ExecutionException e
) {
836 public void testCalibrateFailure() {
839 fShell
.setScenario(SCEN_CALIBRATE_HANDLING
);
840 fService
.calibrate(false, new NullProgressMonitor());
841 fail("No exeption generated");
842 } catch (ExecutionException e
) {