Commit | Line | Data |
---|---|---|
eb1bab5b BH |
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 | **********************************************************************/ | |
115b4a01 | 12 | package org.eclipse.linuxtools.lttng2.ui.tests.control.service; |
eb1bab5b | 13 | |
d132bcc7 BH |
14 | import java.io.File; |
15 | import java.net.URL; | |
16 | import java.util.ArrayList; | |
eb1bab5b BH |
17 | import java.util.List; |
18 | ||
19 | import junit.framework.TestCase; | |
20 | ||
21 | import org.eclipse.core.commands.ExecutionException; | |
d132bcc7 | 22 | import org.eclipse.core.runtime.FileLocator; |
bbb3538a | 23 | import org.eclipse.core.runtime.NullProgressMonitor; |
d132bcc7 | 24 | import org.eclipse.core.runtime.Path; |
115b4a01 BH |
25 | import org.eclipse.linuxtools.internal.lttng2.stubs.service.CommandShellFactory; |
26 | import org.eclipse.linuxtools.internal.lttng2.stubs.shells.LTTngToolsFileShell; | |
27 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IBaseEventInfo; | |
28 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo; | |
29 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo; | |
30 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IEventInfo; | |
31 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo; | |
32 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IUstProviderInfo; | |
33 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.LogLevelType; | |
34 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEnablement; | |
35 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEventType; | |
36 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel; | |
37 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState; | |
38 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.ChannelInfo; | |
39 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService; | |
40 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.LTTngControlService; | |
9269df72 | 41 | import org.osgi.framework.FrameworkUtil; |
eb1bab5b BH |
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 { | |
d132bcc7 BH |
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 | ||
eb1bab5b BH |
66 | // ------------------------------------------------------------------------ |
67 | // Test data | |
68 | // ------------------------------------------------------------------------ | |
d132bcc7 BH |
69 | private CommandShellFactory fShellFactory; |
70 | private String fTestfile; | |
71 | private LTTngToolsFileShell fShell; | |
72 | private ILttngControlService fService; | |
73 | ||
eb1bab5b BH |
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(); | |
d132bcc7 | 92 | |
9269df72 | 93 | URL location = FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path(DIRECTORY + File.separator + TEST_STREAM), null); |
d132bcc7 BH |
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); | |
eb1bab5b BH |
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 { | |
d132bcc7 BH |
118 | fShell.setScenario(SCEN_LTTNG_NOT_INSTALLED); |
119 | fService.getSessionNames(new NullProgressMonitor()); | |
eb1bab5b | 120 | fail("No exeption thrown"); |
eb1bab5b BH |
121 | } catch (ExecutionException e) { |
122 | // success | |
123 | } | |
124 | } | |
125 | ||
126 | public void testGetSessionNames1() { | |
127 | try { | |
d132bcc7 BH |
128 | fShell.setScenario(SCEN_NO_SESSION_AVAILABLE); |
129 | String[] result = fService.getSessionNames(new NullProgressMonitor()); | |
eb1bab5b BH |
130 | |
131 | assertNotNull(result); | |
132 | assertEquals(0, result.length); | |
133 | ||
134 | } catch (ExecutionException e) { | |
135 | fail(e.toString()); | |
136 | } | |
137 | } | |
d132bcc7 | 138 | |
eb1bab5b BH |
139 | public void testGetSessionNames2() { |
140 | try { | |
d132bcc7 BH |
141 | fShell.setScenario(SCEN_GET_SESSION_NAMES1); |
142 | String[] result = fService.getSessionNames(new NullProgressMonitor()); | |
eb1bab5b BH |
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 | } | |
d132bcc7 | 153 | |
eb1bab5b BH |
154 | public void testGetSessionNotExist() { |
155 | try { | |
d132bcc7 BH |
156 | fShell.setScenario(SCEN_GET_SESSION_NAME_NOT_EXIST); |
157 | fService.getSessionNames(new NullProgressMonitor()); | |
eb1bab5b BH |
158 | fail("No exeption thrown"); |
159 | ||
160 | } catch (ExecutionException e) { | |
161 | // success | |
162 | } | |
163 | } | |
164 | ||
165 | public void testGetSessionNameGarbage() { | |
166 | try { | |
d132bcc7 BH |
167 | fShell.setScenario(SCEN_GET_SESSION_GARBAGE_OUT); |
168 | String[] result = fService.getSessionNames(new NullProgressMonitor()); | |
eb1bab5b BH |
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 { | |
d132bcc7 BH |
180 | fShell.setScenario(SCEN_GET_SESSION1); |
181 | ISessionInfo session = fService.getSession("mysession", new NullProgressMonitor()); | |
eb1bab5b BH |
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()); | |
4775bcbf | 271 | assertEquals(TraceLogLevel.TRACE_DEBUG_LINE, ustEvents[0].getLogLevel()); |
eb1bab5b BH |
272 | assertEquals(TraceEventType.TRACEPOINT, ustEvents[0].getEventType()); |
273 | assertEquals(TraceEnablement.DISABLED, ustEvents[0].getState()); | |
274 | ||
275 | assertEquals("*", ustEvents[1].getName()); | |
4775bcbf | 276 | assertEquals(TraceLogLevel.LEVEL_UNKNOWN, ustEvents[1].getLogLevel()); |
eb1bab5b BH |
277 | assertEquals(TraceEventType.TRACEPOINT, ustEvents[1].getEventType()); |
278 | assertEquals(TraceEnablement.ENABLED, ustEvents[1].getState()); | |
279 | ||
280 | // next session (no detailed information available) | |
d132bcc7 | 281 | session = fService.getSession("mysession1", new NullProgressMonitor()); |
eb1bab5b BH |
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 { | |
d132bcc7 BH |
297 | fShell.setScenario(SCEN_GET_KERNEL_PROVIDER1); |
298 | List<IBaseEventInfo> events = fService.getKernelProvider(new NullProgressMonitor()); | |
eb1bab5b BH |
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 { | |
d132bcc7 BH |
327 | fShell.setScenario(SCEN_GET_UST_PROVIDER1); |
328 | List<IUstProviderInfo> providers = fService.getUstProvider(); | |
eb1bab5b BH |
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()); | |
4775bcbf | 346 | assertEquals(TraceLogLevel.TRACE_DEBUG_MODULE, baseEventInfo.getLogLevel()); |
eb1bab5b BH |
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()); | |
4775bcbf | 371 | assertEquals(TraceLogLevel.TRACE_DEBUG_FUNCTION, baseEventInfo.getLogLevel()); |
eb1bab5b BH |
372 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); |
373 | ||
374 | } catch (ExecutionException e) { | |
375 | fail(e.toString()); | |
376 | } | |
377 | } | |
d132bcc7 | 378 | |
eb1bab5b BH |
379 | public void testUstProvider2() { |
380 | try { | |
d132bcc7 BH |
381 | fShell.setScenario(SCEN_GET_UST_PROVIDER2); |
382 | List<IUstProviderInfo> providers = fService.getUstProvider(); | |
eb1bab5b BH |
383 | |
384 | assertNotNull(providers); | |
385 | assertEquals(0, providers.size()); | |
386 | ||
387 | } catch (ExecutionException e) { | |
388 | fail(e.toString()); | |
389 | } | |
390 | } | |
d132bcc7 | 391 | |
bbb3538a BH |
392 | public void testCreateSession() { |
393 | try { | |
d132bcc7 BH |
394 | fShell.setScenario(SCEN_CREATE_SESSION1); |
395 | ||
396 | ISessionInfo info = fService.createSession("mysession2", null, new NullProgressMonitor()); | |
bbb3538a BH |
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 | } | |
d132bcc7 BH |
406 | |
407 | public void testCreateSessionVariants() { | |
408 | ||
409 | fShell.setScenario(SCEN_CREATE_SESSION_VARIANTS); | |
410 | ||
bbb3538a | 411 | try { |
d132bcc7 | 412 | fService.createSession("alreadyExist", null, new NullProgressMonitor()); |
bbb3538a BH |
413 | fail("No exeption thrown"); |
414 | } catch (ExecutionException e) { | |
415 | // success | |
416 | } | |
417 | ||
418 | try { | |
d132bcc7 | 419 | fService.createSession("wrongName", null, new NullProgressMonitor()); |
bbb3538a BH |
420 | fail("No exeption thrown"); |
421 | } catch (ExecutionException e) { | |
422 | // success | |
423 | } | |
424 | ||
425 | try { | |
d132bcc7 | 426 | fService.createSession("withPath", "/home/user/hallo", new NullProgressMonitor()); |
bbb3538a BH |
427 | fail("No exeption thrown"); |
428 | } catch (ExecutionException e) { | |
429 | // success | |
430 | } | |
431 | ||
432 | try { | |
d132bcc7 | 433 | ISessionInfo info = fService.createSession("session with spaces", null, new NullProgressMonitor()); |
bbb3538a BH |
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 { | |
d132bcc7 | 445 | ISessionInfo info = fService.createSession("pathWithSpaces", "/home/user/hallo user/here", new NullProgressMonitor()); |
bbb3538a BH |
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 | ||
9d8a90ad | 457 | public void testDestroySession() { |
bbb3538a | 458 | try { |
d132bcc7 BH |
459 | fShell.setScenario(SCEN_DESTROY_SESSION1); |
460 | fService.destroySession("mysession2", new NullProgressMonitor()); | |
bbb3538a BH |
461 | } catch (ExecutionException e) { |
462 | fail(e.toString()); | |
463 | } | |
464 | } | |
d132bcc7 BH |
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 | } | |
bbb3538a | 525 | |
d132bcc7 BH |
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() { | |
bbb3538a | 551 | // try { |
d132bcc7 BH |
552 | // ILttngControlService service = new LTTngControlService(fShellFactory.getShellForChannelNoTracer()); |
553 | // service.getSessionNames(new NullProgressMonitor()); | |
554 | // fail("No exeption thrown"); | |
bbb3538a | 555 | // |
bbb3538a | 556 | // } catch (ExecutionException e) { |
d132bcc7 | 557 | // // success |
bbb3538a | 558 | // } |
d132bcc7 BH |
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()); | |
bbb3538a | 578 | |
d132bcc7 BH |
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 | } | |
bbb3538a | 593 | |
d132bcc7 BH |
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 | } | |
bbb3538a | 656 | |
eb1bab5b | 657 | } |