Search in sources :

Example 1 with TmfAbstractAnalysisRequirement

use of org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAbstractAnalysisRequirement in project tracecompass by tracecompass.

the class LttngUstCallStackAnalysisRequirement method getSubRequirements.

private static Collection<TmfAbstractAnalysisRequirement> getSubRequirements(ILttngUstEventLayout layout) {
    Set<@NonNull String> requiredEventsFields = Collections.singleton(layout.contextVtid());
    // Requirement for the cyg_profile events
    TmfAnalysisEventFieldRequirement entryReq = new TmfAnalysisEventFieldRequirement(layout.eventCygProfileFuncEntry(), requiredEventsFields, PriorityLevel.MANDATORY);
    TmfAbstractAnalysisRequirement exitReq = new TmfAnalysisEventFieldRequirement(layout.eventCygProfileFuncExit(), requiredEventsFields, PriorityLevel.MANDATORY);
    TmfAbstractAnalysisRequirement cygProfile = new TmfCompositeAnalysisRequirement(ImmutableSet.of(entryReq, exitReq), PriorityLevel.MANDATORY);
    // Requirement for the cyg_profile_fast events
    entryReq = new TmfAnalysisEventFieldRequirement(layout.eventCygProfileFastFuncEntry(), requiredEventsFields, PriorityLevel.MANDATORY);
    exitReq = new TmfAnalysisEventFieldRequirement(layout.eventCygProfileFastFuncExit(), requiredEventsFields, PriorityLevel.MANDATORY);
    TmfAbstractAnalysisRequirement cygProfileFast = new TmfCompositeAnalysisRequirement(ImmutableSet.of(entryReq, exitReq), PriorityLevel.MANDATORY);
    return ImmutableSet.of(cygProfile, cygProfileFast);
}
Also used : TmfAbstractAnalysisRequirement(org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAbstractAnalysisRequirement) TmfCompositeAnalysisRequirement(org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfCompositeAnalysisRequirement) NonNullUtils.nullToEmptyString(org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString) TmfAnalysisEventFieldRequirement(org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAnalysisEventFieldRequirement)

Example 2 with TmfAbstractAnalysisRequirement

use of org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAbstractAnalysisRequirement in project tracecompass by tracecompass.

the class AnalysisEventFieldRequirementTest method testMandatoryRequirements.

/**
 * Test with mandatory requirements
 */
@Test
public void testMandatoryRequirements() {
    /* Test mandatory requirement */
    TmfAbstractAnalysisRequirement req = new TmfAnalysisEventFieldRequirement(EVENT1, ImmutableSet.of(EVENT1_FIELD1), PriorityLevel.MANDATORY);
    assertTrue(req.test(trace));
    req = new TmfAnalysisEventFieldRequirement(EVENT1, ImmutableSet.of(EVENT1_FIELD1, EVENT1_FIELD2), PriorityLevel.MANDATORY);
    assertTrue(req.test(trace));
    /* EVENT3 is not part of the trace. Test case that one of the events is part of the trace */
    req = new TmfAnalysisEventFieldRequirement(EVENT3, ImmutableSet.of(EVENT1_FIELD1, EVENT1_FIELD2), PriorityLevel.MANDATORY);
    assertFalse(req.test(trace));
    /* EVENT_FIELD is not an event field of the trace */
    req = new TmfAnalysisEventFieldRequirement(EVENT1, ImmutableSet.of(EVENT1_FIELD1, EVENT1_FIELD2, EVENT_FIELD), PriorityLevel.MANDATORY);
    assertFalse(req.test(trace));
    /* Test case that all events need to have the given fields */
    req = new TmfAnalysisEventFieldRequirement("", ImmutableSet.of(EVENT1_FIELD1, EVENT1_FIELD2), PriorityLevel.MANDATORY);
    assertTrue(req.test(trace));
    /* Test case that all events need to have the given fields */
    req = new TmfAnalysisEventFieldRequirement("", ImmutableSet.of(EVENT2_FIELD1), PriorityLevel.MANDATORY);
    assertFalse(req.test(trace));
    /* Test case that empty list of event fields behaves like Event Requirements */
    req = new TmfAnalysisEventFieldRequirement(EVENT1, checkNotNull(Collections.emptyList()));
    assertTrue(req.test(trace));
}
Also used : TmfAbstractAnalysisRequirement(org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAbstractAnalysisRequirement) TmfAnalysisEventFieldRequirement(org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAnalysisEventFieldRequirement) Test(org.junit.Test)

Example 3 with TmfAbstractAnalysisRequirement

use of org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAbstractAnalysisRequirement in project tracecompass by tracecompass.

the class AnalysisEventFieldRequirementTest method testAllOrNothingRequirements.

/**
 * Test with {@link PriorityLevel#ALL_OR_NOTHING} requirements
 */
