From: Bernd Hufmann Date: Tue, 5 Jan 2016 21:14:03 +0000 (-0500) Subject: control: add SWTBot test to test kernel filtering for events X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=43628e7b2af4f9c0217a0fe6812d6fb6be87155e;p=deliverable%2Ftracecompass.git control: add SWTBot test to test kernel filtering for events Change-Id: I5de303ba182942b42cccb94db3995f0877cee5bd Signed-off-by: Bernd Hufmann Reviewed-on: https://git.eclipse.org/r/63592 Reviewed-by: Hudson CI Tested-by: Matthew Khouzam Reviewed-by: Matthew Khouzam --- diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/control/ui/swtbot/tests/AllTests.java b/lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/control/ui/swtbot/tests/AllTests.java index ec84a93ae2..0824230d8d 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/control/ui/swtbot/tests/AllTests.java +++ b/lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/control/ui/swtbot/tests/AllTests.java @@ -17,8 +17,9 @@ import org.junit.runners.Suite; */ @RunWith(Suite.class) @Suite.SuiteClasses({ - ControlViewTest.class, + ControlViewKernelFilterTest.class, ControlViewProfileTest.class, + ControlViewTest.class }) public class AllTests { diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/control/ui/swtbot/tests/ControlViewKernelFilterTest.java b/lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/control/ui/swtbot/tests/ControlViewKernelFilterTest.java new file mode 100644 index 0000000000..91ffec28aa --- /dev/null +++ b/lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/control/ui/swtbot/tests/ControlViewKernelFilterTest.java @@ -0,0 +1,218 @@ +/******************************************************************************* + * 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.swt.finder.junit.SWTBotJunit4ClassRunner; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotCCombo; +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.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 save and load feature. + * + * @author Bernd Hufmann + */ +@RunWith(SWTBotJunit4ClassRunner.class) +public class ControlViewKernelFilterTest extends ControlViewTest { + + // ------------------------------------------------------------------------ + // Constants + // ------------------------------------------------------------------------ + private static final String TEST_STREAM = "CreateSessionTestLTTng2_7.cfg"; + private static final String CREATE_SESSION_KERNEL_FILTER_SCENARIO_NAME = "KernelFilter"; + private static final String CREATE_SESSION_KERNEL_FILTER_PROVIDER_SCENARIO_NAME = "KernelFilterProvider"; + + private static final String SESSION_NAME = "mysession"; + private static final String FILTER_EXPRESSION = "next_tid==1234"; + private static final String FILTER_EXPRESSION_DISPLAY = "with filter"; + + @Override + protected String getTestStream() { + return TEST_STREAM; + } + + @Override + protected String getSessionName() { + return SESSION_NAME; + } + + @Override + @Test + public void testTraceSessionTree() { + + fProxy.setTestFile(fTestFile); + fProxy.setScenario(INIT_SCENARIO_NAME); + + testConnectToNode(); + // Prepare for saving of profile + fProxy.setScenario(CREATE_SESSION_KERNEL_FILTER_SCENARIO_NAME); + testCreateSession(); + testEnableKernelEvent(); + testStartStopTracing(TraceSessionState.ACTIVE); + testStartStopTracing(TraceSessionState.INACTIVE); + testDestroySession(); + testDisconnectFromNode(); + } + + /** + * Test enable events from Kernel provider + */ + @Test + public void testTraceSessionTreeKernelProvider() { + + fProxy.setTestFile(fTestFile); + fProxy.setScenario(INIT_SCENARIO_NAME); + + testConnectToNode(); + // Prepare for saving of profile + fProxy.setScenario(CREATE_SESSION_KERNEL_FILTER_PROVIDER_SCENARIO_NAME); + testCreateSession(); + testEnableKernelFromProviderEvent(); + testStartStopTracing(TraceSessionState.ACTIVE); + testStartStopTracing(TraceSessionState.INACTIVE); + testDestroySession(); + testDisconnectFromNode(); + } + + @Override + protected void testEnableKernelEvent() { + SWTBotTreeItem sessionItem = SWTBotUtils.getTreeItem(fBot, fTree, + getNodeName(), + ControlViewSwtBotUtil.SESSION_GROUP_NAME, + getSessionName()); + + sessionItem.select(); + SWTBotMenu menuBot = sessionItem.contextMenu(ControlViewSwtBotUtil.ENABLE_EVENT_DEFAULT_CHANNEL_MENU_ITEM); + menuBot.click(); + + SWTBotShell shell = fBot.shell(ControlViewSwtBotUtil.ENABLE_EVENT_DIALOG_TITLE).activate(); + + SWTBotTree tracepointsTree = shell.bot().tree(); + tracepointsTree.select(ControlViewSwtBotUtil.ALL_TREE_NODE); + SWTBotText filterText = shell.bot().textInGroup(ControlViewSwtBotUtil.FILTER_EXPRESSION_LABEL); + filterText.setText(FILTER_EXPRESSION); + shell.bot().button(ControlViewSwtBotUtil.DIALOG_OK_BUTTON).click(); + SWTBotUtils.waitForJobs(); + + fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, sessionItem)); + + SWTBotTreeItem kernelDomainItem = SWTBotUtils.getTreeItem(fBot, fTree, + getNodeName(), + ControlViewSwtBotUtil.SESSION_GROUP_NAME, + getSessionName(), + ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME); + assertEquals(ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, kernelDomainItem.getText()); + + SWTBotTreeItem channelItem = SWTBotUtils.getTreeItem(fBot, fTree, + getNodeName(), + ControlViewSwtBotUtil.SESSION_GROUP_NAME, + getSessionName(), + ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, + ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME); + assertEquals(ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME, channelItem.getText()); + + SWTBotTreeItem eventItem = SWTBotUtils.getTreeItem(fBot, fTree, + getNodeName(), + ControlViewSwtBotUtil.SESSION_GROUP_NAME, + getSessionName(), + ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, + ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME, + ControlViewSwtBotUtil.ALL_EVENTS_NAME); + assertEquals(ControlViewSwtBotUtil.ALL_EVENTS_NAME, eventItem.getText()); + + ITraceControlComponent comp = ControlViewSwtBotUtil.getComponent(fNode, + ControlViewSwtBotUtil.SESSION_GROUP_NAME, + getSessionName(), + ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, + ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME, + ControlViewSwtBotUtil.ALL_EVENTS_NAME); + assertNotNull(comp); + assertTrue(comp instanceof TraceEventComponent); + TraceEventComponent event = (TraceEventComponent) comp; + assertEquals(FILTER_EXPRESSION_DISPLAY, event.getFilterExpression()); + } + + private void testEnableKernelFromProviderEvent() { + SWTBotTreeItem kernelProviderEventItem = SWTBotUtils.getTreeItem(fBot, fTree, + getNodeName(), + ControlViewSwtBotUtil.PROVIDER_GROUP_NAME, + ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, + ControlViewSwtBotUtil.SCHED_SWITCH_EVENT_NAME); + + kernelProviderEventItem.select(); + SWTBotMenu menuBot = kernelProviderEventItem.contextMenu(ControlViewSwtBotUtil.ENABLE_EVENT_MENU_ITEM); + menuBot.click(); + + SWTBotShell shell = fBot.shell(ControlViewSwtBotUtil.ENABLE_EVENT_DIALOG_TITLE).activate(); + SWTBotCCombo sessionCombo = shell.bot().ccomboBoxInGroup(ControlViewSwtBotUtil.SESSION_LIST_GROUP_NAME); + sessionCombo.setSelection(getSessionName()); + SWTBotText filterText = shell.bot().textInGroup(ControlViewSwtBotUtil.FILTER_EXPRESSION_LABEL); + filterText.setText(FILTER_EXPRESSION); + shell.bot().button(ControlViewSwtBotUtil.DIALOG_OK_BUTTON).click(); + SWTBotUtils.waitForJobs(); + + SWTBotTreeItem sessionItem = SWTBotUtils.getTreeItem(fBot, fTree, + getNodeName(), + ControlViewSwtBotUtil.SESSION_GROUP_NAME, + getSessionName()); + + fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, sessionItem)); + + SWTBotTreeItem kernelDomainItem = SWTBotUtils.getTreeItem(fBot, fTree, + getNodeName(), + ControlViewSwtBotUtil.SESSION_GROUP_NAME, + getSessionName(), + ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME); + assertEquals(ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, kernelDomainItem.getText()); + + SWTBotTreeItem channelItem = SWTBotUtils.getTreeItem(fBot, fTree, + getNodeName(), + ControlViewSwtBotUtil.SESSION_GROUP_NAME, + getSessionName(), + ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, + ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME); + assertEquals(ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME, channelItem.getText()); + + SWTBotTreeItem eventItem = SWTBotUtils.getTreeItem(fBot, fTree, + getNodeName(), + ControlViewSwtBotUtil.SESSION_GROUP_NAME, + getSessionName(), + ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, + ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME, + ControlViewSwtBotUtil.SCHED_SWITCH_EVENT_NAME); + assertEquals(ControlViewSwtBotUtil.SCHED_SWITCH_EVENT_NAME, eventItem.getText()); + + ITraceControlComponent comp = ControlViewSwtBotUtil.getComponent(fNode, + ControlViewSwtBotUtil.SESSION_GROUP_NAME, + getSessionName(), + ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, + ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME, + ControlViewSwtBotUtil.SCHED_SWITCH_EVENT_NAME); + assertNotNull(comp); + assertTrue(comp instanceof TraceEventComponent); + TraceEventComponent event = (TraceEventComponent) comp; + assertEquals(FILTER_EXPRESSION_DISPLAY, event.getFilterExpression()); + } + +} \ No newline at end of file diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/control/ui/swtbot/tests/ControlViewSwtBotUtil.java b/lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/control/ui/swtbot/tests/ControlViewSwtBotUtil.java index 35786bda31..4f9de63131 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/control/ui/swtbot/tests/ControlViewSwtBotUtil.java +++ b/lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/control/ui/swtbot/tests/ControlViewSwtBotUtil.java @@ -9,9 +9,12 @@ package org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests; +import java.util.Arrays; + import org.eclipse.swtbot.swt.finder.waits.ICondition; import org.eclipse.tracecompass.internal.lttng2.control.core.model.TargetNodeState; import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceSessionState; +import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.ITraceControlComponent; import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TargetNodeComponent; import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceSessionComponent; import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers.SWTBotTestCondition; @@ -28,7 +31,9 @@ class ControlViewSwtBotUtil { public static final String KERNEL_DOMAIN_NAME = "Kernel"; public static final String UST_DOMAIN_NAME = "UST global"; public static final String SESSION_GROUP_NAME = "Sessions"; + public static final String PROVIDER_GROUP_NAME = "Provider"; public static final String ALL_EVENTS_NAME = "*"; + public static final String SCHED_SWITCH_EVENT_NAME = "sched_switch"; public static final String PROFILE_SUFFIX = ".lttng"; // Menu strings @@ -58,6 +63,8 @@ class ControlViewSwtBotUtil { public static final String UST_GROUP_NAME = "UST"; 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 SESSION_LIST_GROUP_NAME = "Session List"; public static final String DESTROY_CONFIRM_DIALOG_TITLE = "Destroy Confirmation"; public static final String CHANNEL_NAME_LABEL = "Channel Name"; @@ -131,4 +138,27 @@ class ControlViewSwtBotUtil { return null; } + /** + * Finds a {@link ITraceControlComponent} in a tree for given path. + * + * @param root + * root component + * @param path + * path to element + * @return the matched component or null + */ + public static ITraceControlComponent getComponent(ITraceControlComponent root, String... path) { + ITraceControlComponent newRoot = root; + for (String segment : path) { + newRoot = Arrays.asList(newRoot.getChildren()).stream() + .filter(child -> (child.getName().equals(segment))) + .findFirst() + .orElse(null); + if (newRoot == null) { + return null; + } + } + return newRoot; + } + } diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/testfiles/CreateSessionTestLTTng2_7.cfg b/lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/testfiles/CreateSessionTestLTTng2_7.cfg index 9caffae204..cf140b0fef 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/testfiles/CreateSessionTestLTTng2_7.cfg +++ b/lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/testfiles/CreateSessionTestLTTng2_7.cfg @@ -185,3 +185,152 @@ lttng --mi xml destroy mysession destroymysession/home/eedbhu/lttng-traces/mysession-20151201-205959false00true + + +KernelFilter + +lttng --mi xml create mysession + + +0 + + + +createmysession/home/eedbhu/lttng-traces/mysession-20160105-151744false00true + + +lttng --mi xml list mysession + + +0 + + + +listmysession/home/eedbhu/lttng-traces/mysession-20160105-151744false00 + + +lttng --mi xml enable-event -a -k -s mysession --tracepoint --filter next_tid==1234 + + +0 + + + +enable-event*TRACEPOINTtruetrueTRACE_EMERGALLfalsetruetrue + + +lttng --mi xml list mysession + + +0 + + + +listmysession/home/eedbhu/lttng-traces/mysession-20160105-151744false00KERNELGLOBALchannel0trueDISCARD26214440200000SPLICE000*TRACEPOINTtruetrueTRACE_EMERGALLfalse + + +lttng --mi xml start mysession + + +0 + + + +startmysessiontruetrue + + +lttng --mi xml stop mysession + + +0 + + + +stopmysessionfalsetrue + + +lttng --mi xml destroy mysession + + +0 + + + +destroymysession/home/eedbhu/lttng-traces/mysession-20160105-151744false00true + + + + +KernelFilterProvider + +lttng --mi xml create mysession + + +0 + + + +createmysession/home/eedbhu/lttng-traces/mysession-20160105-151744false00true + + +lttng --mi xml list mysession + + +0 + + + +listmysession/home/eedbhu/lttng-traces/mysession-20160105-151744false00 + + +lttng --mi xml enable-event sched_switch -k -s mysession --tracepoint --filter next_tid==1234 + + +0 + + + +enable-eventsched_switchTRACEPOINTtruetrueTRACE_EMERGALLfalsetruetrue + + +lttng --mi xml list mysession + + +0 + + + +listmysession/home/eedbhu/lttng-traces/mysession-20160105-151744false00KERNELGLOBALchannel0trueDISCARD26214440200000SPLICE000sched_switchTRACEPOINTtruetrueTRACE_EMERGALLfalse + + + +lttng --mi xml start mysession + + +0 + + + +startmysessiontruetrue + + +lttng --mi xml stop mysession + + +0 + + + +stopmysessionfalsetrue + + +lttng --mi xml destroy mysession + + +0 + + + +destroymysession/home/eedbhu/lttng-traces/mysession-20160105-151744false00true + + \ No newline at end of file