Search in sources :

Example 11 with ITmfStateSystem

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());
    }
}
Also used : QuarkIterator(org.eclipse.tracecompass.statesystem.core.StateSystemUtils.QuarkIterator) ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) Test(org.junit.Test)

Example 12 with ITmfStateSystem

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());
    }
}
Also used : QuarkIterator(org.eclipse.tracecompass.statesystem.core.StateSystemUtils.QuarkIterator) ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) Test(org.junit.Test)

Example 13 with ITmfStateSystem

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");
    }
}
Also used : StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) AttributeNotFoundException(org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException) NonNull(org.eclipse.jdt.annotation.NonNull) ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) Test(org.junit.Test) XmlUtilsTest(org.eclipse.tracecompass.tmf.analysis.xml.core.tests.module.XmlUtilsTest)

Example 14 with ITmfStateSystem

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);
}
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 15 with ITmfStateSystem

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

ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)137 ITmfStateInterval (org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval)52 Test (org.junit.Test)52 StateSystemDisposedException (org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException)51 NonNull (org.eclipse.jdt.annotation.NonNull)32 AttributeNotFoundException (org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException)30 Nullable (org.eclipse.jdt.annotation.Nullable)26 ArrayList (java.util.ArrayList)25 TmfModelResponse (org.eclipse.tracecompass.tmf.core.response.TmfModelResponse)23 TimeRangeException (org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException)22 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)22 HashMap (java.util.HashMap)18 ITmfStateValue (org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue)16 XmlUtilsTest (org.eclipse.tracecompass.tmf.analysis.xml.core.tests.module.XmlUtilsTest)16 AtomicLong (java.util.concurrent.atomic.AtomicLong)15 DataDrivenAnalysisModule (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.module.DataDrivenAnalysisModule)10 SelectionTimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter)10 List (java.util.List)9 QuarkIterator (org.eclipse.tracecompass.statesystem.core.StateSystemUtils.QuarkIterator)9 TmfAnalysisException (org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException)9