Search in sources :

Example 26 with ITmfEvent

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

the class TmfMultiTraceExperimentTest method testSeekTimestampNotOnCacheBoundary.

@Test
public void testSeekTimestampNotOnCacheBoundary() {
    // Position trace at event rank 1 (TS = 2)
    ITmfContext context = fExperiment.seekEvent(TmfTimestamp.create(2, SCALE));
    assertEquals("Context rank", 1, context.getRank());
    ITmfEvent event = fExperiment.getNext(context);
    assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
    assertEquals("Context rank", 2, context.getRank());
    // Position trace at event rank 9 (TS = 10)
    context = fExperiment.seekEvent(TmfTimestamp.create(10, SCALE));
    assertEquals("Context rank", 9, context.getRank());
    event = fExperiment.getNext(context);
    assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
    assertEquals("Context rank", 10, context.getRank());
    // Position trace at event rank 999 (TS = 1000)
    context = fExperiment.seekEvent(TmfTimestamp.create(1000, SCALE));
    assertEquals("Context rank", 999, context.getRank());
    event = fExperiment.getNext(context);
    assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
    assertEquals("Context rank", 1000, context.getRank());
    // Position trace at event rank 1001 (TS = 1002)
    context = fExperiment.seekEvent(TmfTimestamp.create(1002, SCALE));
    assertEquals("Context rank", 1001, context.getRank());
    event = fExperiment.getNext(context);
    assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
    assertEquals("Context rank", 1002, context.getRank());
    // Position trace at event rank 4500 (TS = 4501)
    context = fExperiment.seekEvent(TmfTimestamp.create(4501, SCALE));
    assertEquals("Context rank", 4500, context.getRank());
    event = fExperiment.getNext(context);
    assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
    assertEquals("Context rank", 4501, context.getRank());
}
Also used : ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) Test(org.junit.Test)

Example 27 with ITmfEvent

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

the class TmfMultiTraceExperimentTest method testProcessRequestForAllEvents.

@Test
public void testProcessRequestForAllEvents() throws InterruptedException {
    final int nbEvents = ITmfEventRequest.ALL_DATA;
    final Vector<ITmfEvent> requestedEvents = new Vector<>();
    final long nbExpectedEvents = NB_EVENTS;
    final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
    final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class, range, 0, nbEvents, ExecutionType.FOREGROUND) {

        @Override
        public void handleData(final ITmfEvent event) {
            super.handleData(event);
            requestedEvents.add(event);
        }
    };
    fExperiment.sendRequest(request);
    request.waitForCompletion();
    assertEquals("nbEvents", nbExpectedEvents, requestedEvents.size());
    assertTrue("isCompleted", request.isCompleted());
    assertFalse("isCancelled", request.isCancelled());
    // Don't go overboard: we are not validating the stub!
    for (int i = 0; i < nbExpectedEvents; i++) {
        assertEquals("Distinct events", i + 1, requestedEvents.get(i).getTimestamp().getValue());
    }
}
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)

Example 28 with ITmfEvent

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

the class TmfMultiTraceExperimentTest method testProcessRequestForNbEvents.

// ------------------------------------------------------------------------
// processRequest
// ------------------------------------------------------------------------
@Test
public void testProcessRequestForNbEvents() throws InterruptedException {
    final int nbEvents = 1000;
    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) {

        @Override
        public void handleData(final ITmfEvent event) {
            super.handleData(event);
            requestedEvents.add(event);
        }
    };
    fExperiment.sendRequest(request);
    request.waitForCompletion();
    assertEquals("nbEvents", nbEvents, requestedEvents.size());
    assertTrue("isCompleted", request.isCompleted());
    assertFalse("isCancelled", request.isCancelled());
    // Don't go overboard: we are not validating the stub!
    for (int i = 0; i < nbEvents; i++) {
        assertEquals("Distinct events", i + 1, requestedEvents.get(i).getTimestamp().getValue());
    }
}
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)

Example 29 with ITmfEvent

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

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

Example 30 with ITmfEvent

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

the class TmfMultiTraceExperimentTest method testSeekTimestampOnCacheBoundary.

// ------------------------------------------------------------------------
// seekEvent on timestamp
// ------------------------------------------------------------------------
@Test
public void testSeekTimestampOnCacheBoundary() {
    long cacheSize = fExperiment.getCacheSize();
    // Position trace at event rank 0
    ITmfContext context = fExperiment.seekEvent(TmfTimestamp.create(1, SCALE));
    assertEquals("Context rank", 0, context.getRank());
    ITmfEvent event = fExperiment.getNext(context);
    assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
    assertEquals("Context rank", 1, context.getRank());
    // Position trace at event rank [cacheSize]
    context = fExperiment.seekEvent(TmfTimestamp.create(cacheSize + 1, SCALE));
    assertEquals("Event rank", cacheSize, context.getRank());
    event = fExperiment.getNext(context);
    assertEquals("Event timestamp", cacheSize + 1, event.getTimestamp().getValue());
    assertEquals("Context rank", cacheSize + 1, context.getRank());
    // Position trace at event rank [4 * cacheSize]
    context = fExperiment.seekEvent(TmfTimestamp.create(4 * cacheSize + 1, SCALE));
    assertEquals("Context rank", 4 * cacheSize, context.getRank());
    event = fExperiment.getNext(context);
    assertEquals("Event timestamp", 4 * cacheSize + 1, event.getTimestamp().getValue());
    assertEquals("Context rank", 4 * cacheSize + 1, context.getRank());
}
Also used : ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) 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