From d132bcc71fa0ff07cf2a3f0b6258f38abb546fb7 Mon Sep 17 00:00:00 2001 From: Bernd Hufmann Date: Thu, 15 Mar 2012 08:53:30 -0400 Subject: [PATCH] Added some more JUnit tests --- .../control/model/component/AllTests.java | 1 + .../component/TraceControlPropertiesTest.java | 62 +- .../component/TraceControlProviderTests.java | 948 ++++++++++++++++++ .../component/TraceControlTestFacility.java | 16 + .../component/TraceControlTreeModelTest.java | 58 +- .../ui/tests/control/model/impl/AllTests.java | 1 + .../control/model/impl/ModelImplFactory.java | 24 + .../model/impl/ProbeEventInfoTest.java | 208 ++++ .../service/LTTngControlServiceTest.java | 314 +++++- .../stubs/service/CommandShellFactory.java | 54 +- .../stubs/service/TestRemoteSystemProxy.java | 43 +- .../shells/GetSessionGarbageShell.java | 20 - .../service/shells/LTTngToolsFileShell.java | 259 +++++ .../service/shells/LttngNotExistsShell.java | 17 - .../service/shells/NoSessionNamesShell.java | 17 - .../service/shells/NoUstProviderShell.java | 24 - .../shells/SessionCreationErrorsShell.java | 47 - .../service/shells/SessionNamesShell.java | 139 --- .../service/shells/SessionNotExistsShell.java | 20 - .../testfiles/CreateTreeTest.cfg | 306 ++++++ .../testfiles/LTTngServiceTest.cfg | 541 ++++++++++ .../testfiles/ListInfoTest.cfg | 157 +++ .../icons/elcl16/refresh.gif | Bin 0 -> 327 bytes .../plugin.properties | 4 + org.eclipse.linuxtools.lttng.ui/plugin.xml | 45 + .../lttng/ui/views/control/ControlView.java | 24 + .../lttng/ui/views/control/Messages.java | 5 +- .../views/control/dialogs/ConfirmDialog.java | 39 + .../control/dialogs/CreateChannelDialog.java | 33 +- .../control/dialogs/CreateSessionDialog.java | 13 +- .../control/dialogs/EnableEventsDialog.java | 47 +- .../control/dialogs/GetEventInfoDialog.java | 24 +- .../views/control/dialogs/IConfirmDialog.java | 26 + .../control/dialogs/ICreateChannelDialog.java | 7 + .../control/dialogs/ICreateSessionDialog.java | 8 + .../control/dialogs/IEnableEventsDialog.java | 15 + .../control/dialogs/IGetEventInfoDialog.java | 12 + .../control/dialogs/INewConnectionDialog.java | 15 + .../control/dialogs/NewConnectionDialog.java | 26 +- .../dialogs/TraceControlDialogFactory.java | 203 ++++ .../control/handlers/AssignEventHandler.java | 33 +- .../handlers/BaseEnableEventHandler.java | 26 +- .../handlers/ChangeEventStateHandler.java | 4 +- .../CreateChannelOnDomainHandler.java | 13 +- .../CreateChannelOnSessionHandler.java | 12 +- .../handlers/CreateSessionHandler.java | 11 +- .../handlers/DestroySessionHandler.java | 7 +- .../handlers/EnableEventOnChannelHandler.java | 15 +- .../handlers/EnableEventOnDomainHandler.java | 15 +- .../handlers/EnableEventOnSessionHandler.java | 15 +- .../handlers/NewConnectionHandler.java | 6 +- .../control/handlers/RefreshHandler.java | 93 ++ .../ui/views/control/messages.properties | 5 +- .../views/control/model/IProbeEventInfo.java | 54 + .../ui/views/control/model/ITraceInfo.java | 5 + .../control/model/impl/BaseEventInfo.java | 58 +- .../views/control/model/impl/ChannelInfo.java | 119 ++- .../views/control/model/impl/DomainInfo.java | 66 +- .../views/control/model/impl/EventInfo.java | 40 +- .../control/model/impl/ProbeEventInfo.java | 229 +++++ .../views/control/model/impl/SessionInfo.java | 79 +- .../model/impl/TargetNodeComponent.java | 6 +- .../model/impl/TraceChannelComponent.java | 39 +- .../model/impl/TraceDomainComponent.java | 33 +- .../model/impl/TraceEventComponent.java | 4 +- .../views/control/model/impl/TraceInfo.java | 42 +- .../model/impl/TraceProbeEventComponent.java | 124 +++ .../model/impl/TraceSessionComponent.java | 31 +- .../control/model/impl/UstProviderInfo.java | 56 +- .../property/TraceEventPropertySource.java | 2 +- .../TraceProbeEventPropertySource.java | 122 +++ .../control/service/ILttngControlService.java | 28 +- .../control/service/LTTngControlService.java | 120 ++- 73 files changed, 4516 insertions(+), 818 deletions(-) create mode 100644 org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/model/component/TraceControlProviderTests.java create mode 100644 org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/model/impl/ProbeEventInfoTest.java delete mode 100644 org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/GetSessionGarbageShell.java create mode 100644 org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/LTTngToolsFileShell.java delete mode 100644 org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/LttngNotExistsShell.java delete mode 100644 org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/NoSessionNamesShell.java delete mode 100644 org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/NoUstProviderShell.java delete mode 100644 org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/SessionCreationErrorsShell.java delete mode 100644 org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/SessionNamesShell.java delete mode 100644 org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/SessionNotExistsShell.java create mode 100644 org.eclipse.linuxtools.lttng.ui.tests/testfiles/CreateTreeTest.cfg create mode 100644 org.eclipse.linuxtools.lttng.ui.tests/testfiles/LTTngServiceTest.cfg create mode 100644 org.eclipse.linuxtools.lttng.ui.tests/testfiles/ListInfoTest.cfg create mode 100644 org.eclipse.linuxtools.lttng.ui/icons/elcl16/refresh.gif create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/ConfirmDialog.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/IConfirmDialog.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/TraceControlDialogFactory.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/RefreshHandler.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/IProbeEventInfo.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/ProbeEventInfo.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceProbeEventComponent.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/property/TraceProbeEventPropertySource.java diff --git a/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/model/component/AllTests.java b/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/model/component/AllTests.java index 76064d27d3..a6258d9f35 100644 --- a/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/model/component/AllTests.java +++ b/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/model/component/AllTests.java @@ -22,6 +22,7 @@ public class AllTests { //$JUnit-BEGIN$ suite.addTestSuite(TraceControlComponentTest.class); suite.addTestSuite(TraceControlTreeModelTest.class); + suite.addTestSuite(TraceControlProviderTests.class); suite.addTestSuite(TraceControlPropertiesTest.class); //$JUnit-END$ return new ModelImplTestSetup(suite); diff --git a/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/model/component/TraceControlPropertiesTest.java b/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/model/component/TraceControlPropertiesTest.java index ced2114e6e..27e2329973 100644 --- a/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/model/component/TraceControlPropertiesTest.java +++ b/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/model/component/TraceControlPropertiesTest.java @@ -11,11 +11,17 @@ **********************************************************************/ 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; @@ -29,6 +35,7 @@ import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TargetNodeCompon 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; @@ -37,6 +44,7 @@ import org.eclipse.linuxtools.lttng.ui.views.control.property.TargetNodeProperty 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; @@ -52,6 +60,14 @@ import org.junit.Before; */ @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 @@ -105,6 +121,11 @@ public class TraceControlPropertiesTest extends TestCase { 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") @@ -266,7 +287,7 @@ public class TraceControlPropertiesTest extends TestCase { // ------------------------------------------------------------------------ ITraceControlComponent[] channel0Events = channel.getChildren(); assertNotNull(channel0Events); - assertEquals(2, channel0Events.length); + assertEquals(5, channel0Events.length); assertTrue(channel0Events[0] instanceof TraceEventComponent); TraceEventComponent event = (TraceEventComponent) channel0Events[0]; @@ -282,5 +303,44 @@ public class TraceControlPropertiesTest extends TestCase { 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 diff --git a/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/model/component/TraceControlProviderTests.java b/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/model/component/TraceControlProviderTests.java new file mode 100644 index 0000000000..ab9c43e6d9 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/model/component/TraceControlProviderTests.java @@ -0,0 +1,948 @@ +/********************************************************************** + * 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 TraceControlTreeModelTest 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 diff --git a/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/model/component/TraceControlTestFacility.java b/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/model/component/TraceControlTestFacility.java index 9dc19ae41e..45331790bf 100644 --- a/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/model/component/TraceControlTestFacility.java +++ b/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/model/component/TraceControlTestFacility.java @@ -11,12 +11,19 @@ *******************************************************************************/ 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 @@ -31,6 +38,8 @@ public class TraceControlTestFacility { 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 // ------------------------------------------------------------------------ @@ -124,4 +133,11 @@ public class TraceControlTestFacility { 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); + } + } diff --git a/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/model/component/TraceControlTreeModelTest.java b/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/model/component/TraceControlTreeModelTest.java index 48764a198e..691c7b15a3 100644 --- a/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/model/component/TraceControlTreeModelTest.java +++ b/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/model/component/TraceControlTreeModelTest.java @@ -11,12 +11,17 @@ **********************************************************************/ 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; @@ -27,20 +32,18 @@ import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.BaseEventCompone 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; @@ -50,10 +53,17 @@ 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 // ------------------------------------------------------------------------ @@ -80,6 +90,10 @@ public class TraceControlTreeModelTest extends TestCase { @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(); } /** @@ -100,15 +114,16 @@ public class TraceControlTreeModelTest extends TestCase { 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(); @@ -290,9 +305,12 @@ public class TraceControlTreeModelTest extends TestCase { // ------------------------------------------------------------------------ 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()); @@ -306,6 +324,30 @@ public class TraceControlTreeModelTest extends TestCase { 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 // ------------------------------------------------------------------------ diff --git a/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/model/impl/AllTests.java b/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/model/impl/AllTests.java index 69d35da7ba..059bc9b6e3 100644 --- a/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/model/impl/AllTests.java +++ b/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/model/impl/AllTests.java @@ -23,6 +23,7 @@ public class AllTests { 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); diff --git a/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/model/impl/ModelImplFactory.java b/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/model/impl/ModelImplFactory.java index 581cb12d62..305f48c2c0 100644 --- a/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/model/impl/ModelImplFactory.java +++ b/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/model/impl/ModelImplFactory.java @@ -15,6 +15,7 @@ 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.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; @@ -25,6 +26,7 @@ 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; @@ -47,6 +49,8 @@ public class ModelImplFactory { 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"); @@ -115,6 +119,17 @@ public class ModelImplFactory { 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() { @@ -168,4 +183,13 @@ public class ModelImplFactory { public IUstProviderInfo getUstProviderInfo2() { return fUstProviderInfo2; } + + public IProbeEventInfo getProbeEventInfo1() { + return fProbeEventInfo1; + } + + public IProbeEventInfo getProbeEventInfo2() { + return fProbeEventInfo2; + } + } diff --git a/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/model/impl/ProbeEventInfoTest.java b/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/model/impl/ProbeEventInfoTest.java new file mode 100644 index 0000000000..64765611ec --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/model/impl/ProbeEventInfoTest.java @@ -0,0 +1,208 @@ +/********************************************************************** + * 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 BaseEventInfoTest contains test for the class {@link BaseEventInfo}. + */ +@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 diff --git a/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/service/LTTngControlServiceTest.java b/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/service/LTTngControlServiceTest.java index e4b979a42d..b7bfb70136 100644 --- a/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/service/LTTngControlServiceTest.java +++ b/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/service/LTTngControlServiceTest.java @@ -11,24 +11,32 @@ **********************************************************************/ 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; /** @@ -36,10 +44,33 @@ 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 @@ -58,6 +89,14 @@ public class LTTngControlServiceTest extends TestCase { 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); } /** @@ -76,10 +115,9 @@ public class LTTngControlServiceTest extends TestCase { 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 } @@ -87,8 +125,8 @@ public class LTTngControlServiceTest extends TestCase { 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); @@ -97,11 +135,11 @@ public class LTTngControlServiceTest extends TestCase { 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); @@ -112,11 +150,11 @@ public class LTTngControlServiceTest extends TestCase { 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) { @@ -126,8 +164,8 @@ public class LTTngControlServiceTest extends TestCase { 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); @@ -139,8 +177,8 @@ public class LTTngControlServiceTest extends TestCase { 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); @@ -240,7 +278,7 @@ public class LTTngControlServiceTest extends TestCase { 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()); @@ -256,8 +294,8 @@ public class LTTngControlServiceTest extends TestCase { public void testGetKernelProvider() { try { - ILttngControlService service = new LTTngControlService(fShellFactory.getShellForSessionNames()); - List events = service.getKernelProvider(new NullProgressMonitor()); + fShell.setScenario(SCEN_GET_KERNEL_PROVIDER1); + List events = fService.getKernelProvider(new NullProgressMonitor()); // Verify event info assertNotNull(events); @@ -286,8 +324,8 @@ public class LTTngControlServiceTest extends TestCase { public void testGetUstProvider() { try { - ILttngControlService service = new LTTngControlService(fShellFactory.getShellForSessionNames()); - List providers = service.getUstProvider(); + fShell.setScenario(SCEN_GET_UST_PROVIDER1); + List providers = fService.getUstProvider(); // Check all providers assertNotNull(providers); @@ -337,11 +375,11 @@ public class LTTngControlServiceTest extends TestCase { fail(e.toString()); } } - + public void testUstProvider2() { try { - ILttngControlService service = new LTTngControlService(fShellFactory.getShellForNoUstProvider()); - List providers = service.getUstProvider(); + fShell.setScenario(SCEN_GET_UST_PROVIDER2); + List providers = fService.getUstProvider(); assertNotNull(providers); assertEquals(0, providers.size()); @@ -350,11 +388,12 @@ public class LTTngControlServiceTest extends TestCase { 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()); @@ -364,32 +403,34 @@ public class LTTngControlServiceTest extends TestCase { 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()); @@ -401,7 +442,7 @@ public class LTTngControlServiceTest extends TestCase { } 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()); @@ -415,31 +456,202 @@ public class LTTngControlServiceTest extends TestCase { 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 list = new ArrayList(); + 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 list = new ArrayList(); + 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 list = new ArrayList(); + 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 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 list = new ArrayList(); + 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()); + } + } } diff --git a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/CommandShellFactory.java b/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/CommandShellFactory.java index c461ae6334..e10b595ed2 100644 --- a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/CommandShellFactory.java +++ b/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/CommandShellFactory.java @@ -1,13 +1,17 @@ +/********************************************************************** + * 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 { @@ -22,31 +26,15 @@ 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(); } } diff --git a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/TestRemoteSystemProxy.java b/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/TestRemoteSystemProxy.java index 52ab21d45b..b173597f37 100644 --- a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/TestRemoteSystemProxy.java +++ b/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/TestRemoteSystemProxy.java @@ -1,7 +1,19 @@ +/********************************************************************** + * 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; @@ -12,6 +24,10 @@ import org.eclipse.rse.services.terminals.ITerminalService; 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() { @@ -46,12 +62,23 @@ public class TestRemoteSystemProxy implements IRemoteSystemProxy { @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 @@ -61,5 +88,15 @@ public class TestRemoteSystemProxy implements IRemoteSystemProxy { @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); + } + } } diff --git a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/GetSessionGarbageShell.java b/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/GetSessionGarbageShell.java deleted file mode 100644 index 478b4d5d60..0000000000 --- a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/GetSessionGarbageShell.java +++ /dev/null @@ -1,20 +0,0 @@ -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); - } -} - diff --git a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/LTTngToolsFileShell.java b/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/LTTngToolsFileShell.java new file mode 100644 index 0000000000..2d5f96f87b --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/LTTngToolsFileShell.java @@ -0,0 +1,259 @@ +/********************************************************************** + * 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 = ""; //$NON-NLS-1$ + private final static String SCENARIO_END_KEY = ""; //$NON-NLS-1$ + private final static String INPUT_KEY = ""; //$NON-NLS-1$ + private final static String INPUT_END_KEY = ""; //$NON-NLS-1$ + private final static String RESULT_KEY = ""; //$NON-NLS-1$ + @SuppressWarnings("unused") + private final static String RESULT_END_KEY = ""; //$NON-NLS-1$ + private final static String OUTPUT_KEY = ""; //$NON-NLS-1$ + private final static String OUTPUT_END_KEY = ""; //$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> fScenarioMap = new HashMap>(); + private Map fSessionNameMap = new HashMap(); + + /** + * Parse a scenario file with the format: + * + * ScenarioName + * + * + * Command + * + * + * + * CommandResult + * + * + * + * CommandOutput + * + * + * + * + * 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> values = fScenarioMap.values(); + for (Iterator> iterator = values.iterator(); iterator.hasNext();) { + Map map = (Map) 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 commands. + // The numbers are per scenario. + Map tmpSessionNameMap = new HashMap(); + 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 commandMap = new HashMap(); + fScenarioMap.put(scenario, commandMap); + List 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 (); + } 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 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); + } +} diff --git a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/LttngNotExistsShell.java b/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/LttngNotExistsShell.java deleted file mode 100644 index 66aa0fd0c9..0000000000 --- a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/LttngNotExistsShell.java +++ /dev/null @@ -1,17 +0,0 @@ -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); - } -} diff --git a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/NoSessionNamesShell.java b/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/NoSessionNamesShell.java deleted file mode 100644 index 1a4b483b5b..0000000000 --- a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/NoSessionNamesShell.java +++ /dev/null @@ -1,17 +0,0 @@ -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); - } -} diff --git a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/NoUstProviderShell.java b/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/NoUstProviderShell.java deleted file mode 100644 index d02935a1dc..0000000000 --- a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/NoUstProviderShell.java +++ /dev/null @@ -1,24 +0,0 @@ -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; - } -} - diff --git a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/SessionCreationErrorsShell.java b/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/SessionCreationErrorsShell.java deleted file mode 100644 index 32ff74cb8b..0000000000 --- a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/SessionCreationErrorsShell.java +++ /dev/null @@ -1,47 +0,0 @@ -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 list = new ArrayList(); - 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 list = new ArrayList(); - 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 list = new ArrayList(); - 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 list = new ArrayList(); - 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); - } -} - diff --git a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/SessionNamesShell.java b/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/SessionNamesShell.java deleted file mode 100644 index 173986dcae..0000000000 --- a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/SessionNamesShell.java +++ /dev/null @@ -1,139 +0,0 @@ -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 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 list = new ArrayList(); - 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 list = new ArrayList(); - 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 list = new ArrayList(); - 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 list = new ArrayList(); - 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 list = new ArrayList(); - 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 list = new ArrayList(); - 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); - } -} diff --git a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/SessionNotExistsShell.java b/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/SessionNotExistsShell.java deleted file mode 100644 index 3aeac8307e..0000000000 --- a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/SessionNotExistsShell.java +++ /dev/null @@ -1,20 +0,0 @@ -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); - } -} - diff --git a/org.eclipse.linuxtools.lttng.ui.tests/testfiles/CreateTreeTest.cfg b/org.eclipse.linuxtools.lttng.ui.tests/testfiles/CreateTreeTest.cfg new file mode 100644 index 0000000000..3b087951cb --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui.tests/testfiles/CreateTreeTest.cfg @@ -0,0 +1,306 @@ +#################################################################### +# 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 +#################################################################### + +Initialize + +lttng list + + +0 + + +Currently no available tracing session + + + +lttng list -k + + +0 + + +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) + + + + +lttng list -u + + +0 + + +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) + + + + +#################################################################### +# Scenario: Enable events from kernel provider events +#################################################################### + +Scenario1 + +lttng create mysession + + +0 + + +Session mysession created. +Traces will be written in /home/user/lttng-traces/mysession-20120314-132824 + + + +lttng list mysession + + +0 + + +Tracing session mysession: [inactive] + Trace path: /home/user/lttng-traces/mysession-20120314-132824 + + + + +lttng enable-event sched_kthread_stop,sched_kthread_stop_ret -k -s mysession --tracepoint + + +0 + + +kernel event sched_kthread_stop created in channel channel0 +kernel sched_kthread_stop_ret created in channel channel0 + + + +lttng list mysession + + +0 + + +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] + + + + +lttng disable-event sched_kthread_stop_ret,sched_kthread_stop -k -s mysession -c channel0 + + +0 + + +kernel event sched_kthread_stop_ret disabled in channel channel0 +kernel event sched_kthread_stop disabled in channel channel0 + + + +lttng enable-event sched_kthread_stop -k -s mysession -c channel0 --tracepoint + + +0 + + +kernel event sched_kthread_stop enabled in channel channel0 + + + + +lttng destroy mysession + + +0 + + +Session mysession destroyed. + + + + +#################################################################### +# Scenario: Enable events from UST provider events +#################################################################### + +Scenario2 + +lttng create mysession -o /home/user/temp + + +0 + + +Session mysession created. +Traces will be written in /home/user/temp + + + +lttng list mysession + + +0 + + +Tracing session mysession: [inactive] + Trace path: /home/user/temp + + + + +lttng enable-channel mychannel -u -s mysession --subbuf-size 16384 --num-subbuf 2 --switch-timer 200 --read-timer 100 + + +0 + + +UST channel mychannel enabled for session mysession + + + +lttng list mysession + + +0 + + +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 + + + + +lttng enable-event ust_tests_hello:tptest_sighandler,ust_tests_hello:tptest -u -s mysession --tracepoint + + +0 + + +UST event ust_tests_hello:tptest_sighandler in channel channel0 +UST sched_ust_tests_hello:tptest created in channel channel0 + + + +lttng list mysession + + +0 + + +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] + + + + +lttng disable-event ust_tests_hello:tptest -u -s mysession -c mychannel + + +0 + + +kernel event ust_tests_hello:tptest in channel mychannel + + + +lttng enable-event ust_tests_hello:tptest -u -s mysession -c mychannel --tracepoint + + +0 + + +kernel event ust_tests_hello:tptest enabled in channel mychannel + + + + +lttng destroy mysession + + +0 + + +Session mysession destroyed. + + + + diff --git a/org.eclipse.linuxtools.lttng.ui.tests/testfiles/LTTngServiceTest.cfg b/org.eclipse.linuxtools.lttng.ui.tests/testfiles/LTTngServiceTest.cfg new file mode 100644 index 0000000000..7a540a5fe6 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui.tests/testfiles/LTTngServiceTest.cfg @@ -0,0 +1,541 @@ +#################################################################### +# 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 +#################################################################### + +LttngNotInstalled + +lttng list + + +1 + + +Command not found + + + +#################################################################### +# Scenario: Test no sessions available +#################################################################### + +NoSessionAvailable + +lttng list + + +0 + + +Currently no available tracing session + + + +#################################################################### +# Scenario: Test get sessions +#################################################################### + +GetSessionNames1 + +lttng list + + +0 + + +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 for more details + + + +#################################################################### +# Scenario: Test lttng list where session doesn't exist +#################################################################### + +GetSessionNameNotExist + +lttng list test + + +1 + + +Session test not found +Error: Session name not found + + + +#################################################################### +# Scenario: Test lttng list with garbage output +#################################################################### + +GetSessionGarbageOut + +lttng list + + +0 + + +asdfaereafsdcv 12333456434&*89**(())(^%$* +@#$%^&*()@#$%^&*()0834523094578kj;djkfs +a;sdf094v5u dsafj;sd9 + + + +#################################################################### +# Scenario: Test lttng list with sample outputs +#################################################################### + +GetSession1 + +lttng list mysession + + +0 + + +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] + + + +lttng list mysession1 + + +0 + + +Tracing session mysession1: [inactive] + Trace path: /home/user/lttng-traces/mysession1-20120203-133225 + + + + + +#################################################################### +# Scenario: Test "lttng list -k" with sample output +#################################################################### + +GetKernelProvider1 + +lttng list -k + + +0 + + +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) + + + + +#################################################################### +# Scenario: Test "lttng list -u" with sample output +#################################################################### + +GetUstProvider1 + +lttng list -u + + +0 + + +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) + + + + +#################################################################### +# Scenario: Test "lttng list -u" with no UST provider available +#################################################################### + +GetUstProvider2 + +lttng list -u + + +0 + + +UST events: +------------- +None + + + + +#################################################################### +# Scenario: Test "lttng create +#################################################################### + +CreateSession1 + +lttng create mysession2 + + +0 + + +Session mysession2 created. +Traces will be written in /home/user/lttng-traces/mysession2-20120209-095418 + + + +#################################################################### +# Scenario: Test "lttng create with different variants +# and errors +#################################################################### + +CreateSessionVariants + +lttng create alreadyExist + + +1 + + +Error: Session name already exist + + + +lttng create "session with spaces" + + +0 + + +Session session with spaces created. +Traces will be written in /home/user/lttng-traces/session with spaces-20120209-095418 + + + +lttng create wrongName + + +0 + + +Session auto created. +Traces will be written in /home/user/lttng-traces/auto-20120209-095418 + + + +lttng create wrongPath -o /home/user/hallo + + +0 + + +Session wrongPath created. +Traces will be written in /home/user/lttng-traces/wrongPath-20120209-095418 + + + +lttng create pathWithSpaces -o "/home/user/hallo user/here" + + +0 + + +Session pathWithSpaces created. +Traces will be written in /home/user/hallo user/here/pathWithSpaces-20120209-095418 + + + +#################################################################### +# Scenario: Test "lttng destroy +#################################################################### + + +DestroySession1 + +lttng destroy mysession2 + + +0 + + +Session mysession2 destroyed. + + + +#################################################################### +# Scenario: Test "lttng enable-channel ..." with different inputs +#################################################################### + + +ChannelHandling + +lttng enable-channel mychannel0,mychannel1 -k -s mysession2 --overwrite --subbuf-size 16384 --num-subbuf 2 --switch-timer 200 --read-timer 100 + + +0 + + +Kernel channel mychannel0 enabled for session mysession2 +Kernel channel mychannel1 enabled for session mysession2 + + + +lttng enable-channel ustChannel -u -s mysession2 --overwrite --subbuf-size 32768 --num-subbuf 1 --switch-timer 100 --read-timer 200 + + +0 + + +UST channel channel0 enabled for session mysession2 + + + +lttng enable-channel mychannel0,mychannel1 -k -s mysession2 + + +0 + + +Kernel channel mychannel0 enabled for session mysession2 +Kernel channel mychannel1 enabled for session mysession2 + + + +lttng enable-channel ustChannel -u -s mysession2 + + +0 + + +UST channel mychannel0 enabled for session mysession2 + + + +lttng disable-channel mychannel0,mychannel1 -k -s mysession2 + + +0 + + +Kernel channel mychannel0 disabled for session mysession2 +Kernel channel mychannel1 disabled for session mysession2 + + + +lttng disable-channel ustChannel -u -s mysession2 + + +0 + + +UST channel mychannel0 enabled for session mysession2 + + + + +#################################################################### +# Scenario: Test "lttng enable-events ..." with different inputs +#################################################################### + +EventHandling + +# Tracepoint test cases + + +lttng enable-event block_rq_remap,block_bio_remap,softirq_entry -k -s mysession2 --tracepoint + + +0 + + +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 + + + +lttng enable-event -a -k -s mysession2 -c mychannel --tracepoint + + +0 + + +All kernel tracepoints are enabled in channel channel0 + + + +lttng enable-event ust_tests_hello:tptest_sighandler -u -s mysession2 -c mychannel --tracepoint + + +0 + + +UST event ust_tests_hello:tptest_sighandler created in channel mychannel + + + +lttng enable-event -a -u -s mysession2 -c mychannel --tracepoint + + +0 + + +All UST tracepoints are enabled in channel mychannel + + +# Syscall test cases + + +lttng enable-event -a -k -s mysession2 --syscall + + +0 + + +All kernel system calls are enabled in channel channel0 + + + +lttng enable-event -a -k -s mysession2 -c mychannel --syscall + + +0 + + +All kernel system calls are enabled in channel mychannel + + +# dynamic probe/function probe test cases + + +lttng enable-event myevent0 -k -s mysession2 --function 0xc0101340 + + +0 + + +kernel event myevent0 created in channel mychannel + + + +lttng enable-event myevent1 -k -s mysession2 -c mychannel --probe init_post + + +0 + + +kernel event myevent1 created in channel mychannel + + +# log level test cases + + +lttng enable-event myevent4 -u -s mysession2 --loglevel-only TRACE_DEBUG + + +0 + + +UST event myevent4 created in channel channel0 + + + +lttng enable-event myevent5 -u -s mysession2 -c mychannel --loglevel TRACE_DEBUG_FUNCTION + + +0 + + +UST event myevent5 created in channel mychannel + + + + + diff --git a/org.eclipse.linuxtools.lttng.ui.tests/testfiles/ListInfoTest.cfg b/org.eclipse.linuxtools.lttng.ui.tests/testfiles/ListInfoTest.cfg new file mode 100644 index 0000000000..52b0d3a631 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui.tests/testfiles/ListInfoTest.cfg @@ -0,0 +1,157 @@ +#################################################################### +# 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 with sample outputs +#################################################################### + +ListInfoTest + +lttng list + + +0 + + +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 for more details + + + +lttng list mysession + + +0 + + +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] + + + +lttng list mysession1 + + +0 + + +Tracing session mysession1: [inactive] + Trace path: /home/user/lttng-traces/mysession1-20120203-133225 + + + + +lttng list -k + + +0 + + +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) + + + + +lttng list -u + + +0 + + +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) + + + + diff --git a/org.eclipse.linuxtools.lttng.ui/icons/elcl16/refresh.gif b/org.eclipse.linuxtools.lttng.ui/icons/elcl16/refresh.gif new file mode 100644 index 0000000000000000000000000000000000000000..3ca04d06ff9c811a6f791d029a802a7be4681ff4 GIT binary patch literal 327 zcmZ?wbhEHb6krfwxXQrrJWa!4-LeYm0=|77MK@5?WI%v@BcT|Ns9CR0WDZSr{1@R2g(Yrh@#$z?O1g zQh|q#RHw+PiyoXB)1AE)3U1~skT{fJ?U6BUYICAZn$5HYp3GD7dKS#fQdLEHHy z6I^aRo~tUt;P2kV + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/ControlView.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/ControlView.java index e5643d58c1..f993416894 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/ControlView.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/ControlView.java @@ -16,6 +16,7 @@ package org.eclipse.linuxtools.lttng.ui.views.control; 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; @@ -151,6 +152,29 @@ public class ControlView extends ViewPart implements ITraceControlComponentChang } }); } + + /** + * 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 diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/Messages.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/Messages.java index 3aff29d18d..ca1d7141ad 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/Messages.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/Messages.java @@ -163,9 +163,10 @@ final public class Messages extends NLS { 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); diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/ConfirmDialog.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/ConfirmDialog.java new file mode 100644 index 0000000000..c372c6bbcc --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/ConfirmDialog.java @@ -0,0 +1,39 @@ +/********************************************************************** + * 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; + +/** + * ConfirmDialog + *

+ * Confirmation dialog implementation. + *

+ */ + +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); + } +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/CreateChannelDialog.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/CreateChannelDialog.java index 1a062a9c4a..27dee19ee6 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/CreateChannelDialog.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/CreateChannelDialog.java @@ -119,23 +119,8 @@ public class CreateChannelDialog extends Dialog implements ICreateChannelOnSessi * @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() { @@ -159,6 +144,20 @@ public class CreateChannelDialog extends Dialog implements ICreateChannelOnSessi 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() diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/CreateSessionDialog.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/CreateSessionDialog.java index ef66896e6c..ae9e88c972 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/CreateSessionDialog.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/CreateSessionDialog.java @@ -87,11 +87,9 @@ public class CreateSessionDialog extends Dialog implements ICreateSessionDialog /** * 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; } // ------------------------------------------------------------------------ @@ -124,6 +122,15 @@ public class CreateSessionDialog extends Dialog implements ICreateSessionDialog 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 // ------------------------------------------------------------------------ diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/EnableEventsDialog.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/EnableEventsDialog.java index dbeb8586e0..99bd3a2003 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/EnableEventsDialog.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/EnableEventsDialog.java @@ -96,28 +96,11 @@ public class EnableEventsDialog extends Dialog implements IEnableEventsDialog { * @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 // ------------------------------------------------------------------------ @@ -331,6 +314,29 @@ public class EnableEventsDialog extends Dialog implements IEnableEventsDialog { 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 @@ -391,8 +397,11 @@ public class EnableEventsDialog extends Dialog implements IEnableEventsDialog { // ------------------------------------------------------------------------ // Kernel or UST event data group // ------------------------------------------------------------------------ + fUstComposite = null; + fKernelComposite = null; if (fIsKernel) { createKernelComposite(); + fUstComposite = null; } else { createUstComposite(); } diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/GetEventInfoDialog.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/GetEventInfoDialog.java index 1f63b39ce0..0003d506c1 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/GetEventInfoDialog.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/GetEventInfoDialog.java @@ -98,13 +98,9 @@ public class GetEventInfoDialog extends Dialog implements IGetEventInfoDialog { /** * 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); } @@ -129,6 +125,24 @@ public class GetEventInfoDialog extends Dialog implements IGetEventInfoDialog { 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 // ------------------------------------------------------------------------ diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/IConfirmDialog.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/IConfirmDialog.java new file mode 100644 index 0000000000..0d413bf79c --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/IConfirmDialog.java @@ -0,0 +1,26 @@ +/********************************************************************** + * 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; + +/** + * IConfirmDialog + *

+ * Interface for a confirmation dialog. + *

+ */ +public interface IConfirmDialog { + + public boolean openConfirm(Shell parent, String title, String message); + +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/ICreateChannelDialog.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/ICreateChannelDialog.java index 26cd0ce2b7..3e97c94d8f 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/ICreateChannelDialog.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/ICreateChannelDialog.java @@ -12,6 +12,7 @@ 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; /** * ICreateChannelDialog @@ -29,6 +30,12 @@ public interface ICreateChannelDialog { */ public IChannelInfo getChannelInfo(); + /** + * Sets the domain component + * @param domain - the trace domain component + */ + public void setDomainComponent(TraceDomainComponent domain); + // ------------------------------------------------------------------------ // Operations // ------------------------------------------------------------------------ diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/ICreateSessionDialog.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/ICreateSessionDialog.java index eb42ac2af2..91eeeaa063 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/ICreateSessionDialog.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/ICreateSessionDialog.java @@ -11,6 +11,8 @@ **********************************************************************/ package org.eclipse.linuxtools.lttng.ui.views.control.dialogs; +import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionGroup; + /** * ICreateSessionDialog *

@@ -36,6 +38,12 @@ public interface ICreateSessionDialog { * @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 diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/IEnableEventsDialog.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/IEnableEventsDialog.java index eb3230cc4e..e4bd698f8e 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/IEnableEventsDialog.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/IEnableEventsDialog.java @@ -11,6 +11,9 @@ **********************************************************************/ 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; + /** * IEnableKernelEvents *

@@ -26,6 +29,18 @@ public interface IEnableEventsDialog extends IEnableKernelEvents, IEnableUstEven * @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 diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/IGetEventInfoDialog.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/IGetEventInfoDialog.java index b4b09e1751..39d74e5f4c 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/IGetEventInfoDialog.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/IGetEventInfoDialog.java @@ -34,6 +34,18 @@ public interface IGetEventInfoDialog { * @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 diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/INewConnectionDialog.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/INewConnectionDialog.java index acdceac6e4..3b42d3ff35 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/INewConnectionDialog.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/INewConnectionDialog.java @@ -11,6 +11,9 @@ **********************************************************************/ 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; + /** * INewConnectionDialog *

@@ -31,6 +34,18 @@ public interface INewConnectionDialog { * @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 diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/NewConnectionDialog.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/NewConnectionDialog.java index dd7edec72d..d415a5bdf4 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/NewConnectionDialog.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/NewConnectionDialog.java @@ -103,12 +103,8 @@ public class NewConnectionDialog extends Dialog implements INewConnectionDialog // ------------------------------------------------------------------------ // 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); } @@ -132,6 +128,26 @@ public class NewConnectionDialog extends Dialog implements INewConnectionDialog 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 diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/TraceControlDialogFactory.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/TraceControlDialogFactory.java new file mode 100644 index 0000000000..584a154f3d --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/TraceControlDialogFactory.java @@ -0,0 +1,203 @@ +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; + } +} + + diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/AssignEventHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/AssignEventHandler.java index c169e4259c..f2412bff04 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/AssignEventHandler.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/AssignEventHandler.java @@ -15,7 +15,6 @@ import java.util.ArrayList; 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; @@ -28,8 +27,8 @@ import org.eclipse.jface.window.Window; 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; @@ -38,9 +37,6 @@ import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceChannelComp 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; /** * EnableEventHandler @@ -49,7 +45,7 @@ import org.eclipse.ui.PlatformUI; * This is done on the trace provider level. *

*/ -public class AssignEventHandler extends AbstractHandler { +public class AssignEventHandler extends BaseControlViewHandler { // ------------------------------------------------------------------------ // Attributes @@ -80,14 +76,10 @@ public class AssignEventHandler extends AbstractHandler { @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; @@ -149,23 +141,12 @@ public class AssignEventHandler extends AbstractHandler { 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) { diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/BaseEnableEventHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/BaseEnableEventHandler.java index 8a128040b2..fd2bc2a1e1 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/BaseEnableEventHandler.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/BaseEnableEventHandler.java @@ -22,8 +22,8 @@ import org.eclipse.core.runtime.jobs.Job; 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; @@ -71,21 +71,13 @@ abstract public class BaseEnableEventHandler extends BaseControlViewHandler { /** * 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 @@ -116,9 +108,11 @@ abstract public class BaseEnableEventHandler extends BaseControlViewHandler { TargetNodeComponent node = fSession.getTargetNode(); List 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; } @@ -151,14 +145,14 @@ abstract public class BaseEnableEventHandler extends BaseControlViewHandler { // 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); } } diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/ChangeEventStateHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/ChangeEventStateHandler.java index a69f09808d..ef10e9f17a 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/ChangeEventStateHandler.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/ChangeEventStateHandler.java @@ -120,8 +120,8 @@ abstract public class ChangeEventStateHandler extends BaseControlViewHandler { for (Iterator 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) { diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateChannelOnDomainHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateChannelOnDomainHandler.java index 65adabe53d..6d12265fb9 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateChannelOnDomainHandler.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateChannelOnDomainHandler.java @@ -27,14 +27,12 @@ import org.eclipse.jface.window.Window; 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; /** * CreateChannelOnDomainHandler @@ -62,14 +60,9 @@ public class CreateChannelOnDomainHandler extends BaseControlViewHandler { @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; diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateChannelOnSessionHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateChannelOnSessionHandler.java index e54ec436e1..4becd61354 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateChannelOnSessionHandler.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateChannelOnSessionHandler.java @@ -27,14 +27,12 @@ import org.eclipse.jface.window.Window; 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; /** * CreateChannelOnSessionHandler @@ -63,13 +61,7 @@ public class CreateChannelOnSessionHandler extends BaseControlViewHandler { @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; diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateSessionHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateSessionHandler.java index 8d3f20addd..a6b3b7bf25 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateSessionHandler.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateSessionHandler.java @@ -23,12 +23,10 @@ import org.eclipse.jface.window.Window; 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; /** * CreateSessionHandler @@ -55,13 +53,10 @@ public class CreateSessionHandler extends BaseControlViewHandler { */ @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; diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/DestroySessionHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/DestroySessionHandler.java index 10baaac5ce..5974124e52 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/DestroySessionHandler.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/DestroySessionHandler.java @@ -21,12 +21,13 @@ import org.eclipse.core.runtime.IProgressMonitor; 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; @@ -66,12 +67,12 @@ public class DestroySessionHandler extends BaseControlViewHandler { 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) { diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/EnableEventOnChannelHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/EnableEventOnChannelHandler.java index 8c0b02dc19..2829137a5a 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/EnableEventOnChannelHandler.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/EnableEventOnChannelHandler.java @@ -66,22 +66,13 @@ public class EnableEventOnChannelHandler extends BaseEnableEventHandler { /* * (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) diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/EnableEventOnDomainHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/EnableEventOnDomainHandler.java index 1cda8bb445..72c1f0876c 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/EnableEventOnDomainHandler.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/EnableEventOnDomainHandler.java @@ -66,20 +66,11 @@ public class EnableEventOnDomainHandler extends BaseEnableEventHandler { /* * (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); } /* diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/EnableEventOnSessionHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/EnableEventOnSessionHandler.java index 620e37f510..ca0e944229 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/EnableEventOnSessionHandler.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/EnableEventOnSessionHandler.java @@ -62,22 +62,13 @@ public class EnableEventOnSessionHandler extends BaseEnableEventHandler { /* * (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) diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/NewConnectionHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/NewConnectionHandler.java index 0fba7326ba..6656c03cb3 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/NewConnectionHandler.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/NewConnectionHandler.java @@ -18,7 +18,7 @@ import org.eclipse.jface.window.Window; 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; @@ -76,7 +76,9 @@ public class NewConnectionHandler extends BaseControlViewHandler { 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; diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/RefreshHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/RefreshHandler.java new file mode 100644 index 0000000000..f6f6f795e0 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/RefreshHandler.java @@ -0,0 +1,93 @@ +/********************************************************************** + * 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; + +/** + * RefreshHandler + *

+ * Command handler implementation to refresh node configuration. + *

+ */ +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; + } +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/messages.properties b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/messages.properties index da4bf9691e..24a2a96cde 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/messages.properties +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/messages.properties @@ -101,7 +101,7 @@ TraceControl_EnableEventsLogLevelTooltip=The available log levels 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 @@ -135,3 +135,6 @@ TraceControl_HostAddressPropertyName=Host Name TraceControl_SessionPathPropertyName=Session Path TraceControl_ProviderNamePropertyName=Provider Name TraceControl_ProcessIdPropertyName=Process ID +TraceControl_ProbeAddressPropertyName=Address +TraceControl_ProbeOffsetPropertyName=Offset +TraceControl_ProbeSymbolPropertyName=Symbol diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/IProbeEventInfo.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/IProbeEventInfo.java new file mode 100644 index 0000000000..9227d78ff9 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/IProbeEventInfo.java @@ -0,0 +1,54 @@ +/********************************************************************** + * 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; + +/** + * IProbeEventInfo + *

+ * Interface for retrieval of probe event information. + *

+ */ +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); +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/ITraceInfo.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/ITraceInfo.java index f03d6da92f..29a07b62ee 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/ITraceInfo.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/ITraceInfo.java @@ -29,4 +29,9 @@ public interface ITraceInfo { * @param name */ public void setName(String name); + + /** + * @return a formated (readable) String with content. + */ + public String formatString(); } diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/BaseEventInfo.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/BaseEventInfo.java index 098fc5d9b0..b374e9446d 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/BaseEventInfo.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/BaseEventInfo.java @@ -155,43 +155,67 @@ public class BaseEventInfo extends TraceInfo implements IBaseEventInfo { } } + /* + * (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) @@ -210,4 +234,8 @@ public class BaseEventInfo extends TraceInfo implements IBaseEventInfo { output.append(")]"); return output.toString(); } + + + + } \ No newline at end of file diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/ChannelInfo.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/ChannelInfo.java index 468952971d..b2f0035d41 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/ChannelInfo.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/ChannelInfo.java @@ -273,71 +273,122 @@ public class ChannelInfo extends TraceInfo implements IChannelInfo { 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 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 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; } @@ -378,4 +429,6 @@ public class ChannelInfo extends TraceInfo implements IChannelInfo { output.append(")]"); return output.toString(); } + + } \ No newline at end of file diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/DomainInfo.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/DomainInfo.java index 95c1d26366..1bf7994ba2 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/DomainInfo.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/DomainInfo.java @@ -114,19 +114,45 @@ public class DomainInfo extends TraceInfo implements IDomainInfo { 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 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 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; } @@ -135,31 +161,30 @@ public class DomainInfo extends TraceInfo implements IDomainInfo { * @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() @@ -184,4 +209,5 @@ public class DomainInfo extends TraceInfo implements IDomainInfo { output.append(")]"); return output.toString(); } + } diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/EventInfo.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/EventInfo.java index 9ecb0b1b65..8a16e3feb8 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/EventInfo.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/EventInfo.java @@ -72,6 +72,22 @@ public class EventInfo extends BaseEventInfo implements IEventInfo { 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) @@ -92,9 +108,9 @@ public class EventInfo extends BaseEventInfo implements IEventInfo { */ @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; } @@ -103,23 +119,23 @@ public class EventInfo extends BaseEventInfo implements IEventInfo { * @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() diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/ProbeEventInfo.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/ProbeEventInfo.java new file mode 100644 index 0000000000..e7865f015a --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/ProbeEventInfo.java @@ -0,0 +1,229 @@ +/********************************************************************** + * 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; + +/** +* ProbleEventInfo +*

+* Implementation of the trace event interface (IProbeEventInfo) to store probe event +* related data. +*

+*/ +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(); + } + + +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/SessionInfo.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/SessionInfo.java index ac6464762f..5d074b1783 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/SessionInfo.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/SessionInfo.java @@ -158,21 +158,45 @@ public class SessionInfo extends TraceInfo implements ISessionInfo { 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 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; } @@ -181,34 +205,37 @@ public class SessionInfo extends TraceInfo implements ISessionInfo { * @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() @@ -223,8 +250,8 @@ public class SessionInfo extends TraceInfo implements ISessionInfo { output.append(fState); output.append(",Domains="); for (Iterator 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(); diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TargetNodeComponent.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TargetNodeComponent.java index 97c8bc5ec9..0b3775ac1c 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TargetNodeComponent.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TargetNodeComponent.java @@ -285,7 +285,7 @@ public class TargetNodeComponent extends TraceControlComponent implements ICommu * * @throws ExecutionException */ - public void getConfigurationFromNode() throws ExecutionException { + public void getConfigurationFromNode() { Job job = new Job(Messages.TraceControl_RetrieveNodeConfigurationJob) { @Override protected IStatus run(IProgressMonitor monitor) { @@ -310,7 +310,11 @@ public class TargetNodeComponent extends TraceControlComponent implements ICommu }; job.setUser(true); job.schedule(); + } + public void refresh() { + removeAllChildren(); + getConfigurationFromNode(); } // ------------------------------------------------------------------------ diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceChannelComponent.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceChannelComponent.java index 7f4a08195b..d3572a81dd 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceChannelComponent.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceChannelComponent.java @@ -99,7 +99,13 @@ public class TraceChannelComponent extends TraceControlComponent { 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); } @@ -286,45 +292,26 @@ public class TraceChannelComponent extends TraceControlComponent { /** * 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 diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceDomainComponent.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceDomainComponent.java index 237b473921..28696f7dd8 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceDomainComponent.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceDomainComponent.java @@ -228,45 +228,26 @@ public class TraceDomainComponent extends TraceControlComponent { /** * 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 diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceEventComponent.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceEventComponent.java index 936be7521f..7fed4e75b0 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceEventComponent.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceEventComponent.java @@ -24,7 +24,7 @@ import org.eclipse.ui.views.properties.IPropertySource; /** - * TraceChannelComponent + * TraceEventComponent *

* Implementation of the trace channel component. *

@@ -48,7 +48,7 @@ public class TraceEventComponent extends TraceControlComponent { /** * The event information. */ - private IEventInfo fEventInfo = null; + protected IEventInfo fEventInfo = null; /** * The image to be displayed when in disabled state. */ diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceInfo.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceInfo.java index 5ae5e2e0f0..851478ff99 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceInfo.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceInfo.java @@ -77,16 +77,25 @@ public class TraceInfo implements ITraceInfo { 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; } /* @@ -94,15 +103,26 @@ public class TraceInfo implements ITraceInfo { * @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() diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceProbeEventComponent.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceProbeEventComponent.java new file mode 100644 index 0000000000..e473f94d06 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceProbeEventComponent.java @@ -0,0 +1,124 @@ +/********************************************************************** + * 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; + + +/** + * TraceProbeEventComponent + *

+ * Implementation of the trace channel component. + *

+ */ +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; + } + +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceSessionComponent.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceSessionComponent.java index d1f01fe97f..15f3b3eae0 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceSessionComponent.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceSessionComponent.java @@ -292,43 +292,24 @@ public class TraceSessionComponent extends TraceControlComponent { /** * 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); } /** diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/UstProviderInfo.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/UstProviderInfo.java index 537d734117..c3d4b4cec7 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/UstProviderInfo.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/UstProviderInfo.java @@ -125,16 +125,37 @@ public class UstProviderInfo extends TraceInfo implements IUstProviderInfo { /* * (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 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; } @@ -143,23 +164,26 @@ public class UstProviderInfo extends TraceInfo implements IUstProviderInfo { * @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; } @@ -188,4 +212,6 @@ public class UstProviderInfo extends TraceInfo implements IUstProviderInfo { output.append(")]"); return output.toString(); } + + } diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/property/TraceEventPropertySource.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/property/TraceEventPropertySource.java index f656dd3998..fed6661913 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/property/TraceEventPropertySource.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/property/TraceEventPropertySource.java @@ -70,7 +70,7 @@ public class TraceEventPropertySource extends BasePropertySource { /** * The event component which this property source is for. */ - private final TraceEventComponent fEvent; + protected final TraceEventComponent fEvent; // ------------------------------------------------------------------------ // Constructors diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/property/TraceProbeEventPropertySource.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/property/TraceProbeEventPropertySource.java new file mode 100644 index 0000000000..b8e60a6521 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/property/TraceProbeEventPropertySource.java @@ -0,0 +1,122 @@ +/********************************************************************** + * 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; + +/** + * TraceEventPropertySource + *

+ * Property source implementation for the trace probe event component. + *

+ */ +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 list = new ArrayList(); + 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); + } +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/service/ILttngControlService.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/service/ILttngControlService.java index 617a1c3d7c..6db5755720 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/service/ILttngControlService.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/service/ILttngControlService.java @@ -106,7 +106,7 @@ public interface ILttngControlService { /** * 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 @@ -117,7 +117,7 @@ public interface ILttngControlService { /** * 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 @@ -127,8 +127,8 @@ public interface ILttngControlService { /** * 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 @@ -138,33 +138,23 @@ public interface ILttngControlService { /** * 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 diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/service/LTTngControlService.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/service/LTTngControlService.java index efc980bc5a..94290e27c7 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/service/LTTngControlService.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/service/LTTngControlService.java @@ -25,14 +25,17 @@ 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.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; @@ -211,6 +214,18 @@ public class LTTngControlService implements ILttngControlService { * Pattern to match a wildcarded event information (lttng list ) */ 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 ) + */ + 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 ) + */ + 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 ) + */ + 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 * ) @@ -340,9 +355,11 @@ public class LTTngControlService implements ILttngControlService { */ @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$ } @@ -743,13 +760,9 @@ public class LTTngControlService implements ILttngControlService { 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 iterator = eventNames.iterator(); iterator.hasNext();) { String event = (String) iterator.next(); @@ -818,7 +831,7 @@ public class LTTngControlService implements ILttngControlService { * @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); @@ -833,46 +846,19 @@ public class LTTngControlService implements ILttngControlService { 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$ - } + } } /* @@ -1118,17 +1104,69 @@ public class LTTngControlService implements ILttngControlService { 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; -- 2.34.1