use of org.eclipse.tracecompass.statesystem.core.ITmfStateSystem in project tracecompass by tracecompass.
the class StateSystemUtilsTest method testIteratorOverQuarkReversed.
/**
* Test that the reverse iterator returns the correct intervals:
* <ul>
* <li>intervals for the correct quark</li>
* <li>ordered intervals</li>
* <li>intervals covering the correct time range</li>
* </ul>
*/
@Test
public void testIteratorOverQuarkReversed() {
ITmfStateSystem ss = fStateSystem;
assertNotNull(ss);
for (int quark = 0; quark < ss.getNbAttributes(); quark++) {
QuarkIterator iterator = new QuarkIterator(ss, quark, Long.MAX_VALUE);
ITmfStateInterval prevInterval = null;
ITmfStateInterval currInterval = null;
while (iterator.hasPrevious()) {
currInterval = iterator.previous();
assertEquals(quark, currInterval.getAttribute());
if (prevInterval == null) {
/* This is the first interval for this attribute */
assertEquals(currInterval.getEndTime(), ss.getCurrentEndTime());
} else {
assertEquals(prevInterval.getStartTime() - 1, currInterval.getEndTime());
}
prevInterval = currInterval;
}
assertNotNull("Iterator should have returned at least one interval", currInterval);
assertEquals(ss.getStartTime(), currInterval.getStartTime());
}
}
use of org.eclipse.tracecompass.statesystem.core.ITmfStateSystem in project tracecompass by tracecompass.
the class StateSystemUtilsTest method testIteratorOverQuark.
/**
* Test that iterator returns the correct intervals:
* <ul>
* <li>intervals for the correct quark</li>
* <li>ordered intervals</li>
* <li>intervals covering the correct time range</li>
* </ul>
*/
@Test
public void testIteratorOverQuark() {
ITmfStateSystem ss = fStateSystem;
assertNotNull(ss);
for (int quark = 0; quark < ss.getNbAttributes(); quark++) {
QuarkIterator iterator = new QuarkIterator(ss, quark, Long.MIN_VALUE);
ITmfStateInterval prevInterval = null;
ITmfStateInterval currInterval = null;
while (iterator.hasNext()) {
currInterval = iterator.next();
assertEquals(quark, currInterval.getAttribute());
if (prevInterval == null) {
/* This is the first interval for this attribute */
assertEquals(currInterval.getStartTime(), ss.getStartTime());
} else {
assertEquals(prevInterval.getEndTime() + 1, currInterval.getStartTime());
}
prevInterval = currInterval;
}
assertNotNull("Iterator should have returned at least one interval", currInterval);
assertEquals(ss.getCurrentEndTime(), currInterval.getEndTime());
}
}
use of org.eclipse.tracecompass.statesystem.core.ITmfStateSystem in project tracecompass by tracecompass.
the class FsmTest method testInitialStateWithCondition.
/**
* Compare the execution of two state machines doing the same job, the tid
* condition is ignored with the initial element and used with the
* initialState element. The result should be different.
*/
@Test
public void testInitialStateWithCondition() {
ITmfStateSystem stateSystem = fModule.getStateSystem(fModule.getId());
assertNotNull("state system exist", stateSystem);
try {
int quark = stateSystem.getQuarkAbsolute("fsm1");
@NonNull ITmfStateInterval interval = stateSystem.querySingleState(END_TIME, quark);
long count1 = interval.getStateValue().unboxLong();
quark = stateSystem.getQuarkAbsolute("fsm3");
interval = stateSystem.querySingleState(END_TIME, quark);
long count3 = interval.getStateValue().unboxLong();
assertTrue("Test the count value", count1 > count3);
} catch (AttributeNotFoundException | StateSystemDisposedException e) {
fail("Failed to query the state system");
}
}
use of org.eclipse.tracecompass.statesystem.core.ITmfStateSystem 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.statesystem.core.ITmfStateSystem 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);
}
Aggregations