@Test
public void testAllOrNothingRequirements() {
    /* Test at least one requirement */
    TmfAbstractAnalysisRequirement req = new TmfAnalysisEventFieldRequirement(EVENT1, ImmutableSet.of(EVENT1_FIELD1), PriorityLevel.ALL_OR_NOTHING);
    assertTrue(req.test(trace));
    req = new TmfAnalysisEventFieldRequirement(EVENT1, ImmutableSet.of(EVENT1_FIELD1, EVENT1_FIELD2), PriorityLevel.ALL_OR_NOTHING);
    assertTrue(req.test(trace));
    /* EVENT3 is not part of the trace. Test case that the event is part of the trace */
    req = new TmfAnalysisEventFieldRequirement(EVENT3, ImmutableSet.of(EVENT1_FIELD1, EVENT1_FIELD2), PriorityLevel.ALL_OR_NOTHING);
    assertTrue(req.test(trace));
    /* EVENT_FIELD is not an event field of the trace */
    req = new TmfAnalysisEventFieldRequirement(EVENT1, ImmutableSet.of(EVENT1_FIELD1, EVENT1_FIELD2, EVENT_FIELD), PriorityLevel.ALL_OR_NOTHING);
    assertFalse(req.test(trace));
    /* Test case that all events need to have either all or none of the given fields */
    req = new TmfAnalysisEventFieldRequirement("", ImmutableSet.of(EVENT1_FIELD1, EVENT2_FIELD2), PriorityLevel.ALL_OR_NOTHING);
    assertFalse(req.test(trace));
    /* Test case that all events need to have the given fields */
    req = new TmfAnalysisEventFieldRequirement("", ImmutableSet.of(EVENT1_FIELD1), PriorityLevel.ALL_OR_NOTHING);
    assertTrue(req.test(trace));
    /* Test case that empty list of event fields behaves like Event Requirements */
    req = new TmfAnalysisEventFieldRequirement(EVENT1, checkNotNull(Collections.emptyList()), PriorityLevel.ALL_OR_NOTHING);
    assertTrue(req.test(trace));
}
Also used : TmfAbstractAnalysisRequirement(org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAbstractAnalysisRequirement) TmfAnalysisEventFieldRequirement(org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAnalysisEventFieldRequirement) Test(org.junit.Test)

Example 4 with TmfAbstractAnalysisRequirement

use of org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAbstractAnalysisRequirement in project tracecompass by tracecompass.

the class AnalysisEventRequirementTest method testAtLeastOneRequirements.

/**
 * Test with {@link PriorityLevel#AT_LEAST_ONE} requirements
 */
@Test
public void testAtLeastOneRequirements() {
    /* Test mandatory requirement */
    TmfAbstractAnalysisRequirement req = new TmfAnalysisEventRequirement(ImmutableSet.of(EVENT1), PriorityLevel.AT_LEAST_ONE);
    assertTrue(req.test(fTrace));
    req = new TmfAnalysisEventRequirement(ImmutableSet.of(EVENT1, EVENT2), PriorityLevel.AT_LEAST_ONE);
    assertTrue(req.test(fTrace));
    /* Event 3 is not an event of the trace */
    req = new TmfAnalysisEventRequirement(ImmutableSet.of(EVENT1, EVENT2, EVENT3), PriorityLevel.AT_LEAST_ONE);
    assertTrue(req.test(fTrace));
    req = new TmfAnalysisEventRequirement(ImmutableSet.of(EVENT3), PriorityLevel.AT_LEAST_ONE);
    assertFalse(req.test(fTrace));
}
Also used : TmfAbstractAnalysisRequirement(org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAbstractAnalysisRequirement) TmfAnalysisEventRequirement(org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAnalysisEventRequirement) Test(org.junit.Test)

Example 5 with TmfAbstractAnalysisRequirement

use of org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAbstractAnalysisRequirement in project tracecompass by tracecompass.

the class AnalysisEventRequirementTest method testNoPreDefinedEvents.

/**
 * Test event requirements on a trace with no pre-defined events. They
 * should all pass
 */
@Test
public void testNoPreDefinedEvents() {
    /* A simple trace with no pre-defined events */
    TmfTrace traceNoEvents = new TmfTraceStub();
    TmfAbstractAnalysisRequirement req = new TmfAnalysisEventRequirement(ImmutableSet.of(EVENT1, EVENT3), PriorityLevel.MANDATORY);
    assertTrue(req.test(traceNoEvents));
    req = new TmfAnalysisEventRequirement(ImmutableSet.of(EVENT1, EVENT2), PriorityLevel.OPTIONAL);
    assertTrue(req.test(traceNoEvents));
    traceNoEvents.dispose();
}
Also used : TmfTrace(org.eclipse.tracecompass.tmf.core.trace.TmfTrace) TmfAbstractAnalysisRequirement(org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAbstractAnalysisRequirement) TmfAnalysisEventRequirement(org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAnalysisEventRequirement) TmfTraceStub(org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub) Test(org.junit.Test)

Aggregations

TmfAbstractAnalysisRequirement (org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAbstractAnalysisRequirement)22 Test (org.junit.Test)17 TmfAnalysisEventFieldRequirement (org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAnalysisEventFieldRequirement)6 TmfAnalysisEventRequirement (org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAnalysisEventRequirement)6 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)6 TmfCompositeAnalysisRequirement (org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfCompositeAnalysisRequirement)5 NonNull (org.eclipse.jdt.annotation.NonNull)2 NonNullUtils.nullToEmptyString (org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString)2 LttngUstTrace (org.eclipse.tracecompass.lttng2.ust.core.trace.LttngUstTrace)2 ILttngUstEventLayout (org.eclipse.tracecompass.lttng2.ust.core.trace.layout.ILttngUstEventLayout)2 TmfTrace (org.eclipse.tracecompass.tmf.core.trace.TmfTrace)2 TmfTraceStub (org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub)2 IKernelAnalysisEventLayout (org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout)1 AnalysisRequirementFactory (org.eclipse.tracecompass.tmf.tests.stubs.analysis.AnalysisRequirementFactory)1