Search in sources :

Example 6 with TmfExperiment

use of org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment 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 7 with TmfExperiment

use of org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment 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)

Example 8 with TmfExperiment

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

the class SymbolProviderManagerTest method testGetterForExperiment.

/**
 * Test the {@link SymbolProviderManager#getSymbolProviders(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)} for an experiment
 */
@Test
public void testGetterForExperiment() {
    ITmfTrace trace = null;
    TmfExperiment experiment = null;
    try {
        trace = TmfTestTrace.A_TEST_10K.getTrace();
        ITmfTrace[] traces = new ITmfTrace[] { trace };
        experiment = new TmfExperiment(ITmfEvent.class, "test-exp", traces, TmfExperiment.DEFAULT_INDEX_PAGE_SIZE, null);
        // Get the symbol providers for the trace
        Collection<ISymbolProvider> traceSymbolProviders = SymbolProviderManager.getInstance().getSymbolProviders(trace);
        assertTrue(!traceSymbolProviders.isEmpty());
        // Get the symbol providers for the experiment
        Collection<ISymbolProvider> expSymbolProviders = SymbolProviderManager.getInstance().getSymbolProviders(experiment);
        assertTrue(!expSymbolProviders.isEmpty());
        // Assert that the trace of the symbol provider is the same
        for (ISymbolProvider sp : expSymbolProviders) {
            assertTrue(sp.getTrace() == trace);
        }
        for (ISymbolProvider symbolProvider : traceSymbolProviders) {
            assertTrue(expSymbolProviders.contains(symbolProvider));
        }
    } finally {
        if (trace != null) {
            trace.dispose();
        }
        if (experiment != null) {
            experiment.dispose();
        }
    }
}
Also used : 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) ISymbolProvider(org.eclipse.tracecompass.tmf.core.symbols.ISymbolProvider) Test(org.junit.Test)

Example 9 with TmfExperiment

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

the class TmfExperimentTest method testSimpleTmfExperimentConstructor.

// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
@Test
public void testSimpleTmfExperimentConstructor() {
    TmfExperiment experiment = new TmfExperiment(ITmfEvent.class, EXPERIMENT, fTestTraces, TmfExperiment.DEFAULT_INDEX_PAGE_SIZE, null);
    assertEquals("GetId", EXPERIMENT, experiment.getName());
    assertEquals("GetCacheSize", TmfExperiment.DEFAULT_INDEX_PAGE_SIZE, experiment.getCacheSize());
    experiment.dispose();
    experiment = new TmfExperiment(ITmfEvent.class, EXPERIMENT, null, TmfExperiment.DEFAULT_INDEX_PAGE_SIZE, null);
    experiment.dispose();
}
Also used : TmfExperiment(org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) AnalysisManagerTest(org.eclipse.tracecompass.tmf.core.tests.analysis.AnalysisManagerTest) Test(org.junit.Test)

Example 10 with TmfExperiment

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

the class TmfExperimentTest method testWithSingleHostClockOffset.

/**
 * Tests that experiment with traces from the same host and a clock offset
 * are well synchronized
 */
@Test
public void testWithSingleHostClockOffset() {
    // Data for this specific test
    String hostId = "Test Host 1";
    long minOffset = 2000;
    long offset = 1000;
    String clockOffset = "clock_offset";
    ITmfTrace t1 = new TestTrace("t1") {

        @Override
        @NonNull
        public String getHostId() {
            return hostId;
        }

        @Override
        @NonNull
        public Map<@NonNull String, @NonNull String> getProperties() {
            return ImmutableMap.of(clockOffset, String.valueOf(minOffset));
        }
    };
    ITmfTrace t2 = new TestTrace("t2") {

        @Override
        @NonNull
        public String getHostId() {
            return hostId;
        }

        @Override
        @NonNull
        public Map<@NonNull String, @NonNull String> getProperties() {
            return ImmutableMap.of(clockOffset, String.valueOf(minOffset + offset));
        }
    };
    TmfExperiment exp = new TmfExperimentStub(EXPERIMENT, new ITmfTrace[] { t1, t2 }, BLOCK_SIZE);
    try {
        assertEquals(TimestampTransformFactory.createWithOffset(offset / 2), t1.getTimestampTransform());
        assertEquals(TimestampTransformFactory.createWithOffset(-offset / 2), t2.getTimestampTransform());
    } finally {
        exp.dispose();
    }
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfExperiment(org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment) TmfExperimentStub(org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfExperimentStub) TmfTestTrace(org.eclipse.tracecompass.tmf.core.tests.shared.TmfTestTrace) AnalysisManagerTest(org.eclipse.tracecompass.tmf.core.tests.analysis.AnalysisManagerTest) Test(org.junit.Test)

Aggregations

TmfExperiment (org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment)55 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)33 Test (org.junit.Test)31 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)11 TmfTraceOpenedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal)9 TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)8 IAnalysisModule (org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule)7 AnalysisManagerTest (org.eclipse.tracecompass.tmf.core.tests.analysis.AnalysisManagerTest)7 CtfTmfTrace (org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace)7 Nullable (org.eclipse.jdt.annotation.Nullable)5 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)4 NonNull (org.eclipse.jdt.annotation.NonNull)3 KernelAnalysisModule (org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule)3 TmfTraceClosedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal)3 TmfTraceSelectedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal)3 ITmfTimestampTransform (org.eclipse.tracecompass.tmf.core.synchronization.ITmfTimestampTransform)3 SynchronizationAlgorithm (org.eclipse.tracecompass.tmf.core.synchronization.SynchronizationAlgorithm)3 ITmfTimestamp (org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp)3 CtfTmfEvent (org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent)3 Before (org.junit.Before)3