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")
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_UNSUPPORTED_VERSION
= "LttngUnsupportedVersion";
57 private static final String SCEN_LTTNG_NO_VERSION
= "LttngNoVersion";
58 private static final String SCEN_NO_SESSION_AVAILABLE
= "NoSessionAvailable";
59 private static final String SCEN_GET_SESSION_NAMES1
= "GetSessionNames1";
60 private static final String SCEN_GET_SESSION_NAME_NOT_EXIST
= "GetSessionNameNotExist";
61 private static final String SCEN_GET_SESSION_GARBAGE_OUT
= "GetSessionGarbageOut";
62 private static final String SCEN_GET_SESSION1
= "GetSession1";
63 private static final String SCEN_GET_KERNEL_PROVIDER1
= "GetKernelProvider1";
64 private static final String SCEN_GET_UST_PROVIDER1
= "GetUstProvider1";
65 private static final String SCEN_GET_UST_PROVIDER2
= "GetUstProvider2";
66 private static final String SCEN_CREATE_SESSION1
= "CreateSession1";
67 private static final String SCEN_CREATE_SESSION_VARIANTS
= "CreateSessionVariants";
68 private static final String SCEN_DESTROY_SESSION1
= "DestroySession1";
69 private static final String SCEN_CHANNEL_HANDLING
= "ChannelHandling";
70 private static final String SCEN_EVENT_HANDLING
= "EventHandling";
71 private static final String SCEN_CONTEXT_HANDLING
= "ContextHandling";
72 private static final String SCEN_CONTEXT_ERROR_HANDLING
= "ContextErrorHandling";
73 private static final String SCEN_CALIBRATE_HANDLING
= "CalibrateHandling";
75 // ------------------------------------------------------------------------
77 // ------------------------------------------------------------------------
78 private CommandShellFactory fShellFactory
;
79 private String fTestfile
;
80 private LTTngToolsFileShell fShell
;
81 private ILttngControlService fService
;
84 // ------------------------------------------------------------------------
86 // ------------------------------------------------------------------------
88 // ------------------------------------------------------------------------
90 // ------------------------------------------------------------------------
92 * Perform pre-test initialization.
94 * @throws Exception if the initialization fails for some reason
98 public void setUp() throws Exception
{
100 fShellFactory
= CommandShellFactory
.getInstance();
102 URL location
= FileLocator
.find(FrameworkUtil
.getBundle(this.getClass()), new Path(DIRECTORY
+ File
.separator
+ TEST_STREAM
), null);
103 File testfile
= new File(FileLocator
.toFileURL(location
).toURI());
104 fTestfile
= testfile
.getAbsolutePath();
106 fShell
= fShellFactory
.getFileShell();
107 fShell
.loadScenarioFile(fTestfile
);
108 fService
= new LTTngControlService(fShell
);
112 * Perform post-test clean-up.
114 * @throws Exception if the clean-up fails for some reason
118 public void tearDown() throws Exception
{
121 // ------------------------------------------------------------------------
123 // ------------------------------------------------------------------------
125 public void testVersion() {
127 fShell
.setScenario(SCEN_LTTNG_VERSION
);
128 ILttngControlService service
= LTTngControlServiceFactory
.getInstance().getLttngControlService(fShell
);
129 assertNotNull(service
);
130 assertEquals("2.0.0", service
.getVersion());
131 } catch (ExecutionException e
) {
132 fail("Exeption thrown " + e
);
136 public void testUnsupportedVersion() {
138 fShell
.setScenario(SCEN_LTTNG_UNSUPPORTED_VERSION
);
139 LTTngControlServiceFactory
.getInstance().getLttngControlService(fShell
);
140 fail("No exeption thrown");
141 } catch (ExecutionException e
) {
146 public void testNoVersion() {
148 fShell
.setScenario(SCEN_LTTNG_NO_VERSION
);
149 LTTngControlServiceFactory
.getInstance().getLttngControlService(fShell
);
150 fail("No exeption thrown");
151 } catch (ExecutionException e
) {
156 public void testLttngNotInstalled() {
158 fShell
.setScenario(SCEN_LTTNG_NOT_INSTALLED
);
159 fService
.getSessionNames(new NullProgressMonitor());
160 fail("No exeption thrown");
161 } catch (ExecutionException e
) {
166 public void testGetSessionNames1() {
168 fShell
.setScenario(SCEN_NO_SESSION_AVAILABLE
);
169 String
[] result
= fService
.getSessionNames(new NullProgressMonitor());
171 assertNotNull(result
);
172 assertEquals(0, result
.length
);
174 } catch (ExecutionException e
) {
179 public void testGetSessionNames2() {
181 fShell
.setScenario(SCEN_GET_SESSION_NAMES1
);
182 String
[] result
= fService
.getSessionNames(new NullProgressMonitor());
184 assertNotNull(result
);
185 assertEquals(2, result
.length
);
186 assertEquals("mysession1", result
[0]);
187 assertEquals("mysession", result
[1]);
189 } catch (ExecutionException e
) {
194 public void testGetSessionNotExist() {
196 fShell
.setScenario(SCEN_GET_SESSION_NAME_NOT_EXIST
);
197 fService
.getSessionNames(new NullProgressMonitor());
198 fail("No exeption thrown");
200 } catch (ExecutionException e
) {
205 public void testGetSessionNameGarbage() {
207 fShell
.setScenario(SCEN_GET_SESSION_GARBAGE_OUT
);
208 String
[] result
= fService
.getSessionNames(new NullProgressMonitor());
210 assertNotNull(result
);
211 assertEquals(0, result
.length
);
213 } catch (ExecutionException e
) {
218 public void testGetSession1() {
220 fShell
.setScenario(SCEN_GET_SESSION1
);
221 ISessionInfo session
= fService
.getSession("mysession", new NullProgressMonitor());
224 assertNotNull(session
);
225 assertEquals("mysession", session
.getName());
226 assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session
.getSessionPath());
227 assertEquals(TraceSessionState
.ACTIVE
, session
.getSessionState());
229 IDomainInfo
[] domains
= session
.getDomains();
230 assertNotNull(domains
);
231 assertEquals(2, domains
.length
);
233 // Verify Kernel domain
234 assertEquals("Kernel", domains
[0].getName());
235 IChannelInfo
[] channels
= domains
[0].getChannels();
236 assertNotNull(channels
);
237 assertEquals(2, channels
.length
);
239 // Verify Kernel's channel0
240 assertEquals("channel0", channels
[0].getName());
241 assertEquals(4, channels
[0].getNumberOfSubBuffers());
242 assertEquals("splice()", channels
[0].getOutputType());
243 assertEquals(false, channels
[0].isOverwriteMode());
244 assertEquals(200, channels
[0].getReadTimer());
245 assertEquals(TraceEnablement
.ENABLED
, channels
[0].getState());
246 assertEquals(262144, channels
[0].getSubBufferSize());
247 assertEquals(0, channels
[0].getSwitchTimer());
250 IEventInfo
[] channel0Events
= channels
[0].getEvents();
251 assertNotNull(channel0Events
);
252 assertEquals(2, channel0Events
.length
);
253 assertEquals("block_rq_remap", channel0Events
[0].getName());
254 assertEquals(TraceLogLevel
.TRACE_EMERG
, channel0Events
[0].getLogLevel());
255 assertEquals(TraceEventType
.TRACEPOINT
, channel0Events
[0].getEventType());
256 assertEquals(TraceEnablement
.ENABLED
, channel0Events
[0].getState());
258 assertEquals("block_bio_remap", channel0Events
[1].getName());
259 assertEquals(TraceLogLevel
.TRACE_EMERG
, channel0Events
[1].getLogLevel());
260 assertEquals(TraceEventType
.TRACEPOINT
, channel0Events
[1].getEventType());
261 assertEquals(TraceEnablement
.DISABLED
, channel0Events
[1].getState());
263 // Verify Kernel's channel1
264 assertEquals("channel1", channels
[1].getName());
265 assertEquals(4, channels
[1].getNumberOfSubBuffers());
266 assertEquals("splice()", channels
[1].getOutputType());
267 assertEquals(true, channels
[1].isOverwriteMode());
268 assertEquals(400, channels
[1].getReadTimer());
269 assertEquals(TraceEnablement
.DISABLED
, channels
[1].getState());
270 assertEquals(524288, channels
[1].getSubBufferSize());
271 assertEquals(100, channels
[1].getSwitchTimer());
274 IEventInfo
[] channel1Events
= channels
[1].getEvents();
275 assertEquals(0, channel1Events
.length
);
277 // Verify domain UST global
278 assertEquals("UST global", domains
[1].getName());
280 IChannelInfo
[] ustChannels
= domains
[1].getChannels();
282 // Verify UST global's mychannel1
283 assertEquals("mychannel1", ustChannels
[0].getName());
284 assertEquals(8, ustChannels
[0].getNumberOfSubBuffers());
285 assertEquals("mmap()", ustChannels
[0].getOutputType());
286 assertEquals(true, ustChannels
[0].isOverwriteMode());
287 assertEquals(100, ustChannels
[0].getReadTimer());
288 assertEquals(TraceEnablement
.DISABLED
, ustChannels
[0].getState());
289 assertEquals(8192, ustChannels
[0].getSubBufferSize());
290 assertEquals(200, ustChannels
[0].getSwitchTimer());
293 IEventInfo
[] ustEvents
= ustChannels
[0].getEvents();
294 assertEquals(0, ustEvents
.length
);
296 // Verify UST global's channel0
297 assertEquals("channel0", ustChannels
[1].getName());
298 assertEquals(4, ustChannels
[1].getNumberOfSubBuffers());
299 assertEquals("mmap()", ustChannels
[1].getOutputType());
300 assertEquals(false, ustChannels
[1].isOverwriteMode());
301 assertEquals(200, ustChannels
[1].getReadTimer());
302 assertEquals(TraceEnablement
.ENABLED
, ustChannels
[1].getState());
303 assertEquals(4096, ustChannels
[1].getSubBufferSize());
304 assertEquals(0, ustChannels
[1].getSwitchTimer());
307 ustEvents
= ustChannels
[1].getEvents();
308 assertEquals(2, ustEvents
.length
);
310 assertEquals("ust_tests_hello:tptest_sighandler", ustEvents
[0].getName());
311 assertEquals(TraceLogLevel
.TRACE_DEBUG_LINE
, ustEvents
[0].getLogLevel());
312 assertEquals(TraceEventType
.TRACEPOINT
, ustEvents
[0].getEventType());
313 assertEquals(TraceEnablement
.DISABLED
, ustEvents
[0].getState());
315 assertEquals("*", ustEvents
[1].getName());
316 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, ustEvents
[1].getLogLevel());
317 assertEquals(TraceEventType
.TRACEPOINT
, ustEvents
[1].getEventType());
318 assertEquals(TraceEnablement
.ENABLED
, ustEvents
[1].getState());
320 // next session (no detailed information available)
321 session
= fService
.getSession("mysession1", new NullProgressMonitor());
322 assertNotNull(session
);
323 assertEquals("mysession1", session
.getName());
324 assertEquals("/home/user/lttng-traces/mysession1-20120203-133225", session
.getSessionPath());
325 assertEquals(TraceSessionState
.INACTIVE
, session
.getSessionState());
327 domains
= session
.getDomains();
328 assertNotNull(domains
);
329 assertEquals(0, domains
.length
);
330 } catch (ExecutionException e
) {
335 public void testGetKernelProvider() {
337 fShell
.setScenario(SCEN_GET_KERNEL_PROVIDER1
);
338 List
<IBaseEventInfo
> events
= fService
.getKernelProvider(new NullProgressMonitor());
341 assertNotNull(events
);
342 assertEquals(3, events
.size());
344 IBaseEventInfo baseEventInfo
= (IBaseEventInfo
) events
.get(0);
345 assertNotNull(baseEventInfo
);
346 assertEquals("sched_kthread_stop", baseEventInfo
.getName());
347 assertEquals(TraceLogLevel
.TRACE_EMERG
, baseEventInfo
.getLogLevel());
348 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
350 baseEventInfo
= (IBaseEventInfo
) events
.get(1);
351 assertEquals("sched_kthread_stop_ret", baseEventInfo
.getName());
352 assertEquals(TraceLogLevel
.TRACE_EMERG
, baseEventInfo
.getLogLevel());
353 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
355 baseEventInfo
= (IBaseEventInfo
) events
.get(2);
356 assertEquals("sched_wakeup_new", baseEventInfo
.getName());
357 assertEquals(TraceLogLevel
.TRACE_EMERG
, baseEventInfo
.getLogLevel());
358 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
360 } catch (ExecutionException e
) {
365 public void testGetUstProvider() {
367 fShell
.setScenario(SCEN_GET_UST_PROVIDER1
);
368 List
<IUstProviderInfo
> providers
= fService
.getUstProvider();
370 // Check all providers
371 assertNotNull(providers
);
372 assertEquals(2, providers
.size());
374 //Verify first provider
375 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(0).getName());
376 assertEquals(9379, providers
.get(0).getPid());
379 IBaseEventInfo
[] events
= providers
.get(0).getEvents();
380 assertNotNull(events
);
381 assertEquals(2, events
.length
);
383 IBaseEventInfo baseEventInfo
= (IBaseEventInfo
) events
[0];
384 assertNotNull(baseEventInfo
);
385 assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo
.getName());
386 assertEquals(TraceLogLevel
.TRACE_DEBUG_MODULE
, baseEventInfo
.getLogLevel());
387 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
389 baseEventInfo
= (IBaseEventInfo
) events
[1];
390 assertEquals("ust_tests_hello:tptest", baseEventInfo
.getName());
391 assertEquals(TraceLogLevel
.TRACE_INFO
, baseEventInfo
.getLogLevel());
392 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
394 //Verify second provider
395 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers
.get(1).getName());
396 assertEquals(4852, providers
.get(1).getPid());
399 events
= providers
.get(1).getEvents();
400 assertNotNull(events
);
401 assertEquals(2, events
.length
);
403 baseEventInfo
= (IBaseEventInfo
) events
[0];
404 assertNotNull(baseEventInfo
);
405 assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo
.getName());
406 assertEquals(TraceLogLevel
.TRACE_WARNING
, baseEventInfo
.getLogLevel());
407 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
409 baseEventInfo
= (IBaseEventInfo
) events
[1];
410 assertEquals("ust_tests_hello:tptest", baseEventInfo
.getName());
411 assertEquals(TraceLogLevel
.TRACE_DEBUG_FUNCTION
, baseEventInfo
.getLogLevel());
412 assertEquals(TraceEventType
.TRACEPOINT
, baseEventInfo
.getEventType());
414 } catch (ExecutionException e
) {
419 public void testUstProvider2() {
421 fShell
.setScenario(SCEN_GET_UST_PROVIDER2
);
422 List
<IUstProviderInfo
> providers
= fService
.getUstProvider();
424 assertNotNull(providers
);
425 assertEquals(0, providers
.size());
427 } catch (ExecutionException e
) {
432 public void testCreateSession() {
434 fShell
.setScenario(SCEN_CREATE_SESSION1
);
436 ISessionInfo info
= fService
.createSession("mysession2", null, new NullProgressMonitor());
438 assertEquals("mysession2", info
.getName());
439 assertNotNull(info
.getSessionPath());
440 assertTrue(info
.getSessionPath().contains("mysession2"));
441 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
442 } catch (ExecutionException e
) {
447 public void testCreateSessionVariants() {
449 fShell
.setScenario(SCEN_CREATE_SESSION_VARIANTS
);
452 fService
.createSession("alreadyExist", null, new NullProgressMonitor());
453 fail("No exeption thrown");
454 } catch (ExecutionException e
) {
459 fService
.createSession("wrongName", null, new NullProgressMonitor());
460 fail("No exeption thrown");
461 } catch (ExecutionException e
) {
466 fService
.createSession("withPath", "/home/user/hallo", new NullProgressMonitor());
467 fail("No exeption thrown");
468 } catch (ExecutionException e
) {
473 ISessionInfo info
= fService
.createSession("session with spaces", null, new NullProgressMonitor());
475 assertEquals("session with spaces", info
.getName());
476 assertNotNull(info
.getSessionPath());
477 assertTrue(info
.getSessionPath().contains("session with spaces"));
478 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
480 } catch (ExecutionException e
) {
485 ISessionInfo info
= fService
.createSession("pathWithSpaces", "/home/user/hallo user/here", new NullProgressMonitor());
487 assertEquals("pathWithSpaces", info
.getName());
488 assertNotNull(info
.getSessionPath());
489 assertTrue(info
.getSessionPath().contains("/home/user/hallo user/here"));
490 assertEquals(TraceSessionState
.INACTIVE
, info
.getSessionState());
492 } catch (ExecutionException e
) {
497 public void testDestroySession() {
499 fShell
.setScenario(SCEN_DESTROY_SESSION1
);
500 fService
.destroySession("mysession2", new NullProgressMonitor());
501 } catch (ExecutionException e
) {
506 public void testCreateChannel() {
509 String sessionName
= "mysession2";
510 List
<String
> list
= new ArrayList
<String
>();
511 String kernelChannel0
= "mychannel0";
512 String kernelChannel1
= "mychannel1";
513 list
.add(kernelChannel0
);
514 list
.add(kernelChannel1
);
516 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
518 // Create/enable/configure 2 kernel channels
519 ChannelInfo chanInfo
= new ChannelInfo("");
520 chanInfo
.setOverwriteMode(true);
521 chanInfo
.setSubBufferSize(16384);
522 chanInfo
.setReadTimer(100);
523 chanInfo
.setSwitchTimer(200);
524 chanInfo
.setNumberOfSubBuffers(2);
525 fService
.enableChannels(sessionName
, list
, true, chanInfo
, new NullProgressMonitor());
527 // Create/enable/configure 1 UST channel
529 list
.add("ustChannel");
531 chanInfo
= new ChannelInfo("");
532 chanInfo
.setOverwriteMode(true);
533 chanInfo
.setSubBufferSize(32768);
534 chanInfo
.setReadTimer(200);
535 chanInfo
.setSwitchTimer(100);
536 chanInfo
.setNumberOfSubBuffers(1);
537 fService
.enableChannels(sessionName
, list
, false, chanInfo
, new NullProgressMonitor());
539 } catch (ExecutionException e
) {
544 public void testDisableChannel() {
547 String sessionName
= "mysession2";
548 List
<String
> list
= new ArrayList
<String
>();
549 String kernelChannel0
= "mychannel0";
550 String kernelChannel1
= "mychannel1";
551 list
.add(kernelChannel0
);
552 list
.add(kernelChannel1
);
554 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
555 fService
.disableChannels(sessionName
, list
, true, new NullProgressMonitor());
558 list
.add("ustChannel");
559 fService
.disableChannels(sessionName
, list
, false, new NullProgressMonitor());
561 } catch (ExecutionException e
) {
566 public void testEnableChannel() {
569 String sessionName
= "mysession2";
570 List
<String
> list
= new ArrayList
<String
>();
571 String kernelChannel0
= "mychannel0";
572 String kernelChannel1
= "mychannel1";
573 list
.add(kernelChannel0
);
574 list
.add(kernelChannel1
);
576 fShell
.setScenario(SCEN_CHANNEL_HANDLING
);
577 fService
.enableChannels(sessionName
, list
, true, null, new NullProgressMonitor());
579 // Create/enable/configure 1 UST channel
581 list
.add("ustChannel");
583 fService
.enableChannels(sessionName
, list
, false, null, new NullProgressMonitor());
585 } catch (ExecutionException e
) {
590 // public void tesEnableChannelNoTracer() {
592 // ILttngControlService service = new LTTngControlService(fShellFactory.getShellForChannelNoTracer());
593 // service.getSessionNames(new NullProgressMonitor());
594 // fail("No exeption thrown");
596 // } catch (ExecutionException e) {
601 public void testEnableEvents() {
603 // 1) session name, channel = null, 3 event names, kernel
604 String sessionName
= "mysession2";
605 List
<String
> list
= new ArrayList
<String
>();
606 String eventName0
= "block_rq_remap";
607 String eventName1
= "block_bio_remap";
608 String eventName2
= "softirq_entry";
609 list
.add(eventName0
);
610 list
.add(eventName1
);
611 list
.add(eventName2
);
612 fShell
.setScenario(SCEN_EVENT_HANDLING
);
613 fService
.enableEvents(sessionName
, null, list
, true, new NullProgressMonitor());
615 // 2) session name, channel=mychannel, event name= null, kernel
616 String channelName
= "mychannel";
617 fService
.enableEvents(sessionName
, channelName
, null, true, new NullProgressMonitor());
619 // 3) session name, channel=mychannel, 1 event name, ust
620 String ustEventName
= "ust_tests_hello:tptest_sighandler";
622 list
.add(ustEventName
);
623 fService
.enableEvents(sessionName
, channelName
, list
, false, new NullProgressMonitor());
625 // 4) session name, channel = mychannel, no event name, ust
627 fService
.enableEvents(sessionName
, channelName
, list
, false, new NullProgressMonitor());
629 } catch (ExecutionException e
) {
634 public void testEnableSyscalls() {
636 // 1) session name, channel = null, 3 event names, kernel
637 String sessionName
= "mysession2";
638 String channelName
= "mychannel";
640 fShell
.setScenario(SCEN_EVENT_HANDLING
);
642 // 1) session name, channel = null
643 fService
.enableSyscalls(sessionName
, null, new NullProgressMonitor());
645 // 2) session name, channel = mychannel
646 fService
.enableSyscalls(sessionName
, channelName
, new NullProgressMonitor());
648 } catch (ExecutionException e
) {
653 public void testDynamicProbe() {
655 // 1) session name, channel = null, 3 event names, kernel
656 String sessionName
= "mysession2";
657 String channelName
= "mychannel";
658 String eventName0
= "myevent0";
659 String eventName1
= "myevent1";
660 String functionProbe
= "0xc0101340";
661 String dynProbe
= "init_post";
663 fShell
.setScenario(SCEN_EVENT_HANDLING
);
665 // 1) session name, channel = null, event name, function probe, probe
666 fService
.enableProbe(sessionName
, null, eventName0
, true, functionProbe
, new NullProgressMonitor());
668 // 2) session name, channel = mychannel
669 fService
.enableProbe(sessionName
, channelName
, eventName1
, false, dynProbe
, new NullProgressMonitor());
671 } catch (ExecutionException e
) {
676 public void testEnableLogLevel() {
678 // 1) session name, channel = null, 3 event names, kernel
679 String sessionName
= "mysession2";
680 String channelName
= "mychannel";
681 String eventName4
= "myevent4";
682 String eventName5
= "myevent5";
684 fShell
.setScenario(SCEN_EVENT_HANDLING
);
686 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
687 fService
.enableLogLevel(sessionName
, null, eventName4
, LogLevelType
.LOGLEVEL_ONLY
, TraceLogLevel
.TRACE_DEBUG
, new NullProgressMonitor());
689 // 2) session name, channel = mychannel, null, loglevel, TRACE_DEBUG_FUNCTION
690 fService
.enableLogLevel(sessionName
, channelName
, eventName5
, LogLevelType
.LOGLEVEL
, TraceLogLevel
.TRACE_DEBUG_FUNCTION
, new NullProgressMonitor());
692 } catch (ExecutionException e
) {
697 public void testAddContext() {
699 // 1) session name, channel = null, 3 event names, kernel
700 String sessionName
= "mysession2";
701 String channelName
= "mychannel";
702 String eventName
= "ust_tests_hello:tptest_sighandler";
703 List
<String
> contexts
= new ArrayList
<String
>();
704 contexts
.add("prio");
707 fShell
.setScenario(SCEN_CONTEXT_HANDLING
);
709 List
<String
> availContexts
= fService
.getContextList(new NullProgressMonitor());
710 assertNotNull(availContexts
);
711 assertEquals(12, availContexts
.size());
713 // A very "hard-coded" way to verify but it works ...
714 Set
<String
> expectedContexts
= new HashSet
<String
>();
715 expectedContexts
.add("pid");
716 expectedContexts
.add("procname");
717 expectedContexts
.add("prio");
718 expectedContexts
.add("nice");
719 expectedContexts
.add("vpid");
720 expectedContexts
.add("tid");
721 expectedContexts
.add("pthread_id");
722 expectedContexts
.add("vtid");
723 expectedContexts
.add("ppid");
724 expectedContexts
.add("vppid");
725 expectedContexts
.add("perf:cpu-cycles");
726 expectedContexts
.add("perf:cycles");
728 assertTrue(expectedContexts
.containsAll(availContexts
));
730 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
731 fService
.addContexts(sessionName
, channelName
, eventName
, false, contexts
, new NullProgressMonitor());
733 } catch (ExecutionException e
) {
738 public void testAddContextFailure() {
740 // 1) session name, channel = null, 3 event names, kernel
741 String sessionName
= "mysession2";
742 String channelName
= "mychannel";
743 String eventName
= "ust_tests_hello:tptest_sighandler";
744 List
<String
> contexts
= new ArrayList
<String
>();
745 contexts
.add("prio");
747 fShell
.setScenario(SCEN_CONTEXT_ERROR_HANDLING
);
749 fService
.getContextList(new NullProgressMonitor());
750 fail("No exeption generated");
751 } catch (ExecutionException e
) {
755 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
756 fService
.addContexts(sessionName
, channelName
, eventName
, false, contexts
, new NullProgressMonitor());
757 fail("No exeption generated");
758 } catch (ExecutionException e
) {
763 public void testCalibrate() {
765 fShell
.setScenario(SCEN_CALIBRATE_HANDLING
);
766 fService
.calibrate(true, new NullProgressMonitor());
768 } catch (ExecutionException e
) {
773 public void testCalibrateFailure() {
776 fShell
.setScenario(SCEN_CALIBRATE_HANDLING
);
777 fService
.calibrate(false, new NullProgressMonitor());
778 fail("No exeption generated");
779 } catch (ExecutionException e
) {