timing.swtbot: add SWTBot tests to timing analysis
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.timing.core.tests / src / org / eclipse / tracecompass / analysis / timing / core / tests / flamegraph / AggregationTreeTest.java
index 49ab868e89cdfd55d75c06cb2976b12bba26f2a8..4554c32158461d6bf8561ede1d0bb36ca225b45d 100644 (file)
@@ -23,6 +23,7 @@ import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.common.core.NonNullUtils;
 import org.eclipse.tracecompass.internal.analysis.timing.core.callgraph.AggregatedCalledFunction;
 import org.eclipse.tracecompass.internal.analysis.timing.core.callgraph.CallGraphAnalysis;
+import org.eclipse.tracecompass.internal.analysis.timing.core.callgraph.ThreadNode;
 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
 import org.eclipse.tracecompass.statesystem.core.StateSystemFactory;
@@ -79,6 +80,8 @@ public class AggregationTreeTest {
         return fixture;
     }
 
+    private CGAnalysis fCga;
+
     /**
      * Test an empty state system.
      */
@@ -88,7 +91,7 @@ public class AggregationTreeTest {
         fixture.closeHistory(1002);
         CGAnalysis cga = new CGAnalysis();
         assertTrue(cga.iterateOverStateSystem(fixture, TP, PP, CSP, new NullProgressMonitor()));
-        List<AggregatedCalledFunction> threads = cga.getThreadNodes();
+        List<ThreadNode> threads = cga.getThreadNodes();
         assertNotNull(threads);
         assertEquals("Number of threads found", 0, threads.size());
     }
