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
.core
.control
.model
.TargetNodeState
;
26 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceEnablement
;
27 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceEventType
;
28 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceLogLevel
;
29 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceSessionState
;
30 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.impl
.ChannelInfo
;
31 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.dialogs
.AddContextDialogStub
;
32 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.dialogs
.CreateSessionDialogStub
;
33 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.dialogs
.DestroyConfirmDialogStub
;
34 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.dialogs
.EnableChannelDialogStub
;
35 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.dialogs
.EnableEventsDialogStub
;
36 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.dialogs
.GetEventInfoDialogStub
;
37 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.service
.TestRemoteSystemProxy
;
38 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.dialogs
.TraceControlDialogFactory
;
39 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.ITraceControlComponent
;
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
.RSECorePlugin
;
46 import org
.eclipse
.rse
.core
.model
.IHost
;
47 import org
.eclipse
.rse
.core
.model
.ISystemProfile
;
48 import org
.eclipse
.rse
.core
.model
.ISystemRegistry
;
49 import org
.junit
.After
;
50 import org
.junit
.Before
;
51 import org
.osgi
.framework
.FrameworkUtil
;
54 * The class <code>TraceControlKernelSessionTests</code> contains Kernel session/channel/event
55 * handling test cases.
58 @SuppressWarnings("nls")
59 public class TraceControlKernelSessionTests
extends TestCase
{
61 // ------------------------------------------------------------------------
63 // ------------------------------------------------------------------------
64 private static final String TEST_STREAM
= "CreateTreeTest.cfg";
65 private static final String SCEN_SCENARIO3_TEST
= "Scenario3";
67 // ------------------------------------------------------------------------
69 // ------------------------------------------------------------------------
70 private TraceControlTestFacility fFacility
;
71 private TestRemoteSystemProxy fProxy
;
72 private String fTestFile
;
74 // ------------------------------------------------------------------------
76 // ------------------------------------------------------------------------
79 * Returns test setup used when executing test case stand-alone.
80 * @return Test setup class
82 public static Test
suite() {
83 return new ModelImplTestSetup(new TestSuite(TraceControlKernelSessionTests
.class));
86 // ------------------------------------------------------------------------
88 // ------------------------------------------------------------------------
91 * Perform pre-test initialization.
94 * if the initialization fails for some reason
99 public void setUp() throws Exception
{
100 fFacility
= TraceControlTestFacility
.getInstance();
101 fProxy
= new TestRemoteSystemProxy();
102 URL location
= FileLocator
.find(FrameworkUtil
.getBundle(this.getClass()), new Path(TraceControlTestFacility
.DIRECTORY
+ File
.separator
+ TEST_STREAM
), null);
103 File testfile
= new File(FileLocator
.toFileURL(location
).toURI());
104 fTestFile
= testfile
.getAbsolutePath();
108 * Perform post-test clean-up.
111 * if the clean-up fails for some reason
116 public void tearDown() throws Exception
{
117 fFacility
.waitForJobs();
121 * Run the TraceControlComponent.
123 public void testTraceSessionTree() throws Exception
{
125 fProxy
.setTestFile(fTestFile
);
126 fProxy
.setScenario(TraceControlTestFacility
.SCEN_INIT_TEST
);
128 ITraceControlComponent root
= TraceControlTestFacility
.getInstance().getControlView().getTraceControlRoot();
130 ISystemRegistry registry
= RSECorePlugin
.getTheSystemRegistry();
131 ISystemProfile profile
= registry
.createSystemProfile("myProfile", true);
132 IHost host
= registry
.createLocalHost(profile
, "myProfile", "user");
134 TargetNodeComponent node
= new TargetNodeComponent("myNode", root
, host
, fProxy
);
137 fFacility
.waitForJobs();
139 fFacility
.executeCommand(node
, "connect");
141 while ((i
< 10) && (node
.getTargetNodeState() != TargetNodeState
.CONNECTED
)) {
143 fFacility
.delay(TraceControlTestFacility
.GUI_REFESH_DELAY
);
146 // Verify that node is connected
147 assertEquals(TargetNodeState
.CONNECTED
, node
.getTargetNodeState());
149 // Get provider groups
150 ITraceControlComponent
[] groups
= node
.getChildren();
151 assertNotNull(groups
);
152 assertEquals(2, groups
.length
);
154 // Initialize dialog implementations for command execution
155 TraceControlDialogFactory
.getInstance().setCreateSessionDialog(new CreateSessionDialogStub());
156 TraceControlDialogFactory
.getInstance().setGetEventInfoDialog(new GetEventInfoDialogStub());
157 TraceControlDialogFactory
.getInstance().setConfirmDialog(new DestroyConfirmDialogStub());
159 // Initialize session handling scenario
160 fProxy
.setScenario(TraceControlTestFacility
.SCEN_SCENARIO_SESSION_HANDLING
);
162 // ------------------------------------------------------------------------
164 // ------------------------------------------------------------------------
165 TraceSessionComponent session
= fFacility
.createSession(groups
[1]);
167 // Verify that session was created
168 assertNotNull(session
);
169 assertEquals("mysession", session
.getName());
170 assertEquals("/home/user/lttng-traces/mysession-20120314-132824", session
.getSessionPath());
171 assertEquals(TraceSessionState
.INACTIVE
, session
.getSessionState());
173 // Initialize scenario
174 fProxy
.setScenario(SCEN_SCENARIO3_TEST
);
176 // ------------------------------------------------------------------------
177 // Enable channel on session
178 // ------------------------------------------------------------------------
179 EnableChannelDialogStub channelStub
= new EnableChannelDialogStub();
180 channelStub
.setIsKernel(true);
181 TraceControlDialogFactory
.getInstance().setEnableChannelDialog(channelStub
);
183 fFacility
.executeCommand(session
, "enableChannelOnSession");
185 // Verify that Kernel domain was created
186 ITraceControlComponent
[] domains
= session
.getChildren();
187 assertNotNull(domains
);
188 assertEquals(1, domains
.length
);
190 assertEquals("Kernel", domains
[0].getName());
192 // Verify that channel was created with correct data
193 ITraceControlComponent
[] channels
= domains
[0].getChildren();
194 assertNotNull(channels
);
195 assertEquals(1, channels
.length
);
197 assertTrue(channels
[0] instanceof TraceChannelComponent
);
198 TraceChannelComponent channel
= (TraceChannelComponent
) channels
[0];
199 assertEquals("mychannel", channel
.getName());
200 assertEquals(4, channel
.getNumberOfSubBuffers());
201 assertEquals("splice()", channel
.getOutputType());
202 assertEquals(true, channel
.isOverwriteMode());
203 assertEquals(200, channel
.getReadTimer());
204 assertEquals(TraceEnablement
.ENABLED
, channel
.getState());
205 assertEquals(16384, channel
.getSubBufferSize());
206 assertEquals(100, channel
.getSwitchTimer());
208 // ------------------------------------------------------------------------
209 // Create channel on domain
210 // ------------------------------------------------------------------------
211 ChannelInfo info
= (ChannelInfo
)channelStub
.getChannelInfo();
212 info
.setName("mychannel2");
213 info
.setOverwriteMode(false);
214 info
.setSubBufferSize(32768);
215 info
.setNumberOfSubBuffers(2);
216 info
.setSwitchTimer(100);
217 info
.setReadTimer(200);
218 channelStub
.setChannelInfo(info
);
220 fFacility
.executeCommand(domains
[0], "enableChannelOnDomain");
222 // Get Kernel domain component instance
223 domains
= session
.getChildren();
224 assertNotNull(domains
);
225 assertEquals(1, domains
.length
);
227 // Verify that channel was created with correct data
228 channels
= domains
[0].getChildren();
229 assertNotNull(channels
);
230 assertEquals(2, channels
.length
);
232 assertTrue(channels
[1] instanceof TraceChannelComponent
);
233 channel
= (TraceChannelComponent
) channels
[1];
234 assertEquals("mychannel2", channel
.getName());
235 assertEquals(2, channel
.getNumberOfSubBuffers());
236 assertEquals("splice()", channel
.getOutputType());
237 assertEquals(false, channel
.isOverwriteMode());
238 assertEquals(200, channel
.getReadTimer());
239 assertEquals(TraceEnablement
.ENABLED
, channel
.getState());
240 assertEquals(32768, channel
.getSubBufferSize());
241 assertEquals(100, channel
.getSwitchTimer());
243 EnableEventsDialogStub eventsDialogStub
= new EnableEventsDialogStub();
244 eventsDialogStub
.setIsTracePoints(true);
245 List
<String
> events
= new ArrayList
<String
>();
246 events
.add("sched_kthread_stop");
247 events
.add("sched_kthread_stop_ret");
248 eventsDialogStub
.setNames(events
);
249 eventsDialogStub
.setIsKernel(true);
250 TraceControlDialogFactory
.getInstance().setEnableEventsDialog(eventsDialogStub
);
252 // ------------------------------------------------------------------------
254 // ------------------------------------------------------------------------
255 // Get Kernel domain component instance
256 domains
= session
.getChildren();
257 assertNotNull(domains
);
258 assertEquals(1, domains
.length
);
260 // Verify that channel was created with correct data
261 channels
= domains
[0].getChildren();
262 assertNotNull(channels
);
263 assertEquals(2, channels
.length
);
265 fFacility
.executeCommand(channels
, "disableChannel");
267 assertEquals(TraceEnablement
.DISABLED
, ((TraceChannelComponent
)channels
[0]).getState());
268 assertEquals(TraceEnablement
.DISABLED
, ((TraceChannelComponent
)channels
[1]).getState());
270 // ------------------------------------------------------------------------
272 // ------------------------------------------------------------------------
273 // Get Kernel domain component instance
274 domains
= session
.getChildren();
275 assertNotNull(domains
);
276 assertEquals(1, domains
.length
);
278 // Verify that channel was created with correct data
279 channels
= domains
[0].getChildren();
280 assertNotNull(channels
);
281 assertEquals(2, channels
.length
);
283 fFacility
.executeCommand(channels
, "enableChannel");
285 assertEquals(TraceEnablement
.ENABLED
, ((TraceChannelComponent
)channels
[0]).getState());
286 assertEquals(TraceEnablement
.ENABLED
, ((TraceChannelComponent
)channels
[1]).getState());
288 // ------------------------------------------------------------------------
289 // enable event (tracepoints) on session
290 // ------------------------------------------------------------------------
291 fFacility
.executeCommand(session
, "enableEventOnSession");
293 // Get Kernel domain component instance
294 domains
= session
.getChildren();
295 assertNotNull(domains
);
296 assertEquals(1, domains
.length
);
298 // Verify that channel was created with correct data
299 channels
= domains
[0].getChildren();
300 assertNotNull(channels
);
301 assertEquals(3, channels
.length
);
303 assertTrue(channels
[2] instanceof TraceChannelComponent
);
304 channel
= (TraceChannelComponent
) channels
[2];
305 assertEquals("channel0", channel
.getName());
306 // No need to check parameters of default channel because that has been done in other tests
308 ITraceControlComponent
[] channel0Events
= channel
.getChildren();
309 assertEquals(2, channel0Events
.length
);
311 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
312 assertTrue(channel0Events
[1] instanceof TraceEventComponent
);
314 TraceEventComponent event
= (TraceEventComponent
) channel0Events
[0];
315 assertEquals("sched_kthread_stop_ret", event
.getName());
316 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
317 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
318 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
320 event
= (TraceEventComponent
) channel0Events
[1];
321 assertEquals("sched_kthread_stop", event
.getName());
322 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
323 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
324 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
326 // ------------------------------------------------------------------------
327 // enable event (tracepoints) on domain
328 // ------------------------------------------------------------------------
330 events
.add("sched_wakeup_new");
331 eventsDialogStub
.setNames(events
);
333 fFacility
.executeCommand(domains
[0], "enableEventOnDomain");
335 // Get Kernel domain component instance
336 domains
= session
.getChildren();
337 assertNotNull(domains
);
338 assertEquals(1, domains
.length
);
340 // Verify that channel was created with correct data
341 channels
= domains
[0].getChildren();
342 channel
= (TraceChannelComponent
) channels
[2];
343 // No need to check parameters of default channel because that has been done in other tests
345 channel
= (TraceChannelComponent
) channels
[2];
347 channel0Events
= channel
.getChildren();
348 assertEquals(3, channel0Events
.length
);
350 assertTrue(channel0Events
[2] instanceof TraceEventComponent
);
352 event
= (TraceEventComponent
) channel0Events
[2];
353 assertEquals("sched_wakeup_new", event
.getName());
354 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
355 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
356 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
358 // ------------------------------------------------------------------------
359 // enable event (tracepoints) on channel
360 // ------------------------------------------------------------------------
362 eventsDialogStub
.setNames(events
);
363 eventsDialogStub
.setIsAllTracePoints(true);
365 fFacility
.executeCommand(channels
[1], "enableEventOnChannel");
367 // Get Kernel domain component instance
368 domains
= session
.getChildren();
369 assertNotNull(domains
);
370 assertEquals(1, domains
.length
);
372 // Verify that channel was created with correct data
373 channels
= domains
[0].getChildren();
374 // No need to check parameters of default channel because that has been done in other tests
375 channel
= (TraceChannelComponent
) channels
[1];
377 channel0Events
= channel
.getChildren();
378 assertEquals(3, channel0Events
.length
);
380 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
381 assertTrue(channel0Events
[1] instanceof TraceEventComponent
);
382 assertTrue(channel0Events
[2] instanceof TraceEventComponent
);
384 event
= (TraceEventComponent
) channel0Events
[0];
385 assertEquals("sched_kthread_stop_ret", event
.getName());
386 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
387 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
388 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
390 event
= (TraceEventComponent
) channel0Events
[1];
391 assertEquals("sched_kthread_stop", event
.getName());
392 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
393 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
394 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
396 event
= (TraceEventComponent
) channel0Events
[2];
397 assertEquals("sched_wakeup_new", event
.getName());
398 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
399 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
400 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
402 // ------------------------------------------------------------------------
403 // enable event (syscall) on channel
404 // ------------------------------------------------------------------------
406 eventsDialogStub
.setIsTracePoints(false);
407 eventsDialogStub
.setIsAllTracePoints(false);
408 eventsDialogStub
.setIsSysCalls(true);
410 fFacility
.executeCommand(channels
[0], "enableEventOnChannel");
412 // Get Kernel domain component instance
413 domains
= session
.getChildren();
414 assertNotNull(domains
);
415 assertEquals(1, domains
.length
);
417 // Verify that channel was created with correct data
418 channels
= domains
[0].getChildren();
419 channel
= (TraceChannelComponent
) channels
[0];
420 // No need to check parameters of default channel because that has been done in other tests
422 channel
= (TraceChannelComponent
) channels
[0];
424 channel0Events
= channel
.getChildren();
425 assertEquals(1, channel0Events
.length
);
427 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
429 event
= (TraceEventComponent
) channel0Events
[0];
430 assertEquals("syscalls", event
.getName());
431 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, event
.getLogLevel());
432 assertEquals(TraceEventType
.SYSCALL
, event
.getEventType());
433 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
435 // ------------------------------------------------------------------------
436 // enable event (syscall) on domain
437 // ------------------------------------------------------------------------
438 fFacility
.executeCommand(domains
[0], "enableEventOnDomain");
440 // Get Kernel domain component instance
441 domains
= session
.getChildren();
442 assertNotNull(domains
);
443 assertEquals(1, domains
.length
);
445 // Verify that channel was created with correct data
446 channels
= domains
[0].getChildren();
447 channel
= (TraceChannelComponent
) channels
[0];
448 // No need to check parameters of default channel because that has been done in other tests
450 channel
= (TraceChannelComponent
) channels
[2];
452 channel0Events
= channel
.getChildren();
453 assertEquals(4, channel0Events
.length
);
455 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
457 event
= (TraceEventComponent
) channel0Events
[0];
458 assertEquals("syscalls", event
.getName());
459 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, event
.getLogLevel());
460 assertEquals(TraceEventType
.SYSCALL
, event
.getEventType());
461 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
463 // ------------------------------------------------------------------------
464 // enable event (syscall) on session
465 // ------------------------------------------------------------------------
466 fFacility
.executeCommand(session
, "enableEventOnSession");
468 // Get Kernel domain component instance
469 domains
= session
.getChildren();
470 assertNotNull(domains
);
471 assertEquals(1, domains
.length
);
473 // Verify that channel was created with correct data
474 channels
= domains
[0].getChildren();
475 channel
= (TraceChannelComponent
) channels
[0];
476 // No need to check parameters of default channel because that has been done in other tests
478 channel
= (TraceChannelComponent
) channels
[2];
480 channel0Events
= channel
.getChildren();
481 assertEquals(4, channel0Events
.length
);
483 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
485 event
= (TraceEventComponent
) channel0Events
[0];
486 assertEquals("syscalls", event
.getName());
487 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, event
.getLogLevel());
488 assertEquals(TraceEventType
.SYSCALL
, event
.getEventType());
489 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
492 // ------------------------------------------------------------------------
493 // enable event (dynamic probe) on domain
494 // ------------------------------------------------------------------------
496 eventsDialogStub
.setIsSysCalls(false);
497 eventsDialogStub
.setIsDynamicProbe(true);
498 eventsDialogStub
.setDynamicProbe("0xc0101280");
499 eventsDialogStub
.setProbeEventName("myevent1");
501 fFacility
.executeCommand(domains
[0], "enableEventOnDomain");
503 // Get Kernel domain component instance
504 domains
= session
.getChildren();
505 assertNotNull(domains
);
506 assertEquals(1, domains
.length
);
508 // Verify that channel was created with correct data
509 channels
= domains
[0].getChildren();
510 channel
= (TraceChannelComponent
) channels
[2];
511 // No need to check parameters of default channel because that has been done in other tests
513 channel0Events
= channel
.getChildren();
514 assertEquals(5, channel0Events
.length
);
516 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
518 TraceProbeEventComponent probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
519 assertEquals("myevent1", probeEvent
.getName());
520 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
521 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
522 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
523 assertNull(probeEvent
.getOffset());
524 assertEquals("0xc0101280", probeEvent
.getAddress());
525 assertNull(probeEvent
.getSymbol());
527 // ------------------------------------------------------------------------
528 // enable event (dynamic probe) on channel
529 // ------------------------------------------------------------------------
530 eventsDialogStub
.setIsDynamicProbe(true);
531 eventsDialogStub
.setDynamicProbe("init_post");
532 eventsDialogStub
.setProbeEventName("myevent2");
534 fFacility
.executeCommand(channels
[2], "enableEventOnChannel");
536 // Get Kernel domain component instance
537 domains
= session
.getChildren();
538 assertNotNull(domains
);
539 assertEquals(1, domains
.length
);
541 // Verify that channel was created with correct data
542 channels
= domains
[0].getChildren();
543 channel
= (TraceChannelComponent
) channels
[2];
544 // No need to check parameters of default channel because that has been done in other tests
546 channel0Events
= channel
.getChildren();
547 assertEquals(6, channel0Events
.length
);
549 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
551 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
552 assertEquals("myevent2", probeEvent
.getName());
553 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
554 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
555 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
556 assertEquals("0x0", probeEvent
.getOffset());
557 assertNull(null, probeEvent
.getAddress());
558 assertEquals("init_post", probeEvent
.getSymbol());
560 // ------------------------------------------------------------------------
561 // enable event (dynamic probe) on session
562 // ------------------------------------------------------------------------
563 eventsDialogStub
.setIsDynamicProbe(true);
564 eventsDialogStub
.setDynamicProbe("init_post:0x1000");
565 eventsDialogStub
.setProbeEventName("myevent3");
567 fFacility
.executeCommand(session
, "enableEventOnSession");
569 // Get Kernel domain component instance
570 domains
= session
.getChildren();
571 assertNotNull(domains
);
572 assertEquals(1, domains
.length
);
574 // Verify that channel was created with correct data
575 channels
= domains
[0].getChildren();
576 channel
= (TraceChannelComponent
) channels
[2];
577 // No need to check parameters of default channel because that has been done in other tests
579 channel0Events
= channel
.getChildren();
580 assertEquals(7, channel0Events
.length
);
582 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
584 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
585 assertEquals("myevent3", probeEvent
.getName());
586 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
587 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
588 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
589 assertEquals("0x1000", probeEvent
.getOffset());
590 assertNull(null, probeEvent
.getAddress());
591 assertEquals("init_post", probeEvent
.getSymbol());
593 // ------------------------------------------------------------------------
594 // enable event (dynamic function probe) on session
595 // ------------------------------------------------------------------------
596 eventsDialogStub
.setIsDynamicProbe(false);
597 eventsDialogStub
.setDynamicProbe(null);
598 eventsDialogStub
.setProbeEventName(null);
599 eventsDialogStub
.setIsFunctionProbe(true);
600 eventsDialogStub
.setFunctionEventName("myevent4");
601 eventsDialogStub
.setFunctionProbe("create_dev");
603 fFacility
.executeCommand(session
, "enableEventOnSession");
605 // Get Kernel domain component instance
606 domains
= session
.getChildren();
607 assertNotNull(domains
);
608 assertEquals(1, domains
.length
);
610 // Verify that channel was created with correct data
611 channels
= domains
[0].getChildren();
612 channel
= (TraceChannelComponent
) channels
[2];
613 // No need to check parameters of default channel because that has been done in other tests
615 channel0Events
= channel
.getChildren();
616 assertEquals(8, channel0Events
.length
);
618 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
620 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
621 assertEquals("myevent4", probeEvent
.getName());
622 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
623 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
624 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
625 assertEquals("0x0", probeEvent
.getOffset());
626 assertNull(null, probeEvent
.getAddress());
627 assertEquals("create_dev", probeEvent
.getSymbol());
629 // ------------------------------------------------------------------------
630 // enable event (dynamic function probe) on domain
631 // ------------------------------------------------------------------------
632 eventsDialogStub
.setIsFunctionProbe(true);
633 eventsDialogStub
.setFunctionEventName("myevent5");
634 eventsDialogStub
.setFunctionProbe("create_dev:0x2000");
636 fFacility
.executeCommand(domains
[0], "enableEventOnDomain");
638 // Get Kernel domain component instance
639 domains
= session
.getChildren();
640 assertNotNull(domains
);
641 assertEquals(1, domains
.length
);
643 // Verify that channel was created with correct data
644 channels
= domains
[0].getChildren();
645 channel
= (TraceChannelComponent
) channels
[2];
646 // No need to check parameters of default channel because that has been done in other tests
648 channel0Events
= channel
.getChildren();
649 assertEquals(9, channel0Events
.length
);
651 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
653 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
654 assertEquals("myevent5", probeEvent
.getName());
655 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
656 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
657 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
658 assertEquals("0x2000", probeEvent
.getOffset());
659 assertNull(null, probeEvent
.getAddress());
660 assertEquals("create_dev", probeEvent
.getSymbol());
662 // ------------------------------------------------------------------------
663 // enable event (dynamic function probe) on channel
664 // ------------------------------------------------------------------------
665 eventsDialogStub
.setIsFunctionProbe(true);
666 eventsDialogStub
.setFunctionEventName("myevent");
667 eventsDialogStub
.setFunctionProbe("create_dev:0x2000");
669 fFacility
.executeCommand(channels
[0], "enableEventOnChannel");
671 // Get Kernel domain component instance
672 domains
= session
.getChildren();
673 assertNotNull(domains
);
674 assertEquals(1, domains
.length
);
676 // Verify that channel was created with correct data
677 channels
= domains
[0].getChildren();
678 channel
= (TraceChannelComponent
) channels
[0];
679 // No need to check parameters of default channel because that has been done in other tests
681 channel0Events
= channel
.getChildren();
682 assertEquals(2, channel0Events
.length
);
684 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
686 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
687 assertEquals("myevent", probeEvent
.getName());
688 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
689 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
690 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
691 assertEquals("0x2000", probeEvent
.getOffset());
692 assertNull(null, probeEvent
.getAddress());
693 assertEquals("create_dev", probeEvent
.getSymbol());
695 // ------------------------------------------------------------------------
696 // Add Context on domain
697 // ------------------------------------------------------------------------
698 // Get Kernel domain component instance
699 domains
= session
.getChildren();
700 assertNotNull(domains
);
701 assertEquals(1, domains
.length
);
703 AddContextDialogStub addContextStub
= new AddContextDialogStub();
704 List
<String
> contexts
= new ArrayList
<String
>();
705 contexts
.add("prio");
706 contexts
.add("perf:branch-misses");
707 contexts
.add("perf:cache-misses");
708 addContextStub
.setContexts(contexts
);
709 TraceControlDialogFactory
.getInstance().setAddContextDialog(addContextStub
);
711 fFacility
.executeCommand(domains
[0], "addContextOnDomain");
712 // Currently there is nothing to verify because the list commands don't show any context information
713 // However, the execution of the command make sure that the correct service command line is build and executed.
715 // ------------------------------------------------------------------------
716 // Add Context on channel
717 // ------------------------------------------------------------------------
719 // Get Kernel domain component instance
720 domains
= session
.getChildren();
721 assertNotNull(domains
);
722 assertEquals(1, domains
.length
);
724 //Verify that channel was created with correct data
725 channels
= domains
[0].getChildren();
726 channel
= (TraceChannelComponent
) channels
[0];
729 // The setContext() verifies that the contexts set are part of the available contexts
730 // The available contexts are set by the command handler addContextOnDomain above.
731 // So we indirectly test here that the parsing and setting of available contexts were
732 // done correctly above.
733 addContextStub
.setContexts(contexts
);
734 } catch (IllegalArgumentException e
) {
735 fail("Exception caught - unknown context");
738 fFacility
.executeCommand(channel
, "addContextOnChannel");
739 // Currently there is nothing to verify because the list commands don't show any context information
740 // However, the execution of the command make sure that the correct service command line is build and executed.
742 // ------------------------------------------------------------------------
743 // Add Context on event
744 // ------------------------------------------------------------------------
745 // Get Kernel domain component instance
746 domains
= session
.getChildren();
747 assertNotNull(domains
);
748 assertEquals(1, domains
.length
);
750 //Verify that channel was created with correct data
751 channels
= domains
[0].getChildren();
752 channel
= (TraceChannelComponent
) channels
[2];
754 channel0Events
= channel
.getChildren();
756 event
= (TraceEventComponent
) channel0Events
[6];
758 fFacility
.executeCommand(event
, "addContextOnEvent");
759 // Currently there is nothing to verify because the list commands don't show any context information
760 // However, the execution of the command make sure that the correct service command line is build and executed.
762 // ------------------------------------------------------------------------
764 // ------------------------------------------------------------------------
765 // Get Kernel domain component instance
766 domains
= session
.getChildren();
767 assertNotNull(domains
);
768 assertEquals(1, domains
.length
);
770 fFacility
.executeCommand(domains
[0], "calibrate");
771 // There is nothing to verify here.
772 // However, the execution of the command make sure that the correct service command line is build and executed.
774 // ------------------------------------------------------------------------
776 // ------------------------------------------------------------------------
777 fFacility
.executeCommand(node
, "refresh");
778 groups
= node
.getChildren();
779 assertNotNull(groups
);
780 assertEquals(2, groups
.length
);
781 assertEquals(3, groups
[0].getChildren().length
); // provider
782 assertEquals(1, groups
[1].getChildren().length
); // sessions
783 assertEquals(1, groups
[1].getChildren()[0].getChildren().length
); // domains
784 assertEquals(3, groups
[1].getChildren()[0].getChildren()[0].getChildren().length
); // channels
785 assertEquals(2, groups
[1].getChildren()[0].getChildren()[0].getChildren()[0].getChildren().length
); // events (of channel[0])
787 // Initialize session handling scenario
788 fProxy
.setScenario(TraceControlTestFacility
.SCEN_SCENARIO_SESSION_HANDLING
);
790 session
= (TraceSessionComponent
)groups
[1].getChildren()[0];
792 // ------------------------------------------------------------------------
794 // ------------------------------------------------------------------------
795 fFacility
.startSession(session
);
796 assertEquals(TraceSessionState
.ACTIVE
, session
.getSessionState());
798 // ------------------------------------------------------------------------
800 // ------------------------------------------------------------------------
801 fFacility
.stopSession(session
);
802 assertEquals(TraceSessionState
.INACTIVE
, session
.getSessionState());
804 // ------------------------------------------------------------------------
806 // ------------------------------------------------------------------------
808 fFacility
.destroySession(session
);
810 // Verify that no more session components exist
811 assertEquals(0, groups
[1].getChildren().length
);
813 //-------------------------------------------------------------------------
815 //-------------------------------------------------------------------------
816 fFacility
.executeCommand(node
, "disconnect");
817 assertEquals(TargetNodeState
.DISCONNECTED
, node
.getTargetNodeState());
819 //-------------------------------------------------------------------------
821 //-------------------------------------------------------------------------
823 fFacility
.executeCommand(node
, "delete");
824 assertEquals(0,fFacility
.getControlView().getTraceControlRoot().getChildren().length
);