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