1 /**********************************************************************
2 * Copyright (c) 2012 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 **********************************************************************/
12 package org
.eclipse
.linuxtools
.lttng2
.ui
.tests
.control
.model
.component
;
16 import java
.util
.ArrayList
;
17 import java
.util
.List
;
19 import junit
.framework
.Test
;
20 import junit
.framework
.TestCase
;
21 import junit
.framework
.TestSuite
;
23 import org
.eclipse
.core
.runtime
.FileLocator
;
24 import org
.eclipse
.core
.runtime
.Path
;
25 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.dialogs
.AddContextDialogStub
;
26 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.dialogs
.EnableChannelDialogStub
;
27 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.dialogs
.CreateSessionDialogStub
;
28 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.dialogs
.DestroyConfirmDialogStub
;
29 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.dialogs
.EnableEventsDialogStub
;
30 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.dialogs
.GetEventInfoDialogStub
;
31 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.service
.TestRemoteSystemProxy
;
32 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.dialogs
.TraceControlDialogFactory
;
33 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.ITraceControlComponent
;
34 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.TargetNodeState
;
35 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.TraceEnablement
;
36 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.TraceEventType
;
37 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.TraceLogLevel
;
38 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.TraceSessionState
;
39 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.ChannelInfo
;
40 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TargetNodeComponent
;
41 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceChannelComponent
;
42 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceEventComponent
;
43 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceProbeEventComponent
;
44 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceSessionComponent
;
45 import org
.eclipse
.rse
.core
.model
.Host
;
46 import org
.eclipse
.rse
.core
.model
.IHost
;
47 import org
.eclipse
.rse
.internal
.core
.model
.SystemProfile
;
48 import org
.junit
.After
;
49 import org
.junit
.Before
;
50 import org
.osgi
.framework
.FrameworkUtil
;
53 * The class <code>TraceControlKernelSessionTests</code> contains Kernel session/channel/event
54 * handling test cases.
57 @SuppressWarnings("nls")
58 public class TraceControlKernelSessionTests
extends TestCase
{
60 // ------------------------------------------------------------------------
62 // ------------------------------------------------------------------------
63 private static final String TEST_STREAM
= "CreateTreeTest.cfg";
64 private static final String SCEN_SCENARIO3_TEST
= "Scenario3";
66 // ------------------------------------------------------------------------
68 // ------------------------------------------------------------------------
69 private TraceControlTestFacility fFacility
;
70 private TestRemoteSystemProxy fProxy
;
71 private String fTestFile
;
73 // ------------------------------------------------------------------------
75 // ------------------------------------------------------------------------
78 * Returns test setup used when executing test case stand-alone.
79 * @return Test setup class
81 public static Test
suite() {
82 return new ModelImplTestSetup(new TestSuite(TraceControlKernelSessionTests
.class));
85 // ------------------------------------------------------------------------
87 // ------------------------------------------------------------------------
90 * Perform pre-test initialization.
93 * if the initialization fails for some reason
98 public void setUp() throws Exception
{
99 fFacility
= TraceControlTestFacility
.getInstance();
100 fProxy
= new TestRemoteSystemProxy();
101 URL location
= FileLocator
.find(FrameworkUtil
.getBundle(this.getClass()), new Path(TraceControlTestFacility
.DIRECTORY
+ File
.separator
+ TEST_STREAM
), null);
102 File testfile
= new File(FileLocator
.toFileURL(location
).toURI());
103 fTestFile
= testfile
.getAbsolutePath();
107 * Perform post-test clean-up.
110 * if the clean-up fails for some reason
115 public void tearDown() throws Exception
{
116 fFacility
.waitForJobs();
120 * Run the TraceControlComponent.
122 public void testTraceSessionTree() throws Exception
{
124 fProxy
.setTestFile(fTestFile
);
125 fProxy
.setScenario(TraceControlTestFacility
.SCEN_INIT_TEST
);
127 ITraceControlComponent root
= TraceControlTestFacility
.getInstance().getControlView().getTraceControlRoot();
129 @SuppressWarnings("restriction")
130 IHost host
= new Host(new SystemProfile("myProfile", true));
131 host
.setHostName("127.0.0.1");
133 TargetNodeComponent node
= new TargetNodeComponent("myNode", root
, host
, fProxy
);
136 fFacility
.waitForJobs();
138 fFacility
.executeCommand(node
, "connect");
140 while ((i
< 10) && (node
.getTargetNodeState() != TargetNodeState
.CONNECTED
)) {
142 fFacility
.delay(TraceControlTestFacility
.GUI_REFESH_DELAY
);
145 // Verify that node is connected
146 assertEquals(TargetNodeState
.CONNECTED
, node
.getTargetNodeState());
148 // Get provider groups
149 ITraceControlComponent
[] groups
= node
.getChildren();
150 assertNotNull(groups
);
151 assertEquals(2, groups
.length
);
153 // Initialize dialog implementations for command execution
154 TraceControlDialogFactory
.getInstance().setCreateSessionDialog(new CreateSessionDialogStub());
155 TraceControlDialogFactory
.getInstance().setGetEventInfoDialog(new GetEventInfoDialogStub());
156 TraceControlDialogFactory
.getInstance().setConfirmDialog(new DestroyConfirmDialogStub());
158 // Initialize session handling scenario
159 fProxy
.setScenario(TraceControlTestFacility
.SCEN_SCENARIO_SESSION_HANDLING
);
161 // ------------------------------------------------------------------------
163 // ------------------------------------------------------------------------
164 TraceSessionComponent session
= fFacility
.createSession(groups
[1]);
166 // Verify that session was created
167 assertNotNull(session
);
168 assertEquals("mysession", session
.getName());
169 assertEquals("/home/user/lttng-traces/mysession-20120314-132824", session
.getSessionPath());
170 assertEquals(TraceSessionState
.INACTIVE
, session
.getSessionState());
172 // Initialize scenario
173 fProxy
.setScenario(SCEN_SCENARIO3_TEST
);
175 // ------------------------------------------------------------------------
176 // Enable channel on session
177 // ------------------------------------------------------------------------
178 EnableChannelDialogStub channelStub
= new EnableChannelDialogStub();
179 channelStub
.setIsKernel(true);
180 TraceControlDialogFactory
.getInstance().setEnableChannelDialog(channelStub
);
182 fFacility
.executeCommand(session
, "enableChannelOnSession");
184 // Verify that Kernel domain was created
185 ITraceControlComponent
[] domains
= session
.getChildren();
186 assertNotNull(domains
);
187 assertEquals(1, domains
.length
);
189 assertEquals("Kernel", domains
[0].getName());
191 // Verify that channel was created with correct data
192 ITraceControlComponent
[] channels
= domains
[0].getChildren();
193 assertNotNull(channels
);
194 assertEquals(1, channels
.length
);
196 assertTrue(channels
[0] instanceof TraceChannelComponent
);
197 TraceChannelComponent channel
= (TraceChannelComponent
) channels
[0];
198 assertEquals("mychannel", channel
.getName());
199 assertEquals(4, channel
.getNumberOfSubBuffers());
200 assertEquals("splice()", channel
.getOutputType());
201 assertEquals(true, channel
.isOverwriteMode());
202 assertEquals(200, channel
.getReadTimer());
203 assertEquals(TraceEnablement
.ENABLED
, channel
.getState());
204 assertEquals(16384, channel
.getSubBufferSize());
205 assertEquals(100, channel
.getSwitchTimer());
207 // ------------------------------------------------------------------------
208 // Create channel on domain
209 // ------------------------------------------------------------------------
210 ChannelInfo info
= (ChannelInfo
)channelStub
.getChannelInfo();
211 info
.setName("mychannel2");
212 info
.setOverwriteMode(false);
213 info
.setSubBufferSize(32768);
214 info
.setNumberOfSubBuffers(2);
215 info
.setSwitchTimer(100);
216 info
.setReadTimer(200);
217 channelStub
.setChannelInfo(info
);
219 fFacility
.executeCommand(domains
[0], "enableChannelOnDomain");
221 // Get Kernel domain component instance
222 domains
= session
.getChildren();
223 assertNotNull(domains
);
224 assertEquals(1, domains
.length
);
226 // Verify that channel was created with correct data
227 channels
= domains
[0].getChildren();
228 assertNotNull(channels
);
229 assertEquals(2, channels
.length
);
231 assertTrue(channels
[1] instanceof TraceChannelComponent
);
232 channel
= (TraceChannelComponent
) channels
[1];
233 assertEquals("mychannel2", channel
.getName());
234 assertEquals(2, channel
.getNumberOfSubBuffers());
235 assertEquals("splice()", channel
.getOutputType());
236 assertEquals(false, channel
.isOverwriteMode());
237 assertEquals(200, channel
.getReadTimer());
238 assertEquals(TraceEnablement
.ENABLED
, channel
.getState());
239 assertEquals(32768, channel
.getSubBufferSize());
240 assertEquals(100, channel
.getSwitchTimer());
242 EnableEventsDialogStub eventsDialogStub
= new EnableEventsDialogStub();
243 eventsDialogStub
.setIsTracePoints(true);
244 List
<String
> events
= new ArrayList
<String
>();
245 events
.add("sched_kthread_stop");
246 events
.add("sched_kthread_stop_ret");
247 eventsDialogStub
.setNames(events
);
248 eventsDialogStub
.setIsKernel(true);
249 TraceControlDialogFactory
.getInstance().setEnableEventsDialog(eventsDialogStub
);
251 // ------------------------------------------------------------------------
253 // ------------------------------------------------------------------------
254 // Get Kernel domain component instance
255 domains
= session
.getChildren();
256 assertNotNull(domains
);
257 assertEquals(1, domains
.length
);
259 // Verify that channel was created with correct data
260 channels
= domains
[0].getChildren();
261 assertNotNull(channels
);
262 assertEquals(2, channels
.length
);
264 fFacility
.executeCommand(channels
, "disableChannel");
266 assertEquals(TraceEnablement
.DISABLED
, ((TraceChannelComponent
)channels
[0]).getState());
267 assertEquals(TraceEnablement
.DISABLED
, ((TraceChannelComponent
)channels
[1]).getState());
269 // ------------------------------------------------------------------------
271 // ------------------------------------------------------------------------
272 // Get Kernel domain component instance
273 domains
= session
.getChildren();
274 assertNotNull(domains
);
275 assertEquals(1, domains
.length
);
277 // Verify that channel was created with correct data
278 channels
= domains
[0].getChildren();
279 assertNotNull(channels
);
280 assertEquals(2, channels
.length
);
282 fFacility
.executeCommand(channels
, "enableChannel");
284 assertEquals(TraceEnablement
.ENABLED
, ((TraceChannelComponent
)channels
[0]).getState());
285 assertEquals(TraceEnablement
.ENABLED
, ((TraceChannelComponent
)channels
[1]).getState());
287 // ------------------------------------------------------------------------
288 // enable event (tracepoints) on session
289 // ------------------------------------------------------------------------
290 fFacility
.executeCommand(session
, "enableEventOnSession");
292 // Get Kernel domain component instance
293 domains
= session
.getChildren();
294 assertNotNull(domains
);
295 assertEquals(1, domains
.length
);
297 // Verify that channel was created with correct data
298 channels
= domains
[0].getChildren();
299 assertNotNull(channels
);
300 assertEquals(3, channels
.length
);
302 assertTrue(channels
[2] instanceof TraceChannelComponent
);
303 channel
= (TraceChannelComponent
) channels
[2];
304 assertEquals("channel0", channel
.getName());
305 // No need to check parameters of default channel because that has been done in other tests
307 ITraceControlComponent
[] channel0Events
= channel
.getChildren();
308 assertEquals(2, channel0Events
.length
);
310 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
311 assertTrue(channel0Events
[1] instanceof TraceEventComponent
);
313 TraceEventComponent event
= (TraceEventComponent
) channel0Events
[0];
314 assertEquals("sched_kthread_stop_ret", event
.getName());
315 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
316 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
317 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
319 event
= (TraceEventComponent
) channel0Events
[1];
320 assertEquals("sched_kthread_stop", event
.getName());
321 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
322 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
323 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
325 // ------------------------------------------------------------------------
326 // enable event (tracepoints) on domain
327 // ------------------------------------------------------------------------
329 events
.add("sched_wakeup_new");
330 eventsDialogStub
.setNames(events
);
332 fFacility
.executeCommand(domains
[0], "enableEventOnDomain");
334 // Get Kernel domain component instance
335 domains
= session
.getChildren();
336 assertNotNull(domains
);
337 assertEquals(1, domains
.length
);
339 // Verify that channel was created with correct data
340 channels
= domains
[0].getChildren();
341 channel
= (TraceChannelComponent
) channels
[2];
342 // No need to check parameters of default channel because that has been done in other tests
344 channel
= (TraceChannelComponent
) channels
[2];
346 channel0Events
= channel
.getChildren();
347 assertEquals(3, channel0Events
.length
);
349 assertTrue(channel0Events
[2] instanceof TraceEventComponent
);
351 event
= (TraceEventComponent
) channel0Events
[2];
352 assertEquals("sched_wakeup_new", event
.getName());
353 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
354 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
355 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
357 // ------------------------------------------------------------------------
358 // enable event (tracepoints) on channel
359 // ------------------------------------------------------------------------
361 eventsDialogStub
.setNames(events
);
362 eventsDialogStub
.setIsAllTracePoints(true);
364 fFacility
.executeCommand(channels
[1], "enableEventOnChannel");
366 // Get Kernel domain component instance
367 domains
= session
.getChildren();
368 assertNotNull(domains
);
369 assertEquals(1, domains
.length
);
371 // Verify that channel was created with correct data
372 channels
= domains
[0].getChildren();
373 // No need to check parameters of default channel because that has been done in other tests
374 channel
= (TraceChannelComponent
) channels
[1];
376 channel0Events
= channel
.getChildren();
377 assertEquals(3, channel0Events
.length
);
379 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
380 assertTrue(channel0Events
[1] instanceof TraceEventComponent
);
381 assertTrue(channel0Events
[2] instanceof TraceEventComponent
);
383 event
= (TraceEventComponent
) channel0Events
[0];
384 assertEquals("sched_kthread_stop_ret", event
.getName());
385 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
386 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
387 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
389 event
= (TraceEventComponent
) channel0Events
[1];
390 assertEquals("sched_kthread_stop", event
.getName());
391 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
392 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
393 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
395 event
= (TraceEventComponent
) channel0Events
[2];
396 assertEquals("sched_wakeup_new", event
.getName());
397 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
398 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
399 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
401 // ------------------------------------------------------------------------
402 // enable event (syscall) on channel
403 // ------------------------------------------------------------------------
405 eventsDialogStub
.setIsTracePoints(false);
406 eventsDialogStub
.setIsAllTracePoints(false);
407 eventsDialogStub
.setIsSysCalls(true);
409 fFacility
.executeCommand(channels
[0], "enableEventOnChannel");
411 // Get Kernel domain component instance
412 domains
= session
.getChildren();
413 assertNotNull(domains
);
414 assertEquals(1, domains
.length
);
416 // Verify that channel was created with correct data
417 channels
= domains
[0].getChildren();
418 channel
= (TraceChannelComponent
) channels
[0];
419 // No need to check parameters of default channel because that has been done in other tests
421 channel
= (TraceChannelComponent
) channels
[0];
423 channel0Events
= channel
.getChildren();
424 assertEquals(1, channel0Events
.length
);
426 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
428 event
= (TraceEventComponent
) channel0Events
[0];
429 assertEquals("syscalls", event
.getName());
430 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, event
.getLogLevel());
431 assertEquals(TraceEventType
.SYSCALL
, event
.getEventType());
432 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
434 // ------------------------------------------------------------------------
435 // enable event (syscall) on domain
436 // ------------------------------------------------------------------------
437 fFacility
.executeCommand(domains
[0], "enableEventOnDomain");
439 // Get Kernel domain component instance
440 domains
= session
.getChildren();
441 assertNotNull(domains
);
442 assertEquals(1, domains
.length
);
444 // Verify that channel was created with correct data
445 channels
= domains
[0].getChildren();
446 channel
= (TraceChannelComponent
) channels
[0];
447 // No need to check parameters of default channel because that has been done in other tests
449 channel
= (TraceChannelComponent
) channels
[2];
451 channel0Events
= channel
.getChildren();
452 assertEquals(4, channel0Events
.length
);
454 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
456 event
= (TraceEventComponent
) channel0Events
[0];
457 assertEquals("syscalls", event
.getName());
458 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, event
.getLogLevel());
459 assertEquals(TraceEventType
.SYSCALL
, event
.getEventType());
460 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
462 // ------------------------------------------------------------------------
463 // enable event (syscall) on session
464 // ------------------------------------------------------------------------
465 fFacility
.executeCommand(session
, "enableEventOnSession");
467 // Get Kernel domain component instance
468 domains
= session
.getChildren();
469 assertNotNull(domains
);
470 assertEquals(1, domains
.length
);
472 // Verify that channel was created with correct data
473 channels
= domains
[0].getChildren();
474 channel
= (TraceChannelComponent
) channels
[0];
475 // No need to check parameters of default channel because that has been done in other tests
477 channel
= (TraceChannelComponent
) channels
[2];
479 channel0Events
= channel
.getChildren();
480 assertEquals(4, channel0Events
.length
);
482 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
484 event
= (TraceEventComponent
) channel0Events
[0];
485 assertEquals("syscalls", event
.getName());
486 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, event
.getLogLevel());
487 assertEquals(TraceEventType
.SYSCALL
, event
.getEventType());
488 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
491 // ------------------------------------------------------------------------
492 // enable event (dynamic probe) on domain
493 // ------------------------------------------------------------------------
495 eventsDialogStub
.setIsSysCalls(false);
496 eventsDialogStub
.setIsDynamicProbe(true);
497 eventsDialogStub
.setDynamicProbe("0xc0101280");
498 eventsDialogStub
.setProbeEventName("myevent1");
500 fFacility
.executeCommand(domains
[0], "enableEventOnDomain");
502 // Get Kernel domain component instance
503 domains
= session
.getChildren();
504 assertNotNull(domains
);
505 assertEquals(1, domains
.length
);
507 // Verify that channel was created with correct data
508 channels
= domains
[0].getChildren();
509 channel
= (TraceChannelComponent
) channels
[2];
510 // No need to check parameters of default channel because that has been done in other tests
512 channel0Events
= channel
.getChildren();
513 assertEquals(5, channel0Events
.length
);
515 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
517 TraceProbeEventComponent probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
518 assertEquals("myevent1", probeEvent
.getName());
519 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
520 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
521 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
522 assertNull(probeEvent
.getOffset());
523 assertEquals("0xc0101280", probeEvent
.getAddress());
524 assertNull(probeEvent
.getSymbol());
526 // ------------------------------------------------------------------------
527 // enable event (dynamic probe) on channel
528 // ------------------------------------------------------------------------
529 eventsDialogStub
.setIsDynamicProbe(true);
530 eventsDialogStub
.setDynamicProbe("init_post");
531 eventsDialogStub
.setProbeEventName("myevent2");
533 fFacility
.executeCommand(channels
[2], "enableEventOnChannel");
535 // Get Kernel domain component instance
536 domains
= session
.getChildren();
537 assertNotNull(domains
);
538 assertEquals(1, domains
.length
);
540 // Verify that channel was created with correct data
541 channels
= domains
[0].getChildren();
542 channel
= (TraceChannelComponent
) channels
[2];
543 // No need to check parameters of default channel because that has been done in other tests
545 channel0Events
= channel
.getChildren();
546 assertEquals(6, channel0Events
.length
);
548 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
550 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
551 assertEquals("myevent2", probeEvent
.getName());
552 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
553 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
554 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
555 assertEquals("0x0", probeEvent
.getOffset());
556 assertNull(null, probeEvent
.getAddress());
557 assertEquals("init_post", probeEvent
.getSymbol());
559 // ------------------------------------------------------------------------
560 // enable event (dynamic probe) on session
561 // ------------------------------------------------------------------------
562 eventsDialogStub
.setIsDynamicProbe(true);
563 eventsDialogStub
.setDynamicProbe("init_post:0x1000");
564 eventsDialogStub
.setProbeEventName("myevent3");
566 fFacility
.executeCommand(session
, "enableEventOnSession");
568 // Get Kernel domain component instance
569 domains
= session
.getChildren();
570 assertNotNull(domains
);
571 assertEquals(1, domains
.length
);
573 // Verify that channel was created with correct data
574 channels
= domains
[0].getChildren();
575 channel
= (TraceChannelComponent
) channels
[2];
576 // No need to check parameters of default channel because that has been done in other tests
578 channel0Events
= channel
.getChildren();
579 assertEquals(7, channel0Events
.length
);
581 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
583 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
584 assertEquals("myevent3", probeEvent
.getName());
585 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
586 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
587 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
588 assertEquals("0x1000", probeEvent
.getOffset());
589 assertNull(null, probeEvent
.getAddress());
590 assertEquals("init_post", probeEvent
.getSymbol());
592 // ------------------------------------------------------------------------
593 // enable event (dynamic function probe) on session
594 // ------------------------------------------------------------------------
595 eventsDialogStub
.setIsDynamicProbe(false);
596 eventsDialogStub
.setDynamicProbe(null);
597 eventsDialogStub
.setProbeEventName(null);
598 eventsDialogStub
.setIsFunctionProbe(true);
599 eventsDialogStub
.setFunctionEventName("myevent4");
600 eventsDialogStub
.setFunctionProbe("create_dev");
602 fFacility
.executeCommand(session
, "enableEventOnSession");
604 // Get Kernel domain component instance
605 domains
= session
.getChildren();
606 assertNotNull(domains
);
607 assertEquals(1, domains
.length
);
609 // Verify that channel was created with correct data
610 channels
= domains
[0].getChildren();
611 channel
= (TraceChannelComponent
) channels
[2];
612 // No need to check parameters of default channel because that has been done in other tests
614 channel0Events
= channel
.getChildren();
615 assertEquals(8, channel0Events
.length
);
617 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
619 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
620 assertEquals("myevent4", probeEvent
.getName());
621 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
622 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
623 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
624 assertEquals("0x0", probeEvent
.getOffset());
625 assertNull(null, probeEvent
.getAddress());
626 assertEquals("create_dev", probeEvent
.getSymbol());
628 // ------------------------------------------------------------------------
629 // enable event (dynamic function probe) on domain
630 // ------------------------------------------------------------------------
631 eventsDialogStub
.setIsFunctionProbe(true);
632 eventsDialogStub
.setFunctionEventName("myevent5");
633 eventsDialogStub
.setFunctionProbe("create_dev:0x2000");
635 fFacility
.executeCommand(domains
[0], "enableEventOnDomain");
637 // Get Kernel domain component instance
638 domains
= session
.getChildren();
639 assertNotNull(domains
);
640 assertEquals(1, domains
.length
);
642 // Verify that channel was created with correct data
643 channels
= domains
[0].getChildren();
644 channel
= (TraceChannelComponent
) channels
[2];
645 // No need to check parameters of default channel because that has been done in other tests
647 channel0Events
= channel
.getChildren();
648 assertEquals(9, channel0Events
.length
);
650 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
652 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
653 assertEquals("myevent5", probeEvent
.getName());
654 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
655 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
656 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
657 assertEquals("0x2000", probeEvent
.getOffset());
658 assertNull(null, probeEvent
.getAddress());
659 assertEquals("create_dev", probeEvent
.getSymbol());
661 // ------------------------------------------------------------------------
662 // enable event (dynamic function probe) on channel
663 // ------------------------------------------------------------------------
664 eventsDialogStub
.setIsFunctionProbe(true);
665 eventsDialogStub
.setFunctionEventName("myevent");
666 eventsDialogStub
.setFunctionProbe("create_dev:0x2000");
668 fFacility
.executeCommand(channels
[0], "enableEventOnChannel");
670 // Get Kernel domain component instance
671 domains
= session
.getChildren();
672 assertNotNull(domains
);
673 assertEquals(1, domains
.length
);
675 // Verify that channel was created with correct data
676 channels
= domains
[0].getChildren();
677 channel
= (TraceChannelComponent
) channels
[0];
678 // No need to check parameters of default channel because that has been done in other tests
680 channel0Events
= channel
.getChildren();
681 assertEquals(2, channel0Events
.length
);
683 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
685 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
686 assertEquals("myevent", probeEvent
.getName());
687 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
688 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
689 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
690 assertEquals("0x2000", probeEvent
.getOffset());
691 assertNull(null, probeEvent
.getAddress());
692 assertEquals("create_dev", probeEvent
.getSymbol());
694 // ------------------------------------------------------------------------
695 // Add Context on domain
696 // ------------------------------------------------------------------------
697 // Get Kernel domain component instance
698 domains
= session
.getChildren();
699 assertNotNull(domains
);
700 assertEquals(1, domains
.length
);
702 AddContextDialogStub addContextStub
= new AddContextDialogStub();
703 List
<String
> contexts
= new ArrayList
<String
>();
704 contexts
.add("prio");
705 contexts
.add("perf:branch-misses");
706 contexts
.add("perf:cache-misses");
707 addContextStub
.setContexts(contexts
);
708 TraceControlDialogFactory
.getInstance().setAddContextDialog(addContextStub
);
710 fFacility
.executeCommand(domains
[0], "addContextOnDomain");
711 // Currently there is nothing to verify because the list commands don't show any context information
712 // However, the execution of the command make sure that the correct service command line is build and executed.
714 // ------------------------------------------------------------------------
715 // Add Context on channel
716 // ------------------------------------------------------------------------
718 // Get Kernel domain component instance
719 domains
= session
.getChildren();
720 assertNotNull(domains
);
721 assertEquals(1, domains
.length
);
723 //Verify that channel was created with correct data
724 channels
= domains
[0].getChildren();
725 channel
= (TraceChannelComponent
) channels
[0];
728 // The setContext() verifies that the contexts set are part of the available contexts
729 // The available contexts are set by the command handler addContextOnDomain above.
730 // So we indirectly test here that the parsing and setting of available contexts were
731 // done correctly above.
732 addContextStub
.setContexts(contexts
);
733 } catch (IllegalArgumentException e
) {
734 fail("Exception caught - unknown context");
737 fFacility
.executeCommand(channel
, "addContextOnChannel");
738 // Currently there is nothing to verify because the list commands don't show any context information
739 // However, the execution of the command make sure that the correct service command line is build and executed.
741 // ------------------------------------------------------------------------
742 // Add Context on event
743 // ------------------------------------------------------------------------
744 // Get Kernel domain component instance
745 domains
= session
.getChildren();
746 assertNotNull(domains
);
747 assertEquals(1, domains
.length
);
749 //Verify that channel was created with correct data
750 channels
= domains
[0].getChildren();
751 channel
= (TraceChannelComponent
) channels
[2];
753 channel0Events
= channel
.getChildren();
755 event
= (TraceEventComponent
) channel0Events
[6];
757 fFacility
.executeCommand(event
, "addContextOnEvent");
758 // Currently there is nothing to verify because the list commands don't show any context information
759 // However, the execution of the command make sure that the correct service command line is build and executed.
761 // ------------------------------------------------------------------------
763 // ------------------------------------------------------------------------
764 // Get Kernel domain component instance
765 domains
= session
.getChildren();
766 assertNotNull(domains
);
767 assertEquals(1, domains
.length
);
769 fFacility
.executeCommand(domains
[0], "calibrate");
770 // There is nothing to verify here.
771 // However, the execution of the command make sure that the correct service command line is build and executed.
773 // ------------------------------------------------------------------------
775 // ------------------------------------------------------------------------
776 fFacility
.executeCommand(node
, "refresh");
777 groups
= node
.getChildren();
778 assertNotNull(groups
);
779 assertEquals(2, groups
.length
);
780 assertEquals(3, groups
[0].getChildren().length
); // provider
781 assertEquals(1, groups
[1].getChildren().length
); // sessions
782 assertEquals(1, groups
[1].getChildren()[0].getChildren().length
); // domains
783 assertEquals(3, groups
[1].getChildren()[0].getChildren()[0].getChildren().length
); // channels
784 assertEquals(2, groups
[1].getChildren()[0].getChildren()[0].getChildren()[0].getChildren().length
); // events (of channel[0])
786 // Initialize session handling scenario
787 fProxy
.setScenario(TraceControlTestFacility
.SCEN_SCENARIO_SESSION_HANDLING
);
789 session
= (TraceSessionComponent
)groups
[1].getChildren()[0];
791 // ------------------------------------------------------------------------
793 // ------------------------------------------------------------------------
794 fFacility
.startSession(session
);
795 assertEquals(TraceSessionState
.ACTIVE
, session
.getSessionState());
797 // ------------------------------------------------------------------------
799 // ------------------------------------------------------------------------
800 fFacility
.stopSession(session
);
801 assertEquals(TraceSessionState
.INACTIVE
, session
.getSessionState());
803 // ------------------------------------------------------------------------
805 // ------------------------------------------------------------------------
807 fFacility
.destroySession(session
);
809 // Verify that no more session components exist
810 assertEquals(0, groups
[1].getChildren().length
);
812 //-------------------------------------------------------------------------
814 //-------------------------------------------------------------------------
815 fFacility
.executeCommand(node
, "disconnect");
816 assertEquals(TargetNodeState
.DISCONNECTED
, node
.getTargetNodeState());
818 //-------------------------------------------------------------------------
820 //-------------------------------------------------------------------------
822 fFacility
.executeCommand(node
, "delete");
823 assertEquals(0,fFacility
.getControlView().getTraceControlRoot().getChildren().length
);