use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.
the class TmfTraceTest method testGetNextAfterSeekingOnRank_3.
@Test
public void testGetNextAfterSeekingOnRank_3() {
final long INITIAL_RANK = 500L;
final int NB_READS = 20;
// On lower bound, returns the first event (rank = 0)
final ITmfContext context = fTrace.seekEvent(INITIAL_RANK);
// Read NB_EVENTS
ITmfEvent event;
for (int i = 0; i < NB_READS; i++) {
event = fTrace.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 = fTrace.parseEvent(context);
assertEquals("Event timestamp", INITIAL_RANK + NB_READS + 1, event.getTimestamp().getValue());
assertEquals("Event rank", INITIAL_RANK + NB_READS, context.getRank());
}
use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.
the class TmfTraceTest method testGetNextAfteSeekingOnTS_2.
@Test
public void testGetNextAfteSeekingOnTS_2() {
final long INITIAL_TS = 2;
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 testSeekEventOnNullTimestamp.
// ------------------------------------------------------------------------
// seekEvent on timestamp (note: does not reliably set the rank)
// ------------------------------------------------------------------------
@Test
public void testSeekEventOnNullTimestamp() {
// Position trace at event rank 0
ITmfContext context = fTrace.seekEvent((ITmfTimestamp) null);
assertEquals("Event rank", 0, context.getRank());
ITmfEvent event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 0, context.getRank());
}
use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.
the class TmfTraceTest method testProcessEventRequestForNbEvents.
@Test
public void testProcessEventRequestForNbEvents() throws InterruptedException {
final int nbEvents = 1000;
final Vector<ITmfEvent> requestedEvents = new Vector<>();
final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class, range, 0, nbEvents, ExecutionType.FOREGROUND) {
@Override
public void handleData(final ITmfEvent event) {
super.handleData(event);
requestedEvents.add(event);
}
};
final ITmfEventProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
providers[0].sendRequest(request);
request.waitForCompletion();
assertEquals("nbEvents", nbEvents, requestedEvents.size());
assertTrue("isCompleted", request.isCompleted());
assertFalse("isCancelled", request.isCancelled());
// Don't go overboard: we are not validating the stub!
for (int i = 0; i < nbEvents; i++) {
assertEquals("Distinct events", i + 1, requestedEvents.get(i).getTimestamp().getValue());
}
}
use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.
the class TmfTraceTest method testSeekEventOnTimestampNotOnCacheBoundary.
@Test
public void testSeekEventOnTimestampNotOnCacheBoundary() {
// Position trace at event rank 1
ITmfContext context = fTrace.seekEvent(TmfTimestamp.create(2, SCALE));
assertEquals("Event rank", 1, context.getRank());
ITmfEvent event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
event = fTrace.getNext(context);
assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
assertEquals("Event rank", 2, context.getRank());
// Position trace at event rank 9
context = fTrace.seekEvent(TmfTimestamp.create(10, SCALE));
assertEquals("Event rank", 9, context.getRank());
event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", 9, context.getRank());
event = fTrace.getNext(context);
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", 10, context.getRank());
// Position trace at event rank 999
context = fTrace.seekEvent(TmfTimestamp.create(1000, SCALE));
assertEquals("Event rank", 999, context.getRank());
event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", 999, context.getRank());
event = fTrace.getNext(context);
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", 1000, context.getRank());
// Position trace at event rank 1001
context = fTrace.seekEvent(TmfTimestamp.create(1002, SCALE));
assertEquals("Event rank", 1001, context.getRank());
event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1001, context.getRank());
event = fTrace.getNext(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1002, context.getRank());
// Position trace at event rank 4500
context = fTrace.seekEvent(TmfTimestamp.create(4501, SCALE));
assertEquals("Event rank", 4500, context.getRank());
event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", 4500, context.getRank());
event = fTrace.getNext(context);
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", 4501, context.getRank());
}
Aggregations