Search in sources :

Example 1 with CtfTmfEvent

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)));
}
Also used : CtfTmfEvent(org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent) TmfEvent(org.eclipse.tracecompass.tmf.core.event.TmfEvent) CtfTmfEvent(org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent) CtfCpuAspect(org.eclipse.tracecompass.tmf.ctf.core.event.aspect.CtfCpuAspect) CtfTmfEventFactory(org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEventFactory) CtfTmfTrace(org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace) Test(org.junit.Test)

Example 2 with CtfTmfEvent

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();
}
Also used : ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) CtfTmfEvent(org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) ITmfLostEvent(org.eclipse.tracecompass.tmf.core.event.ITmfLostEvent) CtfTmfTrace(org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace) Test(org.junit.Test)

Example 3 with CtfTmfEvent

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);
}
Also used : ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) CtfTmfEvent(org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfExperiment(org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment) KernelAnalysisModule(org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule) Test(org.junit.Test)

Example 4 with CtfTmfEvent

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());
}
Also used : CtfTestTrace(org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace) TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal) TestRule(org.junit.rules.TestRule) CtfTmfTestTraceUtils(org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils) TmfExperiment(org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment) CtfTmfEvent(org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent) KernelAnalysisModule(org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule) After(org.junit.After) Timeout(org.junit.rules.Timeout) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) LttngKernelTestTraceUtils(org.eclipse.tracecompass.lttng2.lttng.kernel.core.tests.shared.LttngKernelTestTraceUtils) Before(org.junit.Before) TmfTraceSelectedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal) KernelThreadInformationProvider(org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelThreadInformationProvider) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) Assert.assertNotNull(org.junit.Assert.assertNotNull) Predicate(java.util.function.Predicate) Test(org.junit.Test) Objects(java.util.Objects) TimeUnit(java.util.concurrent.TimeUnit) ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) Rule(org.junit.Rule) TmfTraceUtils(org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils) TmfSignalManager(org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager) NonNull(org.eclipse.jdt.annotation.NonNull) Assert.assertEquals(org.junit.Assert.assertEquals) CtfTmfEvent(org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfExperiment(org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) KernelAnalysisModule(org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule) Test(org.junit.Test)

Example 5 with CtfTmfEvent

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);
}
Also used : CtfTmfEvent(org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent) Test(org.junit.Test)

Aggregations

CtfTmfEvent (org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent)38 Test (org.junit.Test)25 ITmfContext (org.eclipse.tracecompass.tmf.core.trace.ITmfContext)9 ITmfEventField (org.eclipse.tracecompass.tmf.core.event.ITmfEventField)8 CtfTmfTrace (org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace)6 Nullable (org.eclipse.jdt.annotation.Nullable)4 ICompositeDefinition (org.eclipse.tracecompass.ctf.core.event.types.ICompositeDefinition)4 CtfIterator (org.eclipse.tracecompass.internal.tmf.ctf.core.trace.iterator.CtfIterator)4 ITmfTimestamp (org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp)4 CtfTmfContext (org.eclipse.tracecompass.tmf.ctf.core.context.CtfTmfContext)4 ITmfLostEvent (org.eclipse.tracecompass.tmf.core.event.ITmfLostEvent)3 ArrayList (java.util.ArrayList)2 NonNull (org.eclipse.jdt.annotation.NonNull)2 KernelAnalysisModule (org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule)2 CtfTestTrace (org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace)2 TmfTraceException (org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException)2 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)2 TmfExperiment (org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment)2 CtfTmfTestTraceUtils (org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils)2 After (org.junit.After)2