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