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
.lttng
.ui
.tests
.control
.model
.component
;
14 import junit
.framework
.Test
;
15 import junit
.framework
.TestCase
;
16 import junit
.framework
.TestSuite
;
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
.TraceDomainComponent
;
31 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.impl
.TraceEventComponent
;
32 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.impl
.TraceSessionComponent
;
33 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.impl
.UstProviderComponent
;
34 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.property
.BaseEventPropertySource
;
35 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.property
.KernelProviderPropertySource
;
36 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.property
.TargetNodePropertySource
;
37 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.property
.TraceChannelPropertySource
;
38 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.property
.TraceDomainPropertySource
;
39 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.property
.TraceEventPropertySource
;
40 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.property
.TraceSessionPropertySource
;
41 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.property
.UstProviderPropertySource
;
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
.ui
.views
.properties
.IPropertySource
;
46 import org
.junit
.After
;
47 import org
.junit
.Before
;
50 * The class <code>TraceControlPropertiesTest</code> contains tests for the all property class</code>.
53 @SuppressWarnings("nls")
54 public class TraceControlPropertiesTest
extends TestCase
{
56 // ------------------------------------------------------------------------
58 // ------------------------------------------------------------------------
60 // ------------------------------------------------------------------------
62 // ------------------------------------------------------------------------
65 * Returns test setup used when executing test case stand-alone.
66 * @return Test setup class
68 public static Test
suite() {
69 return new ModelImplTestSetup(new TestSuite(TraceControlPropertiesTest
.class));
72 // ------------------------------------------------------------------------
74 // ------------------------------------------------------------------------
77 * Perform pre-test initialization.
80 * if the initialization fails for some reason
85 public void setUp() throws Exception
{
89 * Perform post-test clean-up.
92 * if the clean-up fails for some reason
97 public void tearDown() throws Exception
{
101 * Run the TraceControlComponent.
103 public void testTraceControlComponents()
106 TestRemoteSystemProxy proxy
= new TestRemoteSystemProxy();
108 ITraceControlComponent root
= TraceControlTestFacility
.getInstance().getControlView().getTraceControlRoot();
110 @SuppressWarnings("restriction")
111 IHost host
= new Host(new SystemProfile("myProfile", true));
112 host
.setHostName("127.0.0.1");
114 TargetNodeComponent node
= new TargetNodeComponent("myNode", root
, host
, proxy
);
119 TraceControlTestFacility
.getInstance().waitForJobs();
121 // ------------------------------------------------------------------------
122 // Verify Node Properties (adapter)
123 // ------------------------------------------------------------------------
124 Object adapter
= node
.getAdapter(IPropertySource
.class);
125 assertNotNull(adapter
);
126 assertTrue(adapter
instanceof TargetNodePropertySource
);
128 TargetNodePropertySource source
= (TargetNodePropertySource
)adapter
;
130 assertNull(source
.getEditableValue());
131 assertFalse(source
.isPropertySet(TargetNodePropertySource
.TARGET_NODE_NAME_PROPERTY_ID
));
132 assertNotNull(source
.getPropertyDescriptors());
134 assertEquals("myNode", source
.getPropertyValue(TargetNodePropertySource
.TARGET_NODE_NAME_PROPERTY_ID
));
135 assertEquals("127.0.0.1", source
.getPropertyValue(TargetNodePropertySource
.TARGET_NODE_ADDRESS_PROPERTY_ID
));
136 assertEquals(TargetNodeState
.CONNECTED
.name(), source
.getPropertyValue(TargetNodePropertySource
.TARGET_NODE_STATE_PROPERTY_ID
));
137 assertNull(source
.getPropertyValue("test"));
139 adapter
= node
.getAdapter(IChannelInfo
.class);
142 ITraceControlComponent
[] groups
= node
.getChildren();
143 assertNotNull(groups
);
144 assertEquals(2, groups
.length
);
146 ITraceControlComponent
[] providers
= groups
[0].getChildren();
148 assertNotNull(providers
);
149 assertEquals(3, providers
.length
);
151 // ------------------------------------------------------------------------
152 // Verify Kernel Provider Properties (adapter)
153 // ------------------------------------------------------------------------
154 KernelProviderComponent kernelProvider
= (KernelProviderComponent
) providers
[0];
156 adapter
= kernelProvider
.getAdapter(IPropertySource
.class);
157 assertNotNull(adapter
);
158 assertTrue(adapter
instanceof KernelProviderPropertySource
);
160 KernelProviderPropertySource kernelSource
= (KernelProviderPropertySource
)adapter
;
161 assertNotNull(kernelSource
.getPropertyDescriptors());
163 assertEquals("Kernel", kernelSource
.getPropertyValue(KernelProviderPropertySource
.KERNEL_PROVIDER_NAME_PROPERTY_ID
));
165 // ------------------------------------------------------------------------
166 // Verify UST Provider Properties (adapter)
167 // ------------------------------------------------------------------------
168 UstProviderComponent ustProvider
= (UstProviderComponent
) providers
[1];
170 adapter
= ustProvider
.getAdapter(IPropertySource
.class);
171 assertNotNull(adapter
);
172 assertTrue(adapter
instanceof UstProviderPropertySource
);
174 UstProviderPropertySource ustSource
= (UstProviderPropertySource
)adapter
;
175 assertNotNull(ustSource
.getPropertyDescriptors());
177 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", ustSource
.getPropertyValue(UstProviderPropertySource
.UST_PROVIDER_NAME_PROPERTY_ID
));
178 assertEquals(String
.valueOf(9379), ustSource
.getPropertyValue(UstProviderPropertySource
.UST_PROVIDER_PID_PROPERTY_ID
));
180 // ------------------------------------------------------------------------
181 // Verify Base Event Properties (adapter)
182 // ------------------------------------------------------------------------
183 ITraceControlComponent
[] events
= ustProvider
.getChildren();
184 assertNotNull(events
);
185 assertEquals(2, events
.length
);
187 BaseEventComponent baseEventInfo
= (BaseEventComponent
) events
[0];
188 assertNotNull(baseEventInfo
);
190 adapter
= baseEventInfo
.getAdapter(IPropertySource
.class);
191 assertNotNull(adapter
);
192 assertTrue(adapter
instanceof BaseEventPropertySource
);
194 BaseEventPropertySource baseSource
= (BaseEventPropertySource
)adapter
;
195 assertNotNull(baseSource
.getPropertyDescriptors());
197 assertEquals("ust_tests_hello:tptest_sighandler", baseSource
.getPropertyValue(BaseEventPropertySource
.BASE_EVENT_NAME_PROPERTY_ID
));
198 assertEquals(TraceEventType
.TRACEPOINT
.name(), baseSource
.getPropertyValue(BaseEventPropertySource
.BASE_EVENT_TYPE_PROPERTY_ID
));
199 assertEquals(TraceLogLevel
.TRACE_DEBUG_MODULE
.name(), baseSource
.getPropertyValue(BaseEventPropertySource
.BASE_EVENT_LOGLEVEL_PROPERTY_ID
));
201 // ------------------------------------------------------------------------
202 // Verify Session Properties (adapter)
203 // ------------------------------------------------------------------------
204 ITraceControlComponent
[] sessions
= groups
[1].getChildren();
205 assertNotNull(sessions
);
206 assertEquals(2, sessions
.length
);
208 TraceSessionComponent session
= (TraceSessionComponent
)sessions
[1];
210 adapter
= session
.getAdapter(IPropertySource
.class);
211 assertNotNull(adapter
);
212 assertTrue(adapter
instanceof TraceSessionPropertySource
);
214 TraceSessionPropertySource sessionSource
= (TraceSessionPropertySource
)adapter
;
215 assertNotNull(sessionSource
.getPropertyDescriptors());
217 assertEquals("mysession", sessionSource
.getPropertyValue(TraceSessionPropertySource
.TRACE_SESSION_NAME_PROPERTY_ID
));
218 assertEquals("/home/user/lttng-traces/mysession-20120129-084256", sessionSource
.getPropertyValue(TraceSessionPropertySource
.TRACE_SESSION_PATH_PROPERTY_ID
));
219 assertEquals(TraceSessionState
.ACTIVE
.name(), sessionSource
.getPropertyValue(TraceSessionPropertySource
.TRACE_SESSION_STATE_PROPERTY_ID
));
221 // ------------------------------------------------------------------------
222 // Verify Domain Provider Properties (adapter)
223 // ------------------------------------------------------------------------
224 ITraceControlComponent
[] domains
= session
.getChildren();
225 assertNotNull(domains
);
226 assertEquals(2, domains
.length
);
228 TraceDomainComponent domain
= (TraceDomainComponent
) domains
[0];
229 adapter
= domain
.getAdapter(IPropertySource
.class);
230 assertNotNull(adapter
);
231 assertTrue(adapter
instanceof TraceDomainPropertySource
);
233 TraceDomainPropertySource domainSource
= (TraceDomainPropertySource
)adapter
;
234 assertNotNull(domainSource
.getPropertyDescriptors());
236 assertEquals("Kernel", domainSource
.getPropertyValue(TraceDomainPropertySource
.TRACE_DOMAIN_NAME_PROPERTY_ID
));
238 ITraceControlComponent
[] channels
= domains
[0].getChildren();
239 assertNotNull(channels
);
240 assertEquals(2, channels
.length
);
242 // ------------------------------------------------------------------------
243 // Verify Channel Properties (adapter)
244 // ------------------------------------------------------------------------
245 assertTrue(channels
[0] instanceof TraceChannelComponent
);
246 TraceChannelComponent channel
= (TraceChannelComponent
) channels
[0];
248 adapter
= channel
.getAdapter(IPropertySource
.class);
249 assertNotNull(adapter
);
250 assertTrue(adapter
instanceof TraceChannelPropertySource
);
252 TraceChannelPropertySource channelSource
= (TraceChannelPropertySource
)adapter
;
253 assertNotNull(channelSource
.getPropertyDescriptors());
255 assertEquals("channel0", channelSource
.getPropertyValue(TraceChannelPropertySource
.TRACE_CHANNEL_NAME_PROPERTY_ID
));
256 assertEquals(String
.valueOf(4), channelSource
.getPropertyValue(TraceChannelPropertySource
.TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_ID
));
257 assertEquals(TraceEnablement
.ENABLED
.name(), channelSource
.getPropertyValue(TraceChannelPropertySource
.TRACE_CHANNEL_STATE_PROPERTY_ID
));
258 assertEquals(String
.valueOf(false), channelSource
.getPropertyValue(TraceChannelPropertySource
.TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_ID
));
259 assertEquals("splice()", channelSource
.getPropertyValue(TraceChannelPropertySource
.TRACE_CHANNEL_OUTPUT_TYPE_PROPERTY_ID
));
260 assertEquals(String
.valueOf(200), channelSource
.getPropertyValue(TraceChannelPropertySource
.TRACE_CHANNEL_READ_TIMER_PROPERTY_ID
));
261 assertEquals(String
.valueOf(262144), channelSource
.getPropertyValue(TraceChannelPropertySource
.TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_ID
));
262 assertEquals(String
.valueOf(0), channelSource
.getPropertyValue(TraceChannelPropertySource
.TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_ID
));
264 // ------------------------------------------------------------------------
265 // Verify Event Properties (adapter)
266 // ------------------------------------------------------------------------
267 ITraceControlComponent
[] channel0Events
= channel
.getChildren();
268 assertNotNull(channel0Events
);
269 assertEquals(2, channel0Events
.length
);
270 assertTrue(channel0Events
[0] instanceof TraceEventComponent
);
272 TraceEventComponent event
= (TraceEventComponent
) channel0Events
[0];
274 adapter
= event
.getAdapter(IPropertySource
.class);
275 assertNotNull(adapter
);
276 assertTrue(adapter
instanceof TraceEventPropertySource
);
278 TraceEventPropertySource eventSource
= (TraceEventPropertySource
)adapter
;
279 assertNotNull(eventSource
.getPropertyDescriptors());
281 assertEquals("block_rq_remap", eventSource
.getPropertyValue(TraceEventPropertySource
.TRACE_EVENT_NAME_PROPERTY_ID
));
282 assertEquals(TraceLogLevel
.TRACE_EMERG
.name(), eventSource
.getPropertyValue(TraceEventPropertySource
.TRACE_EVENT_LOGLEVEL_PROPERTY_ID
));
283 assertEquals(TraceEventType
.TRACEPOINT
.name(), eventSource
.getPropertyValue(TraceEventPropertySource
.TRACE_EVENT_TYPE_PROPERTY_ID
));
284 assertEquals(TraceEnablement
.ENABLED
.name(), eventSource
.getPropertyValue(TraceEventPropertySource
.TRACE_EVENT_STATE_PROPERTY_ID
));