Search in sources :

Example 71 with ITmfEvent

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);
}
Also used : ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) CtfTestTrace(org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace) AfterClass(org.junit.AfterClass) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) BeforeClass(org.junit.BeforeClass) Assert.assertNotNull(org.junit.Assert.assertNotNull) Predicate(java.util.function.Predicate) CtfTmfTestTraceUtils(org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils) Test(org.junit.Test) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) Assert.assertNull(org.junit.Assert.assertNull) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) TmfTraceUtils(org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) NonNull(org.eclipse.jdt.annotation.NonNull) Assert.assertEquals(org.junit.Assert.assertEquals) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) Test(org.junit.Test)

Example 72 with ITmfEvent

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);
}
Also used : CtfTestTrace(org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace) AfterClass(org.junit.AfterClass) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) BeforeClass(org.junit.BeforeClass) Assert.assertNotNull(org.junit.Assert.assertNotNull) Predicate(java.util.function.Predicate) CtfTmfTestTraceUtils(org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils) Test(org.junit.Test) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) Assert.assertNull(org.junit.Assert.assertNull) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) TmfTraceUtils(org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) NonNull(org.eclipse.jdt.annotation.NonNull) Assert.assertEquals(org.junit.Assert.assertEquals) ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) Test(org.junit.Test)

Example 73 with ITmfEvent

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);
}
Also used : CtfTestTrace(org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace) AfterClass(org.junit.AfterClass) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) BeforeClass(org.junit.BeforeClass) Assert.assertNotNull(org.junit.Assert.assertNotNull) Predicate(java.util.function.Predicate) CtfTmfTestTraceUtils(org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils) Test(org.junit.Test) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) Assert.assertNull(org.junit.Assert.assertNull) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) TmfTraceUtils(org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) NonNull(org.eclipse.jdt.annotation.NonNull) Assert.assertEquals(org.junit.Assert.assertEquals) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) Test(org.junit.Test)

Example 74 with ITmfEvent

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);
}
Also used : CtfTestTrace(org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace) AfterClass(org.junit.AfterClass) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) BeforeClass(org.junit.BeforeClass) Assert.assertNotNull(org.junit.Assert.assertNotNull) Predicate(java.util.function.Predicate) CtfTmfTestTraceUtils(org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils) Test(org.junit.Test) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) Assert.assertNull(org.junit.Assert.assertNull) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) TmfTraceUtils(org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) NonNull(org.eclipse.jdt.annotation.NonNull) Assert.assertEquals(org.junit.Assert.assertEquals) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) Test(org.junit.Test)

Example 75 with ITmfEvent

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);
}
Also used : CtfTestTrace(org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace) AfterClass(org.junit.AfterClass) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) BeforeClass(org.junit.BeforeClass) Assert.assertNotNull(org.junit.Assert.assertNotNull) Predicate(java.util.function.Predicate) CtfTmfTestTraceUtils(org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils) Test(org.junit.Test) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) Assert.assertNull(org.junit.Assert.assertNull) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) TmfTraceUtils(org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) NonNull(org.eclipse.jdt.annotation.NonNull) Assert.assertEquals(org.junit.Assert.assertEquals) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) Test(org.junit.Test)

Aggregations

ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)182 Test (org.junit.Test)127 ITmfContext (org.eclipse.tracecompass.tmf.core.trace.ITmfContext)112 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)40 TmfEventRequest (org.eclipse.tracecompass.tmf.core.request.TmfEventRequest)30 AnalysisManagerTest (org.eclipse.tracecompass.tmf.core.tests.analysis.AnalysisManagerTest)27 ITmfLocation (org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation)25 TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)24 NonNull (org.eclipse.jdt.annotation.NonNull)20 TmfEvent (org.eclipse.tracecompass.tmf.core.event.TmfEvent)17 ITmfEventRequest (org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest)16 Vector (java.util.Vector)15 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)15 Predicate (java.util.function.Predicate)14 TmfTraceUtils (org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils)14 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)13 CtfTestTrace (org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace)13 CtfTmfTestTraceUtils (org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils)13 Assert.assertEquals (org.junit.Assert.assertEquals)13 Assert.assertNotNull (org.junit.Assert.assertNotNull)13