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