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