| 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.service; |
| 13 | |
| 14 | import java.io.File; |
| 15 | import java.net.URL; |
| 16 | import java.util.ArrayList; |
| 17 | import java.util.List; |
| 18 | |
| 19 | import junit.framework.TestCase; |
| 20 | |
| 21 | import org.eclipse.core.commands.ExecutionException; |
| 22 | import org.eclipse.core.runtime.FileLocator; |
| 23 | import org.eclipse.core.runtime.NullProgressMonitor; |
| 24 | import org.eclipse.core.runtime.Path; |
| 25 | import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IBaseEventInfo; |
| 26 | import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IChannelInfo; |
| 27 | import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IDomainInfo; |
| 28 | import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IEventInfo; |
| 29 | import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ISessionInfo; |
| 30 | import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IUstProviderInfo; |
| 31 | import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.LogLevelType; |
| 32 | import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEnablement; |
| 33 | import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceEventType; |
| 34 | import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceLogLevel; |
| 35 | import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceSessionState; |
| 36 | import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.ChannelInfo; |
| 37 | import org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ILttngControlService; |
| 38 | import org.eclipse.linuxtools.internal.lttng.ui.views.control.service.LTTngControlService; |
| 39 | import org.eclipse.linuxtools.lttng.stubs.service.CommandShellFactory; |
| 40 | import org.eclipse.linuxtools.lttng.stubs.service.shells.LTTngToolsFileShell; |
| 41 | import org.eclipse.linuxtools.lttng.ui.tests.LTTngUITestPlugin; |
| 42 | /** |
| 43 | * The class <code>LTTngControlServiceTest</code> contains test for the class <code>{@link LTTngControlService}</code>. |
| 44 | */ |
| 45 | @SuppressWarnings("nls") |
| 46 | public class LTTngControlServiceTest extends TestCase { |
| 47 | |
| 48 | private static final String DIRECTORY = "testfiles"; |
| 49 | private static final String TEST_STREAM = "LTTngServiceTest.cfg"; |
| 50 | |
| 51 | private static final String SCEN_LTTNG_NOT_INSTALLED = "LttngNotInstalled"; |
| 52 | private static final String SCEN_NO_SESSION_AVAILABLE = "NoSessionAvailable"; |
| 53 | private static final String SCEN_GET_SESSION_NAMES1 = "GetSessionNames1"; |
| 54 | private static final String SCEN_GET_SESSION_NAME_NOT_EXIST = "GetSessionNameNotExist"; |
| 55 | private static final String SCEN_GET_SESSION_GARBAGE_OUT = "GetSessionGarbageOut"; |
| 56 | private static final String SCEN_GET_SESSION1 = "GetSession1"; |
| 57 | private static final String SCEN_GET_KERNEL_PROVIDER1 = "GetKernelProvider1"; |
| 58 | private static final String SCEN_GET_UST_PROVIDER1 = "GetUstProvider1"; |
| 59 | private static final String SCEN_GET_UST_PROVIDER2 = "GetUstProvider2"; |
| 60 | private static final String SCEN_CREATE_SESSION1 = "CreateSession1"; |
| 61 | private static final String SCEN_CREATE_SESSION_VARIANTS = "CreateSessionVariants"; |
| 62 | private static final String SCEN_DESTROY_SESSION1 = "DestroySession1"; |
| 63 | private static final String SCEN_CHANNEL_HANDLING = "ChannelHandling"; |
| 64 | private static final String SCEN_EVENT_HANDLING = "EventHandling"; |
| 65 | |
| 66 | // ------------------------------------------------------------------------ |
| 67 | // Test data |
| 68 | // ------------------------------------------------------------------------ |
| 69 | private CommandShellFactory fShellFactory; |
| 70 | private String fTestfile; |
| 71 | private LTTngToolsFileShell fShell; |
| 72 | private ILttngControlService fService; |
| 73 | |
| 74 | |
| 75 | // ------------------------------------------------------------------------ |
| 76 | // Static methods |
| 77 | // ------------------------------------------------------------------------ |
| 78 | |
| 79 | // ------------------------------------------------------------------------ |
| 80 | // Housekeeping |
| 81 | // ------------------------------------------------------------------------ |
| 82 | /** |
| 83 | * Perform pre-test initialization. |
| 84 | * |
| 85 | * @throws Exception if the initialization fails for some reason |
| 86 | * |
| 87 | */ |
| 88 | @Override |
| 89 | public void setUp() throws Exception { |
| 90 | super.setUp(); |
| 91 | fShellFactory = CommandShellFactory.getInstance(); |
| 92 | |
| 93 | URL location = FileLocator.find(LTTngUITestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null); |
| 94 | File testfile = new File(FileLocator.toFileURL(location).toURI()); |
| 95 | fTestfile = testfile.getAbsolutePath(); |
| 96 | |
| 97 | fShell = fShellFactory.getFileShell(); |
| 98 | fShell.loadScenarioFile(fTestfile); |
| 99 | fService = new LTTngControlService(fShell); |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Perform post-test clean-up. |
| 104 | * |
| 105 | * @throws Exception if the clean-up fails for some reason |
| 106 | * |
| 107 | */ |
| 108 | @Override |
| 109 | public void tearDown() throws Exception { |
| 110 | } |
| 111 | |
| 112 | // ------------------------------------------------------------------------ |
| 113 | // Test Cases |
| 114 | // ------------------------------------------------------------------------ |
| 115 | |
| 116 | public void testGetSessionNames() { |
| 117 | try { |
| 118 | fShell.setScenario(SCEN_LTTNG_NOT_INSTALLED); |
| 119 | fService.getSessionNames(new NullProgressMonitor()); |
| 120 | fail("No exeption thrown"); |
| 121 | } catch (ExecutionException e) { |
| 122 | // success |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | public void testGetSessionNames1() { |
| 127 | try { |
| 128 | fShell.setScenario(SCEN_NO_SESSION_AVAILABLE); |
| 129 | String[] result = fService.getSessionNames(new NullProgressMonitor()); |
| 130 | |
| 131 | assertNotNull(result); |
| 132 | assertEquals(0, result.length); |
| 133 | |
| 134 | } catch (ExecutionException e) { |
| 135 | fail(e.toString()); |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | public void testGetSessionNames2() { |
| 140 | try { |
| 141 | fShell.setScenario(SCEN_GET_SESSION_NAMES1); |
| 142 | String[] result = fService.getSessionNames(new NullProgressMonitor()); |
| 143 | |
| 144 | assertNotNull(result); |
| 145 | assertEquals(2, result.length); |
| 146 | assertEquals("mysession1", result[0]); |
| 147 | assertEquals("mysession", result[1]); |
| 148 | |
| 149 | } catch (ExecutionException e) { |
| 150 | fail(e.toString()); |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | public void testGetSessionNotExist() { |
| 155 | try { |
| 156 | fShell.setScenario(SCEN_GET_SESSION_NAME_NOT_EXIST); |
| 157 | fService.getSessionNames(new NullProgressMonitor()); |
| 158 | fail("No exeption thrown"); |
| 159 | |
| 160 | } catch (ExecutionException e) { |
| 161 | // success |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | public void testGetSessionNameGarbage() { |
| 166 | try { |
| 167 | fShell.setScenario(SCEN_GET_SESSION_GARBAGE_OUT); |
| 168 | String[] result = fService.getSessionNames(new NullProgressMonitor()); |
| 169 | |
| 170 | assertNotNull(result); |
| 171 | assertEquals(0, result.length); |
| 172 | |
| 173 | } catch (ExecutionException e) { |
| 174 | fail(e.toString()); |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | public void testGetSession1() { |
| 179 | try { |
| 180 | fShell.setScenario(SCEN_GET_SESSION1); |
| 181 | ISessionInfo session = fService.getSession("mysession", new NullProgressMonitor()); |
| 182 | |
| 183 | // Verify Session |
| 184 | assertNotNull(session); |
| 185 | assertEquals("mysession", session.getName()); |
| 186 | assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session.getSessionPath()); |
| 187 | assertEquals(TraceSessionState.ACTIVE, session.getSessionState()); |
| 188 | |
| 189 | IDomainInfo[] domains = session.getDomains(); |
| 190 | assertNotNull(domains); |
| 191 | assertEquals(2, domains.length); |
| 192 | |
| 193 | // Verify Kernel domain |
| 194 | assertEquals("Kernel", domains[0].getName()); |
| 195 | IChannelInfo[] channels = domains[0].getChannels(); |
| 196 | assertNotNull(channels); |
| 197 | assertEquals(2, channels.length); |
| 198 | |
| 199 | // Verify Kernel's channel0 |
| 200 | assertEquals("channel0", channels[0].getName()); |
| 201 | assertEquals(4, channels[0].getNumberOfSubBuffers()); |
| 202 | assertEquals("splice()", channels[0].getOutputType()); |
| 203 | assertEquals(false, channels[0].isOverwriteMode()); |
| 204 | assertEquals(200, channels[0].getReadTimer()); |
| 205 | assertEquals(TraceEnablement.ENABLED, channels[0].getState()); |
| 206 | assertEquals(262144, channels[0].getSubBufferSize()); |
| 207 | assertEquals(0, channels[0].getSwitchTimer()); |
| 208 | |
| 209 | // Verify event info |
| 210 | IEventInfo[] channel0Events = channels[0].getEvents(); |
| 211 | assertNotNull(channel0Events); |
| 212 | assertEquals(2, channel0Events.length); |
| 213 | assertEquals("block_rq_remap", channel0Events[0].getName()); |
| 214 | assertEquals(TraceLogLevel.TRACE_EMERG, channel0Events[0].getLogLevel()); |
| 215 | assertEquals(TraceEventType.TRACEPOINT, channel0Events[0].getEventType()); |
| 216 | assertEquals(TraceEnablement.ENABLED, channel0Events[0].getState()); |
| 217 | |
| 218 | assertEquals("block_bio_remap", channel0Events[1].getName()); |
| 219 | assertEquals(TraceLogLevel.TRACE_EMERG, channel0Events[1].getLogLevel()); |
| 220 | assertEquals(TraceEventType.TRACEPOINT, channel0Events[1].getEventType()); |
| 221 | assertEquals(TraceEnablement.DISABLED, channel0Events[1].getState()); |
| 222 | |
| 223 | // Verify Kernel's channel1 |
| 224 | assertEquals("channel1", channels[1].getName()); |
| 225 | assertEquals(4, channels[1].getNumberOfSubBuffers()); |
| 226 | assertEquals("splice()", channels[1].getOutputType()); |
| 227 | assertEquals(true, channels[1].isOverwriteMode()); |
| 228 | assertEquals(400, channels[1].getReadTimer()); |
| 229 | assertEquals(TraceEnablement.DISABLED, channels[1].getState()); |
| 230 | assertEquals(524288, channels[1].getSubBufferSize()); |
| 231 | assertEquals(100, channels[1].getSwitchTimer()); |
| 232 | |
| 233 | // Verify event info |
| 234 | IEventInfo[] channel1Events = channels[1].getEvents(); |
| 235 | assertEquals(0, channel1Events.length); |
| 236 | |
| 237 | // Verify domain UST global |
| 238 | assertEquals("UST global", domains[1].getName()); |
| 239 | |
| 240 | IChannelInfo[] ustChannels = domains[1].getChannels(); |
| 241 | |
| 242 | // Verify UST global's mychannel1 |
| 243 | assertEquals("mychannel1", ustChannels[0].getName()); |
| 244 | assertEquals(8, ustChannels[0].getNumberOfSubBuffers()); |
| 245 | assertEquals("mmap()", ustChannels[0].getOutputType()); |
| 246 | assertEquals(true, ustChannels[0].isOverwriteMode()); |
| 247 | assertEquals(100, ustChannels[0].getReadTimer()); |
| 248 | assertEquals(TraceEnablement.DISABLED, ustChannels[0].getState()); |
| 249 | assertEquals(8192, ustChannels[0].getSubBufferSize()); |
| 250 | assertEquals(200, ustChannels[0].getSwitchTimer()); |
| 251 | |
| 252 | // Verify event info |
| 253 | IEventInfo[] ustEvents = ustChannels[0].getEvents(); |
| 254 | assertEquals(0, ustEvents.length); |
| 255 | |
| 256 | // Verify UST global's channel0 |
| 257 | assertEquals("channel0", ustChannels[1].getName()); |
| 258 | assertEquals(4, ustChannels[1].getNumberOfSubBuffers()); |
| 259 | assertEquals("mmap()", ustChannels[1].getOutputType()); |
| 260 | assertEquals(false, ustChannels[1].isOverwriteMode()); |
| 261 | assertEquals(200, ustChannels[1].getReadTimer()); |
| 262 | assertEquals(TraceEnablement.ENABLED, ustChannels[1].getState()); |
| 263 | assertEquals(4096, ustChannels[1].getSubBufferSize()); |
| 264 | assertEquals(0, ustChannels[1].getSwitchTimer()); |
| 265 | |
| 266 | // Verify event info |
| 267 | ustEvents = ustChannels[1].getEvents(); |
| 268 | assertEquals(2, ustEvents.length); |
| 269 | |
| 270 | assertEquals("ust_tests_hello:tptest_sighandler", ustEvents[0].getName()); |
| 271 | assertEquals(TraceLogLevel.TRACE_DEBUG_LINE, ustEvents[0].getLogLevel()); |
| 272 | assertEquals(TraceEventType.TRACEPOINT, ustEvents[0].getEventType()); |
| 273 | assertEquals(TraceEnablement.DISABLED, ustEvents[0].getState()); |
| 274 | |
| 275 | assertEquals("*", ustEvents[1].getName()); |
| 276 | assertEquals(TraceLogLevel.LEVEL_UNKNOWN, ustEvents[1].getLogLevel()); |
| 277 | assertEquals(TraceEventType.TRACEPOINT, ustEvents[1].getEventType()); |
| 278 | assertEquals(TraceEnablement.ENABLED, ustEvents[1].getState()); |
| 279 | |
| 280 | // next session (no detailed information available) |
| 281 | session = fService.getSession("mysession1", new NullProgressMonitor()); |
| 282 | assertNotNull(session); |
| 283 | assertEquals("mysession1", session.getName()); |
| 284 | assertEquals("/home/user/lttng-traces/mysession1-20120203-133225", session.getSessionPath()); |
| 285 | assertEquals(TraceSessionState.INACTIVE, session.getSessionState()); |
| 286 | |
| 287 | domains = session.getDomains(); |
| 288 | assertNotNull(domains); |
| 289 | assertEquals(0, domains.length); |
| 290 | } catch (ExecutionException e) { |
| 291 | fail(e.toString()); |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | public void testGetKernelProvider() { |
| 296 | try { |
| 297 | fShell.setScenario(SCEN_GET_KERNEL_PROVIDER1); |
| 298 | List<IBaseEventInfo> events = fService.getKernelProvider(new NullProgressMonitor()); |
| 299 | |
| 300 | // Verify event info |
| 301 | assertNotNull(events); |
| 302 | assertEquals(3, events.size()); |
| 303 | |
| 304 | IBaseEventInfo baseEventInfo = (IBaseEventInfo) events.get(0); |
| 305 | assertNotNull(baseEventInfo); |
| 306 | assertEquals("sched_kthread_stop", baseEventInfo.getName()); |
| 307 | assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel()); |
| 308 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); |
| 309 | |
| 310 | baseEventInfo = (IBaseEventInfo) events.get(1); |
| 311 | assertEquals("sched_kthread_stop_ret", baseEventInfo.getName()); |
| 312 | assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel()); |
| 313 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); |
| 314 | |
| 315 | baseEventInfo = (IBaseEventInfo) events.get(2); |
| 316 | assertEquals("sched_wakeup_new", baseEventInfo.getName()); |
| 317 | assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel()); |
| 318 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); |
| 319 | |
| 320 | } catch (ExecutionException e) { |
| 321 | fail(e.toString()); |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | public void testGetUstProvider() { |
| 326 | try { |
| 327 | fShell.setScenario(SCEN_GET_UST_PROVIDER1); |
| 328 | List<IUstProviderInfo> providers = fService.getUstProvider(); |
| 329 | |
| 330 | // Check all providers |
| 331 | assertNotNull(providers); |
| 332 | assertEquals(2, providers.size()); |
| 333 | |
| 334 | //Verify first provider |
| 335 | assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers.get(0).getName()); |
| 336 | assertEquals(9379, providers.get(0).getPid()); |
| 337 | |
| 338 | // Verify event info |
| 339 | IBaseEventInfo[] events = providers.get(0).getEvents(); |
| 340 | assertNotNull(events); |
| 341 | assertEquals(2, events.length); |
| 342 | |
| 343 | IBaseEventInfo baseEventInfo = (IBaseEventInfo) events[0]; |
| 344 | assertNotNull(baseEventInfo); |
| 345 | assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo.getName()); |
| 346 | assertEquals(TraceLogLevel.TRACE_DEBUG_MODULE, baseEventInfo.getLogLevel()); |
| 347 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); |
| 348 | |
| 349 | baseEventInfo = (IBaseEventInfo) events[1]; |
| 350 | assertEquals("ust_tests_hello:tptest", baseEventInfo.getName()); |
| 351 | assertEquals(TraceLogLevel.TRACE_INFO, baseEventInfo.getLogLevel()); |
| 352 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); |
| 353 | |
| 354 | //Verify second provider |
| 355 | assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers.get(1).getName()); |
| 356 | assertEquals(4852, providers.get(1).getPid()); |
| 357 | |
| 358 | // Verify event info |
| 359 | events = providers.get(1).getEvents(); |
| 360 | assertNotNull(events); |
| 361 | assertEquals(2, events.length); |
| 362 | |
| 363 | baseEventInfo = (IBaseEventInfo) events[0]; |
| 364 | assertNotNull(baseEventInfo); |
| 365 | assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo.getName()); |
| 366 | assertEquals(TraceLogLevel.TRACE_WARNING, baseEventInfo.getLogLevel()); |
| 367 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); |
| 368 | |
| 369 | baseEventInfo = (IBaseEventInfo) events[1]; |
| 370 | assertEquals("ust_tests_hello:tptest", baseEventInfo.getName()); |
| 371 | assertEquals(TraceLogLevel.TRACE_DEBUG_FUNCTION, baseEventInfo.getLogLevel()); |
| 372 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); |
| 373 | |
| 374 | } catch (ExecutionException e) { |
| 375 | fail(e.toString()); |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | public void testUstProvider2() { |
| 380 | try { |
| 381 | fShell.setScenario(SCEN_GET_UST_PROVIDER2); |
| 382 | List<IUstProviderInfo> providers = fService.getUstProvider(); |
| 383 | |
| 384 | assertNotNull(providers); |
| 385 | assertEquals(0, providers.size()); |
| 386 | |
| 387 | } catch (ExecutionException e) { |
| 388 | fail(e.toString()); |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | public void testCreateSession() { |
| 393 | try { |
| 394 | fShell.setScenario(SCEN_CREATE_SESSION1); |
| 395 | |
| 396 | ISessionInfo info = fService.createSession("mysession2", null, new NullProgressMonitor()); |
| 397 | assertNotNull(info); |
| 398 | assertEquals("mysession2", info.getName()); |
| 399 | assertNotNull(info.getSessionPath()); |
| 400 | assertTrue(info.getSessionPath().contains("mysession2")); |
| 401 | assertEquals(TraceSessionState.INACTIVE, info.getSessionState()); |
| 402 | } catch (ExecutionException e) { |
| 403 | fail(e.toString()); |
| 404 | } |
| 405 | } |
| 406 | |
| 407 | public void testCreateSessionVariants() { |
| 408 | |
| 409 | fShell.setScenario(SCEN_CREATE_SESSION_VARIANTS); |
| 410 | |
| 411 | try { |
| 412 | fService.createSession("alreadyExist", null, new NullProgressMonitor()); |
| 413 | fail("No exeption thrown"); |
| 414 | } catch (ExecutionException e) { |
| 415 | // success |
| 416 | } |
| 417 | |
| 418 | try { |
| 419 | fService.createSession("wrongName", null, new NullProgressMonitor()); |
| 420 | fail("No exeption thrown"); |
| 421 | } catch (ExecutionException e) { |
| 422 | // success |
| 423 | } |
| 424 | |
| 425 | try { |
| 426 | fService.createSession("withPath", "/home/user/hallo", new NullProgressMonitor()); |
| 427 | fail("No exeption thrown"); |
| 428 | } catch (ExecutionException e) { |
| 429 | // success |
| 430 | } |
| 431 | |
| 432 | try { |
| 433 | ISessionInfo info = fService.createSession("session with spaces", null, new NullProgressMonitor()); |
| 434 | assertNotNull(info); |
| 435 | assertEquals("session with spaces", info.getName()); |
| 436 | assertNotNull(info.getSessionPath()); |
| 437 | assertTrue(info.getSessionPath().contains("session with spaces")); |
| 438 | assertEquals(TraceSessionState.INACTIVE, info.getSessionState()); |
| 439 | |
| 440 | } catch (ExecutionException e) { |
| 441 | fail(e.toString()); |
| 442 | } |
| 443 | |
| 444 | try { |
| 445 | ISessionInfo info = fService.createSession("pathWithSpaces", "/home/user/hallo user/here", new NullProgressMonitor()); |
| 446 | assertNotNull(info); |
| 447 | assertEquals("pathWithSpaces", info.getName()); |
| 448 | assertNotNull(info.getSessionPath()); |
| 449 | assertTrue(info.getSessionPath().contains("/home/user/hallo user/here")); |
| 450 | assertEquals(TraceSessionState.INACTIVE, info.getSessionState()); |
| 451 | |
| 452 | } catch (ExecutionException e) { |
| 453 | fail(e.toString()); |
| 454 | } |
| 455 | } |
| 456 | |
| 457 | public void testDestroySession() { |
| 458 | try { |
| 459 | fShell.setScenario(SCEN_DESTROY_SESSION1); |
| 460 | fService.destroySession("mysession2", new NullProgressMonitor()); |
| 461 | } catch (ExecutionException e) { |
| 462 | fail(e.toString()); |
| 463 | } |
| 464 | } |
| 465 | |
| 466 | public void testCreateChannel() { |
| 467 | try { |
| 468 | |
| 469 | String sessionName = "mysession2"; |
| 470 | List<String> list = new ArrayList<String>(); |
| 471 | String kernelChannel0 = "mychannel0"; |
| 472 | String kernelChannel1 = "mychannel1"; |
| 473 | list.add(kernelChannel0); |
| 474 | list.add(kernelChannel1); |
| 475 | |
| 476 | fShell.setScenario(SCEN_CHANNEL_HANDLING); |
| 477 | |
| 478 | // Create/enable/configure 2 kernel channels |
| 479 | ChannelInfo chanInfo = new ChannelInfo(""); |
| 480 | chanInfo.setOverwriteMode(true); |
| 481 | chanInfo.setSubBufferSize(16384); |
| 482 | chanInfo.setReadTimer(100); |
| 483 | chanInfo.setSwitchTimer(200); |
| 484 | chanInfo.setNumberOfSubBuffers(2); |
| 485 | fService.enableChannels(sessionName, list, true, chanInfo, new NullProgressMonitor()); |
| 486 | |
| 487 | // Create/enable/configure 1 UST channel |
| 488 | list.clear(); |
| 489 | list.add("ustChannel"); |
| 490 | |
| 491 | chanInfo = new ChannelInfo(""); |
| 492 | chanInfo.setOverwriteMode(true); |
| 493 | chanInfo.setSubBufferSize(32768); |
| 494 | chanInfo.setReadTimer(200); |
| 495 | chanInfo.setSwitchTimer(100); |
| 496 | chanInfo.setNumberOfSubBuffers(1); |
| 497 | fService.enableChannels(sessionName, list, false, chanInfo, new NullProgressMonitor()); |
| 498 | |
| 499 | } catch (ExecutionException e) { |
| 500 | fail(e.toString()); |
| 501 | } |
| 502 | } |
| 503 | |
| 504 | public void testDisableChannel() { |
| 505 | try { |
| 506 | |
| 507 | String sessionName = "mysession2"; |
| 508 | List<String> list = new ArrayList<String>(); |
| 509 | String kernelChannel0 = "mychannel0"; |
| 510 | String kernelChannel1 = "mychannel1"; |
| 511 | list.add(kernelChannel0); |
| 512 | list.add(kernelChannel1); |
| 513 | |
| 514 | fShell.setScenario(SCEN_CHANNEL_HANDLING); |
| 515 | fService.disableChannels(sessionName, list, true, new NullProgressMonitor()); |
| 516 | |
| 517 | list.clear(); |
| 518 | list.add("ustChannel"); |
| 519 | fService.disableChannels(sessionName, list, false, new NullProgressMonitor()); |
| 520 | |
| 521 | } catch (ExecutionException e) { |
| 522 | fail(e.toString()); |
| 523 | } |
| 524 | } |
| 525 | |
| 526 | public void testEnableChannel() { |
| 527 | try { |
| 528 | |
| 529 | String sessionName = "mysession2"; |
| 530 | List<String> list = new ArrayList<String>(); |
| 531 | String kernelChannel0 = "mychannel0"; |
| 532 | String kernelChannel1 = "mychannel1"; |
| 533 | list.add(kernelChannel0); |
| 534 | list.add(kernelChannel1); |
| 535 | |
| 536 | fShell.setScenario(SCEN_CHANNEL_HANDLING); |
| 537 | fService.enableChannels(sessionName, list, true, null, new NullProgressMonitor()); |
| 538 | |
| 539 | // Create/enable/configure 1 UST channel |
| 540 | list.clear(); |
| 541 | list.add("ustChannel"); |
| 542 | |
| 543 | fService.enableChannels(sessionName, list, false, null, new NullProgressMonitor()); |
| 544 | |
| 545 | } catch (ExecutionException e) { |
| 546 | fail(e.toString()); |
| 547 | } |
| 548 | } |
| 549 | |
| 550 | // public void tesEnableChannelNoTracer() { |
| 551 | // try { |
| 552 | // ILttngControlService service = new LTTngControlService(fShellFactory.getShellForChannelNoTracer()); |
| 553 | // service.getSessionNames(new NullProgressMonitor()); |
| 554 | // fail("No exeption thrown"); |
| 555 | // |
| 556 | // } catch (ExecutionException e) { |
| 557 | // // success |
| 558 | // } |
| 559 | // } |
| 560 | |
| 561 | public void testEnableEvents() { |
| 562 | try { |
| 563 | // 1) session name, channel = null, 3 event names, kernel |
| 564 | String sessionName = "mysession2"; |
| 565 | List<String> list = new ArrayList<String>(); |
| 566 | String eventName0 = "block_rq_remap"; |
| 567 | String eventName1 = "block_bio_remap"; |
| 568 | String eventName2 = "softirq_entry"; |
| 569 | list.add(eventName0); |
| 570 | list.add(eventName1); |
| 571 | list.add(eventName2); |
| 572 | fShell.setScenario(SCEN_EVENT_HANDLING); |
| 573 | fService.enableEvents(sessionName, null, list, true, new NullProgressMonitor()); |
| 574 | |
| 575 | // 2) session name, channel=mychannel, event name= null, kernel |
| 576 | String channelName = "mychannel"; |
| 577 | fService.enableEvents(sessionName, channelName, null, true, new NullProgressMonitor()); |
| 578 | |
| 579 | // 3) session name, channel=mychannel, 1 event name, ust |
| 580 | String ustEventName = "ust_tests_hello:tptest_sighandler"; |
| 581 | list.clear(); |
| 582 | list.add(ustEventName); |
| 583 | fService.enableEvents(sessionName, channelName, list, false, new NullProgressMonitor()); |
| 584 | |
| 585 | // 4) session name, channel = mychannel, no event name, ust |
| 586 | list.clear(); |
| 587 | fService.enableEvents(sessionName, channelName, list, false, new NullProgressMonitor()); |
| 588 | |
| 589 | } catch (ExecutionException e) { |
| 590 | fail(e.toString()); |
| 591 | } |
| 592 | } |
| 593 | |
| 594 | public void testEnableSyscalls() { |
| 595 | try { |
| 596 | // 1) session name, channel = null, 3 event names, kernel |
| 597 | String sessionName = "mysession2"; |
| 598 | String channelName = "mychannel"; |
| 599 | |
| 600 | fShell.setScenario(SCEN_EVENT_HANDLING); |
| 601 | |
| 602 | // 1) session name, channel = null |
| 603 | fService.enableSyscalls(sessionName, null, new NullProgressMonitor()); |
| 604 | |
| 605 | // 2) session name, channel = mychannel |
| 606 | fService.enableSyscalls(sessionName, channelName, new NullProgressMonitor()); |
| 607 | |
| 608 | } catch (ExecutionException e) { |
| 609 | fail(e.toString()); |
| 610 | } |
| 611 | } |
| 612 | |
| 613 | public void testDynamicProbe() { |
| 614 | try { |
| 615 | // 1) session name, channel = null, 3 event names, kernel |
| 616 | String sessionName = "mysession2"; |
| 617 | String channelName = "mychannel"; |
| 618 | String eventName0 = "myevent0"; |
| 619 | String eventName1 = "myevent1"; |
| 620 | String functionProbe = "0xc0101340"; |
| 621 | String dynProbe = "init_post"; |
| 622 | |
| 623 | fShell.setScenario(SCEN_EVENT_HANDLING); |
| 624 | |
| 625 | // 1) session name, channel = null, event name, function probe, probe |
| 626 | fService.enableProbe(sessionName, null, eventName0, true, functionProbe, new NullProgressMonitor()); |
| 627 | |
| 628 | // 2) session name, channel = mychannel |
| 629 | fService.enableProbe(sessionName, channelName, eventName1, false, dynProbe, new NullProgressMonitor()); |
| 630 | |
| 631 | } catch (ExecutionException e) { |
| 632 | fail(e.toString()); |
| 633 | } |
| 634 | } |
| 635 | |
| 636 | public void testEnableLogLevel() { |
| 637 | try { |
| 638 | // 1) session name, channel = null, 3 event names, kernel |
| 639 | String sessionName = "mysession2"; |
| 640 | String channelName = "mychannel"; |
| 641 | String eventName4 = "myevent4"; |
| 642 | String eventName5 = "myevent5"; |
| 643 | |
| 644 | fShell.setScenario(SCEN_EVENT_HANDLING); |
| 645 | |
| 646 | // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG |
| 647 | fService.enableLogLevel(sessionName, null, eventName4, LogLevelType.LOGLEVEL_ONLY, TraceLogLevel.TRACE_DEBUG, new NullProgressMonitor()); |
| 648 | |
| 649 | // 2) session name, channel = mychannel, null, loglevel, TRACE_DEBUG_FUNCTION |
| 650 | fService.enableLogLevel(sessionName, channelName, eventName5, LogLevelType.LOGLEVEL, TraceLogLevel.TRACE_DEBUG_FUNCTION, new NullProgressMonitor()); |
| 651 | |
| 652 | } catch (ExecutionException e) { |
| 653 | fail(e.toString()); |
| 654 | } |
| 655 | } |
| 656 | |
| 657 | } |