From 0c656739e65251c1b69aab1011117800fe6a2f49 Mon Sep 17 00:00:00 2001 From: Bruno Roy Date: Mon, 16 May 2016 17:01:19 -0400 Subject: [PATCH] control.test: SWTBot test for enabling specific event type by name Change-Id: I900b990712423203710f5b73b920d0995f637bad Signed-off-by: Bruno Roy Reviewed-on: https://git.eclipse.org/r/73099 Reviewed-by: Hudson CI Reviewed-by: Bernd Hufmann Tested-by: Bernd Hufmann Reviewed-by: Marc-Andre Laperle Tested-by: Marc-Andre Laperle --- .../tests/ControlViewSpecificEventTest.java | 191 ++++++++++++++++++ .../swtbot/tests/ControlViewSwtBotUtil.java | 5 + .../testfiles/CreateSessionTestLTTng2_8.cfg | 156 ++++++++++++++ 3 files changed, 352 insertions(+) create mode 100644 lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/control/ui/swtbot/tests/ControlViewSpecificEventTest.java diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/control/ui/swtbot/tests/ControlViewSpecificEventTest.java b/lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/control/ui/swtbot/tests/ControlViewSpecificEventTest.java new file mode 100644 index 0000000000..6f0e251d55 --- /dev/null +++ b/lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/control/ui/swtbot/tests/ControlViewSpecificEventTest.java @@ -0,0 +1,191 @@ +/******************************************************************************* + * 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 java.util.Arrays; +import java.util.List; + +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.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 enabling + * of specific kernel event(s) by name. + * + * @author Bruno Roy + */ +@RunWith(SWTBotJunit4ClassRunner.class) +public class ControlViewSpecificEventTest extends ControlViewTest { + + // ------------------------------------------------------------------------ + // Constants + // ------------------------------------------------------------------------ + private static final String TEST_STREAM = "CreateSessionTestLTTng2_8.cfg"; + + private static final String CREATE_SESSION_SPECIFIC_KERNEL_EVENT_SCENARIO_NAME = "CreateSessionSpecificKernelEvent"; + + private static final String SESSION_NAME = "mysession"; + + /** + * Get the test stream file name to use for the test suite + * + * @return the name of the test stream file + */ + @Override + protected String getTestStream() { + return TEST_STREAM; + } + + /** + * Get the session name + * + * @return the session name for this test + */ + @Override + protected String getSessionName() { + return SESSION_NAME; + } + + @Override + @Test + public void testTraceSessionTree() { + + // Initialize scenario + fProxy.setTestFile(fTestFile); + fProxy.setScenario(INIT_SCENARIO_NAME); + + testConnectToNode(); + + // Creating a session by specifying an event scenario + fProxy.setScenario(CREATE_SESSION_SPECIFIC_KERNEL_EVENT_SCENARIO_NAME); + // Create a session + testCreateSession(); + // Enable an event by specifying the event type + testEnableSpecificKernelEvent(Arrays.asList(ControlViewSwtBotUtil.SCHED_SWITCH_EVENT_NAME), false, true); + // Enable multiple events by specifying the event type + testEnableSpecificKernelEvent(Arrays.asList(ControlViewSwtBotUtil.SCHED_WAKEUP_EVENT_NAME, ControlViewSwtBotUtil.SCHED_PROCESSWAIT_EVENT_NAME), false, true); + // Enable an event by specifying the event type and selection in tree (duplication of name) + testEnableSpecificKernelEvent(Arrays.asList(ControlViewSwtBotUtil.SCHED_PROCESSFORK_EVENT_NAME), true, true); + // Enable an event using the tree only + testEnableSpecificKernelEvent(Arrays.asList(ControlViewSwtBotUtil.SCHED_PROCESSEXEC_EVENT_NAME), true, false); + // Enable all events using tree. It will ignore what is written in the specific event text box. + testEnableSpecificKernelEvent(Arrays.asList(ControlViewSwtBotUtil.ALL_TREE_NODE), true, true); + + // Start, stop tracing then destroy the session and diconnect + testStartStopTracing(TraceSessionState.ACTIVE); + testStartStopTracing(TraceSessionState.INACTIVE); + testDestroySession(); + testDisconnectFromNode(); + } + + /** + * Test for enabling an event type by specifying its name + * + * @param events + * event names to enable + * @param selectInTree + * select event names also in tree + * Note: using All as name then all tree node is selected + * @param useNameField + * use event name field + * + */ + private void testEnableSpecificKernelEvent(List events, boolean selectInTree, boolean useNameField) { + 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(); + + // Select specific event radio button in the Specific event group + shell.bot().radioInGroup(ControlViewSwtBotUtil.GROUP_SELECT_NAME, ControlViewSwtBotUtil.TRACEPOINTS_GROUP_NAME).click(); + + if (selectInTree) { + SWTBotTree tracepointsTree = shell.bot().tree(); + for (String event : events) { + if (event.equals(ControlViewSwtBotUtil.ALL_TREE_NODE)) { + SWTBotTreeItem treeItem = tracepointsTree.getTreeItem(ControlViewSwtBotUtil.ALL_TREE_NODE); + treeItem.check(); + break; + } + tracepointsTree.expandNode(ControlViewSwtBotUtil.ALL_TREE_NODE); + // select specific + SWTBotTreeItem treeItem = SWTBotUtils.getTreeItem(fBot, tracepointsTree, ControlViewSwtBotUtil.ALL_TREE_NODE, event); + treeItem.check(); + } + } + + // Enters the event type in the text field Event type in the Specific event group + if (useNameField) { + SWTBotText specificEventText = shell.bot().textInGroup(ControlViewSwtBotUtil.SPECIFIC_EVENT_GROUP_NAME); + String suffix = ""; + StringBuffer buffer = new StringBuffer(); + for (String event : events) { + buffer.append(suffix).append(event); + // append comma and space to test removal of space + suffix = ", "; + } + specificEventText.setText(buffer.toString()); + } + + // Click Ok to quit the dialog window + shell.bot().button(ControlViewSwtBotUtil.DIALOG_OK_BUTTON).click(); + SWTBotUtils.waitForJobs(); + + // Wait until the child of Sessions is activated + fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, sessionItem)); + + // 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.KERNEL_DOMAIN_NAME, + ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME); + assertEquals(ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME, channelItem.getText()); + + channelItem.expand(); + + for (String event : events) { + // Wait until the child of Sessions is activated + String eventName = event; + if (event.equals(ControlViewSwtBotUtil.ALL_TREE_NODE)) { + eventName = ControlViewSwtBotUtil.ALL_EVENTS_NAME; + } + fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(eventName, channelItem)); + // Assert that the event type in the channel node are correct + SWTBotTreeItem eventItem = SWTBotUtils.getTreeItem(fBot, fTree, + getNodeName(), + ControlViewSwtBotUtil.SESSION_GROUP_NAME, + getSessionName(), + ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, + ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME, + eventName); + assertEquals(eventName, eventItem.getText()); + } + + } +} 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 b5a40976f6..611868b24e 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 @@ -34,6 +34,10 @@ class ControlViewSwtBotUtil { 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 SCHED_WAKEUP_EVENT_NAME = "sched_wakeup"; + public static final String SCHED_PROCESSWAIT_EVENT_NAME = "sched_process_wait"; + public static final String SCHED_PROCESSFORK_EVENT_NAME = "sched_process_fork"; + public static final String SCHED_PROCESSEXEC_EVENT_NAME = "sched_process_exec"; public static final String PROFILE_SUFFIX = ".lttng"; public static final String KERNEL_TRACE_NAME = "kernel"; @@ -59,6 +63,7 @@ class ControlViewSwtBotUtil { public static final String ENABLE_EVENT_DIALOG_TITLE = "Enable Events"; public static final String ALL_TREE_NODE = "All"; public static final String ALL_EVENT_GROUP_NAME = "All Tracepoint Events and Syscalls"; + public static final String SPECIFIC_EVENT_GROUP_NAME = "Specific event"; public static final String TRACEPOINTS_GROUP_NAME = "Tracepoint Events"; public static final String SYSCALL_GROUP_NAME = "All Syscalls"; public static final String GROUP_SELECT_NAME = "Select"; diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/testfiles/CreateSessionTestLTTng2_8.cfg b/lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/testfiles/CreateSessionTestLTTng2_8.cfg index 5327bf6119..421945ca03 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/testfiles/CreateSessionTestLTTng2_8.cfg +++ b/lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/testfiles/CreateSessionTestLTTng2_8.cfg @@ -411,4 +411,160 @@ lttng --mi xml destroy mysession destroymysession/home/bernd/lttng-traces/mysession-20160422-070226false00true +############################################################################### +# Enable one specific event by specifying the name +############################################################################### + +CreateSessionSpecificKernelEvent + +lttng --mi xml create mysession + + +0 + + + +createmysession{$workspace}/lttng-traces/mysession-20160518-135630false00true + + +lttng --mi xml list mysession + + +0 + + + +listmysession{$workspace}/lttng-traces/mysession-20160518-135630false00 + + +lttng --mi xml enable-event sched_switch -k -s mysession --tracepoint + + +0 + + + +enable-eventsched_switchTRACEPOINTtrueTRACE_EMERGALLtruetrue + + +lttng --mi xml list mysession + + +0 + + + +listmy/home/bernd/lttng-traces/my-20160617-084445false00KERNELGLOBALchannel0trueDISCARD26214440200000SPLICE00000sched_switchTRACEPOINTtrueTRACE_EMERGALL + + +lttng --mi xml enable-event sched_wakeup,sched_process_wait -k -s mysession --tracepoint + + +0 + + + +enable-eventsched_wakeupTRACEPOINTtrueTRACE_EMERGALLtruesched_process_waitTRACEPOINTtrueTRACE_EMERGALLtruetrue + + +lttng --mi xml list mysession + + +0 + + + +listauto-20160617-082932/home/bernd/lttng-traces/auto-20160617-082932false00KERNELGLOBALchannel0trueDISCARD26214440200000SPLICE00000sched_process_waitTRACEPOINTtrueTRACE_EMERGALLsched_wakeupTRACEPOINTtrueTRACE_EMERGALLsched_switchTRACEPOINTtrueTRACE_EMERGALL + + +lttng --mi xml enable-event sched_process_fork -k -s mysession --tracepoint + + +0 + + + +enable-eventsched_process_forkTRACEPOINTtrueTRACE_EMERGALLtruetrue + + +lttng --mi xml list mysession + + +0 + + + +listauto-20160617-082932/home/bernd/lttng-traces/auto-20160617-082932false00KERNELGLOBALchannel0trueDISCARD26214440200000SPLICE00000sched_process_forkTRACEPOINTtrueTRACE_EMERGALLsched_process_waitTRACEPOINTtrueTRACE_EMERGALLsched_wakeupTRACEPOINTtrueTRACE_EMERGALLsched_switchTRACEPOINTtrueTRACE_EMERGALL + + +lttng --mi xml enable-event sched_process_exec -k -s mysession --tracepoint + + +0 + + + +enable-eventsched_process_execTRACEPOINTtrueTRACE_EMERGALLtruetrue + + +lttng --mi xml list mysession + + +0 + + + +listauto-20160617-082932/home/bernd/lttng-traces/auto-20160617-082932false00KERNELGLOBALchannel0trueDISCARD26214440200000SPLICE00000sched_process_execTRACEPOINTtrueTRACE_EMERGALLsched_process_forkTRACEPOINTtrueTRACE_EMERGALLsched_process_waitTRACEPOINTtrueTRACE_EMERGALLsched_wakeupTRACEPOINTtrueTRACE_EMERGALLsched_switchTRACEPOINTtrueTRACE_EMERGALL + + +lttng --mi xml enable-event -a -k -s mysession --tracepoint + + +0 + + + +enable-event*ALLtruetruetrue + + +lttng --mi xml list mysession + + +0 + + + +listauto-20160617-082932/home/bernd/lttng-traces/auto-20160617-082932false00KERNELGLOBALchannel0trueDISCARD26214440200000SPLICE00000*SYSCALLtrue*TRACEPOINTtrueTRACE_EMERGALLsched_process_execTRACEPOINTtrueTRACE_EMERGALLsched_process_forkTRACEPOINTtrueTRACE_EMERGALLsched_process_waitTRACEPOINTtrueTRACE_EMERGALLsched_wakeupTRACEPOINTtrueTRACE_EMERGALLsched_switchTRACEPOINTtrueTRACE_EMERGALL + + +lttng --mi xml start mysession + + +0 + + + +startmysessiontruetrue + + +lttng --mi xml stop mysession + + +0 + + + +stopmysessionfalsetrue + + +lttng --mi xml destroy mysession + + +0 + + + +destroymysession${workspace}/lttng-traces/mysession-20151201-205959false00true + + -- 2.34.1