| 1 | /********************************************************************** |
| 2 | * Copyright (c) 2012, 2015 Ericsson |
| 3 | * |
| 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 |
| 8 | * |
| 9 | * Contributors: |
| 10 | * Bernd Hufmann - Initial API and implementation |
| 11 | * Alexandre Montplaisir - Port to JUnit4 |
| 12 | * Markus Schorn - Bug 448058: Use org.eclipse.remote in favor of RSE |
| 13 | **********************************************************************/ |
| 14 | |
| 15 | package org.eclipse.tracecompass.lttng2.control.ui.tests.model.component; |
| 16 | |
| 17 | import static org.junit.Assert.assertEquals; |
| 18 | import static org.junit.Assert.assertNotNull; |
| 19 | import static org.junit.Assert.assertNull; |
| 20 | import static org.junit.Assert.assertTrue; |
| 21 | |
| 22 | import java.io.File; |
| 23 | import java.net.URL; |
| 24 | import java.util.ArrayList; |
| 25 | import java.util.Arrays; |
| 26 | import java.util.List; |
| 27 | |
| 28 | import org.eclipse.core.runtime.FileLocator; |
| 29 | import org.eclipse.core.runtime.ILogListener; |
| 30 | import org.eclipse.core.runtime.IStatus; |
| 31 | import org.eclipse.core.runtime.Path; |
| 32 | import org.eclipse.jdt.annotation.NonNull; |
| 33 | import org.eclipse.remote.core.IRemoteConnection; |
| 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; |
| 37 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceDomainType; |
| 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; |
| 44 | import org.eclipse.tracecompass.internal.lttng2.control.stubs.dialogs.AddContextDialogStub; |
| 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; |
| 51 | import org.eclipse.tracecompass.internal.lttng2.control.ui.Activator; |
| 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; |
| 59 | import org.eclipse.tracecompass.tmf.remote.core.proxy.TmfRemoteConnectionFactory; |
| 60 | import org.eclipse.tracecompass.tmf.ui.tests.shared.WaitUtils; |
| 61 | import org.junit.After; |
| 62 | import org.junit.Before; |
| 63 | import org.junit.Test; |
| 64 | import org.osgi.framework.FrameworkUtil; |
| 65 | |
| 66 | /** |
| 67 | * The class <code>TraceControlUstSessionTests</code> contains UST |
| 68 | * session/channel/event handling test cases. |
| 69 | */ |
| 70 | public class TraceControlUstSessionTest { |
| 71 | |
| 72 | // ------------------------------------------------------------------------ |
| 73 | // Constants |
| 74 | // ------------------------------------------------------------------------ |
| 75 | |
| 76 | private static final String TEST_STREAM = "CreateTreeTest.cfg"; |
| 77 | private static final String SCEN_SCENARIO4_TEST = "Scenario4"; |
| 78 | |
| 79 | // ------------------------------------------------------------------------ |
| 80 | // Test data |
| 81 | // ------------------------------------------------------------------------ |
| 82 | private IRemoteConnection fHost = TmfRemoteConnectionFactory.getLocalConnection(); |
| 83 | private TraceControlTestFacility fFacility; |
| 84 | private @NonNull TestRemoteSystemProxy fProxy = new TestRemoteSystemProxy(fHost); |
| 85 | private String fTestFile; |
| 86 | |
| 87 | // ------------------------------------------------------------------------ |
| 88 | // Housekeeping |
| 89 | // ------------------------------------------------------------------------ |
| 90 | |
| 91 | /** |
| 92 | * Perform pre-test initialization. |
| 93 | * |
| 94 | * @throws Exception |
| 95 | * if the initialization fails for some reason |
| 96 | */ |
| 97 | @Before |
| 98 | public void setUp() throws Exception { |
| 99 | fFacility = TraceControlTestFacility.getInstance(); |
| 100 | fFacility.init(); |
| 101 | URL location = FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path(TraceControlTestFacility.DIRECTORY + File.separator + TEST_STREAM), null); |
| 102 | File testfile = new File(FileLocator.toFileURL(location).toURI()); |
| 103 | fTestFile = testfile.getAbsolutePath(); |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * Perform post-test clean-up. |
| 108 | */ |
| 109 | @After |
| 110 | public void tearDown() { |
| 111 | fFacility.dispose(); |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * Run the TraceControlComponent. |
| 116 | * |
| 117 | * @throws Exception |
| 118 | * This will fail the test |
| 119 | */ |
| 120 | @Test |
| 121 | public void testTraceSessionTree() throws Exception { |
| 122 | |
| 123 | fProxy.setTestFile(fTestFile); |
| 124 | fProxy.setScenario(TraceControlTestFacility.SCEN_INIT_TEST); |
| 125 | |
| 126 | ITraceControlComponent root = fFacility.getControlView().getTraceControlRoot(); |
| 127 | |
| 128 | TargetNodeComponent node = new TargetNodeComponent("myNode", root, fProxy); |
| 129 | |
| 130 | root.addChild(node); |
| 131 | fFacility.waitForJobs(); |
| 132 | |
| 133 | fFacility.executeCommand(node, "connect"); |
| 134 | WaitUtils.waitUntil(new TargetNodeConnectedCondition(node)); |
| 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); |
| 148 | |
| 149 | // ------------------------------------------------------------------------ |
| 150 | // Create session |
| 151 | // ------------------------------------------------------------------------ |
| 152 | TraceSessionComponent session = fFacility.createSession(groups[1]); |
| 153 | |
| 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); |
| 162 | |
| 163 | // ------------------------------------------------------------------------ |
| 164 | // Enable default channel on created session above |
| 165 | // ------------------------------------------------------------------------ |
| 166 | EnableChannelDialogStub channelStub = new EnableChannelDialogStub(); |
| 167 | channelStub.setDomain(TraceDomainType.UST); |
| 168 | TraceControlDialogFactory.getInstance().setEnableChannelDialog(channelStub); |
| 169 | |
| 170 | fFacility.executeCommand(session, "enableChannelOnSession"); |
| 171 | |
| 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()); |
| 178 | assertEquals("Domain buffer Type", BufferType.BUFFER_TYPE_UNKNOWN, ((TraceDomainComponent)domains[0]).getBufferType()); |
| 179 | |
| 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); |
| 186 | TraceChannelComponent channel = (TraceChannelComponent) channels[0]; |
| 187 | assertEquals("mychannel", channel.getName()); |
| 188 | assertEquals(4, channel.getNumberOfSubBuffers()); |
| 189 | assertEquals("mmap()", channel.getOutputType().getInName()); |
| 190 | assertEquals(TraceChannelOutputType.MMAP, channel.getOutputType()); |
| 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 | |
| 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 | |
| 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); |
| 256 | |
| 257 | fFacility.executeCommand(domains[0], "enableChannelOnDomain"); |
| 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); |
| 270 | channel = (TraceChannelComponent) channels[1]; |
| 271 | assertEquals("mychannel2", channel.getName()); |
| 272 | assertEquals(2, channel.getNumberOfSubBuffers()); |
| 273 | assertEquals("mmap()", channel.getOutputType().getInName()); |
| 274 | assertEquals(TraceChannelOutputType.MMAP, channel.getOutputType()); |
| 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); |
| 286 | List<String> events = new ArrayList<>(); |
| 287 | events.add("ust_tests_hello:tptest_sighandler"); |
| 288 | eventsDialogStub.setNames(events); |
| 289 | eventsDialogStub.setDomain(TraceDomainType.UST); |
| 290 | TraceControlDialogFactory.getInstance().setEnableEventsDialog(eventsDialogStub); |
| 291 | |
| 292 | fFacility.executeCommand(session, "enableEventOnSession"); |
| 293 | |
| 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); |
| 305 | channel = (TraceChannelComponent) channels[2]; |
| 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); |
| 311 | |
| 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); |
| 326 | |
| 327 | fFacility.executeCommand(domains[0], "enableEventOnDomain"); |
| 328 | |
| 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(); |
| 336 | channel = (TraceChannelComponent) channels[2]; |
| 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); |
| 341 | |
| 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(); |
| 366 | channel = (TraceChannelComponent) channels[1]; |
| 367 | // No need to check parameters of default channel because that has been done in other tests |
| 368 | |
| 369 | channel = (TraceChannelComponent) channels[1]; |
| 370 | |
| 371 | channel0Events = channel.getChildren(); |
| 372 | assertEquals(1, channel0Events.length); |
| 373 | |
| 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(); |
| 386 | eventsDialogStub.setIsTracePoints(false); |
| 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(); |
| 400 | channel = (TraceChannelComponent) channels[0]; |
| 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); |
| 405 | |
| 406 | assertTrue(channel0Events[0] instanceof TraceEventComponent); |
| 407 | |
| 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(); |
| 418 | eventsDialogStub.setIsTracePoints(false); |
| 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(); |
| 432 | channel = (TraceChannelComponent) channels[0]; |
| 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); |
| 437 | |
| 438 | assertTrue(channel0Events[0] instanceof TraceEventComponent); |
| 439 | |
| 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(); |
| 450 | eventsDialogStub.setIsTracePoints(false); |
| 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(); |
| 464 | channel = (TraceChannelComponent) channels[2]; |
| 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); |
| 469 | |
| 470 | assertTrue(channel0Events[0] instanceof TraceEventComponent); |
| 471 | |
| 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); |
| 484 | eventsDialogStub.setNames(Arrays.asList("myevent1")); |
| 485 | eventsDialogStub.setLogLevelType(LogLevelType.LOGLEVEL); |
| 486 | eventsDialogStub.setLogLevel(TraceLogLevel.TRACE_WARNING); |
| 487 | |
| 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(); |
| 497 | channel = (TraceChannelComponent) channels[2]; |
| 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); |
| 502 | |
| 503 | assertTrue(channel0Events[0] instanceof TraceEventComponent); |
| 504 | |
| 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 | // ------------------------------------------------------------------------ |
| 514 | eventsDialogStub.setNames(Arrays.asList("myevent2")); |
| 515 | eventsDialogStub.setLogLevelType(LogLevelType.LOGLEVEL_ONLY); |
| 516 | eventsDialogStub.setLogLevel(TraceLogLevel.TRACE_DEBUG_FUNCTION); |
| 517 | |
| 518 | fFacility.executeCommand(session, "enableEventOnSession"); |
| 519 | |
| 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(); |
| 527 | channel = (TraceChannelComponent) channels[2]; |
| 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); |
| 532 | |
| 533 | assertTrue(channel0Events[0] instanceof TraceEventComponent); |
| 534 | |
| 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 | // ------------------------------------------------------------------------ |
| 544 | eventsDialogStub.setNames(Arrays.asList("myevent0")); |
| 545 | eventsDialogStub.setLogLevelType(LogLevelType.LOGLEVEL_ONLY); |
| 546 | eventsDialogStub.setLogLevel(TraceLogLevel.TRACE_DEBUG_FUNCTION); |
| 547 | |
| 548 | fFacility.executeCommand(channels[0], "enableEventOnChannel"); |
| 549 | |
| 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(); |
| 557 | channel = (TraceChannelComponent) channels[0]; |
| 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); |
| 562 | |
| 563 | assertTrue(channel0Events[0] instanceof TraceEventComponent); |
| 564 | |
| 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()); |
| 570 | |
| 571 | // ------------------------------------------------------------------------ |
| 572 | // Destroy session |
| 573 | // ------------------------------------------------------------------------ |
| 574 | // Initialize session handling scenario |
| 575 | fProxy.setScenario(TraceControlTestFacility.SCEN_SCENARIO_SESSION_HANDLING); |
| 576 | |
| 577 | fFacility.destroySession(session); |
| 578 | |
| 579 | // Verify that no more session components exist |
| 580 | assertEquals("Session components still exist.", 0, groups[1].getChildren().length); |
| 581 | |
| 582 | //------------------------------------------------------------------------- |
| 583 | // Disconnect node |
| 584 | //------------------------------------------------------------------------- |
| 585 | fFacility.executeCommand(node, "disconnect"); |
| 586 | assertEquals(TargetNodeState.DISCONNECTED, node.getTargetNodeState()); |
| 587 | |
| 588 | //------------------------------------------------------------------------- |
| 589 | // Delete node |
| 590 | //------------------------------------------------------------------------- |
| 591 | |
| 592 | fFacility.executeCommand(node, "delete"); |
| 593 | assertEquals("Node not deleted.", 0, fFacility.getControlView().getTraceControlRoot().getChildren().length); |
| 594 | } |
| 595 | } |