Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/swtbot/TestCreateSystemtapScript.java')
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/swtbot/TestCreateSystemtapScript.java294
1 files changed, 254 insertions, 40 deletions
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/swtbot/TestCreateSystemtapScript.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/swtbot/TestCreateSystemtapScript.java
index 854e1b9ad3..0561f09daf 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/swtbot/TestCreateSystemtapScript.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/swtbot/TestCreateSystemtapScript.java
@@ -16,12 +16,18 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import java.text.MessageFormat;
+import java.util.List;
+
import org.eclipse.linuxtools.internal.systemtap.ui.ide.launcher.Messages;
+import org.eclipse.linuxtools.systemtap.graphingapi.ui.charts.ScatterChartBuilder;
+import org.eclipse.linuxtools.systemtap.graphingapi.ui.wizards.graph.GraphFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.finders.ContextMenuHelper;
@@ -29,10 +35,12 @@ import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.eclipse.swtbot.swt.finder.results.VoidResult;
import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCTabItem;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
@@ -201,20 +209,9 @@ public class TestCreateSystemtapScript {
editor.typeText(0, editor.getText().length(), "}");
editor.save();
- // Focus on project explorer view.
- bot.viewByTitle("Project Explorer").setFocus();
- bot.activeShell();
- SWTBotTree treeBot = bot.tree();
- treeBot.setFocus();
- SWTBotTreeItem node = treeBot.expandNode((SYSTEMTAP_PROJECT_NAME));
- bot.waitUntil(new NodeAvaiable(node, scriptName));
-
- treeBot.expandNode(SYSTEMTAP_PROJECT_NAME).expand().select(scriptName);
-
- MenuItem menu = ContextMenuHelper.contextMenu(treeBot, "Run As", "Run Configurations...");
- click(menu);
-
+ openRunConfigurations(scriptName);
SWTBotShell shell = bot.shell("Run Configurations");
+ shell.setFocus();
SWTBotTree runConfigurationsTree = bot.tree();
runConfigurationsTree.select("SystemTap").contextMenu("New").click();
@@ -238,19 +235,7 @@ public class TestCreateSystemtapScript {
String scriptName = "missingColumns.stp";
createScript(bot, scriptName);
- // Focus on project explorer view.
- bot.viewByTitle("Project Explorer").setFocus();
- bot.activeShell();
- SWTBotTree treeBot = bot.tree();
- treeBot.setFocus();
- SWTBotTreeItem node = treeBot.expandNode((SYSTEMTAP_PROJECT_NAME));
- bot.waitUntil(new NodeAvaiable(node, scriptName));
-
- treeBot.expandNode(SYSTEMTAP_PROJECT_NAME).expand().select(scriptName);
-
- MenuItem menu = ContextMenuHelper.contextMenu(treeBot, "Run As", "Run Configurations...");
- click(menu);
-
+ openRunConfigurations(scriptName);
SWTBotShell shell = bot.shell("Run Configurations");
shell.setFocus();
@@ -265,22 +250,15 @@ public class TestCreateSystemtapScript {
bot.checkBox(Messages.SystemTapScriptGraphOptionsTab_2).click();
// As soon as the Graphing tab is entered, no regular expression exists & nothing can be run.
- SWTBotText text = bot.textWithLabel("Regular Expression:");
- assertEquals("", text.getText());
+ SWTBotCombo combo = bot.comboBoxWithLabel(Messages.SystemTapScriptGraphOptionsTab_regexLabel);
+ assertEquals("", combo.getText());
assertTrue(!bot.button("Run").isEnabled());
assertTrue(!bot.button(Messages.SystemTapScriptGraphOptionsTab_AddGraphButton).isEnabled());
- text.setText("(1)(2)");
- assertEquals("(1)(2)", text.getText());
+ combo.setText("(1)(2)");
+ assertEquals("(1)(2)", combo.getText());
assertTrue(bot.button("Run").isEnabled());
assertTrue(bot.button(Messages.SystemTapScriptGraphOptionsTab_AddGraphButton).isEnabled());
- text = bot.text("", 1);
- text.setText("Val 1");
- assertEquals("Val 1", text.getText());
- text = bot.text("", 1);
- text.setText("Val 2");
- assertEquals("Val 2", text.getText());
-
bot.button(Messages.SystemTapScriptGraphOptionsTab_AddGraphButton).click();
setupGraph("Graph");
@@ -288,10 +266,10 @@ public class TestCreateSystemtapScript {
assertTrue(bot.button("Run").isEnabled());
// Removing groups from the regex disables graphs that rely on those groups.
- text = bot.textWithLabel("Regular Expression:");
- text.setText("(1)");
+ combo = bot.comboBoxWithLabel(Messages.SystemTapScriptGraphOptionsTab_regexLabel);
+ combo.setText("(1)");
assertTrue(!bot.button("Run").isEnabled());
- text.setText("(1)(2)(3)");
+ combo.setText("(1)(2)(3)");
assertTrue(bot.button("Run").isEnabled());
shell.setFocus();
@@ -300,6 +278,242 @@ public class TestCreateSystemtapScript {
bot.waitUntil(new ShellIsClosed(shell));
}
+ @Test
+ public void testDeleteBlankRegex(){
+ createScript(bot, "blank.stp");
+ openRunConfigurations("blank.stp");
+ SWTBotShell shell = bot.shell("Run Configurations");
+ shell.setFocus();
+
+ SWTBotTree runConfigurationsTree = bot.tree();
+ runConfigurationsTree.select("SystemTap").contextMenu("New").click();
+
+ // Select the "Graphing" tab.
+ SWTBotCTabItem tab = bot.cTabItem(Messages.SystemTapScriptGraphOptionsTab_7);
+ tab.activate();
+
+ // Enable output graphing.
+ bot.checkBox(Messages.SystemTapScriptGraphOptionsTab_2).click();
+
+ // Confirm that adding a new regex when the current one is blank has no effect.
+ SWTBotCombo combo = bot.comboBoxWithLabel(Messages.SystemTapScriptGraphOptionsTab_regexLabel);
+ assertEquals(2, combo.itemCount());
+ combo.setSelection(1);
+ assertEquals(2, combo.itemCount());
+ assertEquals(0, combo.selectionIndex());
+
+ // Confirm that adding a regex works when the current regex is not empty.
+ combo.setText("(a) b (c)");
+ assertEquals("(a) b (c)", combo.getText());
+ combo.setSelection(1);
+ assertEquals(3, combo.itemCount());
+ assertEquals(1, combo.selectionIndex());
+
+ // Confirm that a blank regex is not removed when other data is not empty.
+ combo.setText("(a)");
+ bot.button(Messages.SystemTapScriptGraphOptionsTab_AddGraphButton).click();
+ SWTBotShell shell2 = bot.shell("Create Graph");
+ shell2.setFocus();
+ bot.textWithLabel("Title:").setText("Test");
+ bot.button("Finish").click();
+ bot.waitUntil(new ShellIsClosed(shell2));
+ shell.setFocus();
+ combo.setText("");
+ assertEquals("", combo.getText());
+ combo.setSelection(0);
+ assertEquals(3, combo.itemCount());
+
+ // Confirm that auto-deleting a blank regex in the middle of the regex list works properly.
+ combo.setSelection(2);
+ assertEquals(4, combo.itemCount());
+ combo.setText("sample");
+ combo.setSelection(1);
+ assertEquals(4, combo.itemCount());
+ SWTBotTable table = bot.table(0);
+ SWTBotButton button = bot.button(Messages.SystemTapScriptGraphOptionsTab_RemoveGraphButton);
+ assertTrue(!button.isEnabled());
+ table.select(0);
+ assertTrue(button.isEnabled());
+ button.click();
+ assertTrue(!button.isEnabled());
+ combo.setSelection(2);
+ assertEquals(3, combo.itemCount());
+ assertEquals("sample", combo.getText());
+ assertEquals("(a) b (c)", combo.items()[0]);
+ assertEquals("sample", combo.items()[1]);
+
+ // Confirm that auto-deleting a regex from the beginning of the list works properly.
+ combo.setSelection(2);
+ combo.setText("another sample");
+ combo.setSelection(0);
+ combo.setText("");
+ combo.setSelection(1);
+ assertEquals(3, combo.itemCount());
+ assertEquals("sample", combo.getText());
+ assertEquals("sample", combo.items()[0]);
+ assertEquals("another sample", combo.items()[1]);
+
+ bot.button("Close").click();
+ shell2 = bot.shell("Save Changes");
+ shell2.setFocus();
+ bot.button("No").click();
+ bot.waitUntil(new ShellIsClosed(shell));
+ }
+
+ @Test
+ public void testGraphScript(){
+ String scriptName = "testGraph.stp";
+ createScript(bot, scriptName);
+
+ // Write a script
+ SWTBotEclipseEditor editor = bot.editorByTitle(scriptName).toTextEditor();
+ editor.setText("#!/usr/bin/env stap"
+ + "\nglobal i,j,k"
+ + "\nprobe begin{i=0;j=0;k=0}"
+ + "\nprobe timer.ms(100){printf(\"Value:%d %d\\n\",i,j);i++;j+=2}"
+ + "\nprobe timer.ms(250){printf(\"Other:%d %d\\n\",i,k);k++}");
+ editor.save();
+
+ String val0 = "i";
+ String val1 = "j";
+ String val2 = "k";
+
+ openRunConfigurations(scriptName);
+ SWTBotShell shell = bot.shell("Run Configurations");
+ shell.setFocus();
+
+ SWTBotTree runConfigurationsTree = bot.tree();
+ runConfigurationsTree.select("SystemTap").contextMenu("New").click();
+ bot.textWithLabel("Name:").setText(scriptName);
+
+ // Select the "Graphing" tab.
+ SWTBotCTabItem tab = bot.cTabItem(Messages.SystemTapScriptGraphOptionsTab_7);
+ tab.activate();
+
+ // Enable output graphing.
+ bot.checkBox(Messages.SystemTapScriptGraphOptionsTab_2).click();
+ SWTBotCombo combo = bot.comboBoxWithLabel(Messages.SystemTapScriptGraphOptionsTab_regexLabel);
+ combo.setText("Value:(\\d+) (\\d+)");
+ assertEquals("Value:(\\d+) (\\d+)", combo.getText());
+
+ SWTBotText text = bot.textWithLabel(Messages.SystemTapScriptGraphOptionsTab_sampleOutputLabel);
+ text.setText("Value:1 2");
+ assertEquals("Value:1 2", text.getText());
+
+ text = bot.text(MessageFormat.format(Messages.SystemTapScriptGraphOptionsTab_defaultColumnTitleBase, 1));
+ text.setText(val0);
+ assertEquals(val0, text.getText());
+ text = bot.text(MessageFormat.format(Messages.SystemTapScriptGraphOptionsTab_defaultColumnTitleBase, 2));
+ text.setText(val1);
+ assertEquals(val1, text.getText());
+
+ // Add a graph.
+ bot.button(Messages.SystemTapScriptGraphOptionsTab_AddGraphButton).click();
+ setupGraph("Values");
+
+ // Make a second regex, and a graph for it.
+ shell.setFocus();
+ combo = bot.comboBoxWithLabel(Messages.SystemTapScriptGraphOptionsTab_regexLabel);
+ assertEquals(2, combo.itemCount());
+ combo.setSelection(combo.selectionIndex() + 1);
+ assertEquals(3, combo.itemCount());
+ assertEquals("", combo.getText());
+ combo.setText("Other:(\\d+) (\\d+)");
+ assertEquals("Other:(\\d+) (\\d+)", combo.getText());
+
+ text = bot.text(MessageFormat.format(Messages.SystemTapScriptGraphOptionsTab_defaultColumnTitleBase, 1));
+ text.setText(val0);
+ assertEquals(val0, text.getText());
+ text = bot.text(MessageFormat.format(Messages.SystemTapScriptGraphOptionsTab_defaultColumnTitleBase, 2));
+ text.setText(val2);
+ assertEquals(val2, text.getText());
+
+ text = bot.textWithLabel(Messages.SystemTapScriptGraphOptionsTab_sampleOutputLabel);
+ assertEquals("", text.getText());
+
+ bot.button(Messages.SystemTapScriptGraphOptionsTab_AddGraphButton).click();
+ setupGraph("Others");
+
+ // Apply the changes, then close the menu & reopen it to make sure settings were saved.
+ shell.setFocus();
+ bot.button("Apply").click();
+ bot.button("Close").click();
+ bot.waitUntil(new ShellIsClosed(shell));
+ openRunConfigurations(scriptName);
+ shell = bot.shell("Run Configurations");
+ shell.setFocus();
+ bot.tree().expandNode("SystemTap").select(scriptName);
+ tab = bot.cTabItem(Messages.SystemTapScriptGraphOptionsTab_7);
+ tab.activate();
+
+ combo = bot.comboBoxWithLabel(Messages.SystemTapScriptGraphOptionsTab_regexLabel);
+ text = bot.textWithLabel(Messages.SystemTapScriptGraphOptionsTab_sampleOutputLabel);
+ SWTBotTable table = bot.table(0);
+ assertEquals(3, combo.itemCount());
+ assertEquals("Value:(\\d+) (\\d+)", combo.getText());
+ assertEquals("Value:1 2", text.getText());
+ assertEquals(1, table.rowCount());
+ assertTrue(table.containsItem(GraphFactory.getGraphName(ScatterChartBuilder.ID) + ":Values"));
+ combo.setSelection(1);
+ assertEquals("Other:(\\d+) (\\d+)", combo.getText());
+ assertEquals("", text.getText());
+ assertEquals(1, table.rowCount());
+ assertTrue(table.containsItem(GraphFactory.getGraphName(ScatterChartBuilder.ID) + ":Others"));
+
+ // If Systemtap is not installed, don't test graph output. Otherwise, do.
+ if (!stapInstalled) {
+ bot.button("Close").click();
+ bot.waitUntil(new ShellIsClosed(shell));
+ return;
+ }
+
+ bot.button("Run").click();
+ bot.waitUntil(new ShellIsClosed(shell));
+ bot.sleep(2500); // Let the script run for a moment
+ SWTBotView console = bot.viewById("org.eclipse.ui.console.ConsoleView");
+ console.setFocus();
+ console.toolbarButton("Stop Script").click(); // Stop the script manually
+ bot.waitUntil(new StapHasExited(), 10000);
+
+ bot.sleep(1000); // Give time for the table to be fully constructed
+ SWTBotEditor graphDisplay = bot.activeEditor();
+ graphDisplay.setFocus();
+ graphDisplay.bot().cTabItem(MessageFormat.format(Messages.SystemTapScriptGraphOptionsTab_graphSetTitleBase, 1)).activate();
+ graphDisplay.bot().cTabItem("Data View").activate();
+ SWTBotTable dataTable = bot.table(0);
+ List<String> colNames = dataTable.columns();
+ assertEquals(3, colNames.size());
+ assertEquals(val0, colNames.get(1));
+ assertEquals(val1, colNames.get(2));
+ assertEquals("3", dataTable.cell(3, 1));
+ assertEquals("6", dataTable.cell(3, 2));
+
+ graphDisplay.bot().cTabItem(MessageFormat.format(Messages.SystemTapScriptGraphOptionsTab_graphSetTitleBase, 2)).activate();
+ graphDisplay.bot().cTabItem("Data View").activate();
+ dataTable = bot.table(0);
+ colNames = dataTable.columns();
+ assertEquals(3, colNames.size());
+ assertEquals(val0, colNames.get(1));
+ assertEquals(val2, colNames.get(2));
+ assertEquals("10", dataTable.cell(3, 1));
+ assertEquals("3", dataTable.cell(3, 2));
+ }
+
+ private void openRunConfigurations(String scriptName) {
+ // Focus on project explorer view.
+ bot.viewByTitle("Project Explorer").setFocus();
+ bot.activeShell();
+ SWTBotTree treeBot = bot.tree();
+ treeBot.setFocus();
+ SWTBotTreeItem node = treeBot.expandNode(SYSTEMTAP_PROJECT_NAME);
+ bot.waitUntil(new NodeAvaiable(node, scriptName));
+
+ treeBot.expandNode(SYSTEMTAP_PROJECT_NAME).expand().select(scriptName);
+
+ MenuItem menu = ContextMenuHelper.contextMenu(treeBot, "Run As", "Run Configurations...");
+ click(menu);
+ }
+
private void setupGraph(String title) {
SWTBotShell shell = bot.shell("Create Graph");
shell.setFocus();

Back to the top