1 /**********************************************************************
2 * Copyright (c) 2012, 2013 Ericsson
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
10 * Bernd Hufmann - Initial API and implementation
11 * Alexandre Montplaisir - Port to JUnit4
12 **********************************************************************/
14 package org
.eclipse
.linuxtools
.lttng2
.ui
.tests
.control
.model
.component
;
16 import static org
.junit
.Assert
.assertEquals
;
17 import static org
.junit
.Assert
.assertNotNull
;
18 import static org
.junit
.Assert
.assertNull
;
19 import static org
.junit
.Assert
.assertTrue
;
20 import static org
.junit
.Assert
.fail
;
24 import java
.util
.ArrayList
;
25 import java
.util
.List
;
27 import org
.eclipse
.core
.runtime
.FileLocator
;
28 import org
.eclipse
.core
.runtime
.Path
;
29 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TargetNodeState
;
30 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceEnablement
;
31 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceEventType
;
32 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceLogLevel
;
33 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceSessionState
;
34 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.impl
.ChannelInfo
;
35 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.dialogs
.AddContextDialogStub
;
36 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.dialogs
.CreateSessionDialogStub
;
37 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.dialogs
.DestroyConfirmDialogStub
;
38 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.dialogs
.EnableChannelDialogStub
;
39 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.dialogs
.EnableEventsDialogStub
;
40 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.dialogs
.GetEventInfoDialogStub
;
41 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.service
.TestRemoteSystemProxy
;
42 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.dialogs
.TraceControlDialogFactory
;
43 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.ITraceControlComponent
;
44 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TargetNodeComponent
;
45 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceChannelComponent
;
46 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceEventComponent
;
47 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceProbeEventComponent
;
48 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceSessionComponent
;
49 import org
.eclipse
.rse
.core
.RSECorePlugin
;
50 import org
.eclipse
.rse
.core
.model
.IHost
;
51 import org
.eclipse
.rse
.core
.model
.ISystemProfile
;
52 import org
.eclipse
.rse
.core
.model
.ISystemRegistry
;
53 import org
.junit
.After
;
54 import org
.junit
.Before
;
55 import org
.junit
.Test
;
56 import org
.osgi
.framework
.FrameworkUtil
;
59 * The class <code>TraceControlKernelSessionTests</code> contains Kernel
60 * session/channel/event handling test cases.
62 public class TraceControlKernelSessionTests
{
64 // ------------------------------------------------------------------------
66 // ------------------------------------------------------------------------
68 private static final String TEST_STREAM
= "CreateTreeTest.cfg";
69 private static final String SCEN_SCENARIO3_TEST
= "Scenario3";
71 // ------------------------------------------------------------------------
73 // ------------------------------------------------------------------------
75 private TraceControlTestFacility fFacility
;
76 private TestRemoteSystemProxy fProxy
;
77 private String fTestFile
;
79 // ------------------------------------------------------------------------
81 // ------------------------------------------------------------------------
84 * Perform pre-test initialization.
87 * if the initialization fails for some reason
90 public void setUp() throws Exception
{
91 fFacility
= TraceControlTestFacility
.getInstance();
93 fProxy
= new TestRemoteSystemProxy();
94 URL location
= FileLocator
.find(FrameworkUtil
.getBundle(this.getClass()), new Path(TraceControlTestFacility
.DIRECTORY
+ File
.separator
+ TEST_STREAM
), null);
95 File testfile
= new File(FileLocator
.toFileURL(location
).toURI());
96 fTestFile
= testfile
.getAbsolutePath();
100 * Perform post-test clean-up.
103 public void tearDown() {
104 fFacility
.waitForJobs();
109 * Run the TraceControlComponent.
112 * Would fail the test
115 public void testTraceSessionTree() throws Exception
{
117 fProxy
.setTestFile(fTestFile
);
118 fProxy
.setScenario(TraceControlTestFacility
.SCEN_INIT_TEST
);
120 ITraceControlComponent root
= fFacility
.getControlView().getTraceControlRoot();
122 ISystemRegistry registry
= RSECorePlugin
.getTheSystemRegistry();
123 ISystemProfile profile
= registry
.createSystemProfile("myProfile", true);
124 IHost host
= registry
.createLocalHost(profile
, "myProfile", "user");
126 TargetNodeComponent node
= new TargetNodeComponent("myNode", root
, host
, fProxy
);
129 fFacility
.waitForJobs();
131 fFacility
.executeCommand(node
, "connect");
133 while ((i
< 10) && (node
.getTargetNodeState() != TargetNodeState
.CONNECTED
)) {
135 fFacility
.delay(TraceControlTestFacility
.GUI_REFESH_DELAY
);
138 // Verify that node is connected
139 assertEquals(TargetNodeState
.CONNECTED
, node
.getTargetNodeState());
141 // Get provider groups
142 ITraceControlComponent
[] groups
= node
.getChildren();
143 assertNotNull(groups
);
144 assertEquals(2, groups
.length
);
146 // Initialize dialog implementations for command execution
147 TraceControlDialogFactory
.getInstance().setCreateSessionDialog(new CreateSessionDialogStub());
148 TraceControlDialogFactory
.getInstance().setGetEventInfoDialog(new GetEventInfoDialogStub());
149 TraceControlDialogFactory
.getInstance().setConfirmDialog(new DestroyConfirmDialogStub());
151 // Initialize session handling scenario
152 fProxy
.setScenario(TraceControlTestFacility
.SCEN_SCENARIO_SESSION_HANDLING
);
154 // ------------------------------------------------------------------------
156 // ------------------------------------------------------------------------
157 TraceSessionComponent session
= fFacility
.createSession(groups
[1]);
159 // Verify that session was created
160 assertNotNull(session
);
161 assertEquals("mysession", session
.getName());
162 assertEquals("/home/user/lttng-traces/mysession-20120314-132824", session
.getSessionPath());
163 assertEquals(TraceSessionState
.INACTIVE
, session
.getSessionState());
165 // Initialize scenario
166 fProxy
.setScenario(SCEN_SCENARIO3_TEST
);
168 // ------------------------------------------------------------------------
169 // Enable channel on session
170 // ------------------------------------------------------------------------
171 EnableChannelDialogStub channelStub
= new EnableChannelDialogStub();
172 channelStub
.setIsKernel(true);
173 TraceControlDialogFactory
.getInstance().setEnableChannelDialog(channelStub
);
175 fFacility
.executeCommand(session
, "enableChannelOnSession");
177 // Verify that Kernel domain was created
178 ITraceControlComponent
[] domains
= session
.getChildren();
179 assertNotNull(domains
);
180 assertEquals(1, domains
.length
);
182 assertEquals("Kernel", domains
[0].getName());
184 // Verify that channel was created with correct data
185 ITraceControlComponent
[] channels
= domains
[0].getChildren();
186 assertNotNull(channels
);
187 assertEquals(1, channels
.length
);
189 assertTrue(channels
[0] instanceof TraceChannelComponent
);
190 TraceChannelComponent channel
= (TraceChannelComponent
) channels
[0];
191 assertEquals("mychannel", channel
.getName());
192 assertEquals(4, channel
.getNumberOfSubBuffers());
193 assertEquals("splice()", channel
.getOutputType());
194 assertEquals(true, channel
.isOverwriteMode());
195 assertEquals(200, channel
.getReadTimer());
196 assertEquals(TraceEnablement
.ENABLED
, channel
.getState());
197 assertEquals(16384, channel
.getSubBufferSize());
198 assertEquals(100, channel
.getSwitchTimer());
200 // ------------------------------------------------------------------------
201 // Create channel on domain
202 // ------------------------------------------------------------------------
203 ChannelInfo info
= (ChannelInfo
)channelStub
.getChannelInfo();
204 info
.setName("mychannel2");
205 info
.setOverwriteMode(false);
206 info
.setSubBufferSize(32768);
207 info
.setNumberOfSubBuffers(2);
208 info
.setSwitchTimer(100);
209 info
.setReadTimer(200);
210 channelStub
.setChannelInfo(info
);
212 fFacility
.executeCommand(domains
[0], "enableChannelOnDomain");
214 // Get Kernel domain component instance
215 domains
= session
.getChildren();
216 assertNotNull(domains
);
217 assertEquals(1, domains
.length
);
219 // Verify that channel was created with correct data
220 channels
= domains
[0].getChildren();
221 assertNotNull(channels
);
222 assertEquals(2, channels
.length
);
224 assertTrue(channels
[1] instanceof TraceChannelComponent
);
225 channel
= (TraceChannelComponent
) channels
[1];
226 assertEquals("mychannel2", channel
.getName());
227 assertEquals(2, channel
.getNumberOfSubBuffers());
228 assertEquals("splice()", channel
.getOutputType());
229 assertEquals(false, channel
.isOverwriteMode());
230 assertEquals(200, channel
.getReadTimer());
231 assertEquals(TraceEnablement
.ENABLED
, channel
.getState());
232 assertEquals(32768, channel
.getSubBufferSize());
233 assertEquals(100, channel
.getSwitchTimer());
235 EnableEventsDialogStub eventsDialogStub
= new EnableEventsDialogStub();
236 eventsDialogStub
.setIsTracePoints(true);
237 List
<String
> events
= new ArrayList
<String
>();
238 events
.add("sched_kthread_stop");
239 events
.add("sched_kthread_stop_ret");
240 eventsDialogStub
.setNames(events
);
241 eventsDialogStub
.setIsKernel(true);
242 TraceControlDialogFactory
.getInstance().setEnableEventsDialog(eventsDialogStub
);
244 // ------------------------------------------------------------------------
246 // ------------------------------------------------------------------------
247 // Get Kernel domain component instance
248 domains
= session
.getChildren();
249 assertNotNull(domains
);
250 assertEquals(1, domains
.length
);
252 // Verify that channel was created with correct data
253 channels
= domains
[0].getChildren();
254 assertNotNull(channels
);
255 assertEquals(2, channels
.length
);
257 fFacility
.executeCommand(channels
, "disableChannel");
259 assertEquals(TraceEnablement
.DISABLED
, ((TraceChannelComponent
)channels
[0]).getState());
260 assertEquals(TraceEnablement
.DISABLED
, ((TraceChannelComponent
)channels
[1]).getState());
262 // ------------------------------------------------------------------------
264 // ------------------------------------------------------------------------
265 // Get Kernel domain component instance
266 domains
= session
.getChildren();
267 assertNotNull(domains
);
268 assertEquals(1, domains
.length
);
270 // Verify that channel was created with correct data
271 channels
= domains
[0].getChildren();
272 assertNotNull(channels
);
273 assertEquals(2, channels
.length
);
275 fFacility
.executeCommand(channels
, "enableChannel");
277 assertEquals(TraceEnablement
.ENABLED
, ((TraceChannelComponent
)channels
[0]).getState());
278 assertEquals(TraceEnablement
.ENABLED
, ((TraceChannelComponent
)channels
[1]).getState());
280 // ------------------------------------------------------------------------
281 // enable event (tracepoints) on session
282 // ------------------------------------------------------------------------
283 fFacility
.executeCommand(session
, "enableEventOnSession");
285 // Get Kernel domain component instance
286 domains
= session
.getChildren();
287 assertNotNull(domains
);
288 assertEquals(1, domains
.length
);
290 // Verify that channel was created with correct data
291 channels
= domains
[0].getChildren();
292 assertNotNull(channels
);
293 assertEquals(3, channels
.length
);
295 assertTrue(channels
[2] instanceof TraceChannelComponent
);
296 channel
= (TraceChannelComponent
) channels
[2];
297 assertEquals("channel0", channel
.getName());
298 // No need to check parameters of default channel because that has been done in other tests
300 ITraceControlComponent
[] channel0Events
= channel
.getChildren();
301 assertEquals(2, channel0Events
.length
);
303 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
304 assertTrue(channel0Events
[1] instanceof TraceEventComponent
);
306 TraceEventComponent event
= (TraceEventComponent
) channel0Events
[0];
307 assertEquals("sched_kthread_stop_ret", event
.getName());
308 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
309 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
310 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
312 event
= (TraceEventComponent
) channel0Events
[1];
313 assertEquals("sched_kthread_stop", event
.getName());
314 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
315 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
316 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
318 // ------------------------------------------------------------------------
319 // enable event (tracepoints) on domain
320 // ------------------------------------------------------------------------
322 events
.add("sched_wakeup_new");
323 eventsDialogStub
.setNames(events
);
325 fFacility
.executeCommand(domains
[0], "enableEventOnDomain");
327 // Get Kernel domain component instance
328 domains
= session
.getChildren();
329 assertNotNull(domains
);
330 assertEquals(1, domains
.length
);
332 // Verify that channel was created with correct data
333 channels
= domains
[0].getChildren();
334 channel
= (TraceChannelComponent
) channels
[2];
335 // No need to check parameters of default channel because that has been done in other tests
337 channel
= (TraceChannelComponent
) channels
[2];
339 channel0Events
= channel
.getChildren();
340 assertEquals(3, channel0Events
.length
);
342 assertTrue(channel0Events
[2] instanceof TraceEventComponent
);
344 event
= (TraceEventComponent
) channel0Events
[2];
345 assertEquals("sched_wakeup_new", event
.getName());
346 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
347 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
348 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
350 // ------------------------------------------------------------------------
351 // enable event (tracepoints) on channel
352 // ------------------------------------------------------------------------
354 eventsDialogStub
.setNames(events
);
355 eventsDialogStub
.setIsAllTracePoints(true);
357 fFacility
.executeCommand(channels
[1], "enableEventOnChannel");
359 // Get Kernel domain component instance
360 domains
= session
.getChildren();
361 assertNotNull(domains
);
362 assertEquals(1, domains
.length
);
364 // Verify that channel was created with correct data
365 channels
= domains
[0].getChildren();
366 // No need to check parameters of default channel because that has been done in other tests
367 channel
= (TraceChannelComponent
) channels
[1];
369 channel0Events
= channel
.getChildren();
370 assertEquals(3, channel0Events
.length
);
372 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
373 assertTrue(channel0Events
[1] instanceof TraceEventComponent
);
374 assertTrue(channel0Events
[2] instanceof TraceEventComponent
);
376 event
= (TraceEventComponent
) channel0Events
[0];
377 assertEquals("sched_kthread_stop_ret", event
.getName());
378 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
379 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
380 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
382 event
= (TraceEventComponent
) channel0Events
[1];
383 assertEquals("sched_kthread_stop", event
.getName());
384 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
385 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
386 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
388 event
= (TraceEventComponent
) channel0Events
[2];
389 assertEquals("sched_wakeup_new", event
.getName());
390 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
391 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
392 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
394 // ------------------------------------------------------------------------
395 // enable event (syscall) on channel
396 // ------------------------------------------------------------------------
398 eventsDialogStub
.setIsTracePoints(false);
399 eventsDialogStub
.setIsAllTracePoints(false);
400 eventsDialogStub
.setIsSysCalls(true);
402 fFacility
.executeCommand(channels
[0], "enableEventOnChannel");
404 // Get Kernel domain component instance
405 domains
= session
.getChildren();
406 assertNotNull(domains
);
407 assertEquals(1, domains
.length
);
409 // Verify that channel was created with correct data
410 channels
= domains
[0].getChildren();
411 channel
= (TraceChannelComponent
) channels
[0];
412 // No need to check parameters of default channel because that has been done in other tests
414 channel
= (TraceChannelComponent
) channels
[0];
416 channel0Events
= channel
.getChildren();
417 assertEquals(1, channel0Events
.length
);
419 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
421 event
= (TraceEventComponent
) channel0Events
[0];
422 assertEquals("syscalls", event
.getName());
423 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, event
.getLogLevel());
424 assertEquals(TraceEventType
.SYSCALL
, event
.getEventType());
425 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
427 // ------------------------------------------------------------------------
428 // enable event (syscall) on domain
429 // ------------------------------------------------------------------------
430 fFacility
.executeCommand(domains
[0], "enableEventOnDomain");
432 // Get Kernel domain component instance
433 domains
= session
.getChildren();
434 assertNotNull(domains
);
435 assertEquals(1, domains
.length
);
437 // Verify that channel was created with correct data
438 channels
= domains
[0].getChildren();
439 channel
= (TraceChannelComponent
) channels
[0];
440 // No need to check parameters of default channel because that has been done in other tests
442 channel
= (TraceChannelComponent
) channels
[2];
444 channel0Events
= channel
.getChildren();
445 assertEquals(4, channel0Events
.length
);
447 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
449 event
= (TraceEventComponent
) channel0Events
[0];
450 assertEquals("syscalls", event
.getName());
451 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, event
.getLogLevel());
452 assertEquals(TraceEventType
.SYSCALL
, event
.getEventType());
453 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
455 // ------------------------------------------------------------------------
456 // enable event (syscall) on session
457 // ------------------------------------------------------------------------
458 fFacility
.executeCommand(session
, "enableEventOnSession");
460 // Get Kernel domain component instance
461 domains
= session
.getChildren();
462 assertNotNull(domains
);
463 assertEquals(1, domains
.length
);
465 // Verify that channel was created with correct data
466 channels
= domains
[0].getChildren();
467 channel
= (TraceChannelComponent
) channels
[0];
468 // No need to check parameters of default channel because that has been done in other tests
470 channel
= (TraceChannelComponent
) channels
[2];
472 channel0Events
= channel
.getChildren();
473 assertEquals(4, channel0Events
.length
);
475 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
477 event
= (TraceEventComponent
) channel0Events
[0];
478 assertEquals("syscalls", event
.getName());
479 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, event
.getLogLevel());
480 assertEquals(TraceEventType
.SYSCALL
, event
.getEventType());
481 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
484 // ------------------------------------------------------------------------
485 // enable event (dynamic probe) on domain
486 // ------------------------------------------------------------------------
488 eventsDialogStub
.setIsSysCalls(false);
489 eventsDialogStub
.setIsDynamicProbe(true);
490 eventsDialogStub
.setDynamicProbe("0xc0101280");
491 eventsDialogStub
.setProbeEventName("myevent1");
493 fFacility
.executeCommand(domains
[0], "enableEventOnDomain");
495 // Get Kernel domain component instance
496 domains
= session
.getChildren();
497 assertNotNull(domains
);
498 assertEquals(1, domains
.length
);
500 // Verify that channel was created with correct data
501 channels
= domains
[0].getChildren();
502 channel
= (TraceChannelComponent
) channels
[2];
503 // No need to check parameters of default channel because that has been done in other tests
505 channel0Events
= channel
.getChildren();
506 assertEquals(5, channel0Events
.length
);
508 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
510 TraceProbeEventComponent probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
511 assertEquals("myevent1", probeEvent
.getName());
512 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
513 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
514 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
515 assertNull(probeEvent
.getOffset());
516 assertEquals("0xc0101280", probeEvent
.getAddress());
517 assertNull(probeEvent
.getSymbol());
519 // ------------------------------------------------------------------------
520 // enable event (dynamic probe) on channel
521 // ------------------------------------------------------------------------
522 eventsDialogStub
.setIsDynamicProbe(true);
523 eventsDialogStub
.setDynamicProbe("init_post");
524 eventsDialogStub
.setProbeEventName("myevent2");
526 fFacility
.executeCommand(channels
[2], "enableEventOnChannel");
528 // Get Kernel domain component instance
529 domains
= session
.getChildren();
530 assertNotNull(domains
);
531 assertEquals(1, domains
.length
);
533 // Verify that channel was created with correct data
534 channels
= domains
[0].getChildren();
535 channel
= (TraceChannelComponent
) channels
[2];
536 // No need to check parameters of default channel because that has been done in other tests
538 channel0Events
= channel
.getChildren();
539 assertEquals(6, channel0Events
.length
);
541 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
543 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
544 assertEquals("myevent2", probeEvent
.getName());
545 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
546 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
547 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
548 assertEquals("0x0", probeEvent
.getOffset());
549 assertNull(null, probeEvent
.getAddress());
550 assertEquals("init_post", probeEvent
.getSymbol());
552 // ------------------------------------------------------------------------
553 // enable event (dynamic probe) on session
554 // ------------------------------------------------------------------------
555 eventsDialogStub
.setIsDynamicProbe(true);
556 eventsDialogStub
.setDynamicProbe("init_post:0x1000");
557 eventsDialogStub
.setProbeEventName("myevent3");
559 fFacility
.executeCommand(session
, "enableEventOnSession");
561 // Get Kernel domain component instance
562 domains
= session
.getChildren();
563 assertNotNull(domains
);
564 assertEquals(1, domains
.length
);
566 // Verify that channel was created with correct data
567 channels
= domains
[0].getChildren();
568 channel
= (TraceChannelComponent
) channels
[2];
569 // No need to check parameters of default channel because that has been done in other tests
571 channel0Events
= channel
.getChildren();
572 assertEquals(7, channel0Events
.length
);
574 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
576 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
577 assertEquals("myevent3", probeEvent
.getName());
578 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
579 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
580 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
581 assertEquals("0x1000", probeEvent
.getOffset());
582 assertNull(null, probeEvent
.getAddress());
583 assertEquals("init_post", probeEvent
.getSymbol());
585 // ------------------------------------------------------------------------
586 // enable event (dynamic function probe) on session
587 // ------------------------------------------------------------------------
588 eventsDialogStub
.setIsDynamicProbe(false);
589 eventsDialogStub
.setDynamicProbe(null);
590 eventsDialogStub
.setProbeEventName(null);
591 eventsDialogStub
.setIsFunctionProbe(true);
592 eventsDialogStub
.setFunctionEventName("myevent4");
593 eventsDialogStub
.setFunctionProbe("create_dev");
595 fFacility
.executeCommand(session
, "enableEventOnSession");
597 // Get Kernel domain component instance
598 domains
= session
.getChildren();
599 assertNotNull(domains
);
600 assertEquals(1, domains
.length
);
602 // Verify that channel was created with correct data
603 channels
= domains
[0].getChildren();
604 channel
= (TraceChannelComponent
) channels
[2];
605 // No need to check parameters of default channel because that has been done in other tests
607 channel0Events
= channel
.getChildren();
608 assertEquals(8, channel0Events
.length
);
610 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
612 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
613 assertEquals("myevent4", probeEvent
.getName());
614 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
615 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
616 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
617 assertEquals("0x0", probeEvent
.getOffset());
618 assertNull(null, probeEvent
.getAddress());
619 assertEquals("create_dev", probeEvent
.getSymbol());
621 // ------------------------------------------------------------------------
622 // enable event (dynamic function probe) on domain
623 // ------------------------------------------------------------------------
624 eventsDialogStub
.setIsFunctionProbe(true);
625 eventsDialogStub
.setFunctionEventName("myevent5");
626 eventsDialogStub
.setFunctionProbe("create_dev:0x2000");
628 fFacility
.executeCommand(domains
[0], "enableEventOnDomain");
630 // Get Kernel domain component instance
631 domains
= session
.getChildren();
632 assertNotNull(domains
);
633 assertEquals(1, domains
.length
);
635 // Verify that channel was created with correct data
636 channels
= domains
[0].getChildren();
637 channel
= (TraceChannelComponent
) channels
[2];
638 // No need to check parameters of default channel because that has been done in other tests
640 channel0Events
= channel
.getChildren();
641 assertEquals(9, channel0Events
.length
);
643 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
645 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
646 assertEquals("myevent5", probeEvent
.getName());
647 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
648 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
649 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
650 assertEquals("0x2000", probeEvent
.getOffset());
651 assertNull(null, probeEvent
.getAddress());
652 assertEquals("create_dev", probeEvent
.getSymbol());
654 // ------------------------------------------------------------------------
655 // enable event (dynamic function probe) on channel
656 // ------------------------------------------------------------------------
657 eventsDialogStub
.setIsFunctionProbe(true);
658 eventsDialogStub
.setFunctionEventName("myevent");
659 eventsDialogStub
.setFunctionProbe("create_dev:0x2000");
661 fFacility
.executeCommand(channels
[0], "enableEventOnChannel");
663 // Get Kernel domain component instance
664 domains
= session
.getChildren();
665 assertNotNull(domains
);
666 assertEquals(1, domains
.length
);
668 // Verify that channel was created with correct data
669 channels
= domains
[0].getChildren();
670 channel
= (TraceChannelComponent
) channels
[0];
671 // No need to check parameters of default channel because that has been done in other tests
673 channel0Events
= channel
.getChildren();
674 assertEquals(2, channel0Events
.length
);
676 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
678 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
679 assertEquals("myevent", probeEvent
.getName());
680 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
681 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
682 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
683 assertEquals("0x2000", probeEvent
.getOffset());
684 assertNull(null, probeEvent
.getAddress());
685 assertEquals("create_dev", probeEvent
.getSymbol());
687 // ------------------------------------------------------------------------
688 // Add Context on domain
689 // ------------------------------------------------------------------------
690 // Get Kernel domain component instance
691 domains
= session
.getChildren();
692 assertNotNull(domains
);
693 assertEquals(1, domains
.length
);
695 AddContextDialogStub addContextStub
= new AddContextDialogStub();
696 List
<String
> contexts
= new ArrayList
<String
>();
697 contexts
.add("prio");
698 contexts
.add("perf:branch-misses");
699 contexts
.add("perf:cache-misses");
700 addContextStub
.setContexts(contexts
);
701 TraceControlDialogFactory
.getInstance().setAddContextDialog(addContextStub
);
703 fFacility
.executeCommand(domains
[0], "addContextOnDomain");
704 // Currently there is nothing to verify because the list commands don't show any context information
705 // However, the execution of the command make sure that the correct service command line is build and executed.
707 // ------------------------------------------------------------------------
708 // Add Context on channel
709 // ------------------------------------------------------------------------
711 // Get Kernel domain component instance
712 domains
= session
.getChildren();
713 assertNotNull(domains
);
714 assertEquals(1, domains
.length
);
716 //Verify that channel was created with correct data
717 channels
= domains
[0].getChildren();
718 channel
= (TraceChannelComponent
) channels
[0];
721 // The setContext() verifies that the contexts set are part of the available contexts
722 // The available contexts are set by the command handler addContextOnDomain above.
723 // So we indirectly test here that the parsing and setting of available contexts were
724 // done correctly above.
725 addContextStub
.setContexts(contexts
);
726 } catch (IllegalArgumentException e
) {
727 fail("Exception caught - unknown context");
730 fFacility
.executeCommand(channel
, "addContextOnChannel");
731 // Currently there is nothing to verify because the list commands don't show any context information
732 // However, the execution of the command make sure that the correct service command line is build and executed.
734 // ------------------------------------------------------------------------
735 // Add Context on event
736 // ------------------------------------------------------------------------
737 // Get Kernel domain component instance
738 domains
= session
.getChildren();
739 assertNotNull(domains
);
740 assertEquals(1, domains
.length
);
742 //Verify that channel was created with correct data
743 channels
= domains
[0].getChildren();
744 channel
= (TraceChannelComponent
) channels
[2];
746 channel0Events
= channel
.getChildren();
748 event
= (TraceEventComponent
) channel0Events
[6];
750 fFacility
.executeCommand(event
, "addContextOnEvent");
751 // Currently there is nothing to verify because the list commands don't show any context information
752 // However, the execution of the command make sure that the correct service command line is build and executed.
754 // ------------------------------------------------------------------------
756 // ------------------------------------------------------------------------
757 // Get Kernel domain component instance
758 domains
= session
.getChildren();
759 assertNotNull(domains
);
760 assertEquals(1, domains
.length
);
762 fFacility
.executeCommand(domains
[0], "calibrate");
763 // There is nothing to verify here.
764 // However, the execution of the command make sure that the correct service command line is build and executed.
766 // ------------------------------------------------------------------------
768 // ------------------------------------------------------------------------
769 fFacility
.executeCommand(node
, "refresh");
770 groups
= node
.getChildren();
771 assertNotNull(groups
);
772 assertEquals(2, groups
.length
);
773 assertEquals(3, groups
[0].getChildren().length
); // provider
774 assertEquals(1, groups
[1].getChildren().length
); // sessions
775 assertEquals(1, groups
[1].getChildren()[0].getChildren().length
); // domains
776 assertEquals(3, groups
[1].getChildren()[0].getChildren()[0].getChildren().length
); // channels
777 assertEquals(2, groups
[1].getChildren()[0].getChildren()[0].getChildren()[0].getChildren().length
); // events (of channel[0])
779 // Initialize session handling scenario
780 fProxy
.setScenario(TraceControlTestFacility
.SCEN_SCENARIO_SESSION_HANDLING
);
782 session
= (TraceSessionComponent
)groups
[1].getChildren()[0];
784 // ------------------------------------------------------------------------
786 // ------------------------------------------------------------------------
787 fFacility
.startSession(session
);
788 assertEquals(TraceSessionState
.ACTIVE
, session
.getSessionState());
790 // ------------------------------------------------------------------------
792 // ------------------------------------------------------------------------
793 fFacility
.stopSession(session
);
794 assertEquals(TraceSessionState
.INACTIVE
, session
.getSessionState());
796 // ------------------------------------------------------------------------
798 // ------------------------------------------------------------------------
800 fFacility
.destroySession(session
);
802 // Verify that no more session components exist
803 assertEquals(0, groups
[1].getChildren().length
);
805 //-------------------------------------------------------------------------
807 //-------------------------------------------------------------------------
808 fFacility
.executeCommand(node
, "disconnect");
809 assertEquals(TargetNodeState
.DISCONNECTED
, node
.getTargetNodeState());
811 //-------------------------------------------------------------------------
813 //-------------------------------------------------------------------------
815 fFacility
.executeCommand(node
, "delete");
816 assertEquals(0,fFacility
.getControlView().getTraceControlRoot().getChildren().length
);