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