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