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