Search in sources :

Example 6 with ITmfEvent

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

the class TmfEventRequestIntegrationTest method testSingleRequestException.

/**
 * Test the behavior of a failed request
 *
 * @throws InterruptedException
 *             The test timed out
 */
@Test
public void testSingleRequestException() throws InterruptedException {
    TmfTrace trace = fTrace;
    TmfEventRequest requestFail = new TmfEventRequestStub(ITmfEvent.class, TmfTimeRange.ETERNITY, 2, 0, ExecutionType.BACKGROUND, 0) {

        @Override
        public void handleData(@NonNull ITmfEvent data) {
            throw new IllegalArgumentException();
        }
    };
    trace.sendRequest(requestFail);
    requestFail.waitForCompletion();
    assertTrue(requestFail.isCompleted());
    assertFalse(requestFail.isCancelled());
    assertTrue(requestFail.isFailed());
}
Also used : TmfTrace(org.eclipse.tracecompass.tmf.core.trace.TmfTrace) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) NonNull(org.eclipse.jdt.annotation.NonNull) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) TmfEventRequestStub(org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub) TmfEventRequest(org.eclipse.tracecompass.tmf.core.request.TmfEventRequest) Test(org.junit.Test)

Example 7 with ITmfEvent

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

the class TmfMipmapStateProviderTest method init.

/**
 * Startup code, build a state system with n attributes always going up
 * linearly
 */
@BeforeClass
public static void init() {
    TmfMipmapStateProviderStub mmp = new TmfMipmapStateProviderStub(RESOLUTION, Type.LONG);
    IStateHistoryBackend be = StateHistoryBackendFactory.createInMemoryBackend(SSID, 0);
    ITmfStateSystemBuilder ssb = StateSystemFactory.newStateSystem(be);
    mmp.assignTargetStateSystem(ssb);
    ssq = ssb;
    for (long time = START_TIME; time <= END_TIME; time += INTERVAL) {
        long value = time / INTERVAL;
        ITmfEvent event = mmp.createEvent(time, value);
        mmp.processEvent(event);
    }
    mmp.dispose();
    ssq.waitUntilBuilt();
}
Also used : ITmfStateSystemBuilder(org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) IStateHistoryBackend(org.eclipse.tracecompass.statesystem.core.backend.IStateHistoryBackend) BeforeClass(org.junit.BeforeClass)

Example 8 with ITmfEvent

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

the class TimeOffsetTest method testClearOffset.

@Test
public void testClearOffset() throws TmfTraceException {
    ITmfTimestampTransform tt = TimestampTransformFactory.createWithOffset(ONE_MS);
    TimestampTransformFactory.setTimestampTransform(fResource, tt);
    TimestampTransformFactory.setTimestampTransform(fResource, null);
    ITmfTrace trace = createAndIndexTrace();
    final TmfContext context = (TmfContext) trace.seekEvent(0);
    ITmfEvent event = trace.getNext(context);
    assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
    event = trace.getNext(context);
    assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
    trace.dispose();
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfContext(org.eclipse.tracecompass.tmf.core.trace.TmfContext) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) ITmfTimestampTransform(org.eclipse.tracecompass.tmf.core.synchronization.ITmfTimestampTransform) Test(org.junit.Test)

Example 9 with ITmfEvent

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

the class TmfExperimentTest 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) AnalysisManagerTest(org.eclipse.tracecompass.tmf.core.tests.analysis.AnalysisManagerTest) Test(org.junit.Test)

Example 10 with ITmfEvent

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

the class TmfExperimentTest 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) 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