use of org.eclipse.tracecompass.tmf.core.trace.ITmfContext in project tracecompass by tracecompass.
the class CtfTmfLostEventsTest method testLostEventWithTransform.
/**
* Test getting a lost event from a trace that has a timestamp transform.
*/
@Test
public void testLostEventWithTransform() {
CtfTmfTrace trace = CtfTmfTestTraceUtils.getTrace(testTrace);
long offset = 1234567890L;
trace.setTimestampTransform(TimestampTransformFactory.createWithOffset(offset));
trace.indexTrace(true);
final long rank = 190;
final ITmfTimestamp start = TmfTimestamp.fromNanos(1376592664828900165L + offset);
final ITmfTimestamp end = TmfTimestamp.fromNanos(1376592664828900165L + 502911L + offset);
final long nbLost = 859;
ITmfContext context = trace.seekEvent(rank);
final CtfTmfEvent ev = trace.getNext(context);
context.dispose();
assertTrue(ev instanceof ITmfLostEvent);
ITmfLostEvent event = (ITmfLostEvent) ev;
assertEquals(start, event.getTimestamp());
assertEquals(start, event.getTimeRange().getStartTime());
assertEquals(end, event.getTimeRange().getEndTime());
assertEquals(nbLost, event.getNbLostEvents());
trace.setTimestampTransform(null);
trace.dispose();
}
use of org.eclipse.tracecompass.tmf.core.trace.ITmfContext in project tracecompass by tracecompass.
the class UstKernelSyncTest method testWholeUstTrace.
/**
* Test going through the whole UST trace, making sure the VTID context of
* each event corresponds to the TID given by the kernel analysis at the
* same timestamp.
*/
@Test
public void testWholeUstTrace() {
TmfExperiment experiment = fExperiment;
ITmfTrace ustTrace = fUstTrace;
KernelAnalysisModule module = fKernelModule;
assertNotNull(experiment);
assertNotNull(ustTrace);
assertNotNull(module);
ITmfContext context = ustTrace.seekEvent(0L);
CtfTmfEvent ustEvent = (CtfTmfEvent) ustTrace.getNext(context);
int count = 0;
while (ustEvent != null) {
Long ustVtid = ustEvent.getContent().getFieldValue(Long.class, "context._vtid");
/* All events in the trace should have that context */
assertNotNull(ustVtid);
long ts = ustEvent.getTimestamp().toNanos();
long cpu = ustEvent.getCPU();
Integer kernelTid = KernelThreadInformationProvider.getThreadOnCpu(module, cpu, ts);
assertNotNull(kernelTid);
assertEquals("Wrong TID for trace event " + ustEvent.toString(), ustVtid.longValue(), kernelTid.longValue());
ustEvent = (CtfTmfEvent) ustTrace.getNext(context);
count++;
}
/* Make sure we've read all expected events */
assertEquals(UST_TRACE.getNbEvents(), count);
}
use of org.eclipse.tracecompass.tmf.core.trace.ITmfContext in project tracecompass by tracecompass.
the class TmfExperimentTest method testGetNextAfterSeekingOnRank_1.
@Test
public void testGetNextAfterSeekingOnRank_1() {
final long INITIAL_RANK = 0L;
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.trace.ITmfContext in project tracecompass by tracecompass.
the class TmfExperimentTest method testSeekRankNotOnCacheBoundary.
@Test
public void testSeekRankNotOnCacheBoundary() {
long cacheSize = fExperiment.getCacheSize();
// Position trace at event rank 9
ITmfContext context = fExperiment.seekEvent(9);
assertEquals("Context rank", 9, context.getRank());
ITmfEvent event = fExperiment.getNext(context);
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Context rank", 10, context.getRank());
// Position trace at event rank [cacheSize - 1]
context = fExperiment.seekEvent(cacheSize - 1);
assertEquals("Context rank", cacheSize - 1, context.getRank());
event = fExperiment.getNext(context);
assertEquals("Event timestamp", cacheSize, event.getTimestamp().getValue());
assertEquals("Context rank", cacheSize, context.getRank());
// Position trace at event rank [cacheSize + 1]
context = fExperiment.seekEvent(cacheSize + 1);
assertEquals("Context rank", cacheSize + 1, context.getRank());
event = fExperiment.getNext(context);
assertEquals("Event timestamp", cacheSize + 2, event.getTimestamp().getValue());
assertEquals("Context rank", cacheSize + 2, context.getRank());
// Position trace at event rank 4500
context = fExperiment.seekEvent(4500);
assertEquals("Context rank", 4500, context.getRank());
event = fExperiment.getNext(context);
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Context rank", 4501, context.getRank());
}
use of org.eclipse.tracecompass.tmf.core.trace.ITmfContext in project tracecompass by tracecompass.
the class TmfExperimentTest 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());
}
Aggregations