use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.
the class TmfExperimentTest 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 = 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);
}
use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.
the class TmfExperimentTest method testGetNextAfterSeekingOnLocation_3.
@Test
public void testGetNextAfterSeekingOnLocation_3() {
final ITmfLocation INITIAL_LOC = fExperiment.seekEvent(500L).getLocation();
final long INITIAL_TS = 501;
final int NB_READS = 20;
// On lower bound, returns the first event (ts = 501)
final ITmfContext context = fExperiment.seekEvent(INITIAL_LOC);
validateContextRanks(context);
// Read NB_EVENTS
ITmfEvent event;
for (int i = 0; i < NB_READS; i++) {
event = fExperiment.getNext(context);
assertEquals("Event timestamp", INITIAL_TS + i, event.getTimestamp().getValue());
}
// Make sure we stay positioned
event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", INITIAL_TS + NB_READS, event.getTimestamp().getValue());
validateContextRanks(context);
}
use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.
the class TmfMultiTraceExperimentTest method testSeekLocationOutOfScope.
@Test
public void testSeekLocationOutOfScope() {
// Position trace at beginning
ITmfContext context = fExperiment.seekEvent((ITmfLocation) null);
ITmfEvent event = fExperiment.getNext(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
}
use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.
the class TmfMultiTraceExperimentTest method testGetNextAfteSeekingOnTS_1.
@Test
public void testGetNextAfteSeekingOnTS_1() {
final long INITIAL_TS = 1;
final int NB_READS = 20;
// On lower bound, returns the first event (ts = 1)
final ITmfContext context = fExperiment.seekEvent(TmfTimestamp.create(INITIAL_TS, SCALE));
validateContextRanks(context);
// Read NB_EVENTS
ITmfEvent event;
for (int i = 0; i < NB_READS; i++) {
event = fExperiment.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 = fExperiment.parseEvent(context);
assertEquals("Event timestamp", INITIAL_TS + NB_READS, event.getTimestamp().getValue());
assertEquals("Event rank", INITIAL_TS + NB_READS - 1, context.getRank());
validateContextRanks(context);
}
use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.
the class TmfMultiTraceExperimentTest method testCancel.
// ------------------------------------------------------------------------
// cancel
// ------------------------------------------------------------------------
@Test
public void testCancel() throws InterruptedException {
final int nbEvents = NB_EVENTS;
final int limit = BLOCK_SIZE;
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) {
int nbRead = 0;
@Override
public void handleData(final ITmfEvent event) {
super.handleData(event);
requestedEvents.add(event);
if (++nbRead == limit) {
cancel();
}
}
};
fExperiment.sendRequest(request);
request.waitForCompletion();
assertEquals("nbEvents", limit, requestedEvents.size());
assertTrue("isCompleted", request.isCompleted());
assertTrue("isCancelled", request.isCancelled());
}
Aggregations