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());
}
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());
}
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();
}
}
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");
}
}
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;
}
Aggregations