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 * 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
.remote
.core
.IRemoteConnection
;
31 import org
.eclipse
.remote
.core
.IRemoteConnectionManager
;
32 import org
.eclipse
.remote
.core
.RemoteServices
;
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
.junit
.After
;
55 import org
.junit
.Before
;
56 import org
.junit
.Test
;
57 import org
.osgi
.framework
.FrameworkUtil
;
60 * The class <code>TraceControlKernelSessionTests</code> contains Kernel
61 * session/channel/event handling test cases.
63 public class TraceControlKernelSessionTests
{
65 // ------------------------------------------------------------------------
67 // ------------------------------------------------------------------------
69 private static final String TEST_STREAM
= "CreateTreeTest.cfg";
70 private static final String SCEN_SCENARIO3_TEST
= "Scenario3";
72 // ------------------------------------------------------------------------
74 // ------------------------------------------------------------------------
76 private TraceControlTestFacility fFacility
;
77 private TestRemoteSystemProxy fProxy
;
78 private String fTestFile
;
80 // ------------------------------------------------------------------------
82 // ------------------------------------------------------------------------
85 * Perform pre-test initialization.
88 * if the initialization fails for some reason
91 public void setUp() throws Exception
{
92 fFacility
= TraceControlTestFacility
.getInstance();
94 fProxy
= new TestRemoteSystemProxy();
95 URL location
= FileLocator
.find(FrameworkUtil
.getBundle(this.getClass()), new Path(TraceControlTestFacility
.DIRECTORY
+ File
.separator
+ TEST_STREAM
), null);
96 File testfile
= new File(FileLocator
.toFileURL(location
).toURI());
97 fTestFile
= testfile
.getAbsolutePath();
101 * Perform post-test clean-up.
104 public void tearDown() {
105 fFacility
.waitForJobs();
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 IRemoteConnectionManager cm
= RemoteServices
.getLocalServices().getConnectionManager();
124 IRemoteConnection host
= cm
.getConnection(IRemoteConnectionManager
.LOCAL_CONNECTION_NAME
);
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().getInName());
194 assertEquals(TraceChannelOutputType
.SPLICE
, channel
.getOutputType());
195 assertEquals(true, channel
.isOverwriteMode());
196 assertEquals(200, channel
.getReadTimer());
197 assertEquals(TraceEnablement
.ENABLED
, channel
.getState());
198 assertEquals(16384, channel
.getSubBufferSize());
199 assertEquals(100, channel
.getSwitchTimer());
201 // ------------------------------------------------------------------------
202 // Create channel on domain
203 // ------------------------------------------------------------------------
204 ChannelInfo info
= (ChannelInfo
)channelStub
.getChannelInfo();
205 info
.setName("mychannel2");
206 info
.setOverwriteMode(false);
207 info
.setSubBufferSize(32768);
208 info
.setNumberOfSubBuffers(2);
209 info
.setSwitchTimer(100);
210 info
.setReadTimer(200);
211 channelStub
.setChannelInfo(info
);
213 fFacility
.executeCommand(domains
[0], "enableChannelOnDomain");
215 // Get Kernel domain component instance
216 domains
= session
.getChildren();
217 assertNotNull(domains
);
218 assertEquals(1, domains
.length
);
220 // Verify that channel was created with correct data
221 channels
= domains
[0].getChildren();
222 assertNotNull(channels
);
223 assertEquals(2, channels
.length
);
225 assertTrue(channels
[1] instanceof TraceChannelComponent
);
226 channel
= (TraceChannelComponent
) channels
[1];
227 assertEquals("mychannel2", channel
.getName());
228 assertEquals(2, channel
.getNumberOfSubBuffers());
229 assertEquals("splice()", channel
.getOutputType().getInName());
230 assertEquals(TraceChannelOutputType
.SPLICE
, channel
.getOutputType());
231 assertEquals(false, channel
.isOverwriteMode());
232 assertEquals(200, channel
.getReadTimer());
233 assertEquals(TraceEnablement
.ENABLED
, channel
.getState());
234 assertEquals(32768, channel
.getSubBufferSize());
235 assertEquals(100, channel
.getSwitchTimer());
237 EnableEventsDialogStub eventsDialogStub
= new EnableEventsDialogStub();
238 eventsDialogStub
.setIsTracePoints(true);
239 List
<String
> events
= new ArrayList
<>();
240 events
.add("sched_kthread_stop");
241 events
.add("sched_kthread_stop_ret");
242 eventsDialogStub
.setNames(events
);
243 eventsDialogStub
.setIsKernel(true);
244 TraceControlDialogFactory
.getInstance().setEnableEventsDialog(eventsDialogStub
);
246 // ------------------------------------------------------------------------
248 // ------------------------------------------------------------------------
249 // Get Kernel domain component instance
250 domains
= session
.getChildren();
251 assertNotNull(domains
);
252 assertEquals(1, domains
.length
);
254 // Verify that channel was created with correct data
255 channels
= domains
[0].getChildren();
256 assertNotNull(channels
);
257 assertEquals(2, channels
.length
);
259 fFacility
.executeCommand(channels
, "disableChannel");
261 assertEquals(TraceEnablement
.DISABLED
, ((TraceChannelComponent
)channels
[0]).getState());
262 assertEquals(TraceEnablement
.DISABLED
, ((TraceChannelComponent
)channels
[1]).getState());
264 // ------------------------------------------------------------------------
266 // ------------------------------------------------------------------------
267 // Get Kernel domain component instance
268 domains
= session
.getChildren();
269 assertNotNull(domains
);
270 assertEquals(1, domains
.length
);
272 // Verify that channel was created with correct data
273 channels
= domains
[0].getChildren();
274 assertNotNull(channels
);
275 assertEquals(2, channels
.length
);
277 fFacility
.executeCommand(channels
, "enableChannel");
279 assertEquals(TraceEnablement
.ENABLED
, ((TraceChannelComponent
)channels
[0]).getState());
280 assertEquals(TraceEnablement
.ENABLED
, ((TraceChannelComponent
)channels
[1]).getState());
282 // ------------------------------------------------------------------------
283 // enable event (tracepoints) on session
284 // ------------------------------------------------------------------------
285 fFacility
.executeCommand(session
, "enableEventOnSession");
287 // Get Kernel domain component instance
288 domains
= session
.getChildren();
289 assertNotNull(domains
);
290 assertEquals(1, domains
.length
);
292 // Verify that channel was created with correct data
293 channels
= domains
[0].getChildren();
294 assertNotNull(channels
);
295 assertEquals(3, channels
.length
);
297 assertTrue(channels
[2] instanceof TraceChannelComponent
);
298 channel
= (TraceChannelComponent
) channels
[2];
299 assertEquals("channel0", channel
.getName());
300 // No need to check parameters of default channel because that has been done in other tests
302 ITraceControlComponent
[] channel0Events
= channel
.getChildren();
303 assertEquals(2, channel0Events
.length
);
305 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
306 assertTrue(channel0Events
[1] instanceof TraceEventComponent
);
308 TraceEventComponent event
= (TraceEventComponent
) channel0Events
[0];
309 assertEquals("sched_kthread_stop_ret", event
.getName());
310 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
311 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
312 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
314 event
= (TraceEventComponent
) channel0Events
[1];
315 assertEquals("sched_kthread_stop", event
.getName());
316 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
317 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
318 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
320 // ------------------------------------------------------------------------
321 // enable event (tracepoints) on domain
322 // ------------------------------------------------------------------------
324 events
.add("sched_wakeup_new");
325 eventsDialogStub
.setNames(events
);
327 fFacility
.executeCommand(domains
[0], "enableEventOnDomain");
329 // Get Kernel domain component instance
330 domains
= session
.getChildren();
331 assertNotNull(domains
);
332 assertEquals(1, domains
.length
);
334 // Verify that channel was created with correct data
335 channels
= domains
[0].getChildren();
336 channel
= (TraceChannelComponent
) channels
[2];
337 // No need to check parameters of default channel because that has been done in other tests
339 channel
= (TraceChannelComponent
) channels
[2];
341 channel0Events
= channel
.getChildren();
342 assertEquals(3, channel0Events
.length
);
344 assertTrue(channel0Events
[2] instanceof TraceEventComponent
);
346 event
= (TraceEventComponent
) channel0Events
[2];
347 assertEquals("sched_wakeup_new", event
.getName());
348 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
349 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
350 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
352 // ------------------------------------------------------------------------
353 // enable event (tracepoints) on channel
354 // ------------------------------------------------------------------------
356 eventsDialogStub
.setNames(events
);
357 eventsDialogStub
.setIsAllTracePoints(true);
359 fFacility
.executeCommand(channels
[1], "enableEventOnChannel");
361 // Get Kernel domain component instance
362 domains
= session
.getChildren();
363 assertNotNull(domains
);
364 assertEquals(1, domains
.length
);
366 // Verify that channel was created with correct data
367 channels
= domains
[0].getChildren();
368 // No need to check parameters of default channel because that has been done in other tests
369 channel
= (TraceChannelComponent
) channels
[1];
371 channel0Events
= channel
.getChildren();
372 assertEquals(3, channel0Events
.length
);
374 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
375 assertTrue(channel0Events
[1] instanceof TraceEventComponent
);
376 assertTrue(channel0Events
[2] instanceof TraceEventComponent
);
378 event
= (TraceEventComponent
) channel0Events
[0];
379 assertEquals("sched_kthread_stop_ret", event
.getName());
380 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
381 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
382 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
384 event
= (TraceEventComponent
) channel0Events
[1];
385 assertEquals("sched_kthread_stop", event
.getName());
386 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
387 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
388 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
390 event
= (TraceEventComponent
) channel0Events
[2];
391 assertEquals("sched_wakeup_new", event
.getName());
392 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
393 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
394 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
396 // ------------------------------------------------------------------------
397 // enable event (syscall) on channel
398 // ------------------------------------------------------------------------
400 eventsDialogStub
.setIsTracePoints(false);
401 eventsDialogStub
.setIsAllTracePoints(false);
402 eventsDialogStub
.setIsSysCalls(true);
404 fFacility
.executeCommand(channels
[0], "enableEventOnChannel");
406 // Get Kernel domain component instance
407 domains
= session
.getChildren();
408 assertNotNull(domains
);
409 assertEquals(1, domains
.length
);
411 // Verify that channel was created with correct data
412 channels
= domains
[0].getChildren();
413 channel
= (TraceChannelComponent
) channels
[0];
414 // No need to check parameters of default channel because that has been done in other tests
416 channel
= (TraceChannelComponent
) channels
[0];
418 channel0Events
= channel
.getChildren();
419 assertEquals(1, channel0Events
.length
);
421 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
423 event
= (TraceEventComponent
) channel0Events
[0];
424 assertEquals("syscalls", event
.getName());
425 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, event
.getLogLevel());
426 assertEquals(TraceEventType
.SYSCALL
, event
.getEventType());
427 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
429 // ------------------------------------------------------------------------
430 // enable event (syscall) on domain
431 // ------------------------------------------------------------------------
432 fFacility
.executeCommand(domains
[0], "enableEventOnDomain");
434 // Get Kernel domain component instance
435 domains
= session
.getChildren();
436 assertNotNull(domains
);
437 assertEquals(1, domains
.length
);
439 // Verify that channel was created with correct data
440 channels
= domains
[0].getChildren();
441 channel
= (TraceChannelComponent
) channels
[0];
442 // No need to check parameters of default channel because that has been done in other tests
444 channel
= (TraceChannelComponent
) channels
[2];
446 channel0Events
= channel
.getChildren();
447 assertEquals(4, channel0Events
.length
);
449 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
451 event
= (TraceEventComponent
) channel0Events
[0];
452 assertEquals("syscalls", event
.getName());
453 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, event
.getLogLevel());
454 assertEquals(TraceEventType
.SYSCALL
, event
.getEventType());
455 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
457 // ------------------------------------------------------------------------
458 // enable event (syscall) on session
459 // ------------------------------------------------------------------------
460 fFacility
.executeCommand(session
, "enableEventOnSession");
462 // Get Kernel domain component instance
463 domains
= session
.getChildren();
464 assertNotNull(domains
);
465 assertEquals(1, domains
.length
);
467 // Verify that channel was created with correct data
468 channels
= domains
[0].getChildren();
469 channel
= (TraceChannelComponent
) channels
[0];
470 // No need to check parameters of default channel because that has been done in other tests
472 channel
= (TraceChannelComponent
) channels
[2];
474 channel0Events
= channel
.getChildren();
475 assertEquals(4, channel0Events
.length
);
477 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
479 event
= (TraceEventComponent
) channel0Events
[0];
480 assertEquals("syscalls", event
.getName());
481 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, event
.getLogLevel());
482 assertEquals(TraceEventType
.SYSCALL
, event
.getEventType());
483 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
486 // ------------------------------------------------------------------------
487 // enable event (dynamic probe) on domain
488 // ------------------------------------------------------------------------
490 eventsDialogStub
.setIsSysCalls(false);
491 eventsDialogStub
.setIsDynamicProbe(true);
492 eventsDialogStub
.setDynamicProbe("0xc0101280");
493 eventsDialogStub
.setProbeEventName("myevent1");
495 fFacility
.executeCommand(domains
[0], "enableEventOnDomain");
497 // Get Kernel domain component instance
498 domains
= session
.getChildren();
499 assertNotNull(domains
);
500 assertEquals(1, domains
.length
);
502 // Verify that channel was created with correct data
503 channels
= domains
[0].getChildren();
504 channel
= (TraceChannelComponent
) channels
[2];
505 // No need to check parameters of default channel because that has been done in other tests
507 channel0Events
= channel
.getChildren();
508 assertEquals(5, channel0Events
.length
);
510 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
512 TraceProbeEventComponent probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
513 assertEquals("myevent1", probeEvent
.getName());
514 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
515 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
516 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
517 assertNull(probeEvent
.getOffset());
518 assertEquals("0xc0101280", probeEvent
.getAddress());
519 assertNull(probeEvent
.getSymbol());
521 // ------------------------------------------------------------------------
522 // enable event (dynamic probe) on channel
523 // ------------------------------------------------------------------------
524 eventsDialogStub
.setIsDynamicProbe(true);
525 eventsDialogStub
.setDynamicProbe("init_post");
526 eventsDialogStub
.setProbeEventName("myevent2");
528 fFacility
.executeCommand(channels
[2], "enableEventOnChannel");
530 // Get Kernel domain component instance
531 domains
= session
.getChildren();
532 assertNotNull(domains
);
533 assertEquals(1, domains
.length
);
535 // Verify that channel was created with correct data
536 channels
= domains
[0].getChildren();
537 channel
= (TraceChannelComponent
) channels
[2];
538 // No need to check parameters of default channel because that has been done in other tests
540 channel0Events
= channel
.getChildren();
541 assertEquals(6, channel0Events
.length
);
543 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
545 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
546 assertEquals("myevent2", probeEvent
.getName());
547 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
548 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
549 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
550 assertEquals("0x0", probeEvent
.getOffset());
551 assertNull(null, probeEvent
.getAddress());
552 assertEquals("init_post", probeEvent
.getSymbol());
554 // ------------------------------------------------------------------------
555 // enable event (dynamic probe) on session
556 // ------------------------------------------------------------------------
557 eventsDialogStub
.setIsDynamicProbe(true);
558 eventsDialogStub
.setDynamicProbe("init_post:0x1000");
559 eventsDialogStub
.setProbeEventName("myevent3");
561 fFacility
.executeCommand(session
, "enableEventOnSession");
563 // Get Kernel domain component instance
564 domains
= session
.getChildren();
565 assertNotNull(domains
);
566 assertEquals(1, domains
.length
);
568 // Verify that channel was created with correct data
569 channels
= domains
[0].getChildren();
570 channel
= (TraceChannelComponent
) channels
[2];
571 // No need to check parameters of default channel because that has been done in other tests
573 channel0Events
= channel
.getChildren();
574 assertEquals(7, channel0Events
.length
);
576 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
578 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
579 assertEquals("myevent3", probeEvent
.getName());
580 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
581 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
582 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
583 assertEquals("0x1000", probeEvent
.getOffset());
584 assertNull(null, probeEvent
.getAddress());
585 assertEquals("init_post", probeEvent
.getSymbol());
587 // ------------------------------------------------------------------------
588 // enable event (dynamic function probe) on session
589 // ------------------------------------------------------------------------
590 eventsDialogStub
.setIsDynamicProbe(false);
591 eventsDialogStub
.setDynamicProbe(null);
592 eventsDialogStub
.setProbeEventName(null);
593 eventsDialogStub
.setIsFunctionProbe(true);
594 eventsDialogStub
.setFunctionEventName("myevent4");
595 eventsDialogStub
.setFunctionProbe("create_dev");
597 fFacility
.executeCommand(session
, "enableEventOnSession");
599 // Get Kernel domain component instance
600 domains
= session
.getChildren();
601 assertNotNull(domains
);
602 assertEquals(1, domains
.length
);
604 // Verify that channel was created with correct data
605 channels
= domains
[0].getChildren();
606 channel
= (TraceChannelComponent
) channels
[2];
607 // No need to check parameters of default channel because that has been done in other tests
609 channel0Events
= channel
.getChildren();
610 assertEquals(8, channel0Events
.length
);
612 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
614 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
615 assertEquals("myevent4", probeEvent
.getName());
616 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
617 // Changed for Bug fix 419454 to function event which was introduced by LTTng 2.2
618 assertEquals(TraceEventType
.FUNCTION
, probeEvent
.getEventType());
619 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
620 assertEquals("0x0", probeEvent
.getOffset());
621 assertNull(null, probeEvent
.getAddress());
622 assertEquals("create_dev", probeEvent
.getSymbol());
624 // ------------------------------------------------------------------------
625 // enable event (dynamic function probe) on domain
626 // ------------------------------------------------------------------------
627 eventsDialogStub
.setIsFunctionProbe(true);
628 eventsDialogStub
.setFunctionEventName("myevent5");
629 eventsDialogStub
.setFunctionProbe("create_dev:0x2000");
631 fFacility
.executeCommand(domains
[0], "enableEventOnDomain");
633 // Get Kernel domain component instance
634 domains
= session
.getChildren();
635 assertNotNull(domains
);
636 assertEquals(1, domains
.length
);
638 // Verify that channel was created with correct data
639 channels
= domains
[0].getChildren();
640 channel
= (TraceChannelComponent
) channels
[2];
641 // No need to check parameters of default channel because that has been done in other tests
643 channel0Events
= channel
.getChildren();
644 assertEquals(9, channel0Events
.length
);
646 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
648 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
649 assertEquals("myevent5", probeEvent
.getName());
650 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
651 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
652 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
653 assertEquals("0x2000", probeEvent
.getOffset());
654 assertNull(null, probeEvent
.getAddress());
655 assertEquals("create_dev", probeEvent
.getSymbol());
657 // ------------------------------------------------------------------------
658 // enable event (dynamic function probe) on channel
659 // ------------------------------------------------------------------------
660 eventsDialogStub
.setIsFunctionProbe(true);
661 eventsDialogStub
.setFunctionEventName("myevent");
662 eventsDialogStub
.setFunctionProbe("create_dev:0x2000");
664 fFacility
.executeCommand(channels
[0], "enableEventOnChannel");
666 // Get Kernel domain component instance
667 domains
= session
.getChildren();
668 assertNotNull(domains
);
669 assertEquals(1, domains
.length
);
671 // Verify that channel was created with correct data
672 channels
= domains
[0].getChildren();
673 channel
= (TraceChannelComponent
) channels
[0];
674 // No need to check parameters of default channel because that has been done in other tests
676 channel0Events
= channel
.getChildren();
677 assertEquals(2, channel0Events
.length
);
679 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
681 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
682 assertEquals("myevent", probeEvent
.getName());
683 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
684 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
685 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
686 assertEquals("0x2000", probeEvent
.getOffset());
687 assertNull(null, probeEvent
.getAddress());
688 assertEquals("create_dev", probeEvent
.getSymbol());
690 // ------------------------------------------------------------------------
691 // Add Context on domain
692 // ------------------------------------------------------------------------
693 // Get Kernel domain component instance
694 domains
= session
.getChildren();
695 assertNotNull(domains
);
696 assertEquals(1, domains
.length
);
698 AddContextDialogStub addContextStub
= new AddContextDialogStub();
699 List
<String
> contexts
= new ArrayList
<>();
700 contexts
.add("prio");
701 contexts
.add("perf:branch-misses");
702 contexts
.add("perf:cache-misses");
703 addContextStub
.setContexts(contexts
);
704 TraceControlDialogFactory
.getInstance().setAddContextDialog(addContextStub
);
706 fFacility
.executeCommand(domains
[0], "addContextOnDomain");
707 // Currently there is nothing to verify because the list commands don't show any context information
708 // However, the execution of the command make sure that the correct service command line is build and executed.
710 // ------------------------------------------------------------------------
711 // Add Context on channel
712 // ------------------------------------------------------------------------
714 // Get Kernel domain component instance
715 domains
= session
.getChildren();
716 assertNotNull(domains
);
717 assertEquals(1, domains
.length
);
719 //Verify that channel was created with correct data
720 channels
= domains
[0].getChildren();
721 channel
= (TraceChannelComponent
) channels
[0];
724 // The setContext() verifies that the contexts set are part of the available contexts
725 // The available contexts are set by the command handler addContextOnDomain above.
726 // So we indirectly test here that the parsing and setting of available contexts were
727 // done correctly above.
728 addContextStub
.setContexts(contexts
);
729 } catch (IllegalArgumentException e
) {
730 fail("Exception caught - unknown context");
733 fFacility
.executeCommand(channel
, "addContextOnChannel");
734 // Currently there is nothing to verify because the list commands don't show any context information
735 // However, the execution of the command make sure that the correct service command line is build and executed.
737 // ------------------------------------------------------------------------
738 // Add Context on event
739 // ------------------------------------------------------------------------
740 // Get Kernel domain component instance
741 domains
= session
.getChildren();
742 assertNotNull(domains
);
743 assertEquals(1, domains
.length
);
745 //Verify that channel was created with correct data
746 channels
= domains
[0].getChildren();
747 channel
= (TraceChannelComponent
) channels
[2];
749 channel0Events
= channel
.getChildren();
751 event
= (TraceEventComponent
) channel0Events
[6];
753 fFacility
.executeCommand(event
, "addContextOnEvent");
754 // Currently there is nothing to verify because the list commands don't show any context information
755 // However, the execution of the command make sure that the correct service command line is build and executed.
757 // ------------------------------------------------------------------------
759 // ------------------------------------------------------------------------
760 // Get Kernel domain component instance
761 domains
= session
.getChildren();
762 assertNotNull(domains
);
763 assertEquals(1, domains
.length
);
765 fFacility
.executeCommand(domains
[0], "calibrate");
766 // There is nothing to verify here.
767 // However, the execution of the command make sure that the correct service command line is build and executed.
769 // ------------------------------------------------------------------------
771 // ------------------------------------------------------------------------
772 fFacility
.executeCommand(node
, "refresh");
773 groups
= node
.getChildren();
774 assertNotNull(groups
);
775 assertEquals(2, groups
.length
);
776 assertEquals(3, groups
[0].getChildren().length
); // provider
777 assertEquals(1, groups
[1].getChildren().length
); // sessions
778 assertEquals(1, groups
[1].getChildren()[0].getChildren().length
); // domains
779 assertEquals(3, groups
[1].getChildren()[0].getChildren()[0].getChildren().length
); // channels
780 assertEquals(2, groups
[1].getChildren()[0].getChildren()[0].getChildren()[0].getChildren().length
); // events (of channel[0])
782 // Initialize session handling scenario
783 fProxy
.setScenario(TraceControlTestFacility
.SCEN_SCENARIO_SESSION_HANDLING
);
785 session
= (TraceSessionComponent
)groups
[1].getChildren()[0];
787 // ------------------------------------------------------------------------
789 // ------------------------------------------------------------------------
790 fFacility
.startSession(session
);
791 assertEquals(TraceSessionState
.ACTIVE
, session
.getSessionState());
793 // ------------------------------------------------------------------------
795 // ------------------------------------------------------------------------
796 fFacility
.stopSession(session
);
797 assertEquals(TraceSessionState
.INACTIVE
, session
.getSessionState());
799 // ------------------------------------------------------------------------
801 // ------------------------------------------------------------------------
803 fFacility
.destroySession(session
);
805 // Verify that no more session components exist
806 assertEquals(0, groups
[1].getChildren().length
);
808 //-------------------------------------------------------------------------
810 //-------------------------------------------------------------------------
811 fFacility
.executeCommand(node
, "disconnect");
812 assertEquals(TargetNodeState
.DISCONNECTED
, node
.getTargetNodeState());
814 //-------------------------------------------------------------------------
816 //-------------------------------------------------------------------------
818 fFacility
.executeCommand(node
, "delete");
819 assertEquals(0,fFacility
.getControlView().getTraceControlRoot().getChildren().length
);