1 /**********************************************************************
2 * Copyright (c) 2012, 2015 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 * Markus Schorn - Bug 448058: Use org.eclipse.remote in favor of RSE
13 **********************************************************************/
15 package org
.eclipse
.tracecompass
.lttng2
.control
.ui
.tests
.model
.component
;
17 import static org
.junit
.Assert
.assertEquals
;
18 import static org
.junit
.Assert
.assertNotNull
;
19 import static org
.junit
.Assert
.assertNull
;
20 import static org
.junit
.Assert
.assertTrue
;
21 import static org
.junit
.Assert
.fail
;
25 import java
.util
.ArrayList
;
26 import java
.util
.List
;
28 import org
.eclipse
.core
.runtime
.FileLocator
;
29 import org
.eclipse
.core
.runtime
.Path
;
30 import org
.eclipse
.jdt
.annotation
.NonNull
;
31 import org
.eclipse
.remote
.core
.IRemoteConnection
;
32 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceDomainType
;
33 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TargetNodeState
;
34 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceChannelOutputType
;
35 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceEnablement
;
36 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceEventType
;
37 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceLogLevel
;
38 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceSessionState
;
39 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.impl
.ChannelInfo
;
40 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.stubs
.dialogs
.AddContextDialogStub
;
41 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.stubs
.dialogs
.CreateSessionDialogStub
;
42 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.stubs
.dialogs
.DestroyConfirmDialogStub
;
43 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.stubs
.dialogs
.EnableChannelDialogStub
;
44 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.stubs
.dialogs
.EnableEventsDialogStub
;
45 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.stubs
.dialogs
.GetEventInfoDialogStub
;
46 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.stubs
.service
.TestRemoteSystemProxy
;
47 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.dialogs
.TraceControlDialogFactory
;
48 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.ITraceControlComponent
;
49 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TargetNodeComponent
;
50 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TraceChannelComponent
;
51 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TraceEventComponent
;
52 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TraceProbeEventComponent
;
53 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TraceSessionComponent
;
54 import org
.eclipse
.tracecompass
.tmf
.remote
.core
.proxy
.TmfRemoteConnectionFactory
;
55 import org
.junit
.After
;
56 import org
.junit
.Before
;
57 import org
.junit
.Test
;
58 import org
.osgi
.framework
.FrameworkUtil
;
61 * The class {@link TraceControlKernelSessionTest} contains Kernel
62 * session/channel/event handling test cases.
64 public class TraceControlKernelSessionTest
{
66 // ------------------------------------------------------------------------
68 // ------------------------------------------------------------------------
70 private static final String TEST_STREAM
= "CreateTreeTest.cfg";
71 private static final String SCEN_SCENARIO3_TEST
= "Scenario3";
73 // ------------------------------------------------------------------------
75 // ------------------------------------------------------------------------
77 private TraceControlTestFacility fFacility
;
78 private IRemoteConnection fHost
= TmfRemoteConnectionFactory
.getLocalConnection();
79 private @NonNull TestRemoteSystemProxy fProxy
= new TestRemoteSystemProxy(fHost
);
80 private String fTestFile
;
82 // ------------------------------------------------------------------------
84 // ------------------------------------------------------------------------
87 * Perform pre-test initialization.
90 * if the initialization fails for some reason
93 public void setUp() throws Exception
{
94 fFacility
= TraceControlTestFacility
.getInstance();
96 URL location
= FileLocator
.find(FrameworkUtil
.getBundle(this.getClass()), new Path(TraceControlTestFacility
.DIRECTORY
+ File
.separator
+ TEST_STREAM
), null);
97 File testfile
= new File(FileLocator
.toFileURL(location
).toURI());
98 fTestFile
= testfile
.getAbsolutePath();
102 * Perform post-test clean-up.
105 public void tearDown() {
110 * Run the TraceControlComponent.
113 * Would fail the test
116 public void testTraceSessionTree() throws Exception
{
118 fProxy
.setTestFile(fTestFile
);
119 fProxy
.setScenario(TraceControlTestFacility
.SCEN_INIT_TEST
);
121 ITraceControlComponent root
= fFacility
.getControlView().getTraceControlRoot();
123 TargetNodeComponent node
= new TargetNodeComponent("myNode", root
, fProxy
);
126 fFacility
.waitForJobs();
128 fFacility
.executeCommand(node
, "connect");
130 while ((i
< 10) && (node
.getTargetNodeState() != TargetNodeState
.CONNECTED
)) {
132 fFacility
.delay(TraceControlTestFacility
.GUI_REFESH_DELAY
);
135 // Verify that node is connected
136 assertEquals(TargetNodeState
.CONNECTED
, node
.getTargetNodeState());
138 // Get provider groups
139 ITraceControlComponent
[] groups
= node
.getChildren();
140 assertNotNull(groups
);
141 assertEquals(2, groups
.length
);
143 // Initialize dialog implementations for command execution
144 TraceControlDialogFactory
.getInstance().setCreateSessionDialog(new CreateSessionDialogStub());
145 TraceControlDialogFactory
.getInstance().setGetEventInfoDialog(new GetEventInfoDialogStub());
146 TraceControlDialogFactory
.getInstance().setConfirmDialog(new DestroyConfirmDialogStub());
148 // Initialize session handling scenario
149 fProxy
.setScenario(TraceControlTestFacility
.SCEN_SCENARIO_SESSION_HANDLING
);
151 // ------------------------------------------------------------------------
153 // ------------------------------------------------------------------------
154 TraceSessionComponent session
= fFacility
.createSession(groups
[1]);
156 // Verify that session was created
157 assertNotNull(session
);
158 assertEquals("mysession", session
.getName());
159 assertEquals("/home/user/lttng-traces/mysession-20120314-132824", session
.getSessionPath());
160 assertEquals(TraceSessionState
.INACTIVE
, session
.getSessionState());
162 // Initialize scenario
163 fProxy
.setScenario(SCEN_SCENARIO3_TEST
);
165 // ------------------------------------------------------------------------
166 // Enable channel on session
167 // ------------------------------------------------------------------------
168 EnableChannelDialogStub channelStub
= new EnableChannelDialogStub();
169 channelStub
.setDomain(TraceDomainType
.KERNEL
);
170 TraceControlDialogFactory
.getInstance().setEnableChannelDialog(channelStub
);
172 fFacility
.executeCommand(session
, "enableChannelOnSession");
174 // Verify that Kernel domain was created
175 ITraceControlComponent
[] domains
= session
.getChildren();
176 assertNotNull(domains
);
177 assertEquals(1, domains
.length
);
179 assertEquals("Kernel", domains
[0].getName());
181 // Verify that channel was created with correct data
182 ITraceControlComponent
[] channels
= domains
[0].getChildren();
183 assertNotNull(channels
);
184 assertEquals(1, channels
.length
);
186 assertTrue(channels
[0] instanceof TraceChannelComponent
);
187 TraceChannelComponent channel
= (TraceChannelComponent
) channels
[0];
188 assertEquals("mychannel", channel
.getName());
189 assertEquals(4, channel
.getNumberOfSubBuffers());
190 assertEquals("splice()", channel
.getOutputType().getInName());
191 assertEquals(TraceChannelOutputType
.SPLICE
, channel
.getOutputType());
192 assertEquals(true, channel
.isOverwriteMode());
193 assertEquals(200, channel
.getReadTimer());
194 assertEquals(TraceEnablement
.ENABLED
, channel
.getState());
195 assertEquals(16384, channel
.getSubBufferSize());
196 assertEquals(100, channel
.getSwitchTimer());
198 // ------------------------------------------------------------------------
199 // Create channel on domain
200 // ------------------------------------------------------------------------
201 ChannelInfo info
= (ChannelInfo
)channelStub
.getChannelInfo();
202 info
.setName("mychannel2");
203 info
.setOverwriteMode(false);
204 info
.setSubBufferSize(32768);
205 info
.setNumberOfSubBuffers(2);
206 info
.setSwitchTimer(100);
207 info
.setReadTimer(200);
208 channelStub
.setChannelInfo(info
);
210 fFacility
.executeCommand(domains
[0], "enableChannelOnDomain");
212 // Get Kernel domain component instance
213 domains
= session
.getChildren();
214 assertNotNull(domains
);
215 assertEquals(1, domains
.length
);
217 // Verify that channel was created with correct data
218 channels
= domains
[0].getChildren();
219 assertNotNull(channels
);
220 assertEquals(2, channels
.length
);
222 assertTrue(channels
[1] instanceof TraceChannelComponent
);
223 channel
= (TraceChannelComponent
) channels
[1];
224 assertEquals("mychannel2", channel
.getName());
225 assertEquals(2, channel
.getNumberOfSubBuffers());
226 assertEquals("splice()", channel
.getOutputType().getInName());
227 assertEquals(TraceChannelOutputType
.SPLICE
, channel
.getOutputType());
228 assertEquals(false, channel
.isOverwriteMode());
229 assertEquals(200, channel
.getReadTimer());
230 assertEquals(TraceEnablement
.ENABLED
, channel
.getState());
231 assertEquals(32768, channel
.getSubBufferSize());
232 assertEquals(100, channel
.getSwitchTimer());
234 EnableEventsDialogStub eventsDialogStub
= new EnableEventsDialogStub();
235 eventsDialogStub
.setIsTracePoints(true);
236 List
<String
> events
= new ArrayList
<>();
237 events
.add("sched_kthread_stop");
238 events
.add("sched_kthread_stop_ret");
239 eventsDialogStub
.setNames(events
);
240 eventsDialogStub
.setDomain(TraceDomainType
.KERNEL
);
241 TraceControlDialogFactory
.getInstance().setEnableEventsDialog(eventsDialogStub
);
243 // ------------------------------------------------------------------------
245 // ------------------------------------------------------------------------
246 // Get Kernel domain component instance
247 domains
= session
.getChildren();
248 assertNotNull(domains
);
249 assertEquals(1, domains
.length
);
251 // Verify that channel was created with correct data
252 channels
= domains
[0].getChildren();
253 assertNotNull(channels
);
254 assertEquals(2, channels
.length
);
256 fFacility
.executeCommand(channels
, "disableChannel");
258 assertEquals(TraceEnablement
.DISABLED
, ((TraceChannelComponent
)channels
[0]).getState());
259 assertEquals(TraceEnablement
.DISABLED
, ((TraceChannelComponent
)channels
[1]).getState());
261 // ------------------------------------------------------------------------
263 // ------------------------------------------------------------------------
264 // Get Kernel domain component instance
265 domains
= session
.getChildren();
266 assertNotNull(domains
);
267 assertEquals(1, domains
.length
);
269 // Verify that channel was created with correct data
270 channels
= domains
[0].getChildren();
271 assertNotNull(channels
);
272 assertEquals(2, channels
.length
);
274 fFacility
.executeCommand(channels
, "enableChannel");
276 assertEquals(TraceEnablement
.ENABLED
, ((TraceChannelComponent
)channels
[0]).getState());
277 assertEquals(TraceEnablement
.ENABLED
, ((TraceChannelComponent
)channels
[1]).getState());
279 // ------------------------------------------------------------------------
280 // enable event (tracepoints) on session
281 // ------------------------------------------------------------------------
282 fFacility
.executeCommand(session
, "enableEventOnSession");
284 // Get Kernel domain component instance
285 domains
= session
.getChildren();
286 assertNotNull(domains
);
287 assertEquals(1, domains
.length
);
289 // Verify that channel was created with correct data
290 channels
= domains
[0].getChildren();
291 assertNotNull(channels
);
292 assertEquals(3, channels
.length
);
294 assertTrue(channels
[2] instanceof TraceChannelComponent
);
295 channel
= (TraceChannelComponent
) channels
[2];
296 assertEquals("channel0", channel
.getName());
297 // No need to check parameters of default channel because that has been done in other tests
299 ITraceControlComponent
[] channel0Events
= channel
.getChildren();
300 assertEquals(2, channel0Events
.length
);
302 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
303 assertTrue(channel0Events
[1] instanceof TraceEventComponent
);
305 TraceEventComponent event
= (TraceEventComponent
) channel0Events
[0];
306 assertEquals("sched_kthread_stop_ret", event
.getName());
307 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
308 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
309 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
311 event
= (TraceEventComponent
) channel0Events
[1];
312 assertEquals("sched_kthread_stop", event
.getName());
313 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
314 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
315 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
317 // ------------------------------------------------------------------------
318 // enable event (tracepoints) on domain
319 // ------------------------------------------------------------------------
321 events
.add("sched_wakeup_new");
322 eventsDialogStub
.setNames(events
);
324 fFacility
.executeCommand(domains
[0], "enableEventOnDomain");
326 // Get Kernel domain component instance
327 domains
= session
.getChildren();
328 assertNotNull(domains
);
329 assertEquals(1, domains
.length
);
331 // Verify that channel was created with correct data
332 channels
= domains
[0].getChildren();
333 channel
= (TraceChannelComponent
) channels
[2];
334 // No need to check parameters of default channel because that has been done in other tests
336 channel
= (TraceChannelComponent
) channels
[2];
338 channel0Events
= channel
.getChildren();
339 assertEquals(3, channel0Events
.length
);
341 assertTrue(channel0Events
[2] instanceof TraceEventComponent
);
343 event
= (TraceEventComponent
) channel0Events
[2];
344 assertEquals("sched_wakeup_new", event
.getName());
345 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
346 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
347 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
349 // ------------------------------------------------------------------------
350 // enable event (tracepoints) on channel
351 // ------------------------------------------------------------------------
353 eventsDialogStub
.setNames(events
);
354 eventsDialogStub
.setIsAllTracePoints(true);
356 fFacility
.executeCommand(channels
[1], "enableEventOnChannel");
358 // Get Kernel domain component instance
359 domains
= session
.getChildren();
360 assertNotNull(domains
);
361 assertEquals(1, domains
.length
);
363 // Verify that channel was created with correct data
364 channels
= domains
[0].getChildren();
365 // No need to check parameters of default channel because that has been done in other tests
366 channel
= (TraceChannelComponent
) channels
[1];
368 channel0Events
= channel
.getChildren();
369 assertEquals(3, channel0Events
.length
);
371 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
372 assertTrue(channel0Events
[1] instanceof TraceEventComponent
);
373 assertTrue(channel0Events
[2] instanceof TraceEventComponent
);
375 event
= (TraceEventComponent
) channel0Events
[0];
376 assertEquals("sched_kthread_stop_ret", event
.getName());
377 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
378 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
379 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
381 event
= (TraceEventComponent
) channel0Events
[1];
382 assertEquals("sched_kthread_stop", event
.getName());
383 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
384 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
385 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
387 event
= (TraceEventComponent
) channel0Events
[2];
388 assertEquals("sched_wakeup_new", event
.getName());
389 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
390 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
391 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
393 // ------------------------------------------------------------------------
394 // enable event (syscall) on channel
395 // ------------------------------------------------------------------------
397 eventsDialogStub
.setIsTracePoints(false);
398 eventsDialogStub
.setIsAllTracePoints(false);
399 eventsDialogStub
.setIsSysCalls(true);
401 fFacility
.executeCommand(channels
[0], "enableEventOnChannel");
403 // Get Kernel domain component instance
404 domains
= session
.getChildren();
405 assertNotNull(domains
);
406 assertEquals(1, domains
.length
);
408 // Verify that channel was created with correct data
409 channels
= domains
[0].getChildren();
410 channel
= (TraceChannelComponent
) channels
[0];
411 // No need to check parameters of default channel because that has been done in other tests
413 channel
= (TraceChannelComponent
) channels
[0];
415 channel0Events
= channel
.getChildren();
416 assertEquals(1, channel0Events
.length
);
418 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
420 event
= (TraceEventComponent
) channel0Events
[0];
421 assertEquals("syscalls", event
.getName());
422 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, event
.getLogLevel());
423 assertEquals(TraceEventType
.SYSCALL
, event
.getEventType());
424 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
426 // ------------------------------------------------------------------------
427 // enable event (syscall) on domain
428 // ------------------------------------------------------------------------
429 fFacility
.executeCommand(domains
[0], "enableEventOnDomain");
431 // Get Kernel domain component instance
432 domains
= session
.getChildren();
433 assertNotNull(domains
);
434 assertEquals(1, domains
.length
);
436 // Verify that channel was created with correct data
437 channels
= domains
[0].getChildren();
438 channel
= (TraceChannelComponent
) channels
[0];
439 // No need to check parameters of default channel because that has been done in other tests
441 channel
= (TraceChannelComponent
) channels
[2];
443 channel0Events
= channel
.getChildren();
444 assertEquals(4, channel0Events
.length
);
446 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
448 event
= (TraceEventComponent
) channel0Events
[0];
449 assertEquals("syscalls", event
.getName());
450 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, event
.getLogLevel());
451 assertEquals(TraceEventType
.SYSCALL
, event
.getEventType());
452 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
454 // ------------------------------------------------------------------------
455 // enable event (syscall) on session
456 // ------------------------------------------------------------------------
457 fFacility
.executeCommand(session
, "enableEventOnSession");
459 // Get Kernel domain component instance
460 domains
= session
.getChildren();
461 assertNotNull(domains
);
462 assertEquals(1, domains
.length
);
464 // Verify that channel was created with correct data
465 channels
= domains
[0].getChildren();
466 channel
= (TraceChannelComponent
) channels
[0];
467 // No need to check parameters of default channel because that has been done in other tests
469 channel
= (TraceChannelComponent
) channels
[2];
471 channel0Events
= channel
.getChildren();
472 assertEquals(4, channel0Events
.length
);
474 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
476 event
= (TraceEventComponent
) channel0Events
[0];
477 assertEquals("syscalls", event
.getName());
478 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, event
.getLogLevel());
479 assertEquals(TraceEventType
.SYSCALL
, event
.getEventType());
480 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
483 // ------------------------------------------------------------------------
484 // enable event (dynamic probe) on domain
485 // ------------------------------------------------------------------------
487 eventsDialogStub
.setIsSysCalls(false);
488 eventsDialogStub
.setIsDynamicProbe(true);
489 eventsDialogStub
.setDynamicProbe("0xc0101280");
490 eventsDialogStub
.setProbeEventName("myevent1");
492 fFacility
.executeCommand(domains
[0], "enableEventOnDomain");
494 // Get Kernel domain component instance
495 domains
= session
.getChildren();
496 assertNotNull(domains
);
497 assertEquals(1, domains
.length
);
499 // Verify that channel was created with correct data
500 channels
= domains
[0].getChildren();
501 channel
= (TraceChannelComponent
) channels
[2];
502 // No need to check parameters of default channel because that has been done in other tests
504 channel0Events
= channel
.getChildren();
505 assertEquals(5, channel0Events
.length
);
507 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
509 TraceProbeEventComponent probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
510 assertEquals("myevent1", probeEvent
.getName());
511 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
512 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
513 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
514 assertNull(probeEvent
.getOffset());
515 assertEquals("0xc0101280", probeEvent
.getAddress());
516 assertNull(probeEvent
.getSymbol());
518 // ------------------------------------------------------------------------
519 // enable event (dynamic probe) on channel
520 // ------------------------------------------------------------------------
521 eventsDialogStub
.setIsDynamicProbe(true);
522 eventsDialogStub
.setDynamicProbe("init_post");
523 eventsDialogStub
.setProbeEventName("myevent2");
525 fFacility
.executeCommand(channels
[2], "enableEventOnChannel");
527 // Get Kernel domain component instance
528 domains
= session
.getChildren();
529 assertNotNull(domains
);
530 assertEquals(1, domains
.length
);
532 // Verify that channel was created with correct data
533 channels
= domains
[0].getChildren();
534 channel
= (TraceChannelComponent
) channels
[2];
535 // No need to check parameters of default channel because that has been done in other tests
537 channel0Events
= channel
.getChildren();
538 assertEquals(6, channel0Events
.length
);
540 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
542 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
543 assertEquals("myevent2", probeEvent
.getName());
544 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
545 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
546 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
547 assertEquals("0x0", probeEvent
.getOffset());
548 assertNull(null, probeEvent
.getAddress());
549 assertEquals("init_post", probeEvent
.getSymbol());
551 // ------------------------------------------------------------------------
552 // enable event (dynamic probe) on session
553 // ------------------------------------------------------------------------
554 eventsDialogStub
.setIsDynamicProbe(true);
555 eventsDialogStub
.setDynamicProbe("init_post:0x1000");
556 eventsDialogStub
.setProbeEventName("myevent3");
558 fFacility
.executeCommand(session
, "enableEventOnSession");
560 // Get Kernel domain component instance
561 domains
= session
.getChildren();
562 assertNotNull(domains
);
563 assertEquals(1, domains
.length
);
565 // Verify that channel was created with correct data
566 channels
= domains
[0].getChildren();
567 channel
= (TraceChannelComponent
) channels
[2];
568 // No need to check parameters of default channel because that has been done in other tests
570 channel0Events
= channel
.getChildren();
571 assertEquals(7, channel0Events
.length
);
573 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
575 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
576 assertEquals("myevent3", probeEvent
.getName());
577 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
578 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
579 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
580 assertEquals("0x1000", probeEvent
.getOffset());
581 assertNull(null, probeEvent
.getAddress());
582 assertEquals("init_post", probeEvent
.getSymbol());
584 // ------------------------------------------------------------------------
585 // enable event (dynamic function probe) on session
586 // ------------------------------------------------------------------------
587 eventsDialogStub
.setIsDynamicProbe(false);
588 eventsDialogStub
.setDynamicProbe(null);
589 eventsDialogStub
.setProbeEventName(null);
590 eventsDialogStub
.setIsFunctionProbe(true);
591 eventsDialogStub
.setFunctionEventName("myevent4");
592 eventsDialogStub
.setFunctionProbe("create_dev");
594 fFacility
.executeCommand(session
, "enableEventOnSession");
596 // Get Kernel domain component instance
597 domains
= session
.getChildren();
598 assertNotNull(domains
);
599 assertEquals(1, domains
.length
);
601 // Verify that channel was created with correct data
602 channels
= domains
[0].getChildren();
603 channel
= (TraceChannelComponent
) channels
[2];
604 // No need to check parameters of default channel because that has been done in other tests
606 channel0Events
= channel
.getChildren();
607 assertEquals(8, channel0Events
.length
);
609 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
611 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
612 assertEquals("myevent4", probeEvent
.getName());
613 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
614 // Changed for Bug fix 419454 to function event which was introduced by LTTng 2.2
615 assertEquals(TraceEventType
.FUNCTION
, probeEvent
.getEventType());
616 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
617 assertEquals("0x0", probeEvent
.getOffset());
618 assertNull(null, probeEvent
.getAddress());
619 assertEquals("create_dev", probeEvent
.getSymbol());
621 // ------------------------------------------------------------------------
622 // enable event (dynamic function probe) on domain
623 // ------------------------------------------------------------------------
624 eventsDialogStub
.setIsFunctionProbe(true);
625 eventsDialogStub
.setFunctionEventName("myevent5");
626 eventsDialogStub
.setFunctionProbe("create_dev:0x2000");
628 fFacility
.executeCommand(domains
[0], "enableEventOnDomain");
630 // Get Kernel domain component instance
631 domains
= session
.getChildren();
632 assertNotNull(domains
);
633 assertEquals(1, domains
.length
);
635 // Verify that channel was created with correct data
636 channels
= domains
[0].getChildren();
637 channel
= (TraceChannelComponent
) channels
[2];
638 // No need to check parameters of default channel because that has been done in other tests
640 channel0Events
= channel
.getChildren();
641 assertEquals(9, channel0Events
.length
);
643 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
645 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
646 assertEquals("myevent5", probeEvent
.getName());
647 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
648 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
649 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
650 assertEquals("0x2000", probeEvent
.getOffset());
651 assertNull(null, probeEvent
.getAddress());
652 assertEquals("create_dev", probeEvent
.getSymbol());
654 // ------------------------------------------------------------------------
655 // enable event (dynamic function probe) on channel
656 // ------------------------------------------------------------------------
657 eventsDialogStub
.setIsFunctionProbe(true);
658 eventsDialogStub
.setFunctionEventName("myevent");
659 eventsDialogStub
.setFunctionProbe("create_dev:0x2000");
661 fFacility
.executeCommand(channels
[0], "enableEventOnChannel");
663 // Get Kernel domain component instance
664 domains
= session
.getChildren();
665 assertNotNull(domains
);
666 assertEquals(1, domains
.length
);
668 // Verify that channel was created with correct data
669 channels
= domains
[0].getChildren();
670 channel
= (TraceChannelComponent
) channels
[0];
671 // No need to check parameters of default channel because that has been done in other tests
673 channel0Events
= channel
.getChildren();
674 assertEquals(2, channel0Events
.length
);
676 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
678 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
679 assertEquals("myevent", probeEvent
.getName());
680 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
681 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
682 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
683 assertEquals("0x2000", probeEvent
.getOffset());
684 assertNull(null, probeEvent
.getAddress());
685 assertEquals("create_dev", probeEvent
.getSymbol());
687 // ------------------------------------------------------------------------
688 // Add Context on domain
689 // ------------------------------------------------------------------------
690 // Get Kernel domain component instance
691 domains
= session
.getChildren();
692 assertNotNull(domains
);
693 assertEquals(1, domains
.length
);
695 AddContextDialogStub addContextStub
= new AddContextDialogStub();
696 List
<String
> contexts
= new ArrayList
<>();
697 contexts
.add("prio");
698 contexts
.add("perf:branch-misses");
699 contexts
.add("perf:cache-misses");
700 addContextStub
.setContexts(contexts
);
701 TraceControlDialogFactory
.getInstance().setAddContextDialog(addContextStub
);
703 fFacility
.executeCommand(domains
[0], "addContextOnDomain");
704 // Currently there is nothing to verify because the list commands don't show any context information
705 // However, the execution of the command make sure that the correct service command line is build and executed.
707 // ------------------------------------------------------------------------
708 // Add Context on channel
709 // ------------------------------------------------------------------------
711 // Get Kernel domain component instance
712 domains
= session
.getChildren();
713 assertNotNull(domains
);
714 assertEquals(1, domains
.length
);
716 //Verify that channel was created with correct data
717 channels
= domains
[0].getChildren();
718 channel
= (TraceChannelComponent
) channels
[0];
721 // The setContext() verifies that the contexts set are part of the available contexts
722 // The available contexts are set by the command handler addContextOnDomain above.
723 // So we indirectly test here that the parsing and setting of available contexts were
724 // done correctly above.
725 addContextStub
.setContexts(contexts
);
726 } catch (IllegalArgumentException e
) {
727 fail("Exception caught - unknown context");
730 fFacility
.executeCommand(channel
, "addContextOnChannel");
731 // Currently there is nothing to verify because the list commands don't show any context information
732 // However, the execution of the command make sure that the correct service command line is build and executed.
734 // ------------------------------------------------------------------------
735 // Add Context on event
736 // ------------------------------------------------------------------------
737 // Get Kernel domain component instance
738 domains
= session
.getChildren();
739 assertNotNull(domains
);
740 assertEquals(1, domains
.length
);
742 //Verify that channel was created with correct data
743 channels
= domains
[0].getChildren();
744 channel
= (TraceChannelComponent
) channels
[2];
746 channel0Events
= channel
.getChildren();
748 event
= (TraceEventComponent
) channel0Events
[6];
750 fFacility
.executeCommand(event
, "addContextOnEvent");
751 // Currently there is nothing to verify because the list commands don't show any context information
752 // However, the execution of the command make sure that the correct service command line is build and executed.
754 // ------------------------------------------------------------------------
756 // ------------------------------------------------------------------------
757 fFacility
.executeCommand(node
, "refresh");
758 groups
= node
.getChildren();
759 assertNotNull(groups
);
760 assertEquals(2, groups
.length
);
761 assertEquals(3, groups
[0].getChildren().length
); // provider
762 assertEquals(1, groups
[1].getChildren().length
); // sessions
763 assertEquals(1, groups
[1].getChildren()[0].getChildren().length
); // domains
764 assertEquals(3, groups
[1].getChildren()[0].getChildren()[0].getChildren().length
); // channels
765 assertEquals(2, groups
[1].getChildren()[0].getChildren()[0].getChildren()[0].getChildren().length
); // events (of channel[0])
767 // Initialize session handling scenario
768 fProxy
.setScenario(TraceControlTestFacility
.SCEN_SCENARIO_SESSION_HANDLING
);
770 session
= (TraceSessionComponent
)groups
[1].getChildren()[0];
772 // ------------------------------------------------------------------------
774 // ------------------------------------------------------------------------
775 fFacility
.startSession(session
);
776 assertEquals(TraceSessionState
.ACTIVE
, session
.getSessionState());
778 // ------------------------------------------------------------------------
780 // ------------------------------------------------------------------------
781 fFacility
.stopSession(session
);
782 assertEquals(TraceSessionState
.INACTIVE
, session
.getSessionState());
784 // ------------------------------------------------------------------------
786 // ------------------------------------------------------------------------
788 fFacility
.destroySession(session
);
790 // Verify that no more session components exist
791 assertEquals(0, groups
[1].getChildren().length
);
793 //-------------------------------------------------------------------------
795 //-------------------------------------------------------------------------
796 fFacility
.executeCommand(node
, "disconnect");
797 assertEquals(TargetNodeState
.DISCONNECTED
, node
.getTargetNodeState());
799 //-------------------------------------------------------------------------
801 //-------------------------------------------------------------------------
803 fFacility
.executeCommand(node
, "delete");
804 assertEquals(0,fFacility
.getControlView().getTraceControlRoot().getChildren().length
);