Search in sources :

Example 1 with DataDrivenAnalysisModule

use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.module.DataDrivenAnalysisModule in project tracecompass by tracecompass.

the class TmfXmlTestUtils method getModuleInFile.

/**
 * Get the XML analysis module in the file. It will return either a pattern
 * or state provider, if there is one in the file
 *
 * @param xmlFilePath
 *            The absolute file path to the XML file
 * @param analysisId
 *            The ID of the analysis to get
 * @return The analysis module
 */
public static TmfAbstractAnalysisModule getModuleInFile(String xmlFilePath, @NonNull String analysisId) {
    // Look for a pattern element
    Element element = TmfXmlUtils.getElementInFile(xmlFilePath, TmfXmlStrings.PATTERN, analysisId);
    if (element != null) {
        TmfXmlPatternCu patternCu = TmfXmlPatternCu.compile(element);
        if (patternCu == null) {
            return null;
        }
        XmlPatternAnalysis module = new XmlPatternAnalysis(analysisId, patternCu);
        module.setName(analysisId);
        return module;
    }
    // Look for a state provider
    element = TmfXmlUtils.getElementInFile(xmlFilePath, TmfXmlStrings.STATE_PROVIDER, analysisId);
    if (element != null) {
        TmfXmlStateProviderCu compile = TmfXmlStateProviderCu.compile(Paths.get(xmlFilePath), analysisId);
        assertNotNull(compile);
        DataDrivenAnalysisModule module = new DataDrivenAnalysisModule(analysisId, compile);
        module.setName(analysisId);
        return module;
    }
    throw new NullPointerException("No module named " + analysisId + " in file " + xmlFilePath);
}
Also used : TmfXmlPatternCu(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlPatternCu) TmfXmlStateProviderCu(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlStateProviderCu) Element(org.w3c.dom.Element) XmlPatternAnalysis(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.pattern.stateprovider.XmlPatternAnalysis) DataDrivenAnalysisModule(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.module.DataDrivenAnalysisModule)

Example 2 with DataDrivenAnalysisModule

use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.module.DataDrivenAnalysisModule in project tracecompass by tracecompass.

the class TmfStateValueTest method testStateValueHostId.

/**
 * Test using the HostID event field. It should give the host ID for value
 *
 * @throws StateSystemDisposedException
 *             Exceptions thrown during state system verification
 * @throws AttributeNotFoundException
 *             Exceptions thrown during state system verification
 */
@Test
public void testStateValueHostId() throws AttributeNotFoundException, StateSystemDisposedException {
    DataDrivenAnalysisModule module = fModule;
    assertNotNull(module);
    ITmfStateSystem ss = module.getStateSystem();
    assertNotNull(ss);
    int quark = ss.getQuarkAbsolute("hostID");
    final int[] expectedStarts = { 1, 20 };
    ITmfStateValue[] expectedValues = { TmfStateValue.newValueString("testTrace4.xml") };
    XmlUtilsTest.verifyStateIntervals("testHostId", ss, quark, expectedStarts, expectedValues);
}
Also used : DataDrivenAnalysisModule(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.module.DataDrivenAnalysisModule) ITmfStateValue(org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) Test(org.junit.Test) XmlUtilsTest(org.eclipse.tracecompass.tmf.analysis.xml.core.tests.module.XmlUtilsTest)

Example 3 with DataDrivenAnalysisModule

use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.module.DataDrivenAnalysisModule in project tracecompass by tracecompass.

the class TmfStateValueTest method setUp.

/**
 * Initializes the trace and the module for the tests
 *
 * @throws TmfAnalysisException
 *             Any exception thrown during module initialization
 */
@Before
public void setUp() throws TmfAnalysisException {
    ITmfTrace trace = XmlUtilsTest.initializeTrace(TEST_TRACE);
    fTrace = trace;
    DataDrivenAnalysisModule module = XmlUtilsTest.initializeModule(TmfXmlTestFiles.STATE_VALUE_FILE);
    fModule = module;
    module.setTrace(trace);
    module.schedule();
    module.waitForCompletion();
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) DataDrivenAnalysisModule(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.module.DataDrivenAnalysisModule) Before(org.junit.Before)

Example 4 with DataDrivenAnalysisModule

