Search in sources :

Example 1 with TmfTraceUtils

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);
}
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 2 with TmfTraceUtils

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);
}
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 3 with TmfTraceUtils

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);
}
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 4 with TmfTraceUtils

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);
}
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)

Example 5 with TmfTraceUtils

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);
}
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

Predicate (java.util.function.Predicate)7 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)7 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)7 NonNull (org.eclipse.jdt.annotation.NonNull)7 CtfTestTrace (org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace)7 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)7 ITmfContext (org.eclipse.tracecompass.tmf.core.trace.ITmfContext)7 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)7 TmfTraceUtils (org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils)7 CtfTmfTestTraceUtils (org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils)7 AfterClass (org.junit.AfterClass)7 Assert.assertEquals (org.junit.Assert.assertEquals)7 Assert.assertNotEquals (org.junit.Assert.assertNotEquals)7 Assert.assertNotNull (org.junit.Assert.assertNotNull)7 Assert.assertNull (org.junit.Assert.assertNull)7 BeforeClass (org.junit.BeforeClass)7 Test (org.junit.Test)7