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 @SuppressWarnings("nls")
63 public class TraceControlKernelSessionTests
{
65 // ------------------------------------------------------------------------
67 // ------------------------------------------------------------------------
69 private static final String TEST_STREAM
= "CreateTreeTest.cfg";
70 private static final String SCEN_SCENARIO3_TEST
= "Scenario3";
72 // ------------------------------------------------------------------------
74 // ------------------------------------------------------------------------
76 private TraceControlTestFacility fFacility
;
77 private TestRemoteSystemProxy fProxy
;
78 private String fTestFile
;
80 // ------------------------------------------------------------------------
82 // ------------------------------------------------------------------------
85 * Perform pre-test initialization.
88 * if the initialization fails for some reason
91 public void setUp() throws Exception
{
92 fFacility
= TraceControlTestFacility
.getInstance();
93 fProxy
= new TestRemoteSystemProxy();
94 URL location
= FileLocator
.find(FrameworkUtil
.getBundle(this.getClass()), new Path(TraceControlTestFacility
.DIRECTORY
+ File
.separator
+ TEST_STREAM
), null);
95 File testfile
= new File(FileLocator
.toFileURL(location
).toURI());
96 fTestFile
= testfile
.getAbsolutePath();
100 * Perform post-test clean-up.
103 public void tearDown() {
104 fFacility
.waitForJobs();
108 * Run the TraceControlComponent.
111 * Would fail the test
114 public void testTraceSessionTree() throws Exception
{
116 fProxy
.setTestFile(fTestFile
);
117 fProxy
.setScenario(TraceControlTestFacility
.SCEN_INIT_TEST
);
119 ITraceControlComponent root
= TraceControlTestFacility
.getInstance().getControlView().getTraceControlRoot();
121 ISystemRegistry registry
= RSECorePlugin
.getTheSystemRegistry();
122 ISystemProfile profile
= registry
.createSystemProfile("myProfile", true);
123 IHost host
= registry
.createLocalHost(profile
, "myProfile", "user");
125 TargetNodeComponent node
= new TargetNodeComponent("myNode", root
, host
, fProxy
);
128 fFacility
.waitForJobs();
130 fFacility
.executeCommand(node
, "connect");
132 while ((i
< 10) && (node
.getTargetNodeState() != TargetNodeState
.CONNECTED
)) {
134 fFacility
.delay(TraceControlTestFacility
.GUI_REFESH_DELAY
);
137 // Verify that node is connected
138 assertEquals(TargetNodeState
.CONNECTED
, node
.getTargetNodeState());
140 // Get provider groups
141 ITraceControlComponent
[] groups
= node
.getChildren();
142 assertNotNull(groups
);
143 assertEquals(2, groups
.length
);
145 // Initialize dialog implementations for command execution
146 TraceControlDialogFactory
.getInstance().setCreateSessionDialog(new CreateSessionDialogStub());
147 TraceControlDialogFactory
.getInstance().setGetEventInfoDialog(new GetEventInfoDialogStub());
148 TraceControlDialogFactory
.getInstance().setConfirmDialog(new DestroyConfirmDialogStub());
150 // Initialize session handling scenario
151 fProxy
.setScenario(TraceControlTestFacility
.SCEN_SCENARIO_SESSION_HANDLING
);
153 // ------------------------------------------------------------------------
155 // ------------------------------------------------------------------------
156 TraceSessionComponent session
= fFacility
.createSession(groups
[1]);
158 // Verify that session was created
159 assertNotNull(session
);
160 assertEquals("mysession", session
.getName());
161 assertEquals("/home/user/lttng-traces/mysession-20120314-132824", session
.getSessionPath());
162 assertEquals(TraceSessionState
.INACTIVE
, session
.getSessionState());
164 // Initialize scenario
165 fProxy
.setScenario(SCEN_SCENARIO3_TEST
);
167 // ------------------------------------------------------------------------
168 // Enable channel on session
169 // ------------------------------------------------------------------------
170 EnableChannelDialogStub channelStub
= new EnableChannelDialogStub();
171 channelStub
.setIsKernel(true);
172 TraceControlDialogFactory
.getInstance().setEnableChannelDialog(channelStub
);
174 fFacility
.executeCommand(session
, "enableChannelOnSession");
176 // Verify that Kernel domain was created
177 ITraceControlComponent
[] domains
= session
.getChildren();
178 assertNotNull(domains
);
179 assertEquals(1, domains
.length
);
181 assertEquals("Kernel", domains
[0].getName());
183 // Verify that channel was created with correct data
184 ITraceControlComponent
[] channels
= domains
[0].getChildren();
185 assertNotNull(channels
);
186 assertEquals(1, channels
.length
);
188 assertTrue(channels
[0] instanceof TraceChannelComponent
);
189 TraceChannelComponent channel
= (TraceChannelComponent
) channels
[0];
190 assertEquals("mychannel", channel
.getName());
191 assertEquals(4, channel
.getNumberOfSubBuffers());
192 assertEquals("splice()", channel
.getOutputType());
193 assertEquals(true, channel
.isOverwriteMode());
194 assertEquals(200, channel
.getReadTimer());
195 assertEquals(TraceEnablement
.ENABLED
, channel
.getState());
196 assertEquals(16384, channel
.getSubBufferSize());
197 assertEquals(100, channel
.getSwitchTimer());
199 // ------------------------------------------------------------------------
200 // Create channel on domain
201 // ------------------------------------------------------------------------
202 ChannelInfo info
= (ChannelInfo
)channelStub
.getChannelInfo();
203 info
.setName("mychannel2");
204 info
.setOverwriteMode(false);
205 info
.setSubBufferSize(32768);
206 info
.setNumberOfSubBuffers(2);
207 info
.setSwitchTimer(100);
208 info
.setReadTimer(200);
209 channelStub
.setChannelInfo(info
);
211 fFacility
.executeCommand(domains
[0], "enableChannelOnDomain");
213 // Get Kernel domain component instance
214 domains
= session
.getChildren();
215 assertNotNull(domains
);
216 assertEquals(1, domains
.length
);
218 // Verify that channel was created with correct data
219 channels
= domains
[0].getChildren();
220 assertNotNull(channels
);
221 assertEquals(2, channels
.length
);
223 assertTrue(channels
[1] instanceof TraceChannelComponent
);
224 channel
= (TraceChannelComponent
) channels
[1];
225 assertEquals("mychannel2", channel
.getName());
226 assertEquals(2, channel
.getNumberOfSubBuffers());
227 assertEquals("splice()", channel
.getOutputType());
228 assertEquals(false, channel
.isOverwriteMode());
229 assertEquals(200, channel
.getReadTimer());
230 assertEquals(TraceEnablement
.ENABLED
, channel
.getState());
231 assertEquals(32768, channel
.getSubBufferSize());
232 assertEquals(100, channel
.getSwitchTimer());
234 EnableEventsDialogStub eventsDialogStub
= new EnableEventsDialogStub();
235 eventsDialogStub
.setIsTracePoints(true);
236 List
<String
> events
= new ArrayList
<String
>();
237 events
.add("sched_kthread_stop");
238 events
.add("sched_kthread_stop_ret");
239 eventsDialogStub
.setNames(events
);
240 eventsDialogStub
.setIsKernel(true);
241 TraceControlDialogFactory
.getInstance().setEnableEventsDialog(eventsDialogStub
);
243 // ------------------------------------------------------------------------
245 // ------------------------------------------------------------------------
246 // Get Kernel domain component instance
247 domains
= session
.getChildren();
248 assertNotNull(domains
);
249 assertEquals(1, domains
.length
);
251 // Verify that channel was created with correct data
252 channels
= domains
[0].getChildren();
253 assertNotNull(channels
);
254 assertEquals(2, channels
.length
);
256 fFacility
.executeCommand(channels
, "disableChannel");
258 assertEquals(TraceEnablement
.DISABLED
, ((TraceChannelComponent
)channels
[0]).getState());
259 assertEquals(TraceEnablement
.DISABLED
, ((TraceChannelComponent
)channels
[1]).getState());
261 // ------------------------------------------------------------------------
263 // ------------------------------------------------------------------------
264 // Get Kernel domain component instance
265 domains
= session
.getChildren();
266 assertNotNull(domains
);
267 assertEquals(1, domains
.length
);
269 // Verify that channel was created with correct data
270 channels
= domains
[0].getChildren();
271 assertNotNull(channels
);
272 assertEquals(2, channels
.length
);
274 fFacility
.executeCommand(channels
, "enableChannel");
276 assertEquals(TraceEnablement
.ENABLED
, ((TraceChannelComponent
)channels
[0]).getState());
277 assertEquals(TraceEnablement
.ENABLED
, ((TraceChannelComponent
)channels
[1]).getState());
279 // ------------------------------------------------------------------------
280 // enable event (tracepoints) on session
281 // ------------------------------------------------------------------------
282 fFacility
.executeCommand(session
, "enableEventOnSession");
284 // Get Kernel domain component instance
285 domains
= session
.getChildren();
286 assertNotNull(domains
);
287 assertEquals(1, domains
.length
);
289 // Verify that channel was created with correct data
290 channels
= domains
[0].getChildren();
291 assertNotNull(channels
);
292 assertEquals(3, channels
.length
);
294 assertTrue(channels
[2] instanceof TraceChannelComponent
);
295 channel
= (TraceChannelComponent
) channels
[2];
296 assertEquals("channel0", channel
.getName());
297 // No need to check parameters of default channel because that has been done in other tests
299 ITraceControlComponent
[] channel0Events
= channel
.getChildren();
300 assertEquals(2, channel0Events
.length
);
302 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
303 assertTrue(channel0Events
[1] instanceof TraceEventComponent
);
305 TraceEventComponent event
= (TraceEventComponent
) channel0Events
[0];
306 assertEquals("sched_kthread_stop_ret", event
.getName());
307 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
308 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
309 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
311 event
= (TraceEventComponent
) channel0Events
[1];
312 assertEquals("sched_kthread_stop", event
.getName());
313 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
314 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
315 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
317 // ------------------------------------------------------------------------
318 // enable event (tracepoints) on domain
319 // ------------------------------------------------------------------------
321 events
.add("sched_wakeup_new");
322 eventsDialogStub
.setNames(events
);
324 fFacility
.executeCommand(domains
[0], "enableEventOnDomain");
326 // Get Kernel domain component instance
327 domains
= session
.getChildren();
328 assertNotNull(domains
);
329 assertEquals(1, domains
.length
);
331 // Verify that channel was created with correct data
332 channels
= domains
[0].getChildren();
333 channel
= (TraceChannelComponent
) channels
[2];
334 // No need to check parameters of default channel because that has been done in other tests
336 channel
= (TraceChannelComponent
) channels
[2];
338 channel0Events
= channel
.getChildren();
339 assertEquals(3, channel0Events
.length
);
341 assertTrue(channel0Events
[2] instanceof TraceEventComponent
);
343 event
= (TraceEventComponent
) channel0Events
[2];
344 assertEquals("sched_wakeup_new", event
.getName());
345 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
346 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
347 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
349 // ------------------------------------------------------------------------
350 // enable event (tracepoints) on channel
351 // ------------------------------------------------------------------------
353 eventsDialogStub
.setNames(events
);
354 eventsDialogStub
.setIsAllTracePoints(true);
356 fFacility
.executeCommand(channels
[1], "enableEventOnChannel");
358 // Get Kernel domain component instance
359 domains
= session
.getChildren();
360 assertNotNull(domains
);
361 assertEquals(1, domains
.length
);
363 // Verify that channel was created with correct data
364 channels
= domains
[0].getChildren();
365 // No need to check parameters of default channel because that has been done in other tests
366 channel
= (TraceChannelComponent
) channels
[1];
368 channel0Events
= channel
.getChildren();
369 assertEquals(3, channel0Events
.length
);
371 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
372 assertTrue(channel0Events
[1] instanceof TraceEventComponent
);
373 assertTrue(channel0Events
[2] instanceof TraceEventComponent
);
375 event
= (TraceEventComponent
) channel0Events
[0];
376 assertEquals("sched_kthread_stop_ret", event
.getName());
377 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
378 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
379 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
381 event
= (TraceEventComponent
) channel0Events
[1];
382 assertEquals("sched_kthread_stop", event
.getName());
383 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
384 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
385 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
387 event
= (TraceEventComponent
) channel0Events
[2];
388 assertEquals("sched_wakeup_new", event
.getName());
389 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
390 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
391 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
393 // ------------------------------------------------------------------------
394 // enable event (syscall) on channel
395 // ------------------------------------------------------------------------
397 eventsDialogStub
.setIsTracePoints(false);
398 eventsDialogStub
.setIsAllTracePoints(false);
399 eventsDialogStub
.setIsSysCalls(true);
401 fFacility
.executeCommand(channels
[0], "enableEventOnChannel");
403 // Get Kernel domain component instance
404 domains
= session
.getChildren();
405 assertNotNull(domains
);
406 assertEquals(1, domains
.length
);
408 // Verify that channel was created with correct data
409 channels
= domains
[0].getChildren();
410 channel
= (TraceChannelComponent
) channels
[0];
411 // No need to check parameters of default channel because that has been done in other tests
413 channel
= (TraceChannelComponent
) channels
[0];
415 channel0Events
= channel
.getChildren();
416 assertEquals(1, channel0Events
.length
);
418 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
420 event
= (TraceEventComponent
) channel0Events
[0];
421 assertEquals("syscalls", event
.getName());
422 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, event
.getLogLevel());
423 assertEquals(TraceEventType
.SYSCALL
, event
.getEventType());
424 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
426 // ------------------------------------------------------------------------
427 // enable event (syscall) on domain
428 // ------------------------------------------------------------------------
429 fFacility
.executeCommand(domains
[0], "enableEventOnDomain");
431 // Get Kernel domain component instance
432 domains
= session
.getChildren();
433 assertNotNull(domains
);
434 assertEquals(1, domains
.length
);
436 // Verify that channel was created with correct data
437 channels
= domains
[0].getChildren();
438 channel
= (TraceChannelComponent
) channels
[0];
439 // No need to check parameters of default channel because that has been done in other tests
441 channel
= (TraceChannelComponent
) channels
[2];
443 channel0Events
= channel
.getChildren();
444 assertEquals(4, channel0Events
.length
);
446 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
448 event
= (TraceEventComponent
) channel0Events
[0];
449 assertEquals("syscalls", event
.getName());
450 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, event
.getLogLevel());
451 assertEquals(TraceEventType
.SYSCALL
, event
.getEventType());
452 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
454 // ------------------------------------------------------------------------
455 // enable event (syscall) on session
456 // ------------------------------------------------------------------------
457 fFacility
.executeCommand(session
, "enableEventOnSession");
459 // Get Kernel domain component instance
460 domains
= session
.getChildren();
461 assertNotNull(domains
);
462 assertEquals(1, domains
.length
);
464 // Verify that channel was created with correct data
465 channels
= domains
[0].getChildren();
466 channel
= (TraceChannelComponent
) channels
[0];
467 // No need to check parameters of default channel because that has been done in other tests
469 channel
= (TraceChannelComponent
) channels
[2];
471 channel0Events
= channel
.getChildren();
472 assertEquals(4, channel0Events
.length
);
474 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
476 event
= (TraceEventComponent
) channel0Events
[0];
477 assertEquals("syscalls", event
.getName());
478 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, event
.getLogLevel());
479 assertEquals(TraceEventType
.SYSCALL
, event
.getEventType());
480 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
483 // ------------------------------------------------------------------------
484 // enable event (dynamic probe) on domain
485 // ------------------------------------------------------------------------
487 eventsDialogStub
.setIsSysCalls(false);
488 eventsDialogStub
.setIsDynamicProbe(true);
489 eventsDialogStub
.setDynamicProbe("0xc0101280");
490 eventsDialogStub
.setProbeEventName("myevent1");
492 fFacility
.executeCommand(domains
[0], "enableEventOnDomain");
494 // Get Kernel domain component instance
495 domains
= session
.getChildren();
496 assertNotNull(domains
);
497 assertEquals(1, domains
.length
);
499 // Verify that channel was created with correct data
500 channels
= domains
[0].getChildren();
501 channel
= (TraceChannelComponent
) channels
[2];
502 // No need to check parameters of default channel because that has been done in other tests
504 channel0Events
= channel
.getChildren();
505 assertEquals(5, channel0Events
.length
);
507 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
509 TraceProbeEventComponent probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
510 assertEquals("myevent1", probeEvent
.getName());
511 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
512 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
513 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
514 assertNull(probeEvent
.getOffset());
515 assertEquals("0xc0101280", probeEvent
.getAddress());
516 assertNull(probeEvent
.getSymbol());
518 // ------------------------------------------------------------------------
519 // enable event (dynamic probe) on channel
520 // ------------------------------------------------------------------------
521 eventsDialogStub
.setIsDynamicProbe(true);
522 eventsDialogStub
.setDynamicProbe("init_post");
523 eventsDialogStub
.setProbeEventName("myevent2");
525 fFacility
.executeCommand(channels
[2], "enableEventOnChannel");
527 // Get Kernel domain component instance
528 domains
= session
.getChildren();
529 assertNotNull(domains
);
530 assertEquals(1, domains
.length
);
532 // Verify that channel was created with correct data
533 channels
= domains
[0].getChildren();
534 channel
= (TraceChannelComponent
) channels
[2];
535 // No need to check parameters of default channel because that has been done in other tests
537 channel0Events
= channel
.getChildren();
538 assertEquals(6, channel0Events
.length
);
540 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
542 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
543 assertEquals("myevent2", probeEvent
.getName());
544 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
545 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
546 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
547 assertEquals("0x0", probeEvent
.getOffset());
548 assertNull(null, probeEvent
.getAddress());
549 assertEquals("init_post", probeEvent
.getSymbol());
551 // ------------------------------------------------------------------------
552 // enable event (dynamic probe) on session
553 // ------------------------------------------------------------------------
554 eventsDialogStub
.setIsDynamicProbe(true);
555 eventsDialogStub
.setDynamicProbe("init_post:0x1000");
556 eventsDialogStub
.setProbeEventName("myevent3");
558 fFacility
.executeCommand(session
, "enableEventOnSession");
560 // Get Kernel domain component instance
561 domains
= session
.getChildren();
562 assertNotNull(domains
);
563 assertEquals(1, domains
.length
);
565 // Verify that channel was created with correct data
566 channels
= domains
[0].getChildren();
567 channel
= (TraceChannelComponent
) channels
[2];
568 // No need to check parameters of default channel because that has been done in other tests
570 channel0Events
= channel
.getChildren();
571 assertEquals(7, channel0Events
.length
);
573 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
575 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
576 assertEquals("myevent3", probeEvent
.getName());
577 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
578 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
579 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
580 assertEquals("0x1000", probeEvent
.getOffset());
581 assertNull(null, probeEvent
.getAddress());
582 assertEquals("init_post", probeEvent
.getSymbol());
584 // ------------------------------------------------------------------------
585 // enable event (dynamic function probe) on session
586 // ------------------------------------------------------------------------
587 eventsDialogStub
.setIsDynamicProbe(false);
588 eventsDialogStub
.setDynamicProbe(null);
589 eventsDialogStub
.setProbeEventName(null);
590 eventsDialogStub
.setIsFunctionProbe(true);
591 eventsDialogStub
.setFunctionEventName("myevent4");
592 eventsDialogStub
.setFunctionProbe("create_dev");
594 fFacility
.executeCommand(session
, "enableEventOnSession");
596 // Get Kernel domain component instance
597 domains
= session
.getChildren();
598 assertNotNull(domains
);
599 assertEquals(1, domains
.length
);
601 // Verify that channel was created with correct data
602 channels
= domains
[0].getChildren();
603 channel
= (TraceChannelComponent
) channels
[2];
604 // No need to check parameters of default channel because that has been done in other tests
606 channel0Events
= channel
.getChildren();
607 assertEquals(8, channel0Events
.length
);
609 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
611 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
612 assertEquals("myevent4", probeEvent
.getName());
613 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
614 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
615 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
616 assertEquals("0x0", probeEvent
.getOffset());
617 assertNull(null, probeEvent
.getAddress());
618 assertEquals("create_dev", probeEvent
.getSymbol());
620 // ------------------------------------------------------------------------
621 // enable event (dynamic function probe) on domain
622 // ------------------------------------------------------------------------
623 eventsDialogStub
.setIsFunctionProbe(true);
624 eventsDialogStub
.setFunctionEventName("myevent5");
625 eventsDialogStub
.setFunctionProbe("create_dev:0x2000");
627 fFacility
.executeCommand(domains
[0], "enableEventOnDomain");
629 // Get Kernel domain component instance
630 domains
= session
.getChildren();
631 assertNotNull(domains
);
632 assertEquals(1, domains
.length
);
634 // Verify that channel was created with correct data
635 channels
= domains
[0].getChildren();
636 channel
= (TraceChannelComponent
) channels
[2];
637 // No need to check parameters of default channel because that has been done in other tests
639 channel0Events
= channel
.getChildren();
640 assertEquals(9, channel0Events
.length
);
642 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
644 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
645 assertEquals("myevent5", probeEvent
.getName());
646 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
647 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
648 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
649 assertEquals("0x2000", probeEvent
.getOffset());
650 assertNull(null, probeEvent
.getAddress());
651 assertEquals("create_dev", probeEvent
.getSymbol());
653 // ------------------------------------------------------------------------
654 // enable event (dynamic function probe) on channel
655 // ------------------------------------------------------------------------
656 eventsDialogStub
.setIsFunctionProbe(true);
657 eventsDialogStub
.setFunctionEventName("myevent");
658 eventsDialogStub
.setFunctionProbe("create_dev:0x2000");
660 fFacility
.executeCommand(channels
[0], "enableEventOnChannel");
662 // Get Kernel domain component instance
663 domains
= session
.getChildren();
664 assertNotNull(domains
);
665 assertEquals(1, domains
.length
);
667 // Verify that channel was created with correct data
668 channels
= domains
[0].getChildren();
669 channel
= (TraceChannelComponent
) channels
[0];
670 // No need to check parameters of default channel because that has been done in other tests
672 channel0Events
= channel
.getChildren();
673 assertEquals(2, channel0Events
.length
);
675 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
677 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
678 assertEquals("myevent", probeEvent
.getName());
679 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
680 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
681 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
682 assertEquals("0x2000", probeEvent
.getOffset());
683 assertNull(null, probeEvent
.getAddress());
684 assertEquals("create_dev", probeEvent
.getSymbol());
686 // ------------------------------------------------------------------------
687 // Add Context on domain
688 // ------------------------------------------------------------------------
689 // Get Kernel domain component instance
690 domains
= session
.getChildren();
691 assertNotNull(domains
);
692 assertEquals(1, domains
.length
);
694 AddContextDialogStub addContextStub
= new AddContextDialogStub();
695 List
<String
> contexts
= new ArrayList
<String
>();
696 contexts
.add("prio");
697 contexts
.add("perf:branch-misses");
698 contexts
.add("perf:cache-misses");
699 addContextStub
.setContexts(contexts
);
700 TraceControlDialogFactory
.getInstance().setAddContextDialog(addContextStub
);
702 fFacility
.executeCommand(domains
[0], "addContextOnDomain");
703 // Currently there is nothing to verify because the list commands don't show any context information
704 // However, the execution of the command make sure that the correct service command line is build and executed.
706 // ------------------------------------------------------------------------
707 // Add Context on channel
708 // ------------------------------------------------------------------------
710 // Get Kernel domain component instance
711 domains
= session
.getChildren();
712 assertNotNull(domains
);
713 assertEquals(1, domains
.length
);
715 //Verify that channel was created with correct data
716 channels
= domains
[0].getChildren();
717 channel
= (TraceChannelComponent
) channels
[0];
720 // The setContext() verifies that the contexts set are part of the available contexts
721 // The available contexts are set by the command handler addContextOnDomain above.
722 // So we indirectly test here that the parsing and setting of available contexts were
723 // done correctly above.
724 addContextStub
.setContexts(contexts
);
725 } catch (IllegalArgumentException e
) {
726 fail("Exception caught - unknown context");
729 fFacility
.executeCommand(channel
, "addContextOnChannel");
730 // Currently there is nothing to verify because the list commands don't show any context information
731 // However, the execution of the command make sure that the correct service command line is build and executed.
733 // ------------------------------------------------------------------------
734 // Add Context on event
735 // ------------------------------------------------------------------------
736 // Get Kernel domain component instance
737 domains
= session
.getChildren();
738 assertNotNull(domains
);
739 assertEquals(1, domains
.length
);
741 //Verify that channel was created with correct data
742 channels
= domains
[0].getChildren();
743 channel
= (TraceChannelComponent
) channels
[2];
745 channel0Events
= channel
.getChildren();
747 event
= (TraceEventComponent
) channel0Events
[6];
749 fFacility
.executeCommand(event
, "addContextOnEvent");
750 // Currently there is nothing to verify because the list commands don't show any context information
751 // However, the execution of the command make sure that the correct service command line is build and executed.
753 // ------------------------------------------------------------------------
755 // ------------------------------------------------------------------------
756 // Get Kernel domain component instance
757 domains
= session
.getChildren();
758 assertNotNull(domains
);
759 assertEquals(1, domains
.length
);
761 fFacility
.executeCommand(domains
[0], "calibrate");
762 // There is nothing to verify here.
763 // However, the execution of the command make sure that the correct service command line is build and executed.
765 // ------------------------------------------------------------------------
767 // ------------------------------------------------------------------------
768 fFacility
.executeCommand(node
, "refresh");
769 groups
= node
.getChildren();
770 assertNotNull(groups
);
771 assertEquals(2, groups
.length
);
772 assertEquals(3, groups
[0].getChildren().length
); // provider
773 assertEquals(1, groups
[1].getChildren().length
); // sessions
774 assertEquals(1, groups
[1].getChildren()[0].getChildren().length
); // domains
775 assertEquals(3, groups
[1].getChildren()[0].getChildren()[0].getChildren().length
); // channels
776 assertEquals(2, groups
[1].getChildren()[0].getChildren()[0].getChildren()[0].getChildren().length
); // events (of channel[0])
778 // Initialize session handling scenario
779 fProxy
.setScenario(TraceControlTestFacility
.SCEN_SCENARIO_SESSION_HANDLING
);
781 session
= (TraceSessionComponent
)groups
[1].getChildren()[0];
783 // ------------------------------------------------------------------------
785 // ------------------------------------------------------------------------
786 fFacility
.startSession(session
);
787 assertEquals(TraceSessionState
.ACTIVE
, session
.getSessionState());
789 // ------------------------------------------------------------------------
791 // ------------------------------------------------------------------------
792 fFacility
.stopSession(session
);
793 assertEquals(TraceSessionState
.INACTIVE
, session
.getSessionState());
795 // ------------------------------------------------------------------------
797 // ------------------------------------------------------------------------
799 fFacility
.destroySession(session
);
801 // Verify that no more session components exist
802 assertEquals(0, groups
[1].getChildren().length
);
804 //-------------------------------------------------------------------------
806 //-------------------------------------------------------------------------
807 fFacility
.executeCommand(node
, "disconnect");
808 assertEquals(TargetNodeState
.DISCONNECTED
, node
.getTargetNodeState());
810 //-------------------------------------------------------------------------
812 //-------------------------------------------------------------------------
814 fFacility
.executeCommand(node
, "delete");
815 assertEquals(0,fFacility
.getControlView().getTraceControlRoot().getChildren().length
);