Search in sources :

Example 11 with ITmfEvent

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

the class TmfExperimentTest method testSeekRankNotOnCacheBoundary.

@Test
public void testSeekRankNotOnCacheBoundary() {
    long cacheSize = fExperiment.getCacheSize();
    // Position trace at event rank 9
    ITmfContext context = fExperiment.seekEvent(9);
    assertEquals("Context rank", 9, context.getRank());
    ITmfEvent event = fExperiment.getNext(context);
    assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
    assertEquals("Context rank", 10, context.getRank());
    // Position trace at event rank [cacheSize - 1]
    context = fExperiment.seekEvent(cacheSize - 1);
    assertEquals("Context rank", cacheSize - 1, context.getRank());
    event = fExperiment.getNext(context);
    assertEquals("Event timestamp", cacheSize, event.getTimestamp().getValue());
    assertEquals("Context rank", cacheSize, context.getRank());
    // Position trace at event rank [cacheSize + 1]
    context = fExperiment.seekEvent(cacheSize + 1);
    assertEquals("Context rank", cacheSize + 1, context.getRank());
    event = fExperiment.getNext(context);
    assertEquals("Event timestamp", cacheSize + 2, event.getTimestamp().getValue());
    assertEquals("Context rank", cacheSize + 2, context.getRank());
    // Position trace at event rank 4500
    context = fExperiment.seekEvent(4500);
    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) AnalysisManagerTest(org.eclipse.tracecompass.tmf.core.tests.analysis.AnalysisManagerTest) Test(org.junit.Test)

Example 12 with ITmfEvent

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

the class TmfExperimentTest method testGetNextLocation.

@Test
public void testGetNextLocation() {
    ITmfContext context1 = fExperiment.seekEvent(0);
    fExperiment.getNext(context1);
    ITmfLocation location = context1.getLocation();
    ITmfEvent event1 = fExperiment.getNext(context1);
    ITmfContext context2 = fExperiment.seekEvent(location);
    ITmfEvent event2 = fExperiment.getNext(context2);
    assertEquals("Event timestamp", event1.getTimestamp().getValue(), event2.getTimestamp().getValue());
}
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 13 with ITmfEvent

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

the class TmfExperimentTest method testGetNextAfteSeekingOnTS_2.

@Test
public void testGetNextAfteSeekingOnTS_2() {
    final long INITIAL_TS = 2;
    final int NB_READS = 20;
    // On lower bound, returns the first event (ts = 2)
    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) AnalysisManagerTest(org.eclipse.tracecompass.tmf.core.tests.analysis.AnalysisManagerTest) Test(org.junit.Test)

Example 14 with ITmfEvent

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

the class TmfExperimentTest method testSeekRankOnCacheBoundary.

// @SuppressWarnings("rawtypes")
// public void testGetCurrentLocation() {
// ITmfContext context = fExperiment.seekEvent((ITmfLocation) null);
// ITmfLocation location = fExperiment.getCurrentLocation();
// assertEquals("getCurrentLocation", location, context.getLocation());
// }
// ------------------------------------------------------------------------
// seekEvent on rank
// ------------------------------------------------------------------------
@Test
public void testSeekRankOnCacheBoundary() {
    long cacheSize = fExperiment.getCacheSize();
    // On lower bound, returns the first event (TS = 1)
    ITmfContext context = fExperiment.seekEvent(0);
    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(cacheSize);
    assertEquals("Context 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(4 * cacheSize);
    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) AnalysisManagerTest(org.eclipse.tracecompass.tmf.core.tests.analysis.AnalysisManagerTest) Test(org.junit.Test)

Example 15 with ITmfEvent

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

the class TmfExperimentTest method testGetNextAfterSeekingOnLocation_1.

@Test
public void testGetNextAfterSeekingOnLocation_1() {
    final ITmfLocation INITIAL_LOC = null;
    final long INITIAL_TS = 1;
    final int NB_READS = 20;
    // On lower bound, returns the first event (ts = 1)
    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());
        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) ITmfLocation(org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation) AnalysisManagerTest(org.eclipse.tracecompass.tmf.core.tests.analysis.AnalysisManagerTest) 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