Search in sources :

Example 1 with ITmfContext

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

the class CtfTmfLostEventsTest method testLostEventWithTransform.

/**
 * Test getting a lost event from a trace that has a timestamp transform.
 */
@Test
public void testLostEventWithTransform() {
    CtfTmfTrace trace = CtfTmfTestTraceUtils.getTrace(testTrace);
    long offset = 1234567890L;
    trace.setTimestampTransform(TimestampTransformFactory.createWithOffset(offset));
    trace.indexTrace(true);
    final long rank = 190;
    final ITmfTimestamp start = TmfTimestamp.fromNanos(1376592664828900165L + offset);
    final ITmfTimestamp end = TmfTimestamp.fromNanos(1376592664828900165L + 502911L + offset);
    final long nbLost = 859;
    ITmfContext context = trace.seekEvent(rank);
    final CtfTmfEvent ev = trace.getNext(context);
    context.dispose();
    assertTrue(ev instanceof ITmfLostEvent);
    ITmfLostEvent event = (ITmfLostEvent) ev;
    assertEquals(start, event.getTimestamp());
    assertEquals(start, event.getTimeRange().getStartTime());
    assertEquals(end, event.getTimeRange().getEndTime());
    assertEquals(nbLost, event.getNbLostEvents());
    trace.setTimestampTransform(null);
    trace.dispose();
}
Also used : ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) CtfTmfEvent(org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) ITmfLostEvent(org.eclipse.tracecompass.tmf.core.event.ITmfLostEvent) CtfTmfTrace(org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace) Test(org.junit.Test)

Example 2 with ITmfContext

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

the class UstKernelSyncTest method testWholeUstTrace.

/**
 * Test going through the whole UST trace, making sure the VTID context of
 * each event corresponds to the TID given by the kernel analysis at the
 * same timestamp.
 */
@Test
public void testWholeUstTrace() {
    TmfExperiment experiment = fExperiment;
    ITmfTrace ustTrace = fUstTrace;
    KernelAnalysisModule module = fKernelModule;
    assertNotNull(experiment);
    assertNotNull(ustTrace);
    assertNotNull(module);
    ITmfContext context = ustTrace.seekEvent(0L);
    CtfTmfEvent ustEvent = (CtfTmfEvent) ustTrace.getNext(context);
    int count = 0;
    while (ustEvent != null) {
        Long ustVtid = ustEvent.getContent().getFieldValue(Long.class, "context._vtid");
        /* All events in the trace should have that context */
        assertNotNull(ustVtid);
        long ts = ustEvent.getTimestamp().toNanos();
        long cpu = ustEvent.getCPU();
        Integer kernelTid = KernelThreadInformationProvider.getThreadOnCpu(module, cpu, ts);
        assertNotNull(kernelTid);
        assertEquals("Wrong TID for trace event " + ustEvent.toString(), ustVtid.longValue(), kernelTid.longValue());
        ustEvent = (CtfTmfEvent) ustTrace.getNext(context);
        count++;
    }
    /* Make sure we've read all expected events */
    assertEquals(UST_TRACE.getNbEvents(), count);
}
Also used : ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) 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) KernelAnalysisModule(org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule) Test(org.junit.Test)

Example 3 with ITmfContext

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

the class TmfExperimentTest method testGetNextAfterSeekingOnRank_1.

@Test
public void testGetNextAfterSeekingOnRank_1() {
    final long INITIAL_RANK = 0L;
    final int NB_READS = 20;
    // On lower bound, returns the first event (rank = 0)
    final ITmfContext context = fExperiment.seekEvent(INITIAL_RANK);
    validateContextRanks(context);
    // Read NB_EVENTS
    ITmfEvent event;
    for (int i = 0; i < NB_READS; i++) {
        event = fExperiment.getNext(context);
        assertEquals("Event timestamp", INITIAL_RANK + i + 1, event.getTimestamp().getValue());
        assertEquals("Event rank", INITIAL_RANK + i + 1, context.getRank());
    }
    // Make sure we stay positioned
    event = fExperiment.parseEvent(context);
    assertEquals("Event timestamp", INITIAL_RANK + NB_READS + 1, event.getTimestamp().getValue());
    assertEquals("Event rank", INITIAL_RANK + NB_READS, context.getRank());
    validateContextRanks(context);
}
Also used : ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) AnalysisManagerTest(org.eclipse.tracecompass.tmf.core.tests.analysis.AnalysisManagerTest) Test(org.junit.Test)