use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.module.DataDrivenAnalysisModule in project tracecompass by tracecompass.

the class TmfStateValueTest method testStateValuePeek.

/**
 * it tests that a state change on stack, with a peek() condition. This test
 * verifies the value on the top of the stack and verifies that the peek
 * operation do not remove the value on the top of the stack.
 *
 * @throws StateSystemDisposedException
 *             Exceptions thrown during state system verification
 * @throws AttributeNotFoundException
 *             Exceptions thrown during state system verification
 */
@Test
public void testStateValuePeek() throws AttributeNotFoundException, StateSystemDisposedException {
    DataDrivenAnalysisModule module = fModule;
    assertNotNull(module);
    ITmfStateSystem ss = module.getStateSystem();
    assertNotNull(ss);
    int quark = ss.getQuarkAbsolute("stack");
    final int[] expectedStarts = { 1, 2, 5, 7, 10, 20 };
    ITmfStateValue[] expectedValues = { TmfStateValue.newValueLong(1l), TmfStateValue.newValueLong(2l), TmfStateValue.newValueLong(5l), TmfStateValue.newValueLong(2l), TmfStateValue.newValueLong(10l) };
    XmlUtilsTest.verifyStackStateIntervals("testStateValuePeek", ss, quark, expectedStarts, expectedValues);
}
Also used : DataDrivenAnalysisModule(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.module.DataDrivenAnalysisModule) ITmfStateValue(org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) Test(org.junit.Test) XmlUtilsTest(org.eclipse.tracecompass.tmf.analysis.xml.core.tests.module.XmlUtilsTest)

Example 5 with DataDrivenAnalysisModule

use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.module.DataDrivenAnalysisModule in project tracecompass by tracecompass.

the class TmfStateValueTest method testStateValueModify.

/**
 * Test that a state change with no update causes the modification of the
 * state value at the time of the event
 *
 * @throws StateSystemDisposedException
 *             Exceptions thrown during state system verification
 * @throws AttributeNotFoundException
 *             Exceptions thrown during state system verification
 */
@Test
public void testStateValueModify() throws AttributeNotFoundException, StateSystemDisposedException {
    DataDrivenAnalysisModule module = fModule;
    assertNotNull(module);
    ITmfStateSystem ss = module.getStateSystem();
    assertNotNull(ss);
    int quark = ss.getQuarkAbsolute("modify", "0");
    final int[] expectedStarts = { 1, 3, 5, 7, 20 };
    ITmfStateValue[] expectedValues = { TmfStateValue.newValueString("UNKNOWN"), TmfStateValue.newValueString("GOOD"), TmfStateValue.newValueString("UNKNOWN"), TmfStateValue.newValueString("BAD") };
    XmlUtilsTest.verifyStateIntervals("testStateValueModify", ss, quark, expectedStarts, expectedValues);
}
Also used : DataDrivenAnalysisModule(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.module.DataDrivenAnalysisModule) ITmfStateValue(org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) Test(org.junit.Test) XmlUtilsTest(org.eclipse.tracecompass.tmf.analysis.xml.core.tests.module.XmlUtilsTest)

Aggregations

DataDrivenAnalysisModule (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.module.DataDrivenAnalysisModule)19 Test (org.junit.Test)12 ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)10 XmlUtilsTest (org.eclipse.tracecompass.tmf.analysis.xml.core.tests.module.XmlUtilsTest)10 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)8 ITmfStateValue (org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue)7 TmfXmlStateProviderCu (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlStateProviderCu)5 Element (org.w3c.dom.Element)5 TmfXmlPatternCu (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlPatternCu)4 XmlPatternAnalysis (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.pattern.stateprovider.XmlPatternAnalysis)4 TmfAnalysisException (org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException)3 TmfTimeGraphCompositeDataProvider (org.eclipse.tracecompass.internal.tmf.core.model.timegraph.TmfTimeGraphCompositeDataProvider)2 AttributeNotFoundException (org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException)2 StateSystemDisposedException (org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException)2 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)2 TimeGraphEntryModel (org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel)2 TmfTraceClosedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal)2 TmfTraceOpenedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal)2 TmfTrace (org.eclipse.tracecompass.tmf.core.trace.TmfTrace)2 TmfExperiment (org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment)2