Commit | Line | Data |
---|---|---|
eb1bab5b | 1 | /********************************************************************** |
60ae41e1 | 2 | * Copyright (c) 2012, 2014 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 |
eb1bab5b | 12 | **********************************************************************/ |
2ba3d0a1 | 13 | |
115b4a01 | 14 | package org.eclipse.linuxtools.lttng2.ui.tests.control.service; |
eb1bab5b | 15 | |
d128c979 BH |
16 | import static org.junit.Assert.assertEquals; |
17 | import static org.junit.Assert.assertNotNull; | |
18 | import static org.junit.Assert.assertTrue; | |
19 | import static org.junit.Assert.fail; | |
2ba3d0a1 | 20 | |
d132bcc7 BH |
21 | import java.io.File; |
22 | import java.net.URL; | |
23 | import java.util.ArrayList; | |
4ea599a5 | 24 | import java.util.HashSet; |
eb1bab5b | 25 | import java.util.List; |
4ea599a5 | 26 | import java.util.Set; |
eb1bab5b | 27 | |
eb1bab5b | 28 | import org.eclipse.core.commands.ExecutionException; |
d132bcc7 | 29 | import org.eclipse.core.runtime.FileLocator; |
bbb3538a | 30 | import org.eclipse.core.runtime.NullProgressMonitor; |
d132bcc7 | 31 | import org.eclipse.core.runtime.Path; |
9315aeee BH |
32 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.IBaseEventInfo; |
33 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.IChannelInfo; | |
34 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.IDomainInfo; | |
35 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.IEventInfo; | |
d4514365 | 36 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.IFieldInfo; |
9315aeee | 37 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISessionInfo; |
589d0d33 | 38 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISnapshotInfo; |
9315aeee BH |
39 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.IUstProviderInfo; |
40 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.LogLevelType; | |
41 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEnablement; | |
42 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEventType; | |
43 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel; | |
44 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceSessionState; | |
83051fc3 | 45 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.BufferType; |
9315aeee | 46 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.ChannelInfo; |
f7d4d450 | 47 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.SessionInfo; |
115b4a01 BH |
48 | import org.eclipse.linuxtools.internal.lttng2.stubs.service.CommandShellFactory; |
49 | import org.eclipse.linuxtools.internal.lttng2.stubs.shells.LTTngToolsFileShell; | |
d128c979 BH |
50 | import org.eclipse.linuxtools.internal.lttng2.ui.Activator; |
51 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.logging.ControlCommandLogger; | |
52 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.preferences.ControlPreferences; | |
115b4a01 BH |
53 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService; |
54 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.LTTngControlService; | |
276c17e7 | 55 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.LTTngControlServiceFactory; |
d128c979 | 56 | import org.junit.After; |
2ba3d0a1 AM |
57 | import org.junit.Before; |
58 | import org.junit.Test; | |
9269df72 | 59 | import org.osgi.framework.FrameworkUtil; |
2ba3d0a1 | 60 | |
eb1bab5b | 61 | /** |
2ba3d0a1 AM |
62 | * The class <code>LTTngControlServiceTest</code> contains test for the class |
63 | * <code>{@link LTTngControlService}</code>. | |
eb1bab5b | 64 | */ |
4e0b52e0 | 65 | @SuppressWarnings("javadoc") |
2ba3d0a1 | 66 | public class LTTngControlServiceTest { |
d132bcc7 BH |
67 | |
68 | private static final String DIRECTORY = "testfiles"; | |
69 | private static final String TEST_STREAM = "LTTngServiceTest.cfg"; | |
cfdb727a | 70 | |
d132bcc7 | 71 | private static final String SCEN_LTTNG_NOT_INSTALLED = "LttngNotInstalled"; |
276c17e7 | 72 | private static final String SCEN_LTTNG_VERSION = "LttngVersion"; |
d6fc6e1b | 73 | private static final String SCEN_LTTNG_VERSION_WITH_PROMPT = "LttngVersionWithPrompt"; |
276c17e7 BH |
74 | private static final String SCEN_LTTNG_UNSUPPORTED_VERSION = "LttngUnsupportedVersion"; |
75 | private static final String SCEN_LTTNG_NO_VERSION = "LttngNoVersion"; | |
d132bcc7 BH |
76 | private static final String SCEN_NO_SESSION_AVAILABLE = "NoSessionAvailable"; |
77 | private static final String SCEN_GET_SESSION_NAMES1 = "GetSessionNames1"; | |
78 | private static final String SCEN_GET_SESSION_NAME_NOT_EXIST = "GetSessionNameNotExist"; | |
d128c979 | 79 | private static final String SCEN_GET_SESSION_NAME_NOT_EXIST_VERBOSE = "GetSessionNameNotExistVerbose"; |
d132bcc7 BH |
80 | private static final String SCEN_GET_SESSION_GARBAGE_OUT = "GetSessionGarbageOut"; |
81 | private static final String SCEN_GET_SESSION1 = "GetSession1"; | |
82 | private static final String SCEN_GET_KERNEL_PROVIDER1 = "GetKernelProvider1"; | |
a07c7629 BH |
83 | private static final String SCEN_LIST_WITH_NO_KERNEL1 = "ListWithNoKernel1"; |
84 | private static final String SCEN_LIST_WITH_NO_KERNEL2 = "ListWithNoKernel2"; | |
d128c979 | 85 | private static final String SCEN_LIST_WITH_NO_KERNEL_VERBOSE = "ListWithNoKernelVerbose"; |
d132bcc7 BH |
86 | private static final String SCEN_GET_UST_PROVIDER1 = "GetUstProvider1"; |
87 | private static final String SCEN_GET_UST_PROVIDER2 = "GetUstProvider2"; | |
d4514365 | 88 | private static final String SCEN_GET_UST_PROVIDER3 = "GetUstProvider3"; |
f3e2f354 BH |
89 | private static final String SCEN_LIST_WITH_NO_UST1 = "ListWithNoUst1"; |
90 | private static final String SCEN_LIST_WITH_NO_UST2 = "ListWithNoUst2"; | |
91 | private static final String SCEN_LIST_WITH_NO_UST3 = "ListWithNoUst3"; | |
92 | private static final String SCEN_LIST_WITH_NO_UST_VERBOSE = "ListWithNoUstVerbose"; | |
d132bcc7 | 93 | private static final String SCEN_CREATE_SESSION1 = "CreateSession1"; |
d6fc6e1b | 94 | private static final String SCEN_CREATE_SESSION_WITH_PROMPT = "CreateSessionWithPrompt"; |
d132bcc7 BH |
95 | private static final String SCEN_CREATE_SESSION_VARIANTS = "CreateSessionVariants"; |
96 | private static final String SCEN_DESTROY_SESSION1 = "DestroySession1"; | |
d128c979 | 97 | private static final String SCEN_DESTROY_SESSION_VERBOSE = "DestroySessionVerbose"; |
d132bcc7 BH |
98 | private static final String SCEN_CHANNEL_HANDLING = "ChannelHandling"; |
99 | private static final String SCEN_EVENT_HANDLING = "EventHandling"; | |
4ea599a5 BH |
100 | private static final String SCEN_CONTEXT_HANDLING = "ContextHandling"; |
101 | private static final String SCEN_CONTEXT_ERROR_HANDLING = "ContextErrorHandling"; | |
102 | private static final String SCEN_CALIBRATE_HANDLING = "CalibrateHandling"; | |
f3b33d40 | 103 | private static final String SCEN_CREATE_SESSION_2_1 = "CreateSessionLttng2.1"; |
d128c979 | 104 | private static final String SCEN_CREATE_SESSION_VERBOSE_2_1 = "CreateSessionLttngVerbose2.1"; |
589d0d33 BH |
105 | private static final String SCEN_CREATE_SNAPSHOT_SESSION = "CreateSessionSnapshot"; |
106 | private static final String SCEN_CREATE_STREAMED_SNAPSHOT_SESSION = "CreateSessionStreamedSnapshot"; | |
107 | private static final String SCEN_CREATE_SNAPSHOT_SESSION_ERRORS = "CreateSessionSnapshotErrors"; | |
d132bcc7 | 108 | |
eb1bab5b BH |
109 | // ------------------------------------------------------------------------ |
110 | // Test data | |
111 | // ------------------------------------------------------------------------ | |
2ba3d0a1 | 112 | |
d132bcc7 BH |
113 | private CommandShellFactory fShellFactory; |
114 | private String fTestfile; | |
115 | private LTTngToolsFileShell fShell; | |
116 | private ILttngControlService fService; | |
117 | ||
eb1bab5b BH |
118 | // ------------------------------------------------------------------------ |
119 | // Housekeeping | |
120 | // ------------------------------------------------------------------------ | |
2ba3d0a1 | 121 | |
eb1bab5b BH |
122 | /** |
123 | * Perform pre-test initialization. | |
124 | * | |
2ba3d0a1 AM |
125 | * @throws Exception |
126 | * if the initialization fails for some reason | |
eb1bab5b | 127 | */ |
2ba3d0a1 | 128 | @Before |
eb1bab5b | 129 | public void setUp() throws Exception { |
eb1bab5b | 130 | fShellFactory = CommandShellFactory.getInstance(); |
d132bcc7 | 131 | |
9269df72 | 132 | URL location = FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path(DIRECTORY + File.separator + TEST_STREAM), null); |
d132bcc7 BH |
133 | File testfile = new File(FileLocator.toFileURL(location).toURI()); |
134 | fTestfile = testfile.getAbsolutePath(); | |
cfdb727a | 135 | |
d132bcc7 BH |
136 | fShell = fShellFactory.getFileShell(); |
137 | fShell.loadScenarioFile(fTestfile); | |
138 | fService = new LTTngControlService(fShell); | |
d128c979 BH |
139 | |
140 | ControlPreferences.getInstance().init(Activator.getDefault().getPreferenceStore()); | |
141 | } | |
142 | ||
143 | @After | |
144 | public void tearDown() { | |
145 | disableVerbose(); | |
146 | ControlPreferences.getInstance().dispose(); | |
eb1bab5b BH |
147 | } |
148 | ||
eb1bab5b BH |
149 | // ------------------------------------------------------------------------ |
150 | // Test Cases | |
151 | // ------------------------------------------------------------------------ | |
cfdb727a | 152 | |
2ba3d0a1 | 153 | @Test |
276c17e7 BH |
154 | public void testVersion() { |
155 | try { | |
156 | fShell.setScenario(SCEN_LTTNG_VERSION); | |
cfdb727a | 157 | ILttngControlService service = LTTngControlServiceFactory.getInstance().getLttngControlService(fShell); |
276c17e7 | 158 | assertNotNull(service); |
cfe737e4 | 159 | assertEquals("2.1.0", service.getVersion()); |
276c17e7 BH |
160 | } catch (ExecutionException e) { |
161 | fail("Exeption thrown " + e); | |
162 | } | |
163 | } | |
cfdb727a | 164 | |
2ba3d0a1 | 165 | @Test |
d6fc6e1b BH |
166 | public void testVersionWithPrompt() { |
167 | try { | |
168 | fShell.setScenario(SCEN_LTTNG_VERSION_WITH_PROMPT); | |
169 | ILttngControlService service = LTTngControlServiceFactory.getInstance().getLttngControlService(fShell); | |
170 | assertNotNull(service); | |
171 | assertEquals("2.0.0", service.getVersion()); | |
172 | } catch (ExecutionException e) { | |
173 | fail("Exeption thrown " + e); | |
174 | } | |
175 | } | |
a07c7629 | 176 | |
2ba3d0a1 | 177 | @Test |
276c17e7 BH |
178 | public void testUnsupportedVersion() { |
179 | try { | |
180 | fShell.setScenario(SCEN_LTTNG_UNSUPPORTED_VERSION); | |
cfdb727a | 181 | LTTngControlServiceFactory.getInstance().getLttngControlService(fShell); |
276c17e7 BH |
182 | fail("No exeption thrown"); |
183 | } catch (ExecutionException e) { | |
184 | // success | |
185 | } | |
186 | } | |
187 | ||
2ba3d0a1 | 188 | @Test |
276c17e7 BH |
189 | public void testNoVersion() { |
190 | try { | |
191 | fShell.setScenario(SCEN_LTTNG_NO_VERSION); | |
cfdb727a | 192 | LTTngControlServiceFactory.getInstance().getLttngControlService(fShell); |
276c17e7 BH |
193 | fail("No exeption thrown"); |
194 | } catch (ExecutionException e) { | |
195 | // success | |
196 | } | |
197 | } | |
198 | ||
2ba3d0a1 | 199 | @Test |
276c17e7 | 200 | public void testLttngNotInstalled() { |
eb1bab5b | 201 | try { |
d132bcc7 BH |
202 | fShell.setScenario(SCEN_LTTNG_NOT_INSTALLED); |
203 | fService.getSessionNames(new NullProgressMonitor()); | |
eb1bab5b | 204 | fail("No exeption thrown"); |
eb1bab5b BH |
205 | } catch (ExecutionException e) { |
206 | // success | |
207 | } | |
208 | } | |
cfdb727a | 209 | |
2ba3d0a1 | 210 | @Test |
eb1bab5b BH |
211 | public void testGetSessionNames1() { |
212 | try { | |
d132bcc7 BH |
213 | fShell.setScenario(SCEN_NO_SESSION_AVAILABLE); |
214 | String[] result = fService.getSessionNames(new NullProgressMonitor()); | |
eb1bab5b BH |
215 | |
216 | assertNotNull(result); | |
217 | assertEquals(0, result.length); | |
cfdb727a | 218 | |
eb1bab5b BH |
219 | } catch (ExecutionException e) { |
220 | fail(e.toString()); | |
221 | } | |
222 | } | |
d132bcc7 | 223 | |
2ba3d0a1 | 224 | @Test |
eb1bab5b BH |
225 | public void testGetSessionNames2() { |
226 | try { | |
d132bcc7 BH |
227 | fShell.setScenario(SCEN_GET_SESSION_NAMES1); |
228 | String[] result = fService.getSessionNames(new NullProgressMonitor()); | |
eb1bab5b BH |
229 | |
230 | assertNotNull(result); | |
231 | assertEquals(2, result.length); | |
232 | assertEquals("mysession1", result[0]); | |
233 | assertEquals("mysession", result[1]); | |
cfdb727a | 234 | |
eb1bab5b BH |
235 | } catch (ExecutionException e) { |
236 | fail(e.toString()); | |
237 | } | |
238 | } | |
d132bcc7 | 239 | |
2ba3d0a1 | 240 | @Test |
eb1bab5b BH |
241 | public void testGetSessionNotExist() { |
242 | try { | |
d132bcc7 BH |
243 | fShell.setScenario(SCEN_GET_SESSION_NAME_NOT_EXIST); |
244 | fService.getSessionNames(new NullProgressMonitor()); | |
eb1bab5b | 245 | fail("No exeption thrown"); |
cfdb727a | 246 | |
eb1bab5b BH |
247 | } catch (ExecutionException e) { |
248 | // success | |
249 | } | |
250 | } | |
cfdb727a | 251 | |
d128c979 BH |
252 | @Test |
253 | public void testGetSessionNotExistVerbose() { | |
254 | try { | |
255 | enableVerbose(); | |
256 | fShell.setScenario(SCEN_GET_SESSION_NAME_NOT_EXIST_VERBOSE); | |
257 | fService.getSessionNames(new NullProgressMonitor()); | |
258 | fail("No exeption thrown"); | |
259 | ||
260 | } catch (ExecutionException e) { | |
261 | // success | |
262 | } finally { | |
263 | disableVerbose(); | |
264 | } | |
265 | } | |
266 | ||
2ba3d0a1 | 267 | @Test |
eb1bab5b BH |
268 | public void testGetSessionNameGarbage() { |
269 | try { | |
d132bcc7 BH |
270 | fShell.setScenario(SCEN_GET_SESSION_GARBAGE_OUT); |
271 | String[] result = fService.getSessionNames(new NullProgressMonitor()); | |
eb1bab5b BH |
272 | |
273 | assertNotNull(result); | |
274 | assertEquals(0, result.length); | |
cfdb727a | 275 | |
eb1bab5b BH |
276 | } catch (ExecutionException e) { |
277 | fail(e.toString()); | |
278 | } | |
279 | } | |
cfdb727a | 280 | |
2ba3d0a1 | 281 | @Test |
eb1bab5b BH |
282 | public void testGetSession1() { |
283 | try { | |
d132bcc7 BH |
284 | fShell.setScenario(SCEN_GET_SESSION1); |
285 | ISessionInfo session = fService.getSession("mysession", new NullProgressMonitor()); | |
eb1bab5b BH |
286 | |
287 | // Verify Session | |
288 | assertNotNull(session); | |
289 | assertEquals("mysession", session.getName()); | |
290 | assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session.getSessionPath()); | |
291 | assertEquals(TraceSessionState.ACTIVE, session.getSessionState()); | |
cfdb727a | 292 | |
eb1bab5b BH |
293 | IDomainInfo[] domains = session.getDomains(); |
294 | assertNotNull(domains); | |
295 | assertEquals(2, domains.length); | |
cfdb727a | 296 | |
eb1bab5b BH |
297 | // Verify Kernel domain |
298 | assertEquals("Kernel", domains[0].getName()); | |
299 | IChannelInfo[] channels = domains[0].getChannels(); | |
300 | assertNotNull(channels); | |
301 | assertEquals(2, channels.length); | |
302 | ||
cfdb727a | 303 | // Verify Kernel's channel0 |
eb1bab5b BH |
304 | assertEquals("channel0", channels[0].getName()); |
305 | assertEquals(4, channels[0].getNumberOfSubBuffers()); | |
306 | assertEquals("splice()", channels[0].getOutputType()); | |
307 | assertEquals(false, channels[0].isOverwriteMode()); | |
308 | assertEquals(200, channels[0].getReadTimer()); | |
309 | assertEquals(TraceEnablement.ENABLED, channels[0].getState()); | |
310 | assertEquals(262144, channels[0].getSubBufferSize()); | |
311 | assertEquals(0, channels[0].getSwitchTimer()); | |
cfdb727a | 312 | |
eb1bab5b BH |
313 | // Verify event info |
314 | IEventInfo[] channel0Events = channels[0].getEvents(); | |
315 | assertNotNull(channel0Events); | |
316 | assertEquals(2, channel0Events.length); | |
317 | assertEquals("block_rq_remap", channel0Events[0].getName()); | |
318 | assertEquals(TraceLogLevel.TRACE_EMERG, channel0Events[0].getLogLevel()); | |
319 | assertEquals(TraceEventType.TRACEPOINT, channel0Events[0].getEventType()); | |
320 | assertEquals(TraceEnablement.ENABLED, channel0Events[0].getState()); | |
cfdb727a | 321 | |
eb1bab5b BH |
322 | assertEquals("block_bio_remap", channel0Events[1].getName()); |
323 | assertEquals(TraceLogLevel.TRACE_EMERG, channel0Events[1].getLogLevel()); | |
324 | assertEquals(TraceEventType.TRACEPOINT, channel0Events[1].getEventType()); | |
325 | assertEquals(TraceEnablement.DISABLED, channel0Events[1].getState()); | |
cfdb727a AM |
326 | |
327 | // Verify Kernel's channel1 | |
eb1bab5b BH |
328 | assertEquals("channel1", channels[1].getName()); |
329 | assertEquals(4, channels[1].getNumberOfSubBuffers()); | |
330 | assertEquals("splice()", channels[1].getOutputType()); | |
331 | assertEquals(true, channels[1].isOverwriteMode()); | |
332 | assertEquals(400, channels[1].getReadTimer()); | |
333 | assertEquals(TraceEnablement.DISABLED, channels[1].getState()); | |
334 | assertEquals(524288, channels[1].getSubBufferSize()); | |
335 | assertEquals(100, channels[1].getSwitchTimer()); | |
cfdb727a | 336 | |
eb1bab5b BH |
337 | // Verify event info |
338 | IEventInfo[] channel1Events = channels[1].getEvents(); | |
339 | assertEquals(0, channel1Events.length); | |
cfdb727a | 340 | |
eb1bab5b BH |
341 | // Verify domain UST global |
342 | assertEquals("UST global", domains[1].getName()); | |
cfdb727a | 343 | |
eb1bab5b | 344 | IChannelInfo[] ustChannels = domains[1].getChannels(); |
cfdb727a AM |
345 | |
346 | // Verify UST global's mychannel1 | |
eb1bab5b BH |
347 | assertEquals("mychannel1", ustChannels[0].getName()); |
348 | assertEquals(8, ustChannels[0].getNumberOfSubBuffers()); | |
349 | assertEquals("mmap()", ustChannels[0].getOutputType()); | |
350 | assertEquals(true, ustChannels[0].isOverwriteMode()); | |
351 | assertEquals(100, ustChannels[0].getReadTimer()); | |
352 | assertEquals(TraceEnablement.DISABLED, ustChannels[0].getState()); | |
353 | assertEquals(8192, ustChannels[0].getSubBufferSize()); | |
354 | assertEquals(200, ustChannels[0].getSwitchTimer()); | |
cfdb727a | 355 | |
eb1bab5b BH |
356 | // Verify event info |
357 | IEventInfo[] ustEvents = ustChannels[0].getEvents(); | |
358 | assertEquals(0, ustEvents.length); | |
359 | ||
cfdb727a | 360 | // Verify UST global's channel0 |
eb1bab5b BH |
361 | assertEquals("channel0", ustChannels[1].getName()); |
362 | assertEquals(4, ustChannels[1].getNumberOfSubBuffers()); | |
363 | assertEquals("mmap()", ustChannels[1].getOutputType()); | |
364 | assertEquals(false, ustChannels[1].isOverwriteMode()); | |
365 | assertEquals(200, ustChannels[1].getReadTimer()); | |
366 | assertEquals(TraceEnablement.ENABLED, ustChannels[1].getState()); | |
367 | assertEquals(4096, ustChannels[1].getSubBufferSize()); | |
368 | assertEquals(0, ustChannels[1].getSwitchTimer()); | |
cfdb727a | 369 | |
eb1bab5b BH |
370 | // Verify event info |
371 | ustEvents = ustChannels[1].getEvents(); | |
372 | assertEquals(2, ustEvents.length); | |
cfdb727a | 373 | |
eb1bab5b | 374 | assertEquals("ust_tests_hello:tptest_sighandler", ustEvents[0].getName()); |
4775bcbf | 375 | assertEquals(TraceLogLevel.TRACE_DEBUG_LINE, ustEvents[0].getLogLevel()); |
eb1bab5b BH |
376 | assertEquals(TraceEventType.TRACEPOINT, ustEvents[0].getEventType()); |
377 | assertEquals(TraceEnablement.DISABLED, ustEvents[0].getState()); | |
cfdb727a | 378 | |
eb1bab5b | 379 | assertEquals("*", ustEvents[1].getName()); |
4775bcbf | 380 | assertEquals(TraceLogLevel.LEVEL_UNKNOWN, ustEvents[1].getLogLevel()); |
eb1bab5b BH |
381 | assertEquals(TraceEventType.TRACEPOINT, ustEvents[1].getEventType()); |
382 | assertEquals(TraceEnablement.ENABLED, ustEvents[1].getState()); | |
cfdb727a | 383 | |
eb1bab5b | 384 | // next session (no detailed information available) |
d132bcc7 | 385 | session = fService.getSession("mysession1", new NullProgressMonitor()); |
eb1bab5b BH |
386 | assertNotNull(session); |
387 | assertEquals("mysession1", session.getName()); | |
388 | assertEquals("/home/user/lttng-traces/mysession1-20120203-133225", session.getSessionPath()); | |
389 | assertEquals(TraceSessionState.INACTIVE, session.getSessionState()); | |
cfdb727a | 390 | |
eb1bab5b BH |
391 | domains = session.getDomains(); |
392 | assertNotNull(domains); | |
393 | assertEquals(0, domains.length); | |
394 | } catch (ExecutionException e) { | |
395 | fail(e.toString()); | |
396 | } | |
397 | } | |
398 | ||
399 | public void testGetKernelProvider() { | |
400 | try { | |
d132bcc7 BH |
401 | fShell.setScenario(SCEN_GET_KERNEL_PROVIDER1); |
402 | List<IBaseEventInfo> events = fService.getKernelProvider(new NullProgressMonitor()); | |
eb1bab5b BH |
403 | |
404 | // Verify event info | |
405 | assertNotNull(events); | |
406 | assertEquals(3, events.size()); | |
cfdb727a AM |
407 | |
408 | IBaseEventInfo baseEventInfo = events.get(0); | |
eb1bab5b BH |
409 | assertNotNull(baseEventInfo); |
410 | assertEquals("sched_kthread_stop", baseEventInfo.getName()); | |
411 | assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel()); | |
412 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); | |
cfdb727a AM |
413 | |
414 | baseEventInfo = events.get(1); | |
eb1bab5b BH |
415 | assertEquals("sched_kthread_stop_ret", baseEventInfo.getName()); |
416 | assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel()); | |
417 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); | |
cfdb727a AM |
418 | |
419 | baseEventInfo = events.get(2); | |
eb1bab5b BH |
420 | assertEquals("sched_wakeup_new", baseEventInfo.getName()); |
421 | assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel()); | |
422 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); | |
423 | ||
424 | } catch (ExecutionException e) { | |
425 | fail(e.toString()); | |
426 | } | |
427 | } | |
428 | ||
2ba3d0a1 | 429 | @Test |
a07c7629 BH |
430 | public void testGetKernelProviderNoKernel1() { |
431 | try { | |
432 | fShell.setScenario(SCEN_LIST_WITH_NO_KERNEL1); | |
433 | List<IBaseEventInfo> events = fService.getKernelProvider(new NullProgressMonitor()); | |
434 | ||
435 | // Verify event info | |
436 | assertNotNull(events); | |
437 | assertEquals(0, events.size()); | |
438 | ||
439 | } catch (ExecutionException e) { | |
440 | fail(e.toString()); | |
441 | } | |
442 | } | |
443 | ||
2ba3d0a1 | 444 | @Test |
a07c7629 BH |
445 | public void testGetKernelProviderNoKernel2() { |
446 | try { | |
447 | fShell.setScenario(SCEN_LIST_WITH_NO_KERNEL2); | |
448 | List<IBaseEventInfo> events = fService.getKernelProvider(new NullProgressMonitor()); | |
449 | ||
450 | // Verify event info | |
451 | assertNotNull(events); | |
452 | assertEquals(0, events.size()); | |
453 | ||
454 | } catch (ExecutionException e) { | |
455 | fail(e.toString()); | |
456 | } | |
457 | } | |
458 | ||
d128c979 BH |
459 | @Test |
460 | public void testGetKernelProviderNoKernelVerbose() { | |
461 | try { | |
462 | enableVerbose(); | |
463 | fShell.setScenario(SCEN_LIST_WITH_NO_KERNEL_VERBOSE); | |
464 | List<IBaseEventInfo> events = fService.getKernelProvider(new NullProgressMonitor()); | |
465 | ||
466 | // Verify event info | |
467 | assertNotNull(events); | |
468 | assertEquals(0, events.size()); | |
469 | ||
470 | } catch (ExecutionException e) { | |
471 | fail(e.toString()); | |
472 | } finally { | |
473 | disableVerbose(); | |
474 | } | |
475 | } | |
476 | ||
2ba3d0a1 | 477 | @Test |
eb1bab5b BH |
478 | public void testGetUstProvider() { |
479 | try { | |
d132bcc7 BH |
480 | fShell.setScenario(SCEN_GET_UST_PROVIDER1); |
481 | List<IUstProviderInfo> providers = fService.getUstProvider(); | |
eb1bab5b BH |
482 | |
483 | // Check all providers | |
484 | assertNotNull(providers); | |
485 | assertEquals(2, providers.size()); | |
cfdb727a | 486 | |
eb1bab5b BH |
487 | //Verify first provider |
488 | assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers.get(0).getName()); | |
489 | assertEquals(9379, providers.get(0).getPid()); | |
cfdb727a | 490 | |
eb1bab5b BH |
491 | // Verify event info |
492 | IBaseEventInfo[] events = providers.get(0).getEvents(); | |
493 | assertNotNull(events); | |
494 | assertEquals(2, events.length); | |
495 | ||
cfdb727a | 496 | IBaseEventInfo baseEventInfo = events[0]; |
eb1bab5b BH |
497 | assertNotNull(baseEventInfo); |
498 | assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo.getName()); | |
4775bcbf | 499 | assertEquals(TraceLogLevel.TRACE_DEBUG_MODULE, baseEventInfo.getLogLevel()); |
eb1bab5b | 500 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); |
cfdb727a AM |
501 | |
502 | baseEventInfo = events[1]; | |
eb1bab5b BH |
503 | assertEquals("ust_tests_hello:tptest", baseEventInfo.getName()); |
504 | assertEquals(TraceLogLevel.TRACE_INFO, baseEventInfo.getLogLevel()); | |
505 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); | |
506 | ||
507 | //Verify second provider | |
508 | assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers.get(1).getName()); | |
509 | assertEquals(4852, providers.get(1).getPid()); | |
cfdb727a | 510 | |
eb1bab5b BH |
511 | // Verify event info |
512 | events = providers.get(1).getEvents(); | |
513 | assertNotNull(events); | |
514 | assertEquals(2, events.length); | |
515 | ||
cfdb727a | 516 | baseEventInfo = events[0]; |
eb1bab5b BH |
517 | assertNotNull(baseEventInfo); |
518 | assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo.getName()); | |
519 | assertEquals(TraceLogLevel.TRACE_WARNING, baseEventInfo.getLogLevel()); | |
520 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); | |
cfdb727a AM |
521 | |
522 | baseEventInfo = events[1]; | |
eb1bab5b | 523 | assertEquals("ust_tests_hello:tptest", baseEventInfo.getName()); |
4775bcbf | 524 | assertEquals(TraceLogLevel.TRACE_DEBUG_FUNCTION, baseEventInfo.getLogLevel()); |
eb1bab5b BH |
525 | assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType()); |
526 | ||
527 | } catch (ExecutionException e) { | |
528 | fail(e.toString()); | |
529 | } | |
530 | } | |
d132bcc7 | 531 | |
2ba3d0a1 | 532 | @Test |
eb1bab5b BH |
533 | public void testUstProvider2() { |
534 | try { | |
d132bcc7 BH |
535 | fShell.setScenario(SCEN_GET_UST_PROVIDER2); |
536 | List<IUstProviderInfo> providers = fService.getUstProvider(); | |
eb1bab5b BH |
537 | |
538 | assertNotNull(providers); | |
539 | assertEquals(0, providers.size()); | |
cfdb727a | 540 | |
eb1bab5b BH |
541 | } catch (ExecutionException e) { |
542 | fail(e.toString()); | |
543 | } | |
544 | } | |
d132bcc7 | 545 | |
2ba3d0a1 | 546 | @Test |
d4514365 BH |
547 | public void testGetUstProvider3() { |
548 | try { | |
549 | fShell.setScenario(SCEN_GET_UST_PROVIDER3); | |
550 | // Set version | |
551 | ((LTTngControlService)fService).setVersion("2.1.0"); | |
552 | List<IUstProviderInfo> providers = fService.getUstProvider(); | |
553 | ||
554 | // Check all providers | |
555 | assertNotNull(providers); | |
556 | assertEquals(2, providers.size()); | |
557 | ||
558 | //Verify first provider | |
559 | assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers.get(0).getName()); | |
560 | assertEquals(9379, providers.get(0).getPid()); | |
561 | ||
562 | // Verify event info | |
563 | IBaseEventInfo[] events = providers.get(0).getEvents(); | |
564 | assertNotNull(events); | |
565 | assertEquals(2, events.length); | |
566 | ||
567 | IBaseEventInfo baseEventInfo = events[0]; | |
568 | assertNotNull(baseEventInfo); | |
569 | IFieldInfo[] fields = baseEventInfo.getFields(); | |
570 | assertNotNull(fields); | |
571 | assertEquals(0, fields.length); | |
572 | ||
573 | baseEventInfo = events[1]; | |
574 | fields = baseEventInfo.getFields(); | |
575 | assertNotNull(fields); | |
576 | assertEquals(3, fields.length); | |
577 | assertEquals("doublefield", fields[0].getName()); | |
578 | assertEquals("float", fields[0].getFieldType()); | |
579 | ||
580 | assertEquals("floatfield", fields[1].getName()); | |
581 | assertEquals("float", fields[1].getFieldType()); | |
582 | ||
583 | assertEquals("stringfield", fields[2].getName()); | |
584 | assertEquals("string", fields[2].getFieldType()); | |
585 | ||
586 | //Verify second provider | |
587 | assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers.get(1).getName()); | |
588 | assertEquals(4852, providers.get(1).getPid()); | |
589 | ||
590 | // Verify event info | |
591 | events = providers.get(1).getEvents(); | |
592 | assertNotNull(events); | |
593 | assertEquals(2, events.length); | |
594 | ||
595 | baseEventInfo = events[0]; | |
596 | assertNotNull(baseEventInfo); | |
597 | fields = baseEventInfo.getFields(); | |
598 | assertNotNull(fields); | |
599 | assertEquals(0, fields.length); | |
600 | ||
601 | baseEventInfo = events[1]; | |
602 | fields = baseEventInfo.getFields(); | |
603 | assertNotNull(fields); | |
604 | assertEquals(3, fields.length); | |
605 | ||
606 | assertEquals("doublefield", fields[0].getName()); | |
607 | assertEquals("float", fields[0].getFieldType()); | |
608 | ||
609 | assertEquals("floatfield", fields[1].getName()); | |
610 | assertEquals("float", fields[1].getFieldType()); | |
611 | ||
612 | assertEquals("stringfield", fields[2].getName()); | |
613 | assertEquals("string", fields[2].getFieldType()); | |
614 | ||
615 | // Reset version | |
616 | ((LTTngControlService)fService).setVersion("2.0.0"); | |
617 | ||
618 | } catch (ExecutionException e) { | |
619 | fail(e.toString()); | |
620 | } | |
621 | } | |
622 | ||
f3e2f354 BH |
623 | |
624 | @Test | |
625 | public void testGetKernelProviderNoUst1() { | |
626 | try { | |
627 | fShell.setScenario(SCEN_LIST_WITH_NO_UST1); | |
628 | List<IUstProviderInfo> providerList = fService.getUstProvider(new NullProgressMonitor()); | |
629 | ||
630 | // Verify Provider info | |
631 | assertNotNull(providerList); | |
632 | assertEquals(0, providerList.size()); | |
633 | ||
634 | } catch (ExecutionException e) { | |
635 | fail(e.toString()); | |
636 | } | |
637 | } | |
638 | ||
639 | ||
640 | @Test | |
641 | public void testGetKernelProviderNoUst2() { | |
642 | try { | |
643 | // Set version | |
644 | ((LTTngControlService)fService).setVersion("2.1.0"); | |
645 | ||
646 | fShell.setScenario(SCEN_LIST_WITH_NO_UST2); | |
647 | List<IUstProviderInfo> providerList = fService.getUstProvider(new NullProgressMonitor()); | |
648 | ||
649 | // Verify Provider info | |
650 | assertNotNull(providerList); | |
651 | assertEquals(0, providerList.size()); | |
652 | ||
653 | // Reset version | |
654 | ((LTTngControlService)fService).setVersion("2.0.0"); | |
655 | ||
656 | } catch (ExecutionException e) { | |
657 | fail(e.toString()); | |
658 | } | |
659 | } | |
660 | ||
661 | @Test | |
662 | public void testGetKernelProviderNoUst3() { | |
663 | try { | |
664 | ||
665 | // Set version | |
666 | ((LTTngControlService)fService).setVersion("2.1.0"); | |
667 | ||
668 | fShell.setScenario(SCEN_LIST_WITH_NO_UST3); | |
669 | List<IUstProviderInfo> providerList = fService.getUstProvider(new NullProgressMonitor()); | |
670 | ||
671 | // Verify provider info | |
672 | assertNotNull(providerList); | |
673 | assertEquals(0, providerList.size()); | |
674 | ||
675 | // Reset version | |
676 | ((LTTngControlService)fService).setVersion("2.0.0"); | |
677 | ||
678 | } catch (ExecutionException e) { | |
679 | fail(e.toString()); | |
680 | } | |
681 | } | |
682 | ||
683 | @Test | |
684 | public void testGetKernelProviderNoUstVerbose() { | |
685 | try { | |
686 | enableVerbose(); | |
687 | ||
688 | // Set version | |
689 | ((LTTngControlService)fService).setVersion("2.1.0"); | |
690 | ||
691 | fShell.setScenario(SCEN_LIST_WITH_NO_UST_VERBOSE); | |
692 | List<IUstProviderInfo> providerList = fService.getUstProvider(new NullProgressMonitor()); | |
693 | ||
694 | // Verify provider info | |
695 | assertNotNull(providerList); | |
696 | assertEquals(0, providerList.size()); | |
697 | ||
698 | // Reset version | |
699 | ((LTTngControlService)fService).setVersion("2.0.0"); | |
700 | ||
701 | } catch (ExecutionException e) { | |
702 | fail(e.toString()); | |
703 | } finally { | |
704 | disableVerbose(); | |
705 | } | |
706 | } | |
707 | ||
708 | ||
709 | ||
2ba3d0a1 | 710 | @Test |
bbb3538a BH |
711 | public void testCreateSession() { |
712 | try { | |
d132bcc7 BH |
713 | fShell.setScenario(SCEN_CREATE_SESSION1); |
714 | ||
f7d4d450 | 715 | ISessionInfo info = fService.createSession(new SessionInfo("mysession2"), new NullProgressMonitor()); |
bbb3538a BH |
716 | assertNotNull(info); |
717 | assertEquals("mysession2", info.getName()); | |
718 | assertNotNull(info.getSessionPath()); | |
719 | assertTrue(info.getSessionPath().contains("mysession2")); | |
720 | assertEquals(TraceSessionState.INACTIVE, info.getSessionState()); | |
721 | } catch (ExecutionException e) { | |
722 | fail(e.toString()); | |
723 | } | |
724 | } | |
d132bcc7 | 725 | |
2ba3d0a1 | 726 | @Test |
d6fc6e1b BH |
727 | public void testCreateSessionWithPrompt() { |
728 | try { | |
a07c7629 | 729 | // First line has the shell prompt before the command output |
d6fc6e1b BH |
730 | // This can happen in a real application if the command line is not echoed by the shell. |
731 | fShell.setScenario(SCEN_CREATE_SESSION_WITH_PROMPT); | |
732 | ||
733 | // First line has no shell prompt before the output | |
f7d4d450 | 734 | ISessionInfo info = fService.createSession(new SessionInfo("mysession2"), new NullProgressMonitor()); |
d6fc6e1b BH |
735 | assertNotNull(info); |
736 | assertEquals("mysession2", info.getName()); | |
737 | assertNotNull(info.getSessionPath()); | |
738 | assertTrue(info.getSessionPath().contains("mysession2")); | |
739 | assertEquals(TraceSessionState.INACTIVE, info.getSessionState()); | |
740 | } catch (ExecutionException e) { | |
741 | fail(e.toString()); | |
742 | } | |
743 | } | |
744 | ||
2ba3d0a1 | 745 | @Test |
d132bcc7 BH |
746 | public void testCreateSessionVariants() { |
747 | ||
748 | fShell.setScenario(SCEN_CREATE_SESSION_VARIANTS); | |
749 | ||
bbb3538a | 750 | try { |
f7d4d450 | 751 | fService.createSession(new SessionInfo("alreadyExist"), new NullProgressMonitor()); |
bbb3538a BH |
752 | fail("No exeption thrown"); |
753 | } catch (ExecutionException e) { | |
754 | // success | |
755 | } | |
cfdb727a | 756 | |
bbb3538a | 757 | try { |
f7d4d450 | 758 | fService.createSession(new SessionInfo("wrongName"), new NullProgressMonitor()); |
bbb3538a BH |
759 | fail("No exeption thrown"); |
760 | } catch (ExecutionException e) { | |
761 | // success | |
cfdb727a | 762 | } |
bbb3538a BH |
763 | |
764 | try { | |
f7d4d450 MAL |
765 | ISessionInfo sessionInfo = new SessionInfo("withPath"); |
766 | sessionInfo.setSessionPath("/home/user/hallo"); | |
767 | fService.createSession(sessionInfo, new NullProgressMonitor()); | |
bbb3538a BH |
768 | fail("No exeption thrown"); |
769 | } catch (ExecutionException e) { | |
770 | // success | |
cfdb727a | 771 | } |
bbb3538a BH |
772 | |
773 | try { | |
f7d4d450 | 774 | ISessionInfo info = fService.createSession(new SessionInfo("session with spaces"), new NullProgressMonitor()); |
bbb3538a BH |
775 | assertNotNull(info); |
776 | assertEquals("session with spaces", info.getName()); | |
777 | assertNotNull(info.getSessionPath()); | |
778 | assertTrue(info.getSessionPath().contains("session with spaces")); | |
779 | assertEquals(TraceSessionState.INACTIVE, info.getSessionState()); | |
cfdb727a | 780 | |
bbb3538a BH |
781 | } catch (ExecutionException e) { |
782 | fail(e.toString()); | |
cfdb727a | 783 | } |
bbb3538a BH |
784 | |
785 | try { | |
f7d4d450 MAL |
786 | ISessionInfo sessionInfo = new SessionInfo("pathWithSpaces"); |
787 | sessionInfo.setSessionPath("/home/user/hallo user/here"); | |
788 | ISessionInfo info = fService.createSession(sessionInfo, new NullProgressMonitor()); | |
bbb3538a BH |
789 | assertNotNull(info); |
790 | assertEquals("pathWithSpaces", info.getName()); | |
791 | assertNotNull(info.getSessionPath()); | |
792 | assertTrue(info.getSessionPath().contains("/home/user/hallo user/here")); | |
793 | assertEquals(TraceSessionState.INACTIVE, info.getSessionState()); | |
cfdb727a | 794 | |
bbb3538a BH |
795 | } catch (ExecutionException e) { |
796 | fail(e.toString()); | |
cfdb727a | 797 | } |
bbb3538a BH |
798 | } |
799 | ||
2ba3d0a1 | 800 | @Test |
9d8a90ad | 801 | public void testDestroySession() { |
bbb3538a | 802 | try { |
d132bcc7 BH |
803 | fShell.setScenario(SCEN_DESTROY_SESSION1); |
804 | fService.destroySession("mysession2", new NullProgressMonitor()); | |
bbb3538a BH |
805 | } catch (ExecutionException e) { |
806 | fail(e.toString()); | |
cfdb727a | 807 | } |
bbb3538a | 808 | } |
d132bcc7 | 809 | |
d128c979 BH |
810 | @Test |
811 | public void testDestroySessionVerbose() { | |
812 | try { | |
813 | enableVerbose(); | |
814 | fShell.setScenario(SCEN_DESTROY_SESSION_VERBOSE); | |
815 | fService.destroySession("mysession2", new NullProgressMonitor()); | |
816 | } catch (ExecutionException e) { | |
817 | fail(e.toString()); | |
818 | } finally { | |
819 | disableVerbose(); | |
820 | } | |
821 | } | |
822 | ||
2ba3d0a1 | 823 | @Test |
d132bcc7 BH |
824 | public void testCreateChannel() { |
825 | try { | |
83051fc3 | 826 | ((LTTngControlService)fService).setVersion("2.2.0"); |
d132bcc7 | 827 | String sessionName = "mysession2"; |
e0838ca1 | 828 | List<String> list = new ArrayList<>(); |
d132bcc7 BH |
829 | String kernelChannel0 = "mychannel0"; |
830 | String kernelChannel1 = "mychannel1"; | |
831 | list.add(kernelChannel0); | |
832 | list.add(kernelChannel1); | |
cfdb727a | 833 | |
d132bcc7 | 834 | fShell.setScenario(SCEN_CHANNEL_HANDLING); |
cfdb727a | 835 | |
d132bcc7 BH |
836 | // Create/enable/configure 2 kernel channels |
837 | ChannelInfo chanInfo = new ChannelInfo(""); | |
838 | chanInfo.setOverwriteMode(true); | |
839 | chanInfo.setSubBufferSize(16384); | |
840 | chanInfo.setReadTimer(100); | |
841 | chanInfo.setSwitchTimer(200); | |
842 | chanInfo.setNumberOfSubBuffers(2); | |
e799e5f3 SD |
843 | chanInfo.setMaxNumberTraceFiles(10); |
844 | chanInfo.setMaxSizeTraceFiles(0); | |
d132bcc7 | 845 | fService.enableChannels(sessionName, list, true, chanInfo, new NullProgressMonitor()); |
cfdb727a | 846 | |
d132bcc7 BH |
847 | // Create/enable/configure 1 UST channel |
848 | list.clear(); | |
849 | list.add("ustChannel"); | |
cfdb727a | 850 | |
d132bcc7 BH |
851 | chanInfo = new ChannelInfo(""); |
852 | chanInfo.setOverwriteMode(true); | |
853 | chanInfo.setSubBufferSize(32768); | |
854 | chanInfo.setReadTimer(200); | |
855 | chanInfo.setSwitchTimer(100); | |
856 | chanInfo.setNumberOfSubBuffers(1); | |
e799e5f3 SD |
857 | chanInfo.setMaxNumberTraceFiles(20); |
858 | chanInfo.setMaxSizeTraceFiles(0); | |
859 | fService.enableChannels(sessionName, list, false, chanInfo, new NullProgressMonitor()); | |
83051fc3 | 860 | ((LTTngControlService)fService).setVersion("2.0.0"); |
e799e5f3 SD |
861 | |
862 | } catch (ExecutionException e) { | |
863 | fail(e.toString()); | |
864 | } | |
865 | } | |
866 | ||
867 | @Test | |
868 | public void testCreateChannelUIDBuffer() { | |
869 | try { | |
83051fc3 | 870 | ((LTTngControlService)fService).setVersion("2.2.0"); |
e799e5f3 | 871 | String sessionName = "mysession2"; |
e0838ca1 | 872 | List<String> list = new ArrayList<>(); |
e799e5f3 SD |
873 | String USTChannel = "ustChannel"; |
874 | list.add(USTChannel); | |
875 | fShell.setScenario(SCEN_CHANNEL_HANDLING); | |
876 | ||
877 | ChannelInfo chanInfo = new ChannelInfo(""); | |
878 | chanInfo.setOverwriteMode(true); | |
879 | chanInfo.setSubBufferSize(32768); | |
880 | chanInfo.setReadTimer(200); | |
881 | chanInfo.setSwitchTimer(100); | |
882 | chanInfo.setNumberOfSubBuffers(1); | |
883 | chanInfo.setMaxNumberTraceFiles(20); | |
884 | chanInfo.setMaxSizeTraceFiles(0); | |
83051fc3 | 885 | chanInfo.setBufferType(BufferType.BUFFER_PER_UID); |
d132bcc7 | 886 | fService.enableChannels(sessionName, list, false, chanInfo, new NullProgressMonitor()); |
83051fc3 BH |
887 | ((LTTngControlService)fService).setVersion("2.0.0"); |
888 | ||
889 | } catch (ExecutionException e) { | |
890 | fail(e.toString()); | |
891 | } | |
892 | } | |
893 | ||
894 | @Test | |
895 | public void testCreateChannelPIDBuffer() { | |
896 | try { | |
897 | ((LTTngControlService)fService).setVersion("2.2.0"); | |
898 | String sessionName = "mysession2"; | |
e0838ca1 | 899 | List<String> list = new ArrayList<>(); |
83051fc3 BH |
900 | String USTChannel = "ustChannel"; |
901 | list.add(USTChannel); | |
902 | fShell.setScenario(SCEN_CHANNEL_HANDLING); | |
903 | ||
904 | ||
905 | ChannelInfo chanInfo = new ChannelInfo(""); | |
906 | chanInfo.setOverwriteMode(true); | |
907 | chanInfo.setSubBufferSize(-1); | |
908 | chanInfo.setReadTimer(-1); | |
909 | chanInfo.setSwitchTimer(-1); | |
910 | chanInfo.setNumberOfSubBuffers(-1); | |
911 | chanInfo.setMaxNumberTraceFiles(-1); | |
912 | chanInfo.setMaxSizeTraceFiles(-1); | |
913 | chanInfo.setBufferType(BufferType.BUFFER_PER_PID); | |
914 | ||
915 | fService.enableChannels(sessionName, list, false, chanInfo, new NullProgressMonitor()); | |
916 | ((LTTngControlService)fService).setVersion("2.0.0"); | |
d132bcc7 BH |
917 | |
918 | } catch (ExecutionException e) { | |
919 | fail(e.toString()); | |
920 | } | |
921 | } | |
922 | ||
2ba3d0a1 | 923 | @Test |
d132bcc7 BH |
924 | public void testDisableChannel() { |
925 | try { | |
926 | ||
927 | String sessionName = "mysession2"; | |
e0838ca1 | 928 | List<String> list = new ArrayList<>(); |
d132bcc7 BH |
929 | String kernelChannel0 = "mychannel0"; |
930 | String kernelChannel1 = "mychannel1"; | |
931 | list.add(kernelChannel0); | |
932 | list.add(kernelChannel1); | |
cfdb727a | 933 | |
d132bcc7 BH |
934 | fShell.setScenario(SCEN_CHANNEL_HANDLING); |
935 | fService.disableChannels(sessionName, list, true, new NullProgressMonitor()); | |
cfdb727a | 936 | |
d132bcc7 BH |
937 | list.clear(); |
938 | list.add("ustChannel"); | |
939 | fService.disableChannels(sessionName, list, false, new NullProgressMonitor()); | |
940 | ||
941 | } catch (ExecutionException e) { | |
942 | fail(e.toString()); | |
943 | } | |
944 | } | |
cfdb727a | 945 | |
2ba3d0a1 | 946 | @Test |
d132bcc7 BH |
947 | public void testEnableChannel() { |
948 | try { | |
949 | ||
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 BH |
957 | fShell.setScenario(SCEN_CHANNEL_HANDLING); |
958 | fService.enableChannels(sessionName, list, true, null, new NullProgressMonitor()); | |
cfdb727a | 959 | |
d132bcc7 BH |
960 | // Create/enable/configure 1 UST channel |
961 | list.clear(); | |
962 | list.add("ustChannel"); | |
cfdb727a | 963 | |
d132bcc7 BH |
964 | fService.enableChannels(sessionName, list, false, null, new NullProgressMonitor()); |
965 | ||
966 | } catch (ExecutionException e) { | |
967 | fail(e.toString()); | |
968 | } | |
969 | } | |
cfdb727a | 970 | |
2ba3d0a1 | 971 | @Test |
d132bcc7 BH |
972 | public void testEnableEvents() { |
973 | try { | |
974 | // 1) session name, channel = null, 3 event names, kernel | |
975 | String sessionName = "mysession2"; | |
e0838ca1 | 976 | List<String> list = new ArrayList<>(); |
d132bcc7 BH |
977 | String eventName0 = "block_rq_remap"; |
978 | String eventName1 = "block_bio_remap"; | |
979 | String eventName2 = "softirq_entry"; | |
980 | list.add(eventName0); | |
981 | list.add(eventName1); | |
982 | list.add(eventName2); | |
983 | fShell.setScenario(SCEN_EVENT_HANDLING); | |
d4514365 | 984 | fService.enableEvents(sessionName, null, list, true, null, new NullProgressMonitor()); |
cfdb727a | 985 | |
d132bcc7 BH |
986 | // 2) session name, channel=mychannel, event name= null, kernel |
987 | String channelName = "mychannel"; | |
d4514365 | 988 | fService.enableEvents(sessionName, channelName, null, true, null, new NullProgressMonitor()); |
bbb3538a | 989 | |
d4514365 | 990 | // 3) session name, channel=mychannel, 1 event name, ust, no filter |
d132bcc7 BH |
991 | String ustEventName = "ust_tests_hello:tptest_sighandler"; |
992 | list.clear(); | |
993 | list.add(ustEventName); | |
d4514365 | 994 | fService.enableEvents(sessionName, channelName, list, false, null, new NullProgressMonitor()); |
cfdb727a | 995 | |
d4514365 BH |
996 | // 4) session name, channel = mychannel, no event name, ust, with filter |
997 | fService.enableEvents(sessionName, channelName, list, false, "intfield==10", new NullProgressMonitor()); | |
998 | ||
999 | // 5) session name, channel = mychannel, no event name, ust, no filter | |
d132bcc7 | 1000 | list.clear(); |
d4514365 BH |
1001 | fService.enableEvents(sessionName, channelName, list, false, null, new NullProgressMonitor()); |
1002 | ||
1003 | // TODO add test with filters | |
cfdb727a | 1004 | |
d132bcc7 BH |
1005 | } catch (ExecutionException e) { |
1006 | fail(e.toString()); | |
1007 | } | |
1008 | } | |
cfdb727a | 1009 | |
2ba3d0a1 | 1010 | @Test |
d132bcc7 BH |
1011 | public void testEnableSyscalls() { |
1012 | try { | |
1013 | // 1) session name, channel = null, 3 event names, kernel | |
1014 | String sessionName = "mysession2"; | |
1015 | String channelName = "mychannel"; | |
cfdb727a | 1016 | |
d132bcc7 BH |
1017 | fShell.setScenario(SCEN_EVENT_HANDLING); |
1018 | ||
cfdb727a | 1019 | // 1) session name, channel = null |
d132bcc7 BH |
1020 | fService.enableSyscalls(sessionName, null, new NullProgressMonitor()); |
1021 | ||
1022 | // 2) session name, channel = mychannel | |
1023 | fService.enableSyscalls(sessionName, channelName, new NullProgressMonitor()); | |
cfdb727a | 1024 | |
d132bcc7 BH |
1025 | } catch (ExecutionException e) { |
1026 | fail(e.toString()); | |
1027 | } | |
1028 | } | |
1029 | ||
2ba3d0a1 | 1030 | @Test |
d132bcc7 BH |
1031 | public void testDynamicProbe() { |
1032 | try { | |
1033 | // 1) session name, channel = null, 3 event names, kernel | |
1034 | String sessionName = "mysession2"; | |
1035 | String channelName = "mychannel"; | |
1036 | String eventName0 = "myevent0"; | |
1037 | String eventName1 = "myevent1"; | |
1038 | String functionProbe = "0xc0101340"; | |
1039 | String dynProbe = "init_post"; | |
cfdb727a | 1040 | |
d132bcc7 BH |
1041 | fShell.setScenario(SCEN_EVENT_HANDLING); |
1042 | ||
cfdb727a | 1043 | // 1) session name, channel = null, event name, function probe, probe |
d132bcc7 BH |
1044 | fService.enableProbe(sessionName, null, eventName0, true, functionProbe, new NullProgressMonitor()); |
1045 | ||
1046 | // 2) session name, channel = mychannel | |
1047 | fService.enableProbe(sessionName, channelName, eventName1, false, dynProbe, new NullProgressMonitor()); | |
cfdb727a | 1048 | |
d132bcc7 BH |
1049 | } catch (ExecutionException e) { |
1050 | fail(e.toString()); | |
1051 | } | |
1052 | } | |
1053 | ||
2ba3d0a1 | 1054 | @Test |
d132bcc7 BH |
1055 | public void testEnableLogLevel() { |
1056 | try { | |
1057 | // 1) session name, channel = null, 3 event names, kernel | |
1058 | String sessionName = "mysession2"; | |
1059 | String channelName = "mychannel"; | |
1060 | String eventName4 = "myevent4"; | |
1061 | String eventName5 = "myevent5"; | |
cfdb727a | 1062 | |
d132bcc7 | 1063 | fShell.setScenario(SCEN_EVENT_HANDLING); |
cfdb727a | 1064 | |
d132bcc7 | 1065 | // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG |
d4514365 | 1066 | fService.enableLogLevel(sessionName, null, eventName4, LogLevelType.LOGLEVEL_ONLY, TraceLogLevel.TRACE_DEBUG, null, new NullProgressMonitor()); |
d132bcc7 BH |
1067 | |
1068 | // 2) session name, channel = mychannel, null, loglevel, TRACE_DEBUG_FUNCTION | |
d4514365 BH |
1069 | fService.enableLogLevel(sessionName, channelName, eventName5, LogLevelType.LOGLEVEL, TraceLogLevel.TRACE_DEBUG_FUNCTION, null, new NullProgressMonitor()); |
1070 | ||
1071 | // TODO add test with filters | |
d132bcc7 BH |
1072 | |
1073 | } catch (ExecutionException e) { | |
1074 | fail(e.toString()); | |
1075 | } | |
1076 | } | |
cfdb727a | 1077 | |
2ba3d0a1 | 1078 | @Test |
4ea599a5 BH |
1079 | public void testAddContext() { |
1080 | try { | |
1081 | // 1) session name, channel = null, 3 event names, kernel | |
1082 | String sessionName = "mysession2"; | |
1083 | String channelName = "mychannel"; | |
1084 | String eventName = "ust_tests_hello:tptest_sighandler"; | |
e0838ca1 | 1085 | List<String> contexts = new ArrayList<>(); |
4ea599a5 BH |
1086 | contexts.add("prio"); |
1087 | contexts.add("pid"); | |
1088 | ||
1089 | fShell.setScenario(SCEN_CONTEXT_HANDLING); | |
1090 | ||
1091 | List<String> availContexts = fService.getContextList(new NullProgressMonitor()); | |
1092 | assertNotNull(availContexts); | |
1093 | assertEquals(12, availContexts.size()); | |
1094 | ||
cfdb727a | 1095 | // A very "hard-coded" way to verify but it works ... |
e0838ca1 | 1096 | Set<String> expectedContexts = new HashSet<>(); |
4ea599a5 BH |
1097 | expectedContexts.add("pid"); |
1098 | expectedContexts.add("procname"); | |
1099 | expectedContexts.add("prio"); | |
1100 | expectedContexts.add("nice"); | |
1101 | expectedContexts.add("vpid"); | |
1102 | expectedContexts.add("tid"); | |
1103 | expectedContexts.add("pthread_id"); | |
1104 | expectedContexts.add("vtid"); | |
1105 | expectedContexts.add("ppid"); | |
1106 | expectedContexts.add("vppid"); | |
1107 | expectedContexts.add("perf:cpu-cycles"); | |
1108 | expectedContexts.add("perf:cycles"); | |
cfdb727a | 1109 | |
4ea599a5 | 1110 | assertTrue(expectedContexts.containsAll(availContexts)); |
cfdb727a | 1111 | |
4ea599a5 BH |
1112 | // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG |
1113 | fService.addContexts(sessionName, channelName, eventName, false, contexts, new NullProgressMonitor()); | |
1114 | ||
1115 | } catch (ExecutionException e) { | |
1116 | fail(e.toString()); | |
1117 | } | |
1118 | } | |
1119 | ||
2ba3d0a1 | 1120 | @Test |
4ea599a5 BH |
1121 | public void testAddContextFailure() { |
1122 | ||
1123 | // 1) session name, channel = null, 3 event names, kernel | |
1124 | String sessionName = "mysession2"; | |
1125 | String channelName = "mychannel"; | |
1126 | String eventName = "ust_tests_hello:tptest_sighandler"; | |
e0838ca1 | 1127 | List<String> contexts = new ArrayList<>(); |
4ea599a5 BH |
1128 | contexts.add("prio"); |
1129 | contexts.add("pid"); | |
1130 | fShell.setScenario(SCEN_CONTEXT_ERROR_HANDLING); | |
1131 | try { | |
1132 | fService.getContextList(new NullProgressMonitor()); | |
1133 | fail("No exeption generated"); | |
1134 | } catch (ExecutionException e) { | |
1135 | // success | |
cfdb727a | 1136 | } |
4ea599a5 BH |
1137 | try { |
1138 | // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG | |
1139 | fService.addContexts(sessionName, channelName, eventName, false, contexts, new NullProgressMonitor()); | |
1140 | fail("No exeption generated"); | |
1141 | } catch (ExecutionException e) { | |
1142 | // success | |
cfdb727a | 1143 | } |
4ea599a5 BH |
1144 | } |
1145 | ||
2ba3d0a1 | 1146 | @Test |
4ea599a5 BH |
1147 | public void testCalibrate() { |
1148 | try { | |
1149 | fShell.setScenario(SCEN_CALIBRATE_HANDLING); | |
1150 | fService.calibrate(true, new NullProgressMonitor()); | |
1151 | ||
1152 | } catch (ExecutionException e) { | |
1153 | fail(e.toString()); | |
1154 | } | |
1155 | } | |
1156 | ||
2ba3d0a1 | 1157 | @Test |
4ea599a5 | 1158 | public void testCalibrateFailure() { |
4ea599a5 BH |
1159 | try { |
1160 | fShell.setScenario(SCEN_CALIBRATE_HANDLING); | |
1161 | fService.calibrate(false, new NullProgressMonitor()); | |
1162 | fail("No exeption generated"); | |
1163 | } catch (ExecutionException e) { | |
1164 | // success | |
cfdb727a | 1165 | } |
4ea599a5 | 1166 | } |
cfdb727a | 1167 | |
a30e79fe | 1168 | @Test |
f3b33d40 BH |
1169 | public void testCreateSession2_1() { |
1170 | ||
1171 | try { | |
1172 | fShell.setScenario(SCEN_CREATE_SESSION_2_1); | |
1173 | ||
f7d4d450 MAL |
1174 | ISessionInfo sessionInfo = new SessionInfo("mysession"); |
1175 | sessionInfo.setNetworkUrl("net://172.0.0.1"); | |
1176 | sessionInfo.setStreamedTrace(true); | |
1177 | ISessionInfo info = fService.createSession(sessionInfo, new NullProgressMonitor()); | |
f3b33d40 BH |
1178 | assertNotNull(info); |
1179 | assertEquals("mysession", info.getName()); | |
1180 | assertEquals("net://172.0.0.1", info.getSessionPath()); | |
1181 | assertTrue(info.isStreamedTrace()); | |
1182 | fService.destroySession("mysession", new NullProgressMonitor()); | |
1183 | ||
f7d4d450 MAL |
1184 | sessionInfo = new SessionInfo("mysession"); |
1185 | sessionInfo.setStreamedTrace(true); | |
1186 | sessionInfo.setNetworkUrl("file:///tmp"); | |
1187 | info = fService.createSession(sessionInfo, new NullProgressMonitor()); | |
f3b33d40 BH |
1188 | assertNotNull(info); |
1189 | assertEquals("mysession", info.getName()); | |
1190 | assertEquals("file:///tmp", info.getSessionPath()); | |
d128c979 | 1191 | assertTrue(!info.isStreamedTrace()); |
f3b33d40 BH |
1192 | fService.destroySession("mysession", new NullProgressMonitor()); |
1193 | ||
f7d4d450 MAL |
1194 | sessionInfo = new SessionInfo("mysession"); |
1195 | sessionInfo.setStreamedTrace(true); | |
1196 | sessionInfo.setNetworkUrl("file:///tmp"); | |
1197 | info = fService.createSession(sessionInfo, new NullProgressMonitor()); | |
f3b33d40 BH |
1198 | assertNotNull(info); |
1199 | assertEquals("mysession", info.getName()); | |
1200 | assertEquals("file:///tmp", info.getSessionPath()); | |
d128c979 | 1201 | assertTrue(!info.isStreamedTrace()); |
f3b33d40 BH |
1202 | fService.destroySession("mysession", new NullProgressMonitor()); |
1203 | ||
f7d4d450 MAL |
1204 | sessionInfo = new SessionInfo("mysession"); |
1205 | sessionInfo.setStreamedTrace(true); | |
1206 | sessionInfo.setControlUrl("tcp://172.0.0.1"); | |
1207 | sessionInfo.setDataUrl("tcp://172.0.0.1:5343"); | |
1208 | info = fService.createSession(sessionInfo, new NullProgressMonitor()); | |
f3b33d40 BH |
1209 | assertNotNull(info); |
1210 | assertEquals("mysession", info.getName()); | |
d128c979 | 1211 | assertEquals("", info.getSessionPath()); // the complete network path is not available at this point |
f3b33d40 BH |
1212 | assertTrue(info.isStreamedTrace()); |
1213 | fService.destroySession("mysession", new NullProgressMonitor()); | |
1214 | ||
f7d4d450 MAL |
1215 | sessionInfo = new SessionInfo("mysession"); |
1216 | sessionInfo.setStreamedTrace(true); | |
1217 | sessionInfo.setNetworkUrl("net://172.0.0.1:1234:2345"); | |
1218 | info = fService.createSession(sessionInfo, new NullProgressMonitor()); | |
f3b33d40 BH |
1219 | assertNotNull(info); |
1220 | assertEquals("mysession", info.getName()); | |
1221 | assertEquals("net://172.0.0.1:1234:2345", info.getSessionPath()); | |
1222 | assertTrue(info.isStreamedTrace()); | |
1223 | fService.destroySession("mysession", new NullProgressMonitor()); | |
1224 | ||
d128c979 BH |
1225 | // verbose |
1226 | enableVerbose(); | |
f7d4d450 MAL |
1227 | sessionInfo = new SessionInfo("mysession"); |
1228 | sessionInfo.setStreamedTrace(true); | |
1229 | sessionInfo.setNetworkUrl("net://172.0.0.1"); | |
1230 | info = fService.createSession(sessionInfo, new NullProgressMonitor()); | |
d128c979 BH |
1231 | assertNotNull(info); |
1232 | assertEquals("mysession", info.getName()); | |
1233 | assertEquals("net://172.0.0.1", info.getSessionPath()); | |
1234 | assertTrue(info.isStreamedTrace()); | |
1235 | disableVerbose(); | |
1236 | fService.destroySession("mysession", new NullProgressMonitor()); | |
1237 | ||
1238 | ||
1239 | } catch (ExecutionException e) { | |
1240 | fail(e.toString()); | |
1241 | } | |
1242 | } | |
1243 | ||
1244 | @Test | |
1245 | public void testCreateSessionVerbose2_1() { | |
1246 | try { | |
1247 | fShell.setScenario(SCEN_CREATE_SESSION_VERBOSE_2_1); | |
1248 | ||
1249 | enableVerbose(); | |
f7d4d450 MAL |
1250 | ISessionInfo sessionInfo = new SessionInfo("mysession"); |
1251 | sessionInfo.setStreamedTrace(true); | |
1252 | sessionInfo.setNetworkUrl("net://172.0.0.1"); | |
1253 | ISessionInfo info = fService.createSession(sessionInfo, new NullProgressMonitor()); | |
d128c979 BH |
1254 | assertNotNull(info); |
1255 | assertEquals("mysession", info.getName()); | |
1256 | assertEquals("net://172.0.0.1", info.getSessionPath()); | |
1257 | assertTrue(info.isStreamedTrace()); | |
1258 | fService.destroySession("mysession", new NullProgressMonitor()); | |
f3b33d40 BH |
1259 | } catch (ExecutionException e) { |
1260 | fail(e.toString()); | |
d128c979 BH |
1261 | } finally { |
1262 | disableVerbose(); | |
f3b33d40 BH |
1263 | } |
1264 | } | |
d128c979 | 1265 | |
589d0d33 BH |
1266 | @Test |
1267 | public void testCreateSnapshotSession() { | |
1268 | try { | |
1269 | fShell.setScenario(SCEN_CREATE_SNAPSHOT_SESSION); | |
f7d4d450 MAL |
1270 | ISessionInfo params = new SessionInfo("mysession"); |
1271 | params.setSnapshot(true); | |
1272 | ISessionInfo sessionInfo = fService.createSession(params, new NullProgressMonitor()); | |
589d0d33 BH |
1273 | assertNotNull(sessionInfo); |
1274 | assertEquals("mysession", sessionInfo.getName()); | |
1275 | assertTrue(sessionInfo.isSnapshotSession()); | |
1276 | assertEquals("", sessionInfo.getSessionPath()); | |
1277 | assertTrue(!sessionInfo.isStreamedTrace()); | |
1278 | ||
1279 | assertEquals(TraceSessionState.INACTIVE, sessionInfo.getSessionState()); | |
1280 | ||
1281 | String[] names = fService.getSessionNames(new NullProgressMonitor()); | |
1282 | assertEquals(names[0], "mysession"); | |
1283 | ||
1284 | ISnapshotInfo snapshotInfo = fService.getSnapshotInfo("mysession", new NullProgressMonitor()); | |
1285 | assertNotNull(snapshotInfo); | |
1286 | assertEquals("snapshot-1", snapshotInfo.getName()); | |
1287 | assertEquals("/home/user/lttng-traces/mysession-20130913-141651", snapshotInfo.getSnapshotPath()); | |
1288 | assertEquals(1, snapshotInfo.getId()); | |
1289 | assertTrue(!snapshotInfo.isStreamedSnapshot()); | |
1290 | ||
1291 | // we need to set the snapshotInfo to so that the session path is set correctly | |
1292 | sessionInfo.setSnapshotInfo(snapshotInfo); | |
1293 | assertEquals("/home/user/lttng-traces/mysession-20130913-141651", sessionInfo.getSessionPath()); | |
1294 | ||
1295 | fService.recordSnapshot("mysession", new NullProgressMonitor()); | |
1296 | ||
1297 | fService.destroySession("mysession", new NullProgressMonitor()); | |
1298 | ||
1299 | } catch (ExecutionException e) { | |
1300 | fail(e.toString()); | |
1301 | } | |
1302 | } | |
1303 | ||
1304 | public void testCreateStreamedSnapshotSession() { | |
1305 | try { | |
1306 | fShell.setScenario(SCEN_CREATE_STREAMED_SNAPSHOT_SESSION); | |
1307 | ||
f7d4d450 MAL |
1308 | ISessionInfo params = new SessionInfo("mysession"); |
1309 | params.setNetworkUrl("net://172.0.0.1"); | |
1310 | ISessionInfo sessionInfo = fService.createSession(params, new NullProgressMonitor()); | |
589d0d33 BH |
1311 | assertNotNull(sessionInfo); |
1312 | assertEquals("mysession", sessionInfo.getName()); | |
1313 | assertTrue(sessionInfo.isSnapshotSession()); | |
1314 | ||
1315 | assertEquals(TraceSessionState.INACTIVE, sessionInfo.getSessionState()); | |
1316 | assertTrue(sessionInfo.isStreamedTrace()); | |
1317 | ||
1318 | String[] names = fService.getSessionNames(new NullProgressMonitor()); | |
1319 | assertEquals(names[0], "mysession"); | |
1320 | ||
1321 | ||
1322 | ISnapshotInfo snapshotInfo = sessionInfo.getSnapshotInfo(); | |
1323 | assertNotNull(sessionInfo); | |
1324 | assertEquals("snapshot-2", snapshotInfo.getName()); | |
1325 | assertEquals("net4://172.0.0.1:5342/", snapshotInfo.getSnapshotPath()); | |
1326 | assertEquals(2, snapshotInfo.getId()); | |
1327 | assertTrue(snapshotInfo.isStreamedSnapshot()); | |
1328 | ||
1329 | // we need to set the snapshotInfo to so that the session path is set correctly | |
1330 | sessionInfo.setSnapshotInfo(snapshotInfo); | |
1331 | assertEquals("net4://172.0.0.1:5342/", sessionInfo.getSessionPath()); | |
1332 | ||
1333 | fService.recordSnapshot("mysession", new NullProgressMonitor()); | |
1334 | ||
1335 | fService.destroySession("mysession", new NullProgressMonitor()); | |
1336 | ||
1337 | } catch (ExecutionException e) { | |
1338 | fail(e.toString()); | |
1339 | } | |
1340 | } | |
1341 | ||
1342 | ||
1343 | @Test | |
1344 | public void testCreateSnapshotSessionErrors() { | |
1345 | try { | |
1346 | fShell.setScenario(SCEN_CREATE_SNAPSHOT_SESSION_ERRORS); | |
1347 | ||
1348 | String[] names = fService.getSessionNames(new NullProgressMonitor()); | |
1349 | assertEquals(names[0], "mysession"); | |
1350 | } catch (ExecutionException e) { | |
1351 | fail(e.toString()); | |
1352 | } | |
1353 | ||
1354 | try { | |
1355 | fService.getSnapshotInfo("blabla", new NullProgressMonitor()); | |
1356 | fail("getSnapshoInfo() didn't fail"); | |
1357 | } catch (ExecutionException e) { | |
1358 | // successful | |
1359 | } | |
1360 | ||
1361 | try { | |
1362 | fService.recordSnapshot("blabla", new NullProgressMonitor()); | |
1363 | fail("getSnapshoInfo() didn't fail"); | |
1364 | } catch (ExecutionException e) { | |
1365 | // successful | |
1366 | } | |
1367 | ||
1368 | try { | |
1369 | fService.recordSnapshot("mysession", new NullProgressMonitor()); | |
1370 | fail("getSnapshoInfo() didn't fail"); | |
1371 | } catch (ExecutionException e) { | |
1372 | // successful | |
1373 | } | |
1374 | } | |
1375 | ||
d128c979 BH |
1376 | private static void enableVerbose() { |
1377 | // verbose | |
1378 | ControlCommandLogger.init(ControlPreferences.getInstance().getLogfilePath(), false); | |
1379 | ControlPreferences.getInstance().getPreferenceStore().setDefault(ControlPreferences.TRACE_CONTROL_LOG_COMMANDS_PREF, true); | |
1380 | ControlPreferences.getInstance().getPreferenceStore().setDefault(ControlPreferences.TRACE_CONTROL_VERBOSE_LEVEL_PREF, ControlPreferences.TRACE_CONTROL_VERBOSE_LEVEL_V_V_VERBOSE); | |
1381 | } | |
1382 | ||
1383 | private static void disableVerbose() { | |
1384 | ControlPreferences.getInstance().getPreferenceStore().setDefault(ControlPreferences.TRACE_CONTROL_LOG_COMMANDS_PREF, false); | |
1385 | } | |
1386 | ||
1387 | ||
eb1bab5b | 1388 | } |