Search in sources :

Example 21 with ITmfEvent

use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.

the class TmfExperimentTest method testGetNextAfterSeekingOnRank_3.

@Test
public void testGetNextAfterSeekingOnRank_3() {
    final long INITIAL_RANK = 500L;
    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);
}
Also used : ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) AnalysisManagerTest(org.eclipse.tracecompass.tmf.core.tests.analysis.AnalysisManagerTest) Test(org.junit.Test)

Example 22 with ITmfEvent

use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.

the class TmfExperimentTest method testGetNextAfterSeekingOnLocation_3.

@Test
public void testGetNextAfterSeekingOnLocation_3() {
    final ITmfLocation INITIAL_LOC = fExperiment.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 = fExperiment.seekEvent(INITIAL_LOC);
    validateContextRanks(context);
    // Read NB_EVENTS
    ITmfEvent event;
    for (int i = 0; i < NB_READS; i++) {
        event = fExperiment.getNext(context);
        assertEquals("Event timestamp", INITIAL_TS + i, event.getTimestamp().getValue());
    }
    // Make sure we stay positioned
    event = fExperiment.parseEvent(context);
    assertEquals("Event timestamp", INITIAL_TS + NB_READS, event.getTimestamp().getValue());
    validateContextRanks(context);
}
Also used : ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) ITmfLocation(org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation) AnalysisManagerTest(org.eclipse.tracecompass.tmf.core.tests.analysis.AnalysisManagerTest) Test(org.junit.Test)

Example 23 with ITmfEvent

use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.

the class TmfMultiTraceExperimentTest method testSeekLocationOutOfScope.

@Test
public void testSeekLocationOutOfScope() {
    // Position trace at beginning
    ITmfContext context = fExperiment.seekEvent((ITmfLocation) null);
    ITmfEvent event = fExperiment.getNext(context);
    assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
}
Also used : ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) Test(org.junit.Test)

Example 24 with ITmfEvent

use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.

the class TmfMultiTraceExperimentTest method testGetNextAfteSeekingOnTS_1.

@Test
public void testGetNextAfteSeekingOnTS_1() {
    final long INITIAL_TS = 1;
    final int NB_READS = 20;
    // On lower bound, returns the first event (ts = 1)
    final ITmfContext context = fExperiment.seekEvent(TmfTimestamp.create(INITIAL_TS, SCALE));
    validateContextRanks(context);
    // Read NB_EVENTS
    ITmfEvent event;
    for (int i = 0; i < NB_READS; i++) {
        event = fExperiment.getNext(context);
        assertEquals("Event timestamp", INITIAL_TS + i, event.getTimestamp().getValue());
        assertEquals("Event rank", INITIAL_TS + i, context.getRank());
    }
    // Make sure we stay positioned
    event = fExperiment.parseEvent(context);
    assertEquals("Event timestamp", INITIAL_TS + NB_READS, event.getTimestamp().getValue());
    assertEquals("Event rank", INITIAL_TS + NB_READS - 1, context.getRank());
    validateContextRanks(context);
}
Also used : ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) Test(org.junit.Test)

Example 25 with ITmfEvent

use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.

the class TmfMultiTraceExperimentTest method testCancel.

// ------------------------------------------------------------------------
// cancel
// ------------------------------------------------------------------------
@Test
public void testCancel() throws InterruptedException {
    final int nbEvents = NB_EVENTS;
    final int limit = BLOCK_SIZE;
    final Vector<ITmfEvent> requestedEvents = new Vector<>();
    final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
    final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class, range, 0, nbEvents, ExecutionType.FOREGROUND) {

        int nbRead = 0;

        @Override
        public void handleData(final ITmfEvent event) {
            super.handleData(event);
            requestedEvents.add(event);
            if (++nbRead == limit) {
                cancel();
            }
        }
    };
    fExperiment.sendRequest(request);
    request.waitForCompletion();
    assertEquals("nbEvents", limit, requestedEvents.size());
    assertTrue("isCompleted", request.isCompleted());
    assertTrue("isCancelled", request.isCancelled());
}
Also used : ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) Vector(java.util.Vector) ITmfEventRequest(org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest) TmfEventRequest(org.eclipse.tracecompass.tmf.core.request.TmfEventRequest) 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