Merge branch 'master' into TmfTraceModel-new
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui.tests / src / org / eclipse / linuxtools / lttng2 / ui / tests / control / service / LTTngControlServiceTest.java
1 /**********************************************************************
2 * Copyright (c) 2012 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12 package org.eclipse.linuxtools.lttng2.ui.tests.control.service;
13
14 import java.io.File;
15 import java.net.URL;
16 import java.util.ArrayList;
17 import java.util.HashSet;
18 import java.util.Iterator;
19 import java.util.List;
20 import java.util.Set;
21
22 import junit.framework.TestCase;
23
24 import org.eclipse.core.commands.ExecutionException;
25 import org.eclipse.core.runtime.FileLocator;
26 import org.eclipse.core.runtime.NullProgressMonitor;
27 import org.eclipse.core.runtime.Path;
28 import org.eclipse.linuxtools.internal.lttng2.stubs.service.CommandShellFactory;
29 import org.eclipse.linuxtools.internal.lttng2.stubs.shells.LTTngToolsFileShell;
30 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IBaseEventInfo;
31 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo;
32 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo;
33 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IEventInfo;
34 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo;
35 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IUstProviderInfo;
36 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.LogLevelType;
37 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEnablement;
38 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEventType;
39 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel;
40 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState;
41 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.ChannelInfo;
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.osgi.framework.FrameworkUtil;
45 /**
46 * The class <code>LTTngControlServiceTest</code> contains test for the class <code>{@link LTTngControlService}</code>.
47 */
48 @SuppressWarnings("nls")
49 public class LTTngControlServiceTest extends TestCase {
50
51 private static final String DIRECTORY = "testfiles";
52 private static final String TEST_STREAM = "LTTngServiceTest.cfg";
53
54 private static final String SCEN_LTTNG_NOT_INSTALLED = "LttngNotInstalled";
55 private static final String SCEN_NO_SESSION_AVAILABLE = "NoSessionAvailable";
56 private static final String SCEN_GET_SESSION_NAMES1 = "GetSessionNames1";
57 private static final String SCEN_GET_SESSION_NAME_NOT_EXIST = "GetSessionNameNotExist";
58 private static final String SCEN_GET_SESSION_GARBAGE_OUT = "GetSessionGarbageOut";
59 private static final String SCEN_GET_SESSION1 = "GetSession1";
60 private static final String SCEN_GET_KERNEL_PROVIDER1 = "GetKernelProvider1";
61 private static final String SCEN_GET_UST_PROVIDER1 = "GetUstProvider1";
62 private static final String SCEN_GET_UST_PROVIDER2 = "GetUstProvider2";
63 private static final String SCEN_CREATE_SESSION1 = "CreateSession1";
64 private static final String SCEN_CREATE_SESSION_VARIANTS = "CreateSessionVariants";
65 private static final String SCEN_DESTROY_SESSION1 = "DestroySession1";
66 private static final String SCEN_CHANNEL_HANDLING = "ChannelHandling";
67 private static final String SCEN_EVENT_HANDLING = "EventHandling";
68 private static final String SCEN_CONTEXT_HANDLING = "ContextHandling";
69 private static final String SCEN_CONTEXT_ERROR_HANDLING = "ContextErrorHandling";
70 private static final String SCEN_CALIBRATE_HANDLING = "CalibrateHandling";
71
72 // ------------------------------------------------------------------------
73 // Test data
74 // ------------------------------------------------------------------------
75 private CommandShellFactory fShellFactory;
76 private String fTestfile;
77 private LTTngToolsFileShell fShell;
78 private ILttngControlService fService;
79
80
81 // ------------------------------------------------------------------------
82 // Static methods
83 // ------------------------------------------------------------------------
84
85 // ------------------------------------------------------------------------
86 // Housekeeping
87 // ------------------------------------------------------------------------
88 /**
89 * Perform pre-test initialization.
90 *
91 * @throws Exception if the initialization fails for some reason
92 *
93 */
94 @Override
95 public void setUp() throws Exception {
96 super.setUp();
97 fShellFactory = CommandShellFactory.getInstance();
98
99 URL location = FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
100 File testfile = new File(FileLocator.toFileURL(location).toURI());
101 fTestfile = testfile.getAbsolutePath();
102
103 fShell = fShellFactory.getFileShell();
104 fShell.loadScenarioFile(fTestfile);
105 fService = new LTTngControlService(fShell);
106 }
107
108 /**
109 * Perform post-test clean-up.
110 *
111 * @throws Exception if the clean-up fails for some reason
112 *
113 */
114 @Override
115 public void tearDown() throws Exception {
116 }
117
118 // ------------------------------------------------------------------------
119 // Test Cases
120 // ------------------------------------------------------------------------
121
122 public void testGetSessionNames() {
123 try {
124 fShell.setScenario(SCEN_LTTNG_NOT_INSTALLED);
125 fService.getSessionNames(new NullProgressMonitor());
126 fail("No exeption thrown");
127 } catch (ExecutionException e) {
128 // success
129 }
130 }
131
132 public void testGetSessionNames1() {
133 try {
134 fShell.setScenario(SCEN_NO_SESSION_AVAILABLE);
135 String[] result = fService.getSessionNames(new NullProgressMonitor());
136
137 assertNotNull(result);
138 assertEquals(0, result.length);
139
140 } catch (ExecutionException e) {
141 fail(e.toString());
142 }
143 }
144
145 public void testGetSessionNames2() {
146 try {
147 fShell.setScenario(SCEN_GET_SESSION_NAMES1);
148 String[] result = fService.getSessionNames(new NullProgressMonitor());
149
150 assertNotNull(result);
151 assertEquals(2, result.length);
152 assertEquals("mysession1", result[0]);
153 assertEquals("mysession", result[1]);
154
155 } catch (ExecutionException e) {
156 fail(e.toString());
157 }
158 }
159
160 public void testGetSessionNotExist() {
161 try {
162 fShell.setScenario(SCEN_GET_SESSION_NAME_NOT_EXIST);
163 fService.getSessionNames(new NullProgressMonitor());
164 fail("No exeption thrown");
165
166 } catch (ExecutionException e) {
167 // success
168 }
169 }
170
171 public void testGetSessionNameGarbage() {
172 try {
173 fShell.setScenario(SCEN_GET_SESSION_GARBAGE_OUT);
174 String[] result = fService.getSessionNames(new NullProgressMonitor());
175
176 assertNotNull(result);
177 assertEquals(0, result.length);
178
179 } catch (ExecutionException e) {
180 fail(e.toString());
181 }
182 }
183
184 public void testGetSession1() {
185 try {
186 fShell.setScenario(SCEN_GET_SESSION1);
187 ISessionInfo session = fService.getSession("mysession", new NullProgressMonitor());
188
189 // Verify Session
190 assertNotNull(session);
191 assertEquals("mysession", session.getName());
192 assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session.getSessionPath());
193 assertEquals(TraceSessionState.ACTIVE, session.getSessionState());
194
195 IDomainInfo[] domains = session.getDomains();
196 assertNotNull(domains);
197 assertEquals(2, domains.length);
198
199 // Verify Kernel domain
200 assertEquals("Kernel", domains[0].getName());
201 IChannelInfo[] channels = domains[0].getChannels();
202 assertNotNull(channels);
203 assertEquals(2, channels.length);
204
205 // Verify Kernel's channel0
206 assertEquals("channel0", channels[0].getName());
207 assertEquals(4, channels[0].getNumberOfSubBuffers());
208 assertEquals("splice()", channels[0].getOutputType());
209 assertEquals(false, channels[0].isOverwriteMode());
210 assertEquals(200, channels[0].getReadTimer());
211 assertEquals(TraceEnablement.ENABLED, channels[0].getState());
212 assertEquals(262144, channels[0].getSubBufferSize());
213 assertEquals(0, channels[0].getSwitchTimer());
214
215 // Verify event info
216 IEventInfo[] channel0Events = channels[0].getEvents();
217 assertNotNull(channel0Events);
218 assertEquals(2, channel0Events.length);
219 assertEquals("block_rq_remap", channel0Events[0].getName());
220 assertEquals(TraceLogLevel.TRACE_EMERG, channel0Events[0].getLogLevel());
221 assertEquals(TraceEventType.TRACEPOINT, channel0Events[0].getEventType());
222 assertEquals(TraceEnablement.ENABLED, channel0Events[0].getState());
223
224 assertEquals("block_bio_remap", channel0Events[1].getName());
225 assertEquals(TraceLogLevel.TRACE_EMERG, channel0Events[1].getLogLevel());
226 assertEquals(TraceEventType.TRACEPOINT, channel0Events[1].getEventType());
227 assertEquals(TraceEnablement.DISABLED, channel0Events[1].getState());
228
229 // Verify Kernel's channel1
230 assertEquals("channel1", channels[1].getName());
231 assertEquals(4, channels[1].getNumberOfSubBuffers());
232 assertEquals("splice()", channels[1].getOutputType());
233 assertEquals(true, channels[1].isOverwriteMode());
234 assertEquals(400, channels[1].getReadTimer());
235 assertEquals(TraceEnablement.DISABLED, channels[1].getState());
236 assertEquals(524288, channels[1].getSubBufferSize());
237 assertEquals(100, channels[1].getSwitchTimer());
238
239 // Verify event info
240 IEventInfo[] channel1Events = channels[1].getEvents();
241 assertEquals(0, channel1Events.length);
242
243 // Verify domain UST global
244 assertEquals("UST global", domains[1].getName());
245
246 IChannelInfo[] ustChannels = domains[1].getChannels();
247
248 // Verify UST global's mychannel1
249 assertEquals("mychannel1", ustChannels[0].getName());
250 assertEquals(8, ustChannels[0].getNumberOfSubBuffers());
251 assertEquals("mmap()", ustChannels[0].getOutputType());
252 assertEquals(true, ustChannels[0].isOverwriteMode());
253 assertEquals(100, ustChannels[0].getReadTimer());
254 assertEquals(TraceEnablement.DISABLED, ustChannels[0].getState());
255 assertEquals(8192, ustChannels[0].getSubBufferSize());
256 assertEquals(200, ustChannels[0].getSwitchTimer());
257
258 // Verify event info
259 IEventInfo[] ustEvents = ustChannels[0].getEvents();
260 assertEquals(0, ustEvents.length);
261
262 // Verify UST global's channel0
263 assertEquals("channel0", ustChannels[1].getName());
264 assertEquals(4, ustChannels[1].getNumberOfSubBuffers());
265 assertEquals("mmap()", ustChannels[1].getOutputType());
266 assertEquals(false, ustChannels[1].isOverwriteMode());
267 assertEquals(200, ustChannels[1].getReadTimer());
268 assertEquals(TraceEnablement.ENABLED, ustChannels[1].getState());
269 assertEquals(4096, ustChannels[1].getSubBufferSize());
270 assertEquals(0, ustChannels[1].getSwitchTimer());
271
272 // Verify event info
273 ustEvents = ustChannels[1].getEvents();
274 assertEquals(2, ustEvents.length);
275
276 assertEquals("ust_tests_hello:tptest_sighandler", ustEvents[0].getName());
277 assertEquals(TraceLogLevel.TRACE_DEBUG_LINE, ustEvents[0].getLogLevel());
278 assertEquals(TraceEventType.TRACEPOINT, ustEvents[0].getEventType());
279 assertEquals(TraceEnablement.DISABLED, ustEvents[0].getState());
280
281 assertEquals("*", ustEvents[1].getName());
282 assertEquals(TraceLogLevel.LEVEL_UNKNOWN, ustEvents[1].getLogLevel());
283 assertEquals(TraceEventType.TRACEPOINT, ustEvents[1].getEventType());
284 assertEquals(TraceEnablement.ENABLED, ustEvents[1].getState());
285
286 // next session (no detailed information available)
287 session = fService.getSession("mysession1", new NullProgressMonitor());
288 assertNotNull(session);
289 assertEquals("mysession1", session.getName());
290 assertEquals("/home/user/lttng-traces/mysession1-20120203-133225", session.getSessionPath());
291 assertEquals(TraceSessionState.INACTIVE, session.getSessionState());
292
293 domains = session.getDomains();
294 assertNotNull(domains);
295 assertEquals(0, domains.length);
296 } catch (ExecutionException e) {
297 fail(e.toString());
298 }
299 }
300
301 public void testGetKernelProvider() {
302 try {
303 fShell.setScenario(SCEN_GET_KERNEL_PROVIDER1);
304 List<IBaseEventInfo> events = fService.getKernelProvider(new NullProgressMonitor());
305
306 // Verify event info
307 assertNotNull(events);
308 assertEquals(3, events.size());
309
310 IBaseEventInfo baseEventInfo = (IBaseEventInfo) events.get(0);
311 assertNotNull(baseEventInfo);
312 assertEquals("sched_kthread_stop", baseEventInfo.getName());
313 assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel());
314 assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
315
316 baseEventInfo = (IBaseEventInfo) events.get(1);
317 assertEquals("sched_kthread_stop_ret", baseEventInfo.getName());
318 assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel());
319 assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
320
321 baseEventInfo = (IBaseEventInfo) events.get(2);
322 assertEquals("sched_wakeup_new", baseEventInfo.getName());
323 assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel());
324 assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
325
326 } catch (ExecutionException e) {
327 fail(e.toString());
328 }
329 }
330
331 public void testGetUstProvider() {
332 try {
333 fShell.setScenario(SCEN_GET_UST_PROVIDER1);
334 List<IUstProviderInfo> providers = fService.getUstProvider();
335
336 // Check all providers
337 assertNotNull(providers);
338 assertEquals(2, providers.size());
339
340 //Verify first provider
341 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers.get(0).getName());
342 assertEquals(9379, providers.get(0).getPid());
343
344 // Verify event info
345 IBaseEventInfo[] events = providers.get(0).getEvents();
346 assertNotNull(events);
347 assertEquals(2, events.length);
348
349 IBaseEventInfo baseEventInfo = (IBaseEventInfo) events[0];
350 assertNotNull(baseEventInfo);
351 assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo.getName());
352 assertEquals(TraceLogLevel.TRACE_DEBUG_MODULE, baseEventInfo.getLogLevel());
353 assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
354
355 baseEventInfo = (IBaseEventInfo) events[1];
356 assertEquals("ust_tests_hello:tptest", baseEventInfo.getName());
357 assertEquals(TraceLogLevel.TRACE_INFO, baseEventInfo.getLogLevel());
358 assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
359
360 //Verify second provider
361 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers.get(1).getName());
362 assertEquals(4852, providers.get(1).getPid());
363
364 // Verify event info
365 events = providers.get(1).getEvents();
366 assertNotNull(events);
367 assertEquals(2, events.length);
368
369 baseEventInfo = (IBaseEventInfo) events[0];
370 assertNotNull(baseEventInfo);
371 assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo.getName());
372 assertEquals(TraceLogLevel.TRACE_WARNING, baseEventInfo.getLogLevel());
373 assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
374
375 baseEventInfo = (IBaseEventInfo) events[1];
376 assertEquals("ust_tests_hello:tptest", baseEventInfo.getName());
377 assertEquals(TraceLogLevel.TRACE_DEBUG_FUNCTION, baseEventInfo.getLogLevel());
378 assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
379
380 } catch (ExecutionException e) {
381 fail(e.toString());
382 }
383 }
384
385 public void testUstProvider2() {
386 try {
387 fShell.setScenario(SCEN_GET_UST_PROVIDER2);
388 List<IUstProviderInfo> providers = fService.getUstProvider();
389
390 assertNotNull(providers);
391 assertEquals(0, providers.size());
392
393 } catch (ExecutionException e) {
394 fail(e.toString());
395 }
396 }
397
398 public void testCreateSession() {
399 try {
400 fShell.setScenario(SCEN_CREATE_SESSION1);
401
402 ISessionInfo info = fService.createSession("mysession2", null, new NullProgressMonitor());
403 assertNotNull(info);
404 assertEquals("mysession2", info.getName());
405 assertNotNull(info.getSessionPath());
406 assertTrue(info.getSessionPath().contains("mysession2"));
407 assertEquals(TraceSessionState.INACTIVE, info.getSessionState());
408 } catch (ExecutionException e) {
409 fail(e.toString());
410 }
411 }
412
413 public void testCreateSessionVariants() {
414
415 fShell.setScenario(SCEN_CREATE_SESSION_VARIANTS);
416
417 try {
418 fService.createSession("alreadyExist", null, new NullProgressMonitor());
419 fail("No exeption thrown");
420 } catch (ExecutionException e) {
421 // success
422 }
423
424 try {
425 fService.createSession("wrongName", null, new NullProgressMonitor());
426 fail("No exeption thrown");
427 } catch (ExecutionException e) {
428 // success
429 }
430
431 try {
432 fService.createSession("withPath", "/home/user/hallo", new NullProgressMonitor());
433 fail("No exeption thrown");
434 } catch (ExecutionException e) {
435 // success
436 }
437
438 try {
439 ISessionInfo info = fService.createSession("session with spaces", null, new NullProgressMonitor());
440 assertNotNull(info);
441 assertEquals("session with spaces", info.getName());
442 assertNotNull(info.getSessionPath());
443 assertTrue(info.getSessionPath().contains("session with spaces"));
444 assertEquals(TraceSessionState.INACTIVE, info.getSessionState());
445
446 } catch (ExecutionException e) {
447 fail(e.toString());
448 }
449
450 try {
451 ISessionInfo info = fService.createSession("pathWithSpaces", "/home/user/hallo user/here", new NullProgressMonitor());
452 assertNotNull(info);
453 assertEquals("pathWithSpaces", info.getName());
454 assertNotNull(info.getSessionPath());
455 assertTrue(info.getSessionPath().contains("/home/user/hallo user/here"));
456 assertEquals(TraceSessionState.INACTIVE, info.getSessionState());
457
458 } catch (ExecutionException e) {
459 fail(e.toString());
460 }
461 }
462
463 public void testDestroySession() {
464 try {
465 fShell.setScenario(SCEN_DESTROY_SESSION1);
466 fService.destroySession("mysession2", new NullProgressMonitor());
467 } catch (ExecutionException e) {
468 fail(e.toString());
469 }
470 }
471
472 public void testCreateChannel() {
473 try {
474
475 String sessionName = "mysession2";
476 List<String> list = new ArrayList<String>();
477 String kernelChannel0 = "mychannel0";
478 String kernelChannel1 = "mychannel1";
479 list.add(kernelChannel0);
480 list.add(kernelChannel1);
481
482 fShell.setScenario(SCEN_CHANNEL_HANDLING);
483
484 // Create/enable/configure 2 kernel channels
485 ChannelInfo chanInfo = new ChannelInfo("");
486 chanInfo.setOverwriteMode(true);
487 chanInfo.setSubBufferSize(16384);
488 chanInfo.setReadTimer(100);
489 chanInfo.setSwitchTimer(200);
490 chanInfo.setNumberOfSubBuffers(2);
491 fService.enableChannels(sessionName, list, true, chanInfo, new NullProgressMonitor());
492
493 // Create/enable/configure 1 UST channel
494 list.clear();
495 list.add("ustChannel");
496
497 chanInfo = new ChannelInfo("");
498 chanInfo.setOverwriteMode(true);
499 chanInfo.setSubBufferSize(32768);
500 chanInfo.setReadTimer(200);
501 chanInfo.setSwitchTimer(100);
502 chanInfo.setNumberOfSubBuffers(1);
503 fService.enableChannels(sessionName, list, false, chanInfo, new NullProgressMonitor());
504
505 } catch (ExecutionException e) {
506 fail(e.toString());
507 }
508 }
509
510 public void testDisableChannel() {
511 try {
512
513 String sessionName = "mysession2";
514 List<String> list = new ArrayList<String>();
515 String kernelChannel0 = "mychannel0";
516 String kernelChannel1 = "mychannel1";
517 list.add(kernelChannel0);
518 list.add(kernelChannel1);
519
520 fShell.setScenario(SCEN_CHANNEL_HANDLING);
521 fService.disableChannels(sessionName, list, true, new NullProgressMonitor());
522
523 list.clear();
524 list.add("ustChannel");
525 fService.disableChannels(sessionName, list, false, new NullProgressMonitor());
526
527 } catch (ExecutionException e) {
528 fail(e.toString());
529 }
530 }
531
532 public void testEnableChannel() {
533 try {
534
535 String sessionName = "mysession2";
536 List<String> list = new ArrayList<String>();
537 String kernelChannel0 = "mychannel0";
538 String kernelChannel1 = "mychannel1";
539 list.add(kernelChannel0);
540 list.add(kernelChannel1);
541
542 fShell.setScenario(SCEN_CHANNEL_HANDLING);
543 fService.enableChannels(sessionName, list, true, null, new NullProgressMonitor());
544
545 // Create/enable/configure 1 UST channel
546 list.clear();
547 list.add("ustChannel");
548
549 fService.enableChannels(sessionName, list, false, null, new NullProgressMonitor());
550
551 } catch (ExecutionException e) {
552 fail(e.toString());
553 }
554 }
555
556 // public void tesEnableChannelNoTracer() {
557 // try {
558 // ILttngControlService service = new LTTngControlService(fShellFactory.getShellForChannelNoTracer());
559 // service.getSessionNames(new NullProgressMonitor());
560 // fail("No exeption thrown");
561 //
562 // } catch (ExecutionException e) {
563 // // success
564 // }
565 // }
566
567 public void testEnableEvents() {
568 try {
569 // 1) session name, channel = null, 3 event names, kernel
570 String sessionName = "mysession2";
571 List<String> list = new ArrayList<String>();
572 String eventName0 = "block_rq_remap";
573 String eventName1 = "block_bio_remap";
574 String eventName2 = "softirq_entry";
575 list.add(eventName0);
576 list.add(eventName1);
577 list.add(eventName2);
578 fShell.setScenario(SCEN_EVENT_HANDLING);
579 fService.enableEvents(sessionName, null, list, true, new NullProgressMonitor());
580
581 // 2) session name, channel=mychannel, event name= null, kernel
582 String channelName = "mychannel";
583 fService.enableEvents(sessionName, channelName, null, true, new NullProgressMonitor());
584
585 // 3) session name, channel=mychannel, 1 event name, ust
586 String ustEventName = "ust_tests_hello:tptest_sighandler";
587 list.clear();
588 list.add(ustEventName);
589 fService.enableEvents(sessionName, channelName, list, false, new NullProgressMonitor());
590
591 // 4) session name, channel = mychannel, no event name, ust
592 list.clear();
593 fService.enableEvents(sessionName, channelName, list, false, new NullProgressMonitor());
594
595 } catch (ExecutionException e) {
596 fail(e.toString());
597 }
598 }
599
600 public void testEnableSyscalls() {
601 try {
602 // 1) session name, channel = null, 3 event names, kernel
603 String sessionName = "mysession2";
604 String channelName = "mychannel";
605
606 fShell.setScenario(SCEN_EVENT_HANDLING);
607
608 // 1) session name, channel = null
609 fService.enableSyscalls(sessionName, null, new NullProgressMonitor());
610
611 // 2) session name, channel = mychannel
612 fService.enableSyscalls(sessionName, channelName, new NullProgressMonitor());
613
614 } catch (ExecutionException e) {
615 fail(e.toString());
616 }
617 }
618
619 public void testDynamicProbe() {
620 try {
621 // 1) session name, channel = null, 3 event names, kernel
622 String sessionName = "mysession2";
623 String channelName = "mychannel";
624 String eventName0 = "myevent0";
625 String eventName1 = "myevent1";
626 String functionProbe = "0xc0101340";
627 String dynProbe = "init_post";
628
629 fShell.setScenario(SCEN_EVENT_HANDLING);
630
631 // 1) session name, channel = null, event name, function probe, probe
632 fService.enableProbe(sessionName, null, eventName0, true, functionProbe, new NullProgressMonitor());
633
634 // 2) session name, channel = mychannel
635 fService.enableProbe(sessionName, channelName, eventName1, false, dynProbe, new NullProgressMonitor());
636
637 } catch (ExecutionException e) {
638 fail(e.toString());
639 }
640 }
641
642 public void testEnableLogLevel() {
643 try {
644 // 1) session name, channel = null, 3 event names, kernel
645 String sessionName = "mysession2";
646 String channelName = "mychannel";
647 String eventName4 = "myevent4";
648 String eventName5 = "myevent5";
649
650 fShell.setScenario(SCEN_EVENT_HANDLING);
651
652 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
653 fService.enableLogLevel(sessionName, null, eventName4, LogLevelType.LOGLEVEL_ONLY, TraceLogLevel.TRACE_DEBUG, new NullProgressMonitor());
654
655 // 2) session name, channel = mychannel, null, loglevel, TRACE_DEBUG_FUNCTION
656 fService.enableLogLevel(sessionName, channelName, eventName5, LogLevelType.LOGLEVEL, TraceLogLevel.TRACE_DEBUG_FUNCTION, new NullProgressMonitor());
657
658 } catch (ExecutionException e) {
659 fail(e.toString());
660 }
661 }
662
663 public void testAddContext() {
664 try {
665 // 1) session name, channel = null, 3 event names, kernel
666 String sessionName = "mysession2";
667 String channelName = "mychannel";
668 String eventName = "ust_tests_hello:tptest_sighandler";
669 List<String> contexts = new ArrayList<String>();
670 contexts.add("prio");
671 contexts.add("pid");
672
673 fShell.setScenario(SCEN_CONTEXT_HANDLING);
674
675 List<String> availContexts = fService.getContextList(new NullProgressMonitor());
676 assertNotNull(availContexts);
677 assertEquals(12, availContexts.size());
678
679 // A very "hard-coded" way to verify but it works ...
680 Set<String> expectedContexts = new HashSet<String>();
681 expectedContexts.add("pid");
682 expectedContexts.add("procname");
683 expectedContexts.add("prio");
684 expectedContexts.add("nice");
685 expectedContexts.add("vpid");
686 expectedContexts.add("tid");
687 expectedContexts.add("pthread_id");
688 expectedContexts.add("vtid");
689 expectedContexts.add("ppid");
690 expectedContexts.add("vppid");
691 expectedContexts.add("perf:cpu-cycles");
692 expectedContexts.add("perf:cycles");
693
694 assertTrue(expectedContexts.containsAll(availContexts));
695
696 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
697 fService.addContexts(sessionName, channelName, eventName, false, contexts, new NullProgressMonitor());
698
699 } catch (ExecutionException e) {
700 fail(e.toString());
701 }
702 }
703
704 public void testAddContextFailure() {
705
706 // 1) session name, channel = null, 3 event names, kernel
707 String sessionName = "mysession2";
708 String channelName = "mychannel";
709 String eventName = "ust_tests_hello:tptest_sighandler";
710 List<String> contexts = new ArrayList<String>();
711 contexts.add("prio");
712 contexts.add("pid");
713 fShell.setScenario(SCEN_CONTEXT_ERROR_HANDLING);
714 try {
715 fService.getContextList(new NullProgressMonitor());
716 fail("No exeption generated");
717 } catch (ExecutionException e) {
718 // success
719 }
720 try {
721 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
722 fService.addContexts(sessionName, channelName, eventName, false, contexts, new NullProgressMonitor());
723 fail("No exeption generated");
724 } catch (ExecutionException e) {
725 // success
726 }
727 }
728
729 public void testCalibrate() {
730 try {
731 fShell.setScenario(SCEN_CALIBRATE_HANDLING);
732 fService.calibrate(true, new NullProgressMonitor());
733
734 } catch (ExecutionException e) {
735 fail(e.toString());
736 }
737 }
738
739 public void testCalibrateFailure() {
740
741 try {
742 fShell.setScenario(SCEN_CALIBRATE_HANDLING);
743 fService.calibrate(false, new NullProgressMonitor());
744 fail("No exeption generated");
745 } catch (ExecutionException e) {
746 // success
747 }
748 }
749
750 }
This page took 0.049799 seconds and 6 git commands to generate.