Search in sources :

Example 16 with ITmfEvent

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

the class TmfExperimentTest method testSeekLocationNotOnCacheBoundary.

@Test
public void testSeekLocationNotOnCacheBoundary() {
    long cacheSize = fExperiment.getCacheSize();
    // Position trace at event 'cacheSize' - 1
    ITmfContext tmpContext = fExperiment.seekEvent(cacheSize - 1);
    ITmfContext context = fExperiment.seekEvent(tmpContext.getLocation());
    ITmfEvent event = fExperiment.getNext(context);
    assertEquals("Event timestamp", cacheSize, event.getTimestamp().getValue());
    event = fExperiment.getNext(context);
    assertEquals("Event timestamp", cacheSize + 1, event.getTimestamp().getValue());
    // Position trace at event rank 2 * 'cacheSize' - 1
    tmpContext = fExperiment.seekEvent(2 * cacheSize - 1);
    context = fExperiment.seekEvent(tmpContext.getLocation());
    context = fExperiment.seekEvent(2 * cacheSize - 1);
    event = fExperiment.getNext(context);
    assertEquals("Event timestamp", 2 * cacheSize, event.getTimestamp().getValue());
    event = fExperiment.getNext(context);
    assertEquals("Event timestamp", 2 * cacheSize + 1, event.getTimestamp().getValue());
    // Position trace at event rank 4500
    tmpContext = fExperiment.seekEvent(4500);
    context = fExperiment.seekEvent(tmpContext.getLocation());
    event = fExperiment.getNext(context);
    assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
    event = fExperiment.getNext(context);
    assertEquals("Event timestamp", 4502, event.getTimestamp().getValue());
}
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 17 with ITmfEvent

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

the class TmfExperimentTest method testGetNextAfteSeekingOnTS_3.

@Test
public void testGetNextAfteSeekingOnTS_3() {
    final long INITIAL_TS = 500;
    final int NB_READS = 20;
    // On lower bound, returns the first event (ts = 500)
    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 18 with ITmfEvent

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

the class TmfExperimentTest method testSeekLocationOnCacheBoundary.

// ------------------------------------------------------------------------
// seekEvent by location (context rank is undefined)
// ------------------------------------------------------------------------
@Test
public void testSeekLocationOnCacheBoundary() {
    long cacheSize = fExperiment.getCacheSize();
    // Position trace at event rank 0
    ITmfContext tmpContext = fExperiment.seekEvent(0);
    ITmfContext context = fExperiment.seekEvent(tmpContext.getLocation());
    ITmfEvent event = fExperiment.getNext(context);
    assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
    event = fExperiment.getNext(context);
    assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
    // Position trace at event rank 'cacheSize'
    tmpContext = fExperiment.seekEvent(cacheSize);
    context = fExperiment.seekEvent(tmpContext.getLocation());
    event = fExperiment.getNext(context);
    assertEquals("Event timestamp", cacheSize + 1, event.getTimestamp().getValue());
    event = fExperiment.getNext(context);
    assertEquals("Event timestamp", cacheSize + 2, event.getTimestamp().getValue());
    // Position trace at event rank 4 * 'cacheSize'
    tmpContext = fExperiment.seekEvent(4 * cacheSize);
    context = fExperiment.seekEvent(tmpContext.getLocation());
    event = fExperiment.getNext(context);
    assertEquals("Event timestamp", 4 * cacheSize + 1, event.getTimestamp().getValue());
    event = fExperiment.getNext(context);
    assertEquals("Event timestamp", 4 * cacheSize + 2, event.getTimestamp().getValue());
}
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 19 with ITmfEvent

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

the class TmfExperimentTest method testSeekRankOutOfScope.

@Test
public void testSeekRankOutOfScope() {
    // Position trace at beginning
    ITmfContext context = fExperiment.seekEvent(-1);
    assertEquals("Event 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 passed the end
    context = fExperiment.seekEvent(NB_EVENTS);
    assertEquals("Context rank", NB_EVENTS, context.getRank());
    event = fExperiment.getNext(context);
    assertNull("Event", event);
    assertEquals("Context rank", NB_EVENTS, 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 20 with ITmfEvent

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

the class TmfExperimentTest method testGetNextAfterSeekingOnLocation_2.

@Test
public void testGetNextAfterSeekingOnLocation_2() {
    final ITmfLocation INITIAL_LOC = fExperiment.seekEvent(1L).getLocation();
    final long INITIAL_TS = 2;
    final int NB_READS = 20;
    // On lower bound, returns the first event (ts = 2)
    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)

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