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