Example 4 with ITmfContext

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

the class TmfExperimentTest method testSeekRankNotOnCacheBoundary.

@Test
public void testSeekRankNotOnCacheBoundary() {
    long cacheSize = fExperiment.getCacheSize();
    // Position trace at event rank 9
    ITmfContext context = fExperiment.seekEvent(9);
    assertEquals("Context rank", 9, context.getRank());
    ITmfEvent event = fExperiment.getNext(context);
    assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
    assertEquals("Context rank", 10, context.getRank());
    // Position trace at event rank [cacheSize - 1]
    context = fExperiment.seekEvent(cacheSize - 1);
    assertEquals("Context rank", cacheSize - 1, context.getRank());
    event = fExperiment.getNext(context);
    assertEquals("Event timestamp", cacheSize, event.getTimestamp().getValue());
    assertEquals("Context rank", cacheSize, context.getRank());
    // Position trace at event rank [cacheSize + 1]
    context = fExperiment.seekEvent(cacheSize + 1);
    assertEquals("Context rank", cacheSize + 1, context.getRank());
    event = fExperiment.getNext(context);
    assertEquals("Event timestamp", cacheSize + 2, event.getTimestamp().getValue());
    assertEquals("Context rank", cacheSize + 2, context.getRank());
    // Position trace at event rank 4500
    context = fExperiment.seekEvent(4500);
    assertEquals("Context rank", 4500, context.getRank());
    event = fExperiment.getNext(context);
    assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
    assertEquals("Context rank", 4501, context.getRank());
}
Also used : ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) AnalysisManagerTest(org.eclipse.tracecompass.tmf.core.tests.analysis.AnalysisManagerTest) Test(org.junit.Test)

Example 5 with ITmfContext

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

the class TmfExperimentTest method testGetNextLocation.

@Test
public void testGetNextLocation() {
    ITmfContext context1 = fExperiment.seekEvent(0);
    fExperiment.getNext(context1);
    ITmfLocation location = context1.getLocation();
    ITmfEvent event1 = fExperiment.getNext(context1);
    ITmfContext context2 = fExperiment.seekEvent(location);
    ITmfEvent event2 = fExperiment.getNext(context2);
    assertEquals("Event timestamp", event1.getTimestamp().getValue(), event2.getTimestamp().getValue());
}
Also used : ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) ITmfLocation(org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation) AnalysisManagerTest(org.eclipse.tracecompass.tmf.core.tests.analysis.AnalysisManagerTest) Test(org.junit.Test)

Aggregations

ITmfContext (org.eclipse.tracecompass.tmf.core.trace.ITmfContext)145 Test (org.junit.Test)109 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)103 AnalysisManagerTest (org.eclipse.tracecompass.tmf.core.tests.analysis.AnalysisManagerTest)27 ITmfLocation (org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation)26 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)20 ITmfTimestamp (org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp)10 TmfContext (org.eclipse.tracecompass.tmf.core.trace.TmfContext)10 TmfLongLocation (org.eclipse.tracecompass.tmf.core.trace.location.TmfLongLocation)8 CtfTmfEvent (org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent)8 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)7 NonNull (org.eclipse.jdt.annotation.NonNull)7 BeforeClass (org.junit.BeforeClass)7 IOException (java.io.IOException)6 Predicate (java.util.function.Predicate)6 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)6 CtfTestTrace (org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace)6 TmfTraceUtils (org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils)6 CtfTmfTestTraceUtils (org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils)6 AfterClass (org.junit.AfterClass)6