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