//$JUnit-BEGIN$
suite.addTestSuite(TraceControlComponentTest.class);
suite.addTestSuite(TraceControlTreeModelTest.class);
+ suite.addTestSuite(TraceControlProviderTests.class);
suite.addTestSuite(TraceControlPropertiesTest.class);
//$JUnit-END$
return new ModelImplTestSetup(suite);
**********************************************************************/
package org.eclipse.linuxtools.lttng.ui.tests.control.model.component;
+import java.io.File;
+import java.net.URL;
+
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
import org.eclipse.linuxtools.lttng.stubs.service.TestRemoteSystemProxy;
+import org.eclipse.linuxtools.lttng.ui.tests.LTTngUITestPlugin;
import org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceControlComponent;
import org.eclipse.linuxtools.lttng.ui.views.control.model.TargetNodeState;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceChannelComponent;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceDomainComponent;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceEventComponent;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceProbeEventComponent;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.UstProviderComponent;
import org.eclipse.linuxtools.lttng.ui.views.control.property.BaseEventPropertySource;
import org.eclipse.linuxtools.lttng.ui.views.control.property.TraceChannelPropertySource;
import org.eclipse.linuxtools.lttng.ui.views.control.property.TraceDomainPropertySource;
import org.eclipse.linuxtools.lttng.ui.views.control.property.TraceEventPropertySource;
+import org.eclipse.linuxtools.lttng.ui.views.control.property.TraceProbeEventPropertySource;
import org.eclipse.linuxtools.lttng.ui.views.control.property.TraceSessionPropertySource;
import org.eclipse.linuxtools.lttng.ui.views.control.property.UstProviderPropertySource;
import org.eclipse.rse.core.model.Host;
*/
@SuppressWarnings("nls")
public class TraceControlPropertiesTest extends TestCase {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ private static final String DIRECTORY = "testfiles";
+ private static final String TEST_STREAM = "ListInfoTest.cfg";
+ private static final String SCEN_LIST_INFO_TEST = "ListInfoTest";
+
// ------------------------------------------------------------------------
// Test data
TestRemoteSystemProxy proxy = new TestRemoteSystemProxy();
+ URL location = FileLocator.find(LTTngUITestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
+ File testfile = new File(FileLocator.toFileURL(location).toURI());
+ proxy.setTestFile(testfile.getAbsolutePath());
+ proxy.setScenario(SCEN_LIST_INFO_TEST);
+
ITraceControlComponent root = TraceControlTestFacility.getInstance().getControlView().getTraceControlRoot();
@SuppressWarnings("restriction")
// ------------------------------------------------------------------------
ITraceControlComponent[] channel0Events = channel.getChildren();
assertNotNull(channel0Events);
- assertEquals(2, channel0Events.length);
+ assertEquals(5, channel0Events.length);
assertTrue(channel0Events[0] instanceof TraceEventComponent);
TraceEventComponent event = (TraceEventComponent) channel0Events[0];
assertEquals(TraceLogLevel.TRACE_EMERG.name(), eventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_LOGLEVEL_PROPERTY_ID));
assertEquals(TraceEventType.TRACEPOINT.name(), eventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_TYPE_PROPERTY_ID));
assertEquals(TraceEnablement.ENABLED.name(), eventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_STATE_PROPERTY_ID));
+
+ // ------------------------------------------------------------------------
+ // Verify Probe Event Properties (adapter)
+ // ------------------------------------------------------------------------
+ assertTrue(channel0Events[2] instanceof TraceProbeEventComponent);
+
+ TraceProbeEventComponent probeEvent = (TraceProbeEventComponent) channel0Events[2];
+
+ adapter = probeEvent.getAdapter(IPropertySource.class);
+ assertNotNull(adapter);
+ assertTrue(adapter instanceof TraceProbeEventPropertySource);
+
+ TraceProbeEventPropertySource probeEventSource = (TraceProbeEventPropertySource)adapter;
+ assertNotNull(probeEventSource.getPropertyDescriptors());
+ assertEquals(4, probeEventSource.getPropertyDescriptors().length);
+
+ assertEquals("myevent2", probeEventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_NAME_PROPERTY_ID));
+ assertEquals(TraceEventType.PROBE.name(), probeEventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_TYPE_PROPERTY_ID));
+ assertEquals(TraceEnablement.ENABLED.name(), probeEventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_STATE_PROPERTY_ID));
+ assertEquals("0xc0101340", probeEventSource.getPropertyValue(TraceProbeEventPropertySource.TRACE_EVENT_PROBE_ADDRESS_PROPERTY_ID));
+
+ assertTrue(channel0Events[3] instanceof TraceProbeEventComponent);
+
+ probeEvent = (TraceProbeEventComponent) channel0Events[3];
+
+ adapter = probeEvent.getAdapter(IPropertySource.class);
+ assertNotNull(adapter);
+ assertTrue(adapter instanceof TraceProbeEventPropertySource);
+
+ probeEventSource = (TraceProbeEventPropertySource)adapter;
+ assertNotNull(probeEventSource.getPropertyDescriptors());
+ assertEquals(5, probeEventSource.getPropertyDescriptors().length);
+
+ assertEquals("myevent0", probeEventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_NAME_PROPERTY_ID));
+ assertEquals(TraceEventType.PROBE.name(), probeEventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_TYPE_PROPERTY_ID));
+ assertEquals(TraceEnablement.ENABLED.name(), probeEventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_STATE_PROPERTY_ID));
+ assertEquals("0x0", probeEventSource.getPropertyValue(TraceProbeEventPropertySource.TRACE_EVENT_PROBE_OFFSET_PROPERTY_ID));
+ assertEquals("init_post", probeEventSource.getPropertyValue(TraceProbeEventPropertySource.TRACE_EVENT_PROBE_SYMBOL_PROPERTY_ID));
+
}
}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng.ui.tests.control.model.component;
+
+import java.io.File;
+import java.net.URL;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.NotEnabledException;
+import org.eclipse.core.commands.NotHandledException;
+import org.eclipse.core.commands.common.NotDefinedException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.linuxtools.lttng.stubs.service.TestRemoteSystemProxy;
+import org.eclipse.linuxtools.lttng.ui.tests.LTTngUITestPlugin;
+import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.IConfirmDialog;
+import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.ICreateChannelOnSessionDialog;
+import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.ICreateSessionDialog;
+import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.IGetEventInfoDialog;
+import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.TraceControlDialogFactory;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceControlComponent;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.TargetNodeState;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceEnablement;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceEventType;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceLogLevel;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceSessionState;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.BaseEventComponent;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.ChannelInfo;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.KernelProviderComponent;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TargetNodeComponent;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceChannelComponent;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceDomainComponent;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceEventComponent;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionGroup;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.UstProviderComponent;
+import org.eclipse.rse.core.model.Host;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.rse.internal.core.model.SystemProfile;
+import org.eclipse.swt.widgets.Shell;
+import org.junit.After;
+import org.junit.Before;
+
+/**
+ * The class <code>TraceControlTreeModelTest</code> contains tests for the tree component classes.
+ */
+@SuppressWarnings("nls")
+public class TraceControlProviderTests extends TestCase {
+
+ private static final String DIRECTORY = "testfiles";
+ private static final String TEST_STREAM = "CreateTreeTest.cfg";
+ private static final String SCEN_INIT_TEST = "Initialize";
+ private static final String SCEN_SCENARIO1_TEST = "Scenario1";
+ private static final String SCEN_SCENARIO2_TEST = "Scenario2";
+
+ // ------------------------------------------------------------------------
+ // Test data
+ // ------------------------------------------------------------------------
+ private TraceControlTestFacility fFacility;
+ private TestRemoteSystemProxy fProxy;
+ private String fTestFile;
+
+ // ------------------------------------------------------------------------
+ // Static methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Returns test setup used when executing test case stand-alone.
+ * @return Test setup class
+ */
+ public static Test suite() {
+ return new ModelImplTestSetup(new TestSuite(TraceControlProviderTests.class));
+ }
+
+ // ------------------------------------------------------------------------
+ // Housekeeping
+ // ------------------------------------------------------------------------
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception
+ * if the initialization fails for some reason
+ *
+ */
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ fFacility = TraceControlTestFacility.getInstance();
+ fProxy = new TestRemoteSystemProxy();
+ URL location = FileLocator.find(LTTngUITestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
+ File testfile = new File(FileLocator.toFileURL(location).toURI());
+ fTestFile = testfile.getAbsolutePath();
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception
+ * if the clean-up fails for some reason
+ *
+ */
+ @Override
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ /**
+ * Run the TraceControlComponent.
+ */
+ public void testTraceControlComponents()
+ throws Exception {
+
+ fProxy.setTestFile(fTestFile);
+ fProxy.setScenario(SCEN_INIT_TEST);
+
+ ITraceControlComponent root = TraceControlTestFacility.getInstance().getControlView().getTraceControlRoot();
+
+ @SuppressWarnings("restriction")
+ IHost host = new Host(new SystemProfile("myProfile", true));
+ host.setHostName("127.0.0.1");
+
+ TargetNodeComponent node = new TargetNodeComponent("myNode", root, host, fProxy);
+
+ root.addChild(node);
+ node.connect();
+
+ fFacility.waitForJobs();
+
+ // Verify that node is connected
+ assertEquals(TargetNodeState.CONNECTED, node.getTargetNodeState());
+
+ // Get provider groups
+ ITraceControlComponent[] groups = node.getChildren();
+ assertNotNull(groups);
+ assertEquals(2, groups.length);
+
+ // Get kernel provider
+ ITraceControlComponent[] providers = groups[0].getChildren();
+ KernelProviderComponent kernelProvider = (KernelProviderComponent) providers[0];
+
+ // Get kernel provider events and select 2 events
+ ITraceControlComponent[] events = kernelProvider.getChildren();
+ assertNotNull(events);
+ assertEquals(3, events.length);
+
+ BaseEventComponent baseEventInfo0 = (BaseEventComponent) events[0];
+ BaseEventComponent baseEventInfo1 = (BaseEventComponent) events[1];
+
+ // Initialize dialog implementations for command execution
+ TraceControlDialogFactory.getInstance().setCreateSessionDialog(new CreateSessionDialogStub());
+ TraceControlDialogFactory.getInstance().setGetEventInfoDialog(new GetEventInfoDialogStub());
+ TraceControlDialogFactory.getInstance().setConfirmDialog(new DestroyConfirmDialogStub());
+
+ // Initialize scenario
+ fProxy.setScenario(SCEN_SCENARIO1_TEST);
+
+ // ------------------------------------------------------------------------
+ // Create session
+ // ------------------------------------------------------------------------
+ TraceSessionComponent session = createSession(groups[1]);
+
+ // Verify that session was created
+ assertNotNull(session);
+ assertEquals("mysession", session.getName());
+ assertEquals("/home/user/lttng-traces/mysession-20120314-132824", session.getSessionPath());
+ assertEquals(TraceSessionState.INACTIVE, session.getSessionState());
+
+ // ------------------------------------------------------------------------
+ // Enable event on default channel on created session above
+ // ------------------------------------------------------------------------
+ ITraceControlComponent[] components = { baseEventInfo0, baseEventInfo1 };
+
+ fFacility.getControlView().setSelection(components);
+ // Give GUI time to actually execute refresh
+ fFacility.delay(TraceControlTestFacility.GUI_REFESH_DELAY);
+
+ fFacility.executeCommand("assign.event");
+ fFacility.waitForJobs();
+
+ // Verify that kernel domain was created
+ ITraceControlComponent[] domains = session.getChildren();
+ assertNotNull(domains);
+ assertEquals(1, domains.length);
+
+ assertEquals("Kernel", domains[0].getName());
+
+ // Verify that channel0 was created with default values
+ ITraceControlComponent[] channels = domains[0].getChildren();
+ assertNotNull(channels);
+ assertEquals(1, channels.length);
+
+ assertTrue(channels[0] instanceof TraceChannelComponent);
+ TraceChannelComponent channel = (TraceChannelComponent) channels[0];
+ assertEquals("channel0", channel.getName());
+ assertEquals(4, channel.getNumberOfSubBuffers());
+ assertEquals("splice()", channel.getOutputType());
+ assertEquals(false, channel.isOverwriteMode());
+ assertEquals(200, channel.getReadTimer());
+ assertEquals(TraceEnablement.ENABLED, channel.getState());
+ assertEquals(262144, channel.getSubBufferSize());
+ assertEquals(0, channel.getSwitchTimer());
+
+ // Verify that event components were created
+ ITraceControlComponent[] channel0Events = channel.getChildren();
+ assertNotNull(channel0Events);
+ assertEquals(2, channel0Events.length);
+ assertTrue(channel0Events[0] instanceof TraceEventComponent);
+ assertTrue(channel0Events[1] instanceof TraceEventComponent);
+
+ TraceEventComponent event = (TraceEventComponent) channel0Events[0];
+ assertEquals("sched_kthread_stop_ret", event.getName());
+ assertEquals(TraceLogLevel.TRACE_EMERG, event.getLogLevel());
+ assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
+ assertEquals(TraceEnablement.ENABLED, event.getState());
+
+ TraceEventComponent event1 = (TraceEventComponent) channel0Events[1];
+ assertEquals("sched_kthread_stop", event1.getName());
+ assertEquals(TraceLogLevel.TRACE_EMERG, event1.getLogLevel());
+ assertEquals(TraceEventType.TRACEPOINT, event1.getEventType());
+ assertEquals(TraceEnablement.ENABLED, event1.getState());
+
+ // ------------------------------------------------------------------------
+ // Disable event components
+ // ------------------------------------------------------------------------
+ ITraceControlComponent[] selection = { event, event1 };
+ fFacility.getControlView().setSelection(selection);
+ // Give GUI time to actually execute the selection
+ fFacility.delay(TraceControlTestFacility.GUI_REFESH_DELAY);
+ fFacility.executeCommand("disable.event");
+ fFacility.waitForJobs();
+
+ assertEquals(TraceEnablement.DISABLED, event.getState());
+ assertEquals(TraceEnablement.DISABLED, event1.getState());
+
+ // ------------------------------------------------------------------------
+ // Enable event component
+ // ------------------------------------------------------------------------
+ fFacility.getControlView().setSelection(event1);
+ fFacility.executeCommand("enable.event");
+ fFacility.waitForJobs();
+
+ // Verify event state
+ assertEquals(TraceEnablement.ENABLED, event1.getState());
+
+ // ------------------------------------------------------------------------
+ // Destroy session
+ // ------------------------------------------------------------------------
+ destroySession(session);
+
+ // Verify that no more session components exist
+ assertEquals(0, groups[1].getChildren().length);
+
+
+ // ------------------------------------------------------------------------
+ // Create session
+ // ------------------------------------------------------------------------
+ fProxy.setScenario(SCEN_SCENARIO2_TEST);
+
+ CreateSessionDialogStub sessionDialogStub = new CreateSessionDialogStub();
+ sessionDialogStub.setSessionPath("/home/user/temp");
+ TraceControlDialogFactory.getInstance().setCreateSessionDialog(sessionDialogStub);
+
+ session = createSession(groups[1]);
+
+ // Verify that session was created
+ assertNotNull(session);
+ assertEquals("mysession", session.getName());
+ assertEquals("/home/user/temp", session.getSessionPath());
+ assertEquals(TraceSessionState.INACTIVE, session.getSessionState());
+
+ // ------------------------------------------------------------------------
+ // Create Channel on UST global domain
+ // ------------------------------------------------------------------------
+ TraceControlDialogFactory.getInstance().setCreateChannelOnSessionDialog(new CreateChannelOnSessionDialogStub());
+
+ fFacility.getControlView().setSelection(session);
+ // Give GUI time to actually execute refresh
+ fFacility.delay(TraceControlTestFacility.GUI_REFESH_DELAY);
+
+ fFacility.executeCommand("createChannelOnSession");
+ fFacility.waitForJobs();
+
+ // Verify that UST domain was created
+ domains = session.getChildren();
+ assertNotNull(domains);
+ assertEquals(1, domains.length);
+
+ assertEquals("UST global", domains[0].getName());
+
+ // Verify that channel was created with correct data
+ channels = domains[0].getChildren();
+ assertNotNull(channels);
+ assertEquals(1, channels.length);
+
+ assertTrue(channels[0] instanceof TraceChannelComponent);
+ channel = (TraceChannelComponent) channels[0];
+ assertEquals("mychannel", channel.getName());
+ assertEquals(2, channel.getNumberOfSubBuffers());
+ assertEquals("mmap()", channel.getOutputType());
+ assertEquals(false, channel.isOverwriteMode());
+ assertEquals(100, channel.getReadTimer());
+ assertEquals(TraceEnablement.ENABLED, channel.getState());
+ assertEquals(16384, channel.getSubBufferSize());
+ assertEquals(200, channel.getSwitchTimer());
+
+ // ------------------------------------------------------------------------
+ // Enable event on default channel on created session above
+ // ------------------------------------------------------------------------
+ // Get first UST provider
+ UstProviderComponent ustProvider = (UstProviderComponent) providers[1];
+ assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", ustProvider.getName());
+ assertEquals(9379, ustProvider.getPid());
+
+ // Get events
+ events = ustProvider.getChildren();
+ assertNotNull(events);
+ assertEquals(2, events.length);
+
+ baseEventInfo0 = (BaseEventComponent) events[0];
+ baseEventInfo1 = (BaseEventComponent) events[1];
+
+ ITraceControlComponent[] ustSelection = { baseEventInfo0, baseEventInfo1 };
+
+ fFacility.getControlView().setSelection(ustSelection);
+ // Give GUI time to actually execute refresh
+ fFacility.delay(TraceControlTestFacility.GUI_REFESH_DELAY);
+ fFacility.executeCommand("assign.event");
+ fFacility.waitForJobs();
+
+ // verify that events were created under the channel
+ // Note that domain and channel has to be re-read because the tree is re-created
+
+ domains = session.getChildren();
+
+ // Verify that channel was created with correct data
+ channels = domains[0].getChildren();
+
+ ITraceControlComponent[] ustEvents = channels[0].getChildren();
+ assertEquals(2, ustEvents.length);
+
+ event = (TraceEventComponent) ustEvents[0];
+ assertEquals("ust_tests_hello:tptest_sighandler", event.getName());
+ assertEquals(TraceLogLevel.TRACE_DEBUG_LINE, event.getLogLevel());
+ assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
+ assertEquals(TraceEnablement.ENABLED, event.getState());
+
+ event = (TraceEventComponent) ustEvents[1];
+ assertEquals("ust_tests_hello:tptest", ustEvents[1].getName());
+ assertEquals(TraceLogLevel.TRACE_DEBUG_LINE, event.getLogLevel());
+ assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
+ assertEquals(TraceEnablement.ENABLED, event.getState());
+
+ // ------------------------------------------------------------------------
+ // Disable event components
+ // ------------------------------------------------------------------------
+ fFacility.getControlView().setSelection(event);
+ // Give GUI time to actually execute the selection
+ fFacility.delay(TraceControlTestFacility.GUI_REFESH_DELAY);
+ fFacility.executeCommand("disable.event");
+ fFacility.waitForJobs();
+
+ assertEquals(TraceEnablement.DISABLED, event.getState());
+
+ // ------------------------------------------------------------------------
+ // Enable event component
+ // ------------------------------------------------------------------------
+ fFacility.getControlView().setSelection(event);
+ fFacility.executeCommand("enable.event");
+ fFacility.waitForJobs();
+
+ // Verify event state
+ assertEquals(TraceEnablement.ENABLED, event.getState());
+
+ // ------------------------------------------------------------------------
+ // Destroy session
+ // ------------------------------------------------------------------------
+ destroySession(session);
+
+ // Verify that no more session components exist
+ assertEquals(0, groups[1].getChildren().length);
+
+
+// fFacility.delay(60000);
+ }
+
+ private TraceSessionComponent createSession(ITraceControlComponent group) throws ExecutionException, NotDefinedException, NotEnabledException, NotHandledException {
+ fFacility.getControlView().setSelection(group);
+ // Give GUI time to actually execute the selection
+ fFacility.delay(TraceControlTestFacility.GUI_REFESH_DELAY);
+ fFacility.executeCommand("createSession");
+ fFacility.waitForJobs();
+
+ ITraceControlComponent[] sessions = group.getChildren();
+ if ((sessions == null) || (sessions.length == 0)) {
+ return null;
+ }
+ return (TraceSessionComponent)sessions[0];
+ }
+
+ private void destroySession(TraceSessionComponent session) throws ExecutionException, NotDefinedException, NotEnabledException, NotHandledException {
+ fFacility.getControlView().setSelection(session);
+ // Give GUI time to actually execute the selection
+ fFacility.delay(TraceControlTestFacility.GUI_REFESH_DELAY);
+ fFacility.executeCommand("destroySession");
+ fFacility.waitForJobs();
+ }
+
+// assertEquals("sched_kthread_stop_ret", baseEventInfo.getName());
+// assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel());
+// assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
+//
+// baseEventInfo = (BaseEventComponent) events[2];
+// assertEquals("sched_wakeup_new", baseEventInfo.getName());
+// assertEquals(TraceLogLevel.TRACE_EMERG, baseEventInfo.getLogLevel());
+// assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
+//
+// // ------------------------------------------------------------------------
+// // Verify UstProviderComponent
+// // ------------------------------------------------------------------------
+// UstProviderComponent ustProvider = (UstProviderComponent) providers[1];
+// assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", ustProvider.getName());
+// assertEquals(9379, ustProvider.getPid());
+//
+// // ------------------------------------------------------------------------
+// // Verify event info (UST provider)
+// // ------------------------------------------------------------------------
+// events = ustProvider.getChildren();
+// assertNotNull(events);
+// assertEquals(2, events.length);
+//
+// baseEventInfo = (BaseEventComponent) events[0];
+// assertNotNull(baseEventInfo);
+// assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo.getName());
+// assertEquals(TraceLogLevel.TRACE_DEBUG_MODULE, baseEventInfo.getLogLevel());
+// assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
+//
+// baseEventInfo = (BaseEventComponent) events[1];
+// assertEquals("ust_tests_hello:tptest", baseEventInfo.getName());
+// assertEquals(TraceLogLevel.TRACE_INFO, baseEventInfo.getLogLevel());
+// assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
+//
+// // ------------------------------------------------------------------------
+// // Verify UstProviderComponent
+// // ------------------------------------------------------------------------
+// ustProvider = (UstProviderComponent) providers[2];
+// assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", ustProvider.getName());
+// assertEquals(4852, ustProvider.getPid());
+//
+// // verify getters and setter
+// verifyUstProviderGettersSetters(ustProvider);
+//
+// // ------------------------------------------------------------------------
+// // Verify event info (UST provider)
+// // ------------------------------------------------------------------------
+// events = ustProvider.getChildren();
+// assertNotNull(events);
+// assertEquals(2, events.length);
+//
+// baseEventInfo = (BaseEventComponent) events[0];
+// assertNotNull(baseEventInfo);
+// assertEquals("ust_tests_hello:tptest_sighandler", baseEventInfo.getName());
+// assertEquals(TraceLogLevel.TRACE_WARNING, baseEventInfo.getLogLevel());
+// assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
+//
+// baseEventInfo = (BaseEventComponent) events[1];
+// assertEquals("ust_tests_hello:tptest", baseEventInfo.getName());
+// assertEquals(TraceLogLevel.TRACE_DEBUG_FUNCTION, baseEventInfo.getLogLevel());
+// assertEquals(TraceEventType.TRACEPOINT, baseEventInfo.getEventType());
+//
+// // verify getters and setters
+// verifyBaseEventGettersSetters(baseEventInfo);
+//
+// // ------------------------------------------------------------------------
+// // Verify TraceSessionGroup
+// // ------------------------------------------------------------------------
+// ITraceControlComponent[] sessions = groups[1].getChildren();
+// assertNotNull(sessions);
+// assertEquals(2, sessions.length);
+// for (int i = 0; i < sessions.length; i++) {
+// assertTrue(sessions[i] instanceof TraceSessionComponent);
+// }
+// assertEquals("mysession1", sessions[0].getName());
+// assertEquals("mysession", sessions[1].getName());
+//
+// // ------------------------------------------------------------------------
+// // Verify TraceSessionComponent
+// // ------------------------------------------------------------------------
+// TraceSessionComponent session = (TraceSessionComponent)sessions[1];
+// assertEquals("mysession", session.getName());
+// assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session.getSessionPath());
+// assertEquals(TraceSessionState.ACTIVE, session.getSessionState());
+//
+// // Verify setters and setters
+// verifySessionGetterSetters(session);
+//
+// ITraceControlComponent[] domains = session.getChildren();
+// assertNotNull(domains);
+// assertEquals(2, domains.length);
+//
+// // ------------------------------------------------------------------------
+// // Verify Kernel domain
+// // ------------------------------------------------------------------------
+// assertEquals("Kernel", domains[0].getName());
+// ITraceControlComponent[] channels = domains[0].getChildren();
+// assertNotNull(channels);
+// assertEquals(2, channels.length);
+//
+// // ------------------------------------------------------------------------
+// // Verify Kernel's channel0
+// // ------------------------------------------------------------------------
+// assertTrue(channels[0] instanceof TraceChannelComponent);
+// TraceChannelComponent channel = (TraceChannelComponent) channels[0];
+// assertEquals("channel0", channel.getName());
+// assertEquals(4, channel.getNumberOfSubBuffers());
+// assertEquals("splice()", channel.getOutputType());
+// assertEquals(false, channel.isOverwriteMode());
+// assertEquals(200, channel.getReadTimer());
+// assertEquals(TraceEnablement.ENABLED, channel.getState());
+// assertEquals(262144, channel.getSubBufferSize());
+// assertEquals(0, channel.getSwitchTimer());
+//
+// // ------------------------------------------------------------------------
+// // Verify event info (kernel, channel0)
+// // ------------------------------------------------------------------------
+// ITraceControlComponent[] channel0Events = channel.getChildren();
+// assertNotNull(channel0Events);
+// assertEquals(5, channel0Events.length);
+// assertTrue(channel0Events[0] instanceof TraceEventComponent);
+// assertTrue(channel0Events[1] instanceof TraceEventComponent);
+// assertTrue(channel0Events[2] instanceof TraceProbeEventComponent);
+// assertTrue(channel0Events[3] instanceof TraceProbeEventComponent);
+// assertTrue(channel0Events[4] instanceof TraceEventComponent);
+//
+// TraceEventComponent event = (TraceEventComponent) channel0Events[0];
+// assertEquals("block_rq_remap", event.getName());
+// assertEquals(TraceLogLevel.TRACE_EMERG, event.getLogLevel());
+// assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
+// assertEquals(TraceEnablement.ENABLED, event.getState());
+//
+// event = (TraceEventComponent) channel0Events[1];
+// assertEquals("block_bio_remap", event.getName());
+// assertEquals(TraceLogLevel.TRACE_EMERG, event.getLogLevel());
+// assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
+// assertEquals(TraceEnablement.DISABLED, event.getState());
+//
+// TraceProbeEventComponent probeEvent = (TraceProbeEventComponent) channel0Events[2];
+// assertEquals("myevent2", probeEvent.getName());
+// assertEquals(TraceLogLevel.LEVEL_UNKNOWN, probeEvent.getLogLevel());
+// assertEquals(TraceEventType.PROBE, probeEvent.getEventType());
+// assertEquals(TraceEnablement.ENABLED, probeEvent.getState());
+// assertEquals("0xc0101340", probeEvent.getAddress());
+// assertNull(probeEvent.getOffset());
+// assertNull(probeEvent.getSymbol());
+//
+// probeEvent = (TraceProbeEventComponent) channel0Events[3];
+// assertEquals("myevent0", probeEvent.getName());
+// assertEquals(TraceLogLevel.LEVEL_UNKNOWN, probeEvent.getLogLevel());
+// assertEquals(TraceEventType.PROBE, probeEvent.getEventType());
+// assertEquals(TraceEnablement.ENABLED, probeEvent.getState());
+// assertNull(probeEvent.getAddress());
+// assertEquals("0x0", probeEvent.getOffset());
+// assertEquals("init_post", probeEvent.getSymbol());
+//
+// event = (TraceEventComponent) channel0Events[4];
+// assertEquals("syscalls", event.getName());
+// assertEquals(TraceLogLevel.LEVEL_UNKNOWN, event.getLogLevel());
+// assertEquals(TraceEventType.SYSCALL, event.getEventType());
+// assertEquals(TraceEnablement.ENABLED, event.getState());
+//
+// // ------------------------------------------------------------------------
+// // Verify Kernel's channel1
+// // ------------------------------------------------------------------------
+// assertEquals("channel1", channels[1].getName());
+// channel = (TraceChannelComponent) channels[1];
+// assertEquals(4, channel.getNumberOfSubBuffers());
+// assertEquals("splice()", channel.getOutputType());
+// assertEquals(true, channel.isOverwriteMode());
+// assertEquals(400, channel.getReadTimer());
+// assertEquals(TraceEnablement.DISABLED, channel.getState());
+// assertEquals(524288, channel.getSubBufferSize());
+// assertEquals(100, channel.getSwitchTimer());
+//
+// // ------------------------------------------------------------------------
+// // Verify event info (kernel, channel1)
+// // ------------------------------------------------------------------------
+// ITraceControlComponent[] channel1Events = channels[1].getChildren();
+// assertEquals(0, channel1Events.length);
+//
+// // ------------------------------------------------------------------------
+// // Verify domain UST global
+// // ------------------------------------------------------------------------
+// assertEquals("UST global", domains[1].getName());
+//
+// ITraceControlComponent[] ustChannels = domains[1].getChildren();
+//
+// for (int i = 0; i < ustChannels.length; i++) {
+// assertTrue(ustChannels[i] instanceof TraceChannelComponent);
+// }
+//
+// // ------------------------------------------------------------------------
+// // Verify UST global's mychannel1
+// // ------------------------------------------------------------------------
+// channel = (TraceChannelComponent) ustChannels[0];
+// assertEquals("mychannel1", channel.getName());
+// assertEquals(8, channel.getNumberOfSubBuffers());
+// assertEquals("mmap()", channel.getOutputType());
+// assertEquals(true, channel.isOverwriteMode());
+// assertEquals(100, channel.getReadTimer());
+// assertEquals(TraceEnablement.DISABLED, channel.getState());
+// assertEquals(8192, channel.getSubBufferSize());
+// assertEquals(200, channel.getSwitchTimer());
+//
+// // verify getters and setters
+// verifyChannelGettersSetters(channel);
+//
+// // ------------------------------------------------------------------------
+// // Verify event info (UST global, mychannel1)
+// // ------------------------------------------------------------------------
+// ITraceControlComponent[] ustEvents = channel.getChildren();
+// assertEquals(0, ustEvents.length);
+//
+// // ------------------------------------------------------------------------
+// // Verify UST global's channel0
+// // ------------------------------------------------------------------------
+// channel = (TraceChannelComponent) ustChannels[1];
+// assertEquals("channel0", channel.getName());
+// assertEquals(4, channel.getNumberOfSubBuffers());
+// assertEquals("mmap()", channel.getOutputType());
+// assertEquals(false, channel.isOverwriteMode());
+// assertEquals(200, channel.getReadTimer());
+// assertEquals(TraceEnablement.ENABLED, channel.getState());
+// assertEquals(4096, channel.getSubBufferSize());
+// assertEquals(0, channel.getSwitchTimer());
+//
+// // ------------------------------------------------------------------------
+// // Verify event info (UST global, channel0)
+// // ------------------------------------------------------------------------
+// ustEvents = channel.getChildren();
+// assertEquals(2, ustEvents.length);
+//
+// event = (TraceEventComponent) ustEvents[0];
+// assertEquals("ust_tests_hello:tptest_sighandler", event.getName());
+// assertEquals(TraceLogLevel.TRACE_DEBUG_LINE, event.getLogLevel());
+// assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
+// assertEquals(TraceEnablement.DISABLED, event.getState());
+//
+// event = (TraceEventComponent) ustEvents[1];
+// assertEquals("*", ustEvents[1].getName());
+// assertEquals(TraceLogLevel.LEVEL_UNKNOWN, event.getLogLevel());
+// assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
+// assertEquals(TraceEnablement.ENABLED, event.getState());
+//
+// // verify getters and setters
+// verifyEventGettersSetters(event);
+//
+// // disconnect
+// node.disconnect();
+// assertEquals(TargetNodeState.DISCONNECTED, node.getTargetNodeState());
+// assertNotNull(node.getImage());
+// assertNotSame(connectedImage, node.getImage());
+// }
+//
+// private void verifySessionGetterSetters(TraceSessionComponent session) {
+// // save original values
+// String name = session.getName();
+// String origPath = session.getSessionPath();
+// TraceSessionState origState = session.getSessionState();
+//
+// // test cases
+// session.setName("newName");
+// assertEquals("newName", session.getName());
+//
+// session.setSessionPath("/home/user/tmp");
+// assertEquals("/home/user/tmp", session.getSessionPath());
+//
+// session.setSessionState(TraceSessionState.INACTIVE);
+// assertEquals(TraceSessionState.INACTIVE, session.getSessionState());
+// Image inactiveImage = session.getImage();
+// assertNotNull(inactiveImage);
+//
+// session.setSessionState("active");
+// assertEquals(TraceSessionState.ACTIVE, session.getSessionState());
+//
+// Image activeImage = session.getImage();
+// assertNotNull(activeImage);
+// assertNotSame(activeImage, inactiveImage);
+//
+//
+// // restore original values
+// session.setName(name);
+// session.setSessionPath(origPath);
+// session.setSessionState(origState);
+// }
+//
+// private void verifyBaseEventGettersSetters(BaseEventComponent event) {
+// // save original values
+// String name = event.getName();
+// TraceLogLevel level = event.getLogLevel();
+// TraceEventType type = event.getEventType();
+//
+// // test cases
+// event.setName("newName");
+// assertEquals("newName", event.getName());
+//
+// event.setLogLevel(TraceLogLevel.TRACE_INFO);
+// assertEquals(TraceLogLevel.TRACE_INFO, event.getLogLevel());
+// event.setLogLevel("TRACE_ALERT");
+// assertEquals(TraceLogLevel.TRACE_ALERT, event.getLogLevel());
+//
+// event.setEventType(TraceEventType.UNKNOWN);
+// assertEquals(TraceEventType.UNKNOWN, event.getEventType());
+// event.setEventType("tracepoint");
+// assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
+//
+// // restore original values
+// event.setName(name);
+// event.setLogLevel(level);
+// event.setEventType(type);
+// }
+//
+// private void verifyEventGettersSetters(TraceEventComponent event) {
+// // save original values
+// String name = event.getName();
+// TraceLogLevel level = event.getLogLevel();
+// TraceEventType type = event.getEventType();
+// TraceEnablement state = event.getState();
+//
+// // test cases
+// event.setName("newName");
+// assertEquals("newName", event.getName());
+//
+// event.setLogLevel(TraceLogLevel.TRACE_INFO);
+// assertEquals(TraceLogLevel.TRACE_INFO, event.getLogLevel());
+// event.setLogLevel("TRACE_ALERT");
+// assertEquals(TraceLogLevel.TRACE_ALERT, event.getLogLevel());
+//
+// event.setEventType(TraceEventType.UNKNOWN);
+// assertEquals(TraceEventType.UNKNOWN, event.getEventType());
+// event.setEventType("tracepoint");
+// assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
+//
+// event.setState("disabled");
+// assertEquals(TraceEnablement.DISABLED, event.getState());
+//
+// Image disabledImage = event.getImage();
+// assertNotNull(disabledImage);
+//
+// event.setState(TraceEnablement.ENABLED);
+// assertEquals(TraceEnablement.ENABLED, event.getState());
+//
+// Image enabledImage = event.getImage();
+// assertNotNull(enabledImage);
+// assertNotSame(enabledImage, disabledImage);
+//
+// // restore original values
+// event.setName(name);
+// event.setLogLevel(level);
+// event.setEventType(type);
+// event.setState(state);
+// }
+//
+// private void verifyChannelGettersSetters(TraceChannelComponent channel) {
+// // save original values
+// String name = channel.getName();
+// int nbSubBuffers = channel.getNumberOfSubBuffers();
+// String type = channel.getOutputType();
+// boolean mode = channel.isOverwriteMode();
+// long readTimer = channel.getReadTimer();
+// TraceEnablement state = channel.getState();
+// long subBufferSize = channel.getSubBufferSize();
+// long switchTimer = channel.getSwitchTimer();
+//
+// // test cases
+// channel.setName("newName");
+// assertEquals("newName", channel.getName());
+//
+// channel.setNumberOfSubBuffers(2);
+// assertEquals(2, channel.getNumberOfSubBuffers());
+//
+// channel.setOutputType("splice()");
+// assertEquals("splice()", channel.getOutputType());
+//
+// channel.setOverwriteMode(false);
+// assertEquals(false, channel.isOverwriteMode());
+//
+// channel.setReadTimer(250);
+// assertEquals(250, channel.getReadTimer());
+//
+// channel.setState("enabled");
+// assertEquals(TraceEnablement.ENABLED, channel.getState());
+//
+// Image enabledImage = channel.getImage();
+// assertNotNull(enabledImage);
+// channel.setState(TraceEnablement.DISABLED);
+// assertEquals(TraceEnablement.DISABLED, channel.getState());
+//
+// Image disabledImage = channel.getImage();
+// assertNotNull(disabledImage);
+// assertNotSame(enabledImage, disabledImage);
+//
+// channel.setSubBufferSize(1024);
+// assertEquals(1024, channel.getSubBufferSize());
+//
+// channel.setSwitchTimer(1000);
+// assertEquals(1000, channel.getSwitchTimer());
+//
+// // restore original values
+// channel.setName(name);
+// channel.setNumberOfSubBuffers(nbSubBuffers);
+// channel.setOutputType(type);
+// channel.setOverwriteMode(mode);
+// channel.setReadTimer(readTimer);
+// channel.setState(state);
+// channel.setSubBufferSize(subBufferSize);
+// channel.setSwitchTimer(switchTimer);
+// }
+//
+// private void verifyUstProviderGettersSetters(UstProviderComponent ustProvider) {
+// // save original values
+// String name = ustProvider.getName();
+// int pid = ustProvider.getPid();
+//
+// // test cases
+// ustProvider.setName("newName");
+// assertEquals("newName", ustProvider.getName());
+//
+// ustProvider.setPid(9876);
+// assertEquals(9876, ustProvider.getPid());
+//
+// // restore original values
+// ustProvider.setName(name);
+// ustProvider.setPid(pid);
+// }
+
+ public class CreateSessionDialogStub implements ICreateSessionDialog {
+ public String fPath = null;
+
+ @Override
+ public String getSessionName() {
+ return "mysession";
+ }
+
+ @Override
+ public String getSessionPath() {
+ return fPath;
+ }
+
+ @Override
+ public boolean isDefaultSessionPath() {
+ return fPath == null;
+ }
+
+ @Override
+ public void setTraceSessionGroup(TraceSessionGroup group) {
+
+ }
+
+ @Override
+ public int open() {
+ return 0;
+ }
+
+ public void setSessionPath(String path) {
+ fPath = path;
+ }
+ }
+
+ public class GetEventInfoDialogStub implements IGetEventInfoDialog {
+
+ private TraceSessionComponent[] fSessions;
+
+ @Override
+ public TraceSessionComponent getSession() {
+ return fSessions[0];
+ }
+
+ @Override
+ public TraceChannelComponent getChannel() {
+ return null;
+ }
+
+ @Override
+ public void setIsKernel(boolean isKernel) {
+ }
+
+ @Override
+ public void setSessions(TraceSessionComponent[] sessions) {
+ fSessions = sessions;
+ }
+
+ @Override
+ public int open() {
+ return 0;
+ }
+ }
+
+ public class DestroyConfirmDialogStub implements IConfirmDialog {
+
+ @Override
+ public boolean openConfirm(Shell parent, String title, String message) {
+ return true;
+ }
+ }
+
+ public class CreateChannelOnSessionDialogStub implements ICreateChannelOnSessionDialog {
+
+ @Override
+ public IChannelInfo getChannelInfo() {
+ ChannelInfo info = new ChannelInfo("mychannel");
+ info.setNumberOfSubBuffers(2);
+ info.setOverwriteMode(false);
+ info.setReadTimer(100);
+ info.setSwitchTimer(200);
+ info.setSubBufferSize(16384);
+ return info;
+ }
+
+ @Override
+ public void setDomainComponent(TraceDomainComponent domain) {
+ }
+
+ @Override
+ public int open() {
+ return 0;
+ }
+
+ @Override
+ public boolean isKernel() {
+ return false;
+ }
+
+ }
+}
\ No newline at end of file
*******************************************************************************/
package org.eclipse.linuxtools.lttng.ui.tests.control.model.component;
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.NotEnabledException;
+import org.eclipse.core.commands.NotHandledException;
+import org.eclipse.core.commands.common.NotDefinedException;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.linuxtools.lttng.ui.views.control.ControlView;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.handlers.IHandlerService;
/**
* Singleton class to facilitate the test cases. Creates UML2SD view and loader objects as well as provides
final static public int WAIT_FOR_JOBS_DELAY = 1000;
final static public int GUI_REFESH_DELAY = 500;
+ final static public String COMMAND_CATEGORY_PREFIX = "org.eclipse.linuxtools.lttng.ui.commands.control."; //$NON-NLS-1$
+
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
public ControlView getControlView() {
return fControlView;
}
+
+ public void executeCommand(String commandId) throws ExecutionException, NotDefinedException, NotEnabledException, NotHandledException {
+// ICommandService commandService = (ICommandService) fControlView.getSite().getService(ICommandService.class);
+ IHandlerService handlerService = (IHandlerService) fControlView.getSite().getService(IHandlerService.class);
+ handlerService.executeCommand(COMMAND_CATEGORY_PREFIX + commandId, null);
+ }
+
}
**********************************************************************/
package org.eclipse.linuxtools.lttng.ui.tests.control.model.component;
+import java.io.File;
+import java.net.URL;
+
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
import org.eclipse.linuxtools.lttng.stubs.service.TestRemoteSystemProxy;
-import org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo;
+import org.eclipse.linuxtools.lttng.ui.tests.LTTngUITestPlugin;
import org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceControlComponent;
import org.eclipse.linuxtools.lttng.ui.views.control.model.TargetNodeState;
import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceEnablement;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.KernelProviderComponent;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TargetNodeComponent;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceChannelComponent;
-import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceControlComponent;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceEventComponent;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceProbeEventComponent;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceProviderGroup;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionGroup;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.UstProviderComponent;
-import org.eclipse.linuxtools.lttng.ui.views.control.property.TargetNodePropertySource;
import org.eclipse.linuxtools.lttng.ui.views.control.service.ILttngControlService;
import org.eclipse.linuxtools.lttng.ui.views.control.service.LTTngControlService;
import org.eclipse.rse.core.model.Host;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.internal.core.model.SystemProfile;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.views.properties.IPropertySource;
import org.junit.After;
import org.junit.Before;
@SuppressWarnings("nls")
public class TraceControlTreeModelTest extends TestCase {
+ private static final String DIRECTORY = "testfiles";
+ private static final String TEST_STREAM = "ListInfoTest.cfg";
+ private static final String SCEN_LIST_INFO_TEST = "ListInfoTest";
+
// ------------------------------------------------------------------------
// Test data
// ------------------------------------------------------------------------
+ private TestRemoteSystemProxy fProxy;
+ private String fTestFile;
+
// ------------------------------------------------------------------------
// Static methods
// ------------------------------------------------------------------------
@Override
@Before
public void setUp() throws Exception {
+ fProxy = new TestRemoteSystemProxy();
+ URL location = FileLocator.find(LTTngUITestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
+ File testfile = new File(FileLocator.toFileURL(location).toURI());
+ fTestFile = testfile.getAbsolutePath();
}
/**
public void testTraceControlComponents()
throws Exception {
- TestRemoteSystemProxy proxy = new TestRemoteSystemProxy();
-
+ fProxy.setTestFile(fTestFile);
+ fProxy.setScenario(SCEN_LIST_INFO_TEST);
+
ITraceControlComponent root = TraceControlTestFacility.getInstance().getControlView().getTraceControlRoot();
@SuppressWarnings("restriction")
IHost host = new Host(new SystemProfile("myProfile", true));
host.setHostName("127.0.0.1");
- TargetNodeComponent node = new TargetNodeComponent("myNode", root, host, proxy);
+ TargetNodeComponent node = new TargetNodeComponent("myNode", root, host, fProxy);
root.addChild(node);
node.connect();
// ------------------------------------------------------------------------
ITraceControlComponent[] channel0Events = channel.getChildren();
assertNotNull(channel0Events);
- assertEquals(2, channel0Events.length);
+ assertEquals(5, channel0Events.length);
assertTrue(channel0Events[0] instanceof TraceEventComponent);
assertTrue(channel0Events[1] instanceof TraceEventComponent);
+ assertTrue(channel0Events[2] instanceof TraceProbeEventComponent);
+ assertTrue(channel0Events[3] instanceof TraceProbeEventComponent);
+ assertTrue(channel0Events[4] instanceof TraceEventComponent);
TraceEventComponent event = (TraceEventComponent) channel0Events[0];
assertEquals("block_rq_remap", event.getName());
assertEquals(TraceEventType.TRACEPOINT, event.getEventType());
assertEquals(TraceEnablement.DISABLED, event.getState());
+ TraceProbeEventComponent probeEvent = (TraceProbeEventComponent) channel0Events[2];
+ assertEquals("myevent2", probeEvent.getName());
+ assertEquals(TraceLogLevel.LEVEL_UNKNOWN, probeEvent.getLogLevel());
+ assertEquals(TraceEventType.PROBE, probeEvent.getEventType());
+ assertEquals(TraceEnablement.ENABLED, probeEvent.getState());
+ assertEquals("0xc0101340", probeEvent.getAddress());
+ assertNull(probeEvent.getOffset());
+ assertNull(probeEvent.getSymbol());
+
+ probeEvent = (TraceProbeEventComponent) channel0Events[3];
+ assertEquals("myevent0", probeEvent.getName());
+ assertEquals(TraceLogLevel.LEVEL_UNKNOWN, probeEvent.getLogLevel());
+ assertEquals(TraceEventType.PROBE, probeEvent.getEventType());
+ assertEquals(TraceEnablement.ENABLED, probeEvent.getState());
+ assertNull(probeEvent.getAddress());
+ assertEquals("0x0", probeEvent.getOffset());
+ assertEquals("init_post", probeEvent.getSymbol());
+
+ event = (TraceEventComponent) channel0Events[4];
+ assertEquals("syscalls", event.getName());
+ assertEquals(TraceLogLevel.LEVEL_UNKNOWN, event.getLogLevel());
+ assertEquals(TraceEventType.SYSCALL, event.getEventType());
+ assertEquals(TraceEnablement.ENABLED, event.getState());
+
// ------------------------------------------------------------------------
// Verify Kernel's channel1
// ------------------------------------------------------------------------
suite.addTestSuite(BaseEventInfoTest.class);
suite.addTestSuite(DomainInfoTest.class);
suite.addTestSuite(EventInfoTest.class);
+ suite.addTestSuite(ProbeEventInfoTest.class);
suite.addTestSuite(ChannelInfoTest.class);
suite.addTestSuite(SessionInfoTest.class);
suite.addTestSuite(TraceInfoTest.class);
import org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.IDomainInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.IEventInfo;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.IProbeEventInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.ISessionInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.IUstProviderInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceEnablement;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.ChannelInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.DomainInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.EventInfo;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.ProbeEventInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.SessionInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.UstProviderInfo;
private IBaseEventInfo fBaseEventInfo2 = null;
private IUstProviderInfo fUstProviderInfo1 = null;
private IUstProviderInfo fUstProviderInfo2 = null;
+ private IProbeEventInfo fProbeEventInfo1 = null;
+ private IProbeEventInfo fProbeEventInfo2 = null;
public ModelImplFactory() {
fBaseEventInfo1 = new BaseEventInfo("event1");
fSessionInfo2.setSessionState(TraceSessionState.INACTIVE);
fSessionInfo2.addDomain(fDomainInfo1);
fSessionInfo2.addDomain(fDomainInfo2);
+
+ fProbeEventInfo1 = new ProbeEventInfo("probeEvent1");
+ fProbeEventInfo1.setEventType(TraceEventType.TRACEPOINT);
+ fProbeEventInfo1.setState(TraceEnablement.ENABLED);
+ fProbeEventInfo1.setAddress("0xc1231234");
+
+ fProbeEventInfo2 = new ProbeEventInfo("probeEvent2");
+ fProbeEventInfo2.setEventType(TraceEventType.UNKNOWN);
+ fProbeEventInfo2.setState(TraceEnablement.DISABLED);
+ fProbeEventInfo2.setOffset("0x100");
+ fProbeEventInfo2.setSymbol("init_post");
}
public ISessionInfo getSessionInfo1() {
public IUstProviderInfo getUstProviderInfo2() {
return fUstProviderInfo2;
}
+
+ public IProbeEventInfo getProbeEventInfo1() {
+ return fProbeEventInfo1;
+ }
+
+ public IProbeEventInfo getProbeEventInfo2() {
+ return fProbeEventInfo2;
+ }
+
}
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng.ui.tests.control.model.impl;
+
+import junit.framework.TestCase;
+
+import org.eclipse.linuxtools.lttng.ui.views.control.model.IProbeEventInfo;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceEnablement;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceEventType;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.BaseEventInfo;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.EventInfo;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.ProbeEventInfo;
+
+/**
+ * The class <code>BaseEventInfoTest</code> contains test for the class <code>{@link BaseEventInfo}</code>.
+ */
+@SuppressWarnings("nls")
+public class ProbeEventInfoTest extends TestCase {
+
+ // ------------------------------------------------------------------------
+ // Test data
+ // ------------------------------------------------------------------------
+ private IProbeEventInfo fEventInfo1 = null;
+ private IProbeEventInfo fEventInfo2 = null;
+
+ // ------------------------------------------------------------------------
+ // Housekeeping
+ // ------------------------------------------------------------------------
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ */
+ @Override
+ public void setUp() throws Exception {
+ ModelImplFactory factory = new ModelImplFactory();
+ fEventInfo1 = factory.getProbeEventInfo1();
+ fEventInfo2 = factory.getProbeEventInfo2();
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ */
+ @Override
+ public void tearDown() throws Exception {
+ }
+
+ // ------------------------------------------------------------------------
+ // Tests
+ // ------------------------------------------------------------------------
+
+ /**
+ * Run the BaseEventInfo() constructor test.
+ *
+ */
+ public void testBaseEventInfo() {
+ ProbeEventInfo fixture = new ProbeEventInfo("event");
+ assertNotNull(fixture);
+
+ TraceEventType result = fixture.getEventType();
+
+ assertEquals("event", fixture.getName());
+ assertEquals("unknown", result.getInName());
+ assertEquals("UNKNOWN", result.name());
+ assertEquals("UNKNOWN", result.toString());
+ assertEquals(3, result.ordinal());
+
+ TraceEnablement state = fixture.getState();
+ assertEquals("disabled", state.getInName());
+ assertEquals("DISABLED", state.name());
+ assertEquals("DISABLED", state.toString());
+ assertEquals(0, state.ordinal());
+
+ assertNull(fixture.getAddress());
+ assertNull(fixture.getOffset());
+ assertNull(fixture.getSymbol());
+ }
+
+ /**
+ * Test Copy Constructor
+ */
+ public void testEventInfoCopy() {
+ ProbeEventInfo info = new ProbeEventInfo((ProbeEventInfo)fEventInfo1);
+
+ assertEquals(fEventInfo1.getName(), info.getName());
+ assertEquals(fEventInfo1.getEventType(), info.getEventType());
+ assertEquals(fEventInfo1.getState(), info.getState());
+ assertEquals(fEventInfo1.getAddress(), info.getAddress());
+ assertEquals(fEventInfo1.getOffset(), info.getOffset());
+ assertEquals(fEventInfo1.getSymbol(), info.getSymbol());
+ }
+
+ /**
+ * Test Copy Constructor
+ */
+ public void testEventCopy2() {
+ try {
+ ProbeEventInfo info = null;
+ new ProbeEventInfo(info);
+ fail("null copy");
+ }
+ catch (IllegalArgumentException e) {
+ // Success
+ }
+ }
+
+ /**
+ * Getter/Setter tests
+ */
+ public void testGetAndSetter() {
+ ProbeEventInfo fixture = new ProbeEventInfo("event");
+
+ // Make sure that ProbeEventInfo extends EventInfo
+ // -> so we don't need to re-test common parts
+ assertTrue(fixture instanceof EventInfo);
+
+ fixture.setAddress("0xc12344321");
+ String result = fixture.getAddress();
+
+ assertNotNull(result);
+ assertEquals("0xc12344321", result);
+
+ fixture.setOffset("0x1000");
+ result = fixture.getOffset();
+
+ assertNotNull(result);
+ assertEquals("0x1000", result);
+
+ fixture.setSymbol("cpu_idle");
+ result = fixture.getSymbol();
+
+ assertNotNull(result);
+ assertEquals("cpu_idle", result);
+ }
+
+ /**
+ * Run the String toString() method test.
+ */
+ public void testToString_1() {
+ assertEquals("[ProbeEventInfo([EventInfo([BaseEventInfo([TraceInfo(Name=probeEvent1)],type=TRACEPOINT,level=TRACE_DEBUG)],State=ENABLED)],fAddress=0xc1231234)]", fEventInfo1.toString());
+ assertEquals("[ProbeEventInfo([EventInfo([BaseEventInfo([TraceInfo(Name=probeEvent2)],type=UNKNOWN,level=TRACE_DEBUG)],State=DISABLED)],fOffset=0x100,fSymbol=init_post)]", fEventInfo2.toString());
+ }
+
+ // ------------------------------------------------------------------------
+ // equals
+ // ------------------------------------------------------------------------
+ public void testEqualsReflexivity() {
+ assertTrue("equals", fEventInfo1.equals(fEventInfo1));
+ assertTrue("equals", fEventInfo2.equals(fEventInfo2));
+
+ assertTrue("equals", !fEventInfo1.equals(fEventInfo2));
+ assertTrue("equals", !fEventInfo2.equals(fEventInfo1));
+ }
+
+ public void testEqualsSymmetry() {
+ ProbeEventInfo info1 = new ProbeEventInfo((ProbeEventInfo)fEventInfo1);
+ ProbeEventInfo info2 = new ProbeEventInfo((ProbeEventInfo)fEventInfo2);
+
+ assertTrue("equals", info1.equals(fEventInfo1));
+ assertTrue("equals", fEventInfo1.equals(info1));
+
+ assertTrue("equals", info2.equals(fEventInfo2));
+ assertTrue("equals", fEventInfo2.equals(info2));
+ }
+
+ public void testEqualsTransivity() {
+ ProbeEventInfo info1 = new ProbeEventInfo((ProbeEventInfo)fEventInfo1);
+ ProbeEventInfo info2 = new ProbeEventInfo((ProbeEventInfo)fEventInfo1);
+ ProbeEventInfo info3 = new ProbeEventInfo((ProbeEventInfo)fEventInfo1);
+
+ assertTrue("equals", info1.equals(info2));
+ assertTrue("equals", info2.equals(info3));
+ assertTrue("equals", info1.equals(info3));
+ }
+
+ public void testEqualsNull() {
+ assertTrue("equals", !fEventInfo1.equals(null));
+ assertTrue("equals", !fEventInfo2.equals(null));
+ }
+
+ // ------------------------------------------------------------------------
+ // hashCode
+ // ------------------------------------------------------------------------
+
+ public void testHashCode() {
+ ProbeEventInfo info1 = new ProbeEventInfo((ProbeEventInfo)fEventInfo1);
+ ProbeEventInfo info2 = new ProbeEventInfo((ProbeEventInfo)fEventInfo2);
+
+ assertTrue("hashCode", fEventInfo1.hashCode() == info1.hashCode());
+ assertTrue("hashCode", fEventInfo2.hashCode() == info2.hashCode());
+
+ assertTrue("hashCode", fEventInfo1.hashCode() != info2.hashCode());
+ assertTrue("hashCode", fEventInfo2.hashCode() != info1.hashCode());
+ }
+}
\ No newline at end of file
**********************************************************************/
package org.eclipse.linuxtools.lttng.ui.tests.control.service;
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
import java.util.List;
import junit.framework.TestCase;
import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
import org.eclipse.linuxtools.lttng.stubs.service.CommandShellFactory;
+import org.eclipse.linuxtools.lttng.stubs.service.shells.LTTngToolsFileShell;
+import org.eclipse.linuxtools.lttng.ui.tests.LTTngUITestPlugin;
import org.eclipse.linuxtools.lttng.ui.views.control.model.IBaseEventInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.IDomainInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.IEventInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.ISessionInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.IUstProviderInfo;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.LogLevelType;
import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceEnablement;
import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceEventType;
import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceLogLevel;
import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceSessionState;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.ChannelInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.service.ILttngControlService;
import org.eclipse.linuxtools.lttng.ui.views.control.service.LTTngControlService;
/**
*/
@SuppressWarnings("nls")
public class LTTngControlServiceTest extends TestCase {
+
+ private static final String DIRECTORY = "testfiles";
+ private static final String TEST_STREAM = "LTTngServiceTest.cfg";
+
+ private static final String SCEN_LTTNG_NOT_INSTALLED = "LttngNotInstalled";
+ private static final String SCEN_NO_SESSION_AVAILABLE = "NoSessionAvailable";
+ private static final String SCEN_GET_SESSION_NAMES1 = "GetSessionNames1";
+ private static final String SCEN_GET_SESSION_NAME_NOT_EXIST = "GetSessionNameNotExist";
+ private static final String SCEN_GET_SESSION_GARBAGE_OUT = "GetSessionGarbageOut";
+ private static final String SCEN_GET_SESSION1 = "GetSession1";
+ private static final String SCEN_GET_KERNEL_PROVIDER1 = "GetKernelProvider1";
+ private static final String SCEN_GET_UST_PROVIDER1 = "GetUstProvider1";
+ private static final String SCEN_GET_UST_PROVIDER2 = "GetUstProvider2";
+ private static final String SCEN_CREATE_SESSION1 = "CreateSession1";
+ private static final String SCEN_CREATE_SESSION_VARIANTS = "CreateSessionVariants";
+ private static final String SCEN_DESTROY_SESSION1 = "DestroySession1";
+ private static final String SCEN_CHANNEL_HANDLING = "ChannelHandling";
+ private static final String SCEN_EVENT_HANDLING = "EventHandling";
+
// ------------------------------------------------------------------------
// Test data
// ------------------------------------------------------------------------
- private CommandShellFactory fShellFactory;
+ private CommandShellFactory fShellFactory;
+ private String fTestfile;
+ private LTTngToolsFileShell fShell;
+ private ILttngControlService fService;
+
// ------------------------------------------------------------------------
// Static methods
public void setUp() throws Exception {
super.setUp();
fShellFactory = CommandShellFactory.getInstance();
+
+ URL location = FileLocator.find(LTTngUITestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
+ File testfile = new File(FileLocator.toFileURL(location).toURI());
+ fTestfile = testfile.getAbsolutePath();
+
+ fShell = fShellFactory.getFileShell();
+ fShell.loadScenarioFile(fTestfile);
+ fService = new LTTngControlService(fShell);
}
/**
public void testGetSessionNames() {
try {
- ILttngControlService service = new LTTngControlService(fShellFactory.getShellForLttngNotExistsShell());
- service.getSessionNames(new NullProgressMonitor());
+ fShell.setScenario(SCEN_LTTNG_NOT_INSTALLED);
+ fService.getSessionNames(new NullProgressMonitor());
fail("No exeption thrown");
-
} catch (ExecutionException e) {
// success
}
public void testGetSessionNames1() {
try {
- ILttngControlService service = new LTTngControlService(fShellFactory.getShellForNoSessionNames());
- String[] result = service.getSessionNames(new NullProgressMonitor());
+ fShell.setScenario(SCEN_NO_SESSION_AVAILABLE);
+ String[] result = fService.getSessionNames(new NullProgressMonitor());
assertNotNull(result);
assertEquals(0, result.length);
fail(e.toString());
}
}
-
+
public void testGetSessionNames2() {
try {
- ILttngControlService service = new LTTngControlService(fShellFactory.getShellForSessionNames());
- String[] result = service.getSessionNames(new NullProgressMonitor());
+ fShell.setScenario(SCEN_GET_SESSION_NAMES1);
+ String[] result = fService.getSessionNames(new NullProgressMonitor());
assertNotNull(result);
assertEquals(2, result.length);
fail(e.toString());
}
}
-
+
public void testGetSessionNotExist() {
try {
- ILttngControlService service = new LTTngControlService(fShellFactory.getShellForSessionNotExists());
- service.getSessionNames(new NullProgressMonitor());
+ fShell.setScenario(SCEN_GET_SESSION_NAME_NOT_EXIST);
+ fService.getSessionNames(new NullProgressMonitor());
fail("No exeption thrown");
} catch (ExecutionException e) {
public void testGetSessionNameGarbage() {
try {
- ILttngControlService service = new LTTngControlService(fShellFactory.getShellForSessionGarbage());
- String[] result = service.getSessionNames(new NullProgressMonitor());
+ fShell.setScenario(SCEN_GET_SESSION_GARBAGE_OUT);
+ String[] result = fService.getSessionNames(new NullProgressMonitor());
assertNotNull(result);
assertEquals(0, result.length);
public void testGetSession1() {
try {
- ILttngControlService service = new LTTngControlService(fShellFactory.getShellForSessionNames());
- ISessionInfo session = service.getSession("mysession", new NullProgressMonitor());
+ fShell.setScenario(SCEN_GET_SESSION1);
+ ISessionInfo session = fService.getSession("mysession", new NullProgressMonitor());
// Verify Session
assertNotNull(session);
assertEquals(TraceEnablement.ENABLED, ustEvents[1].getState());
// next session (no detailed information available)
- session = service.getSession("mysession1", new NullProgressMonitor());
+ session = fService.getSession("mysession1", new NullProgressMonitor());
assertNotNull(session);
assertEquals("mysession1", session.getName());
assertEquals("/home/user/lttng-traces/mysession1-20120203-133225", session.getSessionPath());
public void testGetKernelProvider() {
try {
- ILttngControlService service = new LTTngControlService(fShellFactory.getShellForSessionNames());
- List<IBaseEventInfo> events = service.getKernelProvider(new NullProgressMonitor());
+ fShell.setScenario(SCEN_GET_KERNEL_PROVIDER1);
+ List<IBaseEventInfo> events = fService.getKernelProvider(new NullProgressMonitor());
// Verify event info
assertNotNull(events);
public void testGetUstProvider() {
try {
- ILttngControlService service = new LTTngControlService(fShellFactory.getShellForSessionNames());
- List<IUstProviderInfo> providers = service.getUstProvider();
+ fShell.setScenario(SCEN_GET_UST_PROVIDER1);
+ List<IUstProviderInfo> providers = fService.getUstProvider();
// Check all providers
assertNotNull(providers);
fail(e.toString());
}
}
-
+
public void testUstProvider2() {
try {
- ILttngControlService service = new LTTngControlService(fShellFactory.getShellForNoUstProvider());
- List<IUstProviderInfo> providers = service.getUstProvider();
+ fShell.setScenario(SCEN_GET_UST_PROVIDER2);
+ List<IUstProviderInfo> providers = fService.getUstProvider();
assertNotNull(providers);
assertEquals(0, providers.size());
fail(e.toString());
}
}
-
+
public void testCreateSession() {
try {
- ILttngControlService service = new LTTngControlService(fShellFactory.getShellForSessionNames());
- ISessionInfo info = service.createSession("mysession2", null, new NullProgressMonitor());
+ fShell.setScenario(SCEN_CREATE_SESSION1);
+
+ ISessionInfo info = fService.createSession("mysession2", null, new NullProgressMonitor());
assertNotNull(info);
assertEquals("mysession2", info.getName());
assertNotNull(info.getSessionPath());
fail(e.toString());
}
}
-
- public void testCreateSessionErrors() {
- ILttngControlService service = new LTTngControlService(fShellFactory.getShellForSessionErrors());
+
+ public void testCreateSessionVariants() {
+
+ fShell.setScenario(SCEN_CREATE_SESSION_VARIANTS);
+
try {
- service.createSession("alreadyExist", null, new NullProgressMonitor());
+ fService.createSession("alreadyExist", null, new NullProgressMonitor());
fail("No exeption thrown");
} catch (ExecutionException e) {
// success
}
try {
- service.createSession("wrongName", null, new NullProgressMonitor());
+ fService.createSession("wrongName", null, new NullProgressMonitor());
fail("No exeption thrown");
} catch (ExecutionException e) {
// success
}
try {
- service.createSession("wrongPath", "/home/user/hallo", new NullProgressMonitor());
+ fService.createSession("withPath", "/home/user/hallo", new NullProgressMonitor());
fail("No exeption thrown");
} catch (ExecutionException e) {
// success
}
try {
- ISessionInfo info = service.createSession("session with spaces", null, new NullProgressMonitor());
+ ISessionInfo info = fService.createSession("session with spaces", null, new NullProgressMonitor());
assertNotNull(info);
assertEquals("session with spaces", info.getName());
assertNotNull(info.getSessionPath());
}
try {
- ISessionInfo info = service.createSession("pathWithSpaces", "/home/user/hallo user/here", new NullProgressMonitor());
+ ISessionInfo info = fService.createSession("pathWithSpaces", "/home/user/hallo user/here", new NullProgressMonitor());
assertNotNull(info);
assertEquals("pathWithSpaces", info.getName());
assertNotNull(info.getSessionPath());
public void testDestroySession() {
try {
- ILttngControlService service = new LTTngControlService(fShellFactory.getShellForSessionNames());
- service.destroySession("mysession2", new NullProgressMonitor());
+ fShell.setScenario(SCEN_DESTROY_SESSION1);
+ fService.destroySession("mysession2", new NullProgressMonitor());
} catch (ExecutionException e) {
fail(e.toString());
}
}
+
+ public void testCreateChannel() {
+ try {
+
+ String sessionName = "mysession2";
+ List<String> list = new ArrayList<String>();
+ String kernelChannel0 = "mychannel0";
+ String kernelChannel1 = "mychannel1";
+ list.add(kernelChannel0);
+ list.add(kernelChannel1);
+
+ fShell.setScenario(SCEN_CHANNEL_HANDLING);
+
+ // Create/enable/configure 2 kernel channels
+ ChannelInfo chanInfo = new ChannelInfo("");
+ chanInfo.setOverwriteMode(true);
+ chanInfo.setSubBufferSize(16384);
+ chanInfo.setReadTimer(100);
+ chanInfo.setSwitchTimer(200);
+ chanInfo.setNumberOfSubBuffers(2);
+ fService.enableChannels(sessionName, list, true, chanInfo, new NullProgressMonitor());
+
+ // Create/enable/configure 1 UST channel
+ list.clear();
+ list.add("ustChannel");
+
+ chanInfo = new ChannelInfo("");
+ chanInfo.setOverwriteMode(true);
+ chanInfo.setSubBufferSize(32768);
+ chanInfo.setReadTimer(200);
+ chanInfo.setSwitchTimer(100);
+ chanInfo.setNumberOfSubBuffers(1);
+ fService.enableChannels(sessionName, list, false, chanInfo, new NullProgressMonitor());
+
+ } catch (ExecutionException e) {
+ fail(e.toString());
+ }
+ }
+
+ public void testDisableChannel() {
+ try {
+
+ String sessionName = "mysession2";
+ List<String> list = new ArrayList<String>();
+ String kernelChannel0 = "mychannel0";
+ String kernelChannel1 = "mychannel1";
+ list.add(kernelChannel0);
+ list.add(kernelChannel1);
+
+ fShell.setScenario(SCEN_CHANNEL_HANDLING);
+ fService.disableChannels(sessionName, list, true, new NullProgressMonitor());
+
+ list.clear();
+ list.add("ustChannel");
+ fService.disableChannels(sessionName, list, false, new NullProgressMonitor());
+
+ } catch (ExecutionException e) {
+ fail(e.toString());
+ }
+ }
-// public void testCreateChannel() {
+ public void testEnableChannel() {
+ try {
+
+ String sessionName = "mysession2";
+ List<String> list = new ArrayList<String>();
+ String kernelChannel0 = "mychannel0";
+ String kernelChannel1 = "mychannel1";
+ list.add(kernelChannel0);
+ list.add(kernelChannel1);
+
+ fShell.setScenario(SCEN_CHANNEL_HANDLING);
+ fService.enableChannels(sessionName, list, true, null, new NullProgressMonitor());
+
+ // Create/enable/configure 1 UST channel
+ list.clear();
+ list.add("ustChannel");
+
+ fService.enableChannels(sessionName, list, false, null, new NullProgressMonitor());
+
+ } catch (ExecutionException e) {
+ fail(e.toString());
+ }
+ }
+
+// public void tesEnableChannelNoTracer() {
// try {
+// ILttngControlService service = new LTTngControlService(fShellFactory.getShellForChannelNoTracer());
+// service.getSessionNames(new NullProgressMonitor());
+// fail("No exeption thrown");
//
-//// public void enableChannel(String sessionName, List<String> channelNames, boolean isKernel, IChannelInfo info, IProgressMonitor monitor);
-// ILttngControlService service = new LTTngControlService(fShellFactory.getShellForSessionNames());
-//
-//
-// ISessionInfo info = service.createSession("mysession2", null, new NullProgressMonitor());
-// assertNotNull(info);
-// assertEquals("mysession2", info.getName());
-// assertNotNull(info.getSessionPath());
-// assertTrue(info.getSessionPath().contains("mysession2"));
-// assertEquals(TraceSessionState.INACTIVE, info.getSessionState());
// } catch (ExecutionException e) {
-// fail(e.toString());
+// // success
// }
-// }
+// }
+
+ public void testEnableEvents() {
+ try {
+ // 1) session name, channel = null, 3 event names, kernel
+ String sessionName = "mysession2";
+ List<String> list = new ArrayList<String>();
+ String eventName0 = "block_rq_remap";
+ String eventName1 = "block_bio_remap";
+ String eventName2 = "softirq_entry";
+ list.add(eventName0);
+ list.add(eventName1);
+ list.add(eventName2);
+ fShell.setScenario(SCEN_EVENT_HANDLING);
+ fService.enableEvents(sessionName, null, list, true, new NullProgressMonitor());
+
+ // 2) session name, channel=mychannel, event name= null, kernel
+ String channelName = "mychannel";
+ fService.enableEvents(sessionName, channelName, null, true, new NullProgressMonitor());
+ // 3) session name, channel=mychannel, 1 event name, ust
+ String ustEventName = "ust_tests_hello:tptest_sighandler";
+ list.clear();
+ list.add(ustEventName);
+ fService.enableEvents(sessionName, channelName, list, false, new NullProgressMonitor());
+
+ // 4) session name, channel = mychannel, no event name, ust
+ list.clear();
+ fService.enableEvents(sessionName, channelName, list, false, new NullProgressMonitor());
+
+ } catch (ExecutionException e) {
+ fail(e.toString());
+ }
+ }
+ public void testEnableSyscalls() {
+ try {
+ // 1) session name, channel = null, 3 event names, kernel
+ String sessionName = "mysession2";
+ String channelName = "mychannel";
+
+ fShell.setScenario(SCEN_EVENT_HANDLING);
+
+ // 1) session name, channel = null
+ fService.enableSyscalls(sessionName, null, new NullProgressMonitor());
+
+ // 2) session name, channel = mychannel
+ fService.enableSyscalls(sessionName, channelName, new NullProgressMonitor());
+
+ } catch (ExecutionException e) {
+ fail(e.toString());
+ }
+ }
+
+ public void testDynamicProbe() {
+ try {
+ // 1) session name, channel = null, 3 event names, kernel
+ String sessionName = "mysession2";
+ String channelName = "mychannel";
+ String eventName0 = "myevent0";
+ String eventName1 = "myevent1";
+ String functionProbe = "0xc0101340";
+ String dynProbe = "init_post";
+
+ fShell.setScenario(SCEN_EVENT_HANDLING);
+
+ // 1) session name, channel = null, event name, function probe, probe
+ fService.enableProbe(sessionName, null, eventName0, true, functionProbe, new NullProgressMonitor());
+
+ // 2) session name, channel = mychannel
+ fService.enableProbe(sessionName, channelName, eventName1, false, dynProbe, new NullProgressMonitor());
+
+ } catch (ExecutionException e) {
+ fail(e.toString());
+ }
+ }
+
+ public void testEnableLogLevel() {
+ try {
+ // 1) session name, channel = null, 3 event names, kernel
+ String sessionName = "mysession2";
+ String channelName = "mychannel";
+ String eventName4 = "myevent4";
+ String eventName5 = "myevent5";
+
+ fShell.setScenario(SCEN_EVENT_HANDLING);
+
+ // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
+ fService.enableLogLevel(sessionName, null, eventName4, LogLevelType.LOGLEVEL_ONLY, TraceLogLevel.TRACE_DEBUG, new NullProgressMonitor());
+
+ // 2) session name, channel = mychannel, null, loglevel, TRACE_DEBUG_FUNCTION
+ fService.enableLogLevel(sessionName, channelName, eventName5, LogLevelType.LOGLEVEL, TraceLogLevel.TRACE_DEBUG_FUNCTION, new NullProgressMonitor());
+
+ } catch (ExecutionException e) {
+ fail(e.toString());
+ }
+ }
}
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
package org.eclipse.linuxtools.lttng.stubs.service;
-import org.eclipse.linuxtools.lttng.stubs.service.shells.GetSessionGarbageShell;
-import org.eclipse.linuxtools.lttng.stubs.service.shells.LttngNotExistsShell;
-import org.eclipse.linuxtools.lttng.stubs.service.shells.NoSessionNamesShell;
-import org.eclipse.linuxtools.lttng.stubs.service.shells.NoUstProviderShell;
-import org.eclipse.linuxtools.lttng.stubs.service.shells.SessionCreationErrorsShell;
-import org.eclipse.linuxtools.lttng.stubs.service.shells.SessionNotExistsShell;
-import org.eclipse.linuxtools.lttng.stubs.service.shells.SessionNamesShell;
-import org.eclipse.linuxtools.lttng.ui.views.control.service.ICommandShell;
+import org.eclipse.linuxtools.lttng.stubs.service.shells.LTTngToolsFileShell;
public class CommandShellFactory {
return fInstance;
}
- public ICommandShell getShellForNoSessionNames() {
- return new NoSessionNamesShell();
- }
-
- public ICommandShell getShellForSessionNames() {
- return new SessionNamesShell();
- }
-
- public ICommandShell getShellForLttngNotExistsShell() {
- return new LttngNotExistsShell();
- }
-
- public ICommandShell getShellForSessionNotExists() {
- return new SessionNotExistsShell();
- }
-
- public ICommandShell getShellForSessionGarbage() {
- return new GetSessionGarbageShell();
- }
-
- public ICommandShell getShellForNoUstProvider() {
- return new NoUstProviderShell();
- }
+// public ICommandShell getRealShell() {
+// ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
+// IHost host = registry.getLocalHost();
+// RemoteSystemProxy proxy = new RemoteSystemProxy(host);
+// ICommandShell shell = new LTTngToolsSimulatorShell(proxy);
+// return shell;
+// }
- public ICommandShell getShellForSessionErrors() {
- return new SessionCreationErrorsShell();
+ public LTTngToolsFileShell getFileShell() {
+ return new LTTngToolsFileShell();
}
}
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
package org.eclipse.linuxtools.lttng.stubs.service;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.Status;
+import org.eclipse.linuxtools.lttng.stubs.service.shells.LTTngToolsFileShell;
import org.eclipse.linuxtools.lttng.ui.views.control.remote.IRemoteSystemProxy;
import org.eclipse.linuxtools.lttng.ui.views.control.service.ICommandShell;
import org.eclipse.rse.core.model.IRSECallback;
import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
public class TestRemoteSystemProxy implements IRemoteSystemProxy {
+
+ private LTTngToolsFileShell fShell = null;
+ private String fTestFile = null;
+ private String fScenario = null;
@Override
public IShellService getShellService() {
@Override
public void disconnect() throws ExecutionException {
+ fShell = null;
}
@Override
public ICommandShell createCommandShell() throws ExecutionException {
- ICommandShell shell = CommandShellFactory.getInstance().getShellForSessionNames();
- return shell;
+ if (fShell == null) {
+ fShell = CommandShellFactory.getInstance().getFileShell();
+ if ((fTestFile != null) && (fScenario != null)) {
+ try {
+ fShell.loadScenarioFile(fTestFile);
+ } catch (Exception e) {
+ throw new ExecutionException(e.toString());
+ }
+ fShell.setScenario(fScenario);
+ }
+ }
+ return fShell;
}
@Override
@Override
public void removeCommunicationListener(ICommunicationsListener listener) {
}
-
+
+ public void setTestFile(String testFile) {
+ fTestFile = testFile;
+ }
+
+ public void setScenario(String scenario) {
+ fScenario = scenario;
+ if (fShell != null) {
+ fShell.setScenario(fScenario);
+ }
+ }
}
+++ /dev/null
-package org.eclipse.linuxtools.lttng.stubs.service.shells;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.linuxtools.lttng.ui.views.control.service.CommandResult;
-import org.eclipse.linuxtools.lttng.ui.views.control.service.ICommandResult;
-
-public class GetSessionGarbageShell extends TestCommandShell {
- @SuppressWarnings("nls")
- @Override
- public ICommandResult executeCommand(String command, IProgressMonitor monitor, boolean checkReturnValue) throws ExecutionException {
- String[] output = new String[2];
- //Session test not found
- //Error: Session name not found
- output[0] = String.valueOf("asdfaereafsdcv 12333456434&*89**(())(^%$*");
- output[1] = String.valueOf("@#$%^&*()@#$%^&*()0834523094578kj;djkfs");
- return new CommandResult(0, output);
- }
-}
-
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng.stubs.service.shells;
+
+import java.io.BufferedReader;
+import java.io.DataInputStream;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.linuxtools.lttng.ui.views.control.service.CommandResult;
+import org.eclipse.linuxtools.lttng.ui.views.control.service.ICommandResult;
+
+public class LTTngToolsFileShell extends TestCommandShell {
+
+ // ------------------------------------------------------------------------
+ // CONSTANTS
+ // ------------------------------------------------------------------------
+ private final static String SCENARIO_KEY = "<SCENARIO>"; //$NON-NLS-1$
+ private final static String SCENARIO_END_KEY = "</SCENARIO>"; //$NON-NLS-1$
+ private final static String INPUT_KEY = "<COMMAND_INPUT>"; //$NON-NLS-1$
+ private final static String INPUT_END_KEY = "</COMMAND_INPUT>"; //$NON-NLS-1$
+ private final static String RESULT_KEY = "<COMMAND_RESULT>"; //$NON-NLS-1$
+ @SuppressWarnings("unused")
+ private final static String RESULT_END_KEY = "</COMMAND_RESULT>"; //$NON-NLS-1$
+ private final static String OUTPUT_KEY = "<COMMAND_OUTPUT>"; //$NON-NLS-1$
+ private final static String OUTPUT_END_KEY = "</COMMAND_OUTPUT>"; //$NON-NLS-1$
+ private final static String COMMENT_KEY = "#.*"; //$NON-NLS-1$
+
+ private final static Pattern LTTNG_LIST_SESSION_PATTERN = Pattern.compile("lttng\\s+list\\s+(.+)"); //$NON-NLS-1$
+ private final static String LTTNG_LIST_PROVIDER_PATTERN = "lttng\\s+list\\s+(-u|-k)"; //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ private String fScenariofile;
+ private String fScenario;
+
+ private Map<String, Map<String, ICommandResult>> fScenarioMap = new HashMap<String, Map<String, ICommandResult>>();
+ private Map<String, Integer> fSessionNameMap = new HashMap<String, Integer>();
+
+ /**
+ * Parse a scenario file with the format:
+ * <SCENARIO>
+ * ScenarioName
+ *
+ * <COMMAND_INPUT>
+ * Command
+ * </COMAND_INPUT>
+ *
+ * <COMMAND_RESULT>
+ * CommandResult
+ * </COMMAND_RESULT>
+ *
+ * <COMMAND_OUTPUT>
+ * CommandOutput
+ * </COMMAND_OUTPUT>
+ *
+ * </SCENARIO>
+ *
+ * Where: ScenarioName - is the scenario name
+ * Command - the command line string
+ * CommandResult - the result integer of the command (0 for success, 1 for failure)
+ * ComandOutput - the command output string (multi-line possible)
+ *
+ * Note: 1) There can be many scenarios per file
+ * 2) There can be many (Command-CommandResult-CommandOutput) triples per scenario
+ * 3) Lines starting with # will be ignored (comments)
+ *
+ * @param scenariofile - path to scenario file
+ * @throws Exception
+ */
+ public void loadScenarioFile(String scenariofile) throws Exception {
+ fScenariofile = scenariofile;
+
+ // clean up map
+ Collection<Map<String, ICommandResult>> values = fScenarioMap.values();
+ for (Iterator<Map<String, ICommandResult>> iterator = values.iterator(); iterator.hasNext();) {
+ Map<String, ICommandResult> map = (Map<String, ICommandResult>) iterator.next();
+ map.clear();
+ }
+ fScenarioMap.clear();
+
+ // load from file
+
+ // Open the file
+ FileInputStream fstream = new FileInputStream(fScenariofile);
+
+ // Get the object of DataInputStream
+ DataInputStream in = new DataInputStream(fstream);
+ BufferedReader br = new BufferedReader(new InputStreamReader(in));
+ String strLine;
+
+ // Read File Line by Line
+
+ // Temporary map for generating instance numbers for lttng list <session> commands.
+ // The numbers are per scenario.
+ Map<String, Integer> tmpSessionNameMap = new HashMap<String, Integer>();
+ while ((strLine = br.readLine()) != null) {
+
+ // Ignore comments
+ if(isComment(strLine)) {
+ continue;
+ }
+
+ if (SCENARIO_KEY.equals(strLine)) {
+ // scenario start
+
+ // Ignore comments
+ strLine = br.readLine();
+ while (isComment(strLine)) {
+ strLine = br.readLine();
+ }
+
+ String scenario = strLine;
+ Map<String, ICommandResult> commandMap = new HashMap<String, ICommandResult>();
+ fScenarioMap.put(scenario, commandMap);
+ List<String> output = null;
+ String input = null;
+ boolean inOutput = false;
+ int result = 0;
+ tmpSessionNameMap.clear();
+ while ((strLine = br.readLine()) != null) {
+ // Ignore comments
+ if(isComment(strLine)) {
+ continue;
+ }
+
+ if (SCENARIO_END_KEY.equals(strLine)) {
+ // Scenario is finished
+ break;
+ }
+ if (INPUT_KEY.equals(strLine)) {
+ strLine = br.readLine();
+ // Ignore comments
+ while (isComment(strLine)) {
+ strLine = br.readLine();
+ }
+ // Read command
+ input = strLine;
+
+ // Handle instances of 'lttng list <session"-comamand
+ Matcher matcher = LTTNG_LIST_SESSION_PATTERN.matcher(strLine);
+ if (matcher.matches() && !input.matches(LTTNG_LIST_PROVIDER_PATTERN)) {
+ String sessionName = matcher.group(1).trim();
+ Integer i = tmpSessionNameMap.get(sessionName);
+ if (i != null) {
+ i++;
+ } else {
+ i = 0;
+ }
+ tmpSessionNameMap.put(sessionName, i);
+ input += String.valueOf(i);
+ }
+ } else if (INPUT_END_KEY.equals(strLine)) {
+ // Initialize output array
+ output = new ArrayList<String>();
+ } else if (RESULT_KEY.equals(strLine)) {
+ strLine = br.readLine();
+ // Ignore comments
+ while (isComment(strLine)) {
+ strLine = br.readLine();
+ }
+ // Save result value
+ result = Integer.parseInt(strLine);
+ } else if (OUTPUT_END_KEY.equals(strLine)) {
+ // Save output/result in command map
+ commandMap.put(input, new CommandResult(result, output.toArray(new String[output.size()])));
+ inOutput = false;
+ } else if (OUTPUT_KEY.equals(strLine)) {
+ // first line of output
+ inOutput = true;
+ strLine = br.readLine();
+
+ // Ignore comments
+ while (isComment(strLine)) {
+ strLine = br.readLine();
+ }
+ output.add(strLine);
+ } else if (inOutput) {
+ // subsequent lines of output
+ output.add(strLine);
+ }
+// else {
+// if (RESULT_END_KEY.equals(strLine)) {
+ // nothing to do
+// }
+ }
+ }
+ }
+ //Close the input stream
+ in.close();
+ }
+
+ // Set the scenario to consider in executeCommand()
+ public synchronized void setScenario(String scenario) {
+ fScenario = scenario;
+ fSessionNameMap.clear();
+ if (!fScenarioMap.containsKey(fScenario)) {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.stubs.service.shells.TestCommandShell#executeCommand(java.lang.String, org.eclipse.core.runtime.IProgressMonitor, boolean)
+ */
+ @SuppressWarnings("nls")
+ @Override
+ public ICommandResult executeCommand(String command, IProgressMonitor monitor, boolean checkReturnValue) throws ExecutionException {
+ Map<String, ICommandResult> commands = fScenarioMap.get(fScenario);
+
+ Matcher matcher = LTTNG_LIST_SESSION_PATTERN.matcher(command);
+ if (matcher.matches() && !command.matches(LTTNG_LIST_PROVIDER_PATTERN)) {
+ String sessionName = matcher.group(1).trim();
+ Integer i = fSessionNameMap.get(sessionName);
+ if (i != null) {
+ i++;
+ } else {
+ i = 0;
+ }
+ fSessionNameMap.put(sessionName, i);
+ command += String.valueOf(i);
+ }
+
+ if (commands.containsKey(command)) {
+ return commands.get(command);
+ }
+
+ String[] output = new String[1];
+ output[0] = String.valueOf("Command not found");
+ return new CommandResult(1, output);
+ }
+
+ // ------------------------------------------------------------------------
+ // Helper methods
+ // ------------------------------------------------------------------------
+ private boolean isComment(String line) {
+ return line.matches(COMMENT_KEY);
+ }
+}
+++ /dev/null
-package org.eclipse.linuxtools.lttng.stubs.service.shells;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.linuxtools.lttng.ui.views.control.service.CommandResult;
-import org.eclipse.linuxtools.lttng.ui.views.control.service.ICommandResult;
-
-public class LttngNotExistsShell extends TestCommandShell {
-
- @SuppressWarnings("nls")
- @Override
- public ICommandResult executeCommand(String command, IProgressMonitor monitor, boolean checkReturnValue) throws ExecutionException {
- String[] output = new String[1];
- output[0] = String.valueOf("Command not found");
- return new CommandResult(1, output);
- }
-}
+++ /dev/null
-package org.eclipse.linuxtools.lttng.stubs.service.shells;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.linuxtools.lttng.ui.views.control.service.CommandResult;
-import org.eclipse.linuxtools.lttng.ui.views.control.service.ICommandResult;
-
-public class NoSessionNamesShell extends TestCommandShell {
-
- @SuppressWarnings("nls")
- @Override
- public ICommandResult executeCommand(String command, IProgressMonitor monitor, boolean checkReturnValue) throws ExecutionException {
- String[] output = new String[1];
- output[0] = String.valueOf("Currently no available tracing session");
- return new CommandResult(0, output);
- }
-}
+++ /dev/null
-package org.eclipse.linuxtools.lttng.stubs.service.shells;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.linuxtools.lttng.ui.views.control.service.CommandResult;
-import org.eclipse.linuxtools.lttng.ui.views.control.service.ICommandResult;
-
-public class NoUstProviderShell extends TestCommandShell {
- @SuppressWarnings("nls")
- @Override
- public ICommandResult executeCommand(String command, IProgressMonitor monitor, boolean checkReturnValue) throws ExecutionException {
- String[] output = new String[4];
- //Session test not found
- //Error: Session name not found
- output[0] = String.valueOf("UST events:");
- output[1] = String.valueOf("-------------");
- output[2] = String.valueOf("None");
- output[3] = String.valueOf("");
- CommandResult result = new CommandResult(0, output);
- result.setResult(0);
- return result;
- }
-}
-
+++ /dev/null
-package org.eclipse.linuxtools.lttng.stubs.service.shells;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.linuxtools.lttng.ui.views.control.service.CommandResult;
-import org.eclipse.linuxtools.lttng.ui.views.control.service.ICommandResult;
-
-public class SessionCreationErrorsShell extends TestCommandShell {
- @SuppressWarnings("nls")
- @Override
- public ICommandResult executeCommand(String command, IProgressMonitor monitor, boolean checkReturnValue) throws ExecutionException {
- if ("lttng create alreadyExist".equals(command)) {
- String[] output = new String[1];
- //Error: Session name already exist
- output[0] = String.valueOf("Error: Session name already exist");
- return new CommandResult(1, output);
- } else if("lttng create \"session with spaces\"".equals(command)) {
- List<String> list = new ArrayList<String>();
- list.add("Session session with spaces created.");
- list.add("Traces will be written in /home/user/lttng-traces/session with spaces-20120209-095418");
- return new CommandResult(0, list.toArray(new String[list.size()]));
- } else if ("lttng create wrongName".equals(command)) {
- List<String> list = new ArrayList<String>();
- list.add("Session auto created.");
- list.add("Traces will be written in /home/user/lttng-traces/auto-20120209-095418");
- return new CommandResult(0, list.toArray(new String[list.size()]));
- } else if ("lttng create wrongPath -o /home/user/hallo".equals(command)) {
- List<String> list = new ArrayList<String>();
- list.add("Session wrongPath created.");
- list.add("Traces will be written in /home/user/lttng-traces/wrongPath-20120209-095418");
- return new CommandResult(0, list.toArray(new String[list.size()]));
- } else if ("lttng create pathWithSpaces -o \"/home/user/hallo user/here\"".equals(command)) {
- List<String> list = new ArrayList<String>();
- list.add("Session pathWithSpaces created.");
- list.add("Traces will be written in /home/user/hallo user/here/pathWithSpaces-20120209-095418");
- return new CommandResult(0, list.toArray(new String[list.size()]));
- }
-
- String[] output = new String[1];
- output[0] = String.valueOf("Command not found");
- return new CommandResult(1, output);
- }
-}
-
+++ /dev/null
-package org.eclipse.linuxtools.lttng.stubs.service.shells;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.linuxtools.lttng.ui.views.control.service.CommandResult;
-import org.eclipse.linuxtools.lttng.ui.views.control.service.ICommandResult;
-
-public class SessionNamesShell extends TestCommandShell {
- @SuppressWarnings("nls")
- @Override
- public ICommandResult executeCommand(String command, IProgressMonitor monitor, boolean checkReturnValue) throws ExecutionException {
- if ("lttng list ".equals(command)) {
- String[] output = new String[5];
- output[0] = String.valueOf("Available tracing sessions:");
- output[1] = String.valueOf(" 1) mysession1 (/home/user/lttng-traces/mysession1-20120123-083928) [inactive]");
- output[2] = String.valueOf(" 2) mysession (/home/user/lttng-traces/mysession-20120123-083318) [inactive]");
- output[3] = String.valueOf("");
- output[4] = String.valueOf(" Use lttng list <session_name> for more details");
- // test constructor with null pointer parameter
- CommandResult result = new CommandResult(0, null);
- // test setOutput!!!
- result.setOutput(output);
- return result;
- } else if ("lttng list mysession".equals(command)) {
- List<String> list = new ArrayList<String>();
- list.add("Tracing session mysession: [active]");
- list.add(" Trace path: /home/user/lttng-traces/mysession-20120129-084256");
- list.add("");
- list.add("=== Domain: Kernel ===");
- list.add("");
- list.add("Channels:");
- list.add("-------------");
- list.add("- channel0: [enabled]");
- list.add("");
- list.add(" Attributes:");
- list.add(" overwrite mode: 0");
- list.add(" subbufers size: 262144");
- list.add(" number of subbufers: 4");
- list.add(" switch timer interval: 0");
- list.add(" read timer interval: 200");
- list.add(" output: splice()");
- list.add("");
- list.add(" Events:");
- list.add(" block_rq_remap (loglevel: TRACE_EMERG (0)) (type: tracepoint) [enabled]");
- list.add(" block_bio_remap (loglevel: TRACE_EMERG (0)) (type: tracepoint) [disabled]");
- list.add("");
- list.add("- channel1: [disabled]");
- list.add("");
- list.add(" Attributes:");
- list.add(" overwrite mode: 1");
- list.add(" subbufers size: 524288");
- list.add(" number of subbufers: 4");
- list.add(" switch timer interval: 100");
- list.add(" read timer interval: 400");
- list.add(" output: splice()");
- list.add("");
- list.add(" Events:");
- list.add(" None");
- list.add("");
- list.add("=== Domain: UST global ===");
- list.add("");
- list.add("Channels:");
- list.add("-------------");
- list.add("- mychannel1: [disabled]");
- list.add("");
- list.add(" Attributes:");
- list.add(" overwrite mode: 1");
- list.add(" subbufers size: 8192");
- list.add(" number of subbufers: 8");
- list.add(" switch timer interval: 200");
- list.add(" read timer interval: 100");
- list.add(" output: mmap()");
- list.add("");
- list.add(" Events:");
- list.add(" None");
- list.add("");
- list.add("- channel0: [enabled]");
- list.add("");
- list.add(" Attributes:");
- list.add(" overwrite mode: 0");
- list.add(" subbufers size: 4096");
- list.add(" number of subbufers: 4");
- list.add(" switch timer interval: 0");
- list.add(" read timer interval: 200");
- list.add(" output: mmap()");
- list.add("");
- list.add(" Events:");
- list.add(" ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_LINE (13)) (type: tracepoint) [disabled]");
- list.add(" * (type: tracepoint) [enabled]");
- list.add("");
- return new CommandResult(0, list.toArray(new String[list.size()]));
- } else if ("lttng list -u".equals(command)) {
- List<String> list = new ArrayList<String>();
- list.add("UST events:");
- list.add("-------------");
- list.add("");
- list.add("PID: 9379 - Name: /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello");
- list.add(" ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_MODULE (10)) (type: tracepoint)");
- list.add(" ust_tests_hello:tptest (loglevel: TRACE_INFO (6)) (type: tracepoint)");
- list.add("");
- list.add("PID: 4852 - Name: /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello");
- list.add(" ust_tests_hello:tptest_sighandler (loglevel: TRACE_WARNING (4)) (type: tracepoint)");
- list.add(" ust_tests_hello:tptest (loglevel: TRACE_DEBUG_FUNCTION (12)) (type: tracepoint)");
- list.add("");
- return new CommandResult(0, list.toArray(new String[list.size()]));
- } else if ("lttng list -k".equals(command)) {
- List<String> list = new ArrayList<String>();
- list.add("Kernel events:");
- list.add("-------------");
- list.add(" sched_kthread_stop (loglevel: TRACE_EMERG (0)) (type: tracepoint)");
- list.add(" sched_kthread_stop_ret (loglevel: TRACE_EMERG (0)) (type: tracepoint)");
- list.add(" sched_wakeup_new (loglevel: TRACE_EMERG (0)) (type: tracepoint)");
- list.add("");
- return new CommandResult(0, list.toArray(new String[list.size()]));
- } else if ("lttng list mysession1".equals(command)) {
- List<String> list = new ArrayList<String>();
- list.add("Tracing session mysession1: [inactive]");
- list.add(" Trace path: /home/user/lttng-traces/mysession1-20120203-133225");
- list.add("");
- return new CommandResult(0, list.toArray(new String[list.size()]));
- } else if ("lttng create mysession2".equals(command)) {
- List<String> list = new ArrayList<String>();
- list.add("Session mysession2 created.");
- list.add("Traces will be written in /home/user/lttng-traces/mysession2-20120209-095418");
- return new CommandResult(0, list.toArray(new String[list.size()]));
- } else if ("lttng destroy mysession2".equals(command)) {
- List<String> list = new ArrayList<String>();
- list.add("Session mysession2 destrioyed.");
- return new CommandResult(0, list.toArray(new String[list.size()]));
- }
-
- String[] output = new String[1];
- output[0] = String.valueOf("Command not found");
- return new CommandResult(1, output);
- }
-}
+++ /dev/null
-package org.eclipse.linuxtools.lttng.stubs.service.shells;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.linuxtools.lttng.ui.views.control.service.CommandResult;
-import org.eclipse.linuxtools.lttng.ui.views.control.service.ICommandResult;
-
-public class SessionNotExistsShell extends TestCommandShell {
- @SuppressWarnings("nls")
- @Override
- public ICommandResult executeCommand(String command, IProgressMonitor monitor, boolean checkReturnValue) throws ExecutionException {
- String[] output = new String[2];
- //Session test not found
- //Error: Session name not found
- output[0] = String.valueOf("Session test not found");
- output[1] = String.valueOf("Error: Session name not found");
- return new CommandResult(1, output);
- }
-}
-
--- /dev/null
+####################################################################
+# Copyright (c) 2012 Ericsson
+#
+# All rights reserved. This program and the accompanying materials are
+# made available under the terms of the Eclipse Public License v1.0 which
+# accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Bernd Hufmann - Initial API and implementation
+####################################################################
+####################################################################
+# Scenario: Test no sessions available
+####################################################################
+<SCENARIO>
+Initialize
+<COMMAND_INPUT>
+lttng list
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Currently no available tracing session
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng list -k
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Kernel events
+-------------
+ sched_kthread_stop (loglevel: TRACE_EMERG (0)) (type: tracepoint)
+ sched_kthread_stop_ret (loglevel: TRACE_EMERG (0)) (type: tracepoint)
+ sched_wakeup_new (loglevel: TRACE_EMERG (0)) (type: tracepoint)
+
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng list -u
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+UST events:
+-------------
+
+PID: 9379 - Name: /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
+ ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_MODULE (10)) (type: tracepoint)
+ ust_tests_hello:tptest (loglevel: TRACE_INFO (6)) (type: tracepoint)
+
+PID: 4852 - Name: /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
+ ust_tests_hello:tptest_sighandler (loglevel: TRACE_WARNING (4)) (type: tracepoint)
+ ust_tests_hello:tptest (loglevel: TRACE_DEBUG_FUNCTION (12)) (type: tracepoint)
+
+</COMMAND_OUTPUT>
+</SCENARIO>
+
+####################################################################
+# Scenario: Enable events from kernel provider events
+####################################################################
+<SCENARIO>
+Scenario1
+<COMMAND_INPUT>
+lttng create mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Session mysession created.
+Traces will be written in /home/user/lttng-traces/mysession-20120314-132824
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng list mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Tracing session mysession: [inactive]
+ Trace path: /home/user/lttng-traces/mysession-20120314-132824
+
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng enable-event sched_kthread_stop,sched_kthread_stop_ret -k -s mysession --tracepoint
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+kernel event sched_kthread_stop created in channel channel0
+kernel sched_kthread_stop_ret created in channel channel0
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng list mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Tracing session mysession: [inactive]
+ Trace path: /home/user/lttng-traces/mysession-20120314-132824
+
+=== Domain: Kernel ===
+
+Channels:
+-------------
+- channel0: [enabled]
+
+ Attributes:
+ overwrite mode: 0
+ subbufers size: 262144
+ number of subbufers: 4
+ switch timer interval: 0
+ read timer interval: 200
+ output: splice()
+
+ Events:
+ sched_kthread_stop_ret (loglevel: TRACE_EMERG (0)) (type: tracepoint) [enabled]
+ sched_kthread_stop (loglevel: TRACE_EMERG (0)) (type: tracepoint) [enabled]
+
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng disable-event sched_kthread_stop_ret,sched_kthread_stop -k -s mysession -c channel0
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+kernel event sched_kthread_stop_ret disabled in channel channel0
+kernel event sched_kthread_stop disabled in channel channel0
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng enable-event sched_kthread_stop -k -s mysession -c channel0 --tracepoint
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+kernel event sched_kthread_stop enabled in channel channel0
+</COMMAND_OUTPUT>
+
+
+<COMMAND_INPUT>
+lttng destroy mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Session mysession destroyed.
+</COMMAND_OUTPUT>
+
+</SCENARIO>
+
+####################################################################
+# Scenario: Enable events from UST provider events
+####################################################################
+<SCENARIO>
+Scenario2
+<COMMAND_INPUT>
+lttng create mysession -o /home/user/temp
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Session mysession created.
+Traces will be written in /home/user/temp
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng list mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Tracing session mysession: [inactive]
+ Trace path: /home/user/temp
+
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng enable-channel mychannel -u -s mysession --subbuf-size 16384 --num-subbuf 2 --switch-timer 200 --read-timer 100
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+UST channel mychannel enabled for session mysession
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng list mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Tracing session mysession: [inactive]
+ Trace path: /home/user/temp
+
+=== Domain: UST global ===
+
+Channels:
+-------------
+- mychannel: [enabled]
+
+ Attributes:
+ overwrite mode: 0
+ subbufers size: 16384
+ number of subbufers: 2
+ switch timer interval: 200
+ read timer interval: 100
+ output: mmap()
+
+ Events:
+ None
+
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng enable-event ust_tests_hello:tptest_sighandler,ust_tests_hello:tptest -u -s mysession --tracepoint
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+UST event ust_tests_hello:tptest_sighandler in channel channel0
+UST sched_ust_tests_hello:tptest created in channel channel0
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng list mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Tracing session mysession: [inactive]
+ Trace path: /home/user/temp
+
+=== Domain: UST global ===
+
+Channels:
+-------------
+- mychannel: [enabled]
+
+ Attributes:
+ overwrite mode: 0
+ subbufers size: 16384
+ number of subbufers: 2
+ switch timer interval: 200
+ read timer interval: 100
+ output: mmap()
+
+ Events:
+ ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_LINE (13)) (type: tracepoint) [enabled]
+ ust_tests_hello:tptest (loglevel: TRACE_DEBUG_LINE (13)) (type: tracepoint) [enabled]
+
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng disable-event ust_tests_hello:tptest -u -s mysession -c mychannel
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+kernel event ust_tests_hello:tptest in channel mychannel
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng enable-event ust_tests_hello:tptest -u -s mysession -c mychannel --tracepoint
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+kernel event ust_tests_hello:tptest enabled in channel mychannel
+</COMMAND_OUTPUT>
+
+
+<COMMAND_INPUT>
+lttng destroy mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Session mysession destroyed.
+</COMMAND_OUTPUT>
+
+</SCENARIO>
+
--- /dev/null
+####################################################################
+# Copyright (c) 2012 Ericsson
+#
+# All rights reserved. This program and the accompanying materials are
+# made available under the terms of the Eclipse Public License v1.0 which
+# accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Bernd Hufmann - Initial API and implementation
+####################################################################
+####################################################################
+# Scenario: Test lttng not installed
+####################################################################
+<SCENARIO>
+LttngNotInstalled
+<COMMAND_INPUT>
+lttng list
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+1
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Command not found
+</COMMAND_OUTPUT>
+</SCENARIO>
+
+####################################################################
+# Scenario: Test no sessions available
+####################################################################
+<SCENARIO>
+NoSessionAvailable
+<COMMAND_INPUT>
+lttng list
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Currently no available tracing session
+</COMMAND_OUTPUT>
+</SCENARIO>
+
+####################################################################
+# Scenario: Test get sessions
+####################################################################
+<SCENARIO>
+GetSessionNames1
+<COMMAND_INPUT>
+lttng list
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Available tracing sessions:
+ 1) mysession1 (/home/user/lttng-traces/mysession1-20120123-083928) [inactive]
+ 2) mysession (/home/user/lttng-traces/mysession-20120123-083318) [inactive]
+
+ Use lttng list <session_name> for more details
+</COMMAND_OUTPUT>
+</SCENARIO>
+
+####################################################################
+# Scenario: Test lttng list <name> where session doesn't exist
+####################################################################
+<SCENARIO>
+GetSessionNameNotExist
+<COMMAND_INPUT>
+lttng list test
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+1
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Session test not found
+Error: Session name not found
+</COMMAND_OUTPUT>
+</SCENARIO>
+
+####################################################################
+# Scenario: Test lttng list with garbage output
+####################################################################
+<SCENARIO>
+GetSessionGarbageOut
+<COMMAND_INPUT>
+lttng list
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+asdfaereafsdcv 12333456434&*89**(())(^%$*
+@#$%^&*()@#$%^&*()0834523094578kj;djkfs
+a;sdf094v5u dsafj;sd9
+</COMMAND_OUTPUT>
+</SCENARIO>
+
+####################################################################
+# Scenario: Test lttng list <name> with sample outputs
+####################################################################
+<SCENARIO>
+GetSession1
+<COMMAND_INPUT>
+lttng list mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Tracing session mysession: [active]
+ Trace path: /home/user/lttng-traces/mysession-20120129-084256
+
+=== Domain: Kernel ===
+
+Channels:
+-------------
+- channel0: [enabled]
+
+ Attributes:
+ overwrite mode: 0
+ subbufers size: 262144
+ number of subbufers: 4
+ switch timer interval: 0
+ read timer interval: 200
+ output: splice()
+
+ Events:
+ block_rq_remap (loglevel: TRACE_EMERG (0)) (type: tracepoint) [enabled]
+ block_bio_remap (loglevel: TRACE_EMERG (0)) (type: tracepoint) [disabled]
+
+- channel1: [disabled]
+
+ Attributes:
+ overwrite mode: 1
+ subbufers size: 524288
+ number of subbufers: 4
+ switch timer interval: 100
+ read timer interval: 400
+ output: splice()
+
+ Events:
+ None
+
+=== Domain: UST global ===
+
+Channels:
+-------------
+- mychannel1: [disabled]
+
+ Attributes:
+ overwrite mode: 1
+ subbufers size: 8192
+ number of subbufers: 8
+ switch timer interval: 200
+ read timer interval: 100
+ output: mmap()
+
+ Events:
+ None
+
+- channel0: [enabled]
+
+ Attributes:
+ overwrite mode: 0
+ subbufers size: 4096
+ number of subbufers: 4
+ switch timer interval: 0
+ read timer interval: 200
+ output: mmap()
+
+ Events:
+ ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_LINE (13)) (type: tracepoint) [disabled]
+ * (type: tracepoint) [enabled]
+
+</COMMAND_OUTPUT>
+<COMMAND_INPUT>
+lttng list mysession1
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Tracing session mysession1: [inactive]
+ Trace path: /home/user/lttng-traces/mysession1-20120203-133225
+
+</COMMAND_OUTPUT>
+</SCENARIO>
+
+
+####################################################################
+# Scenario: Test "lttng list -k" with sample output
+####################################################################
+<SCENARIO>
+GetKernelProvider1
+<COMMAND_INPUT>
+lttng list -k
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Kernel events
+-------------
+ sched_kthread_stop (loglevel: TRACE_EMERG (0)) (type: tracepoint)
+ sched_kthread_stop_ret (loglevel: TRACE_EMERG (0)) (type: tracepoint)
+ sched_wakeup_new (loglevel: TRACE_EMERG (0)) (type: tracepoint)
+
+</COMMAND_OUTPUT>
+</SCENARIO>
+
+####################################################################
+# Scenario: Test "lttng list -u" with sample output
+####################################################################
+<SCENARIO>
+GetUstProvider1
+<COMMAND_INPUT>
+lttng list -u
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+UST events:
+-------------
+
+PID: 9379 - Name: /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
+ ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_MODULE (10)) (type: tracepoint)
+ ust_tests_hello:tptest (loglevel: TRACE_INFO (6)) (type: tracepoint)
+
+PID: 4852 - Name: /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
+ ust_tests_hello:tptest_sighandler (loglevel: TRACE_WARNING (4)) (type: tracepoint)
+ ust_tests_hello:tptest (loglevel: TRACE_DEBUG_FUNCTION (12)) (type: tracepoint)
+
+</COMMAND_OUTPUT>
+</SCENARIO>
+
+####################################################################
+# Scenario: Test "lttng list -u" with no UST provider available
+####################################################################
+<SCENARIO>
+GetUstProvider2
+<COMMAND_INPUT>
+lttng list -u
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+UST events:
+-------------
+None
+
+</COMMAND_OUTPUT>
+</SCENARIO>
+
+####################################################################
+# Scenario: Test "lttng create <session>
+####################################################################
+<SCENARIO>
+CreateSession1
+<COMMAND_INPUT>
+lttng create mysession2
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Session mysession2 created.
+Traces will be written in /home/user/lttng-traces/mysession2-20120209-095418
+</COMMAND_OUTPUT>
+</SCENARIO>
+
+####################################################################
+# Scenario: Test "lttng create <session> with different variants
+# and errors
+####################################################################
+<SCENARIO>
+CreateSessionVariants
+<COMMAND_INPUT>
+lttng create alreadyExist
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+1
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Error: Session name already exist
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng create "session with spaces"
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Session session with spaces created.
+Traces will be written in /home/user/lttng-traces/session with spaces-20120209-095418
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng create wrongName
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Session auto created.
+Traces will be written in /home/user/lttng-traces/auto-20120209-095418
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng create wrongPath -o /home/user/hallo
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Session wrongPath created.
+Traces will be written in /home/user/lttng-traces/wrongPath-20120209-095418
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng create pathWithSpaces -o "/home/user/hallo user/here"
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Session pathWithSpaces created.
+Traces will be written in /home/user/hallo user/here/pathWithSpaces-20120209-095418
+</COMMAND_OUTPUT>
+</SCENARIO>
+
+####################################################################
+# Scenario: Test "lttng destroy <session>
+####################################################################
+
+<SCENARIO>
+DestroySession1
+<COMMAND_INPUT>
+lttng destroy mysession2
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Session mysession2 destroyed.
+</COMMAND_OUTPUT>
+</SCENARIO>
+
+####################################################################
+# Scenario: Test "lttng enable-channel ..." with different inputs
+####################################################################
+
+<SCENARIO>
+ChannelHandling
+<COMMAND_INPUT>
+lttng enable-channel mychannel0,mychannel1 -k -s mysession2 --overwrite --subbuf-size 16384 --num-subbuf 2 --switch-timer 200 --read-timer 100
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Kernel channel mychannel0 enabled for session mysession2
+Kernel channel mychannel1 enabled for session mysession2
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng enable-channel ustChannel -u -s mysession2 --overwrite --subbuf-size 32768 --num-subbuf 1 --switch-timer 100 --read-timer 200
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+UST channel channel0 enabled for session mysession2
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng enable-channel mychannel0,mychannel1 -k -s mysession2
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Kernel channel mychannel0 enabled for session mysession2
+Kernel channel mychannel1 enabled for session mysession2
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng enable-channel ustChannel -u -s mysession2
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+UST channel mychannel0 enabled for session mysession2
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng disable-channel mychannel0,mychannel1 -k -s mysession2
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Kernel channel mychannel0 disabled for session mysession2
+Kernel channel mychannel1 disabled for session mysession2
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng disable-channel ustChannel -u -s mysession2
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+UST channel mychannel0 enabled for session mysession2
+</COMMAND_OUTPUT>
+</SCENARIO>
+
+
+####################################################################
+# Scenario: Test "lttng enable-events ..." with different inputs
+####################################################################
+<SCENARIO>
+EventHandling
+
+# Tracepoint test cases
+
+<COMMAND_INPUT>
+lttng enable-event block_rq_remap,block_bio_remap,softirq_entry -k -s mysession2 --tracepoint
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+kernel event block_rq_remap created in channel channel0
+kernel event block_bio_remap created in channel channel0
+kernel event softirq_entry created in channel channel0
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng enable-event -a -k -s mysession2 -c mychannel --tracepoint
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+All kernel tracepoints are enabled in channel channel0
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng enable-event ust_tests_hello:tptest_sighandler -u -s mysession2 -c mychannel --tracepoint
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+UST event ust_tests_hello:tptest_sighandler created in channel mychannel
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng enable-event -a -u -s mysession2 -c mychannel --tracepoint
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+All UST tracepoints are enabled in channel mychannel
+</COMMAND_OUTPUT>
+
+# Syscall test cases
+
+<COMMAND_INPUT>
+lttng enable-event -a -k -s mysession2 --syscall
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+All kernel system calls are enabled in channel channel0
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng enable-event -a -k -s mysession2 -c mychannel --syscall
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+All kernel system calls are enabled in channel mychannel
+</COMMAND_OUTPUT>
+
+# dynamic probe/function probe test cases
+
+<COMMAND_INPUT>
+lttng enable-event myevent0 -k -s mysession2 --function 0xc0101340
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+kernel event myevent0 created in channel mychannel
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng enable-event myevent1 -k -s mysession2 -c mychannel --probe init_post
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+kernel event myevent1 created in channel mychannel
+</COMMAND_OUTPUT>
+
+# log level test cases
+
+<COMMAND_INPUT>
+lttng enable-event myevent4 -u -s mysession2 --loglevel-only TRACE_DEBUG
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+UST event myevent4 created in channel channel0
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng enable-event myevent5 -u -s mysession2 -c mychannel --loglevel TRACE_DEBUG_FUNCTION
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+UST event myevent5 created in channel mychannel
+</COMMAND_OUTPUT>
+
+</SCENARIO>
+
+
--- /dev/null
+####################################################################
+# Copyright (c) 2012 Ericsson
+#
+# All rights reserved. This program and the accompanying materials are
+# made available under the terms of the Eclipse Public License v1.0 which
+# accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Bernd Hufmann - Initial API and implementation
+####################################################################
+####################################################################
+# Scenario: Test lttng list <name> with sample outputs
+####################################################################
+<SCENARIO>
+ListInfoTest
+<COMMAND_INPUT>
+lttng list
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Available tracing sessions:
+ 1) mysession1 (/home/user/lttng-traces/mysession1-20120123-083928) [inactive]
+ 2) mysession (/home/user/lttng-traces/mysession-20120123-083318) [inactive]
+
+ Use lttng list <session_name> for more details
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng list mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Tracing session mysession: [active]
+ Trace path: /home/user/lttng-traces/mysession-20120129-084256
+
+=== Domain: Kernel ===
+
+Channels:
+-------------
+- channel0: [enabled]
+
+ Attributes:
+ overwrite mode: 0
+ subbufers size: 262144
+ number of subbufers: 4
+ switch timer interval: 0
+ read timer interval: 200
+ output: splice()
+
+ Events:
+ block_rq_remap (loglevel: TRACE_EMERG (0)) (type: tracepoint) [enabled]
+ block_bio_remap (loglevel: TRACE_EMERG (0)) (type: tracepoint) [disabled]
+ myevent2 (type: probe) [enabled]
+ addr: 0xc0101340
+ myevent0 (type: probe) [enabled]
+ offset: 0x0
+ symbol: init_post
+ syscalls (type: syscall) [enabled]
+
+- channel1: [disabled]
+
+ Attributes:
+ overwrite mode: 1
+ subbufers size: 524288
+ number of subbufers: 4
+ switch timer interval: 100
+ read timer interval: 400
+ output: splice()
+
+ Events:
+ None
+
+=== Domain: UST global ===
+
+Channels:
+-------------
+- mychannel1: [disabled]
+
+ Attributes:
+ overwrite mode: 1
+ subbufers size: 8192
+ number of subbufers: 8
+ switch timer interval: 200
+ read timer interval: 100
+ output: mmap()
+
+ Events:
+ None
+
+- channel0: [enabled]
+
+ Attributes:
+ overwrite mode: 0
+ subbufers size: 4096
+ number of subbufers: 4
+ switch timer interval: 0
+ read timer interval: 200
+ output: mmap()
+
+ Events:
+ ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_LINE (13)) (type: tracepoint) [disabled]
+ * (type: tracepoint) [enabled]
+
+</COMMAND_OUTPUT>
+<COMMAND_INPUT>
+lttng list mysession1
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Tracing session mysession1: [inactive]
+ Trace path: /home/user/lttng-traces/mysession1-20120203-133225
+
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng list -k
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Kernel events
+-------------
+ sched_kthread_stop (loglevel: TRACE_EMERG (0)) (type: tracepoint)
+ sched_kthread_stop_ret (loglevel: TRACE_EMERG (0)) (type: tracepoint)
+ sched_wakeup_new (loglevel: TRACE_EMERG (0)) (type: tracepoint)
+
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng list -u
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+UST events:
+-------------
+
+PID: 9379 - Name: /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
+ ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_MODULE (10)) (type: tracepoint)
+ ust_tests_hello:tptest (loglevel: TRACE_INFO (6)) (type: tracepoint)
+
+PID: 4852 - Name: /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
+ ust_tests_hello:tptest_sighandler (loglevel: TRACE_WARNING (4)) (type: tracepoint)
+ ust_tests_hello:tptest (loglevel: TRACE_DEBUG_FUNCTION (12)) (type: tracepoint)
+
+</COMMAND_OUTPUT>
+
+</SCENARIO>
commands.control.disconnect=Disconnect
commands.control.discconnect.description=Disconnect to Target Node
+commands.control.refresh=Refresh
+commands.control.refresh.description=Refresh Node Configuration
+
+
commands.control.delete=Delete
commands.control.deleete.description=Delete Target Node
id="org.eclipse.linuxtools.lttng.ui.commands.control.disconnect"
name="%commands.control.disconnect">
</command>
+ <command
+ categoryId="org.eclipse.linuxtools.lttng.ui.commands.control.category"
+ description="%commands.control.refresh.description"
+ id="org.eclipse.linuxtools.lttng.ui.commands.control.refresh"
+ name="%commands.control.refresh">
+ </command>
<command
categoryId="org.eclipse.linuxtools.lttng.ui.commands.control.category"
description="%commands.control.delete.description"
label="%commands.control.disconnect"
style="push">
</command>
+ <command
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.refresh"
+ icon="icons/elcl16/refresh.gif"
+ label="%commands.control.refresh"
+ style="push">
+ </command>
<command
commandId="org.eclipse.linuxtools.lttng.ui.commands.control.delete"
icon="icons/elcl16/target_delete.gif"
</with>
</visibleWhen>
</command>
+ <command
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.refresh"
+ icon="icons/elcl16/refresh.gif"
+ label="%commands.control.refresh"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeMenuSelection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceControlComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
<command
commandId="org.eclipse.linuxtools.lttng.ui.commands.control.delete"
icon="icons/elcl16/target_delete.gif"
</with>
</activeWhen>
</handler>
+ <handler
+ class="org.eclipse.linuxtools.lttng.ui.views.control.handlers.RefreshHandler"
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.refresh">
+ <activeWhen>
+ <with
+ variable="selection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceControlComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </activeWhen>
+ </handler>
<handler
class="org.eclipse.linuxtools.lttng.ui.views.control.handlers.DeleteHandler"
commandId="org.eclipse.linuxtools.lttng.ui.commands.control.delete">
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceControlComponent;
import org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceControlComponentChangedListener;
}
});
}
+
+ /**
+ * Sets the selected component in the tree
+ * @param component - component to select
+ */
+ public void setSelection(ITraceControlComponent component) {
+ StructuredSelection selection = new StructuredSelection(component);
+ fTreeViewer.setSelection(selection);
+ }
+
+ /**
+ * Sets the selected components in the tree
+ * @param component - array of components to select
+ */
+ public void setSelection(ITraceControlComponent[] components) {
+ StructuredSelection selection = new StructuredSelection(components);
+ fTreeViewer.setSelection(selection);
+ }
+
+// public ITraceControlComponent getSelection() {
+// ISelection selection = fTreeViewer.getSelection();
+//
+// }
// ------------------------------------------------------------------------
// Helper methods
public static String TraceControl_SessionPathPropertyName;
public static String TraceControl_ProviderNamePropertyName;
public static String TraceControl_ProcessIdPropertyName;
+ public static String TraceControl_ProbeAddressPropertyName;
+ public static String TraceControl_ProbeOffsetPropertyName;
+ public static String TraceControl_ProbeSymbolPropertyName;
-
-
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.linuxtools.lttng.ui.views.control.dialogs;
+
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.linuxtools.lttng.ui.views.control.Messages;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * <b><u>ConfirmDialog</u></b>
+ * <p>
+ * Confirmation dialog implementation.
+ * </p>
+ */
+
+public class ConfirmDialog implements IConfirmDialog {
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.dialogs.IConfirmDialog#openConfirm(org.eclipse.swt.widgets.Shell, java.lang.String, java.lang.String)
+ */
+ @Override
+ public boolean openConfirm(Shell parent, String title, String message) {
+ return MessageDialog.openConfirm(parent,
+ Messages.TraceControl_DestroyConfirmationTitle,
+ Messages.TraceControl_DestroyConfirmationMessage);
+ }
+}
* @param shell - a shell for the display of the dialog
*/
public CreateChannelDialog(Shell shell) {
- this(shell, null);
- }
-
-
- /**
- * Constructor
- * @param shell - a shell for the display of the dialog
- * @param domain - a domain to create channel on. Use null for creating a channel on session level.
- */
- public CreateChannelDialog(Shell shell, TraceDomainComponent domain) {
- super(shell);
- fDomain = domain;
- if (fDomain != null) {
- fIsKernel = fDomain.isKernel();
- } else {
- fIsKernel = true;
- }
+ super(shell);
+ fIsKernel = true;
// Common verify listener
fVerifyListener = new VerifyListener() {
return fChannelInfo;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.dialogs.ICreateChannelDialog#setDomainComponent(org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceDomainComponent)
+ */
+ @Override
+ public void setDomainComponent(TraceDomainComponent domain) {
+ fDomain = domain;
+ if (fDomain != null) {
+ fIsKernel = fDomain.isKernel();
+ } else {
+ fIsKernel = true;
+ }
+ }
+
/*
* (non-Javadoc)
* @see org.eclipse.linuxtools.lttng.ui.views.control.dialogs.ICreateChannelOnSessionDialog#isKernel()
/**
* Constructor
* @param shell - a shell for the display of the dialog
- * @param parent - trace control parent for validation of session name
*/
- public CreateSessionDialog(Shell shell, TraceSessionGroup parent) {
+ public CreateSessionDialog(Shell shell) {
super(shell);
- fParent = parent;
}
// ------------------------------------------------------------------------
return fIsDefaultPath;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.dialogs.ICreateSessionDialog#setTraceSessionGroup(org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionGroup)
+ */
+ @Override
+ public void setTraceSessionGroup(TraceSessionGroup group) {
+ fParent = group;
+ }
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
* @param shell - a shell for the display of the dialog
* @param providerGroup - the trace provider group
*/
- public EnableEventsDialog(Shell shell, TraceProviderGroup providerGroup) {
- this(shell, providerGroup, null);
- }
-
- /**
- * Constructor
- * @param shell - a shell for the display of the dialog
- * @param providerGroup - a trace provider group
- * @param domain - a domain of the events (null if not known)
- */
- public EnableEventsDialog(Shell shell, TraceProviderGroup providerGroup, TraceDomainComponent domain) {
+ public EnableEventsDialog(Shell shell) {
super(shell);
- fProviderGroup = providerGroup;
setShellStyle(SWT.RESIZE);
- fDomain = domain;
- if (fDomain != null) {
- fIsKernel = fDomain.isKernel();
- } else {
- fIsKernel = true;
- }
}
-
+
// ------------------------------------------------------------------------
// Accessors
// ------------------------------------------------------------------------
public boolean isKernel() {
return fIsKernel;
}
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.dialogs.IEnableEventsDialog#setTraceProviderGroup(org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceProviderGroup)
+ */
+ @Override
+ public void setTraceProviderGroup(TraceProviderGroup providerGroup) {
+ fProviderGroup = providerGroup;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.dialogs.IEnableEventsDialog#setTraceDomainComponent(org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceDomainComponent)
+ */
+ @Override
+ public void setTraceDomainComponent(TraceDomainComponent domain) {
+ fDomain = domain;
+ if (fDomain != null) {
+ fIsKernel = fDomain.isKernel();
+ } else {
+ fIsKernel = true;
+ }
+ }
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
// Kernel or UST event data group
// ------------------------------------------------------------------------
+ fUstComposite = null;
+ fKernelComposite = null;
if (fIsKernel) {
createKernelComposite();
+ fUstComposite = null;
} else {
createUstComposite();
}
/**
* Constructor of dialog box.
* @param shell - the shell for the dialog box
- * @param isKernel - a flag to indicate Kernel or UST events.
- * @param sessions - a list of available sessions
*/
- public GetEventInfoDialog(Shell shell, boolean isKernel, TraceSessionComponent[] sessions) {
+ public GetEventInfoDialog(Shell shell) {
super(shell);
- fIsKernel = isKernel;
- fSessions = Arrays.copyOf(sessions, sessions.length);
setShellStyle(SWT.RESIZE);
}
return fChannel;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.dialogs.IGetEventInfoDialog#setIsKernel(boolean)
+ */
+ @Override
+ public void setIsKernel(boolean isKernel) {
+ fIsKernel = isKernel;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.dialogs.IGetEventInfoDialog#setSessions(org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent[])
+ */
+ @Override
+ public void setSessions(TraceSessionComponent[] sessions) {
+ fSessions = Arrays.copyOf(sessions, sessions.length);
+ }
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng.ui.views.control.dialogs;
+
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * <b><u>IConfirmDialog</u></b>
+ * <p>
+ * Interface for a confirmation dialog.
+ * </p>
+ */
+public interface IConfirmDialog {
+
+ public boolean openConfirm(Shell parent, String title, String message);
+
+}
package org.eclipse.linuxtools.lttng.ui.views.control.dialogs;
import org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceDomainComponent;
/**
* <b><u>ICreateChannelDialog</u></b>
*/
public IChannelInfo getChannelInfo();
+ /**
+ * Sets the domain component
+ * @param domain - the trace domain component
+ */
+ public void setDomainComponent(TraceDomainComponent domain);
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
**********************************************************************/
package org.eclipse.linuxtools.lttng.ui.views.control.dialogs;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionGroup;
+
/**
* <b><u>ICreateSessionDialog</u></b>
* <p>
* @return true for default location else false
*/
public boolean isDefaultSessionPath();
+
+ /**
+ * Set trace session group.
+ * @param group - the session group
+ */
+ public void setTraceSessionGroup(TraceSessionGroup group);
// ------------------------------------------------------------------------
// Operations
**********************************************************************/
package org.eclipse.linuxtools.lttng.ui.views.control.dialogs;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceDomainComponent;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceProviderGroup;
+
/**
* <b><u>IEnableKernelEvents</u></b>
* <p>
* @return the session the events shall be enabled.
*/
public boolean isKernel();
+
+ /**
+ * Sets the trace provider group.
+ * @param providerGroup - a trace provider group
+ */
+ public void setTraceProviderGroup(TraceProviderGroup providerGroup);
+
+ /**
+ * Sets the trace domain component.
+ * @param domain - a domain of the events (null if not known)
+ */
+ public void setTraceDomainComponent(TraceDomainComponent domain);
// ------------------------------------------------------------------------
// Operations
* @return the channel the events shall be enabled. Null for default channel.
*/
public TraceChannelComponent getChannel();
+
+ /**
+ * Sets flag about domain.
+ * @param isKernel - true for kernel, false for UST
+ */
+ public void setIsKernel(boolean isKernel);
+
+ /**
+ * Sets available session.
+ * @param sessions - a array of available sessions.
+ */
+ public void setSessions(TraceSessionComponent[] sessions);
// ------------------------------------------------------------------------
// Operations
**********************************************************************/
package org.eclipse.linuxtools.lttng.ui.views.control.dialogs;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceControlComponent;
+import org.eclipse.rse.core.model.IHost;
+
/**
* <b><u>INewConnectionDialog</u></b>
* <p>
* @return the host name (IP address or DNS name)
*/
public String getHostName();
+
+ /**
+ * Sets the trace control root
+ * @param parent - the trace control parent
+ */
+ public void setTraceControlParent(ITraceControlComponent parent);
+
+ /**
+ * Sets the available hosts to select.
+ * @param hosts - the available hosts
+ */
+ public void setHosts(IHost[] hosts);
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
- public NewConnectionDialog(Shell shell, ITraceControlComponent parent, IHost[] hosts) {
+ public NewConnectionDialog(Shell shell) {
super(shell);
- fParent = parent;
- if (hosts != null) {
- fExistingHosts = Arrays.copyOf(hosts, hosts.length);
- }
setShellStyle(SWT.RESIZE);
}
public String getHostName() {
return fHostName;
}
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.dialogs.INewConnectionDialog#setTraceControlParent(org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceControlComponent)
+ */
+ @Override
+ public void setTraceControlParent(ITraceControlComponent parent) {
+ fParent = parent;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.dialogs.INewConnectionDialog#setHosts(org.eclipse.rse.core.model.IHost[])
+ */
+ @Override
+ public void setHosts(IHost[] hosts) {
+ if (hosts != null) {
+ fExistingHosts = Arrays.copyOf(hosts, hosts.length);
+ }
+ }
// ------------------------------------------------------------------------
// Operations
--- /dev/null
+package org.eclipse.linuxtools.lttng.ui.views.control.dialogs;
+
+import org.eclipse.ui.PlatformUI;
+
+
+public class TraceControlDialogFactory {
+
+ // ------------------------------------------------------------------------
+ // Members
+ // ------------------------------------------------------------------------
+
+ /**
+ * The factory instance.
+ */
+ private static TraceControlDialogFactory fInstance;
+
+ /**
+ * The new connection dialog reference.
+ */
+ private INewConnectionDialog fNewConnectionDialog;
+
+ /**
+ * The create channel dialog (on domain level)
+ */
+ private ICreateChannelDialog fCreateChannelDialog;
+
+ /**
+ * The create channel dialog (on session level)
+ */
+ private ICreateChannelOnSessionDialog fCreateChannelOnSessionDialog;
+
+ /**
+ * The create session dialog.
+ */
+ private ICreateSessionDialog fCreateSessionDialog;
+
+ /**
+ * The enable events dialog.
+ */
+ private IEnableEventsDialog fEnableEventsDialog;
+
+ /**
+ * The get event info dialog.
+ */
+ private IGetEventInfoDialog fGetEventInfoDialog;
+
+ /**
+ * The confirmation dialog implementation
+ */
+ private IConfirmDialog fConfirmDialog;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Constructor for R4EUIDialogFactory.
+ */
+ private TraceControlDialogFactory() {
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
+ /**
+ * @return TraceControlDialogFactory instance
+ */
+ public static TraceControlDialogFactory getInstance() {
+ if (null == fInstance) {
+ fInstance = new TraceControlDialogFactory();
+ }
+ return fInstance;
+ }
+
+ /**
+ * @return new connection dialog
+ */
+ public INewConnectionDialog getNewConnectionDialog() {
+ if (null == fNewConnectionDialog) {
+ fNewConnectionDialog = new NewConnectionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+ }
+ return fNewConnectionDialog;
+ }
+
+ /**
+ * Sets a new connection dialog implementation.
+ * @param newConnectionDialog - new connection dialog implementation
+ */
+ public void setNewConnectionDialog(INewConnectionDialog newConnectionDialog) {
+ fNewConnectionDialog = newConnectionDialog;
+ }
+
+ /**
+ * @return create channel dialog (on domain level)
+ */
+ public ICreateChannelDialog getCreateChannelDialog() {
+ if (null == fCreateChannelDialog) {
+ fCreateChannelDialog = new CreateChannelDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+ }
+ return fCreateChannelDialog;
+ }
+
+ /**
+ * Sets a create channel dialog implementation (on domain level).
+ * @param createChannelDialog - a create channel dialog implementation
+ */
+ public void setCreateChannelDialog(ICreateChannelDialog createChannelDialog) {
+ fCreateChannelDialog = createChannelDialog;
+ }
+
+ /**
+ * @return create channel dialog (on session level)
+ */
+ public ICreateChannelOnSessionDialog getCreateChannelOnSessionDialog() {
+ if (null == fCreateChannelOnSessionDialog) {
+ fCreateChannelOnSessionDialog = new CreateChannelDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+ }
+ return fCreateChannelOnSessionDialog;
+ }
+
+ /**
+ * Sets a create channel dialog implementation (on domain level).
+ * @param createChannelDialog - a create channel dialog implementation
+ */
+ public void setCreateChannelOnSessionDialog(ICreateChannelOnSessionDialog createChannelDialog) {
+ fCreateChannelOnSessionDialog = createChannelDialog;
+ }
+
+ /**
+ * @return create session dialog implementation
+ */
+ public ICreateSessionDialog getCreateSessionDialog() {
+ if (null == fCreateSessionDialog) {
+ fCreateSessionDialog = new CreateSessionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+ }
+ return fCreateSessionDialog;
+ }
+
+ /**
+ * Sets a create session dialog implementation.
+ * @param createSessionDialog - a create session implementation.
+ */
+ public void setCreateSessionDialog(ICreateSessionDialog createSessionDialog) {
+ fCreateSessionDialog = createSessionDialog;
+ }
+
+ /**
+ * @return enable events dialog implementation.
+ */
+ public IEnableEventsDialog getEnableEventsDialog() {
+ if (null == fEnableEventsDialog) {
+ fEnableEventsDialog = new EnableEventsDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+ }
+ return fEnableEventsDialog;
+ }
+
+ /**
+ * Sets a enable events dialog implementation.
+ * @param enableEventsDialog - a enable events dialog implementation.
+ */
+ public void setEnableEventsDialog(IEnableEventsDialog enableEventsDialog) {
+ fEnableEventsDialog = enableEventsDialog;
+ }
+
+ /**
+ * @return get events info dialog implementation.
+ */
+ public IGetEventInfoDialog getGetEventInfoDialog() {
+ if (null == fGetEventInfoDialog) {
+ fGetEventInfoDialog = new GetEventInfoDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+ }
+ return fGetEventInfoDialog;
+ }
+
+ /**
+ * Sets a get events info dialog implementation.
+ * @param getEventInfoDialog - a get events info dialog implementation
+ */
+ public void setGetEventInfoDialog(IGetEventInfoDialog getEventInfoDialog) {
+ fGetEventInfoDialog = getEventInfoDialog;
+ }
+
+ /**
+ * @return the confirmation dialog implementation
+ */
+ public IConfirmDialog getConfirmDialog() {
+ if (null == fConfirmDialog) {
+ fConfirmDialog = new ConfirmDialog();
+ }
+ return fConfirmDialog;
+ }
+
+ /**
+ * Sets the confirmation dialog implementation
+ * @param confirmDialog
+ */
+ public void setConfirmDialog(IConfirmDialog confirmDialog) {
+ fConfirmDialog = confirmDialog;
+ }
+}
+
+
import java.util.Iterator;
import java.util.List;
-import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.linuxtools.lttng.ui.LTTngUiPlugin;
import org.eclipse.linuxtools.lttng.ui.views.control.ControlView;
import org.eclipse.linuxtools.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.GetEventInfoDialog;
import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.IGetEventInfoDialog;
+import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.TraceControlDialogFactory;
import org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceControlComponent;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.BaseEventComponent;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.KernelProviderComponent;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.UstProviderComponent;
import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
/**
* <b><u>EnableEventHandler</u></b>
* This is done on the trace provider level.
* </p>
*/
-public class AssignEventHandler extends AbstractHandler {
+public class AssignEventHandler extends BaseControlViewHandler {
// ------------------------------------------------------------------------
// Attributes
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-
- if (window == null) {
- return false;
- }
-
// Open dialog box to retrieve the session and channel where the events should be enabled in.
- final IGetEventInfoDialog dialog = new GetEventInfoDialog(window.getShell(), fIsKernel, fSessions);
+ final IGetEventInfoDialog dialog = TraceControlDialogFactory.getInstance().getGetEventInfoDialog();
+ dialog.setIsKernel(fIsKernel);
+ dialog.setSessions(fSessions);
if (dialog.open() != Window.OK) {
return null;
fSessions = null;
fIsKernel = null;
- // Check if we are closing down
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window == null) {
- return false;
- }
-
- // Check if we are in the Project View
- IWorkbenchPage page = window.getActivePage();
+ // Get workbench page for the Control View
+ IWorkbenchPage page = getWorkbenchPage();
if (page == null) {
return false;
}
- IWorkbenchPart part = page.getActivePart();
- if (!(part instanceof ControlView)) {
- return false;
- }
-
// Check if one or more session are selected
ISelection selection = page.getSelection(ControlView.ID);
if (selection instanceof StructuredSelection) {
import org.eclipse.jface.window.Window;
import org.eclipse.linuxtools.lttng.ui.LTTngUiPlugin;
import org.eclipse.linuxtools.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.EnableEventsDialog;
import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.IEnableEventsDialog;
+import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.TraceControlDialogFactory;
import org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceControlComponent;
import org.eclipse.linuxtools.lttng.ui.views.control.model.LogLevelType;
import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceLogLevel;
/**
* Enables a dynamic probe.
* @param eventName - a event name
+ * @param isFunction - true for dynamic function entry/return probe else false
* @param probe - a dynamic probe information
* @param monitor - a progress monitor
* @throws ExecutionException
*/
- abstract public void enableProbe(String eventName, String probe, IProgressMonitor monitor) throws ExecutionException;
+ abstract public void enableProbe(String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException;
- /**
- * Enables a dynamic function entry/return probe.
- * @param eventName - a event name
- * @param function - a dynamic function entry/return probe information
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- abstract public void enableFunctionProbe(String eventName, String probe, IProgressMonitor monitor) throws ExecutionException;
-
/**
* Enables events using log level
* @param eventName - a event name
TargetNodeComponent node = fSession.getTargetNode();
List<ITraceControlComponent> providers = node.getChildren(TraceProviderGroup.class);
-
- final IEnableEventsDialog dialog = new EnableEventsDialog(window.getShell(), (TraceProviderGroup)providers.get(0), getDomain());
-
+
+ final IEnableEventsDialog dialog = TraceControlDialogFactory.getInstance().getEnableEventsDialog();
+ dialog.setTraceProviderGroup((TraceProviderGroup)providers.get(0));
+ dialog.setTraceDomainComponent(getDomain());
+
if (dialog.open() != Window.OK) {
return null;
}
// Enable dynamic probe
if (dialog.isDynamicProbe()) {
if ((dialog.getProbeEventName() != null && dialog.getProbeName() != null)) {
- enableProbe(dialog.getProbeEventName(), dialog.getProbeName(), monitor);
+ enableProbe(dialog.getProbeEventName(), false, dialog.getProbeName(), monitor);
}
}
// Enable dynamic function probe
if (dialog.isDynamicFunctionProbe()) {
if ((dialog.getFunctionEventName() != null) && (dialog.getFunction() != null)) {
- enableFunctionProbe(dialog.getFunctionEventName(), dialog.getFunction(), monitor);
+ enableProbe(dialog.getFunctionEventName(), true, dialog.getFunction(), monitor);
}
}
for (Iterator<TraceEventComponent> iterator = fEvents.iterator(); iterator.hasNext();) {
// Enable all selected channels which are disabled
- TraceEventComponent channel = (TraceEventComponent) iterator.next();
- channel.setState(getNewState());
+ TraceEventComponent ev = (TraceEventComponent) iterator.next();
+ ev.setState(getNewState());
}
}
} catch (ExecutionException e) {
import org.eclipse.linuxtools.lttng.ui.LTTngUiPlugin;
import org.eclipse.linuxtools.lttng.ui.views.control.ControlView;
import org.eclipse.linuxtools.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.CreateChannelDialog;
import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.ICreateChannelDialog;
+import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.TraceControlDialogFactory;
import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceSessionState;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceDomainComponent;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent;
import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
/**
* <b><u>CreateChannelOnDomainHandler</u></b>
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
- final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-
- if (window == null) {
- return false;
- }
-
// Get channel information from user
- final ICreateChannelDialog dialog = new CreateChannelDialog(window.getShell(), fDomain);
+ final ICreateChannelDialog dialog = TraceControlDialogFactory.getInstance().getCreateChannelDialog();
+ dialog.setDomainComponent(fDomain);
if (dialog.open() != Window.OK) {
return null;
import org.eclipse.linuxtools.lttng.ui.LTTngUiPlugin;
import org.eclipse.linuxtools.lttng.ui.views.control.ControlView;
import org.eclipse.linuxtools.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.CreateChannelDialog;
import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.ICreateChannelOnSessionDialog;
+import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.TraceControlDialogFactory;
import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceSessionState;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceDomainComponent;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent;
import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
/**
* <b><u>CreateChannelOnSessionHandler</u></b>
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
- final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-
- if (window == null) {
- return false;
- }
-
- final ICreateChannelOnSessionDialog dialog = new CreateChannelDialog(window.getShell());
+ final ICreateChannelOnSessionDialog dialog = TraceControlDialogFactory.getInstance().getCreateChannelOnSessionDialog();
if (dialog.open() != Window.OK) {
return null;
import org.eclipse.linuxtools.lttng.ui.LTTngUiPlugin;
import org.eclipse.linuxtools.lttng.ui.views.control.ControlView;
import org.eclipse.linuxtools.lttng.ui.views.control.Messages;
-import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.CreateSessionDialog;
import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.ICreateSessionDialog;
+import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.TraceControlDialogFactory;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionGroup;
import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
/**
* <b><u>CreateSessionHandler</u></b>
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window == null) {
- return false;
- }
// Open dialog box for the node name and address
- ICreateSessionDialog dialog = new CreateSessionDialog(window.getShell(), fSessionGroup);
+ ICreateSessionDialog dialog = TraceControlDialogFactory.getInstance().getCreateSessionDialog();
+ dialog.setTraceSessionGroup(fSessionGroup);
if (dialog.open() != Window.OK) {
return null;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.linuxtools.lttng.ui.LTTngUiPlugin;
import org.eclipse.linuxtools.lttng.ui.views.control.ControlView;
import org.eclipse.linuxtools.lttng.ui.views.control.Messages;
+import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.IConfirmDialog;
+import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.TraceControlDialogFactory;
import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceSessionState;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionGroup;
return false;
}
// Get user confirmation
- if (!MessageDialog.openConfirm(window.getShell(),
+ IConfirmDialog dialog = TraceControlDialogFactory.getInstance().getConfirmDialog();
+ if (!dialog.openConfirm(window.getShell(),
Messages.TraceControl_DestroyConfirmationTitle,
Messages.TraceControl_DestroyConfirmationMessage)) {
return null;
-
}
Job job = new Job(Messages.TraceControl_DestroySessionJob) {
/*
* (non-Javadoc)
- * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableProbe(java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableProbe(java.lang.String, boolean, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- public void enableProbe(String eventName, String probe, IProgressMonitor monitor) throws ExecutionException {
- fChannel.enableProbe(eventName, probe, monitor);
+ public void enableProbe(String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
+ fChannel.enableProbe(eventName, isFunction, probe, monitor);
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableFunctionProbe(java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void enableFunctionProbe(String eventName, String probe, IProgressMonitor monitor) throws ExecutionException {
- fChannel.enableFunctionProbe(eventName, probe, monitor);
- }
-
/*
* (non-Javadoc)
* @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableLogLevel(java.lang.String, org.eclipse.linuxtools.lttng.ui.views.control.model.LogLevelType, org.eclipse.linuxtools.lttng.ui.views.control.model.TraceLogLevel, org.eclipse.core.runtime.IProgressMonitor)
/*
* (non-Javadoc)
- * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableProbe(java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableProbe(java.lang.String, boolean, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- public void enableProbe(String eventName, String probe, IProgressMonitor monitor) throws ExecutionException {
- fDomain.enableProbe(eventName, probe, monitor);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableFunctionProbe(java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void enableFunctionProbe(String eventName, String probe, IProgressMonitor monitor) throws ExecutionException {
- fDomain.enableFunctionProbe(eventName, probe, monitor);
+ public void enableProbe(String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
+ fDomain.enableProbe(eventName, isFunction, probe, monitor);
}
/*
/*
* (non-Javadoc)
- * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableProbe(java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableProbe(java.lang.String, boolean, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- public void enableProbe(String eventName, String probe, IProgressMonitor monitor) throws ExecutionException {
- fSession.enableProbe(eventName, probe, monitor);
+ public void enableProbe(String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
+ fSession.enableProbe(eventName, isFunction, probe, monitor);
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableFunctionProbe(java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void enableFunctionProbe(String eventName, String probe, IProgressMonitor monitor) throws ExecutionException {
- fSession.enableFunctionProbe(eventName, probe, monitor);
- }
-
/*
* (non-Javadoc)
* @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableLogLevel(java.lang.String, org.eclipse.linuxtools.lttng.ui.views.control.model.LogLevelType, org.eclipse.linuxtools.lttng.ui.views.control.model.TraceLogLevel, org.eclipse.core.runtime.IProgressMonitor)
import org.eclipse.linuxtools.lttng.ui.views.control.ControlView;
import org.eclipse.linuxtools.lttng.ui.views.control.Messages;
import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.INewConnectionDialog;
-import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.NewConnectionDialog;
+import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.TraceControlDialogFactory;
import org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceControlComponent;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TargetNodeComponent;
import org.eclipse.rse.core.IRSESystemType;
IHost[] hosts = registry.getHostsBySystemType(sysType);
// Open dialog box for the node name and address
- INewConnectionDialog dialog = new NewConnectionDialog(window.getShell(), fRoot, hosts);
+ final INewConnectionDialog dialog = TraceControlDialogFactory.getInstance().getNewConnectionDialog();
+ dialog.setTraceControlParent(fRoot);
+ dialog.setHosts(hosts);
if (dialog.open() != Window.OK) {
return null;
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng.ui.views.control.handlers;
+
+import java.util.Iterator;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.linuxtools.lttng.ui.views.control.ControlView;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.TargetNodeState;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TargetNodeComponent;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceControlComponent;
+import org.eclipse.ui.IWorkbenchPage;
+
+/**
+ * <b><u>RefreshHandler</u></b>
+ * <p>
+ * Command handler implementation to refresh node configuration.
+ * </p>
+ */
+public class RefreshHandler extends BaseControlViewHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The node component reference.
+ */
+ private TargetNodeComponent fNode;
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ fNode.refresh();
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+ fNode = null;
+
+ // Get workbench page for the Control View
+ IWorkbenchPage page = getWorkbenchPage();
+ if (page == null) {
+ return false;
+ }
+
+ // Check if one or more session are selected
+ ISelection selection = page.getSelection(ControlView.ID);
+ if (selection instanceof StructuredSelection) {
+
+ StructuredSelection structered = ((StructuredSelection) selection);
+ for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
+ Object element = (Object) iterator.next();
+ if (element instanceof TraceControlComponent) {
+ TraceControlComponent component = (TraceControlComponent) element;
+ boolean isConnected = component.getTargetNodeState() == TargetNodeState.CONNECTED;
+ if (isConnected) {
+ while ((component != null) && component.getClass() != TargetNodeComponent.class) {
+ component = (TraceControlComponent) component.getParent();
+ }
+ if (component != null) {
+ fNode = (TargetNodeComponent) component;
+ }
+ }
+ }
+ }
+ }
+ return fNode != null;
+ }
+}
TraceControl_EnableEventsLoglevelEventNameTooltip=Event name for enabling log levels
TraceControl_InvalidProbeNameError=The probe name is invalid
-TraceControl_InvalidProbeNameError=The wild card name is invalid
+TraceControl_InvalidWildcardError=The wild card name is invalid
TraceControl_InvalidLogLevelEventNameError=The event name for log level is invalid
# Tree structure strings
TraceControl_SessionPathPropertyName=Session Path
TraceControl_ProviderNamePropertyName=Provider Name
TraceControl_ProcessIdPropertyName=Process ID
+TraceControl_ProbeAddressPropertyName=Address
+TraceControl_ProbeOffsetPropertyName=Offset
+TraceControl_ProbeSymbolPropertyName=Symbol
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng.ui.views.control.model;
+
+/**
+ * <b><u>IProbeEventInfo</u></b>
+ * <p>
+ * Interface for retrieval of probe event information.
+ * </p>
+ */
+public interface IProbeEventInfo extends IEventInfo {
+
+ /**
+ * @return the address of the probe. (null if not used)
+ */
+ public String getAddress();
+
+ /**
+ * Sets the address of the probe.
+ * @param address - a address (null if not used)
+ */
+ public void setAddress(String address);
+
+ /**
+ * @return the offset applied to the symbol (null if not used).
+ */
+ public String getOffset();
+
+ /**
+ * Sets the offset applied to the symbol.
+ * @param offset - a offset ((null if not used)
+ */
+ public void setOffset(String offset);
+
+ /**
+ * @return the symbol name. ((null if not used))
+ */
+ public String getSymbol();
+
+ /**
+ * Sets the symbol name.
+ * @param symbol - a symbol name ((null if not used))
+ */
+ public void setSymbol(String symbol);
+}
* @param name
*/
public void setName(String name);
+
+ /**
+ * @return a formated (readable) String with content.
+ */
+ public String formatString();
}
}
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceInfo#formatString()
+ */
+ @SuppressWarnings("nls")
+ @Override
+ public String formatString() {
+ StringBuffer output = new StringBuffer();
+ // ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_MODULE (10)) (type: tracepoint)");
+ output.append("\n ");
+ output.append(getName());
+ if (fLogLevel != TraceLogLevel.LEVEL_UNKNOWN) {
+ output.append(" (loglevel: ");
+ output.append(fLogLevel.getInName());
+ output.append(" (");
+ output.append(fLogLevel.ordinal());
+ output.append("))");
+ }
+ output.append(" (type: ");
+ output.append(fEventType.getInName());
+ output.append(")");
+ return output.toString();
+ }
+
/*
* (non-Javadoc)
* @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#hashCode()
*/
@Override
public int hashCode() {
- int result = 17;
- result = 37 * result + super.hashCode();
- result = 37 * result + fEventType.ordinal();
- result = 37 * result + fLogLevel.ordinal();
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((fEventType == null) ? 0 : (fEventType.ordinal() + 1));
+ result = prime * result + ((fLogLevel == null) ? 0 : (fLogLevel.ordinal() + 1));
return result;
- }
+ }
/*
* (non-Javadoc)
* @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object)
*/
@Override
- public boolean equals(Object other) {
- if (!(other instanceof BaseEventInfo)) {
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
return false;
}
-
- BaseEventInfo otherInfo = (BaseEventInfo) other;
- if (!super.equals(otherInfo)) {
+ if (getClass() != obj.getClass()) {
return false;
}
-
- if (fEventType.ordinal() != otherInfo.fEventType.ordinal()) {
+ BaseEventInfo other = (BaseEventInfo) obj;
+ if (fEventType != other.fEventType) {
return false;
}
-
- if (fLogLevel.ordinal() != otherInfo.fLogLevel.ordinal()) {
+ if (fLogLevel != other.fLogLevel) {
return false;
}
return true;
- }
+ }
/*
* (non-Javadoc)
output.append(")]");
return output.toString();
}
+
+
+
+
}
\ No newline at end of file
fEvents.add(channel);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceInfo#formatString()
+ */
+ @SuppressWarnings("nls")
+ @Override
+ public String formatString() {
+ StringBuffer output = new StringBuffer();
+ //- channel0: [enabled]
+ output.append("\n- ");
+ output.append(getName());
+ output.append(": [");
+ output.append(getState().getInName());
+ output.append("]\n");
+ // Attributes:
+ output.append("\n Attributes:\n");
+ // overwrite mode: 0
+ output.append(" overwrite mode: ");
+ output.append(isOverwriteMode() ? "1" : "0");
+ // subbufers size: 262144
+ output.append("\n subbufers size: ");
+ output.append(getSubBufferSize());
+ // number of subbufers: 4
+ output.append("\n number of subbufers: ");
+ output.append(getNumberOfSubBuffers());
+ // switch timer interval: 0
+ output.append("\n switch timer interval: ");
+ output.append(getSwitchTimer());
+ // read timer interval: 200
+ output.append("\n read timer interval: ");
+ output.append(getReadTimer());
+ // output: splice()
+ output.append("\n output: ");
+ output.append(getOutputType());
+ output.append("\n\n");
+
+ output.append(" Events:");
+ if (fEvents.isEmpty()) {
+ output.append("\n None");
+ } else {
+ for (Iterator<IEventInfo> iterator = fEvents.iterator(); iterator.hasNext();) {
+ IEventInfo event = (IEventInfo) iterator.next();
+ output.append(event.formatString());
+ }
+ }
+ output.append("\n");
+
+ return output.toString();
+ }
+
/*
* (non-Javadoc)
* @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#hashCode()
*/
@Override
public int hashCode() {
- int result = 17;
- result = 37 * result + super.hashCode();
- result = 37 * result + Boolean.valueOf(fOverwriteMode).hashCode();
- result = 37 * result + Long.valueOf(fSubBufferSize).hashCode();
- result = 37 * result + fNumberOfSubBuffers;
- result = 37 * result + Long.valueOf(fSwitchTimer).hashCode();
- result = 37 * result + Long.valueOf(fReadTimer).hashCode();
- result = 37 * result + (fOutputType != null ? fOutputType.hashCode() : 0);
- result = 37 * result + fState.ordinal();
- for (Iterator<IEventInfo> iterator = fEvents.iterator(); iterator.hasNext();) {
- IEventInfo event = (IEventInfo) iterator.next();
- result = 37 * result + event.hashCode();
- }
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((fEvents == null) ? 0 : fEvents.hashCode());
+ result = prime * result + fNumberOfSubBuffers;
+ result = prime * result + ((fOutputType == null) ? 0 : fOutputType.hashCode());
+ result = prime * result + (fOverwriteMode ? 1231 : 1237);
+ result = prime * result + (int) (fReadTimer ^ (fReadTimer >>> 32));
+ result = prime * result + ((fState == null) ? 0 : (fState.ordinal() + 1));
+ result = prime * result + (int) (fSubBufferSize ^ (fSubBufferSize >>> 32));
+ result = prime * result + (int) (fSwitchTimer ^ (fSwitchTimer >>> 32));
return result;
- }
+ }
/*
* (non-Javadoc)
* @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object)
*/
@Override
- public boolean equals(Object other) {
- if (!(other instanceof ChannelInfo)) {
- return false;
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
}
-
- ChannelInfo otherInfo = (ChannelInfo) other;
- if (!super.equals(otherInfo)) {
+ if (!super.equals(obj)) {
return false;
}
-
- if (fOverwriteMode != otherInfo.fOverwriteMode) {
+ if (getClass() != obj.getClass()) {
return false;
}
- if (fSubBufferSize != otherInfo.fSubBufferSize) {
+ ChannelInfo other = (ChannelInfo) obj;
+ if (fEvents == null) {
+ if (other.fEvents != null) {
+ return false;
+ }
+ } else if (!fEvents.equals(other.fEvents)) {
return false;
}
- if (fNumberOfSubBuffers != otherInfo.fNumberOfSubBuffers) {
+ if (fNumberOfSubBuffers != other.fNumberOfSubBuffers) {
return false;
}
- if (fSwitchTimer != otherInfo.fSwitchTimer) {
+ if (fOutputType == null) {
+ if (other.fOutputType != null) {
+ return false;
+ }
+ } else if (!fOutputType.equals(other.fOutputType)) {
return false;
}
- if (fReadTimer != otherInfo.fReadTimer) {
+ if (fOverwriteMode != other.fOverwriteMode) {
return false;
}
- if (fState.ordinal() != otherInfo.fState.ordinal()) {
+ if (fReadTimer != other.fReadTimer) {
return false;
}
- if (!fOutputType.equals(otherInfo.fOutputType)) {
+ if (fState != other.fState) {
return false;
}
- if (fEvents.size() != otherInfo.fEvents.size()) {
+ if (fSubBufferSize != other.fSubBufferSize) {
return false;
}
- for (int i = 0; i < fEvents.size(); i++) {
- if (!fEvents.get(i).equals(otherInfo.fEvents.get(i))) {
- return false;
- }
+ if (fSwitchTimer != other.fSwitchTimer) {
+ return false;
}
return true;
}
output.append(")]");
return output.toString();
}
+
+
}
\ No newline at end of file
fChannels.add(channel);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceInfo#formatString()
+ */
+ @SuppressWarnings("nls")
+ @Override
+ public String formatString() {
+ StringBuffer output = new StringBuffer();
+ //=== Domain: Kernel ===
+ output.append("\n=== Domain: ");
+ output.append(getName());
+ output.append(" ===\n");
+ output.append("\n");
+ // Channels:
+ output.append("Channels:\n");
+ // -------------
+ output.append("-------------");
+ if (fChannels.isEmpty()) {
+ output.append("\nNone");
+ } else {
+ for (Iterator<IChannelInfo> iterator = fChannels.iterator(); iterator.hasNext();) {
+ IChannelInfo channel = (IChannelInfo) iterator.next();
+ output.append(channel.formatString());
+ }
+ }
+ output.append("\n");
+ return output.toString();
+ }
+
/*
* (non-Javadoc)
* @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#hashCode()
*/
@Override
public int hashCode() {
- int result = 17;
- result = 37 * result + super.hashCode();
- for (Iterator<IChannelInfo> iterator = fChannels.iterator(); iterator.hasNext();) {
- IChannelInfo channel = (IChannelInfo) iterator.next();
- result = 37 * result + channel.hashCode();
- }
- result += 37 * result + (fIsKernel ? 1 : 0);
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((fChannels == null) ? 0 : fChannels.hashCode());
+ result = prime * result + (fIsKernel ? 1231 : 1237);
return result;
}
* @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object)
*/
@Override
- public boolean equals(Object other) {
- if (!(other instanceof DomainInfo)) {
- return false;
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
}
-
- DomainInfo otherInfo = (DomainInfo) other;
- if (!super.equals(otherInfo)) {
+ if (!super.equals(obj)) {
return false;
}
-
- if (fChannels.size() != otherInfo.fChannels.size()) {
+ if (getClass() != obj.getClass()) {
return false;
}
- for (int i = 0; i < fChannels.size(); i++) {
- if (!fChannels.get(i).equals(otherInfo.fChannels.get(i))) {
+ DomainInfo other = (DomainInfo) obj;
+ if (fChannels == null) {
+ if (other.fChannels != null) {
return false;
}
+ } else if (!fChannels.equals(other.fChannels)) {
+ return false;
}
-
- if (fIsKernel != otherInfo.fIsKernel) {
+ if (fIsKernel != other.fIsKernel) {
return false;
}
return true;
}
-
+
/*
* (non-Javadoc)
* @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#toString()
output.append(")]");
return output.toString();
}
+
}
fState = state;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceInfo#formatString()
+ */
+ @SuppressWarnings("nls")
+ @Override
+ public String formatString() {
+ StringBuffer output = new StringBuffer();
+ // ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_MODULE (10)) (type: tracepoint) [enabled]");
+ output.append(super.formatString());
+ output.append(" [");
+ output.append(fState.getInName());
+ output.append("]");
+ return output.toString();
+ }
+
/*
* (non-Javadoc)
* @see org.eclipse.linuxtools.lttng.ui.views.control.model.IEventInfo#setState(java.lang.String)
*/
@Override
public int hashCode() {
- int result = 17;
- result = 37 * result + super.hashCode();
- result = 37 * result + fState.ordinal();
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((fState == null) ? 0 : (fState.ordinal() + 1));
return result;
}
* @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.BaseEventInfo#equals(java.lang.Object)
*/
@Override
- public boolean equals(Object other) {
- if (!(other instanceof EventInfo)) {
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
return false;
}
-
- EventInfo otherInfo = (EventInfo) other;
- if (!super.equals(otherInfo)) {
+ if (getClass() != obj.getClass()) {
return false;
}
-
- if (fState.ordinal() != otherInfo.fState.ordinal()) {
+ EventInfo other = (EventInfo) obj;
+ if (fState != other.fState) {
return false;
}
return true;
}
-
-
+
/*
* (non-Javadoc)
* @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.BaseEventInfo#toString()
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng.ui.views.control.model.impl;
+
+import org.eclipse.linuxtools.lttng.ui.views.control.model.IProbeEventInfo;
+
+/**
+* <b><u>ProbleEventInfo</u></b>
+* <p>
+* Implementation of the trace event interface (IProbeEventInfo) to store probe event
+* related data.
+* </p>
+*/
+public class ProbeEventInfo extends EventInfo implements IProbeEventInfo {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The dynamic probe address (null if symbol is used).
+ */
+ private String fAddress;
+ /**
+ * The dynamic probe offset (if symbol is used).
+ */
+ private String fOffset;
+
+ /**
+ * The symbol name (null if address is used)
+ */
+ private String fSymbol;
+
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param name - name of event
+ */
+ public ProbeEventInfo(String name) {
+ super(name);
+ }
+
+ /**
+ * Copy constructor
+ * @param other - the instance to copy
+ */
+ public ProbeEventInfo(ProbeEventInfo other) {
+ super(other);
+ fAddress = other.fAddress;
+ fOffset = other.fOffset;
+ fSymbol = other.fSymbol;
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IProbeEventInfo#getAddress()
+ */
+ @Override
+ public String getAddress() {
+ return fAddress;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IProbeEventInfo#setAddress(java.lang.String)
+ */
+ @Override
+ public void setAddress(String address) {
+ fAddress = address;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IProbeEventInfo#getOffset()
+ */
+ @Override
+ public String getOffset() {
+ return fOffset;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IProbeEventInfo#setOffset(java.lang.String)
+ */
+ @Override
+ public void setOffset(String offset) {
+ fOffset = offset;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IProbeEventInfo#getSymbol()
+ */
+ @Override
+ public String getSymbol() {
+ return fSymbol;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IProbeEventInfo#setSymbol(java.lang.String)
+ */
+ @Override
+ public void setSymbol(String symbol) {
+ fSymbol = symbol;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operation
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceInfo#formatString()
+ */
+ @SuppressWarnings("nls")
+ @Override
+ public String formatString() {
+ StringBuffer output = new StringBuffer();
+ // name (type: probe) [enabled]");
+ // address:
+ output.append(super.formatString());
+ if (fAddress != null) {
+ output.append("\n addr: ");
+ output.append(fAddress);
+ } else {
+ output.append("\n offset: ");
+ output.append(fOffset);
+ output.append("\n");
+ output.append(" symbol: ");
+ output.append(fSymbol);
+ }
+ return output.toString();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.BaseEventInfo#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((fAddress == null) ? 0 : fAddress.hashCode());
+ result = prime * result + ((fOffset == null) ? 0 : fOffset.hashCode());
+ result = prime * result + ((fSymbol == null) ? 0 : fSymbol.hashCode());
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.BaseEventInfo#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ ProbeEventInfo other = (ProbeEventInfo) obj;
+ if (fAddress == null) {
+ if (other.fAddress != null) {
+ return false;
+ }
+ } else if (!fAddress.equals(other.fAddress)) {
+ return false;
+ }
+ if (fOffset == null) {
+ if (other.fOffset != null) {
+ return false;
+ }
+ } else if (!fOffset.equals(other.fOffset)) {
+ return false;
+ }
+ if (fSymbol == null) {
+ if (other.fSymbol != null) {
+ return false;
+ }
+ } else if (!fSymbol.equals(other.fSymbol)) {
+ return false;
+ }
+ return true;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.EventInfo#toString()
+ */
+ @SuppressWarnings("nls")
+ @Override
+ public String toString() {
+ StringBuffer output = new StringBuffer();
+ output.append("[ProbeEventInfo(");
+ output.append(super.toString());
+ if (fAddress != null) {
+ output.append(",fAddress=");
+ output.append(fAddress);
+ } else {
+ output.append(",fOffset=");
+ output.append(fOffset);
+ output.append(",fSymbol=");
+ output.append(fSymbol);
+ }
+ output.append(")]");
+ return output.toString();
+ }
+
+
+}
public void addDomain(IDomainInfo domainInfo) {
fDomains.add(domainInfo);
}
-
+
/*
* (non-Javadoc)
- * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#hashCode()
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceInfo#formatString()
*/
@Override
- public int hashCode() {
- int result = 17;
- result = 37 * result + super.hashCode();
- result = 37 * result + fSessionPath.hashCode();
- result = 37 * result + fState.hashCode();
+ @SuppressWarnings("nls")
+ public String formatString() {
+ StringBuffer output = new StringBuffer();
+ // Tracing session mysession: [active]
+ output.append("Tracing session ");
+ output.append(getName());
+ output.append(": [");
+ output.append(getSessionState().getInName());
+ output.append("]\n");
+
+ // Trace path: /home/user/lttng-traces/mysession-20120129-084256
+ output.append(" Trace path: ");
+ output.append(getSessionPath());
+ output.append("\n");
+
for (Iterator<IDomainInfo> iterator = fDomains.iterator(); iterator.hasNext();) {
IDomainInfo domain = (IDomainInfo) iterator.next();
- result = 37 * result + domain.hashCode();
+ output.append(domain.formatString());
}
+ return output.toString();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((fDomains == null) ? 0 : fDomains.hashCode());
+ result = prime * result + ((fSessionPath == null) ? 0 : fSessionPath.hashCode());
+ result = prime * result + ((fState == null) ? 0 : (fState.ordinal() + 1));
return result;
}
* @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object)
*/
@Override
- public boolean equals(Object other) {
- if (!(other instanceof SessionInfo)) {
- return false;
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
}
- SessionInfo otherInfo = (SessionInfo) other;
- if (!super.equals(otherInfo)) {
+ if (!super.equals(obj)) {
return false;
}
-
- if (!fSessionPath.equals(otherInfo.fSessionPath)) {
+ if (getClass() != obj.getClass()) {
return false;
}
-
- if (fState.ordinal() != otherInfo.fState.ordinal()) {
- return false;
- }
-
- if (fDomains.size() != otherInfo.fDomains.size()) {
+ SessionInfo other = (SessionInfo) obj;
+ if (fDomains == null) {
+ if (other.fDomains != null) {
+ return false;
+ }
+ } else if (!fDomains.equals(other.fDomains)) {
return false;
}
- for (int i = 0; i < fDomains.size(); i++) {
- if (!fDomains.get(i).equals(otherInfo.fDomains.get(i))) {
+ if (fSessionPath == null) {
+ if (other.fSessionPath != null) {
return false;
}
+ } else if (!fSessionPath.equals(other.fSessionPath)) {
+ return false;
+ }
+ if (fState != other.fState) {
+ return false;
}
return true;
}
-
+
/*
* (non-Javadoc)
* @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#toString()
output.append(fState);
output.append(",Domains=");
for (Iterator<IDomainInfo> iterator = fDomains.iterator(); iterator.hasNext();) {
- IDomainInfo channel = (IDomainInfo) iterator.next();
- output.append(channel.toString());
+ IDomainInfo domain = (IDomainInfo) iterator.next();
+ output.append(domain.toString());
}
output.append(")]");
return output.toString();
*
* @throws ExecutionException
*/
- public void getConfigurationFromNode() throws ExecutionException {
+ public void getConfigurationFromNode() {
Job job = new Job(Messages.TraceControl_RetrieveNodeConfigurationJob) {
@Override
protected IStatus run(IProgressMonitor monitor) {
};
job.setUser(true);
job.schedule();
+ }
+ public void refresh() {
+ removeAllChildren();
+ getConfigurationFromNode();
}
// ------------------------------------------------------------------------
fChannelInfo = channelInfo;
IEventInfo[] events = fChannelInfo.getEvents();
for (int i = 0; i < events.length; i++) {
- TraceEventComponent event = new TraceEventComponent(events[i].getName(), this);
+ TraceEventComponent event = null;
+ if (events[i].getClass() == ProbeEventInfo.class) {
+ event = new TraceProbeEventComponent(events[i].getName(), this);
+ } else {
+ event = new TraceEventComponent(events[i].getName(), this);
+ }
+
event.setEventInfo(events[i]);
addChild(event);
}
/**
* Enables a dynamic probe (for kernel domain)
* @param eventName - event name for probe
+ * @param isFunction - true for dynamic function entry/return probe else false
* @param probe - the actual probe
* @throws ExecutionException
*/
- public void enableProbe(String eventName, String probe) throws ExecutionException {
- enableProbe(eventName, probe, new NullProgressMonitor());
+ public void enableProbe(String eventName, boolean isFunction, String probe) throws ExecutionException {
+ enableProbe(eventName, isFunction, probe, new NullProgressMonitor());
}
/**
* Enables a dynamic probe (for kernel domain)
* @param eventName - event name for probe
+ * @param isFunction - true for dynamic function entry/return probe else false
* @param probe - the actual probe
* @param monitor - a progress monitor
* @throws ExecutionException
*/
- public void enableProbe(String eventName, String probe, IProgressMonitor monitor) throws ExecutionException {
- getControlService().enableProbe(getSessionName(), getName(), eventName, probe, monitor);
+ public void enableProbe(String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
+ getControlService().enableProbe(getSessionName(), getName(), eventName, isFunction, probe, monitor);
}
- /**
- * Enables a dynamic function entry/return probe (for kernel domain)
- * @param eventName - event name for probe
- * @param probe - the actual probe
- * @throws ExecutionException
- */
- public void enableFunctionProbe(String eventName, String probe) throws ExecutionException {
- enableFunctionProbe(eventName, probe, new NullProgressMonitor());
- }
-
- /**
- * Enables a dynamic function entry/return probe (for kernel domain)
- * @param eventName - event name for probe
- * @param probe - the actual probe
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- public void enableFunctionProbe(String eventName, String probe, IProgressMonitor monitor) throws ExecutionException {
- getControlService().enableFunctionProbe(getSessionName(), getName(), eventName, probe, monitor);
- }
-
/**
* Enables events using log level.
* @param eventName - a event name
/**
* Enables a dynamic probe (for kernel domain)
* @param eventName - event name for probe
- * @param probe - the actual probe
+ * @param isFunction - true for dynamic function entry/return probe else false
+ * @param probe - the actual probe
* @throws ExecutionException
*/
- public void enableProbe(String eventName, String probe) throws ExecutionException {
- enableProbe(eventName, probe, new NullProgressMonitor());
+ public void enableProbe(String eventName, boolean isFunction, String probe) throws ExecutionException {
+ enableProbe(eventName, isFunction, probe, new NullProgressMonitor());
}
/**
* Enables a dynamic probe (for kernel domain)
* @param eventName - event name for probe
+ * @param isFunction - true for dynamic function entry/return probe else false
* @param probe - the actual probe
* @param monitor - a progress monitor
* @throws ExecutionException
*/
- public void enableProbe(String eventName, String probe, IProgressMonitor monitor) throws ExecutionException {
- getControlService().enableProbe(getSessionName(), null, eventName, probe, monitor);
+ public void enableProbe(String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
+ getControlService().enableProbe(getSessionName(), null, eventName, isFunction, probe, monitor);
}
- /**
- * Enables a dynamic function entry/return probe (for kernel domain)
- * @param eventName - event name for probe
- * @param probe - the actual probe
- * @throws ExecutionException
- */
- public void enableFunctionProbe(String eventName, String probe) throws ExecutionException {
- enableFunctionProbe(eventName, probe, new NullProgressMonitor());
- }
-
- /**
- * Enables a dynamic function entry/return probe (for kernel domain)
- * @param eventName - event name for probe
- * @param probe - the actual probe
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- public void enableFunctionProbe(String eventName, String probe, IProgressMonitor monitor) throws ExecutionException {
- getControlService().enableFunctionProbe(getSessionName(), null, eventName, probe, monitor);
- }
-
/**
* Enables events using log level.
* @param eventName - a event name
/**
- * <b><u>TraceChannelComponent</u></b>
+ * <b><u>TraceEventComponent</u></b>
* <p>
* Implementation of the trace channel component.
* </p>
/**
* The event information.
*/
- private IEventInfo fEventInfo = null;
+ protected IEventInfo fEventInfo = null;
/**
* The image to be displayed when in disabled state.
*/
fName = name;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceInfo#formatString()
+ */
+ @Override
+ public String formatString() {
+ return toString();
+ }
+
/*
* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
- if (fName == null) {
- return 17;
- }
- return fName.hashCode();
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((fName == null) ? 0 : fName.hashCode());
+ return result;
}
/*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
- public boolean equals(Object other) {
- if (!(other instanceof TraceInfo)) {
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
return false;
}
-
- TraceInfo otherInfo = (TraceInfo) other;
- return fName.equals(otherInfo.fName);
- }
-
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ TraceInfo other = (TraceInfo) obj;
+ if (fName == null) {
+ if (other.fName != null) {
+ return false;
+ }
+ } else if (!fName.equals(other.fName)) {
+ return false;
+ }
+ return true;
+ }
/*
* (non-Javadoc)
* @see java.lang.Object#toString()
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng.ui.views.control.model.impl;
+
+import org.eclipse.linuxtools.lttng.ui.views.control.model.IEventInfo;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceControlComponent;
+import org.eclipse.linuxtools.lttng.ui.views.control.property.TraceProbeEventPropertySource;
+import org.eclipse.ui.views.properties.IPropertySource;
+
+
+/**
+ * <b><u>TraceProbeEventComponent</u></b>
+ * <p>
+ * Implementation of the trace channel component.
+ * </p>
+ */
+public class TraceProbeEventComponent extends TraceEventComponent {
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param name - the name of the component.
+ * @param parent - the parent of this component.
+ */
+ public TraceProbeEventComponent(String name, ITraceControlComponent parent) {
+ super(name, parent);
+ fEventInfo = new ProbeEventInfo(name);
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Sets the event information.
+ * @param eventInfo - the event information to set.
+ */
+ @Override
+ public void setEventInfo(IEventInfo eventInfo) {
+ if (eventInfo instanceof ProbeEventInfo) {
+ fEventInfo = eventInfo;
+ return;
+ }
+ throw new IllegalArgumentException("Invalid type passed. Only class of type ProbeEventInfo allowed:\n" + eventInfo.getClass()); //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
+ */
+ @SuppressWarnings("rawtypes")
+ @Override
+ public Object getAdapter(Class adapter) {
+ if (adapter == IPropertySource.class) {
+ return new TraceProbeEventPropertySource(this);
+ }
+ return null;
+ }
+ /**
+ * @return the address of the probe. (null if Symbol is used)
+ */
+ public String getAddress() {
+ return getEventInfo().getAddress();
+ }
+ /**
+ * Sets the address of the probe.
+ * @param address - a address
+ */
+ public void setAddress(String address) {
+ getEventInfo().setAddress(address);
+ }
+ /**
+ * @return the offset applied to the symbol.
+ */
+ public String getOffset() {
+ return getEventInfo().getOffset();
+ }
+ /**
+ * Sets the offset applied to the symbol. (valid if symbol is used)
+ * @param offset - a offset
+ */
+ public void setOffset(String offset) {
+ getEventInfo().setOffset(offset);
+ }
+ /**
+ * @return the symbol name. (null if address is used)
+ */
+ public String getSymbol() {
+ return getEventInfo().getSymbol();
+ }
+ /**
+ * Sets the symbol name.
+ * @param symbol - a symbol name (null if address is used)
+ */
+ public void setSymbol(String symbol) {
+ getEventInfo().setSymbol(symbol);
+ }
+
+ // ------------------------------------------------------------------------
+ // Helper methods
+ // ------------------------------------------------------------------------
+ private ProbeEventInfo getEventInfo() {
+ return (ProbeEventInfo) fEventInfo;
+ }
+
+}
/**
* Enables a dynamic probe (for kernel domain)
* @param eventName - event name for probe
+ * @param isFunction - true for dynamic function entry/return probe else false
* @param probe - the actual probe
* @throws ExecutionException
*/
- public void enableProbe(String eventName, String probe) throws ExecutionException {
- enableProbe(eventName, probe, new NullProgressMonitor());
+ public void enableProbe(String eventName, boolean isFunction, String probe) throws ExecutionException {
+ enableProbe(eventName, isFunction, probe, new NullProgressMonitor());
}
/**
* Enables a dynamic probe (for kernel domain)
* @param eventName - event name for probe
+ * @param isFunction - true for dynamic function entry/return probe else false
* @param probe - the actual probe
* @param monitor - a progress monitor
* @throws ExecutionException
*/
- public void enableProbe(String eventName, String probe, IProgressMonitor monitor) throws ExecutionException {
- getControlService().enableProbe(getName(), null, eventName, probe, monitor);
- }
-
- /**
- * Enables a dynamic function entry/return probe (for kernel domain)
- * @param eventName - event name for probe
- * @param probe - the actual probe
- * @throws ExecutionException
- */
- public void enableFunctionProbe(String eventName, String probe) throws ExecutionException {
- enableFunctionProbe(eventName, probe, new NullProgressMonitor());
- }
-
- /**
- * Enables a dynamic function entry/return probe (for kernel domain)
- * @param eventName - event name for probe
- * @param probe - the actual probe
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- public void enableFunctionProbe(String eventName, String probe, IProgressMonitor monitor) throws ExecutionException {
- getControlService().enableFunctionProbe(getName(), null, eventName, probe, monitor);
+ public void enableProbe(String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
+ getControlService().enableProbe(getName(), null, eventName, isFunction, probe, monitor);
}
/**
/*
* (non-Javadoc)
- * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#hashCode()
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceInfo#formatString()
*/
+ @SuppressWarnings("nls")
@Override
- public int hashCode() {
- int result = 17;
- result = 37 * result + super.hashCode();
+ public String formatString() {
+ StringBuffer output = new StringBuffer();
+ //PID: 9379 - Name: /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
+ output.append("\nPID: ");
+ output.append(fPid);
+ output.append(" - Name: ");
+ output.append(getName());
for (Iterator<IBaseEventInfo> iterator = fEvents.iterator(); iterator.hasNext();) {
IBaseEventInfo event = (IBaseEventInfo) iterator.next();
- result = 37 * result + event.hashCode();
+ output.append(event.formatString());
}
+ output.append("\n");
+
+ return output.toString();
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((fEvents == null) ? 0 : fEvents.hashCode());
+ result = prime * result + fPid;
return result;
}
* @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object)
*/
@Override
- public boolean equals(Object other) {
- if (!(other instanceof UstProviderInfo)) {
- return false;
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
}
-
- UstProviderInfo otherUstInfo = (UstProviderInfo) other;
- if (!super.equals(otherUstInfo)) {
+ if (!super.equals(obj)) {
return false;
}
-
- if (fEvents.size() != otherUstInfo.fEvents.size()) {
+ if (getClass() != obj.getClass()) {
return false;
}
- for (int i = 0; i < fEvents.size(); i++) {
- if (!fEvents.get(i).equals(otherUstInfo.fEvents.get(i))) {
+ UstProviderInfo other = (UstProviderInfo) obj;
+ if (fEvents == null) {
+ if (other.fEvents != null) {
return false;
}
+ } else if (!fEvents.equals(other.fEvents)) {
+ return false;
+ }
+ if (fPid != other.fPid) {
+ return false;
}
return true;
}
output.append(")]");
return output.toString();
}
+
+
}
/**
* The event component which this property source is for.
*/
- private final TraceEventComponent fEvent;
+ protected final TraceEventComponent fEvent;
// ------------------------------------------------------------------------
// Constructors
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng.ui.views.control.property;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.linuxtools.lttng.ui.views.control.Messages;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceEventComponent;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceProbeEventComponent;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+
+/**
+ * <b><u>TraceEventPropertySource</u></b>
+ * <p>
+ * Property source implementation for the trace probe event component.
+ * </p>
+ */
+public class TraceProbeEventPropertySource extends TraceEventPropertySource {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * The trace event 'probe address' property ID.
+ */
+ public static final String TRACE_EVENT_PROBE_ADDRESS_PROPERTY_ID = "trace.event.probe.address"; //$NON-NLS-1$
+ /**
+ * The trace event 'probe offset' property ID.
+ */
+ public static final String TRACE_EVENT_PROBE_OFFSET_PROPERTY_ID = "trace.event.probe.offset"; //$NON-NLS-1$
+ /**
+ * The trace event 'probe symbol' property ID.
+ */
+ public static final String TRACE_EVENT_PROBE_SYMBOL_PROPERTY_ID = "trace.event.probe.symbol"; //$NON-NLS-1$
+ /**
+ * The trace event 'probe address' property name.
+ */
+ public static final String TRACE_EVENT_PROBE_ADDRESS_PROPERTY_NAME = Messages.TraceControl_ProbeAddressPropertyName;
+ /**
+ * The trace event 'probe offset' property ID.
+ */
+ public static final String TRACE_EVENT_PROBE_OFFSET_PROPERTY_NAME = Messages.TraceControl_ProbeOffsetPropertyName;
+ /**
+ * The trace event 'probe symbol' property ID.
+ */
+ public static final String TRACE_EVENT_PROBE_SYMBOL_PROPERTY_NAME = Messages.TraceControl_ProbeSymbolPropertyName;
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ public TraceProbeEventPropertySource(TraceEventComponent component) {
+ super(component);
+ if (component.getClass() != TraceProbeEventComponent.class) {
+ throw new IllegalArgumentException("Invalid type passed. Only class of type TraceProbeEventComponent allowed:\n" + component.getClass()); //$NON-NLS-1$
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
+ */
+ @Override
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ IPropertyDescriptor[] superProperties = super.getPropertyDescriptors();
+ List<IPropertyDescriptor> list = new ArrayList<IPropertyDescriptor>();
+ for (int i = 0; i < superProperties.length; i++) {
+ list.add(superProperties[i]);
+ }
+
+ if (fEvent instanceof TraceProbeEventComponent) {
+ TraceProbeEventComponent event = (TraceProbeEventComponent) fEvent;
+ if (event.getAddress() != null) {
+ list.add(new TextPropertyDescriptor(TRACE_EVENT_PROBE_ADDRESS_PROPERTY_ID, TRACE_EVENT_PROBE_ADDRESS_PROPERTY_NAME));
+ }
+
+ if (event.getOffset() != null) {
+ list.add(new TextPropertyDescriptor(TRACE_EVENT_PROBE_OFFSET_PROPERTY_ID, TRACE_EVENT_PROBE_OFFSET_PROPERTY_NAME));
+ }
+
+ if (event.getSymbol() != null) {
+ list.add(new TextPropertyDescriptor(TRACE_EVENT_PROBE_SYMBOL_PROPERTY_ID, TRACE_EVENT_PROBE_SYMBOL_PROPERTY_NAME));
+ }
+ }
+ return (IPropertyDescriptor [])list.toArray(new IPropertyDescriptor[list.size()]);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
+ */
+ @Override
+ public Object getPropertyValue(Object id) {
+ if(TRACE_EVENT_PROBE_ADDRESS_PROPERTY_ID.equals(id)) {
+ return ((TraceProbeEventComponent)fEvent).getAddress();
+ }
+ if (TRACE_EVENT_PROBE_OFFSET_PROPERTY_ID.equals(id)) {
+ return ((TraceProbeEventComponent)fEvent).getOffset();
+ }
+ if (TRACE_EVENT_PROBE_SYMBOL_PROPERTY_ID.equals(id)) {
+ return ((TraceProbeEventComponent)fEvent).getSymbol();
+ }
+ return super.getPropertyValue(id);
+ }
+}
/**
* Enables a list of channels for given session and given channel information (configuration).
* @param sessionName - a session name to create
- * @param channelNames - a list of channel names to enable
+ * @param channelNames - a list of channel names to be enabled
* @param isKernel - a flag to indicate Kernel or UST (true for Kernel, false for UST)
* @param info - channel information used for creation of a channel (or null for default)
* @param monitor - a progress monitor
/**
* Disables a list of channels for given session and given channel information (configuration).
* @param sessionName - a session name to create
- * @param channelNames - a list of channel names to enable
+ * @param channelNames - a list of channel names to be enabled
* @param isKernel - a flag to indicate Kernel or UST (true for Kernel, false for UST)
* @param monitor - a progress monitor
* @throws ExecutionException
/**
* Enables a list of events with no additional parameters.
* @param sessionName - a session name
- * @param channelName - a channel name (null for default channel)
- * @param eventNames - a list of event names to enabled.
+ * @param channelName - a channel name or null for default channel
+ * @param eventNames - a list of event names to be enabled, or null (list of size = 0)for all events .
* @param isKernel - a flag for indicating kernel or UST.
* @param monitor - a progress monitor
* @throws ExecutionException
/**
* Enables all syscall events.
* @param sessionName - a session name
- * @param channelName - a channel name (null for default channel)
+ * @param channelName - a channel name or null for default channel
* @param monitor - a progress monitor
* @throws ExecutionException
*/
public void enableSyscalls(String sessionName, String channelName, IProgressMonitor monitor) throws ExecutionException;
/**
- * Enables a dynamic probe.
+ * Enables a dynamic probe or dynamic function entry/return probe.
* @param sessionName - a session name
- * @param channelName - a channel name (null for default channel)
+ * @param channelName - a channel name or null for default channel
* @param eventName - a event name
+ * @param isFunction - true for dynamic function entry/return probe else false
* @param probe - a dynamic probe information
* @param monitor - a progress monitor
* @throws ExecutionException
*/
- public void enableProbe(String sessionName, String channelName, String eventName, String probe, IProgressMonitor monitor) throws ExecutionException;
-
- /**
- * Enables a dynamic function entry/return probe.
- * @param sessionName - a session name
- * @param channelName - a channel name (null for default channel)
- * @param eventName - a event name
- * @param function - a dynamic function entry/return probe information
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- public void enableFunctionProbe(String sessionName, String channelName, String eventName, String function, IProgressMonitor monitor) throws ExecutionException;
+ public void enableProbe(String sessionName, String channelName, String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException;
/**
* Enables events using log level
import org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.IDomainInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.IEventInfo;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.IProbeEventInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.ISessionInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.IUstProviderInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.LogLevelType;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceEventType;
import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceLogLevel;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.BaseEventInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.ChannelInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.DomainInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.EventInfo;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.ProbeEventInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.SessionInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.UstProviderInfo;
* Pattern to match a wildcarded event information (lttng list <session>)
*/
private final static Pattern WILDCARD_EVENT_PATTERN = Pattern.compile("\\s+(.*)\\s+\\(type:\\s+(.*)\\)\\s+\\[(enabled|disabled)\\].*"); //$NON-NLS-1$
+ /**
+ * Pattern to match a probe address information (lttng list <session>)
+ */
+ private final static Pattern PROBE_ADDRESS_PATTERN = Pattern.compile("\\s+(addr)\\:\\s+(0x[0-9a-fA-F]{1,8})"); //$NON-NLS-1$
+ /**
+ * Pattern to match a probe OFFSET information (lttng list <session>)
+ */
+ private final static Pattern PROBE_OFFSET_PATTERN = Pattern.compile("\\s+(offset)\\:\\s+(0x[0-9a-fA-F]{1,8})"); //$NON-NLS-1$
+ /**
+ * Pattern to match a probe SYMBOL information (lttng list <session>)
+ */
+ private final static Pattern PROBE_SYMBOL_PATTERN = Pattern.compile("\\s+(symbol)\\:\\s+(.+)"); //$NON-NLS-1$
/**
* Pattern to match for channel (overwite mode) information (lttng list
* <session>)
*/
@Override
public ISessionInfo getSession(String sessionName, IProgressMonitor monitor) throws ExecutionException {
+
String command = COMMAND_LIST + sessionName;
ICommandResult result = fCommandShell.executeCommand(command, monitor);
-
+
+
if (isError(result)) {
throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
}
StringBuffer command = new StringBuffer(COMMAND_ENABLE_EVENT);
- if (eventNames == null) {
+ if (eventNames == null || eventNames.size() == 0) {
command.append(OPTION_ALL);
} else {
- // no events to enable
- if (eventNames.size() == 0) {
- return;
- }
for (Iterator<String> iterator = eventNames.iterator(); iterator.hasNext();) {
String event = (String) iterator.next();
* @see org.eclipse.linuxtools.lttng.ui.views.control.service.ILttngControlService#enableProbe(java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- public void enableProbe(String sessionName, String channelName, String eventName, String probe, IProgressMonitor monitor) throws ExecutionException {
+ public void enableProbe(String sessionName, String channelName, String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
String newSessionName = formatParameter(sessionName);
StringBuffer command = new StringBuffer(COMMAND_ENABLE_EVENT);
command.append(OPTION_CHANNEL);
command.append(channelName);
}
-
- command.append(OPTION_PROBE);
- command.append(probe);
-
- ICommandResult result = fCommandShell.executeCommand(command.toString(), monitor);
-
- if (isError(result)) {
- throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.lttng.ui.views.control.service.ILttngControlService#enableFunctionProbe(java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void enableFunctionProbe(String sessionName, String channelName, String eventName, String probe, IProgressMonitor monitor) throws ExecutionException {
- String newSessionName = formatParameter(sessionName);
-
- StringBuffer command = new StringBuffer(COMMAND_ENABLE_EVENT);
-
- command.append(eventName);
- command.append(OPTION_KERNEL);
-
- command.append(OPTION_SESSION);
- command.append(newSessionName);
-
- if (channelName != null) {
- command.append(OPTION_CHANNEL);
- command.append(channelName);
+ if (isFunction) {
+ command.append(OPTION_FUNCTION_PROBE);
+ } else {
+ command.append(OPTION_PROBE);
}
- command.append(OPTION_FUNCTION_PROBE);
command.append(probe);
ICommandResult result = fCommandShell.executeCommand(command.toString(), monitor);
if (isError(result)) {
throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
- }
+ }
}
/*
eventInfo.setEventType(matcher.group(3).trim());
eventInfo.setState(matcher.group(4));
events.add(eventInfo);
+ index++;
} else if (matcher2.matches()) {
IEventInfo eventInfo = new EventInfo(matcher2.group(1).trim());
eventInfo.setLogLevel(TraceLogLevel.LEVEL_UNKNOWN);
eventInfo.setEventType(matcher2.group(2).trim());
eventInfo.setState(matcher2.group(3));
- events.add(eventInfo);
+
+ if (eventInfo.getEventType() == TraceEventType.PROBE) {
+ IProbeEventInfo probeEvent = new ProbeEventInfo(eventInfo.getName());
+ probeEvent.setLogLevel(eventInfo.getLogLevel());
+ probeEvent.setEventType(eventInfo.getEventType());
+ probeEvent.setState(eventInfo.getState());
+
+ // Overwrite eventinfo
+ eventInfo = probeEvent;
+
+ // myevent2 (type: probe) [enabled]
+ // addr: 0xc0101340
+ // myevent0 (type: probe) [enabled]
+ // offset: 0x0
+ // symbol: init_post
+ index++;
+ while (index < output.length) {
+ String probeLine = output[index];
+ // parse probe
+ Matcher addrMatcher = PROBE_ADDRESS_PATTERN.matcher(probeLine);
+ Matcher offsetMatcher = PROBE_OFFSET_PATTERN.matcher(probeLine);
+ Matcher symbolMatcher = PROBE_SYMBOL_PATTERN.matcher(probeLine);
+ if (addrMatcher.matches()) {
+ String addr = addrMatcher.group(2).trim();
+ probeEvent.setAddress(addr);
+ } else if (offsetMatcher.matches()) {
+ String offset = offsetMatcher.group(2).trim();
+ probeEvent.setOffset(offset);
+ } else if (symbolMatcher.matches()) {
+ String symbol = symbolMatcher.group(2).trim();
+ probeEvent.setSymbol(symbol);
+ } else if ((EVENT_PATTERN.matcher(probeLine).matches()) || (WILDCARD_EVENT_PATTERN.matcher(probeLine).matches())) {
+ break;
+ } else if (CHANNEL_PATTERN.matcher(probeLine).matches()) {
+ break;
+ } else if (DOMAIN_KERNEL_PATTERN.matcher(probeLine).matches()) {
+ // end of domain
+ break;
+ } else if (DOMAIN_UST_GLOBAL_PATTERN.matcher(probeLine).matches()) {
+ // end of domain
+ break;
+ }
+ index++;
+ }
+ events.add(eventInfo);
+ } else {
+ events.add(eventInfo);
+ index++;
+ continue;
+ }
+ } else {
+ index++;
}
// else if (line.matches(EVENT_NONE_PATTERN)) {
// do nothing
// } else
- index++;
+
}
return index;