tmf: Split "CTF adaptor" into separate plugins/feature
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.kernel.core.tests / src / org / eclipse / linuxtools / lttng2 / kernel / core / tests / stateprovider / StateSystemTest.java
index 835fd84a711ef88ee8b4650aa7a4e40e2aa02438..b8c6ed0027fd383cc5e8ee2036add5c53fb98d14 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2012, 2013 Ericsson
+ * Copyright (c) 2012, 2014 Ericsson
  * Copyright (c) 2010, 2011 École Polytechnique de Montréal
  * Copyright (c) 2010, 2011 Alexandre Montplaisir <alexandre.montplaisir@gmail.com>
  *
@@ -24,9 +24,9 @@ import org.eclipse.linuxtools.tmf.core.exceptions.StateSystemDisposedException;
 import org.eclipse.linuxtools.tmf.core.exceptions.StateValueTypeException;
 import org.eclipse.linuxtools.tmf.core.exceptions.TimeRangeException;
 import org.eclipse.linuxtools.tmf.core.interval.ITmfStateInterval;
-import org.eclipse.linuxtools.tmf.core.statesystem.IStateChangeInput;
 import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
 import org.eclipse.linuxtools.tmf.core.statevalue.ITmfStateValue;
+import org.eclipse.linuxtools.tmf.ctf.core.tests.shared.CtfTmfTestTrace;
 import org.junit.Test;
 
 /**
@@ -35,11 +35,11 @@ import org.junit.Test;
  *
  * @author Alexandre Montplaisir
  */
-@SuppressWarnings({"nls", "javadoc"})
+@SuppressWarnings("javadoc")
 public abstract class StateSystemTest {
 
-    /** Index of the test trace used for these tests */
-    protected static final int TRACE_INDEX = 1;
+    /** Test trace used for these tests */
+    protected static final CtfTmfTestTrace testTrace = CtfTmfTestTrace.TRACE2;
 
     /** Expected start time of the test trace/state history */
     protected static final long startTime = 1331668247314038062L;
@@ -50,7 +50,6 @@ public abstract class StateSystemTest {
     /** Number of nanoseconds in one second */
     private static final long NANOSECS_PER_SEC = 1000000000L;
 
-    protected static IStateChangeInput input;
     protected static ITmfStateSystem ssq;
 
     /* Offset in the trace + start time of the trace */
@@ -145,8 +144,8 @@ public abstract class StateSystemTest {
     }
 
     /**
-     * Range query, but with a t2 far off the end of the trace.
-     * The result should still be valid.
+     * Range query, but with a t2 far off the end of the trace. The result
+     * should still be valid.
      */
     @Test
     public void testRangeQuery2() {
@@ -405,4 +404,43 @@ public abstract class StateSystemTest {
             fail();
         }
     }
+
+    @Test
+    public void testFirstIntervalIsConsidered() {
+        try {
+            List<ITmfStateInterval> list = ssq.queryFullState(1331668248014135800L);
+            ITmfStateInterval interval = list.get(233);
+            assertEquals(1331668247516664825L, interval.getStartTime());
+
+            int valueInt = interval.getStateValue().unboxInt();
+            assertEquals(1, valueInt);
+        } catch (TimeRangeException e) {
+            fail();
+        } catch (StateSystemDisposedException e) {
+            fail();
+        } catch (StateValueTypeException e) {
+            fail();
+        }
+    }
+
+    @Test
+    public void testParentAttribute() {
+        String[] path = { "CPUs/0/Current_thread",
+                          "CPUs/0",
+                          "CPUs" };
+        try {
+            int q = ssq.getQuarkAbsolute(Attributes.CPUS, "0", Attributes.CURRENT_THREAD);
+            for (int i = 0; i < path.length; i++) {
+                String name = ssq.getFullAttributePath(q);
+                assertEquals(path[i], name);
+                q = ssq.getParentAttributeQuark(q);
+            }
+            assertEquals(-1, q);
+            q = ssq.getParentAttributeQuark(q);
+            assertEquals(-1, q);
+        } catch (AttributeNotFoundException e) {
+            fail();
+        }
+    }
+
 }
This page took 0.025926 seconds and 5 git commands to generate.