use of org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils in project tracecompass by tracecompass.
the class TmfTraceUtilsSearchingTest method testNextMatchingEvent.
// ------------------------------------------------------------------------
// Forwards searches
// ------------------------------------------------------------------------
/**
* Test the {@link TmfTraceUtils#getNextEventMatching} method.
*/
@Test
public void testNextMatchingEvent() {
ITmfTrace trace = fTrace;
assertNotNull(trace);
Predicate<@NonNull ITmfEvent> predicate = event -> event.getName().equals("sched_switch");
ITmfEvent actualEvent = TmfTraceUtils.getNextEventMatching(trace, START_RANK, predicate, null);
// following sched_switch event
ITmfContext ctx = trace.seekEvent(508L);
ITmfEvent expectedEvent = trace.getNext(ctx);
assertEquals(expectedEvent, actualEvent);
}
use of org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils in project tracecompass by tracecompass.
the class TmfTraceUtilsSearchingTest method testPreviousMatchingEvent.
// ------------------------------------------------------------------------
// Backwards searches
// ------------------------------------------------------------------------
/**
* Test the {@link TmfTraceUtils#getPreviousEventMatching} method.
*/
@Test
public void testPreviousMatchingEvent() {
ITmfTrace trace = fTrace;
assertNotNull(trace);
Predicate<@NonNull ITmfEvent> predicate = event -> event.getName().equals("sched_switch");
ITmfEvent actualEvent = TmfTraceUtils.getPreviousEventMatching(trace, START_RANK, predicate, null);
// previous sched_switch event
ITmfContext ctx = trace.seekEvent(455L);
ITmfEvent expectedEvent = trace.getNext(ctx);
assertEquals(expectedEvent, actualEvent);
}
use of org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils in project tracecompass by tracecompass.
the class TmfTraceUtilsSearchingTest method testPreviousMatchingEventFar.
/**
* Test the {@link TmfTraceUtils#getPreviousEventMatching} method with an
* event that is expected to take more than one inner request.
*/
@Test
public void testPreviousMatchingEventFar() {
ITmfTrace trace = fTrace;
assertNotNull(trace);
Predicate<@NonNull ITmfEvent> predicate = event -> event.getName().equals("sys_write");
ITmfEvent actualEvent = TmfTraceUtils.getPreviousEventMatching(trace, START_RANK, predicate, null);
// previous sched_switch event
ITmfContext ctx = trace.seekEvent(387L);
ITmfEvent expectedEvent = trace.getNext(ctx);
assertEquals(expectedEvent, actualEvent);
}
use of org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils in project tracecompass by tracecompass.
the class TmfTraceUtilsSearchingTest method testNextMatchingEventNoMatch.
/**
* Test the {@link TmfTraceUtils#getNextEventMatching} method where no event
* matches the passed predicate. It should return null.
*/
@Test
public void testNextMatchingEventNoMatch() {
ITmfTrace trace = fTrace;
assertNotNull(trace);
Predicate<@NonNull ITmfEvent> predicate = event -> event.getName().equals("non-existent-event");
ITmfEvent actualEvent = TmfTraceUtils.getNextEventMatching(trace, START_RANK, predicate, null);
assertNull(actualEvent);
}
use of org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils in project tracecompass by tracecompass.
the class TmfTraceUtilsSearchingTest method testPreviousMatchingEventNoMatch.
/**
* Test the {@link TmfTraceUtils#getPreviousEventMatching} method where no event
* matches the passed predicate. It should return null.
*/
@Test
public void testPreviousMatchingEventNoMatch() {
ITmfTrace trace = fTrace;
assertNotNull(trace);
Predicate<@NonNull ITmfEvent> predicate = event -> event.getName().equals("non-existent-event");
ITmfEvent actualEvent = TmfTraceUtils.getPreviousEventMatching(trace, START_RANK, predicate, null);
assertNull(actualEvent);
}
Aggregations