Search in sources :

Example 1 with TmfTrace

use of org.eclipse.tracecompass.tmf.core.trace.TmfTrace in project tracecompass by tracecompass.

the class ContextSwitchProviderTest method setUp.

/**
 * Setup the trace for the tests
 */
@Before
public void setUp() {
    ITmfTrace trace = new TmfXmlKernelTraceStub();
    IPath filePath = Activator.getAbsoluteFilePath(CPU_USAGE_FILE);
    IStatus status = trace.validate(null, filePath.toOSString());
    if (!status.isOK()) {
        fail(status.getException().getMessage());
    }
    try {
        trace.initTrace(null, filePath.toOSString(), TmfEvent.class);
    } catch (TmfTraceException e) {
        fail(e.getMessage());
    }
    deleteSuppFiles(trace);
    ((TmfTrace) trace).traceOpened(new TmfTraceOpenedSignal(this, trace, null));
    fModule = TmfTraceUtils.getAnalysisModuleOfClass(trace, KernelContextSwitchAnalysis.class, KernelContextSwitchAnalysis.ID);
    assertNotNull(fModule);
    fTrace = trace;
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) IStatus(org.eclipse.core.runtime.IStatus) TmfXmlKernelTraceStub(org.eclipse.tracecompass.analysis.os.linux.core.tests.stubs.trace.TmfXmlKernelTraceStub) IPath(org.eclipse.core.runtime.IPath) TmfTrace(org.eclipse.tracecompass.tmf.core.trace.TmfTrace) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfTraceException(org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException) TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal) KernelContextSwitchAnalysis(org.eclipse.tracecompass.analysis.os.linux.core.contextswitch.KernelContextSwitchAnalysis) Before(org.junit.Before)

Example 2 with TmfTrace

use of org.eclipse.tracecompass.tmf.core.trace.TmfTrace in project tracecompass by tracecompass.

the class CpuUsageDataProviderTest method setUp.

/**
 * Setup the trace for the tests
 */
@Before
public void setUp() {
    IKernelTrace trace = new TmfXmlKernelTraceStub();
    IPath filePath = Activator.getAbsoluteFilePath(CPU_USAGE_FILE);
    IStatus status = trace.validate(null, filePath.toOSString());
    if (!status.isOK()) {
        fail(status.getException().getMessage());
    }
    try {
        trace.initTrace(null, filePath.toOSString(), TmfEvent.class);
    } catch (TmfTraceException e) {
        fail(e.getMessage());
    }
    deleteSuppFiles(trace);
    ((TmfTrace) trace).traceOpened(new TmfTraceOpenedSignal(this, trace, null));
    /*
         * FIXME: Make sure this analysis is finished before running the CPU analysis.
         * This block can be removed once analysis dependency and request precedence is
         * implemented
         */
    IAnalysisModule module = null;
    for (IAnalysisModule mod : TmfTraceUtils.getAnalysisModulesOfClass(trace, TidAnalysisModule.class)) {
        module = mod;
    }
    assertNotNull(module);
    module.schedule();
    module.waitForCompletion();
    /* End of the FIXME block */
    module = TmfTraceUtils.getAnalysisModuleOfClass(trace, KernelCpuUsageAnalysis.class, KernelCpuUsageAnalysis.ID);
    assertNotNull(module);
    module.schedule();
    module.waitForCompletion();
    fDataProvider = CpuUsageDataProvider.create(trace);
    assertNotNull(fDataProvider);
    fTrace = trace;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) TmfXmlKernelTraceStub(org.eclipse.tracecompass.analysis.os.linux.core.tests.stubs.trace.TmfXmlKernelTraceStub) IPath(org.eclipse.core.runtime.IPath) TmfTrace(org.eclipse.tracecompass.tmf.core.trace.TmfTrace) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfTraceException(org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) KernelCpuUsageAnalysis(org.eclipse.tracecompass.analysis.os.linux.core.cpuusage.KernelCpuUsageAnalysis) TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal) IKernelTrace(org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelTrace) Before(org.junit.Before)

Example 3 with TmfTrace

use of org.eclipse.tracecompass.tmf.core.trace.TmfTrace in project tracecompass by tracecompass.

