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