1 /**********************************************************************
2 * Copyright (c) 2012 Ericsson
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
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12 package org
.eclipse
.linuxtools
.lttng2
.ui
.tests
.control
.model
.component
;
17 import junit
.framework
.Test
;
18 import junit
.framework
.TestCase
;
19 import junit
.framework
.TestSuite
;
21 import org
.eclipse
.core
.runtime
.FileLocator
;
22 import org
.eclipse
.core
.runtime
.Path
;
23 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IChannelInfo
;
24 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TargetNodeState
;
25 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceEnablement
;
26 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceEventType
;
27 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceLogLevel
;
28 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceSessionState
;
29 import org
.eclipse
.linuxtools
.internal
.lttng2
.stubs
.service
.TestRemoteSystemProxy
;
30 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.ITraceControlComponent
;
31 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.BaseEventComponent
;
32 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.KernelProviderComponent
;
33 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TargetNodeComponent
;
34 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceChannelComponent
;
35 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceDomainComponent
;
36 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceEventComponent
;
37 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceProbeEventComponent
;
38 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceSessionComponent
;
39 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.UstProviderComponent
;
40 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.property
.BaseEventPropertySource
;
41 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.property
.KernelProviderPropertySource
;
42 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.property
.TargetNodePropertySource
;
43 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.property
.TraceChannelPropertySource
;
44 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.property
.TraceDomainPropertySource
;
45 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.property
.TraceEventPropertySource
;
46 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.property
.TraceProbeEventPropertySource
;
47 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.property
.TraceSessionPropertySource
;
48 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.property
.UstProviderPropertySource
;
49 import org
.eclipse
.rse
.core
.RSECorePlugin
;
50 import org
.eclipse
.rse
.core
.model
.IHost
;
51 import org
.eclipse
.rse
.core
.model
.ISystemProfile
;
52 import org
.eclipse
.rse
.core
.model
.ISystemRegistry
;
53 import org
.eclipse
.ui
.views
.properties
.IPropertySource
;
54 import org
.junit
.After
;
55 import org
.junit
.Before
;
56 import org
.osgi
.framework
.FrameworkUtil
;
60 * The class <code>TraceControlPropertiesTest</code> contains tests for the all property class</code>.
63 @SuppressWarnings("nls")
64 public class TraceControlPropertiesTest
extends TestCase
{
66 // ------------------------------------------------------------------------
68 // ------------------------------------------------------------------------
69 private static final String DIRECTORY
= "testfiles";
70 private static final String TEST_STREAM
= "ListInfoTest.cfg";
71 private static final String SCEN_LIST_INFO_TEST
= "ListInfoTest";
74 // ------------------------------------------------------------------------
76 // ------------------------------------------------------------------------
78 // ------------------------------------------------------------------------
80 // ------------------------------------------------------------------------
83 * Returns test setup used when executing test case stand-alone.
84 * @return Test setup class
86 public static Test
suite() {
87 return new ModelImplTestSetup(new TestSuite(TraceControlPropertiesTest
.class));
90 // ------------------------------------------------------------------------
92 // ------------------------------------------------------------------------
95 * Perform pre-test initialization.
98 * if the initialization fails for some reason
103 public void setUp() throws Exception
{
107 * Perform post-test clean-up.
110 * if the clean-up fails for some reason
115 public void tearDown() throws Exception
{
116 TraceControlTestFacility
.getInstance().waitForJobs();
120 * Run the TraceControlComponent.
123 * This will fail the test
125 public void testComponentProperties() throws Exception
{
127 TestRemoteSystemProxy proxy
= new TestRemoteSystemProxy();
129 URL location
= FileLocator
.find(FrameworkUtil
.getBundle(this.getClass()), new Path(DIRECTORY
+ File
.separator
+ TEST_STREAM
), null);
130 File testfile
= new File(FileLocator
.toFileURL(location
).toURI());
131 proxy
.setTestFile(testfile
.getAbsolutePath());
132 proxy
.setScenario(SCEN_LIST_INFO_TEST
);
134 ITraceControlComponent root
= TraceControlTestFacility
.getInstance().getControlView().getTraceControlRoot();
136 ISystemRegistry registry
= RSECorePlugin
.getTheSystemRegistry();
137 ISystemProfile profile
= registry
.createSystemProfile("myProfile", true);
138 IHost host
= registry
.createLocalHost(profile
, "myProfile", "user");
140 TargetNodeComponent node
= new TargetNodeComponent("myNode", root
, host
, proxy
);
145 TraceControlTestFacility
.getInstance().waitForJobs();
147 // ------------------------------------------------------------------------
148 // Verify Node Properties (adapter)
149 // ------------------------------------------------------------------------
150 Object adapter
= node
.getAdapter(IPropertySource
.class);
151 assertNotNull(adapter
);
152 assertTrue(adapter
instanceof TargetNodePropertySource
);
154 TargetNodePropertySource source
= (TargetNodePropertySource
)adapter
;
156 assertNull(source
.getEditableValue());
157 assertFalse(source
.isPropertySet(TargetNodePropertySource
.TARGET_NODE_NAME_PROPERTY_ID
));
158 assertNotNull(source
.getPropertyDescriptors());
160 assertEquals("myNode", source
.getPropertyValue(TargetNodePropertySource
.TARGET_NODE_NAME_PROPERTY_ID
));
161 assertEquals("LOCALHOST", source
.getPropertyValue(TargetNodePropertySource
.TARGET_NODE_ADDRESS_PROPERTY_ID
));
162 assertEquals(TargetNodeState
.CONNECTED
.name(), source
.getPropertyValue(TargetNodePropertySource
.TARGET_NODE_STATE_PROPERTY_ID
));
163 assertEquals("2.0.0", source
.getPropertyValue(TargetNodePropertySource
.TARGET_NODE_VERSION_PROPERTY_ID
));
164 assertNull(source
.getPropertyValue("test"));
166 adapter
= node
.getAdapter(IChannelInfo
.class);
169 ITraceControlComponent
[] groups
= node
.getChildren();
170 assertNotNull(groups
);
171 assertEquals(2, groups
.length
);
173 ITraceControlComponent
[] providers
= groups
[0].getChildren();
175 assertNotNull(providers
);
176 assertEquals(3, providers
.length
);
178 // ------------------------------------------------------------------------
179 // Verify Kernel Provider Properties (adapter)
180 // ------------------------------------------------------------------------
181 KernelProviderComponent kernelProvider
= (KernelProviderComponent
) providers
[0];
183 adapter
= kernelProvider
.getAdapter(IPropertySource
.class);
184 assertNotNull(adapter
);
185 assertTrue(adapter
instanceof KernelProviderPropertySource
);
187 KernelProviderPropertySource kernelSource
= (KernelProviderPropertySource
)adapter
;
188 assertNotNull(kernelSource
.getPropertyDescriptors());
190 assertEquals("Kernel", kernelSource
.getPropertyValue(KernelProviderPropertySource
.KERNEL_PROVIDER_NAME_PROPERTY_ID
));
192 // ------------------------------------------------------------------------
193 // Verify UST Provider Properties (adapter)
194 // ------------------------------------------------------------------------
195 UstProviderComponent ustProvider
= (UstProviderComponent
) providers
[1];
197 adapter
= ustProvider
.getAdapter(IPropertySource
.class);
198 assertNotNull(adapter
);
199 assertTrue(adapter
instanceof UstProviderPropertySource
);
201 UstProviderPropertySource ustSource
= (UstProviderPropertySource
)adapter
;
202 assertNotNull(ustSource
.getPropertyDescriptors());
204 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello [PID=9379]", ustSource
.getPropertyValue(UstProviderPropertySource
.UST_PROVIDER_NAME_PROPERTY_ID
));
205 assertEquals(String
.valueOf(9379), ustSource
.getPropertyValue(UstProviderPropertySource
.UST_PROVIDER_PID_PROPERTY_ID
));
207 // ------------------------------------------------------------------------
208 // Verify Base Event Properties (adapter)
209 // ------------------------------------------------------------------------
210 ITraceControlComponent
[] events
= ustProvider
.getChildren();
211 assertNotNull(events
);
212 assertEquals(2, events
.length
);
214 BaseEventComponent baseEventInfo
= (BaseEventComponent
) events
[0];
215 assertNotNull(baseEventInfo
);
217 adapter
= baseEventInfo
.getAdapter(IPropertySource
.class);
218 assertNotNull(adapter
);
219 assertTrue(adapter
instanceof BaseEventPropertySource
);
221 BaseEventPropertySource baseSource
= (BaseEventPropertySource
)adapter
;
222 assertNotNull(baseSource
.getPropertyDescriptors());
224 assertEquals("ust_tests_hello:tptest_sighandler", baseSource
.getPropertyValue(BaseEventPropertySource
.BASE_EVENT_NAME_PROPERTY_ID
));
225 assertEquals(TraceEventType
.TRACEPOINT
.name(), baseSource
.getPropertyValue(BaseEventPropertySource
.BASE_EVENT_TYPE_PROPERTY_ID
));
226 assertEquals(TraceLogLevel
.TRACE_DEBUG_MODULE
.name(), baseSource
.getPropertyValue(BaseEventPropertySource
.BASE_EVENT_LOGLEVEL_PROPERTY_ID
));
228 // ------------------------------------------------------------------------
229 // Verify Session Properties (adapter)
230 // ------------------------------------------------------------------------
231 ITraceControlComponent
[] sessions
= groups
[1].getChildren();
232 assertNotNull(sessions
);
233 assertEquals(2, sessions
.length
);
235 TraceSessionComponent session
= (TraceSessionComponent
)sessions
[1];
237 adapter
= session
.getAdapter(IPropertySource
.class);
238 assertNotNull(adapter
);
239 assertTrue(adapter
instanceof TraceSessionPropertySource
);
241 TraceSessionPropertySource sessionSource
= (TraceSessionPropertySource
)adapter
;
242 assertNotNull(sessionSource
.getPropertyDescriptors());
244 assertEquals("mysession", sessionSource
.getPropertyValue(TraceSessionPropertySource
.TRACE_SESSION_NAME_PROPERTY_ID
));
245 assertEquals("/home/user/lttng-traces/mysession-20120129-084256", sessionSource
.getPropertyValue(TraceSessionPropertySource
.TRACE_SESSION_PATH_PROPERTY_ID
));
246 assertEquals(TraceSessionState
.ACTIVE
.name(), sessionSource
.getPropertyValue(TraceSessionPropertySource
.TRACE_SESSION_STATE_PROPERTY_ID
));
248 // ------------------------------------------------------------------------
249 // Verify Domain Provider Properties (adapter)
250 // ------------------------------------------------------------------------
251 ITraceControlComponent
[] domains
= session
.getChildren();
252 assertNotNull(domains
);
253 assertEquals(2, domains
.length
);
255 TraceDomainComponent domain
= (TraceDomainComponent
) domains
[0];
256 adapter
= domain
.getAdapter(IPropertySource
.class);
257 assertNotNull(adapter
);
258 assertTrue(adapter
instanceof TraceDomainPropertySource
);
260 TraceDomainPropertySource domainSource
= (TraceDomainPropertySource
)adapter
;
261 assertNotNull(domainSource
.getPropertyDescriptors());
263 assertEquals("Kernel", domainSource
.getPropertyValue(TraceDomainPropertySource
.TRACE_DOMAIN_NAME_PROPERTY_ID
));
265 ITraceControlComponent
[] channels
= domains
[0].getChildren();
266 assertNotNull(channels
);
267 assertEquals(2, channels
.length
);
269 // ------------------------------------------------------------------------
270 // Verify Channel Properties (adapter)
271 // ------------------------------------------------------------------------
272 assertTrue(channels
[0] instanceof TraceChannelComponent
);
273 TraceChannelComponent channel
= (TraceChannelComponent
) channels
[0];
275 adapter
= channel
.getAdapter(IPropertySource
.class);
276 assertNotNull(adapter
);
277 assertTrue(adapter
instanceof TraceChannelPropertySource
);
279 TraceChannelPropertySource channelSource
= (TraceChannelPropertySource
)adapter
;
280 assertNotNull(channelSource
.getPropertyDescriptors());
282 assertEquals("channel0", channelSource
.getPropertyValue(TraceChannelPropertySource
.TRACE_CHANNEL_NAME_PROPERTY_ID
));
283 assertEquals(String
.valueOf(4), channelSource
.getPropertyValue(TraceChannelPropertySource
.TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_ID
));
284 assertEquals(TraceEnablement
.ENABLED
.name(), channelSource
.getPropertyValue(TraceChannelPropertySource
.TRACE_CHANNEL_STATE_PROPERTY_ID
));
285 assertEquals(String
.valueOf(false), channelSource
.getPropertyValue(TraceChannelPropertySource
.TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_ID
));
286 assertEquals("splice()", channelSource
.getPropertyValue(TraceChannelPropertySource
.TRACE_CHANNEL_OUTPUT_TYPE_PROPERTY_ID
));
287 assertEquals(String
.valueOf(200), channelSource
.getPropertyValue(TraceChannelPropertySource
.TRACE_CHANNEL_READ_TIMER_PROPERTY_ID
));
288 assertEquals(String
.valueOf(262144), channelSource
.getPropertyValue(TraceChannelPropertySource
.TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_ID
));
289 assertEquals(String
.valueOf(0), channelSource
.getPropertyValue(TraceChannelPropertySource
.TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_ID
));
291 // ------------------------------------------------------------------------
292 // Verify Event Properties (adapter)
293 // ------------------------------------------------------------------------
294 ITraceControlComponent
[] channel0Events
= channel
.getChildren();
295 assertNotNull(channel0Events
);
296 assertEquals(5, channel0Events
.length
);
297 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
299 TraceEventComponent event
= (TraceEventComponent
) channel0Events
[0];
301 adapter
= event
.getAdapter(IPropertySource
.class);
302 assertNotNull(adapter
);
303 assertTrue(adapter
instanceof TraceEventPropertySource
);
305 TraceEventPropertySource eventSource
= (TraceEventPropertySource
)adapter
;
306 assertNotNull(eventSource
.getPropertyDescriptors());
308 assertEquals("block_rq_remap", eventSource
.getPropertyValue(TraceEventPropertySource
.TRACE_EVENT_NAME_PROPERTY_ID
));
309 assertEquals(TraceLogLevel
.TRACE_EMERG
.name(), eventSource
.getPropertyValue(TraceEventPropertySource
.TRACE_EVENT_LOGLEVEL_PROPERTY_ID
));
310 assertEquals(TraceEventType
.TRACEPOINT
.name(), eventSource
.getPropertyValue(TraceEventPropertySource
.TRACE_EVENT_TYPE_PROPERTY_ID
));
311 assertEquals(TraceEnablement
.ENABLED
.name(), eventSource
.getPropertyValue(TraceEventPropertySource
.TRACE_EVENT_STATE_PROPERTY_ID
));
313 // ------------------------------------------------------------------------
314 // Verify Probe Event Properties (adapter)
315 // ------------------------------------------------------------------------
316 assertTrue(channel0Events
[2] instanceof TraceProbeEventComponent
);
318 TraceProbeEventComponent probeEvent
= (TraceProbeEventComponent
) channel0Events
[2];
320 adapter
= probeEvent
.getAdapter(IPropertySource
.class);
321 assertNotNull(adapter
);
322 assertTrue(adapter
instanceof TraceProbeEventPropertySource
);
324 TraceProbeEventPropertySource probeEventSource
= (TraceProbeEventPropertySource
)adapter
;
325 assertNotNull(probeEventSource
.getPropertyDescriptors());
326 assertEquals(4, probeEventSource
.getPropertyDescriptors().length
);
328 assertEquals("myevent2", probeEventSource
.getPropertyValue(TraceEventPropertySource
.TRACE_EVENT_NAME_PROPERTY_ID
));
329 assertEquals(TraceEventType
.PROBE
.name(), probeEventSource
.getPropertyValue(TraceEventPropertySource
.TRACE_EVENT_TYPE_PROPERTY_ID
));
330 assertEquals(TraceEnablement
.ENABLED
.name(), probeEventSource
.getPropertyValue(TraceEventPropertySource
.TRACE_EVENT_STATE_PROPERTY_ID
));
331 assertEquals("0xc0101340", probeEventSource
.getPropertyValue(TraceProbeEventPropertySource
.TRACE_EVENT_PROBE_ADDRESS_PROPERTY_ID
));
333 assertTrue(channel0Events
[3] instanceof TraceProbeEventComponent
);
335 probeEvent
= (TraceProbeEventComponent
) channel0Events
[3];
337 adapter
= probeEvent
.getAdapter(IPropertySource
.class);
338 assertNotNull(adapter
);
339 assertTrue(adapter
instanceof TraceProbeEventPropertySource
);
341 probeEventSource
= (TraceProbeEventPropertySource
)adapter
;
342 assertNotNull(probeEventSource
.getPropertyDescriptors());
343 assertEquals(5, probeEventSource
.getPropertyDescriptors().length
);
345 assertEquals("myevent0", probeEventSource
.getPropertyValue(TraceEventPropertySource
.TRACE_EVENT_NAME_PROPERTY_ID
));
346 assertEquals(TraceEventType
.PROBE
.name(), probeEventSource
.getPropertyValue(TraceEventPropertySource
.TRACE_EVENT_TYPE_PROPERTY_ID
));
347 assertEquals(TraceEnablement
.ENABLED
.name(), probeEventSource
.getPropertyValue(TraceEventPropertySource
.TRACE_EVENT_STATE_PROPERTY_ID
));
348 assertEquals("0x0", probeEventSource
.getPropertyValue(TraceProbeEventPropertySource
.TRACE_EVENT_PROBE_OFFSET_PROPERTY_ID
));
349 assertEquals("init_post", probeEventSource
.getPropertyValue(TraceProbeEventPropertySource
.TRACE_EVENT_PROBE_SYMBOL_PROPERTY_ID
));
351 //-------------------------------------------------------------------------
353 //-------------------------------------------------------------------------
355 node
.getParent().removeChild(node
);