Search in sources :

Example 16 with ITmfTrace

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());
}
Also used : CtfTestTrace(org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace) TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal) TestRule(org.junit.rules.TestRule) CtfTmfTestTraceUtils(org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils) TmfExperiment(org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment) CtfTmfEvent(org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent) KernelAnalysisModule(org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule) After(org.junit.After) Timeout(org.junit.rules.Timeout) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) LttngKernelTestTraceUtils(org.eclipse.tracecompass.lttng2.lttng.kernel.core.tests.shared.LttngKernelTestTraceUtils) Before(org.junit.Before) TmfTraceSelectedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal) KernelThreadInformationProvider(org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelThreadInformationProvider) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) Assert.assertNotNull(org.junit.Assert.assertNotNull) Predicate(java.util.function.Predicate) Test(org.junit.Test) Objects(java.util.Objects) TimeUnit(java.util.concurrent.TimeUnit) ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) Rule(org.junit.Rule) TmfTraceUtils(org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils) TmfSignalManager(org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager) NonNull(org.eclipse.jdt.annotation.NonNull) Assert.assertEquals(org.junit.Assert.assertEquals) CtfTmfEvent(org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfExperiment(org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) KernelAnalysisModule(org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule) Test(org.junit.Test)

Example 17 with ITmfTrace

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";
        }
    });
}
Also used : SWTBotTimeGraph(org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotTimeGraph) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) IOException(java.io.IOException) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfSelectionRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree) SWTBotMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) DefaultCondition(org.eclipse.swtbot.swt.finder.waits.DefaultCondition) SWTBotTimeGraphEntry(org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotTimeGraphEntry) ICondition(org.eclipse.swtbot.swt.finder.waits.ICondition) Test(org.junit.Test)

Example 18 with ITmfTrace

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;
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)

Example 19 with ITmfTrace

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);
}
Also used : CtfTestTrace(org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace) UIThreadRunnable(org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable) TmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp) Chart(org.eclipse.swtchart.Chart) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) CtfTmfTestTraceUtils(org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils) ConditionHelpers(org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers) SWTBotUtils(org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) RGB(org.eclipse.swt.graphics.RGB) CpuUsageView(org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.cpuusage.CpuUsageView) Widget(org.eclipse.swt.widgets.Widget) IViewPart(org.eclipse.ui.IViewPart) TmfTraceManager(org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager) TmfCommonXAxisChartViewer(org.eclipse.tracecompass.tmf.ui.viewers.xychart.linechart.TmfCommonXAxisChartViewer) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) WidgetOfType(org.eclipse.swtbot.swt.finder.matchers.WidgetOfType) TmfCpuSelectedSignal(org.eclipse.tracecompass.analysis.os.linux.core.signals.TmfCpuSelectedSignal) WaitUtils(org.eclipse.tracecompass.tmf.ui.tests.shared.WaitUtils) Before(org.junit.Before) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) Assert.assertNotNull(org.junit.Assert.assertNotNull) ISeries(org.eclipse.swtchart.ISeries) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) TmfSignal(org.eclipse.tracecompass.tmf.core.signal.TmfSignal) XYDataProviderBaseTest(org.eclipse.tracecompass.tmf.ui.swtbot.tests.views.xychart.XYDataProviderBaseTest) ResourcesView(org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.resources.ResourcesView) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) AbstractTimeGraphView(org.eclipse.tracecompass.tmf.ui.views.timegraph.AbstractTimeGraphView) Tree(org.eclipse.swt.widgets.Tree) Matcher(org.hamcrest.Matcher) SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) TmfSignalManager(org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager) TmfWindowRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal) NonNull(org.eclipse.jdt.annotation.NonNull) LineStyle(org.eclipse.swtchart.LineStyle) Assert.assertEquals(org.junit.Assert.assertEquals) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) IViewPart(org.eclipse.ui.IViewPart) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) TmfCommonXAxisChartViewer(org.eclipse.tracecompass.tmf.ui.viewers.xychart.linechart.TmfCommonXAxisChartViewer) CpuUsageView(org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.cpuusage.CpuUsageView) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) Chart(org.eclipse.swtchart.Chart) Test(org.junit.Test) XYDataProviderBaseTest(org.eclipse.tracecompass.tmf.ui.swtbot.tests.views.xychart.XYDataProviderBaseTest)

Example 20 with ITmfTrace

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));
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) AbstractTimeGraphView(org.eclipse.tracecompass.tmf.ui.views.timegraph.AbstractTimeGraphView) IViewPart(org.eclipse.ui.IViewPart) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) TmfCommonXAxisChartViewer(org.eclipse.tracecompass.tmf.ui.viewers.xychart.linechart.TmfCommonXAxisChartViewer) CpuUsageView(org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.cpuusage.CpuUsageView) TmfWindowRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal) Test(org.junit.Test) XYDataProviderBaseTest(org.eclipse.tracecompass.tmf.ui.swtbot.tests.views.xychart.XYDataProviderBaseTest)

Aggregations

ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)352 Test (org.junit.Test)120 NonNull (org.eclipse.jdt.annotation.NonNull)47 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)45 TmfExperiment (org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment)33 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)27 ITmfContext (org.eclipse.tracecompass.tmf.core.trace.ITmfContext)27 Nullable (org.eclipse.jdt.annotation.Nullable)25 TmfSignalHandler (org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)25 IAnalysisModule (org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule)23 TmfTraceOpenedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal)22 TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)22 File (java.io.File)21 BeforeClass (org.junit.BeforeClass)21 ArrayList (java.util.ArrayList)20 ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)19 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)17 TmfAnalysisException (org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException)15 TmfTraceSelectedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal)15 TmfTrace (org.eclipse.tracecompass.tmf.core.trace.TmfTrace)15