| 1 | /********************************************************************** |
| 2 | * Copyright (c) 2012 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 | **********************************************************************/ |
| 12 | package org.eclipse.linuxtools.lttng.ui.tests.control.model.component; |
| 13 | |
| 14 | import java.io.File; |
| 15 | import java.net.URL; |
| 16 | |
| 17 | import junit.framework.Test; |
| 18 | import junit.framework.TestCase; |
| 19 | import junit.framework.TestSuite; |
| 20 | |
| 21 | import org.eclipse.core.runtime.FileLocator; |
| 22 | import org.eclipse.core.runtime.Path; |
| 23 | import org.eclipse.linuxtools.lttng.stubs.service.TestRemoteSystemProxy; |
| 24 | import org.eclipse.linuxtools.lttng.ui.tests.LTTngUITestPlugin; |
| 25 | import org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceControlComponent; |
| 26 | import org.eclipse.linuxtools.lttng.ui.views.control.model.TargetNodeState; |
| 27 | import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceEnablement; |
| 28 | import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceEventType; |
| 29 | import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceLogLevel; |
| 30 | import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceSessionState; |
| 31 | import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.BaseEventComponent; |
| 32 | import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.KernelProviderComponent; |
| 33 | import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TargetNodeComponent; |
| 34 | import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceChannelComponent; |
| 35 | import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceEventComponent; |
| 36 | import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceProbeEventComponent; |
| 37 | import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceProviderGroup; |
| 38 | import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent; |
| 39 | import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionGroup; |
| 40 | import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.UstProviderComponent; |
| 41 | import org.eclipse.linuxtools.lttng.ui.views.control.service.ILttngControlService; |
| 42 | import org.eclipse.linuxtools.lttng.ui.views.control.service.LTTngControlService; |
| 43 | import org.eclipse.rse.core.model.Host; |
| 44 | import org.eclipse.rse.core.model.IHost; |
| 45 | import org.eclipse.rse.internal.core.model.SystemProfile; |
| 46 | import org.eclipse.swt.graphics.Image; |
| 47 | import org.junit.After; |
| 48 | import org.junit.Before; |
| 49 | |
| 50 | /** |
| 51 | * The class <code>TraceControlTreeModelTest</code> contains tests for the tree component classes. |
| 52 | */ |
| 53 | @SuppressWarnings("nls") |
| 54 | public class TraceControlTreeModelTest extends TestCase { |
| 55 | |
| 56 | private static final String DIRECTORY = "testfiles"; |
| 57 | private static final String TEST_STREAM = "ListInfoTest.cfg"; |
| 58 | private static final String SCEN_LIST_INFO_TEST = "ListInfoTest"; |
| 59 | |
| 60 | // ------------------------------------------------------------------------ |
| 61 | // Test data |
| 62 | // ------------------------------------------------------------------------ |
| 63 | |
| 64 | private TestRemoteSystemProxy fProxy; |
| 65 | private String fTestFile; |
| 66 | |
| 67 | // ------------------------------------------------------------------------ |
| 68 | // Static methods |
| 69 | // ------------------------------------------------------------------------ |
| 70 | |
| 71 | /** |
| 72 | * Returns test setup used when executing test case stand-alone. |
| 73 | * @return Test setup class |
| 74 | */ |
| 75 | public static Test suite() { |
| 76 | return new ModelImplTestSetup(new TestSuite(TraceControlTreeModelTest.class)); |
| 77 | } |
| 78 | |
| 79 | // ------------------------------------------------------------------------ |
| 80 | // Housekeeping |
| 81 | // ------------------------------------------------------------------------ |
| 82 | |
| 83 | /** |
| 84 | * Perform pre-test initialization. |
| 85 | * |
| 86 | * @throws Exception |
| 87 | * if the initialization fails for some reason |
| 88 | * |
| 89 | */ |
| 90 | @Override |
| 91 | @Before |
| 92 | public void setUp() throws Exception { |
| 93 | fProxy = new TestRemoteSystemProxy(); |
| 94 | URL location = FileLocator.find(LTTngUITestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null); |
| 95 | File testfile = new File(FileLocator.toFileURL(location).toURI()); |
| 96 | fTestFile = testfile.getAbsolutePath(); |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Perform post-test clean-up. |
| 101 | * |
| 102 | * @throws Exception |
| 103 | * if the clean-up fails for some reason |
| 104 | * |
| 105 | */ |
| 106 | @Override |
| 107 | @After |
| 108 | public void tearDown() throws Exception { |
| 109 | } |
| 110 | |
| 111 | /** |
| 112 | * Run the TraceControlComponent. |
| 113 | */ |
| 114 | public void testTraceControlComponents() |
| 115 | throws Exception { |
| 116 | |
| 117 | fProxy.setTestFile(fTestFile); |
| 118 | fProxy.setScenario(SCEN_LIST_INFO_TEST); |
| 119 | |
| 120 | ITraceControlComponent root = TraceControlTestFacility.getInstance().getControlView().getTraceControlRoot(); |
| 121 | |
| 122 | @SuppressWarnings("restriction") |
| 123 | IHost host = new Host(new SystemProfile("myProfile", true)); |
| 124 | host.setHostName("127.0.0.1"); |
| 125 | |
| 126 | TargetNodeComponent node = new TargetNodeComponent("myNode", root, host, fProxy); |
| 127 | |
| 128 | root.addChild(node); |
| 129 | node.connect(); |
| 130 | |
| 131 | TraceControlTestFacility.getInstance().waitForJobs(); |
| 132 | |
| 133 | // ------------------------------------------------------------------------ |
| 134 | // Verify Parameters of TargetNodeComponent |
| 135 | // ------------------------------------------------------------------------ |
| 136 | assertEquals("127.0.0.1", node.getHostName()); |
| 137 | assertEquals("127.0.0.1", node.getToolTip()); |
| 138 | Image connectedImage = node.getImage(); |
| 139 | assertNotNull(connectedImage); |
| 140 | assertEquals(TargetNodeState.CONNECTED, node.getTargetNodeState()); |
| 141 | assertNotNull(node.getControlService()); |
| 142 | ILttngControlService service = node.getControlService(); |
| 143 | assertTrue(service instanceof LTTngControlService); |
| 144 | node.setControlService(service); |
| 145 | assertTrue(node.getControlService() instanceof LTTngControlService); |
| 146 | |
| 147 | assertTrue(node.isPassiveCommunicationsListener()); |
| 148 | |
| 149 | // ------------------------------------------------------------------------ |
| 150 | // Verify Children of TargetNodeComponent |
| 151 | // ------------------------------------------------------------------------ |
| 152 | ITraceControlComponent[] groups = node.getChildren(); |
| 153 | assertNotNull(groups); |
| 154 | assertEquals(2, groups.length); |
| 155 | |
| 156 | assertTrue(groups[0] instanceof TraceProviderGroup); |
| 157 | assertTrue(groups[1] instanceof TraceSessionGroup); |
| 158 | |
| 159 | assertEquals("Provider", groups[0].getName()); |
| 160 | assertEquals("Sessions", groups[1].getName()); |
| 161 | |
| 162 | // ------------------------------------------------------------------------ |
| 163 | // Verify TraceProviderGroup |
| 164 | // ------------------------------------------------------------------------ |
| 165 | ITraceControlComponent[] providers = groups[0].getChildren(); |
| 166 | |
| 167 | assertNotNull(providers); |
| 168 | assertEquals(3, providers.length); |
| 169 | |
| 170 | // ------------------------------------------------------------------------ |
| 171 | // Verify UstProviderComponent |
| 172 | // ------------------------------------------------------------------------ |
| 173 | KernelProviderComponent kernelProvider = (KernelProviderComponent) providers[0]; |
| 174 | |
| 175 | // ------------------------------------------------------------------------ |
| 176 | // Verify event info (kernel provider) |
| 177 | // ------------------------------------------------------------------------ |
| 178 | ITraceControlComponent[] events = kernelProvider.getChildren(); |
| 179 | assertNotNull(events); |
| 180 | assertEquals(3, events.length); |
| 181 | |
| 182 | BaseEventComponent baseEventInfo = (BaseEventComponent) events[0]; |
| 183 | assertNotNull(baseEventInfo); |
| 184 | assertEquals("sched_kthread_stop", baseEventInfo.getName()); |
| 185 | assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel()); |
| 186 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); |
| 187 | |
| 188 | baseEventInfo = (BaseEventComponent) events[1]; |
| 189 | assertEquals("sched_kthread_stop_ret", baseEventInfo.getName()); |
| 190 | assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel()); |
| 191 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); |
| 192 | |
| 193 | baseEventInfo = (BaseEventComponent) events[2]; |
| 194 | assertEquals("sched_wakeup_new", baseEventInfo.getName()); |
| 195 | assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel()); |
| 196 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); |
| 197 | |
| 198 | // ------------------------------------------------------------------------ |
| 199 | // Verify UstProviderComponent |
| 200 | // ------------------------------------------------------------------------ |
| 201 | UstProviderComponent ustProvider = (UstProviderComponent) providers[1]; |
| 202 | assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", ustProvider.getName()); |
| 203 | assertEquals(9379, ustProvider.getPid()); |
| 204 | |
| 205 | // ------------------------------------------------------------------------ |
| 206 | // Verify event info (UST provider) |
| 207 | // ------------------------------------------------------------------------ |
| 208 | events = ustProvider.getChildren(); |
| 209 | assertNotNull(events); |
| 210 | assertEquals(2, events.length); |
| 211 | |
| 212 | baseEventInfo = (BaseEventComponent) events[0]; |
| 213 | assertNotNull(baseEventInfo); |
| 214 | assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo.getName()); |
| 215 | assertEquals(TraceLogLevel.TRACE_DEBUG_MODULE, baseEventInfo.getLogLevel()); |
| 216 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); |
| 217 | |
| 218 | baseEventInfo = (BaseEventComponent) events[1]; |
| 219 | assertEquals("ust_tests_hello:tptest", baseEventInfo.getName()); |
| 220 | assertEquals(TraceLogLevel.TRACE_INFO, baseEventInfo.getLogLevel()); |
| 221 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); |
| 222 | |
| 223 | // ------------------------------------------------------------------------ |
| 224 | // Verify UstProviderComponent |
| 225 | // ------------------------------------------------------------------------ |
| 226 | ustProvider = (UstProviderComponent) providers[2]; |
| 227 | assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", ustProvider.getName()); |
| 228 | assertEquals(4852, ustProvider.getPid()); |
| 229 | |
| 230 | // verify getters and setter |
| 231 | verifyUstProviderGettersSetters(ustProvider); |
| 232 | |
| 233 | // ------------------------------------------------------------------------ |
| 234 | // Verify event info (UST provider) |
| 235 | // ------------------------------------------------------------------------ |
| 236 | events = ustProvider.getChildren(); |
| 237 | assertNotNull(events); |
| 238 | assertEquals(2, events.length); |
| 239 | |
| 240 | baseEventInfo = (BaseEventComponent) events[0]; |
| 241 | assertNotNull(baseEventInfo); |
| 242 | assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo.getName()); |
| 243 | assertEquals(TraceLogLevel.TRACE_WARNING, baseEventInfo.getLogLevel()); |
| 244 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); |
| 245 | |
| 246 | baseEventInfo = (BaseEventComponent) events[1]; |
| 247 | assertEquals("ust_tests_hello:tptest", baseEventInfo.getName()); |
| 248 | assertEquals(TraceLogLevel.TRACE_DEBUG_FUNCTION, baseEventInfo.getLogLevel()); |
| 249 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); |
| 250 | |
| 251 | // verify getters and setters |
| 252 | verifyBaseEventGettersSetters(baseEventInfo); |
| 253 | |
| 254 | // ------------------------------------------------------------------------ |
| 255 | // Verify TraceSessionGroup |
| 256 | // ------------------------------------------------------------------------ |
| 257 | ITraceControlComponent[] sessions = groups[1].getChildren(); |
| 258 | assertNotNull(sessions); |
| 259 | assertEquals(2, sessions.length); |
| 260 | for (int i = 0; i < sessions.length; i++) { |
| 261 | assertTrue(sessions[i] instanceof TraceSessionComponent); |
| 262 | } |
| 263 | assertEquals("mysession1", sessions[0].getName()); |
| 264 | assertEquals("mysession", sessions[1].getName()); |
| 265 | |
| 266 | // ------------------------------------------------------------------------ |
| 267 | // Verify TraceSessionComponent |
| 268 | // ------------------------------------------------------------------------ |
| 269 | TraceSessionComponent session = (TraceSessionComponent)sessions[1]; |
| 270 | assertEquals("mysession", session.getName()); |
| 271 | assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session.getSessionPath()); |
| 272 | assertEquals(TraceSessionState.ACTIVE, session.getSessionState()); |
| 273 | |
| 274 | // Verify setters and setters |
| 275 | verifySessionGetterSetters(session); |
| 276 | |
| 277 | ITraceControlComponent[] domains = session.getChildren(); |
| 278 | assertNotNull(domains); |
| 279 | assertEquals(2, domains.length); |
| 280 | |
| 281 | // ------------------------------------------------------------------------ |
| 282 | // Verify Kernel domain |
| 283 | // ------------------------------------------------------------------------ |
| 284 | assertEquals("Kernel", domains[0].getName()); |
| 285 | ITraceControlComponent[] channels = domains[0].getChildren(); |
| 286 | assertNotNull(channels); |
| 287 | assertEquals(2, channels.length); |
| 288 | |
| 289 | // ------------------------------------------------------------------------ |
| 290 | // Verify Kernel's channel0 |
| 291 | // ------------------------------------------------------------------------ |
| 292 | assertTrue(channels[0] instanceof TraceChannelComponent); |
| 293 | TraceChannelComponent channel = (TraceChannelComponent) channels[0]; |
| 294 | assertEquals("channel0", channel.getName()); |
| 295 | assertEquals(4, channel.getNumberOfSubBuffers()); |
| 296 | assertEquals("splice()", channel.getOutputType()); |
| 297 | assertEquals(false, channel.isOverwriteMode()); |
| 298 | assertEquals(200, channel.getReadTimer()); |
| 299 | assertEquals(TraceEnablement.ENABLED, channel.getState()); |
| 300 | assertEquals(262144, channel.getSubBufferSize()); |
| 301 | assertEquals(0, channel.getSwitchTimer()); |
| 302 | |
| 303 | // ------------------------------------------------------------------------ |
| 304 | // Verify event info (kernel, channel0) |
| 305 | // ------------------------------------------------------------------------ |
| 306 | ITraceControlComponent[] channel0Events = channel.getChildren(); |
| 307 | assertNotNull(channel0Events); |
| 308 | assertEquals(5, channel0Events.length); |
| 309 | assertTrue(channel0Events[0] instanceof TraceEventComponent); |
| 310 | assertTrue(channel0Events[1] instanceof TraceEventComponent); |
| 311 | assertTrue(channel0Events[2] instanceof TraceProbeEventComponent); |
| 312 | assertTrue(channel0Events[3] instanceof TraceProbeEventComponent); |
| 313 | assertTrue(channel0Events[4] instanceof TraceEventComponent); |
| 314 | |
| 315 | TraceEventComponent event = (TraceEventComponent) channel0Events[0]; |
| 316 | assertEquals("block_rq_remap", event.getName()); |
| 317 | assertEquals(TraceLogLevel.TRACE_EMERG, event.getLogLevel()); |
| 318 | assertEquals(TraceEventType.TRACEPOINT, event.getEventType()); |
| 319 | assertEquals(TraceEnablement.ENABLED, event.getState()); |
| 320 | |
| 321 | event = (TraceEventComponent) channel0Events[1]; |
| 322 | assertEquals("block_bio_remap", event.getName()); |
| 323 | assertEquals(TraceLogLevel.TRACE_EMERG, event.getLogLevel()); |
| 324 | assertEquals(TraceEventType.TRACEPOINT, event.getEventType()); |
| 325 | assertEquals(TraceEnablement.DISABLED, event.getState()); |
| 326 | |
| 327 | TraceProbeEventComponent probeEvent = (TraceProbeEventComponent) channel0Events[2]; |
| 328 | assertEquals("myevent2", probeEvent.getName()); |
| 329 | assertEquals(TraceLogLevel.LEVEL_UNKNOWN, probeEvent.getLogLevel()); |
| 330 | assertEquals(TraceEventType.PROBE, probeEvent.getEventType()); |
| 331 | assertEquals(TraceEnablement.ENABLED, probeEvent.getState()); |
| 332 | assertEquals("0xc0101340", probeEvent.getAddress()); |
| 333 | assertNull(probeEvent.getOffset()); |
| 334 | assertNull(probeEvent.getSymbol()); |
| 335 | |
| 336 | probeEvent = (TraceProbeEventComponent) channel0Events[3]; |
| 337 | assertEquals("myevent0", probeEvent.getName()); |
| 338 | assertEquals(TraceLogLevel.LEVEL_UNKNOWN, probeEvent.getLogLevel()); |
| 339 | assertEquals(TraceEventType.PROBE, probeEvent.getEventType()); |
| 340 | assertEquals(TraceEnablement.ENABLED, probeEvent.getState()); |
| 341 | assertNull(probeEvent.getAddress()); |
| 342 | assertEquals("0x0", probeEvent.getOffset()); |
| 343 | assertEquals("init_post", probeEvent.getSymbol()); |
| 344 | |
| 345 | event = (TraceEventComponent) channel0Events[4]; |
| 346 | assertEquals("syscalls", event.getName()); |
| 347 | assertEquals(TraceLogLevel.LEVEL_UNKNOWN, event.getLogLevel()); |
| 348 | assertEquals(TraceEventType.SYSCALL, event.getEventType()); |
| 349 | assertEquals(TraceEnablement.ENABLED, event.getState()); |
| 350 | |
| 351 | // ------------------------------------------------------------------------ |
| 352 | // Verify Kernel's channel1 |
| 353 | // ------------------------------------------------------------------------ |
| 354 | assertEquals("channel1", channels[1].getName()); |
| 355 | channel = (TraceChannelComponent) channels[1]; |
| 356 | assertEquals(4, channel.getNumberOfSubBuffers()); |
| 357 | assertEquals("splice()", channel.getOutputType()); |
| 358 | assertEquals(true, channel.isOverwriteMode()); |
| 359 | assertEquals(400, channel.getReadTimer()); |
| 360 | assertEquals(TraceEnablement.DISABLED, channel.getState()); |
| 361 | assertEquals(524288, channel.getSubBufferSize()); |
| 362 | assertEquals(100, channel.getSwitchTimer()); |
| 363 | |
| 364 | // ------------------------------------------------------------------------ |
| 365 | // Verify event info (kernel, channel1) |
| 366 | // ------------------------------------------------------------------------ |
| 367 | ITraceControlComponent[] channel1Events = channels[1].getChildren(); |
| 368 | assertEquals(0, channel1Events.length); |
| 369 | |
| 370 | // ------------------------------------------------------------------------ |
| 371 | // Verify domain UST global |
| 372 | // ------------------------------------------------------------------------ |
| 373 | assertEquals("UST global", domains[1].getName()); |
| 374 | |
| 375 | ITraceControlComponent[] ustChannels = domains[1].getChildren(); |
| 376 | |
| 377 | for (int i = 0; i < ustChannels.length; i++) { |
| 378 | assertTrue(ustChannels[i] instanceof TraceChannelComponent); |
| 379 | } |
| 380 | |
| 381 | // ------------------------------------------------------------------------ |
| 382 | // Verify UST global's mychannel1 |
| 383 | // ------------------------------------------------------------------------ |
| 384 | channel = (TraceChannelComponent) ustChannels[0]; |
| 385 | assertEquals("mychannel1", channel.getName()); |
| 386 | assertEquals(8, channel.getNumberOfSubBuffers()); |
| 387 | assertEquals("mmap()", channel.getOutputType()); |
| 388 | assertEquals(true, channel.isOverwriteMode()); |
| 389 | assertEquals(100, channel.getReadTimer()); |
| 390 | assertEquals(TraceEnablement.DISABLED, channel.getState()); |
| 391 | assertEquals(8192, channel.getSubBufferSize()); |
| 392 | assertEquals(200, channel.getSwitchTimer()); |
| 393 | |
| 394 | // verify getters and setters |
| 395 | verifyChannelGettersSetters(channel); |
| 396 | |
| 397 | // ------------------------------------------------------------------------ |
| 398 | // Verify event info (UST global, mychannel1) |
| 399 | // ------------------------------------------------------------------------ |
| 400 | ITraceControlComponent[] ustEvents = channel.getChildren(); |
| 401 | assertEquals(0, ustEvents.length); |
| 402 | |
| 403 | // ------------------------------------------------------------------------ |
| 404 | // Verify UST global's channel0 |
| 405 | // ------------------------------------------------------------------------ |
| 406 | channel = (TraceChannelComponent) ustChannels[1]; |
| 407 | assertEquals("channel0", channel.getName()); |
| 408 | assertEquals(4, channel.getNumberOfSubBuffers()); |
| 409 | assertEquals("mmap()", channel.getOutputType()); |
| 410 | assertEquals(false, channel.isOverwriteMode()); |
| 411 | assertEquals(200, channel.getReadTimer()); |
| 412 | assertEquals(TraceEnablement.ENABLED, channel.getState()); |
| 413 | assertEquals(4096, channel.getSubBufferSize()); |
| 414 | assertEquals(0, channel.getSwitchTimer()); |
| 415 | |
| 416 | // ------------------------------------------------------------------------ |
| 417 | // Verify event info (UST global, channel0) |
| 418 | // ------------------------------------------------------------------------ |
| 419 | ustEvents = channel.getChildren(); |
| 420 | assertEquals(2, ustEvents.length); |
| 421 | |
| 422 | event = (TraceEventComponent) ustEvents[0]; |
| 423 | assertEquals("ust_tests_hello:tptest_sighandler", event.getName()); |
| 424 | assertEquals(TraceLogLevel.TRACE_DEBUG_LINE, event.getLogLevel()); |
| 425 | assertEquals(TraceEventType.TRACEPOINT, event.getEventType()); |
| 426 | assertEquals(TraceEnablement.DISABLED, event.getState()); |
| 427 | |
| 428 | event = (TraceEventComponent) ustEvents[1]; |
| 429 | assertEquals("*", ustEvents[1].getName()); |
| 430 | assertEquals(TraceLogLevel.LEVEL_UNKNOWN, event.getLogLevel()); |
| 431 | assertEquals(TraceEventType.TRACEPOINT, event.getEventType()); |
| 432 | assertEquals(TraceEnablement.ENABLED, event.getState()); |
| 433 | |
| 434 | // verify getters and setters |
| 435 | verifyEventGettersSetters(event); |
| 436 | |
| 437 | // disconnect |
| 438 | node.disconnect(); |
| 439 | assertEquals(TargetNodeState.DISCONNECTED, node.getTargetNodeState()); |
| 440 | assertNotNull(node.getImage()); |
| 441 | assertNotSame(connectedImage, node.getImage()); |
| 442 | } |
| 443 | |
| 444 | private void verifySessionGetterSetters(TraceSessionComponent session) { |
| 445 | // save original values |
| 446 | String name = session.getName(); |
| 447 | String origPath = session.getSessionPath(); |
| 448 | TraceSessionState origState = session.getSessionState(); |
| 449 | |
| 450 | // test cases |
| 451 | session.setName("newName"); |
| 452 | assertEquals("newName", session.getName()); |
| 453 | |
| 454 | session.setSessionPath("/home/user/tmp"); |
| 455 | assertEquals("/home/user/tmp", session.getSessionPath()); |
| 456 | |
| 457 | session.setSessionState(TraceSessionState.INACTIVE); |
| 458 | assertEquals(TraceSessionState.INACTIVE, session.getSessionState()); |
| 459 | Image inactiveImage = session.getImage(); |
| 460 | assertNotNull(inactiveImage); |
| 461 | |
| 462 | session.setSessionState("active"); |
| 463 | assertEquals(TraceSessionState.ACTIVE, session.getSessionState()); |
| 464 | |
| 465 | Image activeImage = session.getImage(); |
| 466 | assertNotNull(activeImage); |
| 467 | assertNotSame(activeImage, inactiveImage); |
| 468 | |
| 469 | |
| 470 | // restore original values |
| 471 | session.setName(name); |
| 472 | session.setSessionPath(origPath); |
| 473 | session.setSessionState(origState); |
| 474 | } |
| 475 | |
| 476 | private void verifyBaseEventGettersSetters(BaseEventComponent event) { |
| 477 | // save original values |
| 478 | String name = event.getName(); |
| 479 | TraceLogLevel level = event.getLogLevel(); |
| 480 | TraceEventType type = event.getEventType(); |
| 481 | |
| 482 | // test cases |
| 483 | event.setName("newName"); |
| 484 | assertEquals("newName", event.getName()); |
| 485 | |
| 486 | event.setLogLevel(TraceLogLevel.TRACE_INFO); |
| 487 | assertEquals(TraceLogLevel.TRACE_INFO, event.getLogLevel()); |
| 488 | event.setLogLevel("TRACE_ALERT"); |
| 489 | assertEquals(TraceLogLevel.TRACE_ALERT, event.getLogLevel()); |
| 490 | |
| 491 | event.setEventType(TraceEventType.UNKNOWN); |
| 492 | assertEquals(TraceEventType.UNKNOWN, event.getEventType()); |
| 493 | event.setEventType("tracepoint"); |
| 494 | assertEquals(TraceEventType.TRACEPOINT, event.getEventType()); |
| 495 | |
| 496 | // restore original values |
| 497 | event.setName(name); |
| 498 | event.setLogLevel(level); |
| 499 | event.setEventType(type); |
| 500 | } |
| 501 | |
| 502 | private void verifyEventGettersSetters(TraceEventComponent event) { |
| 503 | // save original values |
| 504 | String name = event.getName(); |
| 505 | TraceLogLevel level = event.getLogLevel(); |
| 506 | TraceEventType type = event.getEventType(); |
| 507 | TraceEnablement state = event.getState(); |
| 508 | |
| 509 | // test cases |
| 510 | event.setName("newName"); |
| 511 | assertEquals("newName", event.getName()); |
| 512 | |
| 513 | event.setLogLevel(TraceLogLevel.TRACE_INFO); |
| 514 | assertEquals(TraceLogLevel.TRACE_INFO, event.getLogLevel()); |
| 515 | event.setLogLevel("TRACE_ALERT"); |
| 516 | assertEquals(TraceLogLevel.TRACE_ALERT, event.getLogLevel()); |
| 517 | |
| 518 | event.setEventType(TraceEventType.UNKNOWN); |
| 519 | assertEquals(TraceEventType.UNKNOWN, event.getEventType()); |
| 520 | event.setEventType("tracepoint"); |
| 521 | assertEquals(TraceEventType.TRACEPOINT, event.getEventType()); |
| 522 | |
| 523 | event.setState("disabled"); |
| 524 | assertEquals(TraceEnablement.DISABLED, event.getState()); |
| 525 | |
| 526 | Image disabledImage = event.getImage(); |
| 527 | assertNotNull(disabledImage); |
| 528 | |
| 529 | event.setState(TraceEnablement.ENABLED); |
| 530 | assertEquals(TraceEnablement.ENABLED, event.getState()); |
| 531 | |
| 532 | Image enabledImage = event.getImage(); |
| 533 | assertNotNull(enabledImage); |
| 534 | assertNotSame(enabledImage, disabledImage); |
| 535 | |
| 536 | // restore original values |
| 537 | event.setName(name); |
| 538 | event.setLogLevel(level); |
| 539 | event.setEventType(type); |
| 540 | event.setState(state); |
| 541 | } |
| 542 | |
| 543 | private void verifyChannelGettersSetters(TraceChannelComponent channel) { |
| 544 | // save original values |
| 545 | String name = channel.getName(); |
| 546 | int nbSubBuffers = channel.getNumberOfSubBuffers(); |
| 547 | String type = channel.getOutputType(); |
| 548 | boolean mode = channel.isOverwriteMode(); |
| 549 | long readTimer = channel.getReadTimer(); |
| 550 | TraceEnablement state = channel.getState(); |
| 551 | long subBufferSize = channel.getSubBufferSize(); |
| 552 | long switchTimer = channel.getSwitchTimer(); |
| 553 | |
| 554 | // test cases |
| 555 | channel.setName("newName"); |
| 556 | assertEquals("newName", channel.getName()); |
| 557 | |
| 558 | channel.setNumberOfSubBuffers(2); |
| 559 | assertEquals(2, channel.getNumberOfSubBuffers()); |
| 560 | |
| 561 | channel.setOutputType("splice()"); |
| 562 | assertEquals("splice()", channel.getOutputType()); |
| 563 | |
| 564 | channel.setOverwriteMode(false); |
| 565 | assertEquals(false, channel.isOverwriteMode()); |
| 566 | |
| 567 | channel.setReadTimer(250); |
| 568 | assertEquals(250, channel.getReadTimer()); |
| 569 | |
| 570 | channel.setState("enabled"); |
| 571 | assertEquals(TraceEnablement.ENABLED, channel.getState()); |
| 572 | |
| 573 | Image enabledImage = channel.getImage(); |
| 574 | assertNotNull(enabledImage); |
| 575 | channel.setState(TraceEnablement.DISABLED); |
| 576 | assertEquals(TraceEnablement.DISABLED, channel.getState()); |
| 577 | |
| 578 | Image disabledImage = channel.getImage(); |
| 579 | assertNotNull(disabledImage); |
| 580 | assertNotSame(enabledImage, disabledImage); |
| 581 | |
| 582 | channel.setSubBufferSize(1024); |
| 583 | assertEquals(1024, channel.getSubBufferSize()); |
| 584 | |
| 585 | channel.setSwitchTimer(1000); |
| 586 | assertEquals(1000, channel.getSwitchTimer()); |
| 587 | |
| 588 | // restore original values |
| 589 | channel.setName(name); |
| 590 | channel.setNumberOfSubBuffers(nbSubBuffers); |
| 591 | channel.setOutputType(type); |
| 592 | channel.setOverwriteMode(mode); |
| 593 | channel.setReadTimer(readTimer); |
| 594 | channel.setState(state); |
| 595 | channel.setSubBufferSize(subBufferSize); |
| 596 | channel.setSwitchTimer(switchTimer); |
| 597 | } |
| 598 | |
| 599 | private void verifyUstProviderGettersSetters(UstProviderComponent ustProvider) { |
| 600 | // save original values |
| 601 | String name = ustProvider.getName(); |
| 602 | int pid = ustProvider.getPid(); |
| 603 | |
| 604 | // test cases |
| 605 | ustProvider.setName("newName"); |
| 606 | assertEquals("newName", ustProvider.getName()); |
| 607 | |
| 608 | ustProvider.setPid(9876); |
| 609 | assertEquals(9876, ustProvider.getPid()); |
| 610 | |
| 611 | // restore original values |
| 612 | ustProvider.setName(name); |
| 613 | ustProvider.setPid(pid); |
| 614 | } |
| 615 | |
| 616 | } |