Search in sources :

Example 1 with StateSystemDisposedException

use of org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException 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 StateSystemDisposedException

use of org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException 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 StateSystemDisposedException

use of org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException 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 StateSystemDisposedException

use of org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException 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 StateSystemDisposedException

use of org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException 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

StateSystemDisposedException (org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException)96 ITmfStateInterval (org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval)78 ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)51 AttributeNotFoundException (org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException)43 TimeRangeException (org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException)40 Test (org.junit.Test)38 NonNull (org.eclipse.jdt.annotation.NonNull)25 ArrayList (java.util.ArrayList)24 TmfModelResponse (org.eclipse.tracecompass.tmf.core.response.TmfModelResponse)16 HashMap (java.util.HashMap)15 Nullable (org.eclipse.jdt.annotation.Nullable)15 IStateHistoryBackend (org.eclipse.tracecompass.statesystem.core.backend.IStateHistoryBackend)12 AtomicLong (java.util.concurrent.atomic.AtomicLong)11 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)11 StateValueTypeException (org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException)10 SelectionTimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter)10 ImmutableList (com.google.common.collect.ImmutableList)9 List (java.util.List)9 ITmfStateValue (org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue)9 Map (java.util.Map)7