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