Search in sources :

Example 1 with XmlPatternAnalysis

use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.pattern.stateprovider.XmlPatternAnalysis 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 XmlPatternAnalysis

use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.pattern.stateprovider.XmlPatternAnalysis in project tracecompass by tracecompass.

the class TmfStateValueScenarioTest method testAttributePool.

/**
 * Test that attribute pool are generated and populated correctly
 *
 * @throws StateSystemDisposedException
 *             Exceptions thrown during state system verification
 * @throws AttributeNotFoundException
 *             Exceptions thrown during state system verification
 */
@Test
public void testAttributePool() throws AttributeNotFoundException, StateSystemDisposedException {
    XmlPatternAnalysis module = fModule;
    assertNotNull(module);
    ITmfStateSystem ss = module.getStateSystem(module.getId());
    assertNotNull(ss);
    int quark = ss.getQuarkAbsolute("Operations");
    List<Integer> subAttributes = ss.getSubAttributes(quark, false);
    assertEquals("Number of attribute pool children", 2, subAttributes.size());
    final int[] expectedStarts = { 1, 2, 3, 5, 7, 10, 14, 20, 20 };
    ITmfStateValue[] expectedValues = { TmfStateValue.newValueString("op1"), TmfStateValue.newValueString("op2"), TmfStateValue.nullValue(), TmfStateValue.newValueString("op1"), TmfStateValue.nullValue(), TmfStateValue.newValueString("op1"), TmfStateValue.newValueString("op2"), TmfStateValue.nullValue() };
    XmlUtilsTest.verifyStateIntervals("testAttributePool", ss, subAttributes.get(0), expectedStarts, expectedValues);
    final int[] expectedStarts2 = { 1, 2, 3, 4, 20 };
    ITmfStateValue[] expectedValues2 = { TmfStateValue.nullValue(), TmfStateValue.newValueString("op1"), TmfStateValue.newValueString("op2"), TmfStateValue.nullValue() };
    XmlUtilsTest.verifyStateIntervals("testAttributePool", ss, subAttributes.get(1), expectedStarts2, expectedValues2);
}
Also used : XmlPatternAnalysis(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.pattern.stateprovider.XmlPatternAnalysis) 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 XmlPatternAnalysis

use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.pattern.stateprovider.XmlPatternAnalysis in project tracecompass by tracecompass.

the class TmfStateValueScenarioTest 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);
    XmlPatternAnalysis module = XmlUtilsTest.initializePatternModule(TmfXmlTestFiles.STATE_VALUE_PATTERN_FILE);
    module.setTrace(trace);
    module.schedule();
    module.waitForCompletion();
    fTrace = trace;
    fModule = module;
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) XmlPatternAnalysis(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.pattern.stateprovider.XmlPatternAnalysis) Before(org.junit.Before)

Example 4 with XmlPatternAnalysis

use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.pattern.stateprovider.XmlPatternAnalysis in project tracecompass by tracecompass.

the class XmlSegmentTest method testSegmentContent.

/**
 * Test segment generated using a mapping group
 *
 * @throws TmfAnalysisException
 *             Exception thrown by analysis
 */
@Test
public void testSegmentContent() throws TmfAnalysisException {
    ITmfTrace trace = getTrace(TEST_TRACE2);
    XmlPatternAnalysis module = null;
    try {
        module = initializeModule(trace, TmfXmlTestFiles.VALID_PATTERN_SEGMENT);
        doTestSegmentContent(module);
        // Close the segment store and open it again, it should read the
        // segment store from disk this time
        module.dispose();
        module = initializeModule(trace, TmfXmlTestFiles.VALID_PATTERN_SEGMENT);
        doTestSegmentContent(module);
    } finally {
        if (module != null) {
            module.dispose();
        }
        deleteSupplementaryFiles(trace);
        trace.dispose();
    }
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) XmlPatternAnalysis(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.pattern.stateprovider.XmlPatternAnalysis) Test(org.junit.Test) XmlUtilsTest(org.eclipse.tracecompass.tmf.analysis.xml.core.tests.module.XmlUtilsTest)

Example 5 with XmlPatternAnalysis

use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.pattern.stateprovider.XmlPatternAnalysis in project tracecompass by tracecompass.

the class XmlSegmentTest method initializeModule.

@NonNull
private static XmlPatternAnalysis initializeModule(@NonNull ITmfTrace trace, TmfXmlTestFiles xmlTestFile) throws TmfAnalysisException {
    XmlPatternAnalysis module = XmlUtilsTest.initializePatternModule(xmlTestFile);
    module.setTrace(trace);
    module.schedule();
    module.waitForCompletion();
    return module;
}
Also used : XmlPatternAnalysis(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.pattern.stateprovider.XmlPatternAnalysis) NonNull(org.eclipse.jdt.annotation.NonNull)

Aggregations

XmlPatternAnalysis (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.pattern.stateprovider.XmlPatternAnalysis)17 TmfXmlPatternCu (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlPatternCu)6 XmlUtilsTest (org.eclipse.tracecompass.tmf.analysis.xml.core.tests.module.XmlUtilsTest)6 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)6 Test (org.junit.Test)6 TmfXmlStateProviderCu (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlStateProviderCu)4 DataDrivenAnalysisModule (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.module.DataDrivenAnalysisModule)4 Element (org.w3c.dom.Element)4 NonNull (org.eclipse.jdt.annotation.NonNull)3 ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)3 ITmfStateValue (org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue)3 Before (org.junit.Before)3 Document (org.w3c.dom.Document)3 NodeList (org.w3c.dom.NodeList)3 TmfAnalysisException (org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException)2 Nullable (org.eclipse.jdt.annotation.Nullable)1 XmlOutputElement (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.module.XmlOutputElement)1 ISegment (org.eclipse.tracecompass.segmentstore.core.ISegment)1 IAnalysisModule (org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule)1 IAnalysisOutput (org.eclipse.tracecompass.tmf.core.analysis.IAnalysisOutput)1