Commit | Line | Data |
---|---|---|
a26d90be | 1 | /********************************************************************** |
60ae41e1 | 2 | * Copyright (c) 2012, 2014 Ericsson |
cfdb727a | 3 | * |
a26d90be BH |
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 | |
cfdb727a AM |
8 | * |
9 | * Contributors: | |
a26d90be | 10 | * Bernd Hufmann - Initial API and implementation |
2ba3d0a1 | 11 | * Alexandre Montplaisir - Port to JUnit4 |
a26d90be | 12 | **********************************************************************/ |
2ba3d0a1 | 13 | |
9bc60be7 | 14 | package org.eclipse.tracecompass.lttng2.control.ui.tests.model.component; |
a26d90be | 15 | |
2ba3d0a1 AM |
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; | |
21 | ||
a26d90be BH |
22 | import java.io.File; |
23 | import java.net.URL; | |
24 | import java.util.ArrayList; | |
25 | import java.util.List; | |
26 | ||
a26d90be BH |
27 | import org.eclipse.core.runtime.FileLocator; |
28 | import org.eclipse.core.runtime.Path; | |
8577ed1e | 29 | import org.eclipse.rse.core.RSECorePlugin; |
a26d90be | 30 | import org.eclipse.rse.core.model.IHost; |
8577ed1e BH |
31 | import org.eclipse.rse.core.model.ISystemProfile; |
32 | import org.eclipse.rse.core.model.ISystemRegistry; | |
9bc60be7 AM |
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; | |
a26d90be BH |
54 | import org.junit.After; |
55 | import org.junit.Before; | |
2ba3d0a1 | 56 | import org.junit.Test; |
9269df72 | 57 | import org.osgi.framework.FrameworkUtil; |
a26d90be BH |
58 | |
59 | /** | |
2ba3d0a1 AM |
60 | * The class <code>TraceControlKernelSessionTests</code> contains Kernel |
61 | * session/channel/event handling test cases. | |
a26d90be | 62 | */ |
2ba3d0a1 | 63 | public class TraceControlKernelSessionTests { |
cfdb727a | 64 | |
a26d90be BH |
65 | // ------------------------------------------------------------------------ |
66 | // Constants | |
67 | // ------------------------------------------------------------------------ | |
2ba3d0a1 | 68 | |
a26d90be BH |
69 | private static final String TEST_STREAM = "CreateTreeTest.cfg"; |
70 | private static final String SCEN_SCENARIO3_TEST = "Scenario3"; | |
71 | ||
72 | // ------------------------------------------------------------------------ | |
73 | // Test data | |
74 | // ------------------------------------------------------------------------ | |
2ba3d0a1 | 75 | |
a26d90be BH |
76 | private TraceControlTestFacility fFacility; |
77 | private TestRemoteSystemProxy fProxy; | |
cfdb727a AM |
78 | private String fTestFile; |
79 | ||
a26d90be BH |
80 | // ------------------------------------------------------------------------ |
81 | // Housekeeping | |
82 | // ------------------------------------------------------------------------ | |
83 | ||
84 | /** | |
85 | * Perform pre-test initialization. | |
86 | * | |
87 | * @throws Exception | |
88 | * if the initialization fails for some reason | |
a26d90be | 89 | */ |
a26d90be BH |
90 | @Before |
91 | public void setUp() throws Exception { | |
92 | fFacility = TraceControlTestFacility.getInstance(); | |
1c3c5807 | 93 | fFacility.init(); |
a26d90be | 94 | fProxy = new TestRemoteSystemProxy(); |
9269df72 | 95 | URL location = FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path(TraceControlTestFacility.DIRECTORY + File.separator + TEST_STREAM), null); |
a26d90be BH |
96 | File testfile = new File(FileLocator.toFileURL(location).toURI()); |
97 | fTestFile = testfile.getAbsolutePath(); | |
98 | } | |
99 | ||
100 | /** | |
101 | * Perform post-test clean-up. | |
a26d90be | 102 | */ |
a26d90be | 103 | @After |
2ba3d0a1 | 104 | public void tearDown() { |
b957fb8c | 105 | fFacility.waitForJobs(); |
1c3c5807 | 106 | fFacility.dispose(); |
a26d90be | 107 | } |
cfdb727a | 108 | |
a26d90be BH |
109 | /** |
110 | * Run the TraceControlComponent. | |
2ba3d0a1 AM |
111 | * |
112 | * @throws Exception | |
113 | * Would fail the test | |
a26d90be | 114 | */ |
2ba3d0a1 | 115 | @Test |
a26d90be | 116 | public void testTraceSessionTree() throws Exception { |
cfdb727a | 117 | |
a26d90be BH |
118 | fProxy.setTestFile(fTestFile); |
119 | fProxy.setScenario(TraceControlTestFacility.SCEN_INIT_TEST); | |
cfdb727a | 120 | |
1c3c5807 | 121 | ITraceControlComponent root = fFacility.getControlView().getTraceControlRoot(); |
a26d90be | 122 | |
8577ed1e BH |
123 | ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry(); |
124 | ISystemProfile profile = registry.createSystemProfile("myProfile", true); | |
125 | IHost host = registry.createLocalHost(profile, "myProfile", "user"); | |
a26d90be BH |
126 | |
127 | TargetNodeComponent node = new TargetNodeComponent("myNode", root, host, fProxy); | |
128 | ||
129 | root.addChild(node); | |
a26d90be BH |
130 | fFacility.waitForJobs(); |
131 | ||
b957fb8c BH |
132 | fFacility.executeCommand(node, "connect"); |
133 | int i = 0; | |
134 | while ((i < 10) && (node.getTargetNodeState() != TargetNodeState.CONNECTED)) { | |
135 | i++; | |
136 | fFacility.delay(TraceControlTestFacility.GUI_REFESH_DELAY); | |
137 | } | |
138 | ||
a26d90be BH |
139 | // Verify that node is connected |
140 | assertEquals(TargetNodeState.CONNECTED, node.getTargetNodeState()); | |
141 | ||
142 | // Get provider groups | |
143 | ITraceControlComponent[] groups = node.getChildren(); | |
144 | assertNotNull(groups); | |
145 | assertEquals(2, groups.length); | |
146 | ||
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()); | |
cfdb727a | 151 | |
a26d90be BH |
152 | // Initialize session handling scenario |
153 | fProxy.setScenario(TraceControlTestFacility.SCEN_SCENARIO_SESSION_HANDLING); | |
cfdb727a | 154 | |
a26d90be BH |
155 | // ------------------------------------------------------------------------ |
156 | // Create session | |
157 | // ------------------------------------------------------------------------ | |
158 | TraceSessionComponent session = fFacility.createSession(groups[1]); | |
cfdb727a | 159 | |
a26d90be BH |
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()); | |
165 | ||
166 | // Initialize scenario | |
167 | fProxy.setScenario(SCEN_SCENARIO3_TEST); | |
cfdb727a | 168 | |
a26d90be | 169 | // ------------------------------------------------------------------------ |
d62bfa55 | 170 | // Enable channel on session |
a26d90be | 171 | // ------------------------------------------------------------------------ |
d62bfa55 | 172 | EnableChannelDialogStub channelStub = new EnableChannelDialogStub(); |
a26d90be | 173 | channelStub.setIsKernel(true); |
d62bfa55 | 174 | TraceControlDialogFactory.getInstance().setEnableChannelDialog(channelStub); |
a26d90be | 175 | |
d62bfa55 | 176 | fFacility.executeCommand(session, "enableChannelOnSession"); |
cfdb727a | 177 | |
a26d90be BH |
178 | // Verify that Kernel domain was created |
179 | ITraceControlComponent[] domains = session.getChildren(); | |
180 | assertNotNull(domains); | |
181 | assertEquals(1, domains.length); | |
182 | ||
183 | assertEquals("Kernel", domains[0].getName()); | |
cfdb727a | 184 | |
a26d90be BH |
185 | // Verify that channel was created with correct data |
186 | ITraceControlComponent[] channels = domains[0].getChildren(); | |
187 | assertNotNull(channels); | |
188 | assertEquals(1, channels.length); | |
189 | ||
190 | assertTrue(channels[0] instanceof TraceChannelComponent); | |
cfdb727a | 191 | TraceChannelComponent channel = (TraceChannelComponent) channels[0]; |
a26d90be BH |
192 | assertEquals("mychannel", channel.getName()); |
193 | assertEquals(4, channel.getNumberOfSubBuffers()); | |
0ad9fc89 JRJ |
194 | assertEquals("splice()", channel.getOutputType().getInName()); |
195 | assertEquals(TraceChannelOutputType.SPLICE, channel.getOutputType()); | |
a26d90be BH |
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()); | |
201 | ||
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); | |
cfdb727a | 213 | |
d62bfa55 | 214 | fFacility.executeCommand(domains[0], "enableChannelOnDomain"); |
cfdb727a | 215 | |
a26d90be BH |
216 | // Get Kernel domain component instance |
217 | domains = session.getChildren(); | |
218 | assertNotNull(domains); | |
219 | assertEquals(1, domains.length); | |
220 | ||
221 | // Verify that channel was created with correct data | |
222 | channels = domains[0].getChildren(); | |
223 | assertNotNull(channels); | |
224 | assertEquals(2, channels.length); | |
225 | ||
226 | assertTrue(channels[1] instanceof TraceChannelComponent); | |
cfdb727a | 227 | channel = (TraceChannelComponent) channels[1]; |
a26d90be BH |
228 | assertEquals("mychannel2", channel.getName()); |
229 | assertEquals(2, channel.getNumberOfSubBuffers()); | |
0ad9fc89 JRJ |
230 | assertEquals("splice()", channel.getOutputType().getInName()); |
231 | assertEquals(TraceChannelOutputType.SPLICE, channel.getOutputType()); | |
a26d90be BH |
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()); | |
237 | ||
238 | EnableEventsDialogStub eventsDialogStub = new EnableEventsDialogStub(); | |
239 | eventsDialogStub.setIsTracePoints(true); | |
e0838ca1 | 240 | List<String> events = new ArrayList<>(); |
a26d90be BH |
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); | |
cfdb727a | 246 | |
a26d90be | 247 | // ------------------------------------------------------------------------ |
cfdb727a | 248 | // disable channels |
a26d90be BH |
249 | // ------------------------------------------------------------------------ |
250 | // Get Kernel domain component instance | |
251 | domains = session.getChildren(); | |
252 | assertNotNull(domains); | |
253 | assertEquals(1, domains.length); | |
254 | ||
255 | // Verify that channel was created with correct data | |
256 | channels = domains[0].getChildren(); | |
257 | assertNotNull(channels); | |
258 | assertEquals(2, channels.length); | |
259 | ||
260 | fFacility.executeCommand(channels, "disableChannel"); | |
cfdb727a | 261 | |
a26d90be BH |
262 | assertEquals(TraceEnablement.DISABLED, ((TraceChannelComponent)channels[0]).getState()); |
263 | assertEquals(TraceEnablement.DISABLED, ((TraceChannelComponent)channels[1]).getState()); | |
264 | ||
265 | // ------------------------------------------------------------------------ | |
cfdb727a | 266 | // enable channels |
a26d90be BH |
267 | // ------------------------------------------------------------------------ |
268 | // Get Kernel domain component instance | |
269 | domains = session.getChildren(); | |
270 | assertNotNull(domains); | |
271 | assertEquals(1, domains.length); | |
272 | ||
273 | // Verify that channel was created with correct data | |
274 | channels = domains[0].getChildren(); | |
275 | assertNotNull(channels); | |
276 | assertEquals(2, channels.length); | |
cfdb727a | 277 | |
a26d90be | 278 | fFacility.executeCommand(channels, "enableChannel"); |
cfdb727a | 279 | |
a26d90be BH |
280 | assertEquals(TraceEnablement.ENABLED, ((TraceChannelComponent)channels[0]).getState()); |
281 | assertEquals(TraceEnablement.ENABLED, ((TraceChannelComponent)channels[1]).getState()); | |
282 | ||
283 | // ------------------------------------------------------------------------ | |
cfdb727a | 284 | // enable event (tracepoints) on session |
a26d90be BH |
285 | // ------------------------------------------------------------------------ |
286 | fFacility.executeCommand(session, "enableEventOnSession"); | |
287 | ||
288 | // Get Kernel domain component instance | |
289 | domains = session.getChildren(); | |
290 | assertNotNull(domains); | |
291 | assertEquals(1, domains.length); | |
292 | ||
293 | // Verify that channel was created with correct data | |
294 | channels = domains[0].getChildren(); | |
295 | assertNotNull(channels); | |
296 | assertEquals(3, channels.length); | |
297 | ||
298 | assertTrue(channels[2] instanceof TraceChannelComponent); | |
cfdb727a | 299 | channel = (TraceChannelComponent) channels[2]; |
a26d90be BH |
300 | assertEquals("channel0", channel.getName()); |
301 | // No need to check parameters of default channel because that has been done in other tests | |
302 | ||
303 | ITraceControlComponent[] channel0Events = channel.getChildren(); | |
304 | assertEquals(2, channel0Events.length); | |
cfdb727a | 305 | |
a26d90be BH |
306 | assertTrue(channel0Events[0] instanceof TraceEventComponent); |
307 | assertTrue(channel0Events[1] instanceof TraceEventComponent); | |
308 | ||
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()); | |
314 | ||
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()); | |
320 | ||
321 | // ------------------------------------------------------------------------ | |
cfdb727a | 322 | // enable event (tracepoints) on domain |
a26d90be BH |
323 | // ------------------------------------------------------------------------ |
324 | events.clear(); | |
325 | events.add("sched_wakeup_new"); | |
326 | eventsDialogStub.setNames(events); | |
327 | ||
328 | fFacility.executeCommand(domains[0], "enableEventOnDomain"); | |
329 | ||
330 | // Get Kernel domain component instance | |
331 | domains = session.getChildren(); | |
332 | assertNotNull(domains); | |
333 | assertEquals(1, domains.length); | |
334 | ||
335 | // Verify that channel was created with correct data | |
336 | channels = domains[0].getChildren(); | |
cfdb727a | 337 | channel = (TraceChannelComponent) channels[2]; |
a26d90be BH |
338 | // No need to check parameters of default channel because that has been done in other tests |
339 | ||
340 | channel = (TraceChannelComponent) channels[2]; | |
cfdb727a | 341 | |
a26d90be BH |
342 | channel0Events = channel.getChildren(); |
343 | assertEquals(3, channel0Events.length); | |
cfdb727a | 344 | |
a26d90be BH |
345 | assertTrue(channel0Events[2] instanceof TraceEventComponent); |
346 | ||
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()); | |
352 | ||
353 | // ------------------------------------------------------------------------ | |
cfdb727a | 354 | // enable event (tracepoints) on channel |
a26d90be BH |
355 | // ------------------------------------------------------------------------ |
356 | events.clear(); | |
357 | eventsDialogStub.setNames(events); | |
358 | eventsDialogStub.setIsAllTracePoints(true); | |
359 | ||
360 | fFacility.executeCommand(channels[1], "enableEventOnChannel"); | |
cfdb727a | 361 | |
a26d90be BH |
362 | // Get Kernel domain component instance |
363 | domains = session.getChildren(); | |
364 | assertNotNull(domains); | |
365 | assertEquals(1, domains.length); | |
366 | ||
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]; | |
cfdb727a | 371 | |
a26d90be BH |
372 | channel0Events = channel.getChildren(); |
373 | assertEquals(3, channel0Events.length); | |
cfdb727a | 374 | |
a26d90be BH |
375 | assertTrue(channel0Events[0] instanceof TraceEventComponent); |
376 | assertTrue(channel0Events[1] instanceof TraceEventComponent); | |
377 | assertTrue(channel0Events[2] instanceof TraceEventComponent); | |
378 | ||
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()); | |
384 | ||
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()); | |
cfdb727a | 390 | |
a26d90be BH |
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()); | |
396 | ||
397 | // ------------------------------------------------------------------------ | |
cfdb727a | 398 | // enable event (syscall) on channel |
a26d90be BH |
399 | // ------------------------------------------------------------------------ |
400 | events.clear(); | |
cfdb727a | 401 | eventsDialogStub.setIsTracePoints(false); |
a26d90be BH |
402 | eventsDialogStub.setIsAllTracePoints(false); |
403 | eventsDialogStub.setIsSysCalls(true); | |
404 | ||
405 | fFacility.executeCommand(channels[0], "enableEventOnChannel"); | |
cfdb727a | 406 | |
a26d90be BH |
407 | // Get Kernel domain component instance |
408 | domains = session.getChildren(); | |
409 | assertNotNull(domains); | |
410 | assertEquals(1, domains.length); | |
411 | ||
412 | // Verify that channel was created with correct data | |
413 | channels = domains[0].getChildren(); | |
cfdb727a | 414 | channel = (TraceChannelComponent) channels[0]; |
a26d90be BH |
415 | // No need to check parameters of default channel because that has been done in other tests |
416 | ||
417 | channel = (TraceChannelComponent) channels[0]; | |
cfdb727a | 418 | |
a26d90be BH |
419 | channel0Events = channel.getChildren(); |
420 | assertEquals(1, channel0Events.length); | |
cfdb727a | 421 | |
a26d90be | 422 | assertTrue(channel0Events[0] instanceof TraceEventComponent); |
cfdb727a | 423 | |
a26d90be BH |
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()); | |
429 | ||
430 | // ------------------------------------------------------------------------ | |
cfdb727a | 431 | // enable event (syscall) on domain |
a26d90be BH |
432 | // ------------------------------------------------------------------------ |
433 | fFacility.executeCommand(domains[0], "enableEventOnDomain"); | |
434 | ||
435 | // Get Kernel domain component instance | |
436 | domains = session.getChildren(); | |
437 | assertNotNull(domains); | |
438 | assertEquals(1, domains.length); | |
439 | ||
440 | // Verify that channel was created with correct data | |
441 | channels = domains[0].getChildren(); | |
cfdb727a | 442 | channel = (TraceChannelComponent) channels[0]; |
a26d90be BH |
443 | // No need to check parameters of default channel because that has been done in other tests |
444 | ||
445 | channel = (TraceChannelComponent) channels[2]; | |
cfdb727a | 446 | |
a26d90be BH |
447 | channel0Events = channel.getChildren(); |
448 | assertEquals(4, channel0Events.length); | |
cfdb727a | 449 | |
a26d90be | 450 | assertTrue(channel0Events[0] instanceof TraceEventComponent); |
cfdb727a | 451 | |
a26d90be BH |
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()); | |
457 | ||
458 | // ------------------------------------------------------------------------ | |
cfdb727a | 459 | // enable event (syscall) on session |
a26d90be BH |
460 | // ------------------------------------------------------------------------ |
461 | fFacility.executeCommand(session, "enableEventOnSession"); | |
462 | ||
463 | // Get Kernel domain component instance | |
464 | domains = session.getChildren(); | |
465 | assertNotNull(domains); | |
466 | assertEquals(1, domains.length); | |
467 | ||
468 | // Verify that channel was created with correct data | |
469 | channels = domains[0].getChildren(); | |
cfdb727a | 470 | channel = (TraceChannelComponent) channels[0]; |
a26d90be BH |
471 | // No need to check parameters of default channel because that has been done in other tests |
472 | ||
473 | channel = (TraceChannelComponent) channels[2]; | |
cfdb727a | 474 | |
a26d90be BH |
475 | channel0Events = channel.getChildren(); |
476 | assertEquals(4, channel0Events.length); | |
cfdb727a | 477 | |
a26d90be | 478 | assertTrue(channel0Events[0] instanceof TraceEventComponent); |
cfdb727a | 479 | |
a26d90be BH |
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()); | |
485 | ||
cfdb727a | 486 | |
a26d90be | 487 | // ------------------------------------------------------------------------ |
cfdb727a | 488 | // enable event (dynamic probe) on domain |
a26d90be BH |
489 | // ------------------------------------------------------------------------ |
490 | events.clear(); | |
491 | eventsDialogStub.setIsSysCalls(false); | |
492 | eventsDialogStub.setIsDynamicProbe(true); | |
493 | eventsDialogStub.setDynamicProbe("0xc0101280"); | |
494 | eventsDialogStub.setProbeEventName("myevent1"); | |
cfdb727a | 495 | |
a26d90be | 496 | fFacility.executeCommand(domains[0], "enableEventOnDomain"); |
cfdb727a | 497 | |
a26d90be BH |
498 | // Get Kernel domain component instance |
499 | domains = session.getChildren(); | |
500 | assertNotNull(domains); | |
501 | assertEquals(1, domains.length); | |
502 | ||
503 | // Verify that channel was created with correct data | |
504 | channels = domains[0].getChildren(); | |
cfdb727a | 505 | channel = (TraceChannelComponent) channels[2]; |
a26d90be BH |
506 | // No need to check parameters of default channel because that has been done in other tests |
507 | ||
508 | channel0Events = channel.getChildren(); | |
509 | assertEquals(5, channel0Events.length); | |
cfdb727a | 510 | |
a26d90be | 511 | assertTrue(channel0Events[0] instanceof TraceProbeEventComponent); |
cfdb727a | 512 | |
a26d90be BH |
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()); | |
521 | ||
522 | // ------------------------------------------------------------------------ | |
cfdb727a | 523 | // enable event (dynamic probe) on channel |
a26d90be BH |
524 | // ------------------------------------------------------------------------ |
525 | eventsDialogStub.setIsDynamicProbe(true); | |
526 | eventsDialogStub.setDynamicProbe("init_post"); | |
527 | eventsDialogStub.setProbeEventName("myevent2"); | |
528 | ||
529 | fFacility.executeCommand(channels[2], "enableEventOnChannel"); | |
cfdb727a | 530 | |
a26d90be BH |
531 | // Get Kernel domain component instance |
532 | domains = session.getChildren(); | |
533 | assertNotNull(domains); | |
534 | assertEquals(1, domains.length); | |
535 | ||
536 | // Verify that channel was created with correct data | |
537 | channels = domains[0].getChildren(); | |
cfdb727a | 538 | channel = (TraceChannelComponent) channels[2]; |
a26d90be BH |
539 | // No need to check parameters of default channel because that has been done in other tests |
540 | ||
541 | channel0Events = channel.getChildren(); | |
542 | assertEquals(6, channel0Events.length); | |
cfdb727a | 543 | |
a26d90be | 544 | assertTrue(channel0Events[0] instanceof TraceProbeEventComponent); |
cfdb727a | 545 | |
a26d90be BH |
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()); | |
554 | ||
555 | // ------------------------------------------------------------------------ | |
cfdb727a | 556 | // enable event (dynamic probe) on session |
a26d90be BH |
557 | // ------------------------------------------------------------------------ |
558 | eventsDialogStub.setIsDynamicProbe(true); | |
559 | eventsDialogStub.setDynamicProbe("init_post:0x1000"); | |
560 | eventsDialogStub.setProbeEventName("myevent3"); | |
561 | ||
562 | fFacility.executeCommand(session, "enableEventOnSession"); | |
cfdb727a | 563 | |
a26d90be BH |
564 | // Get Kernel domain component instance |
565 | domains = session.getChildren(); | |
566 | assertNotNull(domains); | |
567 | assertEquals(1, domains.length); | |
568 | ||
569 | // Verify that channel was created with correct data | |
570 | channels = domains[0].getChildren(); | |
cfdb727a | 571 | channel = (TraceChannelComponent) channels[2]; |
a26d90be BH |
572 | // No need to check parameters of default channel because that has been done in other tests |
573 | ||
574 | channel0Events = channel.getChildren(); | |
575 | assertEquals(7, channel0Events.length); | |
576 | ||
577 | assertTrue(channel0Events[0] instanceof TraceProbeEventComponent); | |
578 | ||
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()); | |
cfdb727a | 587 | |
a26d90be BH |
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"); | |
597 | ||
598 | fFacility.executeCommand(session, "enableEventOnSession"); | |
cfdb727a | 599 | |
a26d90be BH |
600 | // Get Kernel domain component instance |
601 | domains = session.getChildren(); | |
602 | assertNotNull(domains); | |
603 | assertEquals(1, domains.length); | |
604 | ||
605 | // Verify that channel was created with correct data | |
606 | channels = domains[0].getChildren(); | |
cfdb727a | 607 | channel = (TraceChannelComponent) channels[2]; |
a26d90be BH |
608 | // No need to check parameters of default channel because that has been done in other tests |
609 | ||
610 | channel0Events = channel.getChildren(); | |
611 | assertEquals(8, channel0Events.length); | |
612 | ||
613 | assertTrue(channel0Events[0] instanceof TraceProbeEventComponent); | |
614 | ||
615 | probeEvent = (TraceProbeEventComponent) channel0Events[0]; | |
616 | assertEquals("myevent4", probeEvent.getName()); | |
617 | assertEquals(TraceLogLevel.LEVEL_UNKNOWN, probeEvent.getLogLevel()); | |
1f07c96c BH |
618 | // Changed for Bug fix 419454 to function event which was introduced by LTTng 2.2 |
619 | assertEquals(TraceEventType.FUNCTION, probeEvent.getEventType()); | |
a26d90be BH |
620 | assertEquals(TraceEnablement.ENABLED, probeEvent.getState()); |
621 | assertEquals("0x0", probeEvent.getOffset()); | |
622 | assertNull(null, probeEvent.getAddress()); | |
623 | assertEquals("create_dev", probeEvent.getSymbol()); | |
cfdb727a | 624 | |
a26d90be BH |
625 | // ------------------------------------------------------------------------ |
626 | // enable event (dynamic function probe) on domain | |
627 | // ------------------------------------------------------------------------ | |
628 | eventsDialogStub.setIsFunctionProbe(true); | |
629 | eventsDialogStub.setFunctionEventName("myevent5"); | |
630 | eventsDialogStub.setFunctionProbe("create_dev:0x2000"); | |
631 | ||
632 | fFacility.executeCommand(domains[0], "enableEventOnDomain"); | |
cfdb727a | 633 | |
a26d90be BH |
634 | // Get Kernel domain component instance |
635 | domains = session.getChildren(); | |
636 | assertNotNull(domains); | |
637 | assertEquals(1, domains.length); | |
638 | ||
639 | // Verify that channel was created with correct data | |
640 | channels = domains[0].getChildren(); | |
cfdb727a | 641 | channel = (TraceChannelComponent) channels[2]; |
a26d90be BH |
642 | // No need to check parameters of default channel because that has been done in other tests |
643 | ||
644 | channel0Events = channel.getChildren(); | |
645 | assertEquals(9, channel0Events.length); | |
646 | ||
647 | assertTrue(channel0Events[0] instanceof TraceProbeEventComponent); | |
648 | ||
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()); | |
657 | ||
658 | // ------------------------------------------------------------------------ | |
659 | // enable event (dynamic function probe) on channel | |
660 | // ------------------------------------------------------------------------ | |
661 | eventsDialogStub.setIsFunctionProbe(true); | |
662 | eventsDialogStub.setFunctionEventName("myevent"); | |
663 | eventsDialogStub.setFunctionProbe("create_dev:0x2000"); | |
664 | ||
665 | fFacility.executeCommand(channels[0], "enableEventOnChannel"); | |
cfdb727a | 666 | |
a26d90be BH |
667 | // Get Kernel domain component instance |
668 | domains = session.getChildren(); | |
669 | assertNotNull(domains); | |
670 | assertEquals(1, domains.length); | |
671 | ||
672 | // Verify that channel was created with correct data | |
673 | channels = domains[0].getChildren(); | |
cfdb727a | 674 | channel = (TraceChannelComponent) channels[0]; |
a26d90be BH |
675 | // No need to check parameters of default channel because that has been done in other tests |
676 | ||
677 | channel0Events = channel.getChildren(); | |
678 | assertEquals(2, channel0Events.length); | |
679 | ||
680 | assertTrue(channel0Events[0] instanceof TraceProbeEventComponent); | |
681 | ||
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()); | |
4ea599a5 BH |
690 | |
691 | // ------------------------------------------------------------------------ | |
cfdb727a | 692 | // Add Context on domain |
4ea599a5 BH |
693 | // ------------------------------------------------------------------------ |
694 | // Get Kernel domain component instance | |
695 | domains = session.getChildren(); | |
696 | assertNotNull(domains); | |
697 | assertEquals(1, domains.length); | |
698 | ||
699 | AddContextDialogStub addContextStub = new AddContextDialogStub(); | |
e0838ca1 | 700 | List<String> contexts = new ArrayList<>(); |
4ea599a5 BH |
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); | |
cfdb727a | 706 | |
4ea599a5 BH |
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. | |
710 | ||
711 | // ------------------------------------------------------------------------ | |
cfdb727a | 712 | // Add Context on channel |
4ea599a5 BH |
713 | // ------------------------------------------------------------------------ |
714 | ||
715 | // Get Kernel domain component instance | |
716 | domains = session.getChildren(); | |
717 | assertNotNull(domains); | |
718 | assertEquals(1, domains.length); | |
719 | ||
720 | //Verify that channel was created with correct data | |
721 | channels = domains[0].getChildren(); | |
cfdb727a AM |
722 | channel = (TraceChannelComponent) channels[0]; |
723 | ||
4ea599a5 BH |
724 | try { |
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"); | |
732 | } | |
733 | ||
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. | |
cfdb727a | 737 | |
4ea599a5 | 738 | // ------------------------------------------------------------------------ |
cfdb727a | 739 | // Add Context on event |
4ea599a5 BH |
740 | // ------------------------------------------------------------------------ |
741 | // Get Kernel domain component instance | |
742 | domains = session.getChildren(); | |
743 | assertNotNull(domains); | |
744 | assertEquals(1, domains.length); | |
745 | ||
746 | //Verify that channel was created with correct data | |
747 | channels = domains[0].getChildren(); | |
cfdb727a AM |
748 | channel = (TraceChannelComponent) channels[2]; |
749 | ||
4ea599a5 BH |
750 | channel0Events = channel.getChildren(); |
751 | ||
752 | event = (TraceEventComponent) channel0Events[6]; | |
cfdb727a | 753 | |
4ea599a5 BH |
754 | fFacility.executeCommand(event, "addContextOnEvent"); |
755 | // Currently there is nothing to verify because the list commands don't show any context information | |
cfdb727a | 756 | // However, the execution of the command make sure that the correct service command line is build and executed. |
4ea599a5 BH |
757 | |
758 | // ------------------------------------------------------------------------ | |
cfdb727a | 759 | // Calibrate |
4ea599a5 BH |
760 | // ------------------------------------------------------------------------ |
761 | // Get Kernel domain component instance | |
762 | domains = session.getChildren(); | |
763 | assertNotNull(domains); | |
764 | assertEquals(1, domains.length); | |
cfdb727a | 765 | |
4ea599a5 | 766 | fFacility.executeCommand(domains[0], "calibrate"); |
cfdb727a | 767 | // There is nothing to verify here. |
4ea599a5 | 768 | // However, the execution of the command make sure that the correct service command line is build and executed. |
cfdb727a | 769 | |
a26d90be | 770 | // ------------------------------------------------------------------------ |
cfdb727a | 771 | // refresh |
a26d90be BH |
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]) | |
cfdb727a | 782 | |
a26d90be BH |
783 | // Initialize session handling scenario |
784 | fProxy.setScenario(TraceControlTestFacility.SCEN_SCENARIO_SESSION_HANDLING); | |
cfdb727a | 785 | |
a26d90be | 786 | session = (TraceSessionComponent)groups[1].getChildren()[0]; |
4ea599a5 | 787 | |
a26d90be | 788 | // ------------------------------------------------------------------------ |
cfdb727a | 789 | // start session |
a26d90be BH |
790 | // ------------------------------------------------------------------------ |
791 | fFacility.startSession(session); | |
792 | assertEquals(TraceSessionState.ACTIVE, session.getSessionState()); | |
cfdb727a | 793 | |
a26d90be | 794 | // ------------------------------------------------------------------------ |
cfdb727a | 795 | // stop session |
a26d90be BH |
796 | // ------------------------------------------------------------------------ |
797 | fFacility.stopSession(session); | |
798 | assertEquals(TraceSessionState.INACTIVE, session.getSessionState()); | |
cfdb727a | 799 | |
a26d90be | 800 | // ------------------------------------------------------------------------ |
cfdb727a | 801 | // Destroy session |
a26d90be BH |
802 | // ------------------------------------------------------------------------ |
803 | ||
804 | fFacility.destroySession(session); | |
cfdb727a | 805 | |
a26d90be BH |
806 | // Verify that no more session components exist |
807 | assertEquals(0, groups[1].getChildren().length); | |
808 | ||
809 | //------------------------------------------------------------------------- | |
810 | // Disconnect node | |
811 | //------------------------------------------------------------------------- | |
812 | fFacility.executeCommand(node, "disconnect"); | |
813 | assertEquals(TargetNodeState.DISCONNECTED, node.getTargetNodeState()); | |
cfdb727a | 814 | |
a26d90be BH |
815 | //------------------------------------------------------------------------- |
816 | // Delete node | |
817 | //------------------------------------------------------------------------- | |
cfdb727a | 818 | |
a26d90be BH |
819 | fFacility.executeCommand(node, "delete"); |
820 | assertEquals(0,fFacility.getControlView().getTraceControlRoot().getChildren().length); | |
821 | } | |
cfdb727a | 822 | |
a26d90be | 823 | } |