Search in sources :

Example 1 with AttributeNotFoundException

use of org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException in project tracecompass by tracecompass.

the class StateSystemTest method testFullQuery1.

@Test
public void testFullQuery1() {
    List<ITmfStateInterval> list;
    ITmfStateInterval interval;
    int quark, valueInt;
    String valueStr;
    try {
        list = fixture.queryFullState(interestingTimestamp1);
        quark = fixture.getQuarkAbsolute(Attributes.CPUS, "0", Attributes.CURRENT_THREAD);
        interval = list.get(quark);
        valueInt = interval.getStateValue().unboxInt();
        assertEquals(1397, valueInt);
        quark = fixture.getQuarkAbsolute(Attributes.THREADS, "1432", Attributes.EXEC_NAME);
        interval = list.get(quark);
        valueStr = interval.getStateValue().unboxStr();
        assertEquals("gdbus", valueStr);
        quark = fixture.getQuarkAbsolute(Attributes.THREADS, "1432", Attributes.SYSTEM_CALL);
        interval = list.get(quark);
        valueStr = interval.getStateValue().unboxStr();
        assertEquals("poll", valueStr);
    } catch (AttributeNotFoundException | StateSystemDisposedException e) {
        fail();
    }
}
Also used : StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) AttributeNotFoundException(org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException) ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) Test(org.junit.Test)

Example 2 with AttributeNotFoundException

use of org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException in project tracecompass by tracecompass.

the class StateSystemTest method testQueryInvalidValuetype1.

/**
 * Query but with the wrong State Value type
 */
@Test(expected = StateValueTypeException.class)
public void testQueryInvalidValuetype1() throws StateValueTypeException {
    List<ITmfStateInterval> list;
    ITmfStateInterval interval;
    int quark;
    try {
        list = fixture.queryFullState(interestingTimestamp1);
        quark = fixture.getQuarkAbsolute(Attributes.CPUS, "0", Attributes.CURRENT_THREAD);
        interval = list.get(quark);
        /* This is supposed to be an int value */
        interval.getStateValue().unboxStr();
    } catch (AttributeNotFoundException | StateSystemDisposedException e) {
        fail();
    }
}
Also used : StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) AttributeNotFoundException(org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException) ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) Test(org.junit.Test)

Example 3 with AttributeNotFoundException

use of org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException in project tracecompass by tracecompass.

the class StateSystemTest method testRangeQuery2.

/**
 * Range query, but with a t2 far off the end of the trace. The result
 * should still be valid.
 */
@Test
public void testRangeQuery2() {
    List<ITmfStateInterval> intervals;
    final ITmfStateSystem ss = fixture;
    assertNotNull(ss);
    try {
        int quark = ss.getQuarkAbsolute(Attributes.CPUS, Integer.toString(0), Attributes.IRQS, "1");
        long ts1 = ss.getStartTime();
        /* start of the trace */
        long ts2 = startTime + 20L * NANOSECS_PER_SEC;
        /* invalid, but ignored */
        intervals = StateSystemUtils.queryHistoryRange(ss, quark, ts1, ts2);
        /* Activity of IRQ 1 over the whole trace */
        assertEquals(65, intervals.size());
    } catch (AttributeNotFoundException | StateSystemDisposedException e) {
        fail();
    }
}
Also used : StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) AttributeNotFoundException(org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException) ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) Test(org.junit.Test)

Example 4 with AttributeNotFoundException

use of org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException in project tracecompass by tracecompass.

the class StateSystemTest method testRangeQuery1.

/**
 * Test a range query (with no resolution parameter, so all intervals)
 */
@Test
public void testRangeQuery1() {
    long time1 = interestingTimestamp1;
    long time2 = time1 + 1L * NANOSECS_PER_SEC;
    int quark;
    List<ITmfStateInterval> intervals;
    final ITmfStateSystem ss = fixture;
    assertNotNull(ss);
    try {
        quark = ss.getQuarkAbsolute(Attributes.CPUS, "0", Attributes.CURRENT_THREAD);
        intervals = StateSystemUtils.queryHistoryRange(ss, quark, time1, time2);
        assertEquals(487, intervals.size());
        /* Number of context switches! */
        assertEquals(1685, intervals.get(100).getStateValue().unboxInt());
        assertEquals(1331668248427681372L, intervals.get(205).getEndTime());
    } catch (AttributeNotFoundException | StateSystemDisposedException e) {
        fail();
    }
}
Also used : StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) AttributeNotFoundException(org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException) ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) Test(org.junit.Test)

Example 5 with AttributeNotFoundException

use of org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException in project tracecompass by tracecompass.

the class StateSystemTest method testRangeQueryInvalidTime2.

@Test(expected = TimeRangeException.class)
public void testRangeQueryInvalidTime2() throws TimeRangeException {
    final ITmfStateSystem ss = fixture;
    assertNotNull(ss);
    try {
        int quark = ss.getQuarkAbsolute(Attributes.CPUS, "0", Attributes.CURRENT_THREAD);
        long ts1 = startTime - 1L * NANOSECS_PER_SEC;
        /* invalid */
        long ts2 = startTime + 20L * NANOSECS_PER_SEC;
        /* invalid */
        StateSystemUtils.queryHistoryRange(ss, quark, ts1, ts2);
    } catch (AttributeNotFoundException | StateSystemDisposedException e) {
        fail();
    }
}
Also used : StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) AttributeNotFoundException(org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) Test(org.junit.Test)

Aggregations

AttributeNotFoundException (org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException)54 StateSystemDisposedException (org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException)43 ITmfStateInterval (org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval)43 Test (org.junit.Test)32 ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)30 TimeRangeException (org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException)20 NonNull (org.eclipse.jdt.annotation.NonNull)13 StateValueTypeException (org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException)12 Nullable (org.eclipse.jdt.annotation.Nullable)8 ITmfStateValue (org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue)8 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)8 ITmfStateSystemBuilder (org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder)7 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)4 Random (java.util.Random)4 XmlUtilsTest (org.eclipse.tracecompass.tmf.analysis.xml.core.tests.module.XmlUtilsTest)4 ImmutableList (com.google.common.collect.ImmutableList)3 List (java.util.List)3 TreeSet (java.util.TreeSet)3 QuarkIterator (org.eclipse.tracecompass.statesystem.core.StateSystemUtils.QuarkIterator)3