control.test: Add tests for the exclude feature in Control view
authorBruno Roy <bruno.roy@ericsson.com>
Tue, 14 Jun 2016 14:17:40 +0000 (10:17 -0400)
committerBernd Hufmann <bernd.hufmann@ericsson.com>
Thu, 30 Jun 2016 19:38:14 +0000 (15:38 -0400)
Test the exclude feature with the LTTng service. Also test the UI with
SWTBot tests.

Change-Id: I2afd0fdfa8a1c85b375528c58e0977aa98f4b060
Signed-off-by: Bruno Roy <bruno.roy@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/74320
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Reviewed-by: Hudson CI
Reviewed-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Tested-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
14 files changed:
lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/META-INF/MANIFEST.MF
lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/build.properties
lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/plugin.xml [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/control/ui/swtbot/tests/ControlPerspectiveFactory.java [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/control/ui/swtbot/tests/ControlViewExcludeEventsTest.java [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/control/ui/swtbot/tests/ControlViewSwtBotUtil.java
lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/control/ui/swtbot/tests/ControlViewTest.java
lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/testfiles/CreateSessionTestLTTng2_8.cfg
lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/src/org/eclipse/tracecompass/lttng2/control/ui/tests/service/LTTngControlServiceTest.java
lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/testfiles/LTTngServiceMi3Test.cfg
lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/testfiles/LTTngServiceMiTest.cfg
lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/testfiles/LTTngServiceTest.cfg
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlService.java
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlServiceConstants.java

index 8394a421ffc5dd2794ed592cce1b5ef3113ab5aa..18c857dd6ab9a1b499ce622288ca432a37f71f89 100644 (file)
@@ -31,3 +31,4 @@ Require-Bundle: org.apache.log4j,
 Export-Package: org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests
 Import-Package: com.google.common.collect,
  org.eclipse.tracecompass.testtraces.ctf;version="1.0.0"
+Bundle-Activator: org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests.Activator
index cee367fdce9ca2f94596e03961d68fb29a85e73d..935eee24bd53658e3075c0301fb83e07b6222721 100644 (file)
@@ -14,6 +14,7 @@ source.. = src/
 bin.includes = META-INF/,\
                .,\
                plugin.properties,\
-               about.html
+               about.html,\
+               plugin.xml
 additional.bundles = org.eclipse.jdt.annotation
 jars.extra.classpath = platform:/plugin/org.eclipse.jdt.annotation
diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/plugin.xml b/lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/plugin.xml
new file mode 100644 (file)
index 0000000..ced548a
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+   <extension
+         point="org.eclipse.ui.perspectives">
+      <perspective
+            class="org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests.ControlPerspectiveFactory"
+            id="org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests.perspective"
+            name="Control">
+      </perspective>
+   </extension>
+
+</plugin>
diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/control/ui/swtbot/tests/ControlPerspectiveFactory.java b/lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/control/ui/swtbot/tests/ControlPerspectiveFactory.java
new file mode 100644 (file)
index 0000000..8decbbe
--- /dev/null
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2016 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
+ *******************************************************************************/
+package org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests;
+
+import org.eclipse.tracecompass.internal.lttng2.control.ui.views.ControlView;
+import org.eclipse.ui.IFolderLayout;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPerspectiveFactory;
+
+/**
+ * Perspective factory used during ControlView SWTBot test
+ */
+public class ControlPerspectiveFactory implements IPerspectiveFactory {
+
+    private static final String PROJECT_VIEW_ID = IPageLayout.ID_PROJECT_EXPLORER;
+    private static final String CONTROL_VIEW_ID = ControlView.ID;
+    private static final String PROPERTIES_VIEW_ID = IPageLayout.ID_PROP_SHEET;
+
+    @Override
+    public void createInitialLayout(IPageLayout layout) {
+        layout.setEditorAreaVisible(true);
+
+        // Create the top left folder
+        IFolderLayout topLeftFolder = layout.createFolder(
+                "topLeftFolder", IPageLayout.LEFT, 0.15f, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$
+        topLeftFolder.addView(PROJECT_VIEW_ID);
+
+        // Create the bottom left folder
+        IFolderLayout bottomLeftFolder = layout.createFolder(
+                "bottomLeftFolder", IPageLayout.BOTTOM, 0.70f, "topLeftFolder"); //$NON-NLS-1$ //$NON-NLS-2$
+        bottomLeftFolder.addView(CONTROL_VIEW_ID);
+
+        // Create the bottom right folder
+        IFolderLayout bottomRightFolder = layout.createFolder(
+                "bottomRightFolder", IPageLayout.BOTTOM, 0.50f, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$
+        bottomRightFolder.addView(PROPERTIES_VIEW_ID);
+    }
+
+}
diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/control/ui/swtbot/tests/ControlViewExcludeEventsTest.java b/lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/control/ui/swtbot/tests/ControlViewExcludeEventsTest.java
new file mode 100644 (file)
index 0000000..71296a1
--- /dev/null
@@ -0,0 +1,201 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceSessionState;
+import org.eclipse.tracecompass.internal.lttng2.control.ui.views.ControlView;
+import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.ITraceControlComponent;
+import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceEventComponent;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Test for the Control view in Trace Compass. This will test the exclude events feature.
+ *
+ * @author Bruno Roy
+ */
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class ControlViewExcludeEventsTest extends ControlViewTest {
+
+    // ------------------------------------------------------------------------
+    // Constants
+    // ------------------------------------------------------------------------
+    private static final String TEST_STREAM = "CreateSessionTestLTTng2_8.cfg";
+
+    private static final String CREATE_SESSION_UST_EXCLUDE_SCENARIO_NAME = "ExcludeEvent";
+
+    private static final String SESSION_NAME = "mysession";
+    private static final String EXCLUDE_EXPRESSION = "foo";
+    private static final String PROPERTIES_VIEW = "Properties";
+    private static final String EXCLUDE_TREE_ITEM = "Exclude";
+
+    @Override
+    protected String getTestStream() {
+        return TEST_STREAM;
+    }
+
+    @Override
+    protected String getSessionName() {
+        return SESSION_NAME;
+    }
+
+    /**
+     * Testing the trace session tree.
+     */
+    @Override
+    @Test
+    public void testTraceSessionTree() {
+
+        fProxy.setTestFile(fTestFile);
+        fProxy.setScenario(INIT_SCENARIO_NAME);
+        testConnectToNode();
+
+        // Enable all UST events with one excluded event
+        fProxy.setScenario(CREATE_SESSION_UST_EXCLUDE_SCENARIO_NAME);
+        testCreateSession();
+        testEnableUstEventExclude();
+        testStartStopTracing(TraceSessionState.ACTIVE);
+        testStartStopTracing(TraceSessionState.INACTIVE);
+        // Verify that the Properties view shows to right excluded event
+        testPropertiesEventExclude();
+        // Clean session
+        testDestroySession();
+        testDisconnectFromNode();
+    }
+
+    /**
+     * Enable all UST events with one excluded event.
+     */
+    protected void testEnableUstEventExclude() {
+        // Getting the 'Sessions' tree
+        SWTBotTreeItem sessionItem = SWTBotUtils.getTreeItem(fBot, fTree,
+                getNodeName(),
+                ControlViewSwtBotUtil.SESSION_GROUP_NAME,
+                getSessionName());
+        sessionItem.select();
+
+        // Clicking on the 'Enable Event (default channel)...'
+        SWTBotMenu menuBot = sessionItem.contextMenu(ControlViewSwtBotUtil.ENABLE_EVENT_DEFAULT_CHANNEL_MENU_ITEM);
+        menuBot.click();
+
+        SWTBotShell shell = fBot.shell(ControlViewSwtBotUtil.ENABLE_EVENT_DIALOG_TITLE).activate();
+
+        // Switching to the UST domain
+        shell.bot().radioInGroup(ControlViewSwtBotUtil.UST_GROUP_NAME, ControlViewSwtBotUtil.DOMAIN_GROUP_NAME).click();
+
+        // Selecting all UST events
+        SWTBotTree tracepointsTree = shell.bot().treeInGroup(ControlViewSwtBotUtil.TRACEPOINTS_GROUP_NAME);
+        SWTBotTreeItem treeItem = tracepointsTree.getTreeItem(ControlViewSwtBotUtil.ALL_TREE_NODE);
+        treeItem.check();
+
+        // Click the checkbox for the Exclude event
+        shell.bot().checkBoxInGroup(ControlViewSwtBotUtil.GROUP_SELECT_NAME, ControlViewSwtBotUtil.EXCLUDE_EVENT_LABEL).click();
+
+        // Enter the event to exclude in the text field
+        SWTBotText excludeText = shell.bot().textInGroup(ControlViewSwtBotUtil.EXCLUDE_EVENT_LABEL);
+        excludeText.setText(EXCLUDE_EXPRESSION);
+
+        // Click the Ok at the bottom of the dialog window
+        shell.bot().button(ControlViewSwtBotUtil.DIALOG_OK_BUTTON).click();
+        SWTBotUtils.waitForJobs();
+
+        fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(ControlViewSwtBotUtil.UST_DOMAIN_NAME, sessionItem));
+
+        // Assert that the domain is UST global
+        SWTBotTreeItem ustGlobalDomainItem = SWTBotUtils.getTreeItem(fBot, fTree,
+                getNodeName(),
+                ControlViewSwtBotUtil.SESSION_GROUP_NAME,
+                getSessionName(),
+                ControlViewSwtBotUtil.UST_DOMAIN_NAME);
+        assertEquals(ControlViewSwtBotUtil.UST_DOMAIN_NAME, ustGlobalDomainItem.getText());
+
+        // Assert that the new channel name is channel0 (which is the default name)
+        SWTBotTreeItem channelItem = SWTBotUtils.getTreeItem(fBot, fTree,
+                getNodeName(),
+                ControlViewSwtBotUtil.SESSION_GROUP_NAME,
+                getSessionName(),
+                ControlViewSwtBotUtil.UST_DOMAIN_NAME,
+                ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME);
+        assertEquals(ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME, channelItem.getText());
+
+        // Assert that the event type in the channel node are correct (all events = *)
+        SWTBotTreeItem eventItem = SWTBotUtils.getTreeItem(fBot, fTree,
+                getNodeName(),
+                ControlViewSwtBotUtil.SESSION_GROUP_NAME,
+                getSessionName(),
+                ControlViewSwtBotUtil.UST_DOMAIN_NAME,
+                ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME,
+                ControlViewSwtBotUtil.ALL_EVENTS_NAME);
+        assertEquals(ControlViewSwtBotUtil.ALL_EVENTS_NAME, eventItem.getText());
+
+        // Assert that the excluded event is the correct one
+        ITraceControlComponent comp = ControlViewSwtBotUtil.getComponent(fNode,
+                ControlViewSwtBotUtil.SESSION_GROUP_NAME,
+                getSessionName(),
+                ControlViewSwtBotUtil.UST_DOMAIN_NAME,
+                ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME,
+                ControlViewSwtBotUtil.ALL_EVENTS_NAME);
+        assertNotNull(comp);
+        assertTrue(comp instanceof TraceEventComponent);
+        TraceEventComponent event = (TraceEventComponent) comp;
+        assertEquals(EXCLUDE_EXPRESSION, event.getExcludedEvents());
+    }
+
+    /**
+     * Test that the Properties view has been update and shows the the right
+     * information.
+     */
+    protected void testPropertiesEventExclude() {
+        // Open the properties view (by id)
+        SWTBotUtils.openView("org.eclipse.ui.views.PropertySheet");
+
+        // Select the event in the Control view
+        fBot.viewById(ControlView.ID).show();
+        SWTBotTreeItem eventItem = SWTBotUtils.getTreeItem(fBot, fTree,
+                getNodeName(),
+                ControlViewSwtBotUtil.SESSION_GROUP_NAME,
+                getSessionName(),
+                ControlViewSwtBotUtil.UST_DOMAIN_NAME,
+                ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME,
+                ControlViewSwtBotUtil.ALL_EVENTS_NAME);
+        eventItem.select();
+
+        // Get a bot and open the Properties view
+        SWTBotView propertiesViewBot = fBot.viewByTitle(PROPERTIES_VIEW);
+        propertiesViewBot.show();
+
+        // Get the Exclude field in the tree
+        SWTBotTree propertiesViewTree = propertiesViewBot.bot().tree();
+        SWTBotTreeItem excludeTreeItem = propertiesViewTree.getTreeItem(EXCLUDE_TREE_ITEM);
+        // We want the VALUE of the 'Exclude' row so the cell index is 1
+        String excludeExpression = excludeTreeItem.cell(1);
+
+        // Assert that the expression in the Properties view is the same as
+        // the one we entered
+        assertEquals(EXCLUDE_EXPRESSION, excludeExpression);
+
+        // Close the Properties view
+        SWTBotUtils.closeView(PROPERTIES_VIEW, fBot);
+    }
+
+}
\ No newline at end of file
index 611868b24e6e22b12880519c07cd70c09533fa16..d0d95665c0d046563a9539b2bec02ff5dc2e88e8 100644 (file)
@@ -73,6 +73,7 @@ class ControlViewSwtBotUtil {
     public static final String BUFFERTYPE_GROUP_NAME = "Buffer Type";
     public static final String BUFFERTYPE_PER_UID = "Per UID buffers";
     public static final String FILTER_EXPRESSION_LABEL = "Filter Expression";
+    public static final String EXCLUDE_EVENT_LABEL = "Exclude Events";
     public static final String SESSION_LIST_GROUP_NAME = "Session List";
 
     public static final String DESTROY_CONFIRM_DIALOG_TITLE = "Destroy Confirmation";
index 66bd80bcbee5e801ecf7061eabe7c5c67a4bffba..a6e9901b99c640d196f4fb4f6d8b5f2fa4cbad1c 100644 (file)
@@ -83,6 +83,7 @@ public class ControlViewTest {
     private static final String SESSION_NAME = "mysession";
     private static final String UST_CHANNEL_NAME = ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME;
     private static final String NODE_NAME = "myNode";
+    private static final String PERSPECTIVE_ID = "org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests.perspective";
 
     // ------------------------------------------------------------------------
     // Test data
@@ -126,6 +127,8 @@ public class ControlViewTest {
 
         /* finish waiting for eclipse to load */
         SWTBotUtils.waitForJobs();
+
+        SWTBotUtils.switchToPerspective(PERSPECTIVE_ID);
     }
 
     /**
index 421945ca038f803ac0b58fc254e83ed817edcac1..d0709f9e85791904685c2a797c9f7c275860fbb3 100644 (file)
@@ -568,3 +568,79 @@ lttng --mi xml destroy mysession
 <command xmlns="http://lttng.org/xml/ns/lttng-mi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0"><name>destroy</name><output><sessions><session><name>mysession</name><path>${workspace}/lttng-traces/mysession-20151201-205959</path><enabled>false</enabled><snapshot_mode>0</snapshot_mode><live_timer_interval>0</live_timer_interval></session></sessions></output><success>true</success></command>
 </COMMAND_OUTPUT>
 </SCENARIO>
+###############################################################################
+# Exclude event by specifying the name
+###############################################################################
+<SCENARIO>
+ExcludeEvent
+<COMMAND_INPUT>
+lttng --mi xml create mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command xmlns="http://lttng.org/xml/ns/lttng-mi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0"><name>create</name><output><session><name>mysession</name><path>${workspace}/lttng-traces/mysession-20160105-151744</path><enabled>false</enabled><snapshot_mode>0</snapshot_mode><live_timer_interval>0</live_timer_interval></session></output><success>true</success></command>
+</COMMAND_OUTPUT>
+<COMMAND_INPUT>
+lttng --mi xml list mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command xmlns="http://lttng.org/xml/ns/lttng-mi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0"><name>list</name><output><sessions><session><name>mysession</name><path>${workspace}/lttng-traces/mysession-20160105-151744</path><enabled>false</enabled><snapshot_mode>0</snapshot_mode><live_timer_interval>0</live_timer_interval><domains/></session></sessions></output></command>
+</COMMAND_OUTPUT>
+<COMMAND_INPUT>
+lttng --mi xml enable-event -a -u -s mysession --tracepoint --exclude foo
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command xmlns="http://lttng.org/xml/ns/lttng-mi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0"><name>enable-event</name><output><events><event><name>*</name><type>TRACEPOINT</type><enabled>true</enabled><exclusions/><exclusions><exclusion>foo</exclusion></exclusions><success>true</success></event></events></output><success>true</success></command>
+</COMMAND_OUTPUT>
+<COMMAND_INPUT>
+lttng --mi xml list mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command xmlns="http://lttng.org/xml/ns/lttng-mi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0"><name>list</name><output><sessions><session><name>mysession</name><path>${workspace}/lttng-traces/mysession-20160601-131330</path><enabled>false</enabled><snapshot_mode>0</snapshot_mode><live_timer_interval>0</live_timer_interval><domains><domain><type>UST</type><buffer_type>PER_UID</buffer_type><trackers/><channels><channel><name>channel0</name><enabled>true</enabled><attributes><overwrite_mode>DISCARD</overwrite_mode><subbuffer_size>131072</subbuffer_size><subbuffer_count>4</subbuffer_count><switch_timer_interval>0</switch_timer_interval><read_timer_interval>0</read_timer_interval><output_type>MMAP</output_type><tracefile_size>0</tracefile_size><tracefile_count>0</tracefile_count><live_timer_interval>0</live_timer_interval><discarded_events>0</discarded_events><lost_packets>0</lost_packets></attributes><events><event><name>*</name><type>TRACEPOINT</type><enabled>true</enabled><exclusions><exclusion>foo</exclusion></exclusions></event></events></channel></channels></domain></domains></session></sessions></output></command>
+</COMMAND_OUTPUT>
+<COMMAND_INPUT>
+lttng --mi xml start mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command xmlns="http://lttng.org/xml/ns/lttng-mi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0"><name>start</name><output><sessions><session><name>mysession</name><enabled>true</enabled></session></sessions></output><success>true</success></command>
+</COMMAND_OUTPUT>
+<COMMAND_INPUT>
+lttng --mi xml stop mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command xmlns="http://lttng.org/xml/ns/lttng-mi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0"><name>stop</name><output><sessions><session><name>mysession</name><enabled>false</enabled></session></sessions></output><success>true</success></command>
+</COMMAND_OUTPUT>
+<COMMAND_INPUT>
+lttng --mi xml destroy mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command xmlns="http://lttng.org/xml/ns/lttng-mi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0"><name>destroy</name><output><sessions><session><name>mysession</name><path>${workspace}/lttng-traces/mysession-20160105-151744</path><enabled>false</enabled><snapshot_mode>0</snapshot_mode><live_timer_interval>0</live_timer_interval></session></sessions></output><success>true</success></command>
+</COMMAND_OUTPUT>
+</SCENARIO>
index 5324351d689d314e16dbc0b4b7e85b80ae78e9e2..69b26b21233b397a5f984e6b4e254dfa287bf85b 100644 (file)
@@ -32,6 +32,7 @@ import org.eclipse.core.runtime.FileLocator;
 import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.IBaseEventInfo;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.IChannelInfo;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.IDomainInfo;
@@ -56,6 +57,7 @@ import org.eclipse.tracecompass.internal.lttng2.control.ui.views.preferences.Con
 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.ILttngControlService;
 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.LTTngControlService;
 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.LTTngControlServiceFactory;
+import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.LttngVersion;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Ignore;
@@ -104,6 +106,7 @@ public class LTTngControlServiceTest {
     private static final String SCEN_DESTROY_SESSION_VERBOSE = "DestroySessionVerbose";
     private static final String SCEN_CHANNEL_HANDLING = "ChannelHandling";
     private static final String SCEN_EVENT_HANDLING = "EventHandling";
+    private static final String SCEN_EVENT_EXLUDED = "EventExcluded";
     private static final String SCEN_CONTEXT_HANDLING = "ContextHandling";
     private static final String SCEN_CONTEXT_ERROR_HANDLING = "ContextErrorHandling";
     private static final String SCEN_CREATE_SESSION_2_1 = "CreateSessionLttng2.1";
@@ -1090,38 +1093,113 @@ public class LTTngControlServiceTest {
     @Test
     public void testEnableEvents() {
         try {
-            // 1) session name, channel = null, 3 event names, kernel
             String sessionName = "mysession2";
-            List<String> list = new ArrayList<>();
+            String channelName = "mychannel";
+            // Lists
+            List<String> eventList = new ArrayList<>();
+            List<String> excludeList = new ArrayList<>();
+            // Events
             String eventName0 = "block_rq_remap";
             String eventName1 = "block_bio_remap";
             String eventName2 = "softirq_entry";
-            list.add(eventName0);
-            list.add(eventName1);
-            list.add(eventName2);
+            String ustEventName0 = "ust_tests_hello:tptest_sighandler";
+            String ustEventName1 = "ust_tests_bye:tptest_sighandler";
+            String ustEventWildcard = "ust*";
+
             fShell.setScenario(SCEN_EVENT_HANDLING);
-            fService.enableEvents(sessionName, null, list, true, null, null, new NullProgressMonitor());
 
-            // 2) session name, channel=mychannel, event name= null, kernel
-            String channelName = "mychannel";
+            // 1) session name, channel = null, 3 event names, kernel
+            eventList.add(eventName0);
+            eventList.add(eventName1);
+            eventList.add(eventName2);
+            fService.enableEvents(sessionName, null, eventList, true, null, null, new NullProgressMonitor());
+
+            // 2) session name, channel = mychannel, event name= null, kernel
             fService.enableEvents(sessionName, channelName, null, true, null, null, new NullProgressMonitor());
 
-            // 3) session name, channel=mychannel, 1 event name, ust, no filter
-            String ustEventName = "ust_tests_hello:tptest_sighandler";
-            list.clear();
-            list.add(ustEventName);
-            fService.enableEvents(sessionName, channelName, list, false, null, null, new NullProgressMonitor());
+            // 3) session name, channel = mychannel, 1 event name, ust, no filter
+            eventList.clear();
+            eventList.add(ustEventName0);
+            fService.enableEvents(sessionName, channelName, eventList, false, null, null, new NullProgressMonitor());
 
             // 4) session name, channel = mychannel, no event name, ust, with filter
-            fService.enableEvents(sessionName, channelName, list, false, "intfield==10", null, new NullProgressMonitor());
+            fService.enableEvents(sessionName, channelName, eventList, false, "intfield==10", null, new NullProgressMonitor());
 
             // 5) session name, channel = mychannel, no event name, ust, no filter
-            list.clear();
-            fService.enableEvents(sessionName, channelName, list, false, null, null, new NullProgressMonitor());
+            eventList.clear();
+            fService.enableEvents(sessionName, channelName, eventList, false, null, null, new NullProgressMonitor());
 
             // 6) session name, channel = null,
             fService.enableEvents(sessionName, null, ILttngControlService.ALL_EVENTS, true, null, null, new NullProgressMonitor());
 
+            // 7) session name, channel = mychannel, all events, ust, exclude 1 event
+            excludeList.add(ustEventName0);
+            fService.enableEvents(sessionName, channelName, null, false, null, excludeList, new NullProgressMonitor());
+
+            // 8) session name, channel = mychannel, all events, ust, exclude 2 events
+            excludeList.add(ustEventName1);
+            fService.enableEvents(sessionName, channelName, null, false, null, excludeList, new NullProgressMonitor());
+
+            // 9) session name, channel = mychannel, enable 'ust*', ust, exclude 2 events
+            eventList.add(ustEventWildcard);
+            fService.enableEvents(sessionName, channelName, eventList, false, null, excludeList, new NullProgressMonitor());
+
+        } catch (ExecutionException e) {
+            fail(e.toString());
+        }
+    }
+
+    @Test
+    public void testEventExcluded() {
+        try {
+            String sessionName = "mysession2";
+            String channelName = "mychannel";
+            // Lists
+            List<String> eventList = new ArrayList<>();
+            List<String> excludeList = new ArrayList<>();
+            // Events
+            String ustEventName0 = "ust_tests_hello:tptest_sighandler";
+            String ustEventName1 = "ust_tests_bye:tptest_sighandler";
+            String ustEventWildcard = "ust*";
+
+            @NonNull
+            LttngVersion version = fService.getVersion();
+            fShell.setScenario(SCEN_EVENT_EXLUDED);
+
+            // 1) 1 event excluded
+            eventList.add(ustEventWildcard);
+            excludeList.add(ustEventName0);
+            fService.enableEvents(sessionName, channelName, eventList, false, null, excludeList, new NullProgressMonitor());
+
+            @Nullable
+            ISessionInfo session = fService.getSession(sessionName, new NullProgressMonitor());
+            assertNotNull(session);
+            IEventInfo eventInfo = session.getDomains()[0].getChannels()[0].getEvents()[0];
+            assertNotNull(eventInfo);
+            // version 2.8 and above supports the excluded events list
+            if (version.getMajor() > 1 && version.getMinor() > 7) {
+                assertTrue(eventInfo.getExcludedEvents().contains(ustEventName0));
+            } else {
+                assertEquals("has exclusions", eventInfo.getExcludedEvents());
+            }
+
+            // 2) 2 events excluded
+            excludeList.add(ustEventName1);
+            fService.enableEvents(sessionName, channelName, eventList, false, null, excludeList, new NullProgressMonitor());
+
+            session = fService.getSession(sessionName, new NullProgressMonitor());
+            assertNotNull(session);
+            eventInfo = session.getDomains()[0].getChannels()[0].getEvents()[0];
+            assertNotNull(eventInfo);
+
+            // version 2.8 and above supports the excluded events list
+            if (version.getMajor() > 1 && version.getMinor() > 7) {
+                assertTrue(eventInfo.getExcludedEvents().contains(ustEventName0));
+                assertTrue(eventInfo.getExcludedEvents().contains(ustEventName1));
+            } else {
+                assertEquals("has exclusions", eventInfo.getExcludedEvents());
+            }
+
         } catch (ExecutionException e) {
             fail(e.toString());
         }
@@ -1618,4 +1696,4 @@ public class LTTngControlServiceTest {
     }
 
 
-}
\ No newline at end of file
+}
index 013be09bd59df6a683c0e58bf4e500db3bc31770..035870820780ed22ac2da79f83ce8e35cc174bbd 100644 (file)
@@ -10,6 +10,7 @@
 #    Jonathan Rajotte - Initial API and implementation
 #    Bernd Hufmann - Added new test cases
 #    Marc-Andre Laperle - Adapted to MI 3.0 (LTTng 2.8)
+#       Bruno Roy - Added new test cases
 ####################################################################
 ####################################################################
 # Scenario: Test lttng not installed
@@ -1717,6 +1718,78 @@ lttng --mi xml enable-event -a -u -s mysession2 -c mychannel --tracepoint
 </command>
 </COMMAND_OUTPUT>
 
+<COMMAND_INPUT>
+lttng --mi xml enable-event -a -u -s mysession2 -c mychannel --tracepoint --exclude ust_tests_hello:tptest_sighandler
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command
+    xmlns="http://lttng.org/xml/ns/lttng-mi"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0">
+    <name>enable-event</name>
+    <output>
+        <events>
+            <event>
+                <name>*</name>
+                <type>TRACEPOINT</type>
+                <enabled>true</enabled>
+                <exclusions/>
+                <exclusions>
+                    <exclusion>ust_tests_hello:tptest_sighandler</exclusion>
+                </exclusions>
+                <success>true</success>
+            </event>
+        </events>
+    </output>
+    <success>true</success>
+</command>
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng --mi xml enable-event -a -u -s mysession2 -c mychannel --tracepoint --exclude ust_tests_hello:tptest_sighandler,ust_tests_bye:tptest_sighandler
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command
+    xmlns="http://lttng.org/xml/ns/lttng-mi"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0">
+    <name>enable-event</name>
+    <output>
+        <events>
+            <event>
+                <name>*</name>
+                <type>TRACEPOINT</type>
+                <enabled>true</enabled>
+                <exclusions/>
+                <exclusions>
+                    <exclusion>ust_tests_hello:tptest_sighandler</exclusion>
+                    <exclusion>ust_tests_bye:tptest_sighandler</exclusion>
+                </exclusions>
+                <success>true</success>
+            </event>
+        </events>
+    </output>
+    <success>true</success>
+</command>
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng --mi xml enable-event ust* -u -s mysession2 -c mychannel --tracepoint --exclude ust_tests_hello:tptest_sighandler,ust_tests_bye:tptest_sighandler
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command xmlns="http://lttng.org/xml/ns/lttng-mi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0"><name>enable-event</name><output><events><event><name>ust*</name><type>TRACEPOINT</type><enabled>true</enabled><exclusions/><exclusions><exclusion>ust_tests_hello:tptest_sighandler</exclusion><exclusion>ust_tests_bye:tptest_sighandler</exclusion></exclusions><success>true</success></event></events></output><success>true</success></command>
+</COMMAND_OUTPUT>
+
 # Syscall test cases
 
 <COMMAND_INPUT>
@@ -1901,6 +1974,200 @@ lttng --mi xml enable-event -a -k -s mysession2
 
 </SCENARIO>
 
+####################################################################
+# Scenario: Test "lttng enable-events ..." with exclusion
+####################################################################
+<SCENARIO>
+EventExcluded
+
+<COMMAND_INPUT>
+lttng --mi xml enable-event ust* -u -s mysession2 -c mychannel --tracepoint --exclude ust_tests_hello:tptest_sighandler
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command
+    xmlns="http://lttng.org/xml/ns/lttng-mi"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0">
+    <name>enable-event</name>
+    <output>
+        <events>
+            <event>
+                <name>ust*</name>
+                <type>TRACEPOINT</type>
+                <enabled>true</enabled>
+                <exclusions/>
+                <exclusions>
+                    <exclusion>ust_tests_hello:tptest_sighandler</exclusion>
+                </exclusions>
+                <success>true</success>
+            </event>
+        </events>
+    </output>
+    <success>true</success>
+</command>
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng --mi xml list mysession2
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command
+    xmlns="http://lttng.org/xml/ns/lttng-mi"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0">
+    <name>list</name>
+    <output>
+        <sessions>
+            <session>
+                <name>mysession2</name>
+                <path>/home/bruno/lttng-traces/mysession2-20160621-130829</path>
+                <enabled>false</enabled>
+                <snapshot_mode>0</snapshot_mode>
+                <live_timer_interval>0</live_timer_interval>
+                <domains>
+                    <domain>
+                        <type>UST</type>
+                        <buffer_type>PER_UID</buffer_type>
+                        <trackers/>
+                        <channels>
+                            <channel>
+                                <name>mychannel</name>
+                                <enabled>true</enabled>
+                                <attributes>
+                                    <overwrite_mode>DISCARD</overwrite_mode>
+                                    <subbuffer_size>131072</subbuffer_size>
+                                    <subbuffer_count>4</subbuffer_count>
+                                    <switch_timer_interval>0</switch_timer_interval>
+                                    <read_timer_interval>0</read_timer_interval>
+                                    <output_type>MMAP</output_type>
+                                    <tracefile_size>0</tracefile_size>
+                                    <tracefile_count>0</tracefile_count>
+                                    <live_timer_interval>0</live_timer_interval>
+                                    <discarded_events>0</discarded_events>
+                                    <lost_packets>0</lost_packets>
+                                </attributes>
+                                <events>
+                                    <event>
+                                        <name>ust*</name>
+                                        <type>TRACEPOINT</type>
+                                        <enabled>true</enabled>
+                                        <exclusions>
+                                            <exclusion>ust_tests_hello:tptest_sighandler</exclusion>
+                                        </exclusions>
+                                    </event>
+                                </events>
+                            </channel>
+                        </channels>
+                    </domain>
+                </domains>
+            </session>
+        </sessions>
+    </output>
+</command>
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng --mi xml enable-event ust* -u -s mysession2 -c mychannel --tracepoint --exclude ust_tests_hello:tptest_sighandler,ust_tests_bye:tptest_sighandler
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command
+    xmlns="http://lttng.org/xml/ns/lttng-mi"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0">
+    <name>enable-event</name>
+    <output>
+        <events>
+            <event>
+                <name>ust*</name>
+                <type>TRACEPOINT</type>
+                <enabled>true</enabled>
+                <exclusions/>
+                <exclusions>
+                    <exclusion>ust_tests_hello:tptest_sighandler</exclusion>
+                    <exclusion>ust_tests_bye:tptest_sighandler</exclusion>
+                </exclusions>
+                <success>true</success>
+            </event>
+        </events>
+    </output>
+    <success>true</success>
+</command>
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng --mi xml list mysession2
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command
+    xmlns="http://lttng.org/xml/ns/lttng-mi"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0">
+    <name>list</name>
+    <output>
+        <sessions>
+            <session>
+                <name>mysession2</name>
+                <path>/home/bruno/lttng-traces/mysession2-20160621-131000</path>
+                <enabled>false</enabled>
+                <snapshot_mode>0</snapshot_mode>
+                <live_timer_interval>0</live_timer_interval>
+                <domains>
+                    <domain>
+                        <type>UST</type>
+                        <buffer_type>PER_UID</buffer_type>
+                        <trackers/>
+                        <channels>
+                            <channel>
+                                <name>mychannel</name>
+                                <enabled>true</enabled>
+                                <attributes>
+                                    <overwrite_mode>DISCARD</overwrite_mode>
+                                    <subbuffer_size>131072</subbuffer_size>
+                                    <subbuffer_count>4</subbuffer_count>
+                                    <switch_timer_interval>0</switch_timer_interval>
+                                    <read_timer_interval>0</read_timer_interval>
+                                    <output_type>MMAP</output_type>
+                                    <tracefile_size>0</tracefile_size>
+                                    <tracefile_count>0</tracefile_count>
+                                    <live_timer_interval>0</live_timer_interval>
+                                    <discarded_events>0</discarded_events>
+                                    <lost_packets>0</lost_packets>
+                                </attributes>
+                                <events>
+                                    <event>
+                                        <name>ust*</name>
+                                        <type>TRACEPOINT</type>
+                                        <enabled>true</enabled>
+                                        <exclusions>
+                                            <exclusion>ust_tests_hello:tptest_sighandler</exclusion>
+                                            <exclusion>ust_tests_bye:tptest_sighandler</exclusion>
+                                        </exclusions>
+                                    </event>
+                                </events>
+                            </channel>
+                        </channels>
+                    </domain>
+                </domains>
+            </session>
+        </sessions>
+    </output>
+</command>
+</COMMAND_OUTPUT>
+
+</SCENARIO>
+
 ####################################################################
 # Scenario: Test "lttng add-context -h" and lttng --mi xml add-context ..." with different inputs
 ####################################################################
index 214e6a4290b10cb909369db6645106854b8cc6c9..8c37e8fd869090a8acf91bd4665a0e7673f4d059 100644 (file)
@@ -9,6 +9,7 @@
 # Contributors:
 #    Jonathan Rajotte - Initial API and implementation
 #    Bernd Hufmann - Added new test cases
+#       Bruno Roy - Added new test cases
 ####################################################################
 ####################################################################
 # Scenario: Test lttng not installed
@@ -1666,6 +1667,95 @@ lttng --mi xml enable-event -a -u -s mysession2 -c mychannel --tracepoint
 </command>
 </COMMAND_OUTPUT>
 
+<COMMAND_INPUT>
+lttng --mi xml enable-event -a -u -s mysession2 -c mychannel --tracepoint --exclude ust_tests_hello:tptest_sighandler
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command>
+    <name>enable-event</name>
+    <output>
+        <events>
+            <event>
+                <name>*</name>
+                <type>TRACEPOINT</type>
+                <enabled>true</enabled>
+                <filter>false</filter>
+                <exclusion>true</exclusion>
+                <exclusions>
+                    <exclusion>ust_tests_hello:tptest_sighandler</exclusion>
+                </exclusions>
+                <success>true</success>
+            </event>
+        </events>
+    </output>
+    <success>true</success>
+</command>
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng --mi xml enable-event -a -u -s mysession2 -c mychannel --tracepoint --exclude ust_tests_hello:tptest_sighandler,ust_tests_bye:tptest_sighandler
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command>
+    <name>enable-event</name>
+    <output>
+        <events>
+            <event>
+                <name>*</name>
+                <type>TRACEPOINT</type>
+                <enabled>true</enabled>
+                <filter>false</filter>
+                <exclusion>true</exclusion>
+                <exclusions>
+                    <exclusion>ust_tests_hello:tptest_sighandler</exclusion>
+                    <exclusion>ust_tests_bye:tptest_sighandler</exclusion>
+                </exclusions>
+                <success>true</success>
+            </event>
+        </events>
+    </output>
+    <success>true</success>
+</command>
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng --mi xml enable-event ust* -u -s mysession2 -c mychannel --tracepoint --exclude ust_tests_hello:tptest_sighandler,ust_tests_bye:tptest_sighandler
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command>
+    <name>enable-event</name>
+    <output>
+        <events>
+            <event>
+                <name>ust*</name>
+                <type>TRACEPOINT</type>
+                <enabled>true</enabled>
+                <filter>false</filter>
+                <exclusion>true</exclusion>
+                <exclusions>
+                    <exclusion>ust_tests_hello:tptest_sighandler</exclusion>
+                    <exclusion>ust_tests_bye:tptest_sighandler</exclusion>
+                </exclusions>
+                <success>true</success>
+            </event>
+        </events>
+    </output>
+    <success>true</success>
+</command>
+</COMMAND_OUTPUT>
+
 # Syscall test cases
 
 <COMMAND_INPUT>
@@ -1858,6 +1948,187 @@ lttng --mi xml enable-event -a -k -s mysession2
 
 </SCENARIO>
 
+####################################################################
+# Scenario: Test "lttng enable-events ..." with exclusion
+####################################################################
+<SCENARIO>
+EventExcluded
+
+<COMMAND_INPUT>
+lttng --mi xml enable-event ust* -u -s mysession2 -c mychannel --tracepoint --exclude ust_tests_hello:tptest_sighandler
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command>
+    <name>enable-event</name>
+    <output>
+        <events>
+            <event>
+                <name>ust*</name>
+                <type>TRACEPOINT</type>
+                <enabled>true</enabled>
+                <filter>false</filter>
+                <exclusion>true</exclusion>
+                <exclusions>
+                    <exclusion>ust_tests_hello:tptest_sighandler</exclusion>
+                </exclusions>
+                <success>true</success>
+            </event>
+        </events>
+    </output>
+    <success>true</success>
+</command>
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng --mi xml list mysession2
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command>
+    <name>list</name>
+    <output>
+        <sessions>
+            <session>
+                <name>mysession2</name>
+                <path>/home/ebruroy/lttng-traces/mysession2-20160621-125643</path>
+                <enabled>false</enabled>
+                <snapshot_mode>0</snapshot_mode>
+                <live_timer_interval>0</live_timer_interval>
+                <domains>
+                    <domain>
+                        <type>UST</type>
+                        <buffer_type>PER_UID</buffer_type>
+                        <trackers/>
+                        <channels>
+                            <channel>
+                                <name>mychannel</name>
+                                <enabled>true</enabled>
+                                <attributes>
+                                    <overwrite_mode>DISCARD</overwrite_mode>
+                                    <subbuffer_size>131072</subbuffer_size>
+                                    <subbuffer_count>4</subbuffer_count>
+                                    <switch_timer_interval>0</switch_timer_interval>
+                                    <read_timer_interval>0</read_timer_interval>
+                                    <output_type>MMAP</output_type>
+                                    <tracefile_size>0</tracefile_size>
+                                    <tracefile_count>0</tracefile_count>
+                                    <live_timer_interval>0</live_timer_interval>
+                                </attributes>
+                                <events>
+                                    <event>
+                                        <name>ust*</name>
+                                        <type>TRACEPOINT</type>
+                                        <enabled>true</enabled>
+                                        <filter>false</filter>
+                                        <exclusion>true</exclusion>
+                                    </event>
+                                </events>
+                            </channel>
+                        </channels>
+                    </domain>
+                </domains>
+            </session>
+        </sessions>
+    </output>
+</command>
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng --mi xml enable-event ust* -u -s mysession2 -c mychannel --tracepoint --exclude ust_tests_hello:tptest_sighandler,ust_tests_bye:tptest_sighandler
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command>
+    <name>enable-event</name>
+    <output>
+        <events>
+            <event>
+                <name>ust*</name>
+                <type>TRACEPOINT</type>
+                <enabled>true</enabled>
+                <filter>false</filter>
+                <exclusion>true</exclusion>
+                <exclusions>
+                    <exclusion>ust_tests_hello:tptest_sighandler</exclusion>
+                    <exclusion>ust_tests_bye:tptest_sighandler</exclusion>
+                </exclusions>
+                <success>true</success>
+            </event>
+        </events>
+    </output>
+    <success>true</success>
+</command>
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng --mi xml list mysession2
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command>
+    <name>list</name>
+    <output>
+        <sessions>
+            <session>
+                <name>mysession2</name>
+                <path>/home/ebruroy/lttng-traces/mysession2-20160621-125933</path>
+                <enabled>false</enabled>
+                <snapshot_mode>0</snapshot_mode>
+                <live_timer_interval>0</live_timer_interval>
+                <domains>
+                    <domain>
+                        <type>UST</type>
+                        <buffer_type>PER_UID</buffer_type>
+                        <trackers/>
+                        <channels>
+                            <channel>
+                                <name>mychannel</name>
+                                <enabled>true</enabled>
+                                <attributes>
+                                    <overwrite_mode>DISCARD</overwrite_mode>
+                                    <subbuffer_size>131072</subbuffer_size>
+                                    <subbuffer_count>4</subbuffer_count>
+                                    <switch_timer_interval>0</switch_timer_interval>
+                                    <read_timer_interval>0</read_timer_interval>
+                                    <output_type>MMAP</output_type>
+                                    <tracefile_size>0</tracefile_size>
+                                    <tracefile_count>0</tracefile_count>
+                                    <live_timer_interval>0</live_timer_interval>
+                                </attributes>
+                                <events>
+                                    <event>
+                                        <name>ust*</name>
+                                        <type>TRACEPOINT</type>
+                                        <enabled>true</enabled>
+                                        <filter>false</filter>
+                                        <exclusion>true</exclusion>
+                                    </event>
+                                </events>
+                            </channel>
+                        </channels>
+                    </domain>
+                </domains>
+            </session>
+        </sessions>
+    </output>
+</command>
+</COMMAND_OUTPUT>
+
+</SCENARIO>
+
 ####################################################################
 # Scenario: Test "lttng add-context -h" and lttng --mi xml add-context ..." with different inputs
 ####################################################################
index 6387f5fa0ba59ad5c7470594dc697d996505a6d0..d274d950bfdbfe7cfa914e7f026195b2ca20ce87 100644 (file)
@@ -8,6 +8,7 @@
 #
 # Contributors:
 #    Bernd Hufmann - Initial API and implementation
+#       Bruno Roy - Added new test cases
 ####################################################################
 ####################################################################
 # Scenario: Test lttng not installed
@@ -944,6 +945,36 @@ lttng enable-event -a -u -s mysession2 -c mychannel --tracepoint
 All UST tracepoints are enabled in channel mychannel
 </COMMAND_OUTPUT>
 
+<COMMAND_INPUT>
+lttng enable-event -a -u -s mysession2 -c mychannel --tracepoint --exclude ust_tests_hello:tptest_sighandler
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+All UST events excluding ust_tests_hello:tptest_sighandler are enabled in channel mychannel
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng enable-event -a -u -s mysession2 -c mychannel --tracepoint --exclude ust_tests_hello:tptest_sighandler,ust_tests_bye:tptest_sighandler
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+All UST events excluding ust_tests_hello:tptest_sighandler,ust_tests_bye:tptest_sighandler are enabled in channel mychannel
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng enable-event ust* -u -s mysession2 -c mychannel --tracepoint --exclude ust_tests_hello:tptest_sighandler,ust_tests_bye:tptest_sighandler
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+UST event ust* excluding ust_tests_hello:tptest_sighandler,ust_tests_bye:tptest_sighandler created in channel mychannel
+</COMMAND_OUTPUT>
+
 # Syscall test cases
 
 <COMMAND_INPUT>
@@ -1022,6 +1053,100 @@ All Kernel events are enabled in channel channel0
 
 </SCENARIO>
 
+####################################################################
+# Scenario: Test "lttng enable-events ..." with exclusion
+####################################################################
+<SCENARIO>
+EventExcluded
+
+<COMMAND_INPUT>
+lttng enable-event ust* -u -s mysession2 -c mychannel --tracepoint --exclude ust_tests_hello:tptest_sighandler
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+UST event ust* excluding ust_tests_hello:tptest_sighandler created in channel mychannel
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng list mysession2
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Tracing session mysession2: [inactive]
+    Trace path: /home/user/lttng-traces/mysession2-20160621-104942
+
+=== Domain: UST global ===
+
+Buffer type: per UID
+
+Channels:
+-------------
+- mychannel: [enabled]
+
+    Attributes:
+      overwrite mode: 0
+      subbufers size: 131072
+      number of subbufers: 4
+      switch timer interval: 0
+      read timer interval: 0
+      trace file count: 0
+      trace file size (bytes): 0
+      output: mmap()
+
+    Events:
+      ust* (type: tracepoint) [enabled] [has exclusions]
+
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng enable-event ust* -u -s mysession2 -c mychannel --tracepoint --exclude ust_tests_hello:tptest_sighandler,ust_tests_bye:tptest_sighandler
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+UST event ust* excluding ust_tests_hello:tptest_sighandler,ust_tests_bye:tptest_sighandler created in channel mychannel
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng list mysession2
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Tracing session mysession2: [inactive]
+    Trace path: /home/user/lttng-traces/mysession2-20160621-104942
+
+=== Domain: UST global ===
+
+Buffer type: per UID
+
+Channels:
+-------------
+- mychannel: [enabled]
+
+    Attributes:
+      overwrite mode: 0
+      subbufers size: 131072
+      number of subbufers: 4
+      switch timer interval: 0
+      read timer interval: 0
+      trace file count: 0
+      trace file size (bytes): 0
+      output: mmap()
+
+    Events:
+      ust* (type: tracepoint) [enabled] [has exclusions]
+
+</COMMAND_OUTPUT>
+
+</SCENARIO>
+
 ####################################################################
 # Scenario: Test "lttng add-context -h" and lttng add-context ..." with different inputs
 ####################################################################
index 11710ab744b701e9d3140443d9932458e6166f6d..8ce198ffd72ea402766d37285d8a7a5a5e6c77ea 100644 (file)
@@ -1070,6 +1070,16 @@ public class LTTngControlService implements ILttngControlService {
     // Helper methods
     // ------------------------------------------------------------------------
 
+    private static void setFilterExpression(IEventInfo eventInfo, String filter) {
+        // remove '[' and ']'
+        String temp = filter.substring(1, filter.length() - 1);
+        if (temp.equals(LTTngControlServiceConstants.HAS_EXCLUSIONS)) {
+            eventInfo.setExcludedEvents(temp);
+        } else {
+            eventInfo.setFilterExpression(temp);
+        }
+    }
+
     /**
      * Checks if command result is an error result.
      *
@@ -1292,9 +1302,7 @@ public class LTTngControlService implements ILttngControlService {
                 eventInfo.setState(matcher.group(5));
                 String filter = matcher.group(6);
                 if (filter != null) {
-                    // remove '[' and ']'
-                    filter = filter.substring(1, filter.length() - 1);
-                    eventInfo.setFilterExpression(filter);
+                    setFilterExpression(eventInfo, filter);
                 }
                 events.add(eventInfo);
                 index++;
@@ -1305,9 +1313,7 @@ public class LTTngControlService implements ILttngControlService {
                 eventInfo.setState(matcher2.group(3));
                 String filter = matcher2.group(4);
                 if (filter != null) {
-                    // remove '[' and ']'
-                    filter = filter.substring(1, filter.length() - 1);
-                    eventInfo.setFilterExpression(filter);
+                    setFilterExpression(eventInfo, filter);
                 }
 
                 if ((eventInfo.getEventType() == TraceEventType.PROBE) ||
index 1119c3ac08740d1b3bcaefcf3d1572e5e73a8ae0..bda07e927c99dbc56516051855c4e6a7c3a10450 100644 (file)
@@ -51,6 +51,11 @@ public interface LTTngControlServiceConstants {
     /** The default directory for session */
     public static final String DEFAULT_PATH = ".lttng/sessions"; //$NON-NLS-1$
 
+    /**
+     * The string returned when some event(s) are excluded.
+     */
+    String HAS_EXCLUSIONS = "has exclusions"; //$NON-NLS-1$
+
     // ------------------------------------------------------------------------
     // LTTng Machine Interface constants
     // ------------------------------------------------------------------------
This page took 0.06715 seconds and 5 git commands to generate.