lttng: Move plugins to the Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.tracecompass.lttng2.control.ui.tests / src / org / eclipse / linuxtools / lttng2 / control / ui / tests / model / component / TraceControlKernelSessionTests.java
1 /**********************************************************************
2 * Copyright (c) 2012, 2014 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 * Alexandre Montplaisir - Port to JUnit4
12 **********************************************************************/
13
14 package org.eclipse.linuxtools.lttng2.control.ui.tests.model.component;
15
16 import static org.junit.Assert.assertEquals;
17 import static org.junit.Assert.assertNotNull;
18 import static org.junit.Assert.assertNull;
19 import static org.junit.Assert.assertTrue;
20 import static org.junit.Assert.fail;
21
22 import java.io.File;
23 import java.net.URL;
24 import java.util.ArrayList;
25 import java.util.List;
26
27 import org.eclipse.core.runtime.FileLocator;
28 import org.eclipse.core.runtime.Path;
29 import org.eclipse.linuxtools.internal.lttng2.control.stubs.dialogs.AddContextDialogStub;
30 import org.eclipse.linuxtools.internal.lttng2.control.stubs.dialogs.CreateSessionDialogStub;
31 import org.eclipse.linuxtools.internal.lttng2.control.stubs.dialogs.DestroyConfirmDialogStub;
32 import org.eclipse.linuxtools.internal.lttng2.control.stubs.dialogs.EnableChannelDialogStub;
33 import org.eclipse.linuxtools.internal.lttng2.control.stubs.dialogs.EnableEventsDialogStub;
34 import org.eclipse.linuxtools.internal.lttng2.control.stubs.dialogs.GetEventInfoDialogStub;
35 import org.eclipse.linuxtools.internal.lttng2.control.stubs.service.TestRemoteSystemProxy;
36 import org.eclipse.linuxtools.internal.lttng2.control.core.model.TargetNodeState;
37 import org.eclipse.linuxtools.internal.lttng2.control.core.model.TraceChannelOutputType;
38 import org.eclipse.linuxtools.internal.lttng2.control.core.model.TraceEnablement;
39 import org.eclipse.linuxtools.internal.lttng2.control.core.model.TraceEventType;
40 import org.eclipse.linuxtools.internal.lttng2.control.core.model.TraceLogLevel;
41 import org.eclipse.linuxtools.internal.lttng2.control.core.model.TraceSessionState;
42 import org.eclipse.linuxtools.internal.lttng2.control.core.model.impl.ChannelInfo;
43 import org.eclipse.linuxtools.internal.lttng2.control.ui.views.dialogs.TraceControlDialogFactory;
44 import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.ITraceControlComponent;
45 import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.impl.TargetNodeComponent;
46 import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.impl.TraceChannelComponent;
47 import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.impl.TraceEventComponent;
48 import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.impl.TraceProbeEventComponent;
49 import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.impl.TraceSessionComponent;
50 import org.eclipse.rse.core.RSECorePlugin;
51 import org.eclipse.rse.core.model.IHost;
52 import org.eclipse.rse.core.model.ISystemProfile;
53 import org.eclipse.rse.core.model.ISystemRegistry;
54 import org.junit.After;
55 import org.junit.Before;
56 import org.junit.Test;
57 import org.osgi.framework.FrameworkUtil;
58
59 /**
60 * The class <code>TraceControlKernelSessionTests</code> contains Kernel
61 * session/channel/event handling test cases.
62 */
63 public class TraceControlKernelSessionTests {
64
65 // ------------------------------------------------------------------------
66 // Constants
67 // ------------------------------------------------------------------------
68
69 private static final String TEST_STREAM = "CreateTreeTest.cfg";
70 private static final String SCEN_SCENARIO3_TEST = "Scenario3";
71
72 // ------------------------------------------------------------------------
73 // Test data
74 // ------------------------------------------------------------------------
75
76 private TraceControlTestFacility fFacility;
77 private TestRemoteSystemProxy fProxy;
78 private String fTestFile;
79
80 // ------------------------------------------------------------------------
81 // Housekeeping
82 // ------------------------------------------------------------------------
83
84 /**
85 * Perform pre-test initialization.
86 *
87 * @throws Exception
88 * if the initialization fails for some reason
89 */
90 @Before
91 public void setUp() throws Exception {
92 fFacility = TraceControlTestFacility.getInstance();
93 fFacility.init();
94 fProxy = new TestRemoteSystemProxy();
95 URL location = FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path(TraceControlTestFacility.DIRECTORY + File.separator + TEST_STREAM), null);
96 File testfile = new File(FileLocator.toFileURL(location).toURI());
97 fTestFile = testfile.getAbsolutePath();
98 }
99
100 /**
101 * Perform post-test clean-up.
102 */
103 @After
104 public void tearDown() {
105 fFacility.waitForJobs();
106 fFacility.dispose();
107 }
108
109 /**
110 * Run the TraceControlComponent.
111 *
112 * @throws Exception
113 * Would fail the test
114 */
115 @Test
116 public void testTraceSessionTree() throws Exception {
117
118 fProxy.setTestFile(fTestFile);
119 fProxy.setScenario(TraceControlTestFacility.SCEN_INIT_TEST);
120
121 ITraceControlComponent root = fFacility.getControlView().getTraceControlRoot();
122
123 ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
124 ISystemProfile profile = registry.createSystemProfile("myProfile", true);
125 IHost host = registry.createLocalHost(profile, "myProfile", "user");
126
127 TargetNodeComponent node = new TargetNodeComponent("myNode", root, host, fProxy);
128
129 root.addChild(node);
130 fFacility.waitForJobs();
131
132 fFacility.executeCommand(node, "connect");
133 int i = 0;
134 while ((i < 10) && (node.getTargetNodeState() != TargetNodeState.CONNECTED)) {
135 i++;
136 fFacility.delay(TraceControlTestFacility.GUI_REFESH_DELAY);
137 }
138
139 // Verify that node is connected
140 assertEquals(TargetNodeState.CONNECTED, node.getTargetNodeState());
141
142 // Get provider groups
143 ITraceControlComponent[] groups = node.getChildren();
144 assertNotNull(groups);
145 assertEquals(2, groups.length);
146
147 // Initialize dialog implementations for command execution
148 TraceControlDialogFactory.getInstance().setCreateSessionDialog(new CreateSessionDialogStub());
149 TraceControlDialogFactory.getInstance().setGetEventInfoDialog(new GetEventInfoDialogStub());
150 TraceControlDialogFactory.getInstance().setConfirmDialog(new DestroyConfirmDialogStub());
151
152 // Initialize session handling scenario
153 fProxy.setScenario(TraceControlTestFacility.SCEN_SCENARIO_SESSION_HANDLING);
154
155 // ------------------------------------------------------------------------
156 // Create session
157 // ------------------------------------------------------------------------
158 TraceSessionComponent session = fFacility.createSession(groups[1]);
159
160 // Verify that session was created
161 assertNotNull(session);
162 assertEquals("mysession", session.getName());
163 assertEquals("/home/user/lttng-traces/mysession-20120314-132824", session.getSessionPath());
164 assertEquals(TraceSessionState.INACTIVE, session.getSessionState());
165
166 // Initialize scenario
167 fProxy.setScenario(SCEN_SCENARIO3_TEST);
168
169 // ------------------------------------------------------------------------
170 // Enable channel on session
171 // ------------------------------------------------------------------------
172 EnableChannelDialogStub channelStub = new EnableChannelDialogStub();
173 channelStub.setIsKernel(true);
174 TraceControlDialogFactory.getInstance().setEnableChannelDialog(channelStub);
175
176 fFacility.executeCommand(session, "enableChannelOnSession");
177
178 // Verify that Kernel domain was created
179 ITraceControlComponent[] domains = session.getChildren();
180 assertNotNull(domains);
181 assertEquals(1, domains.length);
182
183 assertEquals("Kernel", domains[0].getName());
184
185 // Verify that channel was created with correct data
186 ITraceControlComponent[] channels = domains[0].getChildren();
187 assertNotNull(channels);
188 assertEquals(1, channels.length);
189
190 assertTrue(channels[0] instanceof TraceChannelComponent);
191 TraceChannelComponent channel = (TraceChannelComponent) channels[0];
192 assertEquals("mychannel", channel.getName());
193 assertEquals(4, channel.getNumberOfSubBuffers());
194 assertEquals("splice()", channel.getOutputType().getInName());
195 assertEquals(TraceChannelOutputType.SPLICE, channel.getOutputType());
196 assertEquals(true, channel.isOverwriteMode());
197 assertEquals(200, channel.getReadTimer());
198 assertEquals(TraceEnablement.ENABLED, channel.getState());
199 assertEquals(16384, channel.getSubBufferSize());
200 assertEquals(100, channel.getSwitchTimer());
201
202 // ------------------------------------------------------------------------
203 // Create channel on domain
204 // ------------------------------------------------------------------------
205 ChannelInfo info = (ChannelInfo)channelStub.getChannelInfo();
206 info.setName("mychannel2");
207 info.setOverwriteMode(false);
208 info.setSubBufferSize(32768);
209 info.setNumberOfSubBuffers(2);
210 info.setSwitchTimer(100);
211 info.setReadTimer(200);
212 channelStub.setChannelInfo(info);
213
214 fFacility.executeCommand(domains[0], "enableChannelOnDomain");
215
216 // Get Kernel domain component instance
217 domains = session.getChildren();
218 assertNotNull(domains);
219 assertEquals(1, domains.length);
220
221 // Verify that channel was created with correct data
222 channels = domains[0].getChildren();
223 assertNotNull(channels);
224 assertEquals(2, channels.length);
225
226 assertTrue(channels[1] instanceof TraceChannelComponent);
227 channel = (TraceChannelComponent) channels[1];
228 assertEquals("mychannel2", channel.getName());
229 assertEquals(2, channel.getNumberOfSubBuffers());
230 assertEquals("splice()", channel.getOutputType().getInName());
231 assertEquals(TraceChannelOutputType.SPLICE, channel.getOutputType());
232 assertEquals(false, channel.isOverwriteMode());
233 assertEquals(200, channel.getReadTimer());
234 assertEquals(TraceEnablement.ENABLED, channel.getState());
235 assertEquals(32768, channel.getSubBufferSize());
236 assertEquals(100, channel.getSwitchTimer());
237
238 EnableEventsDialogStub eventsDialogStub = new EnableEventsDialogStub();
239 eventsDialogStub.setIsTracePoints(true);
240 List<String> events = new ArrayList<>();
241 events.add("sched_kthread_stop");
242 events.add("sched_kthread_stop_ret");
243 eventsDialogStub.setNames(events);
244 eventsDialogStub.setIsKernel(true);
245 TraceControlDialogFactory.getInstance().setEnableEventsDialog(eventsDialogStub);
246
247 // ------------------------------------------------------------------------
248 // disable channels
249 // ------------------------------------------------------------------------
250 // Get Kernel domain component instance
251 domains = session.getChildren();
252 assertNotNull(domains);
253 assertEquals(1, domains.length);
254
255 // Verify that channel was created with correct data
256 channels = domains[0].getChildren();
257 assertNotNull(channels);
258 assertEquals(2, channels.length);
259
260 fFacility.executeCommand(channels, "disableChannel");
261
262 assertEquals(TraceEnablement.DISABLED, ((TraceChannelComponent)channels[0]).getState());
263 assertEquals(TraceEnablement.DISABLED, ((TraceChannelComponent)channels[1]).getState());
264
265 // ------------------------------------------------------------------------
266 // enable channels
267 // ------------------------------------------------------------------------
268 // Get Kernel domain component instance
269 domains = session.getChildren();
270 assertNotNull(domains);
271 assertEquals(1, domains.length);
272
273 // Verify that channel was created with correct data
274 channels = domains[0].getChildren();
275 assertNotNull(channels);
276 assertEquals(2, channels.length);
277
278 fFacility.executeCommand(channels, "enableChannel");
279
280 assertEquals(TraceEnablement.ENABLED, ((TraceChannelComponent)channels[0]).getState());
281 assertEquals(TraceEnablement.ENABLED, ((TraceChannelComponent)channels[1]).getState());
282
283 // ------------------------------------------------------------------------
284 // enable event (tracepoints) on session
285 // ------------------------------------------------------------------------
286 fFacility.executeCommand(session, "enableEventOnSession");
287
288 // Get Kernel domain component instance
289 domains = session.getChildren();
290 assertNotNull(domains);
291 assertEquals(1, domains.length);
292
293 // Verify that channel was created with correct data
294 channels = domains[0].getChildren();
295 assertNotNull(channels);
296 assertEquals(3, channels.length);
297
298 assertTrue(channels[2] instanceof TraceChannelComponent);
299 channel = (TraceChannelComponent) channels[2];
300 assertEquals("channel0", channel.getName());
301 // No need to check parameters of default channel because that has been done in other tests
302
303 ITraceControlComponent[] channel0Events = channel.getChildren();
304 assertEquals(2, channel0Events.length);
305
306 assertTrue(channel0Events[0] instanceof TraceEventComponent);
307 assertTrue(channel0Events[1] instanceof TraceEventComponent);
308
309 TraceEventComponent event = (TraceEventComponent) channel0Events[0];
310 assertEquals("sched_kthread_stop_ret", event.getName());
311 assertEquals(TraceLogLevel.TRACE_EMERG, event.getLogLevel());
312 assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
313 assertEquals(TraceEnablement.ENABLED, event.getState());
314
315 event = (TraceEventComponent) channel0Events[1];
316 assertEquals("sched_kthread_stop", event.getName());
317 assertEquals(TraceLogLevel.TRACE_EMERG, event.getLogLevel());
318 assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
319 assertEquals(TraceEnablement.ENABLED, event.getState());
320
321 // ------------------------------------------------------------------------
322 // enable event (tracepoints) on domain
323 // ------------------------------------------------------------------------
324 events.clear();
325 events.add("sched_wakeup_new");
326 eventsDialogStub.setNames(events);
327
328 fFacility.executeCommand(domains[0], "enableEventOnDomain");
329
330 // Get Kernel domain component instance
331 domains = session.getChildren();
332 assertNotNull(domains);
333 assertEquals(1, domains.length);
334
335 // Verify that channel was created with correct data
336 channels = domains[0].getChildren();
337 channel = (TraceChannelComponent) channels[2];
338 // No need to check parameters of default channel because that has been done in other tests
339
340 channel = (TraceChannelComponent) channels[2];
341
342 channel0Events = channel.getChildren();
343 assertEquals(3, channel0Events.length);
344
345 assertTrue(channel0Events[2] instanceof TraceEventComponent);
346
347 event = (TraceEventComponent) channel0Events[2];
348 assertEquals("sched_wakeup_new", event.getName());
349 assertEquals(TraceLogLevel.TRACE_EMERG, event.getLogLevel());
350 assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
351 assertEquals(TraceEnablement.ENABLED, event.getState());
352
353 // ------------------------------------------------------------------------
354 // enable event (tracepoints) on channel
355 // ------------------------------------------------------------------------
356 events.clear();
357 eventsDialogStub.setNames(events);
358 eventsDialogStub.setIsAllTracePoints(true);
359
360 fFacility.executeCommand(channels[1], "enableEventOnChannel");
361
362 // Get Kernel domain component instance
363 domains = session.getChildren();
364 assertNotNull(domains);
365 assertEquals(1, domains.length);
366
367 // Verify that channel was created with correct data
368 channels = domains[0].getChildren();
369 // No need to check parameters of default channel because that has been done in other tests
370 channel = (TraceChannelComponent) channels[1];
371
372 channel0Events = channel.getChildren();
373 assertEquals(3, channel0Events.length);
374
375 assertTrue(channel0Events[0] instanceof TraceEventComponent);
376 assertTrue(channel0Events[1] instanceof TraceEventComponent);
377 assertTrue(channel0Events[2] instanceof TraceEventComponent);
378
379 event = (TraceEventComponent) channel0Events[0];
380 assertEquals("sched_kthread_stop_ret", event.getName());
381 assertEquals(TraceLogLevel.TRACE_EMERG, event.getLogLevel());
382 assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
383 assertEquals(TraceEnablement.ENABLED, event.getState());
384
385 event = (TraceEventComponent) channel0Events[1];
386 assertEquals("sched_kthread_stop", event.getName());
387 assertEquals(TraceLogLevel.TRACE_EMERG, event.getLogLevel());
388 assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
389 assertEquals(TraceEnablement.ENABLED, event.getState());
390
391 event = (TraceEventComponent) channel0Events[2];
392 assertEquals("sched_wakeup_new", event.getName());
393 assertEquals(TraceLogLevel.TRACE_EMERG, event.getLogLevel());
394 assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
395 assertEquals(TraceEnablement.ENABLED, event.getState());
396
397 // ------------------------------------------------------------------------
398 // enable event (syscall) on channel
399 // ------------------------------------------------------------------------
400 events.clear();
401 eventsDialogStub.setIsTracePoints(false);
402 eventsDialogStub.setIsAllTracePoints(false);
403 eventsDialogStub.setIsSysCalls(true);
404
405 fFacility.executeCommand(channels[0], "enableEventOnChannel");
406
407 // Get Kernel domain component instance
408 domains = session.getChildren();
409 assertNotNull(domains);
410 assertEquals(1, domains.length);
411
412 // Verify that channel was created with correct data
413 channels = domains[0].getChildren();
414 channel = (TraceChannelComponent) channels[0];
415 // No need to check parameters of default channel because that has been done in other tests
416
417 channel = (TraceChannelComponent) channels[0];
418
419 channel0Events = channel.getChildren();
420 assertEquals(1, channel0Events.length);
421
422 assertTrue(channel0Events[0] instanceof TraceEventComponent);
423
424 event = (TraceEventComponent) channel0Events[0];
425 assertEquals("syscalls", event.getName());
426 assertEquals(TraceLogLevel.LEVEL_UNKNOWN, event.getLogLevel());
427 assertEquals(TraceEventType.SYSCALL, event.getEventType());
428 assertEquals(TraceEnablement.ENABLED, event.getState());
429
430 // ------------------------------------------------------------------------
431 // enable event (syscall) on domain
432 // ------------------------------------------------------------------------
433 fFacility.executeCommand(domains[0], "enableEventOnDomain");
434
435 // Get Kernel domain component instance
436 domains = session.getChildren();
437 assertNotNull(domains);
438 assertEquals(1, domains.length);
439
440 // Verify that channel was created with correct data
441 channels = domains[0].getChildren();
442 channel = (TraceChannelComponent) channels[0];
443 // No need to check parameters of default channel because that has been done in other tests
444
445 channel = (TraceChannelComponent) channels[2];
446
447 channel0Events = channel.getChildren();
448 assertEquals(4, channel0Events.length);
449
450 assertTrue(channel0Events[0] instanceof TraceEventComponent);
451
452 event = (TraceEventComponent) channel0Events[0];
453 assertEquals("syscalls", event.getName());
454 assertEquals(TraceLogLevel.LEVEL_UNKNOWN, event.getLogLevel());
455 assertEquals(TraceEventType.SYSCALL, event.getEventType());
456 assertEquals(TraceEnablement.ENABLED, event.getState());
457
458 // ------------------------------------------------------------------------
459 // enable event (syscall) on session
460 // ------------------------------------------------------------------------
461 fFacility.executeCommand(session, "enableEventOnSession");
462
463 // Get Kernel domain component instance
464 domains = session.getChildren();
465 assertNotNull(domains);
466 assertEquals(1, domains.length);
467
468 // Verify that channel was created with correct data
469 channels = domains[0].getChildren();
470 channel = (TraceChannelComponent) channels[0];
471 // No need to check parameters of default channel because that has been done in other tests
472
473 channel = (TraceChannelComponent) channels[2];
474
475 channel0Events = channel.getChildren();
476 assertEquals(4, channel0Events.length);
477
478 assertTrue(channel0Events[0] instanceof TraceEventComponent);
479
480 event = (TraceEventComponent) channel0Events[0];
481 assertEquals("syscalls", event.getName());
482 assertEquals(TraceLogLevel.LEVEL_UNKNOWN, event.getLogLevel());
483 assertEquals(TraceEventType.SYSCALL, event.getEventType());
484 assertEquals(TraceEnablement.ENABLED, event.getState());
485
486
487 // ------------------------------------------------------------------------
488 // enable event (dynamic probe) on domain
489 // ------------------------------------------------------------------------
490 events.clear();
491 eventsDialogStub.setIsSysCalls(false);
492 eventsDialogStub.setIsDynamicProbe(true);
493 eventsDialogStub.setDynamicProbe("0xc0101280");
494 eventsDialogStub.setProbeEventName("myevent1");
495
496 fFacility.executeCommand(domains[0], "enableEventOnDomain");
497
498 // Get Kernel domain component instance
499 domains = session.getChildren();
500 assertNotNull(domains);
501 assertEquals(1, domains.length);
502
503 // Verify that channel was created with correct data
504 channels = domains[0].getChildren();
505 channel = (TraceChannelComponent) channels[2];
506 // No need to check parameters of default channel because that has been done in other tests
507
508 channel0Events = channel.getChildren();
509 assertEquals(5, channel0Events.length);
510
511 assertTrue(channel0Events[0] instanceof TraceProbeEventComponent);
512
513 TraceProbeEventComponent probeEvent = (TraceProbeEventComponent) channel0Events[0];
514 assertEquals("myevent1", probeEvent.getName());
515 assertEquals(TraceLogLevel.LEVEL_UNKNOWN, probeEvent.getLogLevel());
516 assertEquals(TraceEventType.PROBE, probeEvent.getEventType());
517 assertEquals(TraceEnablement.ENABLED, probeEvent.getState());
518 assertNull(probeEvent.getOffset());
519 assertEquals("0xc0101280", probeEvent.getAddress());
520 assertNull(probeEvent.getSymbol());
521
522 // ------------------------------------------------------------------------
523 // enable event (dynamic probe) on channel
524 // ------------------------------------------------------------------------
525 eventsDialogStub.setIsDynamicProbe(true);
526 eventsDialogStub.setDynamicProbe("init_post");
527 eventsDialogStub.setProbeEventName("myevent2");
528
529 fFacility.executeCommand(channels[2], "enableEventOnChannel");
530
531 // Get Kernel domain component instance
532 domains = session.getChildren();
533 assertNotNull(domains);
534 assertEquals(1, domains.length);
535
536 // Verify that channel was created with correct data
537 channels = domains[0].getChildren();
538 channel = (TraceChannelComponent) channels[2];
539 // No need to check parameters of default channel because that has been done in other tests
540
541 channel0Events = channel.getChildren();
542 assertEquals(6, channel0Events.length);
543
544 assertTrue(channel0Events[0] instanceof TraceProbeEventComponent);
545
546 probeEvent = (TraceProbeEventComponent) channel0Events[0];
547 assertEquals("myevent2", probeEvent.getName());
548 assertEquals(TraceLogLevel.LEVEL_UNKNOWN, probeEvent.getLogLevel());
549 assertEquals(TraceEventType.PROBE, probeEvent.getEventType());
550 assertEquals(TraceEnablement.ENABLED, probeEvent.getState());
551 assertEquals("0x0", probeEvent.getOffset());
552 assertNull(null, probeEvent.getAddress());
553 assertEquals("init_post", probeEvent.getSymbol());
554
555 // ------------------------------------------------------------------------
556 // enable event (dynamic probe) on session
557 // ------------------------------------------------------------------------
558 eventsDialogStub.setIsDynamicProbe(true);
559 eventsDialogStub.setDynamicProbe("init_post:0x1000");
560 eventsDialogStub.setProbeEventName("myevent3");
561
562 fFacility.executeCommand(session, "enableEventOnSession");
563
564 // Get Kernel domain component instance
565 domains = session.getChildren();
566 assertNotNull(domains);
567 assertEquals(1, domains.length);
568
569 // Verify that channel was created with correct data
570 channels = domains[0].getChildren();
571 channel = (TraceChannelComponent) channels[2];
572 // No need to check parameters of default channel because that has been done in other tests
573
574 channel0Events = channel.getChildren();
575 assertEquals(7, channel0Events.length);
576
577 assertTrue(channel0Events[0] instanceof TraceProbeEventComponent);
578
579 probeEvent = (TraceProbeEventComponent) channel0Events[0];
580 assertEquals("myevent3", probeEvent.getName());
581 assertEquals(TraceLogLevel.LEVEL_UNKNOWN, probeEvent.getLogLevel());
582 assertEquals(TraceEventType.PROBE, probeEvent.getEventType());
583 assertEquals(TraceEnablement.ENABLED, probeEvent.getState());
584 assertEquals("0x1000", probeEvent.getOffset());
585 assertNull(null, probeEvent.getAddress());
586 assertEquals("init_post", probeEvent.getSymbol());
587
588 // ------------------------------------------------------------------------
589 // enable event (dynamic function probe) on session
590 // ------------------------------------------------------------------------
591 eventsDialogStub.setIsDynamicProbe(false);
592 eventsDialogStub.setDynamicProbe(null);
593 eventsDialogStub.setProbeEventName(null);
594 eventsDialogStub.setIsFunctionProbe(true);
595 eventsDialogStub.setFunctionEventName("myevent4");
596 eventsDialogStub.setFunctionProbe("create_dev");
597
598 fFacility.executeCommand(session, "enableEventOnSession");
599
600 // Get Kernel domain component instance
601 domains = session.getChildren();
602 assertNotNull(domains);
603 assertEquals(1, domains.length);
604
605 // Verify that channel was created with correct data
606 channels = domains[0].getChildren();
607 channel = (TraceChannelComponent) channels[2];
608 // No need to check parameters of default channel because that has been done in other tests
609
610 channel0Events = channel.getChildren();
611 assertEquals(8, channel0Events.length);
612
613 assertTrue(channel0Events[0] instanceof TraceProbeEventComponent);
614
615 probeEvent = (TraceProbeEventComponent) channel0Events[0];
616 assertEquals("myevent4", probeEvent.getName());
617 assertEquals(TraceLogLevel.LEVEL_UNKNOWN, probeEvent.getLogLevel());
618 // Changed for Bug fix 419454 to function event which was introduced by LTTng 2.2
619 assertEquals(TraceEventType.FUNCTION, probeEvent.getEventType());
620 assertEquals(TraceEnablement.ENABLED, probeEvent.getState());
621 assertEquals("0x0", probeEvent.getOffset());
622 assertNull(null, probeEvent.getAddress());
623 assertEquals("create_dev", probeEvent.getSymbol());
624
625 // ------------------------------------------------------------------------
626 // enable event (dynamic function probe) on domain
627 // ------------------------------------------------------------------------
628 eventsDialogStub.setIsFunctionProbe(true);
629 eventsDialogStub.setFunctionEventName("myevent5");
630 eventsDialogStub.setFunctionProbe("create_dev:0x2000");
631
632 fFacility.executeCommand(domains[0], "enableEventOnDomain");
633
634 // Get Kernel domain component instance
635 domains = session.getChildren();
636 assertNotNull(domains);
637 assertEquals(1, domains.length);
638
639 // Verify that channel was created with correct data
640 channels = domains[0].getChildren();
641 channel = (TraceChannelComponent) channels[2];
642 // No need to check parameters of default channel because that has been done in other tests
643
644 channel0Events = channel.getChildren();
645 assertEquals(9, channel0Events.length);
646
647 assertTrue(channel0Events[0] instanceof TraceProbeEventComponent);
648
649 probeEvent = (TraceProbeEventComponent) channel0Events[0];
650 assertEquals("myevent5", probeEvent.getName());
651 assertEquals(TraceLogLevel.LEVEL_UNKNOWN, probeEvent.getLogLevel());
652 assertEquals(TraceEventType.PROBE, probeEvent.getEventType());
653 assertEquals(TraceEnablement.ENABLED, probeEvent.getState());
654 assertEquals("0x2000", probeEvent.getOffset());
655 assertNull(null, probeEvent.getAddress());
656 assertEquals("create_dev", probeEvent.getSymbol());
657
658 // ------------------------------------------------------------------------
659 // enable event (dynamic function probe) on channel
660 // ------------------------------------------------------------------------
661 eventsDialogStub.setIsFunctionProbe(true);
662 eventsDialogStub.setFunctionEventName("myevent");
663 eventsDialogStub.setFunctionProbe("create_dev:0x2000");
664
665 fFacility.executeCommand(channels[0], "enableEventOnChannel");
666
667 // Get Kernel domain component instance
668 domains = session.getChildren();
669 assertNotNull(domains);
670 assertEquals(1, domains.length);
671
672 // Verify that channel was created with correct data
673 channels = domains[0].getChildren();
674 channel = (TraceChannelComponent) channels[0];
675 // No need to check parameters of default channel because that has been done in other tests
676
677 channel0Events = channel.getChildren();
678 assertEquals(2, channel0Events.length);
679
680 assertTrue(channel0Events[0] instanceof TraceProbeEventComponent);
681
682 probeEvent = (TraceProbeEventComponent) channel0Events[0];
683 assertEquals("myevent", probeEvent.getName());
684 assertEquals(TraceLogLevel.LEVEL_UNKNOWN, probeEvent.getLogLevel());
685 assertEquals(TraceEventType.PROBE, probeEvent.getEventType());
686 assertEquals(TraceEnablement.ENABLED, probeEvent.getState());
687 assertEquals("0x2000", probeEvent.getOffset());
688 assertNull(null, probeEvent.getAddress());
689 assertEquals("create_dev", probeEvent.getSymbol());
690
691 // ------------------------------------------------------------------------
692 // Add Context on domain
693 // ------------------------------------------------------------------------
694 // Get Kernel domain component instance
695 domains = session.getChildren();
696 assertNotNull(domains);
697 assertEquals(1, domains.length);
698
699 AddContextDialogStub addContextStub = new AddContextDialogStub();
700 List<String> contexts = new ArrayList<>();
701 contexts.add("prio");
702 contexts.add("perf:branch-misses");
703 contexts.add("perf:cache-misses");
704 addContextStub.setContexts(contexts);
705 TraceControlDialogFactory.getInstance().setAddContextDialog(addContextStub);
706
707 fFacility.executeCommand(domains[0], "addContextOnDomain");
708 // Currently there is nothing to verify because the list commands don't show any context information
709 // However, the execution of the command make sure that the correct service command line is build and executed.
710
711 // ------------------------------------------------------------------------
712 // Add Context on channel
713 // ------------------------------------------------------------------------
714
715 // Get Kernel domain component instance
716 domains = session.getChildren();
717 assertNotNull(domains);
718 assertEquals(1, domains.length);
719
720 //Verify that channel was created with correct data
721 channels = domains[0].getChildren();
722 channel = (TraceChannelComponent) channels[0];
723
724 try {
725 // The setContext() verifies that the contexts set are part of the available contexts
726 // The available contexts are set by the command handler addContextOnDomain above.
727 // So we indirectly test here that the parsing and setting of available contexts were
728 // done correctly above.
729 addContextStub.setContexts(contexts);
730 } catch (IllegalArgumentException e) {
731 fail("Exception caught - unknown context");
732 }
733
734 fFacility.executeCommand(channel, "addContextOnChannel");
735 // Currently there is nothing to verify because the list commands don't show any context information
736 // However, the execution of the command make sure that the correct service command line is build and executed.
737
738 // ------------------------------------------------------------------------
739 // Add Context on event
740 // ------------------------------------------------------------------------
741 // Get Kernel domain component instance
742 domains = session.getChildren();
743 assertNotNull(domains);
744 assertEquals(1, domains.length);
745
746 //Verify that channel was created with correct data
747 channels = domains[0].getChildren();
748 channel = (TraceChannelComponent) channels[2];
749
750 channel0Events = channel.getChildren();
751
752 event = (TraceEventComponent) channel0Events[6];
753
754 fFacility.executeCommand(event, "addContextOnEvent");
755 // Currently there is nothing to verify because the list commands don't show any context information
756 // However, the execution of the command make sure that the correct service command line is build and executed.
757
758 // ------------------------------------------------------------------------
759 // Calibrate
760 // ------------------------------------------------------------------------
761 // Get Kernel domain component instance
762 domains = session.getChildren();
763 assertNotNull(domains);
764 assertEquals(1, domains.length);
765
766 fFacility.executeCommand(domains[0], "calibrate");
767 // There is nothing to verify here.
768 // However, the execution of the command make sure that the correct service command line is build and executed.
769
770 // ------------------------------------------------------------------------
771 // refresh
772 // ------------------------------------------------------------------------
773 fFacility.executeCommand(node, "refresh");
774 groups = node.getChildren();
775 assertNotNull(groups);
776 assertEquals(2, groups.length);
777 assertEquals(3, groups[0].getChildren().length); // provider
778 assertEquals(1, groups[1].getChildren().length); // sessions
779 assertEquals(1, groups[1].getChildren()[0].getChildren().length); // domains
780 assertEquals(3, groups[1].getChildren()[0].getChildren()[0].getChildren().length); // channels
781 assertEquals(2, groups[1].getChildren()[0].getChildren()[0].getChildren()[0].getChildren().length); // events (of channel[0])
782
783 // Initialize session handling scenario
784 fProxy.setScenario(TraceControlTestFacility.SCEN_SCENARIO_SESSION_HANDLING);
785
786 session = (TraceSessionComponent)groups[1].getChildren()[0];
787
788 // ------------------------------------------------------------------------
789 // start session
790 // ------------------------------------------------------------------------
791 fFacility.startSession(session);
792 assertEquals(TraceSessionState.ACTIVE, session.getSessionState());
793
794 // ------------------------------------------------------------------------
795 // stop session
796 // ------------------------------------------------------------------------
797 fFacility.stopSession(session);
798 assertEquals(TraceSessionState.INACTIVE, session.getSessionState());
799
800 // ------------------------------------------------------------------------
801 // Destroy session
802 // ------------------------------------------------------------------------
803
804 fFacility.destroySession(session);
805
806 // Verify that no more session components exist
807 assertEquals(0, groups[1].getChildren().length);
808
809 //-------------------------------------------------------------------------
810 // Disconnect node
811 //-------------------------------------------------------------------------
812 fFacility.executeCommand(node, "disconnect");
813 assertEquals(TargetNodeState.DISCONNECTED, node.getTargetNodeState());
814
815 //-------------------------------------------------------------------------
816 // Delete node
817 //-------------------------------------------------------------------------
818
819 fFacility.executeCommand(node, "delete");
820 assertEquals(0,fFacility.getControlView().getTraceControlRoot().getChildren().length);
821 }
822
823 }
This page took 0.068303 seconds and 5 git commands to generate.