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