use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.
the class CtfExperimentCheckpointIndexTest method verifyIndexContent.
private static void verifyIndexContent() {
assertEquals("getTraceSize", NB_EVENTS, fExperiment.getNbEvents());
assertEquals("getRange-start", START_TIME, fExperiment.getTimeRange().getStartTime().getValue());
assertEquals("getRange-end", END_TIME, fExperiment.getTimeRange().getEndTime().getValue());
assertEquals("getStartTime", START_TIME, fExperiment.getStartTime().getValue());
assertEquals("getEndTime", END_TIME, fExperiment.getEndTime().getValue());
ITmfCheckpointIndex checkpoints = fIndexer.getCheckpoints();
assertTrue(checkpoints != null);
assertEquals(NB_EVENTS, checkpoints.getNbEvents());
assertEquals(NB_CHECKPOINTS, checkpoints.size());
// Validate that each checkpoint points to the right event
for (int i = 0; i < checkpoints.size(); i++) {
ITmfCheckpoint checkpoint = checkpoints.get(i);
TmfContext context = new TmfContext(checkpoint.getLocation(), i * BLOCK_SIZE);
ITmfEvent event = fExperiment.parseEvent(context);
assertEquals(context.getRank(), i * BLOCK_SIZE);
assertEquals(0, (checkpoint.getTimestamp().compareTo(event.getTimestamp())));
}
ITmfContext context = fExperiment.seekEvent(0);
ITmfEvent event = fExperiment.getNext(context);
assertEquals(START_TIME, event.getTimestamp().getValue());
context = fExperiment.seekEvent(NB_EVENTS - 1);
event = fExperiment.getNext(context);
assertEquals(END_TIME, event.getTimestamp().getValue());
}
use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.
the class JsonTraceTest method testJsonTrace.
private static void testJsonTrace(String path, long expectedNbEvents, ITmfTimestamp startTime, ITmfTimestamp endTime) throws TmfTraceException {
ITmfTrace trace = new JsonStubTrace();
try {
IStatus validate = trace.validate(null, path);
assertTrue(validate.getMessage(), validate.isOK());
trace.initTrace(null, path, ITmfEvent.class);
ITmfContext context = trace.seekEvent(0.0);
ITmfEvent event = trace.getNext(context);
long count = 0;
long prevTs = -1;
while (event != null) {
count++;
@NonNull ITmfTimestamp currentTime = event.getTimestamp();
assertNotNull(currentTime);
// Make sure that the event are ordered
assertTrue(currentTime.toNanos() >= prevTs);
prevTs = currentTime.toNanos();
event = trace.getNext(context);
}
assertEquals(expectedNbEvents, count);
assertEquals(expectedNbEvents, trace.getNbEvents());
assertEquals(startTime.toNanos(), trace.getStartTime().toNanos());
assertEquals(endTime.toNanos(), trace.getEndTime().toNanos());
} finally {
trace.dispose();
}
}
use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.
the class ImportAndReadPcapTest method getEvent.
private static ITmfEvent getEvent(int rank) {
PcapTrace trace = pttt.getTrace();
ITmfContext ctx = trace.seekEvent(0);
for (int i = 0; i < rank; i++) {
trace.getNext(ctx);
}
ITmfEvent ret = trace.getNext(ctx);
trace.dispose();
return ret;
}
use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.
the class TmfEventTest method testNonEqualTypes.
@Test
public void testNonEqualTypes() {
final ITmfEvent event1 = new TmfEvent(null, 0, fTimestamp1, fType, fContent1);
ITmfEvent event2 = new TmfEvent(null, 0, fTimestamp1, fType, fContent1);
assertTrue("equals", event1.equals(event2));
assertTrue("equals", event2.equals(event1));
final String typeId = "OtherTestType";
final String[] labels = new String[] { fLabel2, fLabel1 };
final TmfEventType newType = new TmfEventType(typeId, TmfEventField.makeRoot(labels));
event2 = new TmfEvent(null, 0, fTimestamp1, newType, fContent1);
assertFalse("equals", event1.equals(event2));
assertFalse("equals", event2.equals(event1));
event2 = new TmfEvent(null, 0, fTimestamp1, null, fContent1);
assertFalse("equals", event1.equals(event2));
assertFalse("equals", event2.equals(event1));
}
use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.
the class TmfEventTest method testNonEqualTimestamps.
@Test
public void testNonEqualTimestamps() {
final ITmfEvent event1 = new TmfEvent(null, 0, fTimestamp1, fType, fContent1);
ITmfEvent event2 = new TmfEvent(null, 0, fTimestamp1, fType, fContent1);
assertTrue("equals", event1.equals(event2));
assertTrue("equals", event2.equals(event1));
event2 = new TmfEvent(null, 0, fTimestamp2, fType, fContent1);
assertFalse("equals", event1.equals(event2));
assertFalse("equals", event2.equals(event1));
event2 = new TmfEvent(null, 0, null, fType, fContent1);
assertFalse("equals", event1.equals(event2));
assertFalse("equals", event2.equals(event1));
}
Aggregations