Search in sources :

Example 1 with TmfEventRequest

use of org.eclipse.tracecompass.tmf.core.request.TmfEventRequest in project tracecompass by tracecompass.

the class UstDebugInfoAnalysisModuleTest method testBinaryCallsites.

/**
 * Test that the binary callsite aspect resolves correctly for some
 * user-defined tracepoints in the trace.
 *
 * These should be available even without the binaries with debug symbols
 * being present on the system.
 */
@Test
public void testBinaryCallsites() {
    LttngUstTrace trace = LttngUstTestTraceUtils.getTrace(REAL_TEST_TRACE);
    /*
         * Fake a "trace opened" signal, so that the relevant analyses are
         * started.
         */
    TmfTraceOpenedSignal signal = new TmfTraceOpenedSignal(this, trace, null);
    TmfSignalManager.dispatchSignal(signal);
    UstDebugInfoAnalysisModule module = TmfTraceUtils.getAnalysisModuleOfClass(trace, UstDebugInfoAnalysisModule.class, UstDebugInfoAnalysisModule.ID);
    assertNotNull(module);
    module.waitForCompletion();
    /* Send a request to get the 3 events we are interested in */
    List<@NonNull LttngUstEvent> events = new ArrayList<>();
    TmfEventRequest request = new TmfEventRequest(LttngUstEvent.class, 31, 1, ExecutionType.FOREGROUND) {

        @Override
        public void handleData(ITmfEvent event) {
            super.handleData(event);
            events.add((LttngUstEvent) event);
        }
    };
    trace.sendRequest(request);
    try {
        request.waitForCompletion();
    } catch (InterruptedException e) {
        fail(e.getMessage());
    }
    /* Tests that the aspects are resolved correctly */
    final UstDebugInfoBinaryAspect aspect = UstDebugInfoBinaryAspect.INSTANCE;
    String actual = checkNotNull(aspect.resolve(events.get(0))).toString();
    String expected = "/home/simark/src/babeltrace/tests/debug-info-data/libhello_so+0x14d4";
    assertEquals(expected, actual);
    LttngUstTestTraceUtils.dispose(REAL_TEST_TRACE);
}
Also used : LttngUstTrace(org.eclipse.tracecompass.lttng2.ust.core.trace.LttngUstTrace) ArrayList(java.util.ArrayList) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal) LttngUstEvent(org.eclipse.tracecompass.lttng2.ust.core.trace.LttngUstEvent) UstDebugInfoBinaryAspect(org.eclipse.tracecompass.lttng2.ust.core.analysis.debuginfo.UstDebugInfoBinaryAspect) UstDebugInfoAnalysisModule(org.eclipse.tracecompass.lttng2.ust.core.analysis.debuginfo.UstDebugInfoAnalysisModule) TmfEventRequest(org.eclipse.tracecompass.tmf.core.request.TmfEventRequest) Test(org.junit.Test)

Example 2 with TmfEventRequest

use of org.eclipse.tracecompass.tmf.core.request.TmfEventRequest in project tracecompass by tracecompass.

the class TmfCoalescedEventRequestTest method testFail.

// ------------------------------------------------------------------------
// fail
// ------------------------------------------------------------------------
@Test
public void testFail() {
    final boolean[] crFlags = new boolean[4];
    TmfCoalescedEventRequest request = setupTestRequest(crFlags);
    TmfEventRequest subRequest1 = new TmfEventRequestStub(ITmfEvent.class, range1, 100, 200);
    TmfEventRequest subRequest2 = new TmfEventRequestStub(ITmfEvent.class, range1, 100, 200);
    request.addRequest(subRequest1);
    request.addRequest(subRequest2);
    request.fail(new IllformedLocaleException("Hi"));
    // Validate the coalescing request
    assertTrue("isCompleted", request.isCompleted());
    assertTrue("isFailed", request.isFailed());
    final Throwable failCause = request.getFailureCause();
    assertNotNull("Cause of failure", failCause);
    assertEquals("Cause of failure message", "Hi", failCause.getMessage());
    assertFalse("isCancelled", request.isCancelled());
    assertTrue("handleCompleted", crFlags[0]);
    assertFalse("handleSuccess", crFlags[1]);
    assertTrue("handleFailure", crFlags[2]);
    assertFalse("handleCancel", crFlags[3]);
    // Validate the first coalesced request
    assertTrue("isCompleted", subRequest1.isCompleted());
    assertTrue("isFailed", subRequest1.isFailed());
    assertFalse("isCancelled", subRequest1.isCancelled());
    // Validate the second coalesced request
    assertTrue("isCompleted", subRequest2.isCompleted());
    assertTrue("isFailed", subRequest2.isFailed());
    assertFalse("isCancelled", subRequest2.isCancelled());
}
Also used : TmfEventRequestStub(org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub) IllformedLocaleException(java.util.IllformedLocaleException) TmfCoalescedEventRequest(org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest) TmfEventRequest(org.eclipse.tracecompass.tmf.core.request.TmfEventRequest) Test(org.junit.Test)

Example 3 with TmfEventRequest

use of org.eclipse.tracecompass.tmf.core.request.TmfEventRequest in project tracecompass by tracecompass.

the class TmfCoalescedEventRequestTest method testDone.

// ------------------------------------------------------------------------
// done
// ------------------------------------------------------------------------
@Test
public void testDone() {
    // Test request
    final boolean[] crFlags = new boolean[4];
    TmfCoalescedEventRequest request = setupTestRequest(crFlags);
    TmfEventRequest subRequest1 = new TmfEventRequestStub(ITmfEvent.class, range1, 100, 200);
    TmfEventRequest subRequest2 = new TmfEventRequestStub(ITmfEvent.class, range1, 100, 200);
    request.addRequest(subRequest1);
    request.addRequest(subRequest2);
    request.done();
    // Validate the coalescing request
    assertTrue("isCompleted", request.isCompleted());
    assertFalse("isFailed", request.isFailed());
    assertFalse("isCancelled", request.isCancelled());
    assertTrue("handleCompleted", crFlags[0]);
    assertTrue("handleSuccess", crFlags[1]);
    assertFalse("handleFailure", crFlags[2]);
    assertFalse("handleCancel", crFlags[3]);
    // Validate the first coalesced request
    assertTrue("isCompleted", subRequest1.isCompleted());
    assertFalse("isFailed", subRequest1.isFailed());
    assertFalse("isCancelled", subRequest1.isCancelled());
    // Validate the second coalesced request
    assertTrue("isCompleted", subRequest2.isCompleted());
    assertFalse("isFailed", subRequest2.isFailed());
    assertFalse("isCancelled", subRequest2.isCancelled());
}
Also used : TmfEventRequestStub(org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub) TmfCoalescedEventRequest(org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest) TmfEventRequest(org.eclipse.tracecompass.tmf.core.request.TmfEventRequest) Test(org.junit.Test)

Example 4 with TmfEventRequest

use of org.eclipse.tracecompass.tmf.core.request.TmfEventRequest in project tracecompass by tracecompass.

the class TmfCoalescedEventRequestTest method trigger.

/**
 * @param signal
 *            the trigger signal
 */
@TmfSignalHandler
public void trigger(final TmfTestTriggerSignal2 signal) {
    TmfTimeRange range = new TmfTimeRange(TmfTimestamp.create(100, -3), TmfTimestamp.BIG_CRUNCH);
    requestedEvents1 = new Vector<>();
    request1 = new TmfEventRequest(ITmfEvent.class, range, 0, 1, ExecutionType.FOREGROUND) {

        @Override
        public void handleData(ITmfEvent event) {
            super.handleData(event);
            if (!isCompleted()) {
                requestedEvents1.add(event);
            }
        }
    };
    providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
    providers[0].sendRequest(request1);
}
Also used : ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) TmfTraceStub(org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub) TmfEventRequest(org.eclipse.tracecompass.tmf.core.request.TmfEventRequest) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)

Example 5 with TmfEventRequest

use of org.eclipse.tracecompass.tmf.core.request.TmfEventRequest in project tracecompass by tracecompass.

the class TmfCoalescedEventRequestTest method testAddEvent1.

// ------------------------------------------------------------------------
// addEvent
// ------------------------------------------------------------------------
@Test
public void testAddEvent1() {
    TmfCoalescedEventRequest coalescedRequest = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 2147483647, ExecutionType.FOREGROUND, 0);
    TmfEventRequest req1 = new TmfEventRequestStub(ITmfEvent.class, range1, 0, 2147483647, 200);
    TmfEventRequest req2 = new TmfEventRequestStub(ITmfEvent.class, range1, 1, 2147483647, 200);
    assertTrue("isCompatible", coalescedRequest.isCompatible(req1));
    assertTrue("isCompatible", coalescedRequest.isCompatible(req2));
    coalescedRequest.addRequest(req1);
    coalescedRequest.addRequest(req2);
    assertEquals("addRequest", 0, coalescedRequest.getIndex());
    assertEquals("addRequest", 2147483647, coalescedRequest.getNbRequested());
}
Also used : TmfEventRequestStub(org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub) TmfCoalescedEventRequest(org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest) TmfEventRequest(org.eclipse.tracecompass.tmf.core.request.TmfEventRequest) Test(org.junit.Test)

Aggregations

TmfEventRequest (org.eclipse.tracecompass.tmf.core.request.TmfEventRequest)51 Test (org.junit.Test)36 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)31 ITmfEventRequest (org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest)29 TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)24 Vector (java.util.Vector)15 TmfEventRequestStub (org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub)15 ITmfEventProvider (org.eclipse.tracecompass.tmf.core.component.ITmfEventProvider)11 TmfCoalescedEventRequest (org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest)8 ArrayList (java.util.ArrayList)5 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 NonNull (org.eclipse.jdt.annotation.NonNull)3 AnalysisManagerTest (org.eclipse.tracecompass.tmf.core.tests.analysis.AnalysisManagerTest)3 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)2 Nullable (org.eclipse.jdt.annotation.Nullable)2 TmfCollapseFilter (org.eclipse.tracecompass.internal.tmf.core.filter.TmfCollapseFilter)2 ITmfFilter (org.eclipse.tracecompass.tmf.core.filter.ITmfFilter)2 TmfSignalHandler (org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)2 ITmfSyncSequenceDiagramEvent (org.eclipse.tracecompass.tmf.core.uml2sd.ITmfSyncSequenceDiagramEvent)2