use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.
the class TmfTraceTest method testGetNextAfterSeekingOnLocation_3.
@Test
public void testGetNextAfterSeekingOnLocation_3() {
final ITmfLocation INITIAL_LOC = fTrace.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 = fTrace.seekEvent(INITIAL_LOC);
// 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());
}
// Make sure we stay positioned
event = fTrace.parseEvent(context);
assertEquals("Event timestamp", INITIAL_TS + NB_READS, event.getTimestamp().getValue());
}
use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.
the class TmfTraceTest method testSeekEventOnRankOutOfScope.
@Test
public void testSeekEventOnRankOutOfScope() {
// Position trace at beginning
ITmfContext context = fTrace.seekEvent(-1);
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 passed the end
context = fTrace.seekEvent(NB_EVENTS);
assertEquals("Event rank", NB_EVENTS, context.getRank());
event = fTrace.parseEvent(context);
assertNull("Event", event);
assertEquals("Event rank", NB_EVENTS, context.getRank());
event = fTrace.getNext(context);
assertNull("Event", event);
assertEquals("Event rank", NB_EVENTS, context.getRank());
}
use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.
the class TmfTraceUtilsTest method testResolveEventAspectsOfNameForEvent.
/**
* Test the
* {@link TmfTraceUtils#resolveAspectOfNameForEvent(ITmfTrace, String, ITmfEvent)}
* method.
*/
@Test
public void testResolveEventAspectsOfNameForEvent() {
TmfTrace trace = fTrace;
assertNotNull(trace);
ITmfContext context = trace.seekEvent(0L);
ITmfEvent event = trace.getNext(context);
assertNotNull(event);
/* Make sure the CPU aspect returns the expected value */
Object cpuObj = TmfTraceUtils.resolveAspectOfNameForEvent(trace, "cpu", event);
assertNotNull(cpuObj);
assertEquals(1, cpuObj);
}
use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.
the class TmfTraceUtilsTest method testAdditionalAspects.
/**
* Test the {@link TmfTraceUtils#registerEventAspect(ITmfEventAspect)} method
*/
@Test
public void testAdditionalAspects() {
TmfTrace trace = fTrace;
assertNotNull(trace);
ITmfContext context = trace.seekEvent(0L);
ITmfEvent event = trace.getNext(context);
assertNotNull(event);
// Make sure the aspect is not resolved
Object obj = TmfTraceUtils.resolveEventAspectOfClassForEvent(trace, TestEventAspect.class, event);
assertNull(obj);
obj = TmfTraceUtils.resolveAspectOfNameForEvent(trace, TestEventAspect.ASPECT_NAME, event);
assertNull(obj);
Integer val = TmfTraceUtils.resolveIntEventAspectOfClassForEvent(trace, TestEventAspect.class, event);
assertNull(val);
// Register the aspect
TmfTraceUtils.registerEventAspect(TEST_ASPECT);
// See that the aspect is resolved now
obj = TmfTraceUtils.resolveEventAspectOfClassForEvent(trace, TestEventAspect.class, event);
assertNotNull(obj);
assertEquals(TestEventAspect.RESOLVED_VALUE, obj);
// See if it is resolved by name as well
obj = TmfTraceUtils.resolveAspectOfNameForEvent(trace, TestEventAspect.ASPECT_NAME, event);
assertNotNull(obj);
assertEquals(TestEventAspect.RESOLVED_VALUE, obj);
// See if it is resolved by Integer type as well
val = TmfTraceUtils.resolveIntEventAspectOfClassForEvent(trace, TestEventAspect.class, event);
assertNotNull(val);
assertEquals(TestEventAspect.RESOLVED_VALUE, val);
}
use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.
the class TmfCheckpointIndexTest2 method testTmfTraceMultiTimestamps.
// ------------------------------------------------------------------------
// Verify checkpoints
// ------------------------------------------------------------------------
@Test
public void testTmfTraceMultiTimestamps() {
assertEquals("getCacheSize", BLOCK_SIZE, fTrace.getCacheSize());
assertEquals("getTraceSize", NB_EVENTS, fTrace.getNbEvents());
assertEquals("getRange-start", 1, fTrace.getTimeRange().getStartTime().getValue());
assertEquals("getRange-end", 102, fTrace.getTimeRange().getEndTime().getValue());
assertEquals("getStartTime", 1, fTrace.getStartTime().getValue());
assertEquals("getEndTime", 102, fTrace.getEndTime().getValue());
ITmfCheckpointIndex checkpoints = fTrace.getIndexer().getCheckpoints();
assertTrue("Checkpoints exist", checkpoints != null);
assertEquals("Checkpoints size", NB_EVENTS / BLOCK_SIZE + 1, checkpoints.size());
// Trace has 3 events with same timestamp (ts=101) at rank 99, 100, 101
// Verify that the event at rank=99 is returned when seeking to ts=101 (first event with this timestamp)
// and not the event at checkpoint boundary
ITmfTimestamp seekTs = TmfTimestamp.create(101, -3);
ITmfContext ctx = fTrace.seekEvent(seekTs);
ITmfEvent event = fTrace.getNext(ctx);
assertEquals(99, ctx.getRank());
assertEquals(0, seekTs.compareTo(event.getTimestamp()));
event = fTrace.getNext(ctx);
assertEquals(100, ctx.getRank());
assertEquals(0, seekTs.compareTo(event.getTimestamp()));
event = fTrace.getNext(ctx);
assertEquals(101, ctx.getRank());
assertEquals(0, seekTs.compareTo(event.getTimestamp()));
// Trace has events with same timestamp (ts=102) for ranks 102..702 -> 2 checkpoints with same timestamp are created
// Verify that the event at rank=102 is returned when seeking to ts=102 (first event with this timestamp)
// and not the event at checkpoint boundary
seekTs = TmfTimestamp.create(102, -3);
ctx = fTrace.seekEvent(seekTs);
event = fTrace.getNext(ctx);
assertEquals(102, ctx.getRank());
assertEquals(0, seekTs.compareTo(event.getTimestamp()));
// Verify seek to first checkpoint
seekTs = TmfTimestamp.create(1, -3);
ctx = fTrace.seekEvent(seekTs);
event = fTrace.getNext(ctx);
assertEquals(1, ctx.getRank());
assertEquals(0, seekTs.compareTo(event.getTimestamp()));
// Verify seek to timestamp before first event
seekTs = TmfTimestamp.create(0, -3);
ctx = fTrace.seekEvent(seekTs);
event = fTrace.getNext(ctx);
assertEquals(1, ctx.getRank());
assertEquals(0, TmfTimestamp.create(1, -3).compareTo(event.getTimestamp()));
// Verify seek to timestamp between first and second checkpoint
seekTs = TmfTimestamp.create(50, -3);
ctx = fTrace.seekEvent(seekTs);
event = fTrace.getNext(ctx);
assertEquals(50, ctx.getRank());
assertEquals(0, seekTs.compareTo(event.getTimestamp()));
// Verify seek to timestamp after last event in trace
seekTs = TmfTimestamp.create(103, -3);
ctx = fTrace.seekEvent(seekTs);
event = fTrace.getNext(ctx);
assertEquals(-1, ctx.getRank());
assertNull(event);
}
Aggregations