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
.CreateChannelDialogStub
;
26 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.dialogs
.CreateSessionDialogStub
;
27 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.dialogs
.DestroyConfirmDialogStub
;
28 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.dialogs
.EnableEventsDialogStub
;
29 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.dialogs
.GetEventInfoDialogStub
;
30 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.service
.TestRemoteSystemProxy
;
31 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.dialogs
.TraceControlDialogFactory
;
32 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.ITraceControlComponent
;
33 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.TargetNodeState
;
34 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.TraceEnablement
;
35 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.TraceEventType
;
36 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.TraceLogLevel
;
37 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.TraceSessionState
;
38 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.ChannelInfo
;
39 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TargetNodeComponent
;
40 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceChannelComponent
;
41 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceEventComponent
;
42 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceProbeEventComponent
;
43 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceSessionComponent
;
44 import org
.eclipse
.rse
.core
.model
.Host
;
45 import org
.eclipse
.rse
.core
.model
.IHost
;
46 import org
.eclipse
.rse
.internal
.core
.model
.SystemProfile
;
47 import org
.junit
.After
;
48 import org
.junit
.Before
;
49 import org
.osgi
.framework
.FrameworkUtil
;
52 * The class <code>TraceControlKernelSessionTests</code> contains UST session/channel/event
53 * handling test cases.
56 @SuppressWarnings("nls")
57 public class TraceControlKernelSessionTests
extends TestCase
{
59 // ------------------------------------------------------------------------
61 // ------------------------------------------------------------------------
62 private static final String TEST_STREAM
= "CreateTreeTest.cfg";
63 private static final String SCEN_SCENARIO3_TEST
= "Scenario3";
65 // ------------------------------------------------------------------------
67 // ------------------------------------------------------------------------
68 private TraceControlTestFacility fFacility
;
69 private TestRemoteSystemProxy fProxy
;
70 private String fTestFile
;
72 // ------------------------------------------------------------------------
74 // ------------------------------------------------------------------------
77 * Returns test setup used when executing test case stand-alone.
78 * @return Test setup class
80 public static Test
suite() {
81 return new ModelImplTestSetup(new TestSuite(TraceControlKernelSessionTests
.class));
84 // ------------------------------------------------------------------------
86 // ------------------------------------------------------------------------
89 * Perform pre-test initialization.
92 * if the initialization fails for some reason
97 public void setUp() throws Exception
{
98 fFacility
= TraceControlTestFacility
.getInstance();
99 fProxy
= new TestRemoteSystemProxy();
100 URL location
= FileLocator
.find(FrameworkUtil
.getBundle(this.getClass()), new Path(TraceControlTestFacility
.DIRECTORY
+ File
.separator
+ TEST_STREAM
), null);
101 File testfile
= new File(FileLocator
.toFileURL(location
).toURI());
102 fTestFile
= testfile
.getAbsolutePath();
106 * Perform post-test clean-up.
109 * if the clean-up fails for some reason
114 public void tearDown() throws Exception
{
115 fFacility
.waitForJobs();
119 * Run the TraceControlComponent.
121 public void testTraceSessionTree() throws Exception
{
123 fProxy
.setTestFile(fTestFile
);
124 fProxy
.setScenario(TraceControlTestFacility
.SCEN_INIT_TEST
);
126 ITraceControlComponent root
= TraceControlTestFacility
.getInstance().getControlView().getTraceControlRoot();
128 @SuppressWarnings("restriction")
129 IHost host
= new Host(new SystemProfile("myProfile", true));
130 host
.setHostName("127.0.0.1");
132 TargetNodeComponent node
= new TargetNodeComponent("myNode", root
, host
, fProxy
);
135 fFacility
.waitForJobs();
137 fFacility
.executeCommand(node
, "connect");
139 while ((i
< 10) && (node
.getTargetNodeState() != TargetNodeState
.CONNECTED
)) {
141 fFacility
.delay(TraceControlTestFacility
.GUI_REFESH_DELAY
);
144 // Verify that node is connected
145 assertEquals(TargetNodeState
.CONNECTED
, node
.getTargetNodeState());
147 // Get provider groups
148 ITraceControlComponent
[] groups
= node
.getChildren();
149 assertNotNull(groups
);
150 assertEquals(2, groups
.length
);
152 // Initialize dialog implementations for command execution
153 TraceControlDialogFactory
.getInstance().setCreateSessionDialog(new CreateSessionDialogStub());
154 TraceControlDialogFactory
.getInstance().setGetEventInfoDialog(new GetEventInfoDialogStub());
155 TraceControlDialogFactory
.getInstance().setConfirmDialog(new DestroyConfirmDialogStub());
157 // Initialize session handling scenario
158 fProxy
.setScenario(TraceControlTestFacility
.SCEN_SCENARIO_SESSION_HANDLING
);
160 // ------------------------------------------------------------------------
162 // ------------------------------------------------------------------------
163 TraceSessionComponent session
= fFacility
.createSession(groups
[1]);
165 // Verify that session was created
166 assertNotNull(session
);
167 assertEquals("mysession", session
.getName());
168 assertEquals("/home/user/lttng-traces/mysession-20120314-132824", session
.getSessionPath());
169 assertEquals(TraceSessionState
.INACTIVE
, session
.getSessionState());
171 // Initialize scenario
172 fProxy
.setScenario(SCEN_SCENARIO3_TEST
);
174 // ------------------------------------------------------------------------
175 // Create channel on session
176 // ------------------------------------------------------------------------
177 CreateChannelDialogStub channelStub
= new CreateChannelDialogStub();
178 channelStub
.setIsKernel(true);
179 TraceControlDialogFactory
.getInstance().setCreateChannelDialog(channelStub
);
181 fFacility
.executeCommand(session
, "createChannelOnSession");
183 // Verify that Kernel domain was created
184 ITraceControlComponent
[] domains
= session
.getChildren();
185 assertNotNull(domains
);
186 assertEquals(1, domains
.length
);
188 assertEquals("Kernel", domains
[0].getName());
190 // Verify that channel was created with correct data
191 ITraceControlComponent
[] channels
= domains
[0].getChildren();
192 assertNotNull(channels
);
193 assertEquals(1, channels
.length
);
195 assertTrue(channels
[0] instanceof TraceChannelComponent
);
196 TraceChannelComponent channel
= (TraceChannelComponent
) channels
[0];
197 assertEquals("mychannel", channel
.getName());
198 assertEquals(4, channel
.getNumberOfSubBuffers());
199 assertEquals("splice()", channel
.getOutputType());
200 assertEquals(true, channel
.isOverwriteMode());
201 assertEquals(200, channel
.getReadTimer());
202 assertEquals(TraceEnablement
.ENABLED
, channel
.getState());
203 assertEquals(16384, channel
.getSubBufferSize());
204 assertEquals(100, channel
.getSwitchTimer());
206 // ------------------------------------------------------------------------
207 // Create channel on domain
208 // ------------------------------------------------------------------------
209 ChannelInfo info
= (ChannelInfo
)channelStub
.getChannelInfo();
210 info
.setName("mychannel2");
211 info
.setOverwriteMode(false);
212 info
.setSubBufferSize(32768);
213 info
.setNumberOfSubBuffers(2);
214 info
.setSwitchTimer(100);
215 info
.setReadTimer(200);
216 channelStub
.setChannelInfo(info
);
218 fFacility
.executeCommand(domains
[0], "createChannelOnDomain");
220 // Get Kernel domain component instance
221 domains
= session
.getChildren();
222 assertNotNull(domains
);
223 assertEquals(1, domains
.length
);
225 // Verify that channel was created with correct data
226 channels
= domains
[0].getChildren();
227 assertNotNull(channels
);
228 assertEquals(2, channels
.length
);
230 assertTrue(channels
[1] instanceof TraceChannelComponent
);
231 channel
= (TraceChannelComponent
) channels
[1];
232 assertEquals("mychannel2", channel
.getName());
233 assertEquals(2, channel
.getNumberOfSubBuffers());
234 assertEquals("splice()", channel
.getOutputType());
235 assertEquals(false, channel
.isOverwriteMode());
236 assertEquals(200, channel
.getReadTimer());
237 assertEquals(TraceEnablement
.ENABLED
, channel
.getState());
238 assertEquals(32768, channel
.getSubBufferSize());
239 assertEquals(100, channel
.getSwitchTimer());
241 EnableEventsDialogStub eventsDialogStub
= new EnableEventsDialogStub();
242 eventsDialogStub
.setIsTracePoints(true);
243 List
<String
> events
= new ArrayList
<String
>();
244 events
.add("sched_kthread_stop");
245 events
.add("sched_kthread_stop_ret");
246 eventsDialogStub
.setNames(events
);
247 eventsDialogStub
.setIsKernel(true);
248 TraceControlDialogFactory
.getInstance().setEnableEventsDialog(eventsDialogStub
);
250 // ------------------------------------------------------------------------
252 // ------------------------------------------------------------------------
253 // Get Kernel domain component instance
254 domains
= session
.getChildren();
255 assertNotNull(domains
);
256 assertEquals(1, domains
.length
);
258 // Verify that channel was created with correct data
259 channels
= domains
[0].getChildren();
260 assertNotNull(channels
);
261 assertEquals(2, channels
.length
);
263 fFacility
.executeCommand(channels
, "disableChannel");
265 assertEquals(TraceEnablement
.DISABLED
, ((TraceChannelComponent
)channels
[0]).getState());
266 assertEquals(TraceEnablement
.DISABLED
, ((TraceChannelComponent
)channels
[1]).getState());
268 // ------------------------------------------------------------------------
270 // ------------------------------------------------------------------------
271 // Get Kernel domain component instance
272 domains
= session
.getChildren();
273 assertNotNull(domains
);
274 assertEquals(1, domains
.length
);
276 // Verify that channel was created with correct data
277 channels
= domains
[0].getChildren();
278 assertNotNull(channels
);
279 assertEquals(2, channels
.length
);
281 fFacility
.executeCommand(channels
, "enableChannel");
283 assertEquals(TraceEnablement
.ENABLED
, ((TraceChannelComponent
)channels
[0]).getState());
284 assertEquals(TraceEnablement
.ENABLED
, ((TraceChannelComponent
)channels
[1]).getState());
286 // ------------------------------------------------------------------------
287 // enable event (tracepoints) on session
288 // ------------------------------------------------------------------------
289 fFacility
.executeCommand(session
, "enableEventOnSession");
291 // Get Kernel domain component instance
292 domains
= session
.getChildren();
293 assertNotNull(domains
);
294 assertEquals(1, domains
.length
);
296 // Verify that channel was created with correct data
297 channels
= domains
[0].getChildren();
298 assertNotNull(channels
);
299 assertEquals(3, channels
.length
);
301 assertTrue(channels
[2] instanceof TraceChannelComponent
);
302 channel
= (TraceChannelComponent
) channels
[2];
303 assertEquals("channel0", channel
.getName());
304 // No need to check parameters of default channel because that has been done in other tests
306 ITraceControlComponent
[] channel0Events
= channel
.getChildren();
307 assertEquals(2, channel0Events
.length
);
309 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
310 assertTrue(channel0Events
[1] instanceof TraceEventComponent
);
312 TraceEventComponent event
= (TraceEventComponent
) channel0Events
[0];
313 assertEquals("sched_kthread_stop_ret", event
.getName());
314 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
315 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
316 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
318 event
= (TraceEventComponent
) channel0Events
[1];
319 assertEquals("sched_kthread_stop", event
.getName());
320 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
321 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
322 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
324 // ------------------------------------------------------------------------
325 // enable event (tracepoints) on domain
326 // ------------------------------------------------------------------------
328 events
.add("sched_wakeup_new");
329 eventsDialogStub
.setNames(events
);
331 fFacility
.executeCommand(domains
[0], "enableEventOnDomain");
333 // Get Kernel domain component instance
334 domains
= session
.getChildren();
335 assertNotNull(domains
);
336 assertEquals(1, domains
.length
);
338 // Verify that channel was created with correct data
339 channels
= domains
[0].getChildren();
340 channel
= (TraceChannelComponent
) channels
[2];
341 // No need to check parameters of default channel because that has been done in other tests
343 channel
= (TraceChannelComponent
) channels
[2];
345 channel0Events
= channel
.getChildren();
346 assertEquals(3, channel0Events
.length
);
348 assertTrue(channel0Events
[2] instanceof TraceEventComponent
);
350 event
= (TraceEventComponent
) channel0Events
[2];
351 assertEquals("sched_wakeup_new", event
.getName());
352 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
353 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
354 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
356 // ------------------------------------------------------------------------
357 // enable event (tracepoints) on channel
358 // ------------------------------------------------------------------------
360 eventsDialogStub
.setNames(events
);
361 eventsDialogStub
.setIsAllTracePoints(true);
363 fFacility
.executeCommand(channels
[1], "enableEventOnChannel");
365 // Get Kernel domain component instance
366 domains
= session
.getChildren();
367 assertNotNull(domains
);
368 assertEquals(1, domains
.length
);
370 // Verify that channel was created with correct data
371 channels
= domains
[0].getChildren();
372 // No need to check parameters of default channel because that has been done in other tests
373 channel
= (TraceChannelComponent
) channels
[1];
375 channel0Events
= channel
.getChildren();
376 assertEquals(3, channel0Events
.length
);
378 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
379 assertTrue(channel0Events
[1] instanceof TraceEventComponent
);
380 assertTrue(channel0Events
[2] instanceof TraceEventComponent
);
382 event
= (TraceEventComponent
) channel0Events
[0];
383 assertEquals("sched_kthread_stop_ret", event
.getName());
384 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
385 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
386 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
388 event
= (TraceEventComponent
) channel0Events
[1];
389 assertEquals("sched_kthread_stop", event
.getName());
390 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
391 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
392 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
394 event
= (TraceEventComponent
) channel0Events
[2];
395 assertEquals("sched_wakeup_new", event
.getName());
396 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
397 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
398 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
400 // ------------------------------------------------------------------------
401 // enable event (syscall) on channel
402 // ------------------------------------------------------------------------
404 eventsDialogStub
.setIsTracePoints(false);
405 eventsDialogStub
.setIsAllTracePoints(false);
406 eventsDialogStub
.setIsSysCalls(true);
408 fFacility
.executeCommand(channels
[0], "enableEventOnChannel");
410 // Get Kernel domain component instance
411 domains
= session
.getChildren();
412 assertNotNull(domains
);
413 assertEquals(1, domains
.length
);
415 // Verify that channel was created with correct data
416 channels
= domains
[0].getChildren();
417 channel
= (TraceChannelComponent
) channels
[0];
418 // No need to check parameters of default channel because that has been done in other tests
420 channel
= (TraceChannelComponent
) channels
[0];
422 channel0Events
= channel
.getChildren();
423 assertEquals(1, channel0Events
.length
);
425 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
427 event
= (TraceEventComponent
) channel0Events
[0];
428 assertEquals("syscalls", event
.getName());
429 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, event
.getLogLevel());
430 assertEquals(TraceEventType
.SYSCALL
, event
.getEventType());
431 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
433 // ------------------------------------------------------------------------
434 // enable event (syscall) on domain
435 // ------------------------------------------------------------------------
436 fFacility
.executeCommand(domains
[0], "enableEventOnDomain");
438 // Get Kernel domain component instance
439 domains
= session
.getChildren();
440 assertNotNull(domains
);
441 assertEquals(1, domains
.length
);
443 // Verify that channel was created with correct data
444 channels
= domains
[0].getChildren();
445 channel
= (TraceChannelComponent
) channels
[0];
446 // No need to check parameters of default channel because that has been done in other tests
448 channel
= (TraceChannelComponent
) channels
[2];
450 channel0Events
= channel
.getChildren();
451 assertEquals(4, channel0Events
.length
);
453 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
455 event
= (TraceEventComponent
) channel0Events
[0];
456 assertEquals("syscalls", event
.getName());
457 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, event
.getLogLevel());
458 assertEquals(TraceEventType
.SYSCALL
, event
.getEventType());
459 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
461 // ------------------------------------------------------------------------
462 // enable event (syscall) on session
463 // ------------------------------------------------------------------------
464 fFacility
.executeCommand(session
, "enableEventOnSession");
466 // Get Kernel domain component instance
467 domains
= session
.getChildren();
468 assertNotNull(domains
);
469 assertEquals(1, domains
.length
);
471 // Verify that channel was created with correct data
472 channels
= domains
[0].getChildren();
473 channel
= (TraceChannelComponent
) channels
[0];
474 // No need to check parameters of default channel because that has been done in other tests
476 channel
= (TraceChannelComponent
) channels
[2];
478 channel0Events
= channel
.getChildren();
479 assertEquals(4, channel0Events
.length
);
481 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
483 event
= (TraceEventComponent
) channel0Events
[0];
484 assertEquals("syscalls", event
.getName());
485 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, event
.getLogLevel());
486 assertEquals(TraceEventType
.SYSCALL
, event
.getEventType());
487 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
490 // ------------------------------------------------------------------------
491 // enable event (dynamic probe) on domain
492 // ------------------------------------------------------------------------
494 eventsDialogStub
.setIsSysCalls(false);
495 eventsDialogStub
.setIsDynamicProbe(true);
496 eventsDialogStub
.setDynamicProbe("0xc0101280");
497 eventsDialogStub
.setProbeEventName("myevent1");
499 fFacility
.executeCommand(domains
[0], "enableEventOnDomain");
501 // Get Kernel domain component instance
502 domains
= session
.getChildren();
503 assertNotNull(domains
);
504 assertEquals(1, domains
.length
);
506 // Verify that channel was created with correct data
507 channels
= domains
[0].getChildren();
508 channel
= (TraceChannelComponent
) channels
[2];
509 // No need to check parameters of default channel because that has been done in other tests
511 channel0Events
= channel
.getChildren();
512 assertEquals(5, channel0Events
.length
);
514 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
516 TraceProbeEventComponent probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
517 assertEquals("myevent1", probeEvent
.getName());
518 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
519 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
520 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
521 assertNull(probeEvent
.getOffset());
522 assertEquals("0xc0101280", probeEvent
.getAddress());
523 assertNull(probeEvent
.getSymbol());
525 // ------------------------------------------------------------------------
526 // enable event (dynamic probe) on channel
527 // ------------------------------------------------------------------------
528 eventsDialogStub
.setIsDynamicProbe(true);
529 eventsDialogStub
.setDynamicProbe("init_post");
530 eventsDialogStub
.setProbeEventName("myevent2");
532 fFacility
.executeCommand(channels
[2], "enableEventOnChannel");
534 // Get Kernel domain component instance
535 domains
= session
.getChildren();
536 assertNotNull(domains
);
537 assertEquals(1, domains
.length
);
539 // Verify that channel was created with correct data
540 channels
= domains
[0].getChildren();
541 channel
= (TraceChannelComponent
) channels
[2];
542 // No need to check parameters of default channel because that has been done in other tests
544 channel0Events
= channel
.getChildren();
545 assertEquals(6, channel0Events
.length
);
547 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
549 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
550 assertEquals("myevent2", probeEvent
.getName());
551 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
552 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
553 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
554 assertEquals("0x0", probeEvent
.getOffset());
555 assertNull(null, probeEvent
.getAddress());
556 assertEquals("init_post", probeEvent
.getSymbol());
558 // ------------------------------------------------------------------------
559 // enable event (dynamic probe) on session
560 // ------------------------------------------------------------------------
561 eventsDialogStub
.setIsDynamicProbe(true);
562 eventsDialogStub
.setDynamicProbe("init_post:0x1000");
563 eventsDialogStub
.setProbeEventName("myevent3");
565 fFacility
.executeCommand(session
, "enableEventOnSession");
567 // Get Kernel domain component instance
568 domains
= session
.getChildren();
569 assertNotNull(domains
);
570 assertEquals(1, domains
.length
);
572 // Verify that channel was created with correct data
573 channels
= domains
[0].getChildren();
574 channel
= (TraceChannelComponent
) channels
[2];
575 // No need to check parameters of default channel because that has been done in other tests
577 channel0Events
= channel
.getChildren();
578 assertEquals(7, channel0Events
.length
);
580 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
582 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
583 assertEquals("myevent3", probeEvent
.getName());
584 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
585 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
586 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
587 assertEquals("0x1000", probeEvent
.getOffset());
588 assertNull(null, probeEvent
.getAddress());
589 assertEquals("init_post", probeEvent
.getSymbol());
591 // ------------------------------------------------------------------------
592 // enable event (dynamic function probe) on session
593 // ------------------------------------------------------------------------
594 eventsDialogStub
.setIsDynamicProbe(false);
595 eventsDialogStub
.setDynamicProbe(null);
596 eventsDialogStub
.setProbeEventName(null);
597 eventsDialogStub
.setIsFunctionProbe(true);
598 eventsDialogStub
.setFunctionEventName("myevent4");
599 eventsDialogStub
.setFunctionProbe("create_dev");
601 fFacility
.executeCommand(session
, "enableEventOnSession");
603 // Get Kernel domain component instance
604 domains
= session
.getChildren();
605 assertNotNull(domains
);
606 assertEquals(1, domains
.length
);
608 // Verify that channel was created with correct data
609 channels
= domains
[0].getChildren();
610 channel
= (TraceChannelComponent
) channels
[2];
611 // No need to check parameters of default channel because that has been done in other tests
613 channel0Events
= channel
.getChildren();
614 assertEquals(8, channel0Events
.length
);
616 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
618 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
619 assertEquals("myevent4", probeEvent
.getName());
620 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
621 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
622 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
623 assertEquals("0x0", probeEvent
.getOffset());
624 assertNull(null, probeEvent
.getAddress());
625 assertEquals("create_dev", probeEvent
.getSymbol());
627 // ------------------------------------------------------------------------
628 // enable event (dynamic function probe) on domain
629 // ------------------------------------------------------------------------
630 eventsDialogStub
.setIsFunctionProbe(true);
631 eventsDialogStub
.setFunctionEventName("myevent5");
632 eventsDialogStub
.setFunctionProbe("create_dev:0x2000");
634 fFacility
.executeCommand(domains
[0], "enableEventOnDomain");
636 // Get Kernel domain component instance
637 domains
= session
.getChildren();
638 assertNotNull(domains
);
639 assertEquals(1, domains
.length
);
641 // Verify that channel was created with correct data
642 channels
= domains
[0].getChildren();
643 channel
= (TraceChannelComponent
) channels
[2];
644 // No need to check parameters of default channel because that has been done in other tests
646 channel0Events
= channel
.getChildren();
647 assertEquals(9, channel0Events
.length
);
649 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
651 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
652 assertEquals("myevent5", probeEvent
.getName());
653 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
654 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
655 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
656 assertEquals("0x2000", probeEvent
.getOffset());
657 assertNull(null, probeEvent
.getAddress());
658 assertEquals("create_dev", probeEvent
.getSymbol());
660 // ------------------------------------------------------------------------
661 // enable event (dynamic function probe) on channel
662 // ------------------------------------------------------------------------
663 eventsDialogStub
.setIsFunctionProbe(true);
664 eventsDialogStub
.setFunctionEventName("myevent");
665 eventsDialogStub
.setFunctionProbe("create_dev:0x2000");
667 fFacility
.executeCommand(channels
[0], "enableEventOnChannel");
669 // Get Kernel domain component instance
670 domains
= session
.getChildren();
671 assertNotNull(domains
);
672 assertEquals(1, domains
.length
);
674 // Verify that channel was created with correct data
675 channels
= domains
[0].getChildren();
676 channel
= (TraceChannelComponent
) channels
[0];
677 // No need to check parameters of default channel because that has been done in other tests
679 channel0Events
= channel
.getChildren();
680 assertEquals(2, channel0Events
.length
);
682 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
684 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
685 assertEquals("myevent", probeEvent
.getName());
686 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
687 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
688 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
689 assertEquals("0x2000", probeEvent
.getOffset());
690 assertNull(null, probeEvent
.getAddress());
691 assertEquals("create_dev", probeEvent
.getSymbol());
693 // ------------------------------------------------------------------------
695 // ------------------------------------------------------------------------
696 fFacility
.executeCommand(node
, "refresh");
697 groups
= node
.getChildren();
698 assertNotNull(groups
);
699 assertEquals(2, groups
.length
);
700 assertEquals(3, groups
[0].getChildren().length
); // provider
701 assertEquals(1, groups
[1].getChildren().length
); // sessions
702 assertEquals(1, groups
[1].getChildren()[0].getChildren().length
); // domains
703 assertEquals(3, groups
[1].getChildren()[0].getChildren()[0].getChildren().length
); // channels
704 assertEquals(2, groups
[1].getChildren()[0].getChildren()[0].getChildren()[0].getChildren().length
); // events (of channel[0])
706 // Initialize session handling scenario
707 fProxy
.setScenario(TraceControlTestFacility
.SCEN_SCENARIO_SESSION_HANDLING
);
709 session
= (TraceSessionComponent
)groups
[1].getChildren()[0];
711 // ------------------------------------------------------------------------
713 // ------------------------------------------------------------------------
714 fFacility
.startSession(session
);
715 assertEquals(TraceSessionState
.ACTIVE
, session
.getSessionState());
717 // ------------------------------------------------------------------------
719 // ------------------------------------------------------------------------
720 fFacility
.stopSession(session
);
721 assertEquals(TraceSessionState
.INACTIVE
, session
.getSessionState());
723 // ------------------------------------------------------------------------
725 // ------------------------------------------------------------------------
727 fFacility
.destroySession(session
);
729 // Verify that no more session components exist
730 assertEquals(0, groups
[1].getChildren().length
);
732 //-------------------------------------------------------------------------
734 //-------------------------------------------------------------------------
735 fFacility
.executeCommand(node
, "disconnect");
736 assertEquals(TargetNodeState
.DISCONNECTED
, node
.getTargetNodeState());
738 //-------------------------------------------------------------------------
740 //-------------------------------------------------------------------------
742 fFacility
.executeCommand(node
, "delete");
743 assertEquals(0,fFacility
.getControlView().getTraceControlRoot().getChildren().length
);