Search in sources :

Example 31 with ITmfEvent

use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.

the class TmfMultiTraceExperimentTest 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) Test(org.junit.Test)

Example 32 with ITmfEvent

use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.

the class TmfMultiTraceExperimentTest method testSeekTimestampOutOfScope.

@Test
public void testSeekTimestampOutOfScope() {
    // Position trace at beginning
    ITmfContext context = fExperiment.seekEvent(TmfTimestamp.create(-1, SCALE));
    assertEquals("Event rank", 0, context.getRank());
    ITmfEvent event = fExperiment.getNext(context);
    assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
    assertEquals("Event rank", 1, context.getRank());
    // Position trace at event passed the end
    context = fExperiment.seekEvent(TmfTimestamp.create(NB_EVENTS + 1, SCALE));
    event = fExperiment.getNext(context);
    assertNull("Event location", event);
    assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
}
Also used : ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) Test(org.junit.Test)

Example 33 with ITmfEvent

use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.

the class TmfTraceTest method testSeekOnRankOnCacheBoundary.

@Test
public void testSeekOnRankOnCacheBoundary() {
    // On lower bound, returns the first event (ts = 1)
    ITmfContext context = fTrace.seekEvent(0);
    assertEquals("Event rank", 0, context.getRank());
    ITmfEvent event = fTrace.parseEvent(context);
    assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
    assertEquals("Event rank", 0, context.getRank());
    event = fTrace.getNext(context);
    assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
    assertEquals("Event rank", 1, context.getRank());
    // Position trace at event rank 1000
    context = fTrace.seekEvent(1000);
    assertEquals("Event rank", 1000, context.getRank());
    event = fTrace.parseEvent(context);
    assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
    assertEquals("Event rank", 1000, context.getRank());
    event = fTrace.getNext(context);
    assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
    assertEquals("Event rank", 1001, context.getRank());
    // Position trace at event rank 4000
    context = fTrace.seekEvent(4000);
    assertEquals("Event rank", 4000, context.getRank());
    event = fTrace.parseEvent(context);
    assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
    assertEquals("Event rank", 4000, context.getRank());
    event = fTrace.getNext(context);
    assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
    assertEquals("Event rank", 4001, context.getRank());
}
Also used : ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) Test(org.junit.Test)

Example 34 with ITmfEvent

use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.

the class TmfTraceTest method testGetNextAfteSeekingOnTS_3.

@Test
public void testGetNextAfteSeekingOnTS_3() {
    final long INITIAL_TS = 500;
    final int NB_READS = 20;
    // On lower bound, returns the first event (ts = 500)
    final ITmfContext context = fTrace.seekEvent(TmfTimestamp.create(INITIAL_TS, SCALE));
    // Read NB_EVENTS
    ITmfEvent event;
    for (int i = 0; i < NB_READS; i++) {
        event = fTrace.getNext(context);
        assertEquals("Event timestamp", INITIAL_TS + i, event.getTimestamp().getValue());
        assertEquals("Event rank", INITIAL_TS + i, context.getRank());
    }
    // Make sure we stay positioned
    event = fTrace.parseEvent(context);
    assertEquals("Event timestamp", INITIAL_TS + NB_READS, event.getTimestamp().getValue());
    assertEquals("Event rank", INITIAL_TS + NB_READS - 1, context.getRank());
}
Also used : ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) Test(org.junit.Test)

Example 35 with ITmfEvent

use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.

the class TmfTraceTest method testSeekEventOnCacheBoundary.

// ------------------------------------------------------------------------
// seekEvent on location (note: does not reliably set the rank)
// ------------------------------------------------------------------------
@Test
public void testSeekEventOnCacheBoundary() {
    // Position trace at event rank 0
    ITmfContext context = fTrace.seekEvent(0);
    ITmfEvent event = fTrace.parseEvent(context);
    assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
    assertEquals("Event rank", 0, context.getRank());
    context = fTrace.seekEvent(context.getLocation());
    assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
    event = fTrace.parseEvent(context);
    assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
    assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
    event = fTrace.getNext(context);
    assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
    assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
    // Position trace at event rank 1000
    ITmfContext tmpContext = fTrace.seekEvent(TmfTimestamp.create(1001, SCALE));
    context = fTrace.seekEvent(tmpContext.getLocation());
    assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
    event = fTrace.parseEvent(context);
    assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
    assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
    event = fTrace.getNext(context);
    assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
    assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
    // Position trace at event rank 4000
    tmpContext = fTrace.seekEvent(TmfTimestamp.create(4001, SCALE));
    context = fTrace.seekEvent(tmpContext.getLocation());
    assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
    event = fTrace.parseEvent(context);
    assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
    assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
    event = fTrace.getNext(context);
    assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
    assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
}
Also used : ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) Test(org.junit.Test)

Aggregations

ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)182 Test (org.junit.Test)127 ITmfContext (org.eclipse.tracecompass.tmf.core.trace.ITmfContext)112 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)40 TmfEventRequest (org.eclipse.tracecompass.tmf.core.request.TmfEventRequest)30 AnalysisManagerTest (org.eclipse.tracecompass.tmf.core.tests.analysis.AnalysisManagerTest)27 ITmfLocation (org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation)25 TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)24 NonNull (org.eclipse.jdt.annotation.NonNull)20 TmfEvent (org.eclipse.tracecompass.tmf.core.event.TmfEvent)17 ITmfEventRequest (org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest)16 Vector (java.util.Vector)15 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)15 Predicate (java.util.function.Predicate)14 TmfTraceUtils (org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils)14 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)13 CtfTestTrace (org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace)13 CtfTmfTestTraceUtils (org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils)13 Assert.assertEquals (org.junit.Assert.assertEquals)13 Assert.assertNotNull (org.junit.Assert.assertNotNull)13