tmf: Make CtfTmfEventField extend TmfEventField
[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
cfdb727a 3 *
a26d90be
BH
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
cfdb727a
AM
8 *
9 * Contributors:
a26d90be
BH
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;
9315aeee
BH
25import org.eclipse.linuxtools.internal.lttng2.core.control.model.TargetNodeState;
26import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEnablement;
27import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEventType;
28import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel;
29import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceSessionState;
30import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.ChannelInfo;
4ea599a5 31import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.AddContextDialogStub;
a26d90be
BH
32import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.CreateSessionDialogStub;
33import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.DestroyConfirmDialogStub;
8577ed1e 34import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.EnableChannelDialogStub;
a26d90be
BH
35import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.EnableEventsDialogStub;
36import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.GetEventInfoDialogStub;
37import org.eclipse.linuxtools.internal.lttng2.stubs.service.TestRemoteSystemProxy;
38import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.TraceControlDialogFactory;
39import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
a26d90be
BH
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
cfdb727a 58@SuppressWarnings({"nls", "javadoc"})
a26d90be 59public class TraceControlKernelSessionTests extends TestCase {
cfdb727a 60
a26d90be
BH
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;
cfdb727a
AM
72 private String fTestFile;
73
a26d90be
BH
74 // ------------------------------------------------------------------------
75 // Static methods
76 // ------------------------------------------------------------------------
77
78 /**
79 * Returns test setup used when executing test case stand-alone.
cfdb727a 80 * @return Test setup class
a26d90be
BH
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 118 }
cfdb727a 119
a26d90be
BH
120 /**
121 * Run the TraceControlComponent.
122 */
123 public void testTraceSessionTree() throws Exception {
cfdb727a 124
a26d90be
BH
125 fProxy.setTestFile(fTestFile);
126 fProxy.setScenario(TraceControlTestFacility.SCEN_INIT_TEST);
cfdb727a 127
a26d90be
BH
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());
cfdb727a 158
a26d90be
BH
159 // Initialize session handling scenario
160 fProxy.setScenario(TraceControlTestFacility.SCEN_SCENARIO_SESSION_HANDLING);
cfdb727a 161
a26d90be
BH
162 // ------------------------------------------------------------------------
163 // Create session
164 // ------------------------------------------------------------------------
165 TraceSessionComponent session = fFacility.createSession(groups[1]);
cfdb727a 166
a26d90be
BH
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);
cfdb727a 175
a26d90be 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");
cfdb727a 184
a26d90be
BH
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());
cfdb727a 191
a26d90be
BH
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);
cfdb727a 198 TraceChannelComponent channel = (TraceChannelComponent) channels[0];
a26d90be
BH
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);
cfdb727a 219
d62bfa55 220 fFacility.executeCommand(domains[0], "enableChannelOnDomain");
cfdb727a 221
a26d90be
BH
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);
cfdb727a 233 channel = (TraceChannelComponent) channels[1];
a26d90be
BH
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);
cfdb727a 251
a26d90be 252 // ------------------------------------------------------------------------
cfdb727a 253 // disable channels
a26d90be
BH
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");
cfdb727a 266
a26d90be
BH
267 assertEquals(TraceEnablement.DISABLED, ((TraceChannelComponent)channels[0]).getState());
268 assertEquals(TraceEnablement.DISABLED, ((TraceChannelComponent)channels[1]).getState());
269
270 // ------------------------------------------------------------------------
cfdb727a 271 // enable channels
a26d90be
BH
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);
cfdb727a 282
a26d90be 283 fFacility.executeCommand(channels, "enableChannel");
cfdb727a 284
a26d90be
BH
285 assertEquals(TraceEnablement.ENABLED, ((TraceChannelComponent)channels[0]).getState());
286 assertEquals(TraceEnablement.ENABLED, ((TraceChannelComponent)channels[1]).getState());
287
288 // ------------------------------------------------------------------------
cfdb727a 289 // enable event (tracepoints) on session
a26d90be
BH
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);
cfdb727a 304 channel = (TraceChannelComponent) channels[2];
a26d90be
BH
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);
cfdb727a 310
a26d90be
BH
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 // ------------------------------------------------------------------------
cfdb727a 327 // enable event (tracepoints) on domain
a26d90be
BH
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();
cfdb727a 342 channel = (TraceChannelComponent) channels[2];
a26d90be
BH
343 // No need to check parameters of default channel because that has been done in other tests
344
345 channel = (TraceChannelComponent) channels[2];
cfdb727a 346
a26d90be
BH
347 channel0Events = channel.getChildren();
348 assertEquals(3, channel0Events.length);
cfdb727a 349
a26d90be
BH
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 // ------------------------------------------------------------------------
cfdb727a 359 // enable event (tracepoints) on channel
a26d90be
BH
360 // ------------------------------------------------------------------------
361 events.clear();
362 eventsDialogStub.setNames(events);
363 eventsDialogStub.setIsAllTracePoints(true);
364
365 fFacility.executeCommand(channels[1], "enableEventOnChannel");
cfdb727a 366
a26d90be
BH
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];
cfdb727a 376
a26d90be
BH
377 channel0Events = channel.getChildren();
378 assertEquals(3, channel0Events.length);
cfdb727a 379
a26d90be
BH
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());
cfdb727a 395
a26d90be
BH
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 // ------------------------------------------------------------------------
cfdb727a 403 // enable event (syscall) on channel
a26d90be
BH
404 // ------------------------------------------------------------------------
405 events.clear();
cfdb727a 406 eventsDialogStub.setIsTracePoints(false);
a26d90be
BH
407 eventsDialogStub.setIsAllTracePoints(false);
408 eventsDialogStub.setIsSysCalls(true);
409
410 fFacility.executeCommand(channels[0], "enableEventOnChannel");
cfdb727a 411
a26d90be
BH
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();
cfdb727a 419 channel = (TraceChannelComponent) channels[0];
a26d90be
BH
420 // No need to check parameters of default channel because that has been done in other tests
421
422 channel = (TraceChannelComponent) channels[0];
cfdb727a 423
a26d90be
BH
424 channel0Events = channel.getChildren();
425 assertEquals(1, channel0Events.length);
cfdb727a 426
a26d90be 427 assertTrue(channel0Events[0] instanceof TraceEventComponent);
cfdb727a 428
a26d90be
BH
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 // ------------------------------------------------------------------------
cfdb727a 436 // enable event (syscall) on domain
a26d90be
BH
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();
cfdb727a 447 channel = (TraceChannelComponent) channels[0];
a26d90be
BH
448 // No need to check parameters of default channel because that has been done in other tests
449
450 channel = (TraceChannelComponent) channels[2];
cfdb727a 451
a26d90be
BH
452 channel0Events = channel.getChildren();
453 assertEquals(4, channel0Events.length);
cfdb727a 454
a26d90be 455 assertTrue(channel0Events[0] instanceof TraceEventComponent);
cfdb727a 456
a26d90be
BH
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 // ------------------------------------------------------------------------
cfdb727a 464 // enable event (syscall) on session
a26d90be
BH
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();
cfdb727a 475 channel = (TraceChannelComponent) channels[0];
a26d90be
BH
476 // No need to check parameters of default channel because that has been done in other tests
477
478 channel = (TraceChannelComponent) channels[2];
cfdb727a 479
a26d90be
BH
480 channel0Events = channel.getChildren();
481 assertEquals(4, channel0Events.length);
cfdb727a 482
a26d90be 483 assertTrue(channel0Events[0] instanceof TraceEventComponent);
cfdb727a 484
a26d90be
BH
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
cfdb727a 491
a26d90be 492 // ------------------------------------------------------------------------
cfdb727a 493 // enable event (dynamic probe) on domain
a26d90be
BH
494 // ------------------------------------------------------------------------
495 events.clear();
496 eventsDialogStub.setIsSysCalls(false);
497 eventsDialogStub.setIsDynamicProbe(true);
498 eventsDialogStub.setDynamicProbe("0xc0101280");
499 eventsDialogStub.setProbeEventName("myevent1");
cfdb727a 500
a26d90be 501 fFacility.executeCommand(domains[0], "enableEventOnDomain");
cfdb727a 502
a26d90be
BH
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();
cfdb727a 510 channel = (TraceChannelComponent) channels[2];
a26d90be
BH
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);
cfdb727a 515
a26d90be 516 assertTrue(channel0Events[0] instanceof TraceProbeEventComponent);
cfdb727a 517
a26d90be
BH
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 // ------------------------------------------------------------------------
cfdb727a 528 // enable event (dynamic probe) on channel
a26d90be
BH
529 // ------------------------------------------------------------------------
530 eventsDialogStub.setIsDynamicProbe(true);
531 eventsDialogStub.setDynamicProbe("init_post");
532 eventsDialogStub.setProbeEventName("myevent2");
533
534 fFacility.executeCommand(channels[2], "enableEventOnChannel");
cfdb727a 535
a26d90be
BH
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();
cfdb727a 543 channel = (TraceChannelComponent) channels[2];
a26d90be
BH
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);
cfdb727a 548
a26d90be 549 assertTrue(channel0Events[0] instanceof TraceProbeEventComponent);
cfdb727a 550
a26d90be
BH
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 // ------------------------------------------------------------------------
cfdb727a 561 // enable event (dynamic probe) on session
a26d90be
BH
562 // ------------------------------------------------------------------------
563 eventsDialogStub.setIsDynamicProbe(true);
564 eventsDialogStub.setDynamicProbe("init_post:0x1000");
565 eventsDialogStub.setProbeEventName("myevent3");
566
567 fFacility.executeCommand(session, "enableEventOnSession");
cfdb727a 568
a26d90be
BH
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();
cfdb727a 576 channel = (TraceChannelComponent) channels[2];
a26d90be
BH
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());
cfdb727a 592
a26d90be
BH
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");
cfdb727a 604
a26d90be
BH
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();
cfdb727a 612 channel = (TraceChannelComponent) channels[2];
a26d90be
BH
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());
cfdb727a 628
a26d90be
BH
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");
cfdb727a 637
a26d90be
BH
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();
cfdb727a 645 channel = (TraceChannelComponent) channels[2];
a26d90be
BH
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");
cfdb727a 670
a26d90be
BH
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();
cfdb727a 678 channel = (TraceChannelComponent) channels[0];
a26d90be
BH
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 // ------------------------------------------------------------------------
cfdb727a 696 // Add Context on domain
4ea599a5
BH
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);
cfdb727a 710
4ea599a5
BH
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 // ------------------------------------------------------------------------
cfdb727a 716 // Add Context on channel
4ea599a5
BH
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();
cfdb727a
AM
726 channel = (TraceChannelComponent) channels[0];
727
4ea599a5
BH
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.
cfdb727a 741
4ea599a5 742 // ------------------------------------------------------------------------
cfdb727a 743 // Add Context on event
4ea599a5
BH
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();
cfdb727a
AM
752 channel = (TraceChannelComponent) channels[2];
753
4ea599a5
BH
754 channel0Events = channel.getChildren();
755
756 event = (TraceEventComponent) channel0Events[6];
cfdb727a 757
4ea599a5
BH
758 fFacility.executeCommand(event, "addContextOnEvent");
759 // Currently there is nothing to verify because the list commands don't show any context information
cfdb727a 760 // However, the execution of the command make sure that the correct service command line is build and executed.
4ea599a5
BH
761
762 // ------------------------------------------------------------------------
cfdb727a 763 // Calibrate
4ea599a5
BH
764 // ------------------------------------------------------------------------
765 // Get Kernel domain component instance
766 domains = session.getChildren();
767 assertNotNull(domains);
768 assertEquals(1, domains.length);
cfdb727a 769
4ea599a5 770 fFacility.executeCommand(domains[0], "calibrate");
cfdb727a 771 // There is nothing to verify here.
4ea599a5 772 // However, the execution of the command make sure that the correct service command line is build and executed.
cfdb727a 773
a26d90be 774 // ------------------------------------------------------------------------
cfdb727a 775 // refresh
a26d90be
BH
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])
cfdb727a 786
a26d90be
BH
787 // Initialize session handling scenario
788 fProxy.setScenario(TraceControlTestFacility.SCEN_SCENARIO_SESSION_HANDLING);
cfdb727a 789
a26d90be 790 session = (TraceSessionComponent)groups[1].getChildren()[0];
4ea599a5 791
a26d90be 792 // ------------------------------------------------------------------------
cfdb727a 793 // start session
a26d90be
BH
794 // ------------------------------------------------------------------------
795 fFacility.startSession(session);
796 assertEquals(TraceSessionState.ACTIVE, session.getSessionState());
cfdb727a 797
a26d90be 798 // ------------------------------------------------------------------------
cfdb727a 799 // stop session
a26d90be
BH
800 // ------------------------------------------------------------------------
801 fFacility.stopSession(session);
802 assertEquals(TraceSessionState.INACTIVE, session.getSessionState());
cfdb727a 803
a26d90be 804 // ------------------------------------------------------------------------
cfdb727a 805 // Destroy session
a26d90be
BH
806 // ------------------------------------------------------------------------
807
808 fFacility.destroySession(session);
cfdb727a 809
a26d90be
BH
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());
cfdb727a 818
a26d90be
BH
819 //-------------------------------------------------------------------------
820 // Delete node
821 //-------------------------------------------------------------------------
cfdb727a 822
a26d90be
BH
823 fFacility.executeCommand(node, "delete");
824 assertEquals(0,fFacility.getControlView().getTraceControlRoot().getChildren().length);
825 }
cfdb727a 826
a26d90be 827}
This page took 0.074302 seconds and 5 git commands to generate.