/*******************************************************************************
- * Copyright (c) 2015 Ericsson
+ * Copyright (c) 2015, 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
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assume.assumeTrue;
+import static org.junit.Assert.assertTrue;
import java.io.File;
+import java.io.IOException;
+import java.net.URL;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
+import java.util.stream.Collectors;
import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.Logger;
import org.apache.log4j.SimpleLayout;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
+import org.eclipse.swtbot.swt.finder.waits.Conditions;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace;
import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal;
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
-import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTrace;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
+import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils;
+import org.eclipse.tracecompass.tmf.ui.dialog.TmfFileDialogFactory;
import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers;
import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
+import org.eclipse.tracecompass.tmf.ui.tests.shared.WaitUtils;
import org.eclipse.tracecompass.tmf.ui.views.callstack.CallStackView;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Timestamps of consecutive events in the trace
*/
- private static final long TIMESTAMPS[] = new long[] {
+ private static final long TIMESTAMPS[] = new long[] {
1378850463804898643l,
1378850463804899057l,
1378850463804900219l,
* Stack frames of consecutive events in the trace
*/
private static final String[] STACK_FRAMES[] = new String[][] {
- {"40472b", "4045c8", "404412", "", ""},
- {"40472b", "4045c8", "404412", "40392b", ""},
- {"40472b", "4045c8", "404412", "", ""},
- {"40472b", "4045c8", "", "", ""},
- {"40472b", "4045c8", "404412", "", ""},
- {"40472b", "4045c8", "404412", "40392b", ""},
- {"40472b", "4045c8", "404412", "", ""},
- {"40472b", "4045c8", "", "", ""},
- {"40472b", "4045c8", "404412", "", ""},
- {"40472b", "4045c8", "404412", "40392b", ""},
- {"40472b", "4045c8", "404412", "", ""},
+ { "0x40472b", "0x4045c8", "0x404412", "", "" },
+ { "0x40472b", "0x4045c8", "0x404412", "0x40392b", "" },
+ { "0x40472b", "0x4045c8", "0x404412", "", "" },
+ { "0x40472b", "0x4045c8", "", "", "" },
+ { "0x40472b", "0x4045c8", "0x404412", "", "" },
+ { "0x40472b", "0x4045c8", "0x404412", "0x40392b", "" },
+ { "0x40472b", "0x4045c8", "0x404412", "", "" },
+ { "0x40472b", "0x4045c8", "", "", "" },
+ { "0x40472b", "0x4045c8", "0x404412", "", "" },
+ { "0x40472b", "0x4045c8", "0x404412", "0x40392b", "" },
+ { "0x40472b", "0x4045c8", "0x404412", "", "" },
};
/** Tooltips of the toolbar buttons */
- private static final String ALIGN_VIEWS = "Align Views";
- private static final String IMPORT_BINARY = "Import a binary file containing debugging symbols";
- private static final String IMPORT_TEXT = "Import a text file containing the mapping between addresses and function names";
+ private static final @NonNull String ALIGN_VIEWS = "Align Views";
+ private static final @NonNull String CONFIGURE_SYMBOL_PROVIDERS = "Configure how the addresses are mapped to function names";
// Separator
- private static final String SORT_BY_NAME = "Sort threads by thread name";
- private static final String SORT_BY_ID = "Sort threads by thread id";
- private static final String SORT_BY_START = "Sort threads by start time";
+ private static final @NonNull String SORT_BY_NAME = "Sort threads by thread name";
+ private static final @NonNull String SORT_BY_ID = "Sort threads by thread id";
+ private static final @NonNull String SORT_BY_START = "Sort threads by start time";
// Separator
- private static final String RESET_TIME_SCALE = "Reset the Time Scale to Default";
- private static final String SELECT_PREVIOUS_EVENT = "Select Previous Event";
- private static final String SELECT_NEXT_EVENT = "Select Next Event";
- private static final String SELECT_PREVIOUS_ITEM = "Select Previous Item";
- private static final String SELECT_NEXT_ITEM = "Select Next Item";
- private static final String ZOOM_IN = "Zoom In";
- private static final String ZOOM_OUT = "Zoom Out";
+ private static final @NonNull String SHOW_VIEW_FILTERS = "Show View Filters";
+ // Separator
+ private static final @NonNull String RESET_TIME_SCALE = "Reset the Time Scale to Default";
+ private static final @NonNull String SELECT_PREVIOUS_STATE_CHANGE = "Select Previous State Change";
+ private static final @NonNull String SELECT_NEXT_STATE_CHANGE = "Select Next State Change";
+ // Separator
+ private static final @NonNull String ADD_BOOKMARK = "Add Bookmark...";
+ private static final @NonNull String PREVIOUS_MARKER = "Previous Marker";
+ private static final @NonNull String NEXT_MARKER = "Next Marker";
+ // Separator
+ private static final @NonNull String SELECT_PREVIOUS_ITEM = "Select Previous Item";
+ private static final @NonNull String SELECT_NEXT_ITEM = "Select Next Item";
+ private static final @NonNull String ZOOM_IN = "Zoom In";
+ private static final @NonNull String ZOOM_OUT = "Zoom Out";
// Separator
private static final String PIN_VIEW = "Pin View";
private static final List<String> TOOLBAR_BUTTONS_TOOLTIPS = ImmutableList.of(
- ALIGN_VIEWS, IMPORT_BINARY, IMPORT_TEXT,
+ ALIGN_VIEWS, CONFIGURE_SYMBOL_PROVIDERS,
"",
SORT_BY_NAME, SORT_BY_ID, SORT_BY_START,
"",
- RESET_TIME_SCALE, SELECT_PREVIOUS_EVENT, SELECT_NEXT_EVENT,
+ SHOW_VIEW_FILTERS,
+ "",
+ RESET_TIME_SCALE, SELECT_PREVIOUS_STATE_CHANGE, SELECT_NEXT_STATE_CHANGE,
+ "",
+ ADD_BOOKMARK, PREVIOUS_MARKER, NEXT_MARKER,
+ "",
SELECT_PREVIOUS_ITEM, SELECT_NEXT_ITEM, ZOOM_IN, ZOOM_OUT,
"",
PIN_VIEW);
*/
@BeforeClass
public static void init() {
- SWTBotUtils.failIfUIThread();
+ SWTBotUtils.initialize();
Thread.currentThread().setName("SWTBot Thread"); // for the debugger
/* set up for swtbot */
SWTBotUtils.switchToTracingPerspective();
/* finish waiting for eclipse to load */
- SWTBotUtils.waitForJobs();
+ WaitUtils.waitForJobs();
}
/**
SWTBotUtils.createProject(PROJECT_NAME);
SWTBotTreeItem treeItem = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME);
assertNotNull(treeItem);
- final CtfTmfTestTrace cygProfile = CtfTmfTestTrace.CYG_PROFILE;
- assumeTrue(cygProfile.exists());
- final File file = new File(cygProfile.getTrace().getPath());
+ final CtfTestTrace cygProfile = CtfTestTrace.CYG_PROFILE;
+ final File file = new File(CtfTmfTestTraceUtils.getTrace(cygProfile).getPath());
SWTBotUtils.openTrace(PROJECT_NAME, file.getAbsolutePath(), UST_ID);
SWTBotUtils.openView(CallStackView.ID);
- SWTBotUtils.waitForJobs();
+ WaitUtils.waitForJobs();
}
/**
@Test
public void testOpenCallstack() {
String node = "glxgears-cyg-profile";
+ String processName = "UNKNOWN";
String childName = "glxgears-16073";
- List<String> expected = ImmutableList.of("40472b", "", "", "", "");
+ List<String> expected = ImmutableList.of("0x40472b", "", "", "", "");
SWTBotView viewBot = fBot.viewById(CallStackView.ID);
viewBot.setFocus();
final SWTBotView viewBot1 = viewBot;
SWTBotTree tree = viewBot1.bot().tree();
- SWTBotTreeItem treeItem = tree.getTreeItem(node);
+ SWTBotTreeItem treeItem = tree.getTreeItem(node).getNode(processName);
assertEquals(childName, treeItem.getNodes().get(0));
List<String> names = treeItem.getNode(childName).getNodes();
assertEquals(expected, names);
final SWTBotView viewBot = fBot.viewById(CallStackView.ID);
viewBot.setFocus();
- SWTBotUtils.waitForJobs();
+ WaitUtils.waitForJobs();
List<String> names = getVisibleStackFrames(viewBot);
assertArrayEquals(STACK_FRAMES[0], names.toArray());
}
final SWTBotView viewBot = fBot.viewById(CallStackView.ID);
// forward 10 times
for (int i = 0; i < 10; i++) {
- viewBot.toolbarPushButton(SELECT_NEXT_EVENT).click();
+ viewBot.toolbarPushButton(SELECT_NEXT_STATE_CHANGE).click();
currentEventOffset++;
fBot.waitUntil(ConditionHelpers.selectionInEventsTable(fBot, TIMESTAMPS[currentEventOffset]));
- SWTBotUtils.waitForJobs();
+ WaitUtils.waitForJobs();
assertArrayEquals(STACK_FRAMES[currentEventOffset], getVisibleStackFrames(viewBot).toArray());
}
// back twice
for (int i = 0; i < 2; i++) {
- viewBot.toolbarPushButton(SELECT_PREVIOUS_EVENT).click();
+ viewBot.toolbarPushButton(SELECT_PREVIOUS_STATE_CHANGE).click();
currentEventOffset--;
fBot.waitUntil(ConditionHelpers.selectionInEventsTable(fBot, TIMESTAMPS[currentEventOffset]));
- SWTBotUtils.waitForJobs();
+ WaitUtils.waitForJobs();
assertArrayEquals(STACK_FRAMES[currentEventOffset], getVisibleStackFrames(viewBot).toArray());
}
// move up and down once to make sure it doesn't explode
viewBot.toolbarPushButton(SELECT_PREVIOUS_ITEM).click();
- SWTBotUtils.waitForJobs();
+ WaitUtils.waitForJobs();
viewBot.toolbarPushButton(SELECT_NEXT_ITEM).click();
- SWTBotUtils.waitForJobs();
+ WaitUtils.waitForJobs();
// Zoom in and out too
viewBot.toolbarPushButton(ZOOM_IN).click();
- SWTBotUtils.waitForJobs();
+ WaitUtils.waitForJobs();
viewBot.toolbarPushButton(ZOOM_OUT).click();
- SWTBotUtils.waitForJobs();
+ WaitUtils.waitForJobs();
}
/**
viewBot.toolbarToggleButton(SORT_BY_ID).click();
viewBot.toolbarToggleButton(SORT_BY_START).click();
viewBot.setFocus();
- SWTBotUtils.waitForJobs();
+ WaitUtils.waitForJobs();
List<String> names = getVisibleStackFrames(viewBot);
assertArrayEquals(STACK_FRAMES[0], names.toArray());
}
private static List<String> getVisibleStackFrames(final SWTBotView viewBot) {
SWTBotTree tree = viewBot.bot().tree();
- List<String> names = new ArrayList<>();
- for (SWTBotTreeItem swtBotTreeItem : tree.getAllItems()) {
- for (SWTBotTreeItem items : swtBotTreeItem.getItems()) {
- for (SWTBotTreeItem item : items.getItems()) {
- names.add(item.cell(0));
- }
- }
- }
- return names;
+ return Arrays.stream(tree.getAllItems())
+ // Process entries
+ .flatMap(item -> Arrays.stream(item.getItems()))
+ // Thread entries
+ .flatMap(item -> Arrays.stream(item.getItems()))
+ // Callstack entries
+ .flatMap(item -> Arrays.stream(item.getItems()))
+ .map(item -> item.cell(0))
+ .collect(Collectors.toList());
}
private static void goToTime(long timestamp) {
SWTBotTable table = fBot.activeEditor().bot().table();
table.setFocus();
- TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(table.widget, new TmfNanoTimestamp(timestamp)));
+ TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(table.widget, TmfTimestamp.fromNanos(timestamp)));
fBot.waitUntil(ConditionHelpers.selectionInEventsTable(fBot, timestamp));
}
/**
* Test check callstack at a time with function map
+ *
+ * @throws IOException
+ * Missing file
*/
- @Ignore
@Test
- public void testGoToTimeAndCheckStackWithNames() {
+ public void testGoToTimeAndCheckStackWithNames() throws IOException {
goToTime(TIMESTAMPS[0]);
final SWTBotView viewBot = fBot.viewById(CallStackView.ID);
viewBot.setFocus();
- // no way to load mappings yet! :(
SWTBotTree tree = viewBot.bot().tree();
- SWTBotUtils.waitForJobs();
+ Object mapObj = CtfTmfTestTraceUtils.class.getResource("cyg-profile-mapping.txt");
+ assertTrue(mapObj instanceof URL);
+ URL mapUrl = (URL) mapObj;
+
+ String absoluteFile = FileLocator.toFileURL(mapUrl).getFile();
+ TmfFileDialogFactory.setOverrideFiles(absoluteFile);
+ viewBot.toolbarButton("Configure how the addresses are mapped to function names").click();
+ String shellTitle = "Symbol mapping";
+ fBot.waitUntil(Conditions.shellIsActive(shellTitle));
+ SWTBot shellBot = fBot.shell(shellTitle).bot();
+ SWTBotShell activeShell = shellBot.activeShell();
+ shellBot.radio(1).click();
+ shellBot.button("Browse...", 1).click();
+ shellBot.button("OK").click();
+ shellBot.waitUntil(Conditions.shellCloses(activeShell));
+ // FIXME: remove when updates are propagated
+ goToTime(TIMESTAMPS[0]);
+ WaitUtils.waitForJobs();
List<String> names = new ArrayList<>();
+
for (SWTBotTreeItem swtBotTreeItem : tree.getAllItems()) {
for (SWTBotTreeItem items : swtBotTreeItem.getItems()) {
for (SWTBotTreeItem item : items.getItems()) {
}
}
}
+ List<String> functions = getVisibleStackFrames(viewBot);
+ assertEquals(ImmutableList.of("glxgears-16073"), names);
+ assertEquals(ImmutableList.of("main", "event_loop", "handle_event", "", ""), functions);
}
/**