Search in sources :

Example 76 with ITmfEvent

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());
}
Also used : ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) ITmfCheckpoint(org.eclipse.tracecompass.tmf.core.trace.indexer.checkpoint.ITmfCheckpoint) TmfContext(org.eclipse.tracecompass.tmf.core.trace.TmfContext) ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) ITmfCheckpointIndex(org.eclipse.tracecompass.tmf.core.trace.indexer.checkpoint.ITmfCheckpointIndex) ITmfCheckpoint(org.eclipse.tracecompass.tmf.core.trace.indexer.checkpoint.ITmfCheckpoint)

Example 77 with ITmfEvent

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();
    }
}
Also used : ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) IStatus(org.eclipse.core.runtime.IStatus) NonNull(org.eclipse.jdt.annotation.NonNull) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) JsonStubTrace(org.eclipse.tracecompass.jsontrace.core.tests.stub.JsonStubTrace) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent)

Example 78 with ITmfEvent

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;
}
Also used : ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) PcapTrace(org.eclipse.tracecompass.internal.tmf.pcap.core.trace.PcapTrace) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent)

Example 79 with ITmfEvent

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

Example 80 with ITmfEvent

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

Aggregations

ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)182 Test (org.junit.Test)127 ITmfContext (org.eclipse.tracecompass.tmf.core.trace.ITmfContext)112 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)40 TmfEventRequest (org.eclipse.tracecompass.tmf.core.request.TmfEventRequest)30 AnalysisManagerTest (org.eclipse.tracecompass.tmf.core.tests.analysis.AnalysisManagerTest)27 ITmfLocation (org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation)25 TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)24 NonNull (org.eclipse.jdt.annotation.NonNull)20 TmfEvent (org.eclipse.tracecompass.tmf.core.event.TmfEvent)17 ITmfEventRequest (org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest)16 Vector (java.util.Vector)15 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)15 Predicate (java.util.function.Predicate)14 TmfTraceUtils (org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils)14 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)13 CtfTestTrace (org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace)13 CtfTmfTestTraceUtils (org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils)13 Assert.assertEquals (org.junit.Assert.assertEquals)13 Assert.assertNotNull (org.junit.Assert.assertNotNull)13