use of org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent in project tracecompass by tracecompass.
the class CtfTmfCpuAspectTest method test.
/**
* Test the cpu aspect
*/
@Test
public void test() {
CtfCpuAspect fixture = new CtfCpuAspect();
CtfTmfTrace trace = fTrace;
assertNotNull(trace);
CtfTmfEventFactory fabrica = CtfTmfEventFactory.instance();
/*
* Evaluate field, no stream
*/
CtfTmfEvent e = fabrica.createEvent(trace, fEvents.get(0), "");
assertEquals(Integer.valueOf(2), fixture.resolve(e));
/*
* Evaluate stream and field
*/
e = fabrica.createEvent(trace, fEvents.get(1), "");
assertEquals(Integer.valueOf(3), fixture.resolve(e));
/*
* Evaluate context
*/
e = fabrica.createEvent(trace, fEvents.get(2), "");
assertNull(fixture.resolve(e));
/*
* Evaluate an empty event
*/
e = fabrica.createEvent(trace, fEvents.get(3), "");
assertNull(fixture.resolve(e));
/*
* Evaluate stream and no field, default LTTng behaviour
*/
e = fabrica.createEvent(trace, fEvents.get(4), "");
assertEquals(Integer.valueOf(6), fixture.resolve(e));
/*
* Evaluate non-ctf event
*/
assertNull(fixture.resolve(new TmfEvent(trace, 0, TmfTimestamp.BIG_BANG, null, null)));
}
use of org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent 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.ctf.core.event.CtfTmfEvent 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.ctf.core.event.CtfTmfEvent in project tracecompass by tracecompass.
the class UstKernelSyncTest method testOneEvent.
/**
* Test that the TID given by the kernel analysis matches the one from the
* UST event's context for a given UST event that was known to fail.
*
* Reproduces the specific example that was pointed out in bug 484620.
*/
@Test
public void testOneEvent() {
TmfExperiment experiment = fExperiment;
ITmfTrace ustTrace = fUstTrace;
KernelAnalysisModule module = fKernelModule;
assertNotNull(experiment);
assertNotNull(ustTrace);
assertNotNull(module);
Predicate<@NonNull ITmfEvent> eventFinder = event -> {
Long addr = event.getContent().getFieldValue(Long.class, "addr");
Long cs = event.getContent().getFieldValue(Long.class, "call_site");
Long ctxVtid = event.getContent().getFieldValue(Long.class, "context._vtid");
if (addr == null || cs == null || ctxVtid == null) {
return false;
}
return Objects.equals(event.getType().getName(), "lttng_ust_cyg_profile:func_entry") && Objects.equals(Long.toHexString(addr), "804af97") && Objects.equals(Long.toHexString(cs), "804ab03") && Objects.equals(ctxVtid.longValue(), 594L);
};
/* The event we're looking for is the second event matching the predicate */
CtfTmfEvent ustEvent = (CtfTmfEvent) TmfTraceUtils.getNextEventMatching(experiment, 0, eventFinder, null);
assertNotNull(ustEvent);
long rank = experiment.seekEvent(ustEvent.getTimestamp()).getRank() + 1;
ustEvent = (CtfTmfEvent) TmfTraceUtils.getNextEventMatching(experiment, rank, eventFinder, null);
assertNotNull(ustEvent);
/* Make sure the correct event was retrieved */
assertEquals(ustTrace, ustEvent.getTrace());
assertEquals(1450193715128075054L, ustEvent.getTimestamp().toNanos());
Integer tidFromKernel = KernelThreadInformationProvider.getThreadOnCpu(module, ustEvent.getCPU(), ustEvent.getTimestamp().toNanos());
assertNotNull(tidFromKernel);
assertEquals(594, tidFromKernel.intValue());
}
use of org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent in project tracecompass by tracecompass.
the class EventContextTest method testContextEnd.
/**
* Test the context of the last event of the trace.
*/
@Test
public void testContextEnd() {
CtfTmfEvent lastEvent = getEventAt(endTime);
long perfPageFault = (Long) lastEvent.getContent().getField("context._perf_page_fault").getValue();
String procname = (String) lastEvent.getContent().getField("context._procname").getValue();
long tid = (Long) lastEvent.getContent().getField("context._tid").getValue();
assertEquals(22117, perfPageFault);
assertEquals("lttng-sessiond", procname);
assertEquals(1230, tid);
}
Aggregations