ss: Improve getQuarks() functionality
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.kernel.core.tests / src / org / eclipse / tracecompass / lttng2 / kernel / core / tests / analysis / kernel / statesystem / StateSystemTest.java
index 2decf38a2b47140c59213fe6fec1b8d475996010..ef8169a66b7fe286421ab4a9202c6fb911763318 100644 (file)
@@ -19,11 +19,12 @@ import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
 
+import java.util.Arrays;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 
 import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.analysis.os.linux.core.kernel.Attributes;
+import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.Attributes;
 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
 import org.eclipse.tracecompass.statesystem.core.StateSystemUtils;
 import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
@@ -407,6 +408,70 @@ public abstract class StateSystemTest {
         assertEquals(5, list.size());
     }
 
+    @Test
+    public void testGetQuarks_middle_end() {
+        List<Integer> list = fixture.getQuarks(Attributes.THREADS, "*", "*");
+
+        /* There should be 169 threads and 5 sub-attributes per thread */
+        assertEquals(169 * 5, list.size());
+    }
+
+    @Test
+    public void testGetQuarks_empty() {
+        List<Integer> list = fixture.getQuarks();
+
+        assertEquals(Arrays.asList(ITmfStateSystem.ROOT_ATTRIBUTE), list);
+    }
+
+    @Test
+    public void testGetQuarks_relative() {
+        int threadsQuark = INVALID_ATTRIBUTE;
+        try {
+            threadsQuark = fixture.getQuarkAbsolute(Attributes.THREADS);
+        } catch (AttributeNotFoundException e) {
+            fail();
+        }
+        assertNotEquals(INVALID_ATTRIBUTE, threadsQuark);
+
+        List<Integer> list = fixture.getQuarks(threadsQuark, "*", Attributes.EXEC_NAME);
+
+        /* Number of different kernel threads in the trace */
+        assertEquals(169, list.size());
+    }
+
+    @Test
+    public void testGetQuarks_relative_up_wildcard() {
+        int threadsQuark = INVALID_ATTRIBUTE;
+        try {
+            threadsQuark = fixture.getQuarkAbsolute(Attributes.THREADS);
+        } catch (AttributeNotFoundException e) {
+            fail();
+        }
+        assertNotEquals(INVALID_ATTRIBUTE, threadsQuark);
+
+        List<Integer> list = fixture.getQuarks(threadsQuark, "..", Attributes.CPUS, "*");
+
+        /* There should be 2 CPUs */
+        assertEquals(2, list.size());
+    }
+
+    @Test
+    public void testGetQuarks_relative_empty() {
+        int threadsQuark = INVALID_ATTRIBUTE;
+        try {
+            threadsQuark = fixture.getQuarkAbsolute(Attributes.THREADS);
+        } catch (AttributeNotFoundException e) {
+            fail();
+        }
+        assertNotEquals(INVALID_ATTRIBUTE, threadsQuark);
+
+        List<Integer> list = fixture.getQuarks(threadsQuark, new String[0]);
+        assertEquals(Arrays.asList(threadsQuark), list);
+
+        list = fixture.getQuarks(threadsQuark);
+        assertEquals(Arrays.asList(threadsQuark), list);
+    }
+
     @Test
     public void testGetQuarksNoMatch() {
         List<Integer> list = fixture.getQuarks("invalid");
This page took 0.026517 seconds and 5 git commands to generate.