use of org.eclipse.tracecompass.tmf.core.trace.ITmfTrace in project tracecompass by tracecompass.
the class UstKernelSyncTest method testOneEvent.
/**
* Test that the TID given by the kernel analysis matches the one from the
* UST event's context for a given UST event that was known to fail.
*
* Reproduces the specific example that was pointed out in bug 484620.
*/
@Test
public void testOneEvent() {
TmfExperiment experiment = fExperiment;
ITmfTrace ustTrace = fUstTrace;
KernelAnalysisModule module = fKernelModule;
assertNotNull(experiment);
assertNotNull(ustTrace);
assertNotNull(module);
Predicate<@NonNull ITmfEvent> eventFinder = event -> {
Long addr = event.getContent().getFieldValue(Long.class, "addr");
Long cs = event.getContent().getFieldValue(Long.class, "call_site");
Long ctxVtid = event.getContent().getFieldValue(Long.class, "context._vtid");
if (addr == null || cs == null || ctxVtid == null) {
return false;
}
return Objects.equals(event.getType().getName(), "lttng_ust_cyg_profile:func_entry") && Objects.equals(Long.toHexString(addr), "804af97") && Objects.equals(Long.toHexString(cs), "804ab03") && Objects.equals(ctxVtid.longValue(), 594L);
};
/* The event we're looking for is the second event matching the predicate */
CtfTmfEvent ustEvent = (CtfTmfEvent) TmfTraceUtils.getNextEventMatching(experiment, 0, eventFinder, null);
assertNotNull(ustEvent);
long rank = experiment.seekEvent(ustEvent.getTimestamp()).getRank() + 1;
ustEvent = (CtfTmfEvent) TmfTraceUtils.getNextEventMatching(experiment, rank, eventFinder, null);
assertNotNull(ustEvent);
/* Make sure the correct event was retrieved */
assertEquals(ustTrace, ustEvent.getTrace());
assertEquals(1450193715128075054L, ustEvent.getTimestamp().toNanos());
Integer tidFromKernel = KernelThreadInformationProvider.getThreadOnCpu(module, ustEvent.getCPU(), ustEvent.getTimestamp().toNanos());
assertNotNull(tidFromKernel);
assertEquals(594, tidFromKernel.intValue());
}
use of org.eclipse.tracecompass.tmf.core.trace.ITmfTrace in project tracecompass by tracecompass.
the class CriticalPathTest method testFull.
/**
* test the behavior of the critical path for a thread selection signal from
* the control flow view
*/
@Test
public void testFull() {
SWTBotTimeGraph timeGraphCfv = new SWTBotTimeGraph(fViewBotCfv.bot());
SWTBotTree treeCp = fViewBotCp.bot().tree();
SWTBotTimeGraph timeGraphCp = new SWTBotTimeGraph(fViewBotCp.bot());
assertNotNull(timeGraphCfv.widget);
assertNotNull(treeCp.widget);
SWTBotTreeItem[] allItems = treeCp.getAllItems();
for (int i = 0; i < allItems.length; i++) {
assertEquals(0, allItems[i].getNodes().size());
}
ITmfTrace trace = TmfTraceManager.getInstance().getActiveTrace();
assertNotNull(trace);
SWTBotTimeGraphEntry entry = timeGraphCfv.getEntry(trace.getName(), "systemd", "we", PROCESS);
assertNotNull(entry);
entry.select();
SWTBotMenu menu = entry.contextMenu("Follow " + PROCESS + "/" + TID);
assertEquals("Follow " + PROCESS + "/" + TID, menu.getText());
menu.click();
fBot.waitUntil(new DefaultCondition() {
@Override
public boolean test() throws Exception {
SWTBotTimeGraphEntry[] entries = timeGraphCp.getEntries();
return CRIT_PATH_MAIN_ENTRY.equals(entries[0].getEntries()[0].getText());
}
@Override
public String getFailureMessage() {
return "Could not find " + CRIT_PATH_MAIN_ENTRY + " in Critical Path view";
}
});
// Test navigating the critical path view with the follow arrows buttons
IWorkbenchPart part = fViewBotCp.getViewReference().getPart(false);
TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, CPU_TIME0));
SWTBotTimeGraphEntry critPathEntry = timeGraphCp.getEntry(trace.getHostId(), CRIT_PATH_MAIN_ENTRY);
critPathEntry.select();
// Condition to wait for the time graph view to refresh
ICondition timeGraphIsReadyCondition = ConditionHelpers.timeGraphIsReadyCondition((AbstractTimeGraphView) part, new TmfTimeRange(CPU_TIME1, CPU_TIME1), CPU_TIME1);
// Reach the end of the current event
fViewBotCp.toolbarButton(FOLLOW_FORWARD).click();
fBot.waitUntil(timeGraphIsReadyCondition);
fBot.waitUntil(ConditionHelpers.timeGraphSelectionContains(timeGraphCp, 0, CRIT_PATH_MAIN_ENTRY));
// Follow the arrow down to the next item
fViewBotCp.toolbarButton(FOLLOW_FORWARD).click();
fBot.waitUntil(timeGraphIsReadyCondition);
fBot.waitUntil(ConditionHelpers.timeGraphSelectionContains(timeGraphCp, 0, CRIT_PATH_OTHER_ENTRY));
// Make sure changing the selection changed the selection in CFV too
fBot.waitUntil(ConditionHelpers.timeGraphSelectionContains(timeGraphCfv, 0, KWORKER_PROCESS));
// Follow it back up
fViewBotCp.toolbarButton(FOLLOW_BACKWARD).click();
fBot.waitUntil(timeGraphIsReadyCondition);
fBot.waitUntil(ConditionHelpers.timeGraphSelectionContains(timeGraphCp, 0, CRIT_PATH_MAIN_ENTRY));
// Make sure changing the selection changed the selection in CFV too
fBot.waitUntil(ConditionHelpers.timeGraphSelectionContains(timeGraphCfv, 0, PROCESS));
// Follow another process and make sure the critical path changes
entry = timeGraphCfv.getEntry(trace.getName(), "systemd", "we", PROCESS, PROCESS2);
assertNotNull(entry);
entry.select();
menu = entry.contextMenu("Follow " + PROCESS2 + "/" + TID2);
assertEquals("Follow " + PROCESS2 + "/" + TID2, menu.getText());
menu.click();
fBot.waitUntil(new DefaultCondition() {
@Override
public boolean test() throws Exception {
SWTBotTimeGraphEntry[] entries = timeGraphCp.getEntries();
return CRIT_PATH_MAIN_ENTRY2.equals(entries[0].getEntries()[0].getText());
}
@Override
public String getFailureMessage() {
return "Could not find " + CRIT_PATH_MAIN_ENTRY2 + " in Critical Path view";
}
});
}
use of org.eclipse.tracecompass.tmf.core.trace.ITmfTrace in project tracecompass by tracecompass.
the class KernelMemoryUsageViewTest method getTestTrace.
@Override
protected ITmfTrace getTestTrace() {
ITmfTrace trace = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.ARM_64_BIT_HEADER);
fTraceName = trace.getName();
return trace;
}
use of org.eclipse.tracecompass.tmf.core.trace.ITmfTrace in project tracecompass by tracecompass.
the class ResourcesAndCpuViewTest method testCpuView.
/**
* Simple test to check the CPU Usage view after getting signals.
*/
@Test
public void testCpuView() {
IViewPart viewPart = getSWTBotView().getViewReference().getView(true);
assertTrue(viewPart instanceof CpuUsageView);
final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewPart);
assertNotNull(chartViewer);
fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
final Chart chart = getChart();
assertNotNull(chart);
SWTBotUtils.waitUntil(c -> c.getSeriesSet().getSeries().length > 0, chart, "No data available");
chartViewer.setNbPoints(10);
fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
/* Test data model */
SWTBotUtils.waitUntil(json -> isChartDataValid(chart, json), "resources/cpuusage/cpu-usage-res10.json", "Chart data is not valid");
/* Test chart style */
verifySeriesStyle(TOTAL_SERIES_NAME, ISeries.SeriesType.LINE, BLUE, LineStyle.SOLID, false);
/* Select a thread */
SWTBotTreeItem rootEntry = getSWTBotView().bot().tree().getTreeItem(TRACE_NAME);
SWTBotUtils.waitUntil(tree -> getTableCount() >= 8, rootEntry, "Did not finish loading");
SWTBotTreeItem selectedTheadNode = rootEntry.getNode(SELECTED_THREAD);
selectedTheadNode.check();
SWTBotUtils.waitUntil(c -> c.getSeriesSet().getSeries().length >= 2, chart, "Only total available");
/* Test data model */
SWTBotUtils.waitUntil(json -> isChartDataValid(chart, json, SELECTED_THREAD_SERIES), "resources/cpuusage/cpu-usage-res10Selected.json", "Chart data is not valid");
/* Test chart style */
verifySeriesStyle(SELECTED_THREAD_SERIES, ISeries.SeriesType.LINE, RED, LineStyle.SOLID, true);
selectedTheadNode.uncheck();
/* Selected an another thread and test in HD */
String otherSelectedThread = "lttng-consumerd";
SWTBotTreeItem otherSelectedThreadNode = rootEntry.getNode(otherSelectedThread);
otherSelectedThreadNode.check();
chartViewer.setNbPoints(100);
SWTBotUtils.waitUntil(c -> c.getSeriesSet().getSeries().length >= 2, chart, "Only total available");
fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
/* Test data model */
SWTBotUtils.waitUntil(json -> isChartDataValid(chart, json, OTHERTHREAD_SERIES), "resources/cpuusage/cpu-usage-res100Selected.json", "Chart data is not valid");
/* Test chart style */
verifySeriesStyle(OTHERTHREAD_SERIES, ISeries.SeriesType.LINE, GREEN, LineStyle.SOLID, true);
/*
* Test new TimeRange
*/
chartViewer.setNbPoints(10);
SWTBotUtils.waitUntil(c -> c.getSeriesSet().getSeries().length >= 2, chart, "Only total available");
fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
ITmfTrace activeTrace = TmfTraceManager.getInstance().getActiveTrace();
assertNotNull(activeTrace);
fResourcesViewBot.getToolbarButtons().stream().filter(button -> button.getToolTipText().contains(RESET)).findAny().get().click();
fBot.waitUntil(ConditionHelpers.windowRange(new TmfTimeRange(TRACE_START, TRACE_END)));
SWTBotUtils.waitUntil(c -> c.getSeriesSet().getSeries().length >= 2, chart, "Only total available");
fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
/* Test data model */
SWTBotUtils.waitUntil(json -> isChartDataValid(chart, json, OTHERTHREAD_SERIES), "resources/cpuusage/cpu-usage-all-res10.json", "Chart data is not valid");
/* Test chart style */
verifySeriesStyle(OTHERTHREAD_SERIES, ISeries.SeriesType.LINE, GREEN, LineStyle.SOLID, true);
}
use of org.eclipse.tracecompass.tmf.core.trace.ITmfTrace in project tracecompass by tracecompass.
the class ResourcesAndCpuViewTest method testResetTimeRange.
/**
* Test that the reset time range button resets the time range for both the CPU
* view and the Resources view.
*/
@Test
public void testResetTimeRange() {
ITmfTrace activeTrace = TmfTraceManager.getInstance().getActiveTrace();
assertNotNull(activeTrace);
IViewPart viewPart = getSWTBotView().getViewReference().getView(true);
assertTrue(viewPart instanceof CpuUsageView);
final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewPart);
assertNotNull(chartViewer);
IWorkbenchPart part = fResourcesViewBot.getViewReference().getPart(false);
assertTrue(part instanceof AbstractTimeGraphView);
AbstractTimeGraphView abstractTimeGraphView = (AbstractTimeGraphView) part;
// click the reset time range button in the CPU view
getSWTBotView().toolbarButton(RESET).click();
assertChartRange(chartViewer, FULL_RANGE);
fResourcesViewBot.setFocus();
fBot.waitUntil(ConditionHelpers.timeGraphRangeCondition(abstractTimeGraphView, activeTrace, FULL_RANGE));
// go back to the original range
broadcast(new TmfWindowRangeUpdatedSignal(this, activeTrace.getInitialTimeRange(), activeTrace));
// click the reset time range button in the Resources View
fResourcesViewBot.toolbarButton(RESET).click();
assertChartRange(chartViewer, FULL_RANGE);
fResourcesViewBot.setFocus();
fBot.waitUntil(ConditionHelpers.timeGraphRangeCondition(abstractTimeGraphView, activeTrace, FULL_RANGE));
}
Aggregations