Commit | Line | Data |
---|---|---|
a26d90be | 1 | /********************************************************************** |
2ba3d0a1 | 2 | * Copyright (c) 2012, 2013 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 | |
a26d90be BH |
14 | package org.eclipse.linuxtools.lttng2.ui.tests.control.model.component; |
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; | |
9315aeee BH |
29 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.TargetNodeState; |
30 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEnablement; | |
31 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEventType; | |
32 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel; | |
33 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceSessionState; | |
34 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.ChannelInfo; | |
4ea599a5 | 35 | import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.AddContextDialogStub; |
a26d90be BH |
36 | import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.CreateSessionDialogStub; |
37 | import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.DestroyConfirmDialogStub; | |
8577ed1e | 38 | import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.EnableChannelDialogStub; |
a26d90be BH |
39 | import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.EnableEventsDialogStub; |
40 | import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.GetEventInfoDialogStub; | |
41 | import org.eclipse.linuxtools.internal.lttng2.stubs.service.TestRemoteSystemProxy; | |
42 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.TraceControlDialogFactory; | |
43 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent; | |
a26d90be BH |
44 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TargetNodeComponent; |
45 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceChannelComponent; | |
46 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceEventComponent; | |
47 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceProbeEventComponent; | |
48 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent; | |
8577ed1e | 49 | import org.eclipse.rse.core.RSECorePlugin; |
a26d90be | 50 | import org.eclipse.rse.core.model.IHost; |
8577ed1e BH |
51 | import org.eclipse.rse.core.model.ISystemProfile; |
52 | import org.eclipse.rse.core.model.ISystemRegistry; | |
a26d90be BH |
53 | import org.junit.After; |
54 | import org.junit.Before; | |
2ba3d0a1 | 55 | import org.junit.Test; |
9269df72 | 56 | import org.osgi.framework.FrameworkUtil; |
a26d90be BH |
57 | |
58 | /** | |
2ba3d0a1 AM |
59 | * The class <code>TraceControlKernelSessionTests</code> contains Kernel |
60 | * session/channel/event handling test cases. | |
a26d90be | 61 | */ |
2ba3d0a1 AM |
62 | @SuppressWarnings("nls") |
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(); | |
93 | fProxy = new TestRemoteSystemProxy(); | |
9269df72 | 94 | URL location = FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path(TraceControlTestFacility.DIRECTORY + File.separator + TEST_STREAM), null); |
a26d90be BH |
95 | File testfile = new File(FileLocator.toFileURL(location).toURI()); |
96 | fTestFile = testfile.getAbsolutePath(); | |
97 | } | |
98 | ||
99 | /** | |
100 | * Perform post-test clean-up. | |
a26d90be | 101 | */ |
a26d90be | 102 | @After |
2ba3d0a1 | 103 | public void tearDown() { |
b957fb8c | 104 | fFacility.waitForJobs(); |
a26d90be | 105 | } |
cfdb727a | 106 | |
a26d90be BH |
107 | /** |
108 | * Run the TraceControlComponent. | |
2ba3d0a1 AM |
109 | * |
110 | * @throws Exception | |
111 | * Would fail the test | |
a26d90be | 112 | */ |
2ba3d0a1 | 113 | @Test |
a26d90be | 114 | public void testTraceSessionTree() throws Exception { |
cfdb727a | 115 | |
a26d90be BH |
116 | fProxy.setTestFile(fTestFile); |
117 | fProxy.setScenario(TraceControlTestFacility.SCEN_INIT_TEST); | |
cfdb727a | 118 | |
a26d90be BH |
119 | ITraceControlComponent root = TraceControlTestFacility.getInstance().getControlView().getTraceControlRoot(); |
120 | ||
8577ed1e BH |
121 | ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry(); |
122 | ISystemProfile profile = registry.createSystemProfile("myProfile", true); | |
123 | IHost host = registry.createLocalHost(profile, "myProfile", "user"); | |
a26d90be BH |
124 | |
125 | TargetNodeComponent node = new TargetNodeComponent("myNode", root, host, fProxy); | |
126 | ||
127 | root.addChild(node); | |
a26d90be BH |
128 | fFacility.waitForJobs(); |
129 | ||
b957fb8c BH |
130 | fFacility.executeCommand(node, "connect"); |
131 | int i = 0; | |
132 | while ((i < 10) && (node.getTargetNodeState() != TargetNodeState.CONNECTED)) { | |
133 | i++; | |
134 | fFacility.delay(TraceControlTestFacility.GUI_REFESH_DELAY); | |
135 | } | |
136 | ||
a26d90be BH |
137 | // Verify that node is connected |
138 | assertEquals(TargetNodeState.CONNECTED, node.getTargetNodeState()); | |
139 | ||
140 | // Get provider groups | |
141 | ITraceControlComponent[] groups = node.getChildren(); | |
142 | assertNotNull(groups); | |
143 | assertEquals(2, groups.length); | |
144 | ||
145 | // Initialize dialog implementations for command execution | |
146 | TraceControlDialogFactory.getInstance().setCreateSessionDialog(new CreateSessionDialogStub()); | |
147 | TraceControlDialogFactory.getInstance().setGetEventInfoDialog(new GetEventInfoDialogStub()); | |
148 | TraceControlDialogFactory.getInstance().setConfirmDialog(new DestroyConfirmDialogStub()); | |
cfdb727a | 149 | |
a26d90be BH |
150 | // Initialize session handling scenario |
151 | fProxy.setScenario(TraceControlTestFacility.SCEN_SCENARIO_SESSION_HANDLING); | |
cfdb727a | 152 | |
a26d90be BH |
153 | // ------------------------------------------------------------------------ |
154 | // Create session | |
155 | // ------------------------------------------------------------------------ | |
156 | TraceSessionComponent session = fFacility.createSession(groups[1]); | |
cfdb727a | 157 | |
a26d90be BH |
158 | // Verify that session was created |
159 | assertNotNull(session); | |
160 | assertEquals("mysession", session.getName()); | |
161 | assertEquals("/home/user/lttng-traces/mysession-20120314-132824", session.getSessionPath()); | |
162 | assertEquals(TraceSessionState.INACTIVE, session.getSessionState()); | |
163 | ||
164 | // Initialize scenario | |
165 | fProxy.setScenario(SCEN_SCENARIO3_TEST); | |
cfdb727a | 166 | |
a26d90be | 167 | // ------------------------------------------------------------------------ |
d62bfa55 | 168 | // Enable channel on session |
a26d90be | 169 | // ------------------------------------------------------------------------ |
d62bfa55 | 170 | EnableChannelDialogStub channelStub = new EnableChannelDialogStub(); |
a26d90be | 171 | channelStub.setIsKernel(true); |
d62bfa55 | 172 | TraceControlDialogFactory.getInstance().setEnableChannelDialog(channelStub); |
a26d90be | 173 | |
d62bfa55 | 174 | fFacility.executeCommand(session, "enableChannelOnSession"); |
cfdb727a | 175 | |
a26d90be BH |
176 | // Verify that Kernel domain was created |
177 | ITraceControlComponent[] domains = session.getChildren(); | |
178 | assertNotNull(domains); | |
179 | assertEquals(1, domains.length); | |
180 | ||
181 | assertEquals("Kernel", domains[0].getName()); | |
cfdb727a | 182 | |
a26d90be BH |
183 | // Verify that channel was created with correct data |
184 | ITraceControlComponent[] channels = domains[0].getChildren(); | |
185 | assertNotNull(channels); | |
186 | assertEquals(1, channels.length); | |
187 | ||
188 | assertTrue(channels[0] instanceof TraceChannelComponent); | |
cfdb727a | 189 | TraceChannelComponent channel = (TraceChannelComponent) channels[0]; |
a26d90be BH |
190 | assertEquals("mychannel", channel.getName()); |
191 | assertEquals(4, channel.getNumberOfSubBuffers()); | |
192 | assertEquals("splice()", channel.getOutputType()); | |
193 | assertEquals(true, channel.isOverwriteMode()); | |
194 | assertEquals(200, channel.getReadTimer()); | |
195 | assertEquals(TraceEnablement.ENABLED, channel.getState()); | |
196 | assertEquals(16384, channel.getSubBufferSize()); | |
197 | assertEquals(100, channel.getSwitchTimer()); | |
198 | ||
199 | // ------------------------------------------------------------------------ | |
200 | // Create channel on domain | |
201 | // ------------------------------------------------------------------------ | |
202 | ChannelInfo info = (ChannelInfo)channelStub.getChannelInfo(); | |
203 | info.setName("mychannel2"); | |
204 | info.setOverwriteMode(false); | |
205 | info.setSubBufferSize(32768); | |
206 | info.setNumberOfSubBuffers(2); | |
207 | info.setSwitchTimer(100); | |
208 | info.setReadTimer(200); | |
209 | channelStub.setChannelInfo(info); | |
cfdb727a | 210 | |
d62bfa55 | 211 | fFacility.executeCommand(domains[0], "enableChannelOnDomain"); |
cfdb727a | 212 | |
a26d90be BH |
213 | // Get Kernel domain component instance |
214 | domains = session.getChildren(); | |
215 | assertNotNull(domains); | |
216 | assertEquals(1, domains.length); | |
217 | ||
218 | // Verify that channel was created with correct data | |
219 | channels = domains[0].getChildren(); | |
220 | assertNotNull(channels); | |
221 | assertEquals(2, channels.length); | |
222 | ||
223 | assertTrue(channels[1] instanceof TraceChannelComponent); | |
cfdb727a | 224 | channel = (TraceChannelComponent) channels[1]; |
a26d90be BH |
225 | assertEquals("mychannel2", channel.getName()); |
226 | assertEquals(2, channel.getNumberOfSubBuffers()); | |
227 | assertEquals("splice()", channel.getOutputType()); | |
228 | assertEquals(false, channel.isOverwriteMode()); | |
229 | assertEquals(200, channel.getReadTimer()); | |
230 | assertEquals(TraceEnablement.ENABLED, channel.getState()); | |
231 | assertEquals(32768, channel.getSubBufferSize()); | |
232 | assertEquals(100, channel.getSwitchTimer()); | |
233 | ||
234 | EnableEventsDialogStub eventsDialogStub = new EnableEventsDialogStub(); | |
235 | eventsDialogStub.setIsTracePoints(true); | |
236 | List<String> events = new ArrayList<String>(); | |
237 | events.add("sched_kthread_stop"); | |
238 | events.add("sched_kthread_stop_ret"); | |
239 | eventsDialogStub.setNames(events); | |
240 | eventsDialogStub.setIsKernel(true); | |
241 | TraceControlDialogFactory.getInstance().setEnableEventsDialog(eventsDialogStub); | |
cfdb727a | 242 | |
a26d90be | 243 | // ------------------------------------------------------------------------ |
cfdb727a | 244 | // disable channels |
a26d90be BH |
245 | // ------------------------------------------------------------------------ |
246 | // Get Kernel domain component instance | |
247 | domains = session.getChildren(); | |
248 | assertNotNull(domains); | |
249 | assertEquals(1, domains.length); | |
250 | ||
251 | // Verify that channel was created with correct data | |
252 | channels = domains[0].getChildren(); | |
253 | assertNotNull(channels); | |
254 | assertEquals(2, channels.length); | |
255 | ||
256 | fFacility.executeCommand(channels, "disableChannel"); | |
cfdb727a | 257 | |
a26d90be BH |
258 | assertEquals(TraceEnablement.DISABLED, ((TraceChannelComponent)channels[0]).getState()); |
259 | assertEquals(TraceEnablement.DISABLED, ((TraceChannelComponent)channels[1]).getState()); | |
260 | ||
261 | // ------------------------------------------------------------------------ | |
cfdb727a | 262 | // enable channels |
a26d90be BH |
263 | // ------------------------------------------------------------------------ |
264 | // Get Kernel domain component instance | |
265 | domains = session.getChildren(); | |
266 | assertNotNull(domains); | |
267 | assertEquals(1, domains.length); | |
268 | ||
269 | // Verify that channel was created with correct data | |
270 | channels = domains[0].getChildren(); | |
271 | assertNotNull(channels); | |
272 | assertEquals(2, channels.length); | |
cfdb727a | 273 | |
a26d90be | 274 | fFacility.executeCommand(channels, "enableChannel"); |
cfdb727a | 275 | |
a26d90be BH |
276 | assertEquals(TraceEnablement.ENABLED, ((TraceChannelComponent)channels[0]).getState()); |
277 | assertEquals(TraceEnablement.ENABLED, ((TraceChannelComponent)channels[1]).getState()); | |
278 | ||
279 | // ------------------------------------------------------------------------ | |
cfdb727a | 280 | // enable event (tracepoints) on session |
a26d90be BH |
281 | // ------------------------------------------------------------------------ |
282 | fFacility.executeCommand(session, "enableEventOnSession"); | |
283 | ||
284 | // Get Kernel domain component instance | |
285 | domains = session.getChildren(); | |
286 | assertNotNull(domains); | |
287 | assertEquals(1, domains.length); | |
288 | ||
289 | // Verify that channel was created with correct data | |
290 | channels = domains[0].getChildren(); | |
291 | assertNotNull(channels); | |
292 | assertEquals(3, channels.length); | |
293 | ||
294 | assertTrue(channels[2] instanceof TraceChannelComponent); | |
cfdb727a | 295 | channel = (TraceChannelComponent) channels[2]; |
a26d90be BH |
296 | assertEquals("channel0", channel.getName()); |
297 | // No need to check parameters of default channel because that has been done in other tests | |
298 | ||
299 | ITraceControlComponent[] channel0Events = channel.getChildren(); | |
300 | assertEquals(2, channel0Events.length); | |
cfdb727a | 301 | |
a26d90be BH |
302 | assertTrue(channel0Events[0] instanceof TraceEventComponent); |
303 | assertTrue(channel0Events[1] instanceof TraceEventComponent); | |
304 | ||
305 | TraceEventComponent event = (TraceEventComponent) channel0Events[0]; | |
306 | assertEquals("sched_kthread_stop_ret", event.getName()); | |
307 | assertEquals(TraceLogLevel.TRACE_EMERG, event.getLogLevel()); | |
308 | assertEquals(TraceEventType.TRACEPOINT, event.getEventType()); | |
309 | assertEquals(TraceEnablement.ENABLED, event.getState()); | |
310 | ||
311 | event = (TraceEventComponent) channel0Events[1]; | |
312 | assertEquals("sched_kthread_stop", event.getName()); | |
313 | assertEquals(TraceLogLevel.TRACE_EMERG, event.getLogLevel()); | |
314 | assertEquals(TraceEventType.TRACEPOINT, event.getEventType()); | |
315 | assertEquals(TraceEnablement.ENABLED, event.getState()); | |
316 | ||
317 | // ------------------------------------------------------------------------ | |
cfdb727a | 318 | // enable event (tracepoints) on domain |
a26d90be BH |
319 | // ------------------------------------------------------------------------ |
320 | events.clear(); | |
321 | events.add("sched_wakeup_new"); | |
322 | eventsDialogStub.setNames(events); | |
323 | ||
324 | fFacility.executeCommand(domains[0], "enableEventOnDomain"); | |
325 | ||
326 | // Get Kernel domain component instance | |
327 | domains = session.getChildren(); | |
328 | assertNotNull(domains); | |
329 | assertEquals(1, domains.length); | |
330 | ||
331 | // Verify that channel was created with correct data | |
332 | channels = domains[0].getChildren(); | |
cfdb727a | 333 | channel = (TraceChannelComponent) channels[2]; |
a26d90be BH |
334 | // No need to check parameters of default channel because that has been done in other tests |
335 | ||
336 | channel = (TraceChannelComponent) channels[2]; | |
cfdb727a | 337 | |
a26d90be BH |
338 | channel0Events = channel.getChildren(); |
339 | assertEquals(3, channel0Events.length); | |
cfdb727a | 340 | |
a26d90be BH |
341 | assertTrue(channel0Events[2] instanceof TraceEventComponent); |
342 | ||
343 | event = (TraceEventComponent) channel0Events[2]; | |
344 | assertEquals("sched_wakeup_new", event.getName()); | |
345 | assertEquals(TraceLogLevel.TRACE_EMERG, event.getLogLevel()); | |
346 | assertEquals(TraceEventType.TRACEPOINT, event.getEventType()); | |
347 | assertEquals(TraceEnablement.ENABLED, event.getState()); | |
348 | ||
349 | // ------------------------------------------------------------------------ | |
cfdb727a | 350 | // enable event (tracepoints) on channel |
a26d90be BH |
351 | // ------------------------------------------------------------------------ |
352 | events.clear(); | |
353 | eventsDialogStub.setNames(events); | |
354 | eventsDialogStub.setIsAllTracePoints(true); | |
355 | ||
356 | fFacility.executeCommand(channels[1], "enableEventOnChannel"); | |
cfdb727a | 357 | |
a26d90be BH |
358 | // Get Kernel domain component instance |
359 | domains = session.getChildren(); | |
360 | assertNotNull(domains); | |
361 | assertEquals(1, domains.length); | |
362 | ||
363 | // Verify that channel was created with correct data | |
364 | channels = domains[0].getChildren(); | |
365 | // No need to check parameters of default channel because that has been done in other tests | |
366 | channel = (TraceChannelComponent) channels[1]; | |
cfdb727a | 367 | |
a26d90be BH |
368 | channel0Events = channel.getChildren(); |
369 | assertEquals(3, channel0Events.length); | |
cfdb727a | 370 | |
a26d90be BH |
371 | assertTrue(channel0Events[0] instanceof TraceEventComponent); |
372 | assertTrue(channel0Events[1] instanceof TraceEventComponent); | |
373 | assertTrue(channel0Events[2] instanceof TraceEventComponent); | |
374 | ||
375 | event = (TraceEventComponent) channel0Events[0]; | |
376 | assertEquals("sched_kthread_stop_ret", event.getName()); | |
377 | assertEquals(TraceLogLevel.TRACE_EMERG, event.getLogLevel()); | |
378 | assertEquals(TraceEventType.TRACEPOINT, event.getEventType()); | |
379 | assertEquals(TraceEnablement.ENABLED, event.getState()); | |
380 | ||
381 | event = (TraceEventComponent) channel0Events[1]; | |
382 | assertEquals("sched_kthread_stop", event.getName()); | |
383 | assertEquals(TraceLogLevel.TRACE_EMERG, event.getLogLevel()); | |
384 | assertEquals(TraceEventType.TRACEPOINT, event.getEventType()); | |
385 | assertEquals(TraceEnablement.ENABLED, event.getState()); | |
cfdb727a | 386 | |
a26d90be BH |
387 | event = (TraceEventComponent) channel0Events[2]; |
388 | assertEquals("sched_wakeup_new", event.getName()); | |
389 | assertEquals(TraceLogLevel.TRACE_EMERG, event.getLogLevel()); | |
390 | assertEquals(TraceEventType.TRACEPOINT, event.getEventType()); | |
391 | assertEquals(TraceEnablement.ENABLED, event.getState()); | |
392 | ||
393 | // ------------------------------------------------------------------------ | |
cfdb727a | 394 | // enable event (syscall) on channel |
a26d90be BH |
395 | // ------------------------------------------------------------------------ |
396 | events.clear(); | |
cfdb727a | 397 | eventsDialogStub.setIsTracePoints(false); |
a26d90be BH |
398 | eventsDialogStub.setIsAllTracePoints(false); |
399 | eventsDialogStub.setIsSysCalls(true); | |
400 | ||
401 | fFacility.executeCommand(channels[0], "enableEventOnChannel"); | |
cfdb727a | 402 | |
a26d90be BH |
403 | // Get Kernel domain component instance |
404 | domains = session.getChildren(); | |
405 | assertNotNull(domains); | |
406 | assertEquals(1, domains.length); | |
407 | ||
408 | // Verify that channel was created with correct data | |
409 | channels = domains[0].getChildren(); | |
cfdb727a | 410 | channel = (TraceChannelComponent) channels[0]; |
a26d90be BH |
411 | // No need to check parameters of default channel because that has been done in other tests |
412 | ||
413 | channel = (TraceChannelComponent) channels[0]; | |
cfdb727a | 414 | |
a26d90be BH |
415 | channel0Events = channel.getChildren(); |
416 | assertEquals(1, channel0Events.length); | |
cfdb727a | 417 | |
a26d90be | 418 | assertTrue(channel0Events[0] instanceof TraceEventComponent); |
cfdb727a | 419 | |
a26d90be BH |
420 | event = (TraceEventComponent) channel0Events[0]; |
421 | assertEquals("syscalls", event.getName()); | |
422 | assertEquals(TraceLogLevel.LEVEL_UNKNOWN, event.getLogLevel()); | |
423 | assertEquals(TraceEventType.SYSCALL, event.getEventType()); | |
424 | assertEquals(TraceEnablement.ENABLED, event.getState()); | |
425 | ||
426 | // ------------------------------------------------------------------------ | |
cfdb727a | 427 | // enable event (syscall) on domain |
a26d90be BH |
428 | // ------------------------------------------------------------------------ |
429 | fFacility.executeCommand(domains[0], "enableEventOnDomain"); | |
430 | ||
431 | // Get Kernel domain component instance | |
432 | domains = session.getChildren(); | |
433 | assertNotNull(domains); | |
434 | assertEquals(1, domains.length); | |
435 | ||
436 | // Verify that channel was created with correct data | |
437 | channels = domains[0].getChildren(); | |
cfdb727a | 438 | channel = (TraceChannelComponent) channels[0]; |
a26d90be BH |
439 | // No need to check parameters of default channel because that has been done in other tests |
440 | ||
441 | channel = (TraceChannelComponent) channels[2]; | |
cfdb727a | 442 | |
a26d90be BH |
443 | channel0Events = channel.getChildren(); |
444 | assertEquals(4, channel0Events.length); | |
cfdb727a | 445 | |
a26d90be | 446 | assertTrue(channel0Events[0] instanceof TraceEventComponent); |
cfdb727a | 447 | |
a26d90be BH |
448 | event = (TraceEventComponent) channel0Events[0]; |
449 | assertEquals("syscalls", event.getName()); | |
450 | assertEquals(TraceLogLevel.LEVEL_UNKNOWN, event.getLogLevel()); | |
451 | assertEquals(TraceEventType.SYSCALL, event.getEventType()); | |
452 | assertEquals(TraceEnablement.ENABLED, event.getState()); | |
453 | ||
454 | // ------------------------------------------------------------------------ | |
cfdb727a | 455 | // enable event (syscall) on session |
a26d90be BH |
456 | // ------------------------------------------------------------------------ |
457 | fFacility.executeCommand(session, "enableEventOnSession"); | |
458 | ||
459 | // Get Kernel domain component instance | |
460 | domains = session.getChildren(); | |
461 | assertNotNull(domains); | |
462 | assertEquals(1, domains.length); | |
463 | ||
464 | // Verify that channel was created with correct data | |
465 | channels = domains[0].getChildren(); | |
cfdb727a | 466 | channel = (TraceChannelComponent) channels[0]; |
a26d90be BH |
467 | // No need to check parameters of default channel because that has been done in other tests |
468 | ||
469 | channel = (TraceChannelComponent) channels[2]; | |
cfdb727a | 470 | |
a26d90be BH |
471 | channel0Events = channel.getChildren(); |
472 | assertEquals(4, channel0Events.length); | |
cfdb727a | 473 | |
a26d90be | 474 | assertTrue(channel0Events[0] instanceof TraceEventComponent); |
cfdb727a | 475 | |
a26d90be BH |
476 | event = (TraceEventComponent) channel0Events[0]; |
477 | assertEquals("syscalls", event.getName()); | |
478 | assertEquals(TraceLogLevel.LEVEL_UNKNOWN, event.getLogLevel()); | |
479 | assertEquals(TraceEventType.SYSCALL, event.getEventType()); | |
480 | assertEquals(TraceEnablement.ENABLED, event.getState()); | |
481 | ||
cfdb727a | 482 | |
a26d90be | 483 | // ------------------------------------------------------------------------ |
cfdb727a | 484 | // enable event (dynamic probe) on domain |
a26d90be BH |
485 | // ------------------------------------------------------------------------ |
486 | events.clear(); | |
487 | eventsDialogStub.setIsSysCalls(false); | |
488 | eventsDialogStub.setIsDynamicProbe(true); | |
489 | eventsDialogStub.setDynamicProbe("0xc0101280"); | |
490 | eventsDialogStub.setProbeEventName("myevent1"); | |
cfdb727a | 491 | |
a26d90be | 492 | fFacility.executeCommand(domains[0], "enableEventOnDomain"); |
cfdb727a | 493 | |
a26d90be BH |
494 | // Get Kernel domain component instance |
495 | domains = session.getChildren(); | |
496 | assertNotNull(domains); | |
497 | assertEquals(1, domains.length); | |
498 | ||
499 | // Verify that channel was created with correct data | |
500 | channels = domains[0].getChildren(); | |
cfdb727a | 501 | channel = (TraceChannelComponent) channels[2]; |
a26d90be BH |
502 | // No need to check parameters of default channel because that has been done in other tests |
503 | ||
504 | channel0Events = channel.getChildren(); | |
505 | assertEquals(5, channel0Events.length); | |
cfdb727a | 506 | |
a26d90be | 507 | assertTrue(channel0Events[0] instanceof TraceProbeEventComponent); |
cfdb727a | 508 | |
a26d90be BH |
509 | TraceProbeEventComponent probeEvent = (TraceProbeEventComponent) channel0Events[0]; |
510 | assertEquals("myevent1", probeEvent.getName()); | |
511 | assertEquals(TraceLogLevel.LEVEL_UNKNOWN, probeEvent.getLogLevel()); | |
512 | assertEquals(TraceEventType.PROBE, probeEvent.getEventType()); | |
513 | assertEquals(TraceEnablement.ENABLED, probeEvent.getState()); | |
514 | assertNull(probeEvent.getOffset()); | |
515 | assertEquals("0xc0101280", probeEvent.getAddress()); | |
516 | assertNull(probeEvent.getSymbol()); | |
517 | ||
518 | // ------------------------------------------------------------------------ | |
cfdb727a | 519 | // enable event (dynamic probe) on channel |
a26d90be BH |
520 | // ------------------------------------------------------------------------ |
521 | eventsDialogStub.setIsDynamicProbe(true); | |
522 | eventsDialogStub.setDynamicProbe("init_post"); | |
523 | eventsDialogStub.setProbeEventName("myevent2"); | |
524 | ||
525 | fFacility.executeCommand(channels[2], "enableEventOnChannel"); | |
cfdb727a | 526 | |
a26d90be BH |
527 | // Get Kernel domain component instance |
528 | domains = session.getChildren(); | |
529 | assertNotNull(domains); | |
530 | assertEquals(1, domains.length); | |
531 | ||
532 | // Verify that channel was created with correct data | |
533 | channels = domains[0].getChildren(); | |
cfdb727a | 534 | channel = (TraceChannelComponent) channels[2]; |
a26d90be BH |
535 | // No need to check parameters of default channel because that has been done in other tests |
536 | ||
537 | channel0Events = channel.getChildren(); | |
538 | assertEquals(6, channel0Events.length); | |
cfdb727a | 539 | |
a26d90be | 540 | assertTrue(channel0Events[0] instanceof TraceProbeEventComponent); |
cfdb727a | 541 | |
a26d90be BH |
542 | probeEvent = (TraceProbeEventComponent) channel0Events[0]; |
543 | assertEquals("myevent2", probeEvent.getName()); | |
544 | assertEquals(TraceLogLevel.LEVEL_UNKNOWN, probeEvent.getLogLevel()); | |
545 | assertEquals(TraceEventType.PROBE, probeEvent.getEventType()); | |
546 | assertEquals(TraceEnablement.ENABLED, probeEvent.getState()); | |
547 | assertEquals("0x0", probeEvent.getOffset()); | |
548 | assertNull(null, probeEvent.getAddress()); | |
549 | assertEquals("init_post", probeEvent.getSymbol()); | |
550 | ||
551 | // ------------------------------------------------------------------------ | |
cfdb727a | 552 | // enable event (dynamic probe) on session |
a26d90be BH |
553 | // ------------------------------------------------------------------------ |
554 | eventsDialogStub.setIsDynamicProbe(true); | |
555 | eventsDialogStub.setDynamicProbe("init_post:0x1000"); | |
556 | eventsDialogStub.setProbeEventName("myevent3"); | |
557 | ||
558 | fFacility.executeCommand(session, "enableEventOnSession"); | |
cfdb727a | 559 | |
a26d90be BH |
560 | // Get Kernel domain component instance |
561 | domains = session.getChildren(); | |
562 | assertNotNull(domains); | |
563 | assertEquals(1, domains.length); | |
564 | ||
565 | // Verify that channel was created with correct data | |
566 | channels = domains[0].getChildren(); | |
cfdb727a | 567 | channel = (TraceChannelComponent) channels[2]; |
a26d90be BH |
568 | // No need to check parameters of default channel because that has been done in other tests |
569 | ||
570 | channel0Events = channel.getChildren(); | |
571 | assertEquals(7, channel0Events.length); | |
572 | ||
573 | assertTrue(channel0Events[0] instanceof TraceProbeEventComponent); | |
574 | ||
575 | probeEvent = (TraceProbeEventComponent) channel0Events[0]; | |
576 | assertEquals("myevent3", probeEvent.getName()); | |
577 | assertEquals(TraceLogLevel.LEVEL_UNKNOWN, probeEvent.getLogLevel()); | |
578 | assertEquals(TraceEventType.PROBE, probeEvent.getEventType()); | |
579 | assertEquals(TraceEnablement.ENABLED, probeEvent.getState()); | |
580 | assertEquals("0x1000", probeEvent.getOffset()); | |
581 | assertNull(null, probeEvent.getAddress()); | |
582 | assertEquals("init_post", probeEvent.getSymbol()); | |
cfdb727a | 583 | |
a26d90be BH |
584 | // ------------------------------------------------------------------------ |
585 | // enable event (dynamic function probe) on session | |
586 | // ------------------------------------------------------------------------ | |
587 | eventsDialogStub.setIsDynamicProbe(false); | |
588 | eventsDialogStub.setDynamicProbe(null); | |
589 | eventsDialogStub.setProbeEventName(null); | |
590 | eventsDialogStub.setIsFunctionProbe(true); | |
591 | eventsDialogStub.setFunctionEventName("myevent4"); | |
592 | eventsDialogStub.setFunctionProbe("create_dev"); | |
593 | ||
594 | fFacility.executeCommand(session, "enableEventOnSession"); | |
cfdb727a | 595 | |
a26d90be BH |
596 | // Get Kernel domain component instance |
597 | domains = session.getChildren(); | |
598 | assertNotNull(domains); | |
599 | assertEquals(1, domains.length); | |
600 | ||
601 | // Verify that channel was created with correct data | |
602 | channels = domains[0].getChildren(); | |
cfdb727a | 603 | channel = (TraceChannelComponent) channels[2]; |
a26d90be BH |
604 | // No need to check parameters of default channel because that has been done in other tests |
605 | ||
606 | channel0Events = channel.getChildren(); | |
607 | assertEquals(8, channel0Events.length); | |
608 | ||
609 | assertTrue(channel0Events[0] instanceof TraceProbeEventComponent); | |
610 | ||
611 | probeEvent = (TraceProbeEventComponent) channel0Events[0]; | |
612 | assertEquals("myevent4", probeEvent.getName()); | |
613 | assertEquals(TraceLogLevel.LEVEL_UNKNOWN, probeEvent.getLogLevel()); | |
614 | assertEquals(TraceEventType.PROBE, probeEvent.getEventType()); | |
615 | assertEquals(TraceEnablement.ENABLED, probeEvent.getState()); | |
616 | assertEquals("0x0", probeEvent.getOffset()); | |
617 | assertNull(null, probeEvent.getAddress()); | |
618 | assertEquals("create_dev", probeEvent.getSymbol()); | |
cfdb727a | 619 | |
a26d90be BH |
620 | // ------------------------------------------------------------------------ |
621 | // enable event (dynamic function probe) on domain | |
622 | // ------------------------------------------------------------------------ | |
623 | eventsDialogStub.setIsFunctionProbe(true); | |
624 | eventsDialogStub.setFunctionEventName("myevent5"); | |
625 | eventsDialogStub.setFunctionProbe("create_dev:0x2000"); | |
626 | ||
627 | fFacility.executeCommand(domains[0], "enableEventOnDomain"); | |
cfdb727a | 628 | |
a26d90be BH |
629 | // Get Kernel domain component instance |
630 | domains = session.getChildren(); | |
631 | assertNotNull(domains); | |
632 | assertEquals(1, domains.length); | |
633 | ||
634 | // Verify that channel was created with correct data | |
635 | channels = domains[0].getChildren(); | |
cfdb727a | 636 | channel = (TraceChannelComponent) channels[2]; |
a26d90be BH |
637 | // No need to check parameters of default channel because that has been done in other tests |
638 | ||
639 | channel0Events = channel.getChildren(); | |
640 | assertEquals(9, channel0Events.length); | |
641 | ||
642 | assertTrue(channel0Events[0] instanceof TraceProbeEventComponent); | |
643 | ||
644 | probeEvent = (TraceProbeEventComponent) channel0Events[0]; | |
645 | assertEquals("myevent5", probeEvent.getName()); | |
646 | assertEquals(TraceLogLevel.LEVEL_UNKNOWN, probeEvent.getLogLevel()); | |
647 | assertEquals(TraceEventType.PROBE, probeEvent.getEventType()); | |
648 | assertEquals(TraceEnablement.ENABLED, probeEvent.getState()); | |
649 | assertEquals("0x2000", probeEvent.getOffset()); | |
650 | assertNull(null, probeEvent.getAddress()); | |
651 | assertEquals("create_dev", probeEvent.getSymbol()); | |
652 | ||
653 | // ------------------------------------------------------------------------ | |
654 | // enable event (dynamic function probe) on channel | |
655 | // ------------------------------------------------------------------------ | |
656 | eventsDialogStub.setIsFunctionProbe(true); | |
657 | eventsDialogStub.setFunctionEventName("myevent"); | |
658 | eventsDialogStub.setFunctionProbe("create_dev:0x2000"); | |
659 | ||
660 | fFacility.executeCommand(channels[0], "enableEventOnChannel"); | |
cfdb727a | 661 | |
a26d90be BH |
662 | // Get Kernel domain component instance |
663 | domains = session.getChildren(); | |
664 | assertNotNull(domains); | |
665 | assertEquals(1, domains.length); | |
666 | ||
667 | // Verify that channel was created with correct data | |
668 | channels = domains[0].getChildren(); | |
cfdb727a | 669 | channel = (TraceChannelComponent) channels[0]; |
a26d90be BH |
670 | // No need to check parameters of default channel because that has been done in other tests |
671 | ||
672 | channel0Events = channel.getChildren(); | |
673 | assertEquals(2, channel0Events.length); | |
674 | ||
675 | assertTrue(channel0Events[0] instanceof TraceProbeEventComponent); | |
676 | ||
677 | probeEvent = (TraceProbeEventComponent) channel0Events[0]; | |
678 | assertEquals("myevent", probeEvent.getName()); | |
679 | assertEquals(TraceLogLevel.LEVEL_UNKNOWN, probeEvent.getLogLevel()); | |
680 | assertEquals(TraceEventType.PROBE, probeEvent.getEventType()); | |
681 | assertEquals(TraceEnablement.ENABLED, probeEvent.getState()); | |
682 | assertEquals("0x2000", probeEvent.getOffset()); | |
683 | assertNull(null, probeEvent.getAddress()); | |
684 | assertEquals("create_dev", probeEvent.getSymbol()); | |
4ea599a5 BH |
685 | |
686 | // ------------------------------------------------------------------------ | |
cfdb727a | 687 | // Add Context on domain |
4ea599a5 BH |
688 | // ------------------------------------------------------------------------ |
689 | // Get Kernel domain component instance | |
690 | domains = session.getChildren(); | |
691 | assertNotNull(domains); | |
692 | assertEquals(1, domains.length); | |
693 | ||
694 | AddContextDialogStub addContextStub = new AddContextDialogStub(); | |
695 | List<String> contexts = new ArrayList<String>(); | |
696 | contexts.add("prio"); | |
697 | contexts.add("perf:branch-misses"); | |
698 | contexts.add("perf:cache-misses"); | |
699 | addContextStub.setContexts(contexts); | |
700 | TraceControlDialogFactory.getInstance().setAddContextDialog(addContextStub); | |
cfdb727a | 701 | |
4ea599a5 BH |
702 | fFacility.executeCommand(domains[0], "addContextOnDomain"); |
703 | // Currently there is nothing to verify because the list commands don't show any context information | |
704 | // However, the execution of the command make sure that the correct service command line is build and executed. | |
705 | ||
706 | // ------------------------------------------------------------------------ | |
cfdb727a | 707 | // Add Context on channel |
4ea599a5 BH |
708 | // ------------------------------------------------------------------------ |
709 | ||
710 | // Get Kernel domain component instance | |
711 | domains = session.getChildren(); | |
712 | assertNotNull(domains); | |
713 | assertEquals(1, domains.length); | |
714 | ||
715 | //Verify that channel was created with correct data | |
716 | channels = domains[0].getChildren(); | |
cfdb727a AM |
717 | channel = (TraceChannelComponent) channels[0]; |
718 | ||
4ea599a5 BH |
719 | try { |
720 | // The setContext() verifies that the contexts set are part of the available contexts | |
721 | // The available contexts are set by the command handler addContextOnDomain above. | |
722 | // So we indirectly test here that the parsing and setting of available contexts were | |
723 | // done correctly above. | |
724 | addContextStub.setContexts(contexts); | |
725 | } catch (IllegalArgumentException e) { | |
726 | fail("Exception caught - unknown context"); | |
727 | } | |
728 | ||
729 | fFacility.executeCommand(channel, "addContextOnChannel"); | |
730 | // Currently there is nothing to verify because the list commands don't show any context information | |
731 | // However, the execution of the command make sure that the correct service command line is build and executed. | |
cfdb727a | 732 | |
4ea599a5 | 733 | // ------------------------------------------------------------------------ |
cfdb727a | 734 | // Add Context on event |
4ea599a5 BH |
735 | // ------------------------------------------------------------------------ |
736 | // Get Kernel domain component instance | |
737 | domains = session.getChildren(); | |
738 | assertNotNull(domains); | |
739 | assertEquals(1, domains.length); | |
740 | ||
741 | //Verify that channel was created with correct data | |
742 | channels = domains[0].getChildren(); | |
cfdb727a AM |
743 | channel = (TraceChannelComponent) channels[2]; |
744 | ||
4ea599a5 BH |
745 | channel0Events = channel.getChildren(); |
746 | ||
747 | event = (TraceEventComponent) channel0Events[6]; | |
cfdb727a | 748 | |
4ea599a5 BH |
749 | fFacility.executeCommand(event, "addContextOnEvent"); |
750 | // Currently there is nothing to verify because the list commands don't show any context information | |
cfdb727a | 751 | // However, the execution of the command make sure that the correct service command line is build and executed. |
4ea599a5 BH |
752 | |
753 | // ------------------------------------------------------------------------ | |
cfdb727a | 754 | // Calibrate |
4ea599a5 BH |
755 | // ------------------------------------------------------------------------ |
756 | // Get Kernel domain component instance | |
757 | domains = session.getChildren(); | |
758 | assertNotNull(domains); | |
759 | assertEquals(1, domains.length); | |
cfdb727a | 760 | |
4ea599a5 | 761 | fFacility.executeCommand(domains[0], "calibrate"); |
cfdb727a | 762 | // There is nothing to verify here. |
4ea599a5 | 763 | // However, the execution of the command make sure that the correct service command line is build and executed. |
cfdb727a | 764 | |
a26d90be | 765 | // ------------------------------------------------------------------------ |
cfdb727a | 766 | // refresh |
a26d90be BH |
767 | // ------------------------------------------------------------------------ |
768 | fFacility.executeCommand(node, "refresh"); | |
769 | groups = node.getChildren(); | |
770 | assertNotNull(groups); | |
771 | assertEquals(2, groups.length); | |
772 | assertEquals(3, groups[0].getChildren().length); // provider | |
773 | assertEquals(1, groups[1].getChildren().length); // sessions | |
774 | assertEquals(1, groups[1].getChildren()[0].getChildren().length); // domains | |
775 | assertEquals(3, groups[1].getChildren()[0].getChildren()[0].getChildren().length); // channels | |
776 | assertEquals(2, groups[1].getChildren()[0].getChildren()[0].getChildren()[0].getChildren().length); // events (of channel[0]) | |
cfdb727a | 777 | |
a26d90be BH |
778 | // Initialize session handling scenario |
779 | fProxy.setScenario(TraceControlTestFacility.SCEN_SCENARIO_SESSION_HANDLING); | |
cfdb727a | 780 | |
a26d90be | 781 | session = (TraceSessionComponent)groups[1].getChildren()[0]; |
4ea599a5 | 782 | |
a26d90be | 783 | // ------------------------------------------------------------------------ |
cfdb727a | 784 | // start session |
a26d90be BH |
785 | // ------------------------------------------------------------------------ |
786 | fFacility.startSession(session); | |
787 | assertEquals(TraceSessionState.ACTIVE, session.getSessionState()); | |
cfdb727a | 788 | |
a26d90be | 789 | // ------------------------------------------------------------------------ |
cfdb727a | 790 | // stop session |
a26d90be BH |
791 | // ------------------------------------------------------------------------ |
792 | fFacility.stopSession(session); | |
793 | assertEquals(TraceSessionState.INACTIVE, session.getSessionState()); | |
cfdb727a | 794 | |
a26d90be | 795 | // ------------------------------------------------------------------------ |
cfdb727a | 796 | // Destroy session |
a26d90be BH |
797 | // ------------------------------------------------------------------------ |
798 | ||
799 | fFacility.destroySession(session); | |
cfdb727a | 800 | |
a26d90be BH |
801 | // Verify that no more session components exist |
802 | assertEquals(0, groups[1].getChildren().length); | |
803 | ||
804 | //------------------------------------------------------------------------- | |
805 | // Disconnect node | |
806 | //------------------------------------------------------------------------- | |
807 | fFacility.executeCommand(node, "disconnect"); | |
808 | assertEquals(TargetNodeState.DISCONNECTED, node.getTargetNodeState()); | |
cfdb727a | 809 | |
a26d90be BH |
810 | //------------------------------------------------------------------------- |
811 | // Delete node | |
812 | //------------------------------------------------------------------------- | |
cfdb727a | 813 | |
a26d90be BH |
814 | fFacility.executeCommand(node, "delete"); |
815 | assertEquals(0,fFacility.getControlView().getTraceControlRoot().getChildren().length); | |
816 | } | |
cfdb727a | 817 | |
a26d90be | 818 | } |