@@ -110,7 +113,9 @@ public class AggregationTreeTest {
         // Build the state system
         long start = 1;
         long end = 1001;
-        int parentQuark = fixture.getQuarkAbsoluteAndAdd(PROCESS_PATH, THREAD_PATH, CALLSTACK_PATH);
+        int threadQuark = fixture.getQuarkAbsoluteAndAdd(PROCESS_PATH, THREAD_PATH);
+        int parentQuark = fixture.getQuarkRelativeAndAdd(threadQuark, CALLSTACK_PATH);
+        fixture.updateOngoingState(TmfStateValue.newValueLong(100), threadQuark);
         for (int i = 1; i <= SMALL_AMOUNT_OF_SEGMENT; i++) {
             int quark = fixture.getQuarkRelativeAndAdd(parentQuark, Integer.toString(i));
             TmfStateValue statev = TmfStateValue.newValueLong(i);
@@ -122,13 +127,16 @@ public class AggregationTreeTest {
         fixture.closeHistory(1002);
         // Execute the CallGraphAnalysis
         CGAnalysis cga = new CGAnalysis();
+        setCga(cga);
         assertTrue(cga.iterateOverStateSystem(fixture, TP, PP, CSP, new NullProgressMonitor()));
         @NonNull
-        List<AggregatedCalledFunction> threads = cga.getThreadNodes();
+        List<ThreadNode> threads = cga.getThreadNodes();
         // Test the threads generated by the analysis
         assertNotNull(threads);
         assertEquals("Number of thread nodes Found", 1, threads.size());
         assertEquals("Number of root functions ", 1, threads.get(0).getChildren().size());
+        assertEquals("Thread id", 100, threads.get(0).getId());
+        assertEquals("Thread name", "Thread", threads.get(0).getSymbol());
         Object[] children = threads.get(0).getChildren().toArray();
         AggregatedCalledFunction firstFunction = (AggregatedCalledFunction) children[0];
         assertEquals("Children number: First function", 1, firstFunction.getChildren().size());
@@ -174,7 +182,9 @@ public class AggregationTreeTest {
     public void treeTest() {
         ITmfStateSystemBuilder fixture = createFixture();
         // Build the state system
-        int parentQuark = fixture.getQuarkAbsoluteAndAdd(PROCESS_PATH, THREAD_PATH, CALLSTACK_PATH);
+        int threadQuark = fixture.getQuarkAbsoluteAndAdd(PROCESS_PATH, THREAD_PATH);
+        int parentQuark = fixture.getQuarkRelativeAndAdd(threadQuark, CALLSTACK_PATH);
+        fixture.updateOngoingState(TmfStateValue.newValueDouble(0.001), threadQuark);
         int quark = fixture.getQuarkRelativeAndAdd(parentQuark, QUARK_0);
         TmfStateValue statev = TmfStateValue.newValueLong(0);
         fixture.modifyAttribute(0, statev, quark);
@@ -194,12 +204,14 @@ public class AggregationTreeTest {
 
         // Execute the CallGraphAnalysis
         CGAnalysis cga = new CGAnalysis();
+        setCga(cga);
         assertTrue(cga.iterateOverStateSystem(fixture, TP, PP, CSP, new NullProgressMonitor()));
-        @NonNull
-        List<AggregatedCalledFunction> threads = cga.getThreadNodes();
+        List<ThreadNode> threads = cga.getThreadNodes();
         // Test the threads generated by the analysis
         assertNotNull(threads);
         assertEquals("Number of thread nodes Found", 1, threads.size());
+        assertEquals("Thread id", -1, threads.get(0).getId());
+        assertEquals("Thread name", "Thread", threads.get(0).getSymbol());
         Object[] children = threads.get(0).getChildren().toArray();
         AggregatedCalledFunction firstFunction = (AggregatedCalledFunction) children[0];
         assertEquals("Children number: First function", 1, firstFunction.getChildren().size());
@@ -245,7 +257,9 @@ public class AggregationTreeTest {
     public void mergeFirstLevelCalleesTest() {
         ITmfStateSystemBuilder fixture = createFixture();
         // Build the state system
-        int parentQuark = fixture.getQuarkAbsoluteAndAdd(PROCESS_PATH, THREAD_PATH, CALLSTACK_PATH);
+        int threadQuark = fixture.getQuarkAbsoluteAndAdd(PROCESS_PATH, "123");
+        int parentQuark = fixture.getQuarkRelativeAndAdd(threadQuark, CALLSTACK_PATH);
+        fixture.updateOngoingState(TmfStateValue.newValueDouble(0.001), threadQuark);
         int quark = fixture.getQuarkRelativeAndAdd(parentQuark, QUARK_0);
         TmfStateValue statev = TmfStateValue.newValueLong(0);
         fixture.modifyAttribute(0, statev, quark);
@@ -269,11 +283,15 @@ public class AggregationTreeTest {
 
         // Execute the CallGraphAnalysis
         CGAnalysis cga = new CGAnalysis();
-        assertTrue(cga.iterateOverStateSystem(fixture, TP, PP, CSP, new NullProgressMonitor()));
-        List<AggregatedCalledFunction> threads = cga.getThreadNodes();
+        String @NonNull [] tp = { "123" };
+        assertTrue(cga.iterateOverStateSystem(fixture, tp, PP, CSP, new NullProgressMonitor()));
+        setCga(cga);
+        List<ThreadNode> threads = cga.getThreadNodes();
         // Test the threads generated by the analysis
         assertNotNull(threads);
         assertEquals("Number of thread nodes Found", 1, threads.size());
+        assertEquals("Thread id", 123, threads.get(0).getId());
+        assertEquals("Thread name", "123", threads.get(0).getSymbol());
         assertEquals("Number of root functions ", 1, threads.get(0).getChildren().size());
         Object[] children = threads.get(0).getChildren().toArray();
 
@@ -379,11 +397,14 @@ public class AggregationTreeTest {
         buildCallStack(fixture);
         // Execute the CallGraphAnalysis
         CGAnalysis cga = new CGAnalysis();
+        setCga(cga);
         assertTrue(cga.iterateOverStateSystem(fixture, TP, PP, CSP, new NullProgressMonitor()));
-        List<AggregatedCalledFunction> threads = cga.getThreadNodes();
+        List<ThreadNode> threads = cga.getThreadNodes();
         // Test the threads generated by the analysis
         assertNotNull(threads);
         assertEquals("Number of thread nodes Found", 1, threads.size());
+        assertEquals("Thread id", -1, threads.get(0).getId());
+        assertEquals("Thread name", "Thread", threads.get(0).getSymbol());
         assertEquals("Number of root functions ", 1, threads.get(0).getChildren().size());
         Object[] children = threads.get(0).getChildren().toArray();
         AggregatedCalledFunction main = (AggregatedCalledFunction) children[0];
@@ -456,10 +477,13 @@ public class AggregationTreeTest {
         fixture.closeHistory(11);
         // Execute the callGraphAnalysis
         CGAnalysis cga = new CGAnalysis();
+        setCga(cga);
         assertTrue(cga.iterateOverStateSystem(fixture, TP, PP, CSP, new NullProgressMonitor()));
-        List<AggregatedCalledFunction> threads = cga.getThreadNodes();
+        List<ThreadNode> threads = cga.getThreadNodes();
         // Test the threads generated by the analysis
         assertNotNull(threads);
+        assertEquals("Thread id", -1, threads.get(0).getId());
+        assertEquals("Thread name", "Thread", threads.get(0).getSymbol());
         Object[] children = threads.get(0).getChildren().toArray();
         AggregatedCalledFunction parent = (AggregatedCalledFunction) children[0];
         for (int i = 1; i < LARGE_AMOUNT_OF_SEGMENTS; i++) {
@@ -506,11 +530,14 @@ public class AggregationTreeTest {
 
         // Execute the callGraphAnalysis
         CGAnalysis cga = new CGAnalysis();
+        setCga(cga);
         assertTrue(cga.iterateOverStateSystem(fixture, TP, PP, CSP, new NullProgressMonitor()));
-        List<AggregatedCalledFunction> threads = cga.getThreadNodes();
+        List<ThreadNode> threads = cga.getThreadNodes();
         // Test the threads generated by the analysis
         assertNotNull(threads);
         assertEquals("Number of thread nodes Found", 1, threads.size());
+        assertEquals("Thread id", -1, threads.get(0).getId());
+        assertEquals("Thread name", "Thread", threads.get(0).getSymbol());
         assertEquals("Number of root functions ", 1, threads.get(0).getChildren().size());
         Object[] children = threads.get(0).getChildren().toArray();
         AggregatedCalledFunction firstFunction = (AggregatedCalledFunction) children[0];
@@ -578,11 +605,14 @@ public class AggregationTreeTest {
 
         // Execute the callGraphAnalysis
         CGAnalysis cga = new CGAnalysis();
+        setCga(cga);
         assertTrue(cga.iterateOverStateSystem(fixture, TP, PP, CSP, new NullProgressMonitor()));
-        List<AggregatedCalledFunction> threads = cga.getThreadNodes();
+        List<ThreadNode> threads = cga.getThreadNodes();
         // Test the threads generated by the analysis
         assertNotNull(threads);
         assertEquals("Number of thread nodes Found", 1, threads.size());
+        assertEquals("Thread id", -1, threads.get(0).getId());
+        assertEquals("Thread name", "Thread", threads.get(0).getSymbol());
         assertEquals("Number of root functions ", 2, threads.get(0).getChildren().size());
         Object[] children = threads.get(0).getChildren().toArray();
         AggregatedCalledFunction firstFunction = (AggregatedCalledFunction) children[0];
@@ -622,4 +652,16 @@ public class AggregationTreeTest {
         assertEquals("Test third function's number of calls", 1, function4.getNbCalls());
 
     }
+
+    /**
+     * Gets the call graph analysis
+     * @return the call graph analysis
+     */
+    protected CGAnalysis getCga() {
+        return fCga;
+    }
+
+    private void setCga(CGAnalysis cga) {
+        fCga = cga;
+    }
 }
This page took 0.026294 seconds and 5 git commands to generate.