the class AbstractTestInputOutput method setUp.

/**
 * Setup the trace for the tests and return the InputOutputAnalysisModule,
 * not executed.
 *
 * @param fileName
 *            The file name of the trace to open
 * @return The input output analysis module
 */
@NonNull
protected InputOutputAnalysisModule setUp(String fileName) {
    TmfXmlKernelTraceStub trace = new TmfXmlKernelTraceStub();
    trace.addEventAspect(KernelTidAspect.INSTANCE);
    trace.setKernelEventLayout(EVENT_LAYOUT);
    IPath filePath = Activator.getAbsoluteFilePath(IO_FILE_PATH + fileName);
    IStatus status = trace.validate(null, filePath.toOSString());
    if (!status.isOK()) {
        fail(status.getException().getMessage());
    }
    try {
        trace.initTrace(null, filePath.toOSString(), TmfEvent.class);
    } catch (TmfTraceException e) {
        fail(e.getMessage());
    }
    deleteSuppFiles(trace);
    ((TmfTrace) trace).traceOpened(new TmfTraceOpenedSignal(this, trace, null));
    fTrace = trace;
    /* Start the kernel analysis module */
    KernelAnalysisModule kernelMod = TmfTraceUtils.getAnalysisModuleOfClass(trace, KernelAnalysisModule.class, KernelAnalysisModule.ID);
    assertNotNull(kernelMod);
    kernelMod.schedule();
    kernelMod.waitForCompletion();
    InputOutputAnalysisModule module = TmfTraceUtils.getAnalysisModuleOfClass(trace, InputOutputAnalysisModule.class, InputOutputAnalysisModule.ID);
    assertNotNull(module);
    return module;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) TmfXmlKernelTraceStub(org.eclipse.tracecompass.analysis.os.linux.core.tests.stubs.trace.TmfXmlKernelTraceStub) IPath(org.eclipse.core.runtime.IPath) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfTrace(org.eclipse.tracecompass.tmf.core.trace.TmfTrace) TmfTraceException(org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException) TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal) InputOutputAnalysisModule(org.eclipse.tracecompass.internal.analysis.os.linux.core.inputoutput.InputOutputAnalysisModule) KernelAnalysisModule(org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule) NonNull(org.eclipse.jdt.annotation.NonNull)

Example 4 with TmfTrace

use of org.eclipse.tracecompass.tmf.core.trace.TmfTrace in project tracecompass by tracecompass.

the class XmlDataProviderManagerTest method testOneTrace.

/**
 * Test getting the XML data provider for one trace, with an analysis that
 * applies to a trace
 */
@Test
public void testOneTrace() {
    ITmfTrace trace = null;
    try {
        // Initialize the trace and module
        trace = XmlUtilsTest.initializeTrace(TEST_TRACE);
        TmfTraceOpenedSignal signal = new TmfTraceOpenedSignal(this, trace, null);
        ((TmfTrace) trace).traceOpened(signal);
        // The data provider manager uses opened traces from the manager
        TmfTraceManager.getInstance().traceOpened(signal);
        // Get the view element from the file
        Element viewElement = TmfXmlUtils.getElementInFile(TmfXmlTestFiles.STATE_VALUE_FILE.getPath().toOSString(), TmfXmlStrings.TIME_GRAPH_VIEW, TRACE_VIEW_ID);
        assertNotNull(viewElement);
        ITimeGraphDataProvider<@NonNull TimeGraphEntryModel> timeGraphProvider = XmlDataProviderManager.getInstance().getTimeGraphProvider(trace, viewElement);
        assertNotNull(timeGraphProvider);
    } finally {
        if (trace != null) {
            trace.dispose();
            TmfTraceManager.getInstance().traceClosed(new TmfTraceClosedSignal(this, trace));
        }
    }
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfTrace(org.eclipse.tracecompass.tmf.core.trace.TmfTrace) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) Element(org.w3c.dom.Element) TimeGraphEntryModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel) TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal) TmfTraceClosedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal) Test(org.junit.Test)

Example 5 with TmfTrace

use of org.eclipse.tracecompass.tmf.core.trace.TmfTrace in project tracecompass by tracecompass.

the class XmlDataProviderManagerTest method testExperimentWithTraceAnalysis.

/**
 * Test getting the XML data provider for an experiment, with an analysis that
 * applies to a trace
 */
@Test
public void testExperimentWithTraceAnalysis() {
    ITmfTrace trace = null;
    ITmfTrace trace2 = null;
    ITmfTrace experiment = null;
    try {
        // Initialize the trace and module
        trace = XmlUtilsTest.initializeTrace(TEST_TRACE);
        trace2 = XmlUtilsTest.initializeTrace(TEST_TRACE2);
        ITmfTrace[] traces = { trace, trace2 };
        experiment = new TmfExperiment(ITmfEvent.class, "Xml Experiment", traces, TmfExperiment.DEFAULT_INDEX_PAGE_SIZE, null);
        TmfTraceOpenedSignal signal = new TmfTraceOpenedSignal(this, experiment, null);
        ((TmfTrace) trace).traceOpened(signal);
        ((TmfTrace) trace2).traceOpened(signal);
        ((TmfTrace) experiment).traceOpened(signal);
        // The data provider manager uses opened traces from the manager
        TmfTraceManager.getInstance().traceOpened(signal);
        Iterable<@NonNull DataDrivenAnalysisModule> modules = TmfTraceUtils.getAnalysisModulesOfClass(experiment, DataDrivenAnalysisModule.class);
        modules.forEach(module -> {
            module.schedule();
            assertTrue(module.waitForCompletion());
        });
        // Get the view element from the file
        Element viewElement = TmfXmlUtils.getElementInFile(TmfXmlTestFiles.STATE_VALUE_FILE.getPath().toOSString(), TmfXmlStrings.TIME_GRAPH_VIEW, TRACE_VIEW_ID);
        assertNotNull(viewElement);
        ITimeGraphDataProvider<@NonNull TimeGraphEntryModel> timeGraphProvider = XmlDataProviderManager.getInstance().getTimeGraphProvider(experiment, viewElement);
        assertNotNull(timeGraphProvider);
        assertTrue(timeGraphProvider instanceof TmfTimeGraphCompositeDataProvider);
    } finally {
        if (trace != null) {
            trace.dispose();
        }
        if (trace2 != null) {
            trace2.dispose();
        }
        if (experiment != null) {
            experiment.dispose();
            TmfTraceManager.getInstance().traceClosed(new TmfTraceClosedSignal(this, experiment));
        }
    }
}
Also used : Element(org.w3c.dom.Element) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) TmfTraceClosedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfTimeGraphCompositeDataProvider(org.eclipse.tracecompass.internal.tmf.core.model.timegraph.TmfTimeGraphCompositeDataProvider) TmfTrace(org.eclipse.tracecompass.tmf.core.trace.TmfTrace) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfExperiment(org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment) TimeGraphEntryModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel) TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal) DataDrivenAnalysisModule(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.module.DataDrivenAnalysisModule) Test(org.junit.Test)

Aggregations

TmfTrace (org.eclipse.tracecompass.tmf.core.trace.TmfTrace)26 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)22 TmfTraceOpenedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal)18 Test (org.junit.Test)16 IAnalysisModule (org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule)7 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)7 Before (org.junit.Before)7 AnalysisManagerTest (org.eclipse.tracecompass.tmf.core.tests.analysis.AnalysisManagerTest)6 IPath (org.eclipse.core.runtime.IPath)5 IStatus (org.eclipse.core.runtime.IStatus)5 TmfXmlKernelTraceStub (org.eclipse.tracecompass.analysis.os.linux.core.tests.stubs.trace.TmfXmlKernelTraceStub)5 TmfTraceException (org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException)5 TimeGraphEntryModel (org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel)4 TmfTraceClosedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal)4 Element (org.w3c.dom.Element)4 NonNull (org.eclipse.jdt.annotation.NonNull)3 ITmfContext (org.eclipse.tracecompass.tmf.core.trace.ITmfContext)3 KernelCpuUsageAnalysis (org.eclipse.tracecompass.analysis.os.linux.core.cpuusage.KernelCpuUsageAnalysis)2 KernelAnalysisModule (org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule)2 IKernelTrace (org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelTrace)2