Search in sources :

Example 1 with TmfTraceStub

use of org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub in project tracecompass by tracecompass.

the class TmfEventMatchingTest method testMultiHostMultiKeyType.

/**
 * Test event matching from different hosts and with different key types, there
 * should be cleanup of event data when matches occur, but only for the appropriate key
 */
@Test
public void testMultiHostMultiKeyType() {
    // Test-specific data initialization
    int count = 1;
    int matchedKey1 = count++;
    int unmatchedKey1 = count++;
    int unmatchedKey2 = count++;
    int unmatchedKey3 = count++;
    int unmatchedKey4 = count++;
    int unmatchedStringKey1 = -count++;
    int matchedStringKey1 = -count++;
    int matchedKey2 = count++;
    Collection<@NonNull ITmfTrace> traces = fTraces;
    assertNotNull(traces);
    TmfEventMatchingStub matching = new TmfEventMatchingStub(traces);
    matching.initMatching();
    TmfTraceStub t1 = fT1;
    assertNotNull(t1);
    TmfTraceStub t2 = fT2;
    assertNotNull(t2);
    /*
         * Have t1 send and receive all its packets before any of t2, no match should be
         * made at this point
         */
    // Add an unmatched cause
    matching.matchEvent(new MatchEventStub(t1, TmfTimestamp.fromNanos(1L), unmatchedKey1, Direction.CAUSE), t1, PROGRESS_MONITOR);
    assertEquals(1, matching.getUnmatchedOut().row(t1).size());
    // Add an unmatched effect
    matching.matchEvent(new MatchEventStub(t1, TmfTimestamp.fromNanos(3L), unmatchedKey2, Direction.EFFECT), t1, PROGRESS_MONITOR);
    assertEquals(1, matching.getUnmatchedOut().row(t1).size());
    assertEquals(1, matching.getUnmatchedIn().row(t1).size());
    // Add another unmatched effect
    matching.matchEvent(new MatchEventStub(t1, TmfTimestamp.fromNanos(5L), unmatchedKey3, Direction.EFFECT), t1, PROGRESS_MONITOR);
    assertEquals(1, matching.getUnmatchedOut().row(t1).size());
    assertEquals(2, matching.getUnmatchedIn().row(t1).size());
    // Add a string key that will not be matched
    matching.matchEvent(new MatchEventStub(t1, TmfTimestamp.fromNanos(6L), unmatchedStringKey1, Direction.CAUSE), t1, PROGRESS_MONITOR);
    assertEquals(2, matching.getUnmatchedOut().row(t1).size());
    assertEquals(2, matching.getUnmatchedIn().row(t1).size());
    // Add a cause that will be matched later
    matching.matchEvent(new MatchEventStub(t1, TmfTimestamp.fromNanos(7L), matchedKey1, Direction.CAUSE), t1, PROGRESS_MONITOR);
    assertEquals(3, matching.getUnmatchedOut().row(t1).size());
    assertEquals(2, matching.getUnmatchedIn().row(t1).size());
    // Add an effect that will be matched later
    matching.matchEvent(new MatchEventStub(t1, TmfTimestamp.fromNanos(11L), matchedKey2, Direction.EFFECT), t1, PROGRESS_MONITOR);
    assertEquals(3, matching.getUnmatchedOut().row(t1).size());
    assertEquals(3, matching.getUnmatchedIn().row(t1).size());
    // Add an unmatched cause
    matching.matchEvent(new MatchEventStub(t1, TmfTimestamp.fromNanos(13L), unmatchedKey4, Direction.CAUSE), t1, PROGRESS_MONITOR);
    assertEquals(4, matching.getUnmatchedOut().row(t1).size());
    assertEquals(3, matching.getUnmatchedIn().row(t1).size());
    // Add a string key that will not be matched
    matching.matchEvent(new MatchEventStub(t1, TmfTimestamp.fromNanos(15L), matchedStringKey1, Direction.CAUSE), t1, PROGRESS_MONITOR);
    assertEquals(5, matching.getUnmatchedOut().row(t1).size());
    assertEquals(3, matching.getUnmatchedIn().row(t1).size());
    /* Let t2 receive and send the packets */
    // Match the sent packet, it should cleanup the unmatched outgoing from t1,
    // except the last one and the strings
    matching.matchEvent(new MatchEventStub(t2, TmfTimestamp.fromNanos(20L), matchedKey1, Direction.EFFECT), t2, PROGRESS_MONITOR);
    assertEquals(3, matching.getUnmatchedOut().row(t1).size());
    assertEquals(3, matching.getUnmatchedIn().row(t1).size());
    // Match the received packet, it should cleanup the unmatched incoming from t1
    matching.matchEvent(new MatchEventStub(t2, TmfTimestamp.fromNanos(21L), matchedKey2, Direction.CAUSE), t2, PROGRESS_MONITOR);
    assertEquals(3, matching.getUnmatchedOut().row(t1).size());
    assertEquals(0, matching.getUnmatchedIn().row(t1).size());
    // Match the received string key, it should cleanup the unmatched string key from t1
    matching.matchEvent(new MatchEventStub(t2, TmfTimestamp.fromNanos(22L), matchedStringKey1, Direction.EFFECT), t2, PROGRESS_MONITOR);
    assertEquals(1, matching.getUnmatchedOut().row(t1).size());
    assertEquals(0, matching.getUnmatchedIn().row(t1).size());
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfTraceStub(org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub) Test(org.junit.Test)

Example 2 with TmfTraceStub

use of org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub in project tracecompass by tracecompass.

the class TmfEventMatchingTest method init.

/**
 * Initializing the traces
 */
@Before
public void init() {
    TmfTraceStub t1 = new TmfTraceStub();
    t1.init("t1");
    TmfTraceStub t2 = new TmfTraceStub();
    t2.init("t2");
    Collection<@NonNull ITmfTrace> traces = new LinkedList<>();
    traces.add(t1);
    traces.add(t2);
    fT1 = t1;
    fT2 = t2;
    fTraces = traces;
    TmfEventMatching.registerMatchObject(new StubEventMatching());
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfTraceStub(org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub) LinkedList(java.util.LinkedList) Before(org.junit.Before)

Example 3 with TmfTraceStub

use of org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub in project tracecompass by tracecompass.

the class TmfEventMatchingTest method cleanup.

/**
 * Clean up
 */
@After
public void cleanup() {
    TmfTraceStub trace = fT1;
    if (trace != null) {
        trace.dispose();
    }
    trace = fT2;
    if (trace != null) {
        trace.dispose();
    }
}
Also used : TmfTraceStub(org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub) After(org.junit.After)

Example 4 with TmfTraceStub

use of org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub in project tracecompass by tracecompass.

the class TmfEventRequestIntegrationTest method setUp.

/**
 * Test class setup
 */
@BeforeClass
public static void setUp() {
    try {
        fTrace = new TmfTraceStub(TEST_TRACE.getFullPath(), ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, false, null);
        TmfSignalManager.deregister(fTrace);
        fTrace.indexTrace(true);
    } catch (final TmfTraceException e) {
        e.printStackTrace();
        fail("Error setting up test trace");
    }
}
Also used : TmfTraceException(org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException) TmfTraceStub(org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub) BeforeClass(org.junit.BeforeClass)

Example 5 with TmfTraceStub

use of org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub in project tracecompass by tracecompass.

the class TmfExperimentTest method setupTrace.

// ------------------------------------------------------------------------
// Housekeeping
// ------------------------------------------------------------------------
private synchronized ITmfTrace[] setupTrace(final String path) {
    if (fTestTraces == null) {
        fTestTraces = new ITmfTrace[1];
        try {
            final TmfTraceStub trace = new TmfTraceStub(path, 0, true, null);
            fTestTraces[0] = trace;
        } catch (final TmfTraceException e) {
            e.printStackTrace();
        }
    }
    return fTestTraces;
}
Also used : TmfTraceException(org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException) TmfTraceStub(org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub)

Aggregations

TmfTraceStub (org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub)38 Test (org.junit.Test)22 TmfTraceException (org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException)13 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)9 Before (org.junit.Before)6 After (org.junit.After)4 IOException (java.io.IOException)3 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)3 ITmfTimestamp (org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp)3 TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)3 ITmfLocation (org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation)3 BeforeClass (org.junit.BeforeClass)3 File (java.io.File)2 LinkedList (java.util.LinkedList)2 NonNull (org.eclipse.jdt.annotation.NonNull)2 Point (org.eclipse.swt.graphics.Point)2 SWTWorkbenchBot (org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot)2 SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)2 DefaultCondition (org.eclipse.swtbot.swt.finder.waits.DefaultCondition)2 TmfTraceClosedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal)2