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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations