Improve package tangle index for LTTng 2.0 control design
[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.List;
19 import java.util.Set;
20
21 import junit.framework.TestCase;
22
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;
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_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";
74
75 // ------------------------------------------------------------------------
76 // Test data
77 // ------------------------------------------------------------------------
78 private CommandShellFactory fShellFactory;
79 private String fTestfile;
80 private LTTngToolsFileShell fShell;
81 private ILttngControlService fService;
82
83
84 // ------------------------------------------------------------------------
85 // Static methods
86 // ------------------------------------------------------------------------
87
88 // ------------------------------------------------------------------------
89 // Housekeeping
90 // ------------------------------------------------------------------------
91 /**
92 * Perform pre-test initialization.
93 *
94 * @throws Exception if the initialization fails for some reason
95 *
96 */
97 @Override
98 public void setUp() throws Exception {
99 super.setUp();
100 fShellFactory = CommandShellFactory.getInstance();
101
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();
105
106 fShell = fShellFactory.getFileShell();
107 fShell.loadScenarioFile(fTestfile);
108 fService = new LTTngControlService(fShell);
109 }
110
111 /**
112 * Perform post-test clean-up.
113 *
114 * @throws Exception if the clean-up fails for some reason
115 *
116 */
117 @Override
118 public void tearDown() throws Exception {
119 }
120
121 // ------------------------------------------------------------------------
122 // Test Cases
123 // ------------------------------------------------------------------------
124
125 public void testVersion() {
126 try {
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);
133 }
134 }
135
136 public void testUnsupportedVersion() {
137 try {
138 fShell.setScenario(SCEN_LTTNG_UNSUPPORTED_VERSION);
139 LTTngControlServiceFactory.getInstance().getLttngControlService(fShell);
140 fail("No exeption thrown");
141 } catch (ExecutionException e) {
142 // success
143 }
144 }
145
146 public void testNoVersion() {
147 try {
148 fShell.setScenario(SCEN_LTTNG_NO_VERSION);
149 LTTngControlServiceFactory.getInstance().getLttngControlService(fShell);
150 fail("No exeption thrown");
151 } catch (ExecutionException e) {
152 // success
153 }
154 }
155
156 public void testLttngNotInstalled() {
157 try {
158 fShell.setScenario(SCEN_LTTNG_NOT_INSTALLED);
159 fService.getSessionNames(new NullProgressMonitor());
160 fail("No exeption thrown");
161 } catch (ExecutionException e) {
162 // success
163 }
164 }
165
166 public void testGetSessionNames1() {
167 try {
168 fShell.setScenario(SCEN_NO_SESSION_AVAILABLE);
169 String[] result = fService.getSessionNames(new NullProgressMonitor());
170
171 assertNotNull(result);
172 assertEquals(0, result.length);
173
174 } catch (ExecutionException e) {
175 fail(e.toString());
176 }
177 }
178
179 public void testGetSessionNames2() {
180 try {
181 fShell.setScenario(SCEN_GET_SESSION_NAMES1);
182 String[] result = fService.getSessionNames(new NullProgressMonitor());
183
184 assertNotNull(result);
185 assertEquals(2, result.length);
186 assertEquals("mysession1", result[0]);
187 assertEquals("mysession", result[1]);
188
189 } catch (ExecutionException e) {
190 fail(e.toString());
191 }
192 }
193
194 public void testGetSessionNotExist() {
195 try {
196 fShell.setScenario(SCEN_GET_SESSION_NAME_NOT_EXIST);
197 fService.getSessionNames(new NullProgressMonitor());
198 fail("No exeption thrown");
199
200 } catch (ExecutionException e) {
201 // success
202 }
203 }
204
205 public void testGetSessionNameGarbage() {
206 try {
207 fShell.setScenario(SCEN_GET_SESSION_GARBAGE_OUT);
208 String[] result = fService.getSessionNames(new NullProgressMonitor());
209
210 assertNotNull(result);
211 assertEquals(0, result.length);
212
213 } catch (ExecutionException e) {
214 fail(e.toString());
215 }
216 }
217
218 public void testGetSession1() {
219 try {
220 fShell.setScenario(SCEN_GET_SESSION1);
221 ISessionInfo session = fService.getSession("mysession", new NullProgressMonitor());
222
223 // Verify Session
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());
228
229 IDomainInfo[] domains = session.getDomains();
230 assertNotNull(domains);
231 assertEquals(2, domains.length);
232
233 // Verify Kernel domain
234 assertEquals("Kernel", domains[0].getName());
235 IChannelInfo[] channels = domains[0].getChannels();
236 assertNotNull(channels);
237 assertEquals(2, channels.length);
238
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());
248
249 // Verify event info
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());
257
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());
262
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());
272
273 // Verify event info
274 IEventInfo[] channel1Events = channels[1].getEvents();
275 assertEquals(0, channel1Events.length);
276
277 // Verify domain UST global
278 assertEquals("UST global", domains[1].getName());
279
280 IChannelInfo[] ustChannels = domains[1].getChannels();
281
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());
291
292 // Verify event info
293 IEventInfo[] ustEvents = ustChannels[0].getEvents();
294 assertEquals(0, ustEvents.length);
295
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());
305
306 // Verify event info
307 ustEvents = ustChannels[1].getEvents();
308 assertEquals(2, ustEvents.length);
309
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());
314
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());
319
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());
326
327 domains = session.getDomains();
328 assertNotNull(domains);
329 assertEquals(0, domains.length);
330 } catch (ExecutionException e) {
331 fail(e.toString());
332 }
333 }
334
335 public void testGetKernelProvider() {
336 try {
337 fShell.setScenario(SCEN_GET_KERNEL_PROVIDER1);
338 List<IBaseEventInfo> events = fService.getKernelProvider(new NullProgressMonitor());
339
340 // Verify event info
341 assertNotNull(events);
342 assertEquals(3, events.size());
343
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());
349
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());
354
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());
359
360 } catch (ExecutionException e) {
361 fail(e.toString());
362 }
363 }
364
365 public void testGetUstProvider() {
366 try {
367 fShell.setScenario(SCEN_GET_UST_PROVIDER1);
368 List<IUstProviderInfo> providers = fService.getUstProvider();
369
370 // Check all providers
371 assertNotNull(providers);
372 assertEquals(2, providers.size());
373
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());
377
378 // Verify event info
379 IBaseEventInfo[] events = providers.get(0).getEvents();
380 assertNotNull(events);
381 assertEquals(2, events.length);
382
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());
388
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());
393
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());
397
398 // Verify event info
399 events = providers.get(1).getEvents();
400 assertNotNull(events);
401 assertEquals(2, events.length);
402
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());
408
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());
413
414 } catch (ExecutionException e) {
415 fail(e.toString());
416 }
417 }
418
419 public void testUstProvider2() {
420 try {
421 fShell.setScenario(SCEN_GET_UST_PROVIDER2);
422 List<IUstProviderInfo> providers = fService.getUstProvider();
423
424 assertNotNull(providers);
425 assertEquals(0, providers.size());
426
427 } catch (ExecutionException e) {
428 fail(e.toString());
429 }
430 }
431
432 public void testCreateSession() {
433 try {
434 fShell.setScenario(SCEN_CREATE_SESSION1);
435
436 ISessionInfo info = fService.createSession("mysession2", null, new NullProgressMonitor());
437 assertNotNull(info);
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) {
443 fail(e.toString());
444 }
445 }
446
447 public void testCreateSessionVariants() {
448
449 fShell.setScenario(SCEN_CREATE_SESSION_VARIANTS);
450
451 try {
452 fService.createSession("alreadyExist", null, new NullProgressMonitor());
453 fail("No exeption thrown");
454 } catch (ExecutionException e) {
455 // success
456 }
457
458 try {
459 fService.createSession("wrongName", null, new NullProgressMonitor());
460 fail("No exeption thrown");
461 } catch (ExecutionException e) {
462 // success
463 }
464
465 try {
466 fService.createSession("withPath", "/home/user/hallo", new NullProgressMonitor());
467 fail("No exeption thrown");
468 } catch (ExecutionException e) {
469 // success
470 }
471
472 try {
473 ISessionInfo info = fService.createSession("session with spaces", null, new NullProgressMonitor());
474 assertNotNull(info);
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());
479
480 } catch (ExecutionException e) {
481 fail(e.toString());
482 }
483
484 try {
485 ISessionInfo info = fService.createSession("pathWithSpaces", "/home/user/hallo user/here", new NullProgressMonitor());
486 assertNotNull(info);
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());
491
492 } catch (ExecutionException e) {
493 fail(e.toString());
494 }
495 }
496
497 public void testDestroySession() {
498 try {
499 fShell.setScenario(SCEN_DESTROY_SESSION1);
500 fService.destroySession("mysession2", new NullProgressMonitor());
501 } catch (ExecutionException e) {
502 fail(e.toString());
503 }
504 }
505
506 public void testCreateChannel() {
507 try {
508
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);
515
516 fShell.setScenario(SCEN_CHANNEL_HANDLING);
517
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());
526
527 // Create/enable/configure 1 UST channel
528 list.clear();
529 list.add("ustChannel");
530
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());
538
539 } catch (ExecutionException e) {
540 fail(e.toString());
541 }
542 }
543
544 public void testDisableChannel() {
545 try {
546
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);
553
554 fShell.setScenario(SCEN_CHANNEL_HANDLING);
555 fService.disableChannels(sessionName, list, true, new NullProgressMonitor());
556
557 list.clear();
558 list.add("ustChannel");
559 fService.disableChannels(sessionName, list, false, new NullProgressMonitor());
560
561 } catch (ExecutionException e) {
562 fail(e.toString());
563 }
564 }
565
566 public void testEnableChannel() {
567 try {
568
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);
575
576 fShell.setScenario(SCEN_CHANNEL_HANDLING);
577 fService.enableChannels(sessionName, list, true, null, new NullProgressMonitor());
578
579 // Create/enable/configure 1 UST channel
580 list.clear();
581 list.add("ustChannel");
582
583 fService.enableChannels(sessionName, list, false, null, new NullProgressMonitor());
584
585 } catch (ExecutionException e) {
586 fail(e.toString());
587 }
588 }
589
590 // public void tesEnableChannelNoTracer() {
591 // try {
592 // ILttngControlService service = new LTTngControlService(fShellFactory.getShellForChannelNoTracer());
593 // service.getSessionNames(new NullProgressMonitor());
594 // fail("No exeption thrown");
595 //
596 // } catch (ExecutionException e) {
597 // // success
598 // }
599 // }
600
601 public void testEnableEvents() {
602 try {
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());
614
615 // 2) session name, channel=mychannel, event name= null, kernel
616 String channelName = "mychannel";
617 fService.enableEvents(sessionName, channelName, null, true, new NullProgressMonitor());
618
619 // 3) session name, channel=mychannel, 1 event name, ust
620 String ustEventName = "ust_tests_hello:tptest_sighandler";
621 list.clear();
622 list.add(ustEventName);
623 fService.enableEvents(sessionName, channelName, list, false, new NullProgressMonitor());
624
625 // 4) session name, channel = mychannel, no event name, ust
626 list.clear();
627 fService.enableEvents(sessionName, channelName, list, false, new NullProgressMonitor());
628
629 } catch (ExecutionException e) {
630 fail(e.toString());
631 }
632 }
633
634 public void testEnableSyscalls() {
635 try {
636 // 1) session name, channel = null, 3 event names, kernel
637 String sessionName = "mysession2";
638 String channelName = "mychannel";
639
640 fShell.setScenario(SCEN_EVENT_HANDLING);
641
642 // 1) session name, channel = null
643 fService.enableSyscalls(sessionName, null, new NullProgressMonitor());
644
645 // 2) session name, channel = mychannel
646 fService.enableSyscalls(sessionName, channelName, new NullProgressMonitor());
647
648 } catch (ExecutionException e) {
649 fail(e.toString());
650 }
651 }
652
653 public void testDynamicProbe() {
654 try {
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";
662
663 fShell.setScenario(SCEN_EVENT_HANDLING);
664
665 // 1) session name, channel = null, event name, function probe, probe
666 fService.enableProbe(sessionName, null, eventName0, true, functionProbe, new NullProgressMonitor());
667
668 // 2) session name, channel = mychannel
669 fService.enableProbe(sessionName, channelName, eventName1, false, dynProbe, new NullProgressMonitor());
670
671 } catch (ExecutionException e) {
672 fail(e.toString());
673 }
674 }
675
676 public void testEnableLogLevel() {
677 try {
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";
683
684 fShell.setScenario(SCEN_EVENT_HANDLING);
685
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());
688
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());
691
692 } catch (ExecutionException e) {
693 fail(e.toString());
694 }
695 }
696
697 public void testAddContext() {
698 try {
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");
705 contexts.add("pid");
706
707 fShell.setScenario(SCEN_CONTEXT_HANDLING);
708
709 List<String> availContexts = fService.getContextList(new NullProgressMonitor());
710 assertNotNull(availContexts);
711 assertEquals(12, availContexts.size());
712
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");
727
728 assertTrue(expectedContexts.containsAll(availContexts));
729
730 // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
731 fService.addContexts(sessionName, channelName, eventName, false, contexts, new NullProgressMonitor());
732
733 } catch (ExecutionException e) {
734 fail(e.toString());
735 }
736 }
737
738 public void testAddContextFailure() {
739
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");
746 contexts.add("pid");
747 fShell.setScenario(SCEN_CONTEXT_ERROR_HANDLING);
748 try {
749 fService.getContextList(new NullProgressMonitor());
750 fail("No exeption generated");
751 } catch (ExecutionException e) {
752 // success
753 }
754 try {
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) {
759 // success
760 }
761 }
762
763 public void testCalibrate() {
764 try {
765 fShell.setScenario(SCEN_CALIBRATE_HANDLING);
766 fService.calibrate(true, new NullProgressMonitor());
767
768 } catch (ExecutionException e) {
769 fail(e.toString());
770 }
771 }
772
773 public void testCalibrateFailure() {
774
775 try {
776 fShell.setScenario(SCEN_CALIBRATE_HANDLING);
777 fService.calibrate(false, new NullProgressMonitor());
778 fail("No exeption generated");
779 } catch (ExecutionException e) {
780 // success
781 }
782 }
783
784 }
This page took 0.051233 seconds and 6 git commands to generate.