Commit | Line | Data |
---|---|---|
a26d90be | 1 | /********************************************************************** |
533d0bc3 | 2 | * Copyright (c) 2012, 2015 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 |
b732adaa | 12 | * Markus Schorn - Bug 448058: Use org.eclipse.remote in favor of RSE |
a26d90be | 13 | **********************************************************************/ |
2ba3d0a1 | 14 | |
9bc60be7 | 15 | package org.eclipse.tracecompass.lttng2.control.ui.tests.model.component; |
a26d90be | 16 | |
b732adaa MS |
17 | import static org.junit.Assert.assertEquals; |
18 | import static org.junit.Assert.assertNotNull; | |
362278af | 19 | import static org.junit.Assert.assertNull; |
b732adaa | 20 | import static org.junit.Assert.assertTrue; |
2ba3d0a1 | 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 | 27 | import org.eclipse.core.runtime.FileLocator; |
362278af BH |
28 | import org.eclipse.core.runtime.ILogListener; |
29 | import org.eclipse.core.runtime.IStatus; | |
a26d90be | 30 | import org.eclipse.core.runtime.Path; |
d8a4fd60 | 31 | import org.eclipse.jdt.annotation.NonNull; |
b732adaa | 32 | import org.eclipse.remote.core.IRemoteConnection; |
9bc60be7 AM |
33 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.LogLevelType; |
34 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.TargetNodeState; | |
35 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceChannelOutputType; | |
36 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceEnablement; | |
37 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceEventType; | |
38 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceLogLevel; | |
39 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceSessionState; | |
40 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.BufferType; | |
41 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.ChannelInfo; | |
362278af | 42 | import org.eclipse.tracecompass.internal.lttng2.control.stubs.dialogs.AddContextDialogStub; |
9bc60be7 AM |
43 | import org.eclipse.tracecompass.internal.lttng2.control.stubs.dialogs.CreateSessionDialogStub; |
44 | import org.eclipse.tracecompass.internal.lttng2.control.stubs.dialogs.DestroyConfirmDialogStub; | |
45 | import org.eclipse.tracecompass.internal.lttng2.control.stubs.dialogs.EnableChannelDialogStub; | |
46 | import org.eclipse.tracecompass.internal.lttng2.control.stubs.dialogs.EnableEventsDialogStub; | |
47 | import org.eclipse.tracecompass.internal.lttng2.control.stubs.dialogs.GetEventInfoDialogStub; | |
48 | import org.eclipse.tracecompass.internal.lttng2.control.stubs.service.TestRemoteSystemProxy; | |
362278af | 49 | import org.eclipse.tracecompass.internal.lttng2.control.ui.Activator; |
9bc60be7 AM |
50 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs.TraceControlDialogFactory; |
51 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.ITraceControlComponent; | |
52 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TargetNodeComponent; | |
53 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceChannelComponent; | |
54 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceDomainComponent; | |
55 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceEventComponent; | |
56 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceSessionComponent; | |
b6b4e8b4 | 57 | import org.eclipse.tracecompass.tmf.remote.core.proxy.TmfRemoteConnectionFactory; |
a26d90be BH |
58 | import org.junit.After; |
59 | import org.junit.Before; | |
2ba3d0a1 | 60 | import org.junit.Test; |
9269df72 | 61 | import org.osgi.framework.FrameworkUtil; |
a26d90be BH |
62 | |
63 | /** | |
2ba3d0a1 AM |
64 | * The class <code>TraceControlUstSessionTests</code> contains UST |
65 | * session/channel/event handling test cases. | |
a26d90be | 66 | */ |
2ba3d0a1 | 67 | public class TraceControlUstSessionTests { |
a26d90be BH |
68 | |
69 | // ------------------------------------------------------------------------ | |
70 | // Constants | |
71 | // ------------------------------------------------------------------------ | |
2ba3d0a1 | 72 | |
a26d90be BH |
73 | private static final String TEST_STREAM = "CreateTreeTest.cfg"; |
74 | private static final String SCEN_SCENARIO4_TEST = "Scenario4"; | |
75 | ||
76 | // ------------------------------------------------------------------------ | |
77 | // Test data | |
78 | // ------------------------------------------------------------------------ | |
b6b4e8b4 | 79 | private IRemoteConnection fHost = TmfRemoteConnectionFactory.getLocalConnection(); |
a26d90be | 80 | private TraceControlTestFacility fFacility; |
d8a4fd60 | 81 | private @NonNull TestRemoteSystemProxy fProxy = new TestRemoteSystemProxy(fHost); |
cfdb727a AM |
82 | private String fTestFile; |
83 | ||
a26d90be BH |
84 | // ------------------------------------------------------------------------ |
85 | // Housekeeping | |
86 | // ------------------------------------------------------------------------ | |
87 | ||
88 | /** | |
89 | * Perform pre-test initialization. | |
90 | * | |
91 | * @throws Exception | |
92 | * if the initialization fails for some reason | |
a26d90be | 93 | */ |
a26d90be BH |
94 | @Before |
95 | public void setUp() throws Exception { | |
96 | fFacility = TraceControlTestFacility.getInstance(); | |
1c3c5807 | 97 | fFacility.init(); |
9269df72 | 98 | URL location = FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path(TraceControlTestFacility.DIRECTORY + File.separator + TEST_STREAM), null); |
a26d90be BH |
99 | File testfile = new File(FileLocator.toFileURL(location).toURI()); |
100 | fTestFile = testfile.getAbsolutePath(); | |
101 | } | |
102 | ||
103 | /** | |
104 | * Perform post-test clean-up. | |
a26d90be | 105 | */ |
a26d90be | 106 | @After |
2ba3d0a1 | 107 | public void tearDown() { |
1c3c5807 | 108 | fFacility.dispose(); |
a26d90be | 109 | } |
cfdb727a | 110 | |
a26d90be BH |
111 | /** |
112 | * Run the TraceControlComponent. | |
cfdb727a AM |
113 | * |
114 | * @throws Exception | |
115 | * This will fail the test | |
a26d90be | 116 | */ |
2ba3d0a1 | 117 | @Test |
a26d90be | 118 | public void testTraceSessionTree() throws Exception { |
cfdb727a | 119 | |
a26d90be BH |
120 | fProxy.setTestFile(fTestFile); |
121 | fProxy.setScenario(TraceControlTestFacility.SCEN_INIT_TEST); | |
cfdb727a | 122 | |
1c3c5807 | 123 | ITraceControlComponent root = fFacility.getControlView().getTraceControlRoot(); |
a26d90be | 124 | |
d8a4fd60 | 125 | TargetNodeComponent node = new TargetNodeComponent("myNode", root, fProxy); |
a26d90be BH |
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 | } | |
a26d90be BH |
136 | |
137 | // Get provider groups | |
138 | ITraceControlComponent[] groups = node.getChildren(); | |
139 | assertNotNull(groups); | |
140 | assertEquals(2, groups.length); | |
141 | ||
142 | // Initialize dialog implementations for command execution | |
143 | TraceControlDialogFactory.getInstance().setCreateSessionDialog(new CreateSessionDialogStub()); | |
144 | TraceControlDialogFactory.getInstance().setGetEventInfoDialog(new GetEventInfoDialogStub()); | |
145 | TraceControlDialogFactory.getInstance().setConfirmDialog(new DestroyConfirmDialogStub()); | |
146 | ||
147 | // Initialize session handling scenario | |
148 | fProxy.setScenario(TraceControlTestFacility.SCEN_SCENARIO_SESSION_HANDLING); | |
cfdb727a | 149 | |
a26d90be BH |
150 | // ------------------------------------------------------------------------ |
151 | // Create session | |
152 | // ------------------------------------------------------------------------ | |
153 | TraceSessionComponent session = fFacility.createSession(groups[1]); | |
cfdb727a | 154 | |
a26d90be BH |
155 | // Verify that session was created |
156 | assertNotNull(session); | |
157 | assertEquals("mysession", session.getName()); | |
158 | assertEquals("/home/user/lttng-traces/mysession-20120314-132824", session.getSessionPath()); | |
159 | assertEquals(TraceSessionState.INACTIVE, session.getSessionState()); | |
160 | ||
161 | // Initialize scenario | |
162 | fProxy.setScenario(SCEN_SCENARIO4_TEST); | |
cfdb727a | 163 | |
a26d90be BH |
164 | // ------------------------------------------------------------------------ |
165 | // Enable default channel on created session above | |
166 | // ------------------------------------------------------------------------ | |
d62bfa55 | 167 | EnableChannelDialogStub channelStub = new EnableChannelDialogStub(); |
a26d90be | 168 | channelStub.setIsKernel(false); |
d62bfa55 | 169 | TraceControlDialogFactory.getInstance().setEnableChannelDialog(channelStub); |
a26d90be | 170 | |
d62bfa55 | 171 | fFacility.executeCommand(session, "enableChannelOnSession"); |
cfdb727a | 172 | |
a26d90be BH |
173 | // Verify that Kernel domain was created |
174 | ITraceControlComponent[] domains = session.getChildren(); | |
175 | assertNotNull(domains); | |
176 | assertEquals(1, domains.length); | |
177 | ||
178 | assertEquals("UST global", domains[0].getName()); | |
83051fc3 | 179 | assertEquals("Domain buffer Type", BufferType.BUFFER_TYPE_UNKNOWN, ((TraceDomainComponent)domains[0]).getBufferType()); |
cfdb727a | 180 | |
a26d90be BH |
181 | // Verify that channel was created with correct data |
182 | ITraceControlComponent[] channels = domains[0].getChildren(); | |
183 | assertNotNull(channels); | |
184 | assertEquals(1, channels.length); | |
185 | ||
186 | assertTrue(channels[0] instanceof TraceChannelComponent); | |
cfdb727a | 187 | TraceChannelComponent channel = (TraceChannelComponent) channels[0]; |
a26d90be BH |
188 | assertEquals("mychannel", channel.getName()); |
189 | assertEquals(4, channel.getNumberOfSubBuffers()); | |
0ad9fc89 JRJ |
190 | assertEquals("mmap()", channel.getOutputType().getInName()); |
191 | assertEquals(TraceChannelOutputType.MMAP, channel.getOutputType()); | |
a26d90be BH |
192 | assertEquals(true, channel.isOverwriteMode()); |
193 | assertEquals(200, channel.getReadTimer()); | |
194 | assertEquals(TraceEnablement.ENABLED, channel.getState()); | |
195 | assertEquals(16384, channel.getSubBufferSize()); | |
196 | assertEquals(100, channel.getSwitchTimer()); | |
197 | ||
362278af BH |
198 | // ------------------------------------------------------------------------ |
199 | // Add context on channel | |
200 | // ------------------------------------------------------------------------ | |
201 | AddContextDialogStub addContextStub = new AddContextDialogStub(); | |
202 | List<String> contexts = new ArrayList<>(); | |
203 | contexts.add("procname"); | |
204 | contexts.add("vtid"); | |
205 | addContextStub.setContexts(contexts); | |
206 | TraceControlDialogFactory.getInstance().setAddContextDialog(addContextStub); | |
207 | ||
208 | /* | |
209 | * Currently there is nothing to verify because the list commands don't | |
210 | * show any context information. However, the execution of the command | |
211 | * makes sure that the correct service command line is built and | |
212 | * executed. | |
213 | * | |
214 | * There was a bug in the control where the add context command was | |
215 | * called with -k option instead of -u. Sending the -k option would | |
216 | * cause that the command string is not found in the scenario. When a | |
217 | * command string is not found then it is logged in the error log. | |
218 | * | |
219 | * Check the error log here to verify that the command was successful. | |
220 | */ | |
221 | final IStatus[] statusToCheck = new IStatus[1]; | |
222 | ILogListener listener = new ILogListener() { | |
223 | @Override | |
224 | public void logging(IStatus status, String plugin) { | |
225 | if (plugin.contentEquals(Activator.PLUGIN_ID) && (!status.isOK())) { | |
226 | statusToCheck[0] = status; | |
227 | } | |
228 | } | |
229 | }; | |
230 | Activator.getDefault().getLog().addLogListener(listener); | |
231 | ||
232 | fFacility.executeCommand(channels[0], "addContextOnChannel"); | |
233 | ||
234 | // check that no error status was created | |
235 | assertNull(statusToCheck[0]); | |
236 | ||
237 | Activator.getDefault().getLog().removeLogListener(listener); | |
238 | ||
239 | fFacility.delay(10000); | |
240 | ||
241 | // Get Kernel domain component instance | |
242 | domains = session.getChildren(); | |
243 | assertNotNull(domains); | |
244 | assertEquals(1, domains.length); | |
245 | ||
a26d90be BH |
246 | // ------------------------------------------------------------------------ |
247 | // Enable channel on domain | |
248 | // ------------------------------------------------------------------------ | |
249 | ChannelInfo info = (ChannelInfo)channelStub.getChannelInfo(); | |
250 | info.setName("mychannel2"); | |
251 | info.setOverwriteMode(false); | |
252 | info.setSubBufferSize(32768); | |
253 | info.setNumberOfSubBuffers(2); | |
254 | info.setSwitchTimer(100); | |
255 | info.setReadTimer(200); | |
256 | channelStub.setChannelInfo(info); | |
cfdb727a | 257 | |
d62bfa55 | 258 | fFacility.executeCommand(domains[0], "enableChannelOnDomain"); |
a26d90be BH |
259 | |
260 | // Get Kernel domain component instance | |
261 | domains = session.getChildren(); | |
262 | assertNotNull(domains); | |
263 | assertEquals(1, domains.length); | |
264 | ||
265 | // Verify that channel was created with correct data | |
266 | channels = domains[0].getChildren(); | |
267 | assertNotNull(channels); | |
268 | assertEquals(2, channels.length); | |
269 | ||
270 | assertTrue(channels[1] instanceof TraceChannelComponent); | |
cfdb727a | 271 | channel = (TraceChannelComponent) channels[1]; |
a26d90be BH |
272 | assertEquals("mychannel2", channel.getName()); |
273 | assertEquals(2, channel.getNumberOfSubBuffers()); | |
0ad9fc89 JRJ |
274 | assertEquals("mmap()", channel.getOutputType().getInName()); |
275 | assertEquals(TraceChannelOutputType.MMAP, channel.getOutputType()); | |
a26d90be BH |
276 | assertEquals(false, channel.isOverwriteMode()); |
277 | assertEquals(200, channel.getReadTimer()); | |
278 | assertEquals(TraceEnablement.ENABLED, channel.getState()); | |
279 | assertEquals(32768, channel.getSubBufferSize()); | |
280 | assertEquals(100, channel.getSwitchTimer()); | |
281 | ||
282 | // ------------------------------------------------------------------------ | |
283 | // Enable event (tracepoint) on session and default channel | |
284 | // ------------------------------------------------------------------------ | |
285 | EnableEventsDialogStub eventsDialogStub = new EnableEventsDialogStub(); | |
286 | eventsDialogStub.setIsTracePoints(true); | |
e0838ca1 | 287 | List<String> events = new ArrayList<>(); |
a26d90be BH |
288 | events.add("ust_tests_hello:tptest_sighandler"); |
289 | eventsDialogStub.setNames(events); | |
290 | eventsDialogStub.setIsKernel(false); | |
291 | TraceControlDialogFactory.getInstance().setEnableEventsDialog(eventsDialogStub); | |
cfdb727a | 292 | |
a26d90be | 293 | fFacility.executeCommand(session, "enableEventOnSession"); |
cfdb727a | 294 | |
a26d90be BH |
295 | // Get Kernel domain component instance |
296 | domains = session.getChildren(); | |
297 | assertNotNull(domains); | |
298 | assertEquals(1, domains.length); | |
299 | ||
300 | // Verify that channel was created with correct data | |
301 | channels = domains[0].getChildren(); | |
302 | assertNotNull(channels); | |
303 | assertEquals(3, channels.length); | |
304 | ||
305 | assertTrue(channels[2] instanceof TraceChannelComponent); | |
cfdb727a | 306 | channel = (TraceChannelComponent) channels[2]; |
a26d90be BH |
307 | assertEquals("channel0", channel.getName()); |
308 | // No need to check parameters of default channel because that has been done in other tests | |
309 | ||
310 | ITraceControlComponent[] channel0Events = channel.getChildren(); | |
311 | assertEquals(1, channel0Events.length); | |
cfdb727a | 312 | |
a26d90be BH |
313 | assertTrue(channel0Events[0] instanceof TraceEventComponent); |
314 | ||
315 | TraceEventComponent event = (TraceEventComponent) channel0Events[0]; | |
316 | assertEquals("ust_tests_hello:tptest_sighandler", event.getName()); | |
317 | assertEquals(TraceLogLevel.LEVEL_UNKNOWN, event.getLogLevel()); // TODO | |
318 | assertEquals(TraceEventType.TRACEPOINT, event.getEventType()); | |
319 | assertEquals(TraceEnablement.ENABLED, event.getState()); | |
320 | ||
321 | // ------------------------------------------------------------------------ | |
322 | // Enable event (tracepoint) on domain and default channel | |
323 | // ------------------------------------------------------------------------ | |
324 | events.clear(); | |
325 | events.add("ust_tests_hello:tptest"); | |
326 | eventsDialogStub.setNames(events); | |
cfdb727a | 327 | |
a26d90be | 328 | fFacility.executeCommand(domains[0], "enableEventOnDomain"); |
cfdb727a | 329 | |
a26d90be BH |
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 | channel0Events = channel.getChildren(); | |
341 | assertEquals(2, channel0Events.length); | |
cfdb727a | 342 | |
a26d90be BH |
343 | assertTrue(channel0Events[1] instanceof TraceEventComponent); |
344 | ||
345 | event = (TraceEventComponent) channel0Events[1]; | |
346 | assertEquals("ust_tests_hello:tptest", event.getName()); | |
347 | assertEquals(TraceLogLevel.LEVEL_UNKNOWN, event.getLogLevel()); // TODO | |
348 | assertEquals(TraceEventType.TRACEPOINT, event.getEventType()); | |
349 | assertEquals(TraceEnablement.ENABLED, event.getState()); | |
350 | ||
351 | // ------------------------------------------------------------------------ | |
352 | // Enable event (all tracepoints) on specific channel | |
353 | // ------------------------------------------------------------------------ | |
354 | events.clear(); | |
355 | eventsDialogStub.setNames(events); | |
356 | eventsDialogStub.setIsAllTracePoints(true); | |
357 | ||
358 | fFacility.executeCommand(channels[1], "enableEventOnChannel"); | |
359 | ||
360 | // Get Kernel domain component instance | |
361 | domains = session.getChildren(); | |
362 | assertNotNull(domains); | |
363 | assertEquals(1, domains.length); | |
364 | ||
365 | // Verify that channel was created with correct data | |
366 | channels = domains[0].getChildren(); | |
cfdb727a | 367 | channel = (TraceChannelComponent) channels[1]; |
a26d90be BH |
368 | // No need to check parameters of default channel because that has been done in other tests |
369 | ||
370 | channel = (TraceChannelComponent) channels[1]; | |
cfdb727a | 371 | |
a26d90be BH |
372 | channel0Events = channel.getChildren(); |
373 | assertEquals(1, channel0Events.length); | |
cfdb727a | 374 | |
a26d90be BH |
375 | assertTrue(channel0Events[0] instanceof TraceEventComponent); |
376 | ||
377 | event = (TraceEventComponent) channel0Events[0]; | |
378 | assertEquals("*", event.getName()); | |
379 | assertEquals(TraceLogLevel.LEVEL_UNKNOWN, event.getLogLevel()); | |
380 | assertEquals(TraceEventType.TRACEPOINT, event.getEventType()); | |
381 | assertEquals(TraceEnablement.ENABLED, event.getState()); | |
382 | ||
383 | // ------------------------------------------------------------------------ | |
384 | // Enable event (wildcard) on specific channel | |
385 | // ------------------------------------------------------------------------ | |
386 | events.clear(); | |
cfdb727a | 387 | eventsDialogStub.setIsTracePoints(false); |
a26d90be BH |
388 | eventsDialogStub.setIsAllTracePoints(false); |
389 | eventsDialogStub.setIsWildcard(true); | |
390 | eventsDialogStub.setWildcard("ust*"); | |
391 | ||
392 | fFacility.executeCommand(channels[0], "enableEventOnChannel"); | |
393 | ||
394 | // Get Kernel domain component instance | |
395 | domains = session.getChildren(); | |
396 | assertNotNull(domains); | |
397 | assertEquals(1, domains.length); | |
398 | ||
399 | // Verify that channel was created with correct data | |
400 | channels = domains[0].getChildren(); | |
cfdb727a | 401 | channel = (TraceChannelComponent) channels[0]; |
a26d90be BH |
402 | // No need to check parameters of default channel because that has been done in other tests |
403 | ||
404 | channel0Events = channel.getChildren(); | |
405 | assertEquals(1, channel0Events.length); | |
cfdb727a | 406 | |
a26d90be | 407 | assertTrue(channel0Events[0] instanceof TraceEventComponent); |
cfdb727a | 408 | |
a26d90be BH |
409 | event = (TraceEventComponent) channel0Events[0]; |
410 | assertEquals("ust*", event.getName()); | |
411 | assertEquals(TraceLogLevel.LEVEL_UNKNOWN, event.getLogLevel()); | |
412 | assertEquals(TraceEventType.TRACEPOINT, event.getEventType()); | |
413 | assertEquals(TraceEnablement.ENABLED, event.getState()); | |
414 | ||
415 | // ------------------------------------------------------------------------ | |
416 | // Enable event (wildcard) on domain | |
417 | // ------------------------------------------------------------------------ | |
418 | events.clear(); | |
cfdb727a | 419 | eventsDialogStub.setIsTracePoints(false); |
a26d90be BH |
420 | eventsDialogStub.setIsAllTracePoints(false); |
421 | eventsDialogStub.setIsWildcard(true); | |
422 | eventsDialogStub.setWildcard("ust*"); | |
423 | ||
424 | fFacility.executeCommand(domains[0], "enableEventOnDomain"); | |
425 | ||
426 | // Get Kernel domain component instance | |
427 | domains = session.getChildren(); | |
428 | assertNotNull(domains); | |
429 | assertEquals(1, domains.length); | |
430 | ||
431 | // Verify that channel was created with correct data | |
432 | channels = domains[0].getChildren(); | |
cfdb727a | 433 | channel = (TraceChannelComponent) channels[0]; |
a26d90be BH |
434 | // No need to check parameters of default channel because that has been done in other tests |
435 | ||
436 | channel0Events = channel.getChildren(); | |
437 | assertEquals(1, channel0Events.length); | |
cfdb727a | 438 | |
a26d90be | 439 | assertTrue(channel0Events[0] instanceof TraceEventComponent); |
cfdb727a | 440 | |
a26d90be BH |
441 | event = (TraceEventComponent) channel0Events[0]; |
442 | assertEquals("ust*", event.getName()); | |
443 | assertEquals(TraceLogLevel.LEVEL_UNKNOWN, event.getLogLevel()); | |
444 | assertEquals(TraceEventType.TRACEPOINT, event.getEventType()); | |
445 | assertEquals(TraceEnablement.ENABLED, event.getState()); | |
446 | ||
447 | // ------------------------------------------------------------------------ | |
448 | // Enable event (wildcard) on session | |
449 | // ------------------------------------------------------------------------ | |
450 | events.clear(); | |
cfdb727a | 451 | eventsDialogStub.setIsTracePoints(false); |
a26d90be BH |
452 | eventsDialogStub.setIsAllTracePoints(false); |
453 | eventsDialogStub.setIsWildcard(true); | |
454 | eventsDialogStub.setWildcard("ust*"); | |
455 | ||
456 | fFacility.executeCommand(domains[0], "enableEventOnDomain"); | |
457 | ||
458 | // Get Kernel domain component instance | |
459 | domains = session.getChildren(); | |
460 | assertNotNull(domains); | |
461 | assertEquals(1, domains.length); | |
462 | ||
463 | // Verify that channel was created with correct data | |
464 | channels = domains[0].getChildren(); | |
cfdb727a | 465 | channel = (TraceChannelComponent) channels[2]; |
a26d90be BH |
466 | // No need to check parameters of default channel because that has been done in other tests |
467 | ||
468 | channel0Events = channel.getChildren(); | |
469 | assertEquals(4, channel0Events.length); | |
cfdb727a | 470 | |
a26d90be | 471 | assertTrue(channel0Events[0] instanceof TraceEventComponent); |
cfdb727a | 472 | |
a26d90be BH |
473 | event = (TraceEventComponent) channel0Events[0]; |
474 | assertEquals("u*", event.getName()); | |
475 | assertEquals(TraceLogLevel.LEVEL_UNKNOWN, event.getLogLevel()); | |
476 | assertEquals(TraceEventType.TRACEPOINT, event.getEventType()); | |
477 | assertEquals(TraceEnablement.ENABLED, event.getState()); | |
478 | ||
479 | // ------------------------------------------------------------------------ | |
480 | // Enable event (loglevel) on domain | |
481 | // ------------------------------------------------------------------------ | |
482 | events.clear(); | |
483 | eventsDialogStub.setIsWildcard(false); | |
484 | eventsDialogStub.setIsLogLevel(true); | |
485 | eventsDialogStub.setLogLevelEventName("myevent1"); | |
486 | eventsDialogStub.setLogLevelType(LogLevelType.LOGLEVEL); | |
487 | eventsDialogStub.setLogLevel(TraceLogLevel.TRACE_WARNING); | |
cfdb727a | 488 | |
a26d90be BH |
489 | fFacility.executeCommand(domains[0], "enableEventOnDomain"); |
490 | ||
491 | // Get Kernel domain component instance | |
492 | domains = session.getChildren(); | |
493 | assertNotNull(domains); | |
494 | assertEquals(1, domains.length); | |
495 | ||
496 | // Verify that channel was created with correct data | |
497 | channels = domains[0].getChildren(); | |
cfdb727a | 498 | channel = (TraceChannelComponent) channels[2]; |
a26d90be BH |
499 | // No need to check parameters of default channel because that has been done in other tests |
500 | ||
501 | channel0Events = channel.getChildren(); | |
502 | assertEquals(5, channel0Events.length); | |
cfdb727a | 503 | |
a26d90be | 504 | assertTrue(channel0Events[0] instanceof TraceEventComponent); |
cfdb727a | 505 | |
a26d90be BH |
506 | event = (TraceEventComponent) channel0Events[0]; |
507 | assertEquals("myevent1", event.getName()); | |
508 | assertEquals(TraceLogLevel.TRACE_WARNING, event.getLogLevel()); | |
509 | assertEquals(TraceEventType.TRACEPOINT, event.getEventType()); | |
510 | assertEquals(TraceEnablement.ENABLED, event.getState()); | |
511 | ||
512 | // ------------------------------------------------------------------------ | |
513 | // Enable event (loglevel) on session | |
514 | // ------------------------------------------------------------------------ | |
515 | eventsDialogStub.setLogLevelEventName("myevent2"); | |
516 | eventsDialogStub.setLogLevelType(LogLevelType.LOGLEVEL_ONLY); | |
517 | eventsDialogStub.setLogLevel(TraceLogLevel.TRACE_DEBUG_FUNCTION); | |
cfdb727a | 518 | |
a26d90be | 519 | fFacility.executeCommand(session, "enableEventOnSession"); |
cfdb727a | 520 | |
a26d90be BH |
521 | // Get Kernel domain component instance |
522 | domains = session.getChildren(); | |
523 | assertNotNull(domains); | |
524 | assertEquals(1, domains.length); | |
525 | ||
526 | // Verify that channel was created with correct data | |
527 | channels = domains[0].getChildren(); | |
cfdb727a | 528 | channel = (TraceChannelComponent) channels[2]; |
a26d90be BH |
529 | // No need to check parameters of default channel because that has been done in other tests |
530 | ||
531 | channel0Events = channel.getChildren(); | |
532 | assertEquals(6, channel0Events.length); | |
cfdb727a | 533 | |
a26d90be | 534 | assertTrue(channel0Events[0] instanceof TraceEventComponent); |
cfdb727a | 535 | |
a26d90be BH |
536 | event = (TraceEventComponent) channel0Events[0]; |
537 | assertEquals("myevent2", event.getName()); | |
538 | assertEquals(TraceLogLevel.TRACE_DEBUG_FUNCTION, event.getLogLevel()); | |
539 | assertEquals(TraceEventType.TRACEPOINT, event.getEventType()); | |
540 | assertEquals(TraceEnablement.ENABLED, event.getState()); | |
541 | ||
542 | // ------------------------------------------------------------------------ | |
543 | // Enable event (loglevel) on channel | |
544 | // ------------------------------------------------------------------------ | |
545 | eventsDialogStub.setLogLevelEventName("myevent0"); | |
546 | eventsDialogStub.setLogLevelType(LogLevelType.LOGLEVEL_ONLY); | |
547 | eventsDialogStub.setLogLevel(TraceLogLevel.TRACE_DEBUG_FUNCTION); | |
cfdb727a | 548 | |
a26d90be | 549 | fFacility.executeCommand(channels[0], "enableEventOnChannel"); |
cfdb727a | 550 | |
a26d90be BH |
551 | // Get Kernel domain component instance |
552 | domains = session.getChildren(); | |
553 | assertNotNull(domains); | |
554 | assertEquals(1, domains.length); | |
555 | ||
556 | // Verify that channel was created with correct data | |
557 | channels = domains[0].getChildren(); | |
cfdb727a | 558 | channel = (TraceChannelComponent) channels[0]; |
a26d90be BH |
559 | // No need to check parameters of default channel because that has been done in other tests |
560 | ||
561 | channel0Events = channel.getChildren(); | |
562 | assertEquals(2, channel0Events.length); | |
cfdb727a | 563 | |
a26d90be | 564 | assertTrue(channel0Events[0] instanceof TraceEventComponent); |
cfdb727a | 565 | |
a26d90be BH |
566 | event = (TraceEventComponent) channel0Events[0]; |
567 | assertEquals("myevent0", event.getName()); | |
568 | assertEquals(TraceLogLevel.TRACE_DEBUG_FUNCTION, event.getLogLevel()); | |
569 | assertEquals(TraceEventType.TRACEPOINT, event.getEventType()); | |
570 | assertEquals(TraceEnablement.ENABLED, event.getState()); | |
cfdb727a | 571 | |
a26d90be | 572 | // ------------------------------------------------------------------------ |
cfdb727a | 573 | // Destroy session |
a26d90be BH |
574 | // ------------------------------------------------------------------------ |
575 | // Initialize session handling scenario | |
576 | fProxy.setScenario(TraceControlTestFacility.SCEN_SCENARIO_SESSION_HANDLING); | |
577 | ||
578 | fFacility.destroySession(session); | |
cfdb727a | 579 | |
a26d90be | 580 | // Verify that no more session components exist |
cc703e6c | 581 | assertEquals("Session components still exist.", 0, groups[1].getChildren().length); |
a26d90be BH |
582 | |
583 | //------------------------------------------------------------------------- | |
584 | // Disconnect node | |
585 | //------------------------------------------------------------------------- | |
586 | fFacility.executeCommand(node, "disconnect"); | |
587 | assertEquals(TargetNodeState.DISCONNECTED, node.getTargetNodeState()); | |
588 | ||
589 | //------------------------------------------------------------------------- | |
590 | // Delete node | |
591 | //------------------------------------------------------------------------- | |
cfdb727a | 592 | |
a26d90be | 593 | fFacility.executeCommand(node, "delete"); |
cc703e6c | 594 | assertEquals("Node not deleted.", 0, fFacility.getControlView().getTraceControlRoot().getChildren().length); |
a26d90be BH |
595 | } |
596 | } |