Commit | Line | Data |
---|---|---|
eb1bab5b | 1 | /********************************************************************** |
11b78e10 | 2 | * Copyright (c) 2012, 2015 Ericsson |
cfdb727a | 3 | * |
eb1bab5b BH |
4 | * All rights reserved. This program and the accompanying materials are |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
cfdb727a AM |
8 | * |
9 | * Contributors: | |
eb1bab5b | 10 | * Bernd Hufmann - Initial API and implementation |
2ba3d0a1 | 11 | * Alexandre Montplaisir - Port to JUnit4 |
81d5dc3a | 12 | * Marc-Andre Laperle - Support for creating a live session |
eb1bab5b | 13 | **********************************************************************/ |
2ba3d0a1 | 14 | |
9bc60be7 | 15 | package org.eclipse.tracecompass.lttng2.control.ui.tests.service; |
eb1bab5b | 16 | |
d128c979 | 17 | import static org.junit.Assert.assertEquals; |
e5237dc5 | 18 | import static org.junit.Assert.assertFalse; |
d128c979 BH |
19 | import static org.junit.Assert.assertNotNull; |
20 | import static org.junit.Assert.assertTrue; | |
21 | import static org.junit.Assert.fail; | |
2ba3d0a1 | 22 | |
d132bcc7 BH |
23 | import java.io.File; |
24 | import java.net.URL; | |
25 | import java.util.ArrayList; | |
4ea599a5 | 26 | import java.util.HashSet; |
eb1bab5b | 27 | import java.util.List; |
4ea599a5 | 28 | import java.util.Set; |
eb1bab5b | 29 | |
eb1bab5b | 30 | import org.eclipse.core.commands.ExecutionException; |
d132bcc7 | 31 | import org.eclipse.core.runtime.FileLocator; |
bbb3538a | 32 | import org.eclipse.core.runtime.NullProgressMonitor; |
d132bcc7 | 33 | import org.eclipse.core.runtime.Path; |
13729cbc | 34 | import org.eclipse.jdt.annotation.NonNull; |
a959e694 | 35 | import org.eclipse.jdt.annotation.Nullable; |
9bc60be7 AM |
36 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.IBaseEventInfo; |
37 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.IChannelInfo; | |
38 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.IDomainInfo; | |
39 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.IEventInfo; | |
40 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.IFieldInfo; | |
41 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.ISessionInfo; | |
42 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.ISnapshotInfo; | |
43 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.IUstProviderInfo; | |
44 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.LogLevelType; | |
45 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceChannelOutputType; | |
1bc37054 | 46 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceDomainType; |
9bc60be7 AM |
47 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceEnablement; |
48 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceEventType; | |
49 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceLogLevel; | |
50 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceSessionState; | |
51 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.BufferType; | |
52 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.ChannelInfo; | |
53 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.SessionInfo; | |
9bc60be7 AM |
54 | import org.eclipse.tracecompass.internal.lttng2.control.stubs.shells.LTTngToolsFileShell; |
55 | import org.eclipse.tracecompass.internal.lttng2.control.ui.Activator; | |
56 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.logging.ControlCommandLogger; | |
57 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.preferences.ControlPreferences; | |
58 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.ILttngControlService; | |
59 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.LTTngControlService; | |
60 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.LTTngControlServiceFactory; | |
a959e694 | 61 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.LttngVersion; |
d128c979 | 62 | import org.junit.After; |
2ba3d0a1 | 63 | import org.junit.Before; |
ee8d0c40 | 64 | import org.junit.Ignore; |
2ba3d0a1 | 65 | import org.junit.Test; |
9269df72 | 66 | import org.osgi.framework.FrameworkUtil; |
2ba3d0a1 | 67 | |
eb1bab5b | 68 | /** |
2ba3d0a1 AM |
69 | * The class <code>LTTngControlServiceTest</code> contains test for the class |
70 | * <code>{@link LTTngControlService}</code>. | |
eb1bab5b | 71 | */ |
4e0b52e0 | 72 | @SuppressWarnings("javadoc") |
2ba3d0a1 | 73 | public class LTTngControlServiceTest { |
d132bcc7 BH |
74 | |
75 | private static final String DIRECTORY = "testfiles"; | |
76 | private static final String TEST_STREAM = "LTTngServiceTest.cfg"; | |
cfdb727a | 77 | |
d132bcc7 | 78 | private static final String SCEN_LTTNG_NOT_INSTALLED = "LttngNotInstalled"; |
798b4543 MAL |
79 | protected static final String SCEN_LTTNG_VERSION = "LttngVersion"; |
80 | protected static final String SCEN_LTTNG_VERSION_WITH_PROMPT = "LttngVersionWithPrompt"; | |
276c17e7 BH |
81 | private static final String SCEN_LTTNG_UNSUPPORTED_VERSION = "LttngUnsupportedVersion"; |
82 | private static final String SCEN_LTTNG_NO_VERSION = "LttngNoVersion"; | |
798b4543 | 83 | protected static final String SCEN_LTTNG_COMPILED_VERSION = "LttngVersionCompiled"; |
d132bcc7 BH |
84 | private static final String SCEN_NO_SESSION_AVAILABLE = "NoSessionAvailable"; |
85 | private static final String SCEN_GET_SESSION_NAMES1 = "GetSessionNames1"; | |
11b78e10 | 86 | private static final String SCEN_GET_SESSION_WITH_GROUP = "GetSessionWithTracingGroup"; |
d132bcc7 | 87 | private static final String SCEN_GET_SESSION_NAME_NOT_EXIST = "GetSessionNameNotExist"; |
d128c979 | 88 | private static final String SCEN_GET_SESSION_NAME_NOT_EXIST_VERBOSE = "GetSessionNameNotExistVerbose"; |
e5e5b3db | 89 | protected static final String SCEN_GET_SESSION_GARBAGE_OUT = "GetSessionGarbageOut"; |
d132bcc7 | 90 | private static final String SCEN_GET_SESSION1 = "GetSession1"; |
e5237dc5 | 91 | private static final String SCEN_GET_SESSION_WITH_LIVE = "GetSessionWithLiveInterval"; |
d132bcc7 | 92 | private static final String SCEN_GET_KERNEL_PROVIDER1 = "GetKernelProvider1"; |
a07c7629 BH |
93 | private static final String SCEN_LIST_WITH_NO_KERNEL1 = "ListWithNoKernel1"; |
94 | private static final String SCEN_LIST_WITH_NO_KERNEL2 = "ListWithNoKernel2"; | |
d128c979 | 95 | private static final String SCEN_LIST_WITH_NO_KERNEL_VERBOSE = "ListWithNoKernelVerbose"; |
d132bcc7 BH |
96 | private static final String SCEN_GET_UST_PROVIDER1 = "GetUstProvider1"; |
97 | private static final String SCEN_GET_UST_PROVIDER2 = "GetUstProvider2"; | |
d4514365 | 98 | private static final String SCEN_GET_UST_PROVIDER3 = "GetUstProvider3"; |
f3e2f354 BH |
99 | private static final String SCEN_LIST_WITH_NO_UST1 = "ListWithNoUst1"; |
100 | private static final String SCEN_LIST_WITH_NO_UST2 = "ListWithNoUst2"; | |
101 | private static final String SCEN_LIST_WITH_NO_UST3 = "ListWithNoUst3"; | |
102 | private static final String SCEN_LIST_WITH_NO_UST_VERBOSE = "ListWithNoUstVerbose"; | |
d132bcc7 | 103 | private static final String SCEN_CREATE_SESSION1 = "CreateSession1"; |
d6fc6e1b | 104 | private static final String SCEN_CREATE_SESSION_WITH_PROMPT = "CreateSessionWithPrompt"; |
d132bcc7 BH |
105 | private static final String SCEN_CREATE_SESSION_VARIANTS = "CreateSessionVariants"; |
106 | private static final String SCEN_DESTROY_SESSION1 = "DestroySession1"; | |
d128c979 | 107 | private static final String SCEN_DESTROY_SESSION_VERBOSE = "DestroySessionVerbose"; |
d132bcc7 BH |
108 | private static final String SCEN_CHANNEL_HANDLING = "ChannelHandling"; |
109 | private static final String SCEN_EVENT_HANDLING = "EventHandling"; | |
1bc37054 | 110 | private static final String SCEN_EVENT_EXCLUDED = "EventExcluded"; |
4ea599a5 BH |
111 | private static final String SCEN_CONTEXT_HANDLING = "ContextHandling"; |
112 | private static final String SCEN_CONTEXT_ERROR_HANDLING = "ContextErrorHandling"; | |
f3b33d40 | 113 | private static final String SCEN_CREATE_SESSION_2_1 = "CreateSessionLttng2.1"; |
d128c979 | 114 | private static final String SCEN_CREATE_SESSION_VERBOSE_2_1 = "CreateSessionLttngVerbose2.1"; |
589d0d33 | 115 | private static final String SCEN_CREATE_SNAPSHOT_SESSION = "CreateSessionSnapshot"; |
ad311f36 | 116 | private static final String SCEN_CREATE_SNAPSHOT_SESSION_2_5 = "CreateSessionSnapshot2.5"; |
589d0d33 BH |
117 | private static final String SCEN_CREATE_STREAMED_SNAPSHOT_SESSION = "CreateSessionStreamedSnapshot"; |
118 | private static final String SCEN_CREATE_SNAPSHOT_SESSION_ERRORS = "CreateSessionSnapshotErrors"; | |
e5e5b3db | 119 | protected static final String SCEN_CREATE_LIVE_SESSION = "CreateSessionLive"; |
81d5dc3a | 120 | private static final String SCEN_CREATE_LIVE_SESSION_ERRORS = "CreateSessionLiveErrors"; |
2b7c6996 BH |
121 | private static final String SCEN_SESSION_PROFILES = "SessionProfile"; |
122 | ||
d132bcc7 | 123 | |
ad311f36 | 124 | |
eb1bab5b BH |
125 | // ------------------------------------------------------------------------ |
126 | // Test data | |
127 | // ------------------------------------------------------------------------ | |
d132bcc7 | 128 | private String fTestfile; |
13729cbc | 129 | protected final @NonNull LTTngToolsFileShell fShell = new LTTngToolsFileShell(); |
e5e5b3db | 130 | protected ILttngControlService fService; |
d132bcc7 | 131 | |
eb1bab5b BH |
132 | // ------------------------------------------------------------------------ |
133 | // Housekeeping | |
134 | // ------------------------------------------------------------------------ | |
2ba3d0a1 | 135 | |
eb1bab5b BH |
136 | /** |
137 | * Perform pre-test initialization. | |
138 | * | |
2ba3d0a1 AM |
139 | * @throws Exception |
140 | * if the initialization fails for some reason | |
eb1bab5b | 141 | */ |
2ba3d0a1 | 142 | @Before |
eb1bab5b | 143 | public void setUp() throws Exception { |
e5e5b3db | 144 | URL location = FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path(getTestDirectory() + File.separator + getTestStream()), null); |
d132bcc7 BH |
145 | File testfile = new File(FileLocator.toFileURL(location).toURI()); |
146 | fTestfile = testfile.getAbsolutePath(); | |
d132bcc7 | 147 | fShell.loadScenarioFile(fTestfile); |
e5e5b3db JRJ |
148 | fService = getControlService(); |
149 | if (fService == null) { | |
150 | throw new Exception("Unable to obtain a valid ControlService"); | |
151 | } | |
d128c979 BH |
152 | |
153 | ControlPreferences.getInstance().init(Activator.getDefault().getPreferenceStore()); | |
154 | } | |
155 | ||
e5e5b3db JRJ |
156 | /** |
157 | * @return the string of the test directory to use | |
158 | */ | |
159 | protected String getTestDirectory() { | |
160 | return DIRECTORY; | |
161 | } | |
162 | ||
163 | /** | |
164 | * @return the LttngCon | |
165 | */ | |
166 | protected ILttngControlService getControlService() { | |
167 | return new LTTngControlService(fShell); | |
168 | } | |
169 | ||
364dcfaf BH |
170 | /** |
171 | * @return the shell implementation | |
172 | */ | |
173 | public @NonNull LTTngToolsFileShell getShell() { | |
e5e5b3db JRJ |
174 | return fShell; |
175 | } | |
176 | ||
177 | /** | |
178 | * @return | |
179 | */ | |
180 | protected String getTestStream() { | |
181 | return TEST_STREAM; | |
182 | } | |
183 | ||
d128c979 BH |
184 | @After |
185 | public void tearDown() { | |
186 | disableVerbose(); | |
187 | ControlPreferences.getInstance().dispose(); | |
eb1bab5b BH |
188 | } |
189 | ||
eb1bab5b BH |
190 | // ------------------------------------------------------------------------ |
191 | // Test Cases | |
192 | // ------------------------------------------------------------------------ | |
cfdb727a | 193 | |
2ba3d0a1 | 194 | @Test |
276c17e7 BH |
195 | public void testVersion() { |
196 | try { | |
197 | fShell.setScenario(SCEN_LTTNG_VERSION); | |
13729cbc | 198 | ILttngControlService service = LTTngControlServiceFactory.getLttngControlService(fShell); |
276c17e7 | 199 | assertNotNull(service); |
0df4af5f | 200 | assertEquals("2.1.0", service.getVersionString()); |
276c17e7 BH |
201 | } catch (ExecutionException e) { |
202 | fail("Exeption thrown " + e); | |
203 | } | |
204 | } | |
cfdb727a | 205 | |
2ba3d0a1 | 206 | @Test |
d6fc6e1b BH |
207 | public void testVersionWithPrompt() { |
208 | try { | |
209 | fShell.setScenario(SCEN_LTTNG_VERSION_WITH_PROMPT); | |
13729cbc | 210 | ILttngControlService service = LTTngControlServiceFactory.getLttngControlService(fShell); |
d6fc6e1b | 211 | assertNotNull(service); |
0df4af5f | 212 | assertEquals("2.0.0", service.getVersionString()); |
d6fc6e1b BH |
213 | } catch (ExecutionException e) { |
214 | fail("Exeption thrown " + e); | |
215 | } | |
216 | } | |
a07c7629 | 217 | |
13729cbc BH |
218 | @Test(expected=ExecutionException.class) |
219 | public void testUnsupportedVersion() throws ExecutionException { | |
220 | fShell.setScenario(SCEN_LTTNG_UNSUPPORTED_VERSION); | |
221 | LTTngControlServiceFactory.getLttngControlService(fShell); | |
276c17e7 BH |
222 | } |
223 | ||
2ba3d0a1 | 224 | @Test |
276c17e7 BH |
225 | public void testNoVersion() { |
226 | try { | |
227 | fShell.setScenario(SCEN_LTTNG_NO_VERSION); | |
13729cbc | 228 | LTTngControlServiceFactory.getLttngControlService(fShell); |
276c17e7 BH |
229 | fail("No exeption thrown"); |
230 | } catch (ExecutionException e) { | |
231 | // success | |
232 | } | |
233 | } | |
234 | ||
c541f121 GB |
235 | @Test |
236 | public void testVersionCompiled() { | |
237 | try { | |
238 | fShell.setScenario(SCEN_LTTNG_COMPILED_VERSION); | |
13729cbc | 239 | ILttngControlService service = LTTngControlServiceFactory.getLttngControlService(fShell); |
c541f121 GB |
240 | assertNotNull(service); |
241 | assertEquals("2.5.0", service.getVersionString()); | |
242 | } catch (ExecutionException e) { | |
243 | fail("Exeption thrown " + e); | |
244 | } | |
245 | } | |
246 | ||
247 | ||
2ba3d0a1 | 248 | @Test |
276c17e7 | 249 | public void testLttngNotInstalled() { |
eb1bab5b | 250 | try { |
d132bcc7 BH |
251 | fShell.setScenario(SCEN_LTTNG_NOT_INSTALLED); |
252 | fService.getSessionNames(new NullProgressMonitor()); | |
eb1bab5b | 253 | fail("No exeption thrown"); |
eb1bab5b BH |
254 | } catch (ExecutionException e) { |
255 | // success | |
256 | } | |
257 | } | |
cfdb727a | 258 | |
2ba3d0a1 | 259 | @Test |
eb1bab5b BH |
260 | public void testGetSessionNames1() { |
261 | try { | |
d132bcc7 | 262 | fShell.setScenario(SCEN_NO_SESSION_AVAILABLE); |
cbc46cc9 | 263 | List<String> result = fService.getSessionNames(new NullProgressMonitor()); |
eb1bab5b BH |
264 | |
265 | assertNotNull(result); | |
cbc46cc9 | 266 | assertEquals(0, result.size()); |
cfdb727a | 267 | |
eb1bab5b BH |
268 | } catch (ExecutionException e) { |
269 | fail(e.toString()); | |
270 | } | |
271 | } | |
d132bcc7 | 272 | |
2ba3d0a1 | 273 | @Test |
eb1bab5b BH |
274 | public void testGetSessionNames2() { |
275 | try { | |
d132bcc7 | 276 | fShell.setScenario(SCEN_GET_SESSION_NAMES1); |
cbc46cc9 | 277 | List<String> result = fService.getSessionNames(new NullProgressMonitor()); |
eb1bab5b BH |
278 | |
279 | assertNotNull(result); | |
cbc46cc9 BH |
280 | assertEquals(2, result.size()); |
281 | assertEquals("mysession1", result.get(0)); | |
282 | assertEquals("mysession", result.get(1)); | |
cfdb727a | 283 | |
eb1bab5b BH |
284 | } catch (ExecutionException e) { |
285 | fail(e.toString()); | |
286 | } | |
287 | } | |
d132bcc7 | 288 | |
11b78e10 BH |
289 | @Test |
290 | public void testGetSessionNamesWithTracingGroup() { | |
291 | try { | |
292 | fShell.setScenario(SCEN_GET_SESSION_WITH_GROUP); | |
293 | ControlPreferences.getInstance().getPreferenceStore().setValue( | |
294 | ControlPreferences.TRACE_CONTROL_TRACING_GROUP_PREF, "group"); | |
295 | ||
cbc46cc9 | 296 | List<String> result = fService.getSessionNames(new NullProgressMonitor()); |
11b78e10 BH |
297 | |
298 | assertNotNull(result); | |
cbc46cc9 BH |
299 | assertEquals(2, result.size()); |
300 | assertEquals("mysession1", result.get(0)); | |
301 | assertEquals("mysession", result.get(1)); | |
11b78e10 BH |
302 | |
303 | ControlCommandLogger.init(ControlPreferences.getInstance().getLogfilePath(), false); | |
304 | ControlPreferences.getInstance().getPreferenceStore().setValue( | |
305 | ControlPreferences.TRACE_CONTROL_TRACING_GROUP_PREF, ControlPreferences.TRACE_CONTROL_DEFAULT_TRACING_GROUP); | |
306 | ||
307 | ||
308 | } catch (ExecutionException e) { | |
309 | fail(e.toString()); | |
310 | } | |
311 | } | |
312 | ||
313 | ||
2ba3d0a1 | 314 | @Test |
eb1bab5b BH |
315 | public void testGetSessionNotExist() { |
316 | try { | |
d132bcc7 BH |
317 | fShell.setScenario(SCEN_GET_SESSION_NAME_NOT_EXIST); |
318 | fService.getSessionNames(new NullProgressMonitor()); | |
eb1bab5b | 319 | fail("No exeption thrown"); |
cfdb727a | 320 | |
eb1bab5b BH |
321 | } catch (ExecutionException e) { |
322 | // success | |
323 | } | |
324 | } | |
cfdb727a | 325 | |
d128c979 BH |
326 | @Test |
327 | public void testGetSessionNotExistVerbose() { | |
328 | try { | |
329 | enableVerbose(); | |
330 | fShell.setScenario(SCEN_GET_SESSION_NAME_NOT_EXIST_VERBOSE); | |
331 | fService.getSessionNames(new NullProgressMonitor()); | |
332 | fail("No exeption thrown"); | |
333 | ||
334 | } catch (ExecutionException e) { | |
335 | // success | |
336 | } finally { | |
337 | disableVerbose(); | |
338 | } | |
339 | } | |
340 | ||
2ba3d0a1 | 341 | @Test |
eb1bab5b BH |
342 | public void testGetSessionNameGarbage() { |
343 | try { | |
d132bcc7 | 344 | fShell.setScenario(SCEN_GET_SESSION_GARBAGE_OUT); |
cbc46cc9 | 345 | List<String> result = fService.getSessionNames(new NullProgressMonitor()); |
eb1bab5b BH |
346 | |
347 | assertNotNull(result); | |
cbc46cc9 | 348 | assertEquals(0, result.size()); |
cfdb727a | 349 | |
eb1bab5b BH |
350 | } catch (ExecutionException e) { |
351 | fail(e.toString()); | |
352 | } | |
353 | } | |
cfdb727a | 354 | |
2ba3d0a1 | 355 | @Test |
eb1bab5b BH |
356 | public void testGetSession1() { |
357 | try { | |
d132bcc7 BH |
358 | fShell.setScenario(SCEN_GET_SESSION1); |
359 | ISessionInfo session = fService.getSession("mysession", new NullProgressMonitor()); | |
eb1bab5b BH |
360 | |
361 | // Verify Session | |
362 | assertNotNull(session); | |
363 | assertEquals("mysession", session.getName()); | |
364 | assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session.getSessionPath()); | |
365 | assertEquals(TraceSessionState.ACTIVE, session.getSessionState()); | |
cfdb727a | 366 | |
eb1bab5b BH |
367 | IDomainInfo[] domains = session.getDomains(); |
368 | assertNotNull(domains); | |
369 | assertEquals(2, domains.length); | |
cfdb727a | 370 | |
eb1bab5b BH |
371 | // Verify Kernel domain |
372 | assertEquals("Kernel", domains[0].getName()); | |
373 | IChannelInfo[] channels = domains[0].getChannels(); | |
374 | assertNotNull(channels); | |
375 | assertEquals(2, channels.length); | |
376 | ||
cfdb727a | 377 | // Verify Kernel's channel0 |
eb1bab5b BH |
378 | assertEquals("channel0", channels[0].getName()); |
379 | assertEquals(4, channels[0].getNumberOfSubBuffers()); | |
0ad9fc89 JRJ |
380 | assertEquals("splice()", channels[0].getOutputType().getInName()); |
381 | assertEquals(TraceChannelOutputType.SPLICE, channels[0].getOutputType()); | |
eb1bab5b BH |
382 | assertEquals(false, channels[0].isOverwriteMode()); |
383 | assertEquals(200, channels[0].getReadTimer()); | |
384 | assertEquals(TraceEnablement.ENABLED, channels[0].getState()); | |
385 | assertEquals(262144, channels[0].getSubBufferSize()); | |
386 | assertEquals(0, channels[0].getSwitchTimer()); | |
cfdb727a | 387 | |
eb1bab5b BH |
388 | // Verify event info |
389 | IEventInfo[] channel0Events = channels[0].getEvents(); | |
390 | assertNotNull(channel0Events); | |
391 | assertEquals(2, channel0Events.length); | |
392 | assertEquals("block_rq_remap", channel0Events[0].getName()); | |
393 | assertEquals(TraceLogLevel.TRACE_EMERG, channel0Events[0].getLogLevel()); | |
394 | assertEquals(TraceEventType.TRACEPOINT, channel0Events[0].getEventType()); | |
395 | assertEquals(TraceEnablement.ENABLED, channel0Events[0].getState()); | |
cfdb727a | 396 | |
eb1bab5b BH |
397 | assertEquals("block_bio_remap", channel0Events[1].getName()); |
398 | assertEquals(TraceLogLevel.TRACE_EMERG, channel0Events[1].getLogLevel()); | |
399 | assertEquals(TraceEventType.TRACEPOINT, channel0Events[1].getEventType()); | |
400 | assertEquals(TraceEnablement.DISABLED, channel0Events[1].getState()); | |
cfdb727a AM |
401 | |
402 | // Verify Kernel's channel1 | |
eb1bab5b BH |
403 | assertEquals("channel1", channels[1].getName()); |
404 | assertEquals(4, channels[1].getNumberOfSubBuffers()); | |
0ad9fc89 JRJ |
405 | assertEquals("splice()", channels[1].getOutputType().getInName()); |
406 | assertEquals(TraceChannelOutputType.SPLICE, channels[1].getOutputType()); | |
eb1bab5b BH |
407 | assertEquals(true, channels[1].isOverwriteMode()); |
408 | assertEquals(400, channels[1].getReadTimer()); | |
409 | assertEquals(TraceEnablement.DISABLED, channels[1].getState()); | |
410 | assertEquals(524288, channels[1].getSubBufferSize()); | |
411 | assertEquals(100, channels[1].getSwitchTimer()); | |
cfdb727a | 412 | |
eb1bab5b BH |
413 | // Verify event info |
414 | IEventInfo[] channel1Events = channels[1].getEvents(); | |
415 | assertEquals(0, channel1Events.length); | |
cfdb727a | 416 | |
eb1bab5b BH |
417 | // Verify domain UST global |
418 | assertEquals("UST global", domains[1].getName()); | |
cfdb727a | 419 | |
eb1bab5b | 420 | IChannelInfo[] ustChannels = domains[1].getChannels(); |
cfdb727a AM |
421 | |
422 | // Verify UST global's mychannel1 | |
eb1bab5b BH |
423 | assertEquals("mychannel1", ustChannels[0].getName()); |
424 | assertEquals(8, ustChannels[0].getNumberOfSubBuffers()); | |
0ad9fc89 JRJ |
425 | assertEquals("mmap()", ustChannels[0].getOutputType().getInName()); |
426 | assertEquals(TraceChannelOutputType.MMAP, ustChannels[0].getOutputType()); | |
eb1bab5b BH |
427 | assertEquals(true, ustChannels[0].isOverwriteMode()); |
428 | assertEquals(100, ustChannels[0].getReadTimer()); | |
429 | assertEquals(TraceEnablement.DISABLED, ustChannels[0].getState()); | |
430 | assertEquals(8192, ustChannels[0].getSubBufferSize()); | |
431 | assertEquals(200, ustChannels[0].getSwitchTimer()); | |
cfdb727a | 432 | |
eb1bab5b BH |
433 | // Verify event info |
434 | IEventInfo[] ustEvents = ustChannels[0].getEvents(); | |
435 | assertEquals(0, ustEvents.length); | |
436 | ||
cfdb727a | 437 | // Verify UST global's channel0 |
eb1bab5b BH |
438 | assertEquals("channel0", ustChannels[1].getName()); |
439 | assertEquals(4, ustChannels[1].getNumberOfSubBuffers()); | |
0ad9fc89 JRJ |
440 | assertEquals("mmap()", ustChannels[1].getOutputType().getInName()); |
441 | assertEquals(TraceChannelOutputType.MMAP, ustChannels[1].getOutputType()); | |
eb1bab5b BH |
442 | assertEquals(false, ustChannels[1].isOverwriteMode()); |
443 | assertEquals(200, ustChannels[1].getReadTimer()); | |
444 | assertEquals(TraceEnablement.ENABLED, ustChannels[1].getState()); | |
445 | assertEquals(4096, ustChannels[1].getSubBufferSize()); | |
446 | assertEquals(0, ustChannels[1].getSwitchTimer()); | |
cfdb727a | 447 | |
eb1bab5b BH |
448 | // Verify event info |
449 | ustEvents = ustChannels[1].getEvents(); | |
450 | assertEquals(2, ustEvents.length); | |
cfdb727a | 451 | |
eb1bab5b | 452 | assertEquals("ust_tests_hello:tptest_sighandler", ustEvents[0].getName()); |
4775bcbf | 453 | assertEquals(TraceLogLevel.TRACE_DEBUG_LINE, ustEvents[0].getLogLevel()); |
eb1bab5b BH |
454 | assertEquals(TraceEventType.TRACEPOINT, ustEvents[0].getEventType()); |
455 | assertEquals(TraceEnablement.DISABLED, ustEvents[0].getState()); | |
cfdb727a | 456 | |
eb1bab5b | 457 | assertEquals("*", ustEvents[1].getName()); |
e5e5b3db | 458 | assertEquals(getAllEventTraceLogLevel(), ustEvents[1].getLogLevel()); |
eb1bab5b BH |
459 | assertEquals(TraceEventType.TRACEPOINT, ustEvents[1].getEventType()); |
460 | assertEquals(TraceEnablement.ENABLED, ustEvents[1].getState()); | |
cfdb727a | 461 | |
eb1bab5b | 462 | // next session (no detailed information available) |
d132bcc7 | 463 | session = fService.getSession("mysession1", new NullProgressMonitor()); |
eb1bab5b BH |
464 | assertNotNull(session); |
465 | assertEquals("mysession1", session.getName()); | |
466 | assertEquals("/home/user/lttng-traces/mysession1-20120203-133225", session.getSessionPath()); | |
467 | assertEquals(TraceSessionState.INACTIVE, session.getSessionState()); | |
cfdb727a | 468 | |
eb1bab5b BH |
469 | domains = session.getDomains(); |
470 | assertNotNull(domains); | |
471 | assertEquals(0, domains.length); | |
472 | } catch (ExecutionException e) { | |
473 | fail(e.toString()); | |
474 | } | |
475 | } | |
476 | ||
e5237dc5 | 477 | @Test |
ee8d0c40 | 478 | @Ignore |
e5237dc5 BH |
479 | public void testGetSessionWithLive() { |
480 | try { | |
481 | fShell.setScenario(SCEN_GET_SESSION_WITH_LIVE); | |
482 | ||
483 | // Verify Session (snapshot session, non-live) | |
484 | ISessionInfo session = fService.getSession("mysession", new NullProgressMonitor()); | |
485 | assertNotNull(session); | |
486 | assertEquals("mysession", session.getName()); | |
487 | assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session.getSessionPath()); | |
488 | assertEquals(TraceSessionState.INACTIVE, session.getSessionState()); | |
489 | assertFalse(session.isLive()); | |
490 | ||
491 | // Verify Session (regular session, non-live) | |
492 | session = fService.getSession("mysession1", new NullProgressMonitor()); | |
493 | assertNotNull(session); | |
494 | assertEquals("mysession1", session.getName()); | |
495 | assertEquals("/home/user/lttng-traces/mysession1-20120129-084256", session.getSessionPath()); | |
496 | assertEquals(TraceSessionState.ACTIVE, session.getSessionState()); | |
497 | assertFalse(session.isLive()); | |
498 | ||
499 | // Verify Session (regular session, live) | |
500 | session = fService.getSession("mysession2", new NullProgressMonitor()); | |
501 | assertNotNull(session); | |
502 | assertEquals("mysession2", session.getName()); | |
503 | assertEquals("tcp4://172.0.0.1:5342/ [data: 5343]", session.getSessionPath()); | |
504 | assertEquals("net://127.0.0.1", session.getLiveUrl()); | |
505 | assertEquals(Integer.valueOf(5344), session.getLivePort()); | |
506 | assertEquals(1000000, session.getLiveDelay()); | |
507 | assertEquals(TraceSessionState.INACTIVE, session.getSessionState()); | |
508 | assertTrue(session.isLive()); | |
509 | ||
510 | } catch (ExecutionException e) { | |
511 | fail(e.toString()); | |
512 | } | |
513 | } | |
514 | ||
e5e5b3db JRJ |
515 | /** |
516 | * @return | |
517 | */ | |
518 | protected TraceLogLevel getAllEventTraceLogLevel() { | |
519 | return TraceLogLevel.LEVEL_UNKNOWN; | |
520 | } | |
521 | ||
eb1bab5b BH |
522 | public void testGetKernelProvider() { |
523 | try { | |
d132bcc7 BH |
524 | fShell.setScenario(SCEN_GET_KERNEL_PROVIDER1); |
525 | List<IBaseEventInfo> events = fService.getKernelProvider(new NullProgressMonitor()); | |
eb1bab5b BH |
526 | |
527 | // Verify event info | |
528 | assertNotNull(events); | |
529 | assertEquals(3, events.size()); | |
cfdb727a AM |
530 | |
531 | IBaseEventInfo baseEventInfo = events.get(0); | |
eb1bab5b BH |
532 | assertNotNull(baseEventInfo); |
533 | assertEquals("sched_kthread_stop", baseEventInfo.getName()); | |
534 | assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel()); | |
535 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); | |
cfdb727a AM |
536 | |
537 | baseEventInfo = events.get(1); | |
eb1bab5b BH |
538 | assertEquals("sched_kthread_stop_ret", baseEventInfo.getName()); |
539 | assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel()); | |
540 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); | |
cfdb727a AM |
541 | |
542 | baseEventInfo = events.get(2); | |
eb1bab5b BH |
543 | assertEquals("sched_wakeup_new", baseEventInfo.getName()); |
544 | assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel()); | |
545 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); | |
546 | ||
547 | } catch (ExecutionException e) { | |
548 | fail(e.toString()); | |
549 | } | |
550 | } | |
551 | ||
2ba3d0a1 | 552 | @Test |
a07c7629 BH |
553 | public void testGetKernelProviderNoKernel1() { |
554 | try { | |
555 | fShell.setScenario(SCEN_LIST_WITH_NO_KERNEL1); | |
556 | List<IBaseEventInfo> events = fService.getKernelProvider(new NullProgressMonitor()); | |
557 | ||
558 | // Verify event info | |
559 | assertNotNull(events); | |
560 | assertEquals(0, events.size()); | |
561 | ||
562 | } catch (ExecutionException e) { | |
563 | fail(e.toString()); | |
564 | } | |
565 | } | |
566 | ||
2ba3d0a1 | 567 | @Test |
a07c7629 BH |
568 | public void testGetKernelProviderNoKernel2() { |
569 | try { | |
570 | fShell.setScenario(SCEN_LIST_WITH_NO_KERNEL2); | |
571 | List<IBaseEventInfo> events = fService.getKernelProvider(new NullProgressMonitor()); | |
572 | ||
573 | // Verify event info | |
574 | assertNotNull(events); | |
575 | assertEquals(0, events.size()); | |
576 | ||
577 | } catch (ExecutionException e) { | |
578 | fail(e.toString()); | |
579 | } | |
580 | } | |
581 | ||
d128c979 BH |
582 | @Test |
583 | public void testGetKernelProviderNoKernelVerbose() { | |
584 | try { | |
585 | enableVerbose(); | |
586 | fShell.setScenario(SCEN_LIST_WITH_NO_KERNEL_VERBOSE); | |
587 | List<IBaseEventInfo> events = fService.getKernelProvider(new NullProgressMonitor()); | |
588 | ||
589 | // Verify event info | |
590 | assertNotNull(events); | |
591 | assertEquals(0, events.size()); | |
592 | ||
593 | } catch (ExecutionException e) { | |
594 | fail(e.toString()); | |
595 | } finally { | |
596 | disableVerbose(); | |
597 | } | |
598 | } | |
599 | ||
2ba3d0a1 | 600 | @Test |
eb1bab5b BH |
601 | public void testGetUstProvider() { |
602 | try { | |
d132bcc7 BH |
603 | fShell.setScenario(SCEN_GET_UST_PROVIDER1); |
604 | List<IUstProviderInfo> providers = fService.getUstProvider(); | |
eb1bab5b BH |
605 | |
606 | // Check all providers | |
607 | assertNotNull(providers); | |
608 | assertEquals(2, providers.size()); | |
cfdb727a | 609 | |
eb1bab5b BH |
610 | //Verify first provider |
611 | assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers.get(0).getName()); | |
612 | assertEquals(9379, providers.get(0).getPid()); | |
cfdb727a | 613 | |
eb1bab5b BH |
614 | // Verify event info |
615 | IBaseEventInfo[] events = providers.get(0).getEvents(); | |
616 | assertNotNull(events); | |
617 | assertEquals(2, events.length); | |
618 | ||
cfdb727a | 619 | IBaseEventInfo baseEventInfo = events[0]; |
eb1bab5b BH |
620 | assertNotNull(baseEventInfo); |
621 | assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo.getName()); | |
4775bcbf | 622 | assertEquals(TraceLogLevel.TRACE_DEBUG_MODULE, baseEventInfo.getLogLevel()); |
eb1bab5b | 623 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); |
cfdb727a AM |
624 | |
625 | baseEventInfo = events[1]; | |
eb1bab5b BH |
626 | assertEquals("ust_tests_hello:tptest", baseEventInfo.getName()); |
627 | assertEquals(TraceLogLevel.TRACE_INFO, baseEventInfo.getLogLevel()); | |
628 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); | |
629 | ||
630 | //Verify second provider | |
631 | assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers.get(1).getName()); | |
632 | assertEquals(4852, providers.get(1).getPid()); | |
cfdb727a | 633 | |
eb1bab5b BH |
634 | // Verify event info |
635 | events = providers.get(1).getEvents(); | |
636 | assertNotNull(events); | |
637 | assertEquals(2, events.length); | |
638 | ||
cfdb727a | 639 | baseEventInfo = events[0]; |
eb1bab5b BH |
640 | assertNotNull(baseEventInfo); |
641 | assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo.getName()); | |
642 | assertEquals(TraceLogLevel.TRACE_WARNING, baseEventInfo.getLogLevel()); | |
643 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); | |
cfdb727a AM |
644 | |
645 | baseEventInfo = events[1]; | |
eb1bab5b | 646 | assertEquals("ust_tests_hello:tptest", baseEventInfo.getName()); |
4775bcbf | 647 | assertEquals(TraceLogLevel.TRACE_DEBUG_FUNCTION, baseEventInfo.getLogLevel()); |
eb1bab5b BH |
648 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); |
649 | ||
650 | } catch (ExecutionException e) { | |
651 | fail(e.toString()); | |
652 | } | |
653 | } | |
d132bcc7 | 654 | |
2ba3d0a1 | 655 | @Test |
eb1bab5b BH |
656 | public void testUstProvider2() { |
657 | try { | |
d132bcc7 BH |
658 | fShell.setScenario(SCEN_GET_UST_PROVIDER2); |
659 | List<IUstProviderInfo> providers = fService.getUstProvider(); | |
eb1bab5b BH |
660 | |
661 | assertNotNull(providers); | |
662 | assertEquals(0, providers.size()); | |
cfdb727a | 663 | |
eb1bab5b BH |
664 | } catch (ExecutionException e) { |
665 | fail(e.toString()); | |
666 | } | |
667 | } | |
d132bcc7 | 668 | |
2ba3d0a1 | 669 | @Test |
d4514365 BH |
670 | public void testGetUstProvider3() { |
671 | try { | |
672 | fShell.setScenario(SCEN_GET_UST_PROVIDER3); | |
673 | // Set version | |
674 | ((LTTngControlService)fService).setVersion("2.1.0"); | |
675 | List<IUstProviderInfo> providers = fService.getUstProvider(); | |
676 | ||
677 | // Check all providers | |
678 | assertNotNull(providers); | |
679 | assertEquals(2, providers.size()); | |
680 | ||
681 | //Verify first provider | |
682 | assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers.get(0).getName()); | |
683 | assertEquals(9379, providers.get(0).getPid()); | |
684 | ||
685 | // Verify event info | |
686 | IBaseEventInfo[] events = providers.get(0).getEvents(); | |
687 | assertNotNull(events); | |
688 | assertEquals(2, events.length); | |
689 | ||
690 | IBaseEventInfo baseEventInfo = events[0]; | |
691 | assertNotNull(baseEventInfo); | |
692 | IFieldInfo[] fields = baseEventInfo.getFields(); | |
693 | assertNotNull(fields); | |
694 | assertEquals(0, fields.length); | |
695 | ||
696 | baseEventInfo = events[1]; | |
697 | fields = baseEventInfo.getFields(); | |
698 | assertNotNull(fields); | |
699 | assertEquals(3, fields.length); | |
700 | assertEquals("doublefield", fields[0].getName()); | |
701 | assertEquals("float", fields[0].getFieldType()); | |
702 | ||
703 | assertEquals("floatfield", fields[1].getName()); | |
704 | assertEquals("float", fields[1].getFieldType()); | |
705 | ||
706 | assertEquals("stringfield", fields[2].getName()); | |
707 | assertEquals("string", fields[2].getFieldType()); | |
708 | ||
709 | //Verify second provider | |
710 | assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers.get(1).getName()); | |
711 | assertEquals(4852, providers.get(1).getPid()); | |
712 | ||
713 | // Verify event info | |
714 | events = providers.get(1).getEvents(); | |
715 | assertNotNull(events); | |
716 | assertEquals(2, events.length); | |
717 | ||
718 | baseEventInfo = events[0]; | |
719 | assertNotNull(baseEventInfo); | |
720 | fields = baseEventInfo.getFields(); | |
721 | assertNotNull(fields); | |
722 | assertEquals(0, fields.length); | |
723 | ||
724 | baseEventInfo = events[1]; | |
725 | fields = baseEventInfo.getFields(); | |
726 | assertNotNull(fields); | |
727 | assertEquals(3, fields.length); | |
728 | ||
729 | assertEquals("doublefield", fields[0].getName()); | |
730 | assertEquals("float", fields[0].getFieldType()); | |
731 | ||
732 | assertEquals("floatfield", fields[1].getName()); | |
733 | assertEquals("float", fields[1].getFieldType()); | |
734 | ||
735 | assertEquals("stringfield", fields[2].getName()); | |
736 | assertEquals("string", fields[2].getFieldType()); | |
737 | ||
738 | // Reset version | |
739 | ((LTTngControlService)fService).setVersion("2.0.0"); | |
740 | ||
741 | } catch (ExecutionException e) { | |
742 | fail(e.toString()); | |
743 | } | |
744 | } | |
745 | ||
f3e2f354 BH |
746 | |
747 | @Test | |
748 | public void testGetKernelProviderNoUst1() { | |
749 | try { | |
750 | fShell.setScenario(SCEN_LIST_WITH_NO_UST1); | |
751 | List<IUstProviderInfo> providerList = fService.getUstProvider(new NullProgressMonitor()); | |
752 | ||
753 | // Verify Provider info | |
754 | assertNotNull(providerList); | |
755 | assertEquals(0, providerList.size()); | |
756 | ||
757 | } catch (ExecutionException e) { | |
758 | fail(e.toString()); | |
759 | } | |
760 | } | |
761 | ||
762 | ||
763 | @Test | |
764 | public void testGetKernelProviderNoUst2() { | |
765 | try { | |
766 | // Set version | |
767 | ((LTTngControlService)fService).setVersion("2.1.0"); | |
768 | ||
769 | fShell.setScenario(SCEN_LIST_WITH_NO_UST2); | |
770 | List<IUstProviderInfo> providerList = fService.getUstProvider(new NullProgressMonitor()); | |
771 | ||
772 | // Verify Provider info | |
773 | assertNotNull(providerList); | |
774 | assertEquals(0, providerList.size()); | |
775 | ||
776 | // Reset version | |
777 | ((LTTngControlService)fService).setVersion("2.0.0"); | |
778 | ||
779 | } catch (ExecutionException e) { | |
780 | fail(e.toString()); | |
781 | } | |
782 | } | |
783 | ||
784 | @Test | |
785 | public void testGetKernelProviderNoUst3() { | |
786 | try { | |
787 | ||
788 | // Set version | |
789 | ((LTTngControlService)fService).setVersion("2.1.0"); | |
790 | ||
791 | fShell.setScenario(SCEN_LIST_WITH_NO_UST3); | |
792 | List<IUstProviderInfo> providerList = fService.getUstProvider(new NullProgressMonitor()); | |
793 | ||
794 | // Verify provider info | |
795 | assertNotNull(providerList); | |
796 | assertEquals(0, providerList.size()); | |
797 | ||
798 | // Reset version | |
799 | ((LTTngControlService)fService).setVersion("2.0.0"); | |
800 | ||
801 | } catch (ExecutionException e) { | |
802 | fail(e.toString()); | |
803 | } | |
804 | } | |
805 | ||
806 | @Test | |
807 | public void testGetKernelProviderNoUstVerbose() { | |
808 | try { | |
809 | enableVerbose(); | |
810 | ||
811 | // Set version | |
812 | ((LTTngControlService)fService).setVersion("2.1.0"); | |
813 | ||
814 | fShell.setScenario(SCEN_LIST_WITH_NO_UST_VERBOSE); | |
815 | List<IUstProviderInfo> providerList = fService.getUstProvider(new NullProgressMonitor()); | |
816 | ||
817 | // Verify provider info | |
818 | assertNotNull(providerList); | |
819 | assertEquals(0, providerList.size()); | |
820 | ||
821 | // Reset version | |
822 | ((LTTngControlService)fService).setVersion("2.0.0"); | |
823 | ||
824 | } catch (ExecutionException e) { | |
825 | fail(e.toString()); | |
826 | } finally { | |
827 | disableVerbose(); | |
828 | } | |
829 | } | |
830 | ||
831 | ||
832 | ||
2ba3d0a1 | 833 | @Test |
bbb3538a BH |
834 | public void testCreateSession() { |
835 | try { | |
d132bcc7 BH |
836 | fShell.setScenario(SCEN_CREATE_SESSION1); |
837 | ||
f7d4d450 | 838 | ISessionInfo info = fService.createSession(new SessionInfo("mysession2"), new NullProgressMonitor()); |
bbb3538a BH |
839 | assertNotNull(info); |
840 | assertEquals("mysession2", info.getName()); | |
841 | assertNotNull(info.getSessionPath()); | |
842 | assertTrue(info.getSessionPath().contains("mysession2")); | |
843 | assertEquals(TraceSessionState.INACTIVE, info.getSessionState()); | |
844 | } catch (ExecutionException e) { | |
845 | fail(e.toString()); | |
846 | } | |
847 | } | |
d132bcc7 | 848 | |
2ba3d0a1 | 849 | @Test |
d6fc6e1b BH |
850 | public void testCreateSessionWithPrompt() { |
851 | try { | |
a07c7629 | 852 | // First line has the shell prompt before the command output |
d6fc6e1b BH |
853 | // This can happen in a real application if the command line is not echoed by the shell. |
854 | fShell.setScenario(SCEN_CREATE_SESSION_WITH_PROMPT); | |
855 | ||
856 | // First line has no shell prompt before the output | |
f7d4d450 | 857 | ISessionInfo info = fService.createSession(new SessionInfo("mysession2"), new NullProgressMonitor()); |
d6fc6e1b BH |
858 | assertNotNull(info); |
859 | assertEquals("mysession2", info.getName()); | |
860 | assertNotNull(info.getSessionPath()); | |
861 | assertTrue(info.getSessionPath().contains("mysession2")); | |
862 | assertEquals(TraceSessionState.INACTIVE, info.getSessionState()); | |
863 | } catch (ExecutionException e) { | |
864 | fail(e.toString()); | |
865 | } | |
866 | } | |
867 | ||
2ba3d0a1 | 868 | @Test |
d132bcc7 BH |
869 | public void testCreateSessionVariants() { |
870 | ||
871 | fShell.setScenario(SCEN_CREATE_SESSION_VARIANTS); | |
872 | ||
bbb3538a | 873 | try { |
f7d4d450 | 874 | fService.createSession(new SessionInfo("alreadyExist"), new NullProgressMonitor()); |
bbb3538a BH |
875 | fail("No exeption thrown"); |
876 | } catch (ExecutionException e) { | |
877 | // success | |
878 | } | |
cfdb727a | 879 | |
bbb3538a | 880 | try { |
f7d4d450 | 881 | fService.createSession(new SessionInfo("wrongName"), new NullProgressMonitor()); |
bbb3538a BH |
882 | fail("No exeption thrown"); |
883 | } catch (ExecutionException e) { | |
884 | // success | |
cfdb727a | 885 | } |
bbb3538a BH |
886 | |
887 | try { | |
f7d4d450 MAL |
888 | ISessionInfo sessionInfo = new SessionInfo("withPath"); |
889 | sessionInfo.setSessionPath("/home/user/hallo"); | |
890 | fService.createSession(sessionInfo, new NullProgressMonitor()); | |
bbb3538a BH |
891 | fail("No exeption thrown"); |
892 | } catch (ExecutionException e) { | |
893 | // success | |
cfdb727a | 894 | } |
bbb3538a BH |
895 | |
896 | try { | |
f7d4d450 | 897 | ISessionInfo info = fService.createSession(new SessionInfo("session with spaces"), new NullProgressMonitor()); |
bbb3538a BH |
898 | assertNotNull(info); |
899 | assertEquals("session with spaces", info.getName()); | |
900 | assertNotNull(info.getSessionPath()); | |
901 | assertTrue(info.getSessionPath().contains("session with spaces")); | |
902 | assertEquals(TraceSessionState.INACTIVE, info.getSessionState()); | |
cfdb727a | 903 | |
bbb3538a BH |
904 | } catch (ExecutionException e) { |
905 | fail(e.toString()); | |
cfdb727a | 906 | } |
bbb3538a BH |
907 | |
908 | try { | |
f7d4d450 MAL |
909 | ISessionInfo sessionInfo = new SessionInfo("pathWithSpaces"); |
910 | sessionInfo.setSessionPath("/home/user/hallo user/here"); | |
911 | ISessionInfo info = fService.createSession(sessionInfo, new NullProgressMonitor()); | |
bbb3538a BH |
912 | assertNotNull(info); |
913 | assertEquals("pathWithSpaces", info.getName()); | |
914 | assertNotNull(info.getSessionPath()); | |
915 | assertTrue(info.getSessionPath().contains("/home/user/hallo user/here")); | |
916 | assertEquals(TraceSessionState.INACTIVE, info.getSessionState()); | |
cfdb727a | 917 | |
bbb3538a BH |
918 | } catch (ExecutionException e) { |
919 | fail(e.toString()); | |
cfdb727a | 920 | } |
bbb3538a BH |
921 | } |
922 | ||
2ba3d0a1 | 923 | @Test |
9d8a90ad | 924 | public void testDestroySession() { |
bbb3538a | 925 | try { |
d132bcc7 BH |
926 | fShell.setScenario(SCEN_DESTROY_SESSION1); |
927 | fService.destroySession("mysession2", new NullProgressMonitor()); | |
bbb3538a BH |
928 | } catch (ExecutionException e) { |
929 | fail(e.toString()); | |
cfdb727a | 930 | } |
bbb3538a | 931 | } |
d132bcc7 | 932 | |
d128c979 BH |
933 | @Test |
934 | public void testDestroySessionVerbose() { | |
935 | try { | |
936 | enableVerbose(); | |
937 | fShell.setScenario(SCEN_DESTROY_SESSION_VERBOSE); | |
938 | fService.destroySession("mysession2", new NullProgressMonitor()); | |
939 | } catch (ExecutionException e) { | |
940 | fail(e.toString()); | |
941 | } finally { | |
942 | disableVerbose(); | |
943 | } | |
944 | } | |
945 | ||
2ba3d0a1 | 946 | @Test |
d132bcc7 BH |
947 | public void testCreateChannel() { |
948 | try { | |
83051fc3 | 949 | ((LTTngControlService)fService).setVersion("2.2.0"); |
d132bcc7 | 950 | String sessionName = "mysession2"; |
e0838ca1 | 951 | List<String> list = new ArrayList<>(); |
d132bcc7 BH |
952 | String kernelChannel0 = "mychannel0"; |
953 | String kernelChannel1 = "mychannel1"; | |
954 | list.add(kernelChannel0); | |
955 | list.add(kernelChannel1); | |
cfdb727a | 956 | |
d132bcc7 | 957 | fShell.setScenario(SCEN_CHANNEL_HANDLING); |
cfdb727a | 958 | |
d132bcc7 BH |
959 | // Create/enable/configure 2 kernel channels |
960 | ChannelInfo chanInfo = new ChannelInfo(""); | |
961 | chanInfo.setOverwriteMode(true); | |
962 | chanInfo.setSubBufferSize(16384); | |
963 | chanInfo.setReadTimer(100); | |
964 | chanInfo.setSwitchTimer(200); | |
965 | chanInfo.setNumberOfSubBuffers(2); | |
e799e5f3 SD |
966 | chanInfo.setMaxNumberTraceFiles(10); |
967 | chanInfo.setMaxSizeTraceFiles(0); | |
1bc37054 | 968 | fService.enableChannels(sessionName, list, TraceDomainType.KERNEL, chanInfo, new NullProgressMonitor()); |
cfdb727a | 969 | |
d132bcc7 BH |
970 | // Create/enable/configure 1 UST channel |
971 | list.clear(); | |
972 | list.add("ustChannel"); | |
cfdb727a | 973 | |
d132bcc7 BH |
974 | chanInfo = new ChannelInfo(""); |
975 | chanInfo.setOverwriteMode(true); | |
976 | chanInfo.setSubBufferSize(32768); | |
977 | chanInfo.setReadTimer(200); | |
978 | chanInfo.setSwitchTimer(100); | |
979 | chanInfo.setNumberOfSubBuffers(1); | |
e799e5f3 SD |
980 | chanInfo.setMaxNumberTraceFiles(20); |
981 | chanInfo.setMaxSizeTraceFiles(0); | |
1bc37054 | 982 | fService.enableChannels(sessionName, list, TraceDomainType.UST, chanInfo, new NullProgressMonitor()); |
83051fc3 | 983 | ((LTTngControlService)fService).setVersion("2.0.0"); |
e799e5f3 SD |
984 | |
985 | } catch (ExecutionException e) { | |
986 | fail(e.toString()); | |
987 | } | |
988 | } | |
989 | ||
990 | @Test | |
991 | public void testCreateChannelUIDBuffer() { | |
992 | try { | |
83051fc3 | 993 | ((LTTngControlService)fService).setVersion("2.2.0"); |
e799e5f3 | 994 | String sessionName = "mysession2"; |
e0838ca1 | 995 | List<String> list = new ArrayList<>(); |
e799e5f3 SD |
996 | String USTChannel = "ustChannel"; |
997 | list.add(USTChannel); | |
998 | fShell.setScenario(SCEN_CHANNEL_HANDLING); | |
999 | ||
1000 | ChannelInfo chanInfo = new ChannelInfo(""); | |
1001 | chanInfo.setOverwriteMode(true); | |
1002 | chanInfo.setSubBufferSize(32768); | |
1003 | chanInfo.setReadTimer(200); | |
1004 | chanInfo.setSwitchTimer(100); | |
1005 | chanInfo.setNumberOfSubBuffers(1); | |
1006 | chanInfo.setMaxNumberTraceFiles(20); | |
1007 | chanInfo.setMaxSizeTraceFiles(0); | |
83051fc3 | 1008 | chanInfo.setBufferType(BufferType.BUFFER_PER_UID); |
1bc37054 | 1009 | fService.enableChannels(sessionName, list, TraceDomainType.UST, chanInfo, new NullProgressMonitor()); |
83051fc3 BH |
1010 | ((LTTngControlService)fService).setVersion("2.0.0"); |
1011 | ||
1012 | } catch (ExecutionException e) { | |
1013 | fail(e.toString()); | |
1014 | } | |
1015 | } | |
1016 | ||
1017 | @Test | |
1018 | public void testCreateChannelPIDBuffer() { | |
1019 | try { | |
1020 | ((LTTngControlService)fService).setVersion("2.2.0"); | |
1021 | String sessionName = "mysession2"; | |
e0838ca1 | 1022 | List<String> list = new ArrayList<>(); |
83051fc3 BH |
1023 | String USTChannel = "ustChannel"; |
1024 | list.add(USTChannel); | |
1025 | fShell.setScenario(SCEN_CHANNEL_HANDLING); | |
1026 | ||
1027 | ||
1028 | ChannelInfo chanInfo = new ChannelInfo(""); | |
1029 | chanInfo.setOverwriteMode(true); | |
1030 | chanInfo.setSubBufferSize(-1); | |
1031 | chanInfo.setReadTimer(-1); | |
1032 | chanInfo.setSwitchTimer(-1); | |
1033 | chanInfo.setNumberOfSubBuffers(-1); | |
1034 | chanInfo.setMaxNumberTraceFiles(-1); | |
1035 | chanInfo.setMaxSizeTraceFiles(-1); | |
1036 | chanInfo.setBufferType(BufferType.BUFFER_PER_PID); | |
1037 | ||
1bc37054 | 1038 | fService.enableChannels(sessionName, list, TraceDomainType.UST, chanInfo, new NullProgressMonitor()); |
83051fc3 | 1039 | ((LTTngControlService)fService).setVersion("2.0.0"); |
d132bcc7 BH |
1040 | |
1041 | } catch (ExecutionException e) { | |
1042 | fail(e.toString()); | |
1043 | } | |
1044 | } | |
1045 | ||
2ba3d0a1 | 1046 | @Test |
d132bcc7 BH |
1047 | public void testDisableChannel() { |
1048 | try { | |
1049 | ||
1050 | String sessionName = "mysession2"; | |
e0838ca1 | 1051 | List<String> list = new ArrayList<>(); |
d132bcc7 BH |
1052 | String kernelChannel0 = "mychannel0"; |
1053 | String kernelChannel1 = "mychannel1"; | |
1054 | list.add(kernelChannel0); | |
1055 | list.add(kernelChannel1); | |
cfdb727a | 1056 | |
d132bcc7 | 1057 | fShell.setScenario(SCEN_CHANNEL_HANDLING); |
1bc37054 | 1058 | fService.disableChannels(sessionName, list, TraceDomainType.KERNEL, new NullProgressMonitor()); |
cfdb727a | 1059 | |
d132bcc7 BH |
1060 | list.clear(); |
1061 | list.add("ustChannel"); | |
1bc37054 | 1062 | fService.disableChannels(sessionName, list, TraceDomainType.UST, new NullProgressMonitor()); |
d132bcc7 BH |
1063 | |
1064 | } catch (ExecutionException e) { | |
1065 | fail(e.toString()); | |
1066 | } | |
1067 | } | |
cfdb727a | 1068 | |
2ba3d0a1 | 1069 | @Test |
d132bcc7 BH |
1070 | public void testEnableChannel() { |
1071 | try { | |
1072 | ||
1073 | String sessionName = "mysession2"; | |
e0838ca1 | 1074 | List<String> list = new ArrayList<>(); |
d132bcc7 BH |
1075 | String kernelChannel0 = "mychannel0"; |
1076 | String kernelChannel1 = "mychannel1"; | |
1077 | list.add(kernelChannel0); | |
1078 | list.add(kernelChannel1); | |
cfdb727a | 1079 | |
d132bcc7 | 1080 | fShell.setScenario(SCEN_CHANNEL_HANDLING); |
1bc37054 | 1081 | fService.enableChannels(sessionName, list, TraceDomainType.KERNEL, null, new NullProgressMonitor()); |
cfdb727a | 1082 | |
d132bcc7 BH |
1083 | // Create/enable/configure 1 UST channel |
1084 | list.clear(); | |
1085 | list.add("ustChannel"); | |
cfdb727a | 1086 | |
1bc37054 | 1087 | fService.enableChannels(sessionName, list, TraceDomainType.UST, null, new NullProgressMonitor()); |
d132bcc7 BH |
1088 | |
1089 | } catch (ExecutionException e) { | |
1090 | fail(e.toString()); | |
1091 | } | |
1092 | } | |
cfdb727a | 1093 | |
2ba3d0a1 | 1094 | @Test |
d132bcc7 BH |
1095 | public void testEnableEvents() { |
1096 | try { | |
d132bcc7 | 1097 | String sessionName = "mysession2"; |
a959e694 BR |
1098 | String channelName = "mychannel"; |
1099 | // Lists | |
1100 | List<String> eventList = new ArrayList<>(); | |
1101 | List<String> excludeList = new ArrayList<>(); | |
1102 | // Events | |
d132bcc7 BH |
1103 | String eventName0 = "block_rq_remap"; |
1104 | String eventName1 = "block_bio_remap"; | |
1105 | String eventName2 = "softirq_entry"; | |
a959e694 BR |
1106 | String ustEventName0 = "ust_tests_hello:tptest_sighandler"; |
1107 | String ustEventName1 = "ust_tests_bye:tptest_sighandler"; | |
1108 | String ustEventWildcard = "ust*"; | |
1109 | ||
d132bcc7 | 1110 | fShell.setScenario(SCEN_EVENT_HANDLING); |
cfdb727a | 1111 | |
a959e694 BR |
1112 | // 1) session name, channel = null, 3 event names, kernel |
1113 | eventList.add(eventName0); | |
1114 | eventList.add(eventName1); | |
1115 | eventList.add(eventName2); | |
1bc37054 | 1116 | fService.enableEvents(sessionName, null, eventList, TraceDomainType.KERNEL, null, null, new NullProgressMonitor()); |
a959e694 BR |
1117 | |
1118 | // 2) session name, channel = mychannel, event name= null, kernel | |
1bc37054 | 1119 | fService.enableEvents(sessionName, channelName, null, TraceDomainType.KERNEL, null, null, new NullProgressMonitor()); |
bbb3538a | 1120 | |
a959e694 BR |
1121 | // 3) session name, channel = mychannel, 1 event name, ust, no filter |
1122 | eventList.clear(); | |
1123 | eventList.add(ustEventName0); | |
1bc37054 | 1124 | fService.enableEvents(sessionName, channelName, eventList, TraceDomainType.UST, null, null, new NullProgressMonitor()); |
cfdb727a | 1125 | |
d4514365 | 1126 | // 4) session name, channel = mychannel, no event name, ust, with filter |
1bc37054 | 1127 | fService.enableEvents(sessionName, channelName, eventList, TraceDomainType.UST, "intfield==10", null, new NullProgressMonitor()); |
d4514365 BH |
1128 | |
1129 | // 5) session name, channel = mychannel, no event name, ust, no filter | |
a959e694 | 1130 | eventList.clear(); |
1bc37054 | 1131 | fService.enableEvents(sessionName, channelName, eventList, TraceDomainType.UST, null, null, new NullProgressMonitor()); |
d4514365 | 1132 | |
9ee91a86 | 1133 | // 6) session name, channel = null, |
1bc37054 | 1134 | fService.enableEvents(sessionName, null, ILttngControlService.ALL_EVENTS, TraceDomainType.KERNEL, null, null, new NullProgressMonitor()); |
cfdb727a | 1135 | |
a959e694 BR |
1136 | // 7) session name, channel = mychannel, all events, ust, exclude 1 event |
1137 | excludeList.add(ustEventName0); | |
1bc37054 | 1138 | fService.enableEvents(sessionName, channelName, null, TraceDomainType.UST, null, excludeList, new NullProgressMonitor()); |
a959e694 BR |
1139 | |
1140 | // 8) session name, channel = mychannel, all events, ust, exclude 2 events | |
1141 | excludeList.add(ustEventName1); | |
1bc37054 | 1142 | fService.enableEvents(sessionName, channelName, null, TraceDomainType.UST, null, excludeList, new NullProgressMonitor()); |
a959e694 BR |
1143 | |
1144 | // 9) session name, channel = mychannel, enable 'ust*', ust, exclude 2 events | |
1145 | eventList.add(ustEventWildcard); | |
1bc37054 | 1146 | fService.enableEvents(sessionName, channelName, eventList, TraceDomainType.UST, null, excludeList, new NullProgressMonitor()); |
a959e694 BR |
1147 | |
1148 | } catch (ExecutionException e) { | |
1149 | fail(e.toString()); | |
1150 | } | |
1151 | } | |
1152 | ||
1153 | @Test | |
1154 | public void testEventExcluded() { | |
1155 | try { | |
1156 | String sessionName = "mysession2"; | |
1157 | String channelName = "mychannel"; | |
1158 | // Lists | |
1159 | List<String> eventList = new ArrayList<>(); | |
1160 | List<String> excludeList = new ArrayList<>(); | |
1161 | // Events | |
1162 | String ustEventName0 = "ust_tests_hello:tptest_sighandler"; | |
1163 | String ustEventName1 = "ust_tests_bye:tptest_sighandler"; | |
1164 | String ustEventWildcard = "ust*"; | |
1165 | ||
1166 | @NonNull | |
1167 | LttngVersion version = fService.getVersion(); | |
1bc37054 | 1168 | fShell.setScenario(SCEN_EVENT_EXCLUDED); |
a959e694 BR |
1169 | |
1170 | // 1) 1 event excluded | |
1171 | eventList.add(ustEventWildcard); | |
1172 | excludeList.add(ustEventName0); | |
1bc37054 | 1173 | fService.enableEvents(sessionName, channelName, eventList, TraceDomainType.UST, null, excludeList, new NullProgressMonitor()); |
a959e694 BR |
1174 | |
1175 | @Nullable | |
1176 | ISessionInfo session = fService.getSession(sessionName, new NullProgressMonitor()); | |
1177 | assertNotNull(session); | |
1178 | IEventInfo eventInfo = session.getDomains()[0].getChannels()[0].getEvents()[0]; | |
1179 | assertNotNull(eventInfo); | |
1180 | // version 2.8 and above supports the excluded events list | |
1181 | if (version.getMajor() > 1 && version.getMinor() > 7) { | |
1182 | assertTrue(eventInfo.getExcludedEvents().contains(ustEventName0)); | |
1183 | } else { | |
1184 | assertEquals("has exclusions", eventInfo.getExcludedEvents()); | |
1185 | } | |
1186 | ||
1187 | // 2) 2 events excluded | |
1188 | excludeList.add(ustEventName1); | |
1bc37054 | 1189 | fService.enableEvents(sessionName, channelName, eventList, TraceDomainType.UST, null, excludeList, new NullProgressMonitor()); |
a959e694 BR |
1190 | |
1191 | session = fService.getSession(sessionName, new NullProgressMonitor()); | |
1192 | assertNotNull(session); | |
1193 | eventInfo = session.getDomains()[0].getChannels()[0].getEvents()[0]; | |
1194 | assertNotNull(eventInfo); | |
1195 | ||
1196 | // version 2.8 and above supports the excluded events list | |
1197 | if (version.getMajor() > 1 && version.getMinor() > 7) { | |
1198 | assertTrue(eventInfo.getExcludedEvents().contains(ustEventName0)); | |
1199 | assertTrue(eventInfo.getExcludedEvents().contains(ustEventName1)); | |
1200 | } else { | |
1201 | assertEquals("has exclusions", eventInfo.getExcludedEvents()); | |
1202 | } | |
1203 | ||
d132bcc7 BH |
1204 | } catch (ExecutionException e) { |
1205 | fail(e.toString()); | |
1206 | } | |
1207 | } | |
cfdb727a | 1208 | |
2ba3d0a1 | 1209 | @Test |
d132bcc7 BH |
1210 | public void testEnableSyscalls() { |
1211 | try { | |
1212 | // 1) session name, channel = null, 3 event names, kernel | |
1213 | String sessionName = "mysession2"; | |
1214 | String channelName = "mychannel"; | |
cfdb727a | 1215 | |
d132bcc7 BH |
1216 | fShell.setScenario(SCEN_EVENT_HANDLING); |
1217 | ||
cfdb727a | 1218 | // 1) session name, channel = null |
d132bcc7 BH |
1219 | fService.enableSyscalls(sessionName, null, new NullProgressMonitor()); |
1220 | ||
1221 | // 2) session name, channel = mychannel | |
1222 | fService.enableSyscalls(sessionName, channelName, new NullProgressMonitor()); | |
cfdb727a | 1223 | |
d132bcc7 BH |
1224 | } catch (ExecutionException e) { |
1225 | fail(e.toString()); | |
1226 | } | |
1227 | } | |
1228 | ||
2ba3d0a1 | 1229 | @Test |
d132bcc7 BH |
1230 | public void testDynamicProbe() { |
1231 | try { | |
1232 | // 1) session name, channel = null, 3 event names, kernel | |
1233 | String sessionName = "mysession2"; | |
1234 | String channelName = "mychannel"; | |
1235 | String eventName0 = "myevent0"; | |
1236 | String eventName1 = "myevent1"; | |
1237 | String functionProbe = "0xc0101340"; | |
1238 | String dynProbe = "init_post"; | |
cfdb727a | 1239 | |
d132bcc7 BH |
1240 | fShell.setScenario(SCEN_EVENT_HANDLING); |
1241 | ||
cfdb727a | 1242 | // 1) session name, channel = null, event name, function probe, probe |
d132bcc7 BH |
1243 | fService.enableProbe(sessionName, null, eventName0, true, functionProbe, new NullProgressMonitor()); |
1244 | ||
1245 | // 2) session name, channel = mychannel | |
1246 | fService.enableProbe(sessionName, channelName, eventName1, false, dynProbe, new NullProgressMonitor()); | |
cfdb727a | 1247 | |
d132bcc7 BH |
1248 | } catch (ExecutionException e) { |
1249 | fail(e.toString()); | |
1250 | } | |
1251 | } | |
1252 | ||
2ba3d0a1 | 1253 | @Test |
d132bcc7 BH |
1254 | public void testEnableLogLevel() { |
1255 | try { | |
1256 | // 1) session name, channel = null, 3 event names, kernel | |
1257 | String sessionName = "mysession2"; | |
1258 | String channelName = "mychannel"; | |
1259 | String eventName4 = "myevent4"; | |
1260 | String eventName5 = "myevent5"; | |
cfdb727a | 1261 | |
d132bcc7 | 1262 | fShell.setScenario(SCEN_EVENT_HANDLING); |
cfdb727a | 1263 | |
d132bcc7 | 1264 | // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG |
d4514365 | 1265 | fService.enableLogLevel(sessionName, null, eventName4, LogLevelType.LOGLEVEL_ONLY, TraceLogLevel.TRACE_DEBUG, null, new NullProgressMonitor()); |
d132bcc7 BH |
1266 | |
1267 | // 2) session name, channel = mychannel, null, loglevel, TRACE_DEBUG_FUNCTION | |
d4514365 BH |
1268 | fService.enableLogLevel(sessionName, channelName, eventName5, LogLevelType.LOGLEVEL, TraceLogLevel.TRACE_DEBUG_FUNCTION, null, new NullProgressMonitor()); |
1269 | ||
1270 | // TODO add test with filters | |
d132bcc7 BH |
1271 | |
1272 | } catch (ExecutionException e) { | |
1273 | fail(e.toString()); | |
1274 | } | |
1275 | } | |
cfdb727a | 1276 | |
2ba3d0a1 | 1277 | @Test |
4ea599a5 BH |
1278 | public void testAddContext() { |
1279 | try { | |
1280 | // 1) session name, channel = null, 3 event names, kernel | |
1281 | String sessionName = "mysession2"; | |
1282 | String channelName = "mychannel"; | |
1283 | String eventName = "ust_tests_hello:tptest_sighandler"; | |
e0838ca1 | 1284 | List<String> contexts = new ArrayList<>(); |
4ea599a5 BH |
1285 | contexts.add("prio"); |
1286 | contexts.add("pid"); | |
1287 | ||
1288 | fShell.setScenario(SCEN_CONTEXT_HANDLING); | |
1289 | ||
1290 | List<String> availContexts = fService.getContextList(new NullProgressMonitor()); | |
1291 | assertNotNull(availContexts); | |
1292 | assertEquals(12, availContexts.size()); | |
1293 | ||
cfdb727a | 1294 | // A very "hard-coded" way to verify but it works ... |
e0838ca1 | 1295 | Set<String> expectedContexts = new HashSet<>(); |
4ea599a5 BH |
1296 | expectedContexts.add("pid"); |
1297 | expectedContexts.add("procname"); | |
1298 | expectedContexts.add("prio"); | |
1299 | expectedContexts.add("nice"); | |
1300 | expectedContexts.add("vpid"); | |
1301 | expectedContexts.add("tid"); | |
1302 | expectedContexts.add("pthread_id"); | |
1303 | expectedContexts.add("vtid"); | |
1304 | expectedContexts.add("ppid"); | |
1305 | expectedContexts.add("vppid"); | |
1306 | expectedContexts.add("perf:cpu-cycles"); | |
1307 | expectedContexts.add("perf:cycles"); | |
cfdb727a | 1308 | |
4ea599a5 | 1309 | assertTrue(expectedContexts.containsAll(availContexts)); |
cfdb727a | 1310 | |
4ea599a5 | 1311 | // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG |
1bc37054 | 1312 | fService.addContexts(sessionName, channelName, eventName, TraceDomainType.UST, contexts, new NullProgressMonitor()); |
4ea599a5 BH |
1313 | |
1314 | } catch (ExecutionException e) { | |
1315 | fail(e.toString()); | |
1316 | } | |
1317 | } | |
1318 | ||
2ba3d0a1 | 1319 | @Test |
4ea599a5 BH |
1320 | public void testAddContextFailure() { |
1321 | ||
1322 | // 1) session name, channel = null, 3 event names, kernel | |
1323 | String sessionName = "mysession2"; | |
1324 | String channelName = "mychannel"; | |
1325 | String eventName = "ust_tests_hello:tptest_sighandler"; | |
e0838ca1 | 1326 | List<String> contexts = new ArrayList<>(); |
4ea599a5 BH |
1327 | contexts.add("prio"); |
1328 | contexts.add("pid"); | |
1329 | fShell.setScenario(SCEN_CONTEXT_ERROR_HANDLING); | |
1330 | try { | |
1331 | fService.getContextList(new NullProgressMonitor()); | |
1332 | fail("No exeption generated"); | |
1333 | } catch (ExecutionException e) { | |
1334 | // success | |
cfdb727a | 1335 | } |
4ea599a5 BH |
1336 | try { |
1337 | // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG | |
1bc37054 | 1338 | fService.addContexts(sessionName, channelName, eventName, TraceDomainType.UST, contexts, new NullProgressMonitor()); |
4ea599a5 BH |
1339 | fail("No exeption generated"); |
1340 | } catch (ExecutionException e) { | |
1341 | // success | |
cfdb727a | 1342 | } |
4ea599a5 BH |
1343 | } |
1344 | ||
a30e79fe | 1345 | @Test |
f3b33d40 BH |
1346 | public void testCreateSession2_1() { |
1347 | ||
1348 | try { | |
1349 | fShell.setScenario(SCEN_CREATE_SESSION_2_1); | |
1350 | ||
f7d4d450 MAL |
1351 | ISessionInfo sessionInfo = new SessionInfo("mysession"); |
1352 | sessionInfo.setNetworkUrl("net://172.0.0.1"); | |
1353 | sessionInfo.setStreamedTrace(true); | |
1354 | ISessionInfo info = fService.createSession(sessionInfo, new NullProgressMonitor()); | |
f3b33d40 BH |
1355 | assertNotNull(info); |
1356 | assertEquals("mysession", info.getName()); | |
1357 | assertEquals("net://172.0.0.1", info.getSessionPath()); | |
1358 | assertTrue(info.isStreamedTrace()); | |
1359 | fService.destroySession("mysession", new NullProgressMonitor()); | |
1360 | ||
f7d4d450 MAL |
1361 | sessionInfo = new SessionInfo("mysession"); |
1362 | sessionInfo.setStreamedTrace(true); | |
1363 | sessionInfo.setNetworkUrl("file:///tmp"); | |
1364 | info = fService.createSession(sessionInfo, new NullProgressMonitor()); | |
f3b33d40 BH |
1365 | assertNotNull(info); |
1366 | assertEquals("mysession", info.getName()); | |
1367 | assertEquals("file:///tmp", info.getSessionPath()); | |
d128c979 | 1368 | assertTrue(!info.isStreamedTrace()); |
f3b33d40 BH |
1369 | fService.destroySession("mysession", new NullProgressMonitor()); |
1370 | ||
f7d4d450 MAL |
1371 | sessionInfo = new SessionInfo("mysession"); |
1372 | sessionInfo.setStreamedTrace(true); | |
1373 | sessionInfo.setNetworkUrl("file:///tmp"); | |
1374 | info = fService.createSession(sessionInfo, new NullProgressMonitor()); | |
f3b33d40 BH |
1375 | assertNotNull(info); |
1376 | assertEquals("mysession", info.getName()); | |
1377 | assertEquals("file:///tmp", info.getSessionPath()); | |
d128c979 | 1378 | assertTrue(!info.isStreamedTrace()); |
f3b33d40 BH |
1379 | fService.destroySession("mysession", new NullProgressMonitor()); |
1380 | ||
f7d4d450 MAL |
1381 | sessionInfo = new SessionInfo("mysession"); |
1382 | sessionInfo.setStreamedTrace(true); | |
1383 | sessionInfo.setControlUrl("tcp://172.0.0.1"); | |
1384 | sessionInfo.setDataUrl("tcp://172.0.0.1:5343"); | |
1385 | info = fService.createSession(sessionInfo, new NullProgressMonitor()); | |
f3b33d40 BH |
1386 | assertNotNull(info); |
1387 | assertEquals("mysession", info.getName()); | |
d128c979 | 1388 | assertEquals("", info.getSessionPath()); // the complete network path is not available at this point |
f3b33d40 BH |
1389 | assertTrue(info.isStreamedTrace()); |
1390 | fService.destroySession("mysession", new NullProgressMonitor()); | |
1391 | ||
f7d4d450 MAL |
1392 | sessionInfo = new SessionInfo("mysession"); |
1393 | sessionInfo.setStreamedTrace(true); | |
1394 | sessionInfo.setNetworkUrl("net://172.0.0.1:1234:2345"); | |
1395 | info = fService.createSession(sessionInfo, new NullProgressMonitor()); | |
f3b33d40 BH |
1396 | assertNotNull(info); |
1397 | assertEquals("mysession", info.getName()); | |
1398 | assertEquals("net://172.0.0.1:1234:2345", info.getSessionPath()); | |
1399 | assertTrue(info.isStreamedTrace()); | |
1400 | fService.destroySession("mysession", new NullProgressMonitor()); | |
1401 | ||
d128c979 BH |
1402 | // verbose |
1403 | enableVerbose(); | |
f7d4d450 MAL |
1404 | sessionInfo = new SessionInfo("mysession"); |
1405 | sessionInfo.setStreamedTrace(true); | |
1406 | sessionInfo.setNetworkUrl("net://172.0.0.1"); | |
1407 | info = fService.createSession(sessionInfo, new NullProgressMonitor()); | |
d128c979 BH |
1408 | assertNotNull(info); |
1409 | assertEquals("mysession", info.getName()); | |
1410 | assertEquals("net://172.0.0.1", info.getSessionPath()); | |
1411 | assertTrue(info.isStreamedTrace()); | |
1412 | disableVerbose(); | |
1413 | fService.destroySession("mysession", new NullProgressMonitor()); | |
1414 | ||
1415 | ||
1416 | } catch (ExecutionException e) { | |
1417 | fail(e.toString()); | |
1418 | } | |
1419 | } | |
1420 | ||
1421 | @Test | |
1422 | public void testCreateSessionVerbose2_1() { | |
1423 | try { | |
1424 | fShell.setScenario(SCEN_CREATE_SESSION_VERBOSE_2_1); | |
1425 | ||
1426 | enableVerbose(); | |
f7d4d450 MAL |
1427 | ISessionInfo sessionInfo = new SessionInfo("mysession"); |
1428 | sessionInfo.setStreamedTrace(true); | |
1429 | sessionInfo.setNetworkUrl("net://172.0.0.1"); | |
1430 | ISessionInfo info = fService.createSession(sessionInfo, new NullProgressMonitor()); | |
d128c979 BH |
1431 | assertNotNull(info); |
1432 | assertEquals("mysession", info.getName()); | |
1433 | assertEquals("net://172.0.0.1", info.getSessionPath()); | |
1434 | assertTrue(info.isStreamedTrace()); | |
1435 | fService.destroySession("mysession", new NullProgressMonitor()); | |
f3b33d40 BH |
1436 | } catch (ExecutionException e) { |
1437 | fail(e.toString()); | |
d128c979 BH |
1438 | } finally { |
1439 | disableVerbose(); | |
f3b33d40 BH |
1440 | } |
1441 | } | |
d128c979 | 1442 | |
589d0d33 BH |
1443 | @Test |
1444 | public void testCreateSnapshotSession() { | |
1445 | try { | |
1446 | fShell.setScenario(SCEN_CREATE_SNAPSHOT_SESSION); | |
f7d4d450 MAL |
1447 | ISessionInfo params = new SessionInfo("mysession"); |
1448 | params.setSnapshot(true); | |
1449 | ISessionInfo sessionInfo = fService.createSession(params, new NullProgressMonitor()); | |
589d0d33 BH |
1450 | assertNotNull(sessionInfo); |
1451 | assertEquals("mysession", sessionInfo.getName()); | |
1452 | assertTrue(sessionInfo.isSnapshotSession()); | |
1453 | assertEquals("", sessionInfo.getSessionPath()); | |
1454 | assertTrue(!sessionInfo.isStreamedTrace()); | |
1455 | ||
1456 | assertEquals(TraceSessionState.INACTIVE, sessionInfo.getSessionState()); | |
1457 | ||
cbc46cc9 BH |
1458 | List<String> names = fService.getSessionNames(new NullProgressMonitor()); |
1459 | assertEquals(names.get(0), "mysession"); | |
589d0d33 BH |
1460 | |
1461 | ISnapshotInfo snapshotInfo = fService.getSnapshotInfo("mysession", new NullProgressMonitor()); | |
1462 | assertNotNull(snapshotInfo); | |
1463 | assertEquals("snapshot-1", snapshotInfo.getName()); | |
1464 | assertEquals("/home/user/lttng-traces/mysession-20130913-141651", snapshotInfo.getSnapshotPath()); | |
ad311f36 BH |
1465 | assertEquals(1, snapshotInfo.getId()); |
1466 | assertTrue(!snapshotInfo.isStreamedSnapshot()); | |
1467 | ||
1468 | // we need to set the snapshotInfo to so that the session path is set correctly | |
1469 | sessionInfo.setSnapshotInfo(snapshotInfo); | |
1470 | assertEquals("/home/user/lttng-traces/mysession-20130913-141651", sessionInfo.getSessionPath()); | |
1471 | ||
1472 | fService.recordSnapshot("mysession", new NullProgressMonitor()); | |
1473 | ||
1474 | fService.destroySession("mysession", new NullProgressMonitor()); | |
1475 | ||
1476 | } catch (ExecutionException e) { | |
1477 | fail(e.toString()); | |
1478 | } | |
1479 | } | |
1480 | ||
1481 | @Test | |
1482 | public void testCreateSnapshotSession2_5() { | |
1483 | try { | |
1484 | fShell.setScenario(SCEN_CREATE_SNAPSHOT_SESSION_2_5); | |
1485 | ISessionInfo params = new SessionInfo("mysession"); | |
1486 | params.setSnapshot(true); | |
1487 | ISessionInfo sessionInfo = fService.createSession(params, new NullProgressMonitor()); | |
1488 | assertNotNull(sessionInfo); | |
1489 | assertEquals("mysession", sessionInfo.getName()); | |
1490 | assertTrue(sessionInfo.isSnapshotSession()); | |
1491 | assertEquals("", sessionInfo.getSessionPath()); | |
1492 | assertTrue(!sessionInfo.isStreamedTrace()); | |
1493 | ||
1494 | assertEquals(TraceSessionState.INACTIVE, sessionInfo.getSessionState()); | |
1495 | ||
cbc46cc9 BH |
1496 | List<String> names = fService.getSessionNames(new NullProgressMonitor()); |
1497 | assertEquals(names.get(0), "mysession"); | |
ad311f36 BH |
1498 | |
1499 | ISnapshotInfo snapshotInfo = fService.getSnapshotInfo("mysession", new NullProgressMonitor()); | |
1500 | assertNotNull(snapshotInfo); | |
1501 | assertEquals("snapshot-1", snapshotInfo.getName()); | |
1502 | assertEquals("/home/user/lttng-traces/mysession-20130913-141651", snapshotInfo.getSnapshotPath()); | |
589d0d33 BH |
1503 | assertEquals(1, snapshotInfo.getId()); |
1504 | assertTrue(!snapshotInfo.isStreamedSnapshot()); | |
1505 | ||
1506 | // we need to set the snapshotInfo to so that the session path is set correctly | |
1507 | sessionInfo.setSnapshotInfo(snapshotInfo); | |
1508 | assertEquals("/home/user/lttng-traces/mysession-20130913-141651", sessionInfo.getSessionPath()); | |
1509 | ||
1510 | fService.recordSnapshot("mysession", new NullProgressMonitor()); | |
1511 | ||
1512 | fService.destroySession("mysession", new NullProgressMonitor()); | |
1513 | ||
1514 | } catch (ExecutionException e) { | |
1515 | fail(e.toString()); | |
1516 | } | |
1517 | } | |
1518 | ||
1519 | public void testCreateStreamedSnapshotSession() { | |
1520 | try { | |
1521 | fShell.setScenario(SCEN_CREATE_STREAMED_SNAPSHOT_SESSION); | |
1522 | ||
f7d4d450 MAL |
1523 | ISessionInfo params = new SessionInfo("mysession"); |
1524 | params.setNetworkUrl("net://172.0.0.1"); | |
1525 | ISessionInfo sessionInfo = fService.createSession(params, new NullProgressMonitor()); | |
589d0d33 BH |
1526 | assertNotNull(sessionInfo); |
1527 | assertEquals("mysession", sessionInfo.getName()); | |
1528 | assertTrue(sessionInfo.isSnapshotSession()); | |
1529 | ||
1530 | assertEquals(TraceSessionState.INACTIVE, sessionInfo.getSessionState()); | |
1531 | assertTrue(sessionInfo.isStreamedTrace()); | |
1532 | ||
cbc46cc9 BH |
1533 | List<String> names = fService.getSessionNames(new NullProgressMonitor()); |
1534 | assertEquals(names.get(0), "mysession"); | |
589d0d33 | 1535 | |
589d0d33 BH |
1536 | ISnapshotInfo snapshotInfo = sessionInfo.getSnapshotInfo(); |
1537 | assertNotNull(sessionInfo); | |
1538 | assertEquals("snapshot-2", snapshotInfo.getName()); | |
1539 | assertEquals("net4://172.0.0.1:5342/", snapshotInfo.getSnapshotPath()); | |
1540 | assertEquals(2, snapshotInfo.getId()); | |
1541 | assertTrue(snapshotInfo.isStreamedSnapshot()); | |
1542 | ||
1543 | // we need to set the snapshotInfo to so that the session path is set correctly | |
1544 | sessionInfo.setSnapshotInfo(snapshotInfo); | |
1545 | assertEquals("net4://172.0.0.1:5342/", sessionInfo.getSessionPath()); | |
1546 | ||
1547 | fService.recordSnapshot("mysession", new NullProgressMonitor()); | |
1548 | ||
1549 | fService.destroySession("mysession", new NullProgressMonitor()); | |
1550 | ||
1551 | } catch (ExecutionException e) { | |
1552 | fail(e.toString()); | |
1553 | } | |
1554 | } | |
1555 | ||
589d0d33 BH |
1556 | @Test |
1557 | public void testCreateSnapshotSessionErrors() { | |
1558 | try { | |
1559 | fShell.setScenario(SCEN_CREATE_SNAPSHOT_SESSION_ERRORS); | |
1560 | ||
cbc46cc9 BH |
1561 | List<String> names = fService.getSessionNames(new NullProgressMonitor()); |
1562 | assertEquals(names.get(0), "mysession"); | |
589d0d33 BH |
1563 | } catch (ExecutionException e) { |
1564 | fail(e.toString()); | |
1565 | } | |
1566 | ||
1567 | try { | |
1568 | fService.getSnapshotInfo("blabla", new NullProgressMonitor()); | |
1569 | fail("getSnapshoInfo() didn't fail"); | |
1570 | } catch (ExecutionException e) { | |
1571 | // successful | |
1572 | } | |
1573 | ||
1574 | try { | |
1575 | fService.recordSnapshot("blabla", new NullProgressMonitor()); | |
1576 | fail("getSnapshoInfo() didn't fail"); | |
1577 | } catch (ExecutionException e) { | |
1578 | // successful | |
1579 | } | |
1580 | ||
1581 | try { | |
1582 | fService.recordSnapshot("mysession", new NullProgressMonitor()); | |
1583 | fail("getSnapshoInfo() didn't fail"); | |
1584 | } catch (ExecutionException e) { | |
1585 | // successful | |
1586 | } | |
1587 | } | |
1588 | ||
81d5dc3a | 1589 | @Test |
ee8d0c40 | 1590 | @Ignore |
81d5dc3a MAL |
1591 | public void testCreateLiveSession() throws ExecutionException { |
1592 | fShell.setScenario(SCEN_CREATE_LIVE_SESSION); | |
1593 | ||
1594 | ISessionInfo params = new SessionInfo("mysession"); | |
1595 | params.setLive(true); | |
1596 | params.setStreamedTrace(true); | |
1597 | params.setNetworkUrl("net://127.0.0.1"); | |
1598 | ISessionInfo sessionInfo = fService.createSession(params, new NullProgressMonitor()); | |
1599 | assertNotNull(sessionInfo); | |
1600 | assertEquals("mysession", sessionInfo.getName()); | |
1601 | assertEquals(TraceSessionState.INACTIVE, sessionInfo.getSessionState()); | |
1602 | assertTrue(sessionInfo.isStreamedTrace()); | |
1603 | assertTrue(sessionInfo.isLive()); | |
1604 | assertEquals("net://127.0.0.1", sessionInfo.getSessionPath()); | |
cbc46cc9 BH |
1605 | List<String> names = fService.getSessionNames(new NullProgressMonitor()); |
1606 | assertEquals(names.get(0), "mysession"); | |
81d5dc3a MAL |
1607 | fService.destroySession("mysession", new NullProgressMonitor()); |
1608 | } | |
1609 | ||
1610 | @Test | |
ee8d0c40 | 1611 | @Ignore |
81d5dc3a MAL |
1612 | public void testCreateLiveSessionErrors() { |
1613 | try { | |
1614 | fShell.setScenario(SCEN_CREATE_LIVE_SESSION_ERRORS); | |
1615 | ||
1616 | ISessionInfo parameters = new SessionInfo("mysession"); | |
1617 | parameters.setLive(true); | |
1618 | parameters.setSnapshot(true); | |
1619 | fService.createSession(parameters, new NullProgressMonitor()); | |
1620 | fail("createSession() didn't fail"); | |
1621 | } catch (ExecutionException e) { | |
1622 | // successful | |
1623 | } | |
1624 | ||
1625 | try { | |
1626 | ISessionInfo parameters = new SessionInfo("mysession"); | |
1627 | parameters.setNetworkUrl("blah"); | |
1628 | parameters.setLive(true); | |
1629 | fService.createSession(parameters, new NullProgressMonitor()); | |
1630 | fail("createSession() didn't fail"); | |
1631 | } catch (ExecutionException e) { | |
1632 | // successful | |
1633 | } | |
1634 | ||
1635 | try { | |
1636 | ISessionInfo parameters = new SessionInfo("mysession"); | |
1637 | parameters.setControlUrl("net://127.0.0.1"); | |
1638 | parameters.setLive(true); | |
1639 | fService.createSession(parameters, new NullProgressMonitor()); | |
1640 | fail("createSession() didn't fail"); | |
1641 | } catch (ExecutionException e) { | |
1642 | // successful | |
1643 | } | |
1644 | } | |
1645 | ||
2b7c6996 BH |
1646 | @Test |
1647 | public void testSessionProfile() { | |
1648 | fShell.setScenario(SCEN_SESSION_PROFILES); | |
1649 | final String profile = "/home/user/.lttng/sessions/mysession.lttng"; | |
1650 | try { | |
1651 | fService.loadSession(profile, false, new NullProgressMonitor()); | |
1652 | } catch (ExecutionException e) { | |
1653 | fail("load session failed: " + e); | |
1654 | } | |
1655 | ||
1656 | try { | |
1657 | fService.loadSession(profile, true, new NullProgressMonitor()); | |
1658 | } catch (ExecutionException e) { | |
1659 | fail("load session failed: " + e); | |
1660 | } | |
1661 | ||
1662 | try { | |
1663 | fService.saveSession(null, null, false, new NullProgressMonitor()); | |
1664 | } catch (ExecutionException e) { | |
1665 | fail("save session failed: " + e); | |
1666 | } | |
1667 | ||
1668 | final String sessionName = "mysession"; | |
1669 | try { | |
1670 | fService.saveSession(sessionName, null, false, new NullProgressMonitor()); | |
1671 | } catch (ExecutionException e) { | |
1672 | fail("save session failed: " + e); | |
1673 | } | |
1674 | ||
1675 | try { | |
1676 | fService.saveSession(sessionName, null, true, new NullProgressMonitor()); | |
1677 | } catch (ExecutionException e) { | |
1678 | fail("save session failed: " + e); | |
1679 | } | |
1680 | ||
1681 | try { | |
1682 | fService.saveSession(sessionName, "/tmp/test", true, new NullProgressMonitor()); | |
1683 | } catch (ExecutionException e) { | |
1684 | fail("save session failed: " + e); | |
1685 | } | |
1686 | } | |
1687 | ||
d128c979 BH |
1688 | private static void enableVerbose() { |
1689 | // verbose | |
1690 | ControlCommandLogger.init(ControlPreferences.getInstance().getLogfilePath(), false); | |
1691 | ControlPreferences.getInstance().getPreferenceStore().setDefault(ControlPreferences.TRACE_CONTROL_LOG_COMMANDS_PREF, true); | |
1692 | ControlPreferences.getInstance().getPreferenceStore().setDefault(ControlPreferences.TRACE_CONTROL_VERBOSE_LEVEL_PREF, ControlPreferences.TRACE_CONTROL_VERBOSE_LEVEL_V_V_VERBOSE); | |
1693 | } | |
1694 | ||
1695 | private static void disableVerbose() { | |
1696 | ControlPreferences.getInstance().getPreferenceStore().setDefault(ControlPreferences.TRACE_CONTROL_LOG_COMMANDS_PREF, false); | |
1697 | } | |
1698 | ||
1699 | ||
a959e694 | 1700 | } |