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
.TraceChannelOutputType
;
38 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.TraceEnablement
;
39 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.TraceEventType
;
40 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.TraceLogLevel
;
41 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.TraceSessionState
;
42 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.impl
.ChannelInfo
;
43 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.dialogs
.TraceControlDialogFactory
;
44 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.model
.ITraceControlComponent
;
45 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TargetNodeComponent
;
46 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TraceChannelComponent
;
47 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TraceEventComponent
;
48 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TraceProbeEventComponent
;
49 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TraceSessionComponent
;
50 import org
.eclipse
.rse
.core
.RSECorePlugin
;
51 import org
.eclipse
.rse
.core
.model
.IHost
;
52 import org
.eclipse
.rse
.core
.model
.ISystemProfile
;
53 import org
.eclipse
.rse
.core
.model
.ISystemRegistry
;
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 ISystemRegistry registry
= RSECorePlugin
.getTheSystemRegistry();
124 ISystemProfile profile
= registry
.createSystemProfile("myProfile", true);
125 IHost host
= registry
.createLocalHost(profile
, "myProfile", "user");
127 TargetNodeComponent node
= new TargetNodeComponent("myNode", root
, host
, fProxy
);
130 fFacility
.waitForJobs();
132 fFacility
.executeCommand(node
, "connect");
134 while ((i
< 10) && (node
.getTargetNodeState() != TargetNodeState
.CONNECTED
)) {
136 fFacility
.delay(TraceControlTestFacility
.GUI_REFESH_DELAY
);
139 // Verify that node is connected
140 assertEquals(TargetNodeState
.CONNECTED
, node
.getTargetNodeState());
142 // Get provider groups
143 ITraceControlComponent
[] groups
= node
.getChildren();
144 assertNotNull(groups
);
145 assertEquals(2, groups
.length
);
147 // Initialize dialog implementations for command execution
148 TraceControlDialogFactory
.getInstance().setCreateSessionDialog(new CreateSessionDialogStub());
149 TraceControlDialogFactory
.getInstance().setGetEventInfoDialog(new GetEventInfoDialogStub());
150 TraceControlDialogFactory
.getInstance().setConfirmDialog(new DestroyConfirmDialogStub());
152 // Initialize session handling scenario
153 fProxy
.setScenario(TraceControlTestFacility
.SCEN_SCENARIO_SESSION_HANDLING
);
155 // ------------------------------------------------------------------------
157 // ------------------------------------------------------------------------
158 TraceSessionComponent session
= fFacility
.createSession(groups
[1]);
160 // Verify that session was created
161 assertNotNull(session
);
162 assertEquals("mysession", session
.getName());
163 assertEquals("/home/user/lttng-traces/mysession-20120314-132824", session
.getSessionPath());
164 assertEquals(TraceSessionState
.INACTIVE
, session
.getSessionState());
166 // Initialize scenario
167 fProxy
.setScenario(SCEN_SCENARIO3_TEST
);
169 // ------------------------------------------------------------------------
170 // Enable channel on session
171 // ------------------------------------------------------------------------
172 EnableChannelDialogStub channelStub
= new EnableChannelDialogStub();
173 channelStub
.setIsKernel(true);
174 TraceControlDialogFactory
.getInstance().setEnableChannelDialog(channelStub
);
176 fFacility
.executeCommand(session
, "enableChannelOnSession");
178 // Verify that Kernel domain was created
179 ITraceControlComponent
[] domains
= session
.getChildren();
180 assertNotNull(domains
);
181 assertEquals(1, domains
.length
);
183 assertEquals("Kernel", domains
[0].getName());
185 // Verify that channel was created with correct data
186 ITraceControlComponent
[] channels
= domains
[0].getChildren();
187 assertNotNull(channels
);
188 assertEquals(1, channels
.length
);
190 assertTrue(channels
[0] instanceof TraceChannelComponent
);
191 TraceChannelComponent channel
= (TraceChannelComponent
) channels
[0];
192 assertEquals("mychannel", channel
.getName());
193 assertEquals(4, channel
.getNumberOfSubBuffers());
194 assertEquals("splice()", channel
.getOutputType().getInName());
195 assertEquals(TraceChannelOutputType
.SPLICE
, channel
.getOutputType());
196 assertEquals(true, channel
.isOverwriteMode());
197 assertEquals(200, channel
.getReadTimer());
198 assertEquals(TraceEnablement
.ENABLED
, channel
.getState());
199 assertEquals(16384, channel
.getSubBufferSize());
200 assertEquals(100, channel
.getSwitchTimer());
202 // ------------------------------------------------------------------------
203 // Create channel on domain
204 // ------------------------------------------------------------------------
205 ChannelInfo info
= (ChannelInfo
)channelStub
.getChannelInfo();
206 info
.setName("mychannel2");
207 info
.setOverwriteMode(false);
208 info
.setSubBufferSize(32768);
209 info
.setNumberOfSubBuffers(2);
210 info
.setSwitchTimer(100);
211 info
.setReadTimer(200);
212 channelStub
.setChannelInfo(info
);
214 fFacility
.executeCommand(domains
[0], "enableChannelOnDomain");
216 // Get Kernel domain component instance
217 domains
= session
.getChildren();
218 assertNotNull(domains
);
219 assertEquals(1, domains
.length
);
221 // Verify that channel was created with correct data
222 channels
= domains
[0].getChildren();
223 assertNotNull(channels
);
224 assertEquals(2, channels
.length
);
226 assertTrue(channels
[1] instanceof TraceChannelComponent
);
227 channel
= (TraceChannelComponent
) channels
[1];
228 assertEquals("mychannel2", channel
.getName());
229 assertEquals(2, channel
.getNumberOfSubBuffers());
230 assertEquals("splice()", channel
.getOutputType().getInName());
231 assertEquals(TraceChannelOutputType
.SPLICE
, channel
.getOutputType());
232 assertEquals(false, channel
.isOverwriteMode());
233 assertEquals(200, channel
.getReadTimer());
234 assertEquals(TraceEnablement
.ENABLED
, channel
.getState());
235 assertEquals(32768, channel
.getSubBufferSize());
236 assertEquals(100, channel
.getSwitchTimer());
238 EnableEventsDialogStub eventsDialogStub
= new EnableEventsDialogStub();
239 eventsDialogStub
.setIsTracePoints(true);
240 List
<String
> events
= new ArrayList
<>();
241 events
.add("sched_kthread_stop");
242 events
.add("sched_kthread_stop_ret");
243 eventsDialogStub
.setNames(events
);
244 eventsDialogStub
.setIsKernel(true);
245 TraceControlDialogFactory
.getInstance().setEnableEventsDialog(eventsDialogStub
);
247 // ------------------------------------------------------------------------
249 // ------------------------------------------------------------------------
250 // Get Kernel domain component instance
251 domains
= session
.getChildren();
252 assertNotNull(domains
);
253 assertEquals(1, domains
.length
);
255 // Verify that channel was created with correct data
256 channels
= domains
[0].getChildren();
257 assertNotNull(channels
);
258 assertEquals(2, channels
.length
);
260 fFacility
.executeCommand(channels
, "disableChannel");
262 assertEquals(TraceEnablement
.DISABLED
, ((TraceChannelComponent
)channels
[0]).getState());
263 assertEquals(TraceEnablement
.DISABLED
, ((TraceChannelComponent
)channels
[1]).getState());
265 // ------------------------------------------------------------------------
267 // ------------------------------------------------------------------------
268 // Get Kernel domain component instance
269 domains
= session
.getChildren();
270 assertNotNull(domains
);
271 assertEquals(1, domains
.length
);
273 // Verify that channel was created with correct data
274 channels
= domains
[0].getChildren();
275 assertNotNull(channels
);
276 assertEquals(2, channels
.length
);
278 fFacility
.executeCommand(channels
, "enableChannel");
280 assertEquals(TraceEnablement
.ENABLED
, ((TraceChannelComponent
)channels
[0]).getState());
281 assertEquals(TraceEnablement
.ENABLED
, ((TraceChannelComponent
)channels
[1]).getState());
283 // ------------------------------------------------------------------------
284 // enable event (tracepoints) on session
285 // ------------------------------------------------------------------------
286 fFacility
.executeCommand(session
, "enableEventOnSession");
288 // Get Kernel domain component instance
289 domains
= session
.getChildren();
290 assertNotNull(domains
);
291 assertEquals(1, domains
.length
);
293 // Verify that channel was created with correct data
294 channels
= domains
[0].getChildren();
295 assertNotNull(channels
);
296 assertEquals(3, channels
.length
);
298 assertTrue(channels
[2] instanceof TraceChannelComponent
);
299 channel
= (TraceChannelComponent
) channels
[2];
300 assertEquals("channel0", channel
.getName());
301 // No need to check parameters of default channel because that has been done in other tests
303 ITraceControlComponent
[] channel0Events
= channel
.getChildren();
304 assertEquals(2, channel0Events
.length
);
306 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
307 assertTrue(channel0Events
[1] instanceof TraceEventComponent
);
309 TraceEventComponent event
= (TraceEventComponent
) channel0Events
[0];
310 assertEquals("sched_kthread_stop_ret", event
.getName());
311 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
312 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
313 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
315 event
= (TraceEventComponent
) channel0Events
[1];
316 assertEquals("sched_kthread_stop", event
.getName());
317 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
318 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
319 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
321 // ------------------------------------------------------------------------
322 // enable event (tracepoints) on domain
323 // ------------------------------------------------------------------------
325 events
.add("sched_wakeup_new");
326 eventsDialogStub
.setNames(events
);
328 fFacility
.executeCommand(domains
[0], "enableEventOnDomain");
330 // Get Kernel domain component instance
331 domains
= session
.getChildren();
332 assertNotNull(domains
);
333 assertEquals(1, domains
.length
);
335 // Verify that channel was created with correct data
336 channels
= domains
[0].getChildren();
337 channel
= (TraceChannelComponent
) channels
[2];
338 // No need to check parameters of default channel because that has been done in other tests
340 channel
= (TraceChannelComponent
) channels
[2];
342 channel0Events
= channel
.getChildren();
343 assertEquals(3, channel0Events
.length
);
345 assertTrue(channel0Events
[2] instanceof TraceEventComponent
);
347 event
= (TraceEventComponent
) channel0Events
[2];
348 assertEquals("sched_wakeup_new", event
.getName());
349 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
350 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
351 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
353 // ------------------------------------------------------------------------
354 // enable event (tracepoints) on channel
355 // ------------------------------------------------------------------------
357 eventsDialogStub
.setNames(events
);
358 eventsDialogStub
.setIsAllTracePoints(true);
360 fFacility
.executeCommand(channels
[1], "enableEventOnChannel");
362 // Get Kernel domain component instance
363 domains
= session
.getChildren();
364 assertNotNull(domains
);
365 assertEquals(1, domains
.length
);
367 // Verify that channel was created with correct data
368 channels
= domains
[0].getChildren();
369 // No need to check parameters of default channel because that has been done in other tests
370 channel
= (TraceChannelComponent
) channels
[1];
372 channel0Events
= channel
.getChildren();
373 assertEquals(3, channel0Events
.length
);
375 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
376 assertTrue(channel0Events
[1] instanceof TraceEventComponent
);
377 assertTrue(channel0Events
[2] instanceof TraceEventComponent
);
379 event
= (TraceEventComponent
) channel0Events
[0];
380 assertEquals("sched_kthread_stop_ret", event
.getName());
381 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
382 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
383 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
385 event
= (TraceEventComponent
) channel0Events
[1];
386 assertEquals("sched_kthread_stop", event
.getName());
387 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
388 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
389 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
391 event
= (TraceEventComponent
) channel0Events
[2];
392 assertEquals("sched_wakeup_new", event
.getName());
393 assertEquals(TraceLogLevel
.TRACE_EMERG
, event
.getLogLevel());
394 assertEquals(TraceEventType
.TRACEPOINT
, event
.getEventType());
395 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
397 // ------------------------------------------------------------------------
398 // enable event (syscall) on channel
399 // ------------------------------------------------------------------------
401 eventsDialogStub
.setIsTracePoints(false);
402 eventsDialogStub
.setIsAllTracePoints(false);
403 eventsDialogStub
.setIsSysCalls(true);
405 fFacility
.executeCommand(channels
[0], "enableEventOnChannel");
407 // Get Kernel domain component instance
408 domains
= session
.getChildren();
409 assertNotNull(domains
);
410 assertEquals(1, domains
.length
);
412 // Verify that channel was created with correct data
413 channels
= domains
[0].getChildren();
414 channel
= (TraceChannelComponent
) channels
[0];
415 // No need to check parameters of default channel because that has been done in other tests
417 channel
= (TraceChannelComponent
) channels
[0];
419 channel0Events
= channel
.getChildren();
420 assertEquals(1, channel0Events
.length
);
422 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
424 event
= (TraceEventComponent
) channel0Events
[0];
425 assertEquals("syscalls", event
.getName());
426 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, event
.getLogLevel());
427 assertEquals(TraceEventType
.SYSCALL
, event
.getEventType());
428 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
430 // ------------------------------------------------------------------------
431 // enable event (syscall) on domain
432 // ------------------------------------------------------------------------
433 fFacility
.executeCommand(domains
[0], "enableEventOnDomain");
435 // Get Kernel domain component instance
436 domains
= session
.getChildren();
437 assertNotNull(domains
);
438 assertEquals(1, domains
.length
);
440 // Verify that channel was created with correct data
441 channels
= domains
[0].getChildren();
442 channel
= (TraceChannelComponent
) channels
[0];
443 // No need to check parameters of default channel because that has been done in other tests
445 channel
= (TraceChannelComponent
) channels
[2];
447 channel0Events
= channel
.getChildren();
448 assertEquals(4, channel0Events
.length
);
450 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
452 event
= (TraceEventComponent
) channel0Events
[0];
453 assertEquals("syscalls", event
.getName());
454 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, event
.getLogLevel());
455 assertEquals(TraceEventType
.SYSCALL
, event
.getEventType());
456 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
458 // ------------------------------------------------------------------------
459 // enable event (syscall) on session
460 // ------------------------------------------------------------------------
461 fFacility
.executeCommand(session
, "enableEventOnSession");
463 // Get Kernel domain component instance
464 domains
= session
.getChildren();
465 assertNotNull(domains
);
466 assertEquals(1, domains
.length
);
468 // Verify that channel was created with correct data
469 channels
= domains
[0].getChildren();
470 channel
= (TraceChannelComponent
) channels
[0];
471 // No need to check parameters of default channel because that has been done in other tests
473 channel
= (TraceChannelComponent
) channels
[2];
475 channel0Events
= channel
.getChildren();
476 assertEquals(4, channel0Events
.length
);
478 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
480 event
= (TraceEventComponent
) channel0Events
[0];
481 assertEquals("syscalls", event
.getName());
482 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, event
.getLogLevel());
483 assertEquals(TraceEventType
.SYSCALL
, event
.getEventType());
484 assertEquals(TraceEnablement
.ENABLED
, event
.getState());
487 // ------------------------------------------------------------------------
488 // enable event (dynamic probe) on domain
489 // ------------------------------------------------------------------------
491 eventsDialogStub
.setIsSysCalls(false);
492 eventsDialogStub
.setIsDynamicProbe(true);
493 eventsDialogStub
.setDynamicProbe("0xc0101280");
494 eventsDialogStub
.setProbeEventName("myevent1");
496 fFacility
.executeCommand(domains
[0], "enableEventOnDomain");
498 // Get Kernel domain component instance
499 domains
= session
.getChildren();
500 assertNotNull(domains
);
501 assertEquals(1, domains
.length
);
503 // Verify that channel was created with correct data
504 channels
= domains
[0].getChildren();
505 channel
= (TraceChannelComponent
) channels
[2];
506 // No need to check parameters of default channel because that has been done in other tests
508 channel0Events
= channel
.getChildren();
509 assertEquals(5, channel0Events
.length
);
511 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
513 TraceProbeEventComponent probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
514 assertEquals("myevent1", probeEvent
.getName());
515 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
516 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
517 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
518 assertNull(probeEvent
.getOffset());
519 assertEquals("0xc0101280", probeEvent
.getAddress());
520 assertNull(probeEvent
.getSymbol());
522 // ------------------------------------------------------------------------
523 // enable event (dynamic probe) on channel
524 // ------------------------------------------------------------------------
525 eventsDialogStub
.setIsDynamicProbe(true);
526 eventsDialogStub
.setDynamicProbe("init_post");
527 eventsDialogStub
.setProbeEventName("myevent2");
529 fFacility
.executeCommand(channels
[2], "enableEventOnChannel");
531 // Get Kernel domain component instance
532 domains
= session
.getChildren();
533 assertNotNull(domains
);
534 assertEquals(1, domains
.length
);
536 // Verify that channel was created with correct data
537 channels
= domains
[0].getChildren();
538 channel
= (TraceChannelComponent
) channels
[2];
539 // No need to check parameters of default channel because that has been done in other tests
541 channel0Events
= channel
.getChildren();
542 assertEquals(6, channel0Events
.length
);
544 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
546 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
547 assertEquals("myevent2", probeEvent
.getName());
548 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
549 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
550 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
551 assertEquals("0x0", probeEvent
.getOffset());
552 assertNull(null, probeEvent
.getAddress());
553 assertEquals("init_post", probeEvent
.getSymbol());
555 // ------------------------------------------------------------------------
556 // enable event (dynamic probe) on session
557 // ------------------------------------------------------------------------
558 eventsDialogStub
.setIsDynamicProbe(true);
559 eventsDialogStub
.setDynamicProbe("init_post:0x1000");
560 eventsDialogStub
.setProbeEventName("myevent3");
562 fFacility
.executeCommand(session
, "enableEventOnSession");
564 // Get Kernel domain component instance
565 domains
= session
.getChildren();
566 assertNotNull(domains
);
567 assertEquals(1, domains
.length
);
569 // Verify that channel was created with correct data
570 channels
= domains
[0].getChildren();
571 channel
= (TraceChannelComponent
) channels
[2];
572 // No need to check parameters of default channel because that has been done in other tests
574 channel0Events
= channel
.getChildren();
575 assertEquals(7, channel0Events
.length
);
577 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
579 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
580 assertEquals("myevent3", probeEvent
.getName());
581 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
582 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
583 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
584 assertEquals("0x1000", probeEvent
.getOffset());
585 assertNull(null, probeEvent
.getAddress());
586 assertEquals("init_post", probeEvent
.getSymbol());
588 // ------------------------------------------------------------------------
589 // enable event (dynamic function probe) on session
590 // ------------------------------------------------------------------------
591 eventsDialogStub
.setIsDynamicProbe(false);
592 eventsDialogStub
.setDynamicProbe(null);
593 eventsDialogStub
.setProbeEventName(null);
594 eventsDialogStub
.setIsFunctionProbe(true);
595 eventsDialogStub
.setFunctionEventName("myevent4");
596 eventsDialogStub
.setFunctionProbe("create_dev");
598 fFacility
.executeCommand(session
, "enableEventOnSession");
600 // Get Kernel domain component instance
601 domains
= session
.getChildren();
602 assertNotNull(domains
);
603 assertEquals(1, domains
.length
);
605 // Verify that channel was created with correct data
606 channels
= domains
[0].getChildren();
607 channel
= (TraceChannelComponent
) channels
[2];
608 // No need to check parameters of default channel because that has been done in other tests
610 channel0Events
= channel
.getChildren();
611 assertEquals(8, channel0Events
.length
);
613 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
615 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
616 assertEquals("myevent4", probeEvent
.getName());
617 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
618 // Changed for Bug fix 419454 to function event which was introduced by LTTng 2.2
619 assertEquals(TraceEventType
.FUNCTION
, probeEvent
.getEventType());
620 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
621 assertEquals("0x0", probeEvent
.getOffset());
622 assertNull(null, probeEvent
.getAddress());
623 assertEquals("create_dev", probeEvent
.getSymbol());
625 // ------------------------------------------------------------------------
626 // enable event (dynamic function probe) on domain
627 // ------------------------------------------------------------------------
628 eventsDialogStub
.setIsFunctionProbe(true);
629 eventsDialogStub
.setFunctionEventName("myevent5");
630 eventsDialogStub
.setFunctionProbe("create_dev:0x2000");
632 fFacility
.executeCommand(domains
[0], "enableEventOnDomain");
634 // Get Kernel domain component instance
635 domains
= session
.getChildren();
636 assertNotNull(domains
);
637 assertEquals(1, domains
.length
);
639 // Verify that channel was created with correct data
640 channels
= domains
[0].getChildren();
641 channel
= (TraceChannelComponent
) channels
[2];
642 // No need to check parameters of default channel because that has been done in other tests
644 channel0Events
= channel
.getChildren();
645 assertEquals(9, channel0Events
.length
);
647 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
649 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
650 assertEquals("myevent5", probeEvent
.getName());
651 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
652 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
653 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
654 assertEquals("0x2000", probeEvent
.getOffset());
655 assertNull(null, probeEvent
.getAddress());
656 assertEquals("create_dev", probeEvent
.getSymbol());
658 // ------------------------------------------------------------------------
659 // enable event (dynamic function probe) on channel
660 // ------------------------------------------------------------------------
661 eventsDialogStub
.setIsFunctionProbe(true);
662 eventsDialogStub
.setFunctionEventName("myevent");
663 eventsDialogStub
.setFunctionProbe("create_dev:0x2000");
665 fFacility
.executeCommand(channels
[0], "enableEventOnChannel");
667 // Get Kernel domain component instance
668 domains
= session
.getChildren();
669 assertNotNull(domains
);
670 assertEquals(1, domains
.length
);
672 // Verify that channel was created with correct data
673 channels
= domains
[0].getChildren();
674 channel
= (TraceChannelComponent
) channels
[0];
675 // No need to check parameters of default channel because that has been done in other tests
677 channel0Events
= channel
.getChildren();
678 assertEquals(2, channel0Events
.length
);
680 assertTrue(channel0Events
[0] instanceof TraceProbeEventComponent
);
682 probeEvent
= (TraceProbeEventComponent
) channel0Events
[0];
683 assertEquals("myevent", probeEvent
.getName());
684 assertEquals(TraceLogLevel
.LEVEL_UNKNOWN
, probeEvent
.getLogLevel());
685 assertEquals(TraceEventType
.PROBE
, probeEvent
.getEventType());
686 assertEquals(TraceEnablement
.ENABLED
, probeEvent
.getState());
687 assertEquals("0x2000", probeEvent
.getOffset());
688 assertNull(null, probeEvent
.getAddress());
689 assertEquals("create_dev", probeEvent
.getSymbol());
691 // ------------------------------------------------------------------------
692 // Add Context on domain
693 // ------------------------------------------------------------------------
694 // Get Kernel domain component instance
695 domains
= session
.getChildren();
696 assertNotNull(domains
);
697 assertEquals(1, domains
.length
);
699 AddContextDialogStub addContextStub
= new AddContextDialogStub();
700 List
<String
> contexts
= new ArrayList
<>();
701 contexts
.add("prio");
702 contexts
.add("perf:branch-misses");
703 contexts
.add("perf:cache-misses");
704 addContextStub
.setContexts(contexts
);
705 TraceControlDialogFactory
.getInstance().setAddContextDialog(addContextStub
);
707 fFacility
.executeCommand(domains
[0], "addContextOnDomain");
708 // Currently there is nothing to verify because the list commands don't show any context information
709 // However, the execution of the command make sure that the correct service command line is build and executed.
711 // ------------------------------------------------------------------------
712 // Add Context on channel
713 // ------------------------------------------------------------------------
715 // Get Kernel domain component instance
716 domains
= session
.getChildren();
717 assertNotNull(domains
);
718 assertEquals(1, domains
.length
);
720 //Verify that channel was created with correct data
721 channels
= domains
[0].getChildren();
722 channel
= (TraceChannelComponent
) channels
[0];
725 // The setContext() verifies that the contexts set are part of the available contexts
726 // The available contexts are set by the command handler addContextOnDomain above.
727 // So we indirectly test here that the parsing and setting of available contexts were
728 // done correctly above.
729 addContextStub
.setContexts(contexts
);
730 } catch (IllegalArgumentException e
) {
731 fail("Exception caught - unknown context");
734 fFacility
.executeCommand(channel
, "addContextOnChannel");
735 // Currently there is nothing to verify because the list commands don't show any context information
736 // However, the execution of the command make sure that the correct service command line is build and executed.
738 // ------------------------------------------------------------------------
739 // Add Context on event
740 // ------------------------------------------------------------------------
741 // Get Kernel domain component instance
742 domains
= session
.getChildren();
743 assertNotNull(domains
);
744 assertEquals(1, domains
.length
);
746 //Verify that channel was created with correct data
747 channels
= domains
[0].getChildren();
748 channel
= (TraceChannelComponent
) channels
[2];
750 channel0Events
= channel
.getChildren();
752 event
= (TraceEventComponent
) channel0Events
[6];
754 fFacility
.executeCommand(event
, "addContextOnEvent");
755 // Currently there is nothing to verify because the list commands don't show any context information
756 // However, the execution of the command make sure that the correct service command line is build and executed.
758 // ------------------------------------------------------------------------
760 // ------------------------------------------------------------------------
761 // Get Kernel domain component instance
762 domains
= session
.getChildren();
763 assertNotNull(domains
);
764 assertEquals(1, domains
.length
);
766 fFacility
.executeCommand(domains
[0], "calibrate");
767 // There is nothing to verify here.
768 // However, the execution of the command make sure that the correct service command line is build and executed.
770 // ------------------------------------------------------------------------
772 // ------------------------------------------------------------------------
773 fFacility
.executeCommand(node
, "refresh");
774 groups
= node
.getChildren();
775 assertNotNull(groups
);
776 assertEquals(2, groups
.length
);
777 assertEquals(3, groups
[0].getChildren().length
); // provider
778 assertEquals(1, groups
[1].getChildren().length
); // sessions
779 assertEquals(1, groups
[1].getChildren()[0].getChildren().length
); // domains
780 assertEquals(3, groups
[1].getChildren()[0].getChildren()[0].getChildren().length
); // channels
781 assertEquals(2, groups
[1].getChildren()[0].getChildren()[0].getChildren()[0].getChildren().length
); // events (of channel[0])
783 // Initialize session handling scenario
784 fProxy
.setScenario(TraceControlTestFacility
.SCEN_SCENARIO_SESSION_HANDLING
);
786 session
= (TraceSessionComponent
)groups
[1].getChildren()[0];
788 // ------------------------------------------------------------------------
790 // ------------------------------------------------------------------------
791 fFacility
.startSession(session
);
792 assertEquals(TraceSessionState
.ACTIVE
, session
.getSessionState());
794 // ------------------------------------------------------------------------
796 // ------------------------------------------------------------------------
797 fFacility
.stopSession(session
);
798 assertEquals(TraceSessionState
.INACTIVE
, session
.getSessionState());
800 // ------------------------------------------------------------------------
802 // ------------------------------------------------------------------------
804 fFacility
.destroySession(session
);
806 // Verify that no more session components exist
807 assertEquals(0, groups
[1].getChildren().length
);
809 //-------------------------------------------------------------------------
811 //-------------------------------------------------------------------------
812 fFacility
.executeCommand(node
, "disconnect");
813 assertEquals(TargetNodeState
.DISCONNECTED
, node
.getTargetNodeState());
815 //-------------------------------------------------------------------------
817 //-------------------------------------------------------------------------
819 fFacility
.executeCommand(node
, "delete");
820 assertEquals(0,fFacility
.getControlView().getTraceControlRoot().getChildren().length
);