use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.
the class TmfTraceUtilsSearchingTest method testPreviousMatchingBeginningOfTrace.
/**
* When doing a backwards search near the beginning of the trace (when
* startRank < step), make sure that we do not go beyond the start rank.
*/
@Test
public void testPreviousMatchingBeginningOfTrace() {
ITmfTrace trace = fTrace;
assertNotNull(trace);
final int startRank = 3;
ITmfContext ctx = fTrace.seekEvent(startRank);
ITmfEvent startEvent = fTrace.getNext(ctx);
assertEquals("exit_syscall", startEvent.getName());
/* There is a sys_mmap at rank 6, it should not be matched! */
Predicate<@NonNull ITmfEvent> predicate = event -> event.getName().equals("sys_mmap");
ITmfEvent foundEvent = TmfTraceUtils.getPreviousEventMatching(trace, startRank, predicate, null);
assertNull(foundEvent);
/* Do not match the event itself either, or any later "exit_syscall" */
predicate = event -> event.getName().equals("exit_syscall");
foundEvent = TmfTraceUtils.getPreviousEventMatching(trace, startRank, predicate, null);
assertNull(foundEvent);
}
use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent 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.event.ITmfEvent in project tracecompass by tracecompass.
the class TmfTraceUtilsSearchingTest method testNextMatchingEventCancelled.
/**
* Test with a progress monitor that cancels the job.
*/
@Test
public void testNextMatchingEventCancelled() {
ITmfTrace trace = fTrace;
assertNotNull(trace);
Predicate<@NonNull ITmfEvent> predicate = event -> event.getName().equals("sched_switch");
IProgressMonitor monitor = new NullProgressMonitor();
monitor.setCanceled(true);
ITmfEvent actualEvent = TmfTraceUtils.getNextEventMatching(trace, START_RANK, predicate, monitor);
/* No event should be returend */
assertNull(actualEvent);
}
use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.
the class TmfTraceUtilsSearchingTest method testPreviousMatchingEventCancelled.
/**
* Test with a progress monitor that cancels the job.
*/
@Test
public void testPreviousMatchingEventCancelled() {
ITmfTrace trace = fTrace;
assertNotNull(trace);
Predicate<@NonNull ITmfEvent> predicate = event -> event.getName().equals("sched_switch");
IProgressMonitor monitor = new NullProgressMonitor();
monitor.setCanceled(true);
ITmfEvent actualEvent = TmfTraceUtils.getPreviousEventMatching(trace, START_RANK, predicate, monitor);
/* No event should be returend */
assertNull(actualEvent);
}
use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent 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);
}
Aggregations