tmf.ui: bug 503678 The ss explorer should not execute analyses
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Tue, 4 Oct 2016 19:46:53 +0000 (15:46 -0400)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Sat, 17 Dec 2016 02:00:14 +0000 (21:00 -0500)
And because the state system does not execute the analyses, the state
systems may not exist when the tree is built. The hierarchy is thus
changed so that the analyses themselves appear as top-level items and
their children are the state system. This way, if the state system did
not exist at first and appears later, it will show when the view
refreshes (without having to refresh the whole view).

Change-Id: Icc750abcdfb27d74d486b9fdcf8b3e910310684f
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/83811
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/META-INF/MANIFEST.MF
lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ImportAndReadKernelSmokeTest.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/statesystem/TmfStateSystemViewer.java

index 0fc2af715766ec8f03f8acdd15c46fe3c9161343..7fdb1e57c0a9177f0e7b5ea2df5d7db6cedd1a1e 100644 (file)
@@ -32,5 +32,6 @@ Require-Bundle: org.apache.log4j,
  org.eclipse.tracecompass.analysis.graph.ui,
  org.eclipse.tracecompass.analysis.os.linux.ui.swtbot.tests,
  org.eclipse.tracecompass.tmf.ui.tests
-Import-Package: org.eclipse.tracecompass.testtraces.ctf,
+Import-Package: com.google.common.collect,
+ org.eclipse.tracecompass.testtraces.ctf,
  org.swtchart;version="0.7.0"
index bee4bf89b168f97c3c83c1e7f8bf6cefa4093f3f..742bb1beb38e8bc8a793991fa2c7de7286f077b0 100644 (file)
@@ -20,8 +20,11 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jface.viewers.SelectionChangedEvent;
@@ -58,6 +61,8 @@ import org.hamcrest.Matcher;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import com.google.common.collect.ImmutableSet;
+
 /**
  * SWTBot Smoke test for LTTng Kernel UI.
  *
@@ -66,9 +71,18 @@ import org.junit.runner.RunWith;
 @RunWith(SWTBotJunit4ClassRunner.class)
 public class ImportAndReadKernelSmokeTest extends KernelTestBase {
 
-    private static final @NonNull List<String> EXPECTED_ANALYSES = Arrays.asList("org.eclipse.tracecompass.analysis.os.linux.inputoutput", "org.eclipse.linuxtools.tmf.statistics.totals", "org.eclipse.linuxtools.tmf.statistics.types",
-            "org.eclipse.tracecompass.analysis.os.linux.kernel.tid", "org.eclipse.tracecompass.analysis.os.linux.kernel", "org.eclipse.tracecompass.analysis.os.linux.contextswitch", "org.eclipse.tracecompass.analysis.os.linux.core.kernelmemory",
-            "org.eclipse.tracecompass.analysis.os.linux.cpuusage");
+    private static final @NonNull Map<String, Set<String>> EXPECTED_ANALYSES = new HashMap<>();
+
+    static {
+        EXPECTED_ANALYSES.put("Input/Output", Collections.singleton("org.eclipse.tracecompass.analysis.os.linux.inputoutput"));
+        EXPECTED_ANALYSES.put("Tmf Statistics", ImmutableSet.of("org.eclipse.linuxtools.tmf.statistics.totals", "org.eclipse.linuxtools.tmf.statistics.types"));
+        EXPECTED_ANALYSES.put("Active Thread", Collections.singleton("org.eclipse.tracecompass.analysis.os.linux.kernel.tid"));
+        EXPECTED_ANALYSES.put("Linux Kernel", Collections.singleton("org.eclipse.tracecompass.analysis.os.linux.kernel"));
+        EXPECTED_ANALYSES.put("Context switch", Collections.singleton("org.eclipse.tracecompass.analysis.os.linux.contextswitch"));
+        EXPECTED_ANALYSES.put("Kernel memory usage", Collections.singleton("org.eclipse.tracecompass.analysis.os.linux.core.kernelmemory"));
+        EXPECTED_ANALYSES.put("CPU usage", Collections.singleton("org.eclipse.tracecompass.analysis.os.linux.cpuusage"));
+    }
+
     private ITmfEvent fDesired1;
     private ITmfEvent fDesired2;
 
@@ -78,26 +92,28 @@ public class ImportAndReadKernelSmokeTest extends KernelTestBase {
     @Test
     public void test() {
         CtfTmfTrace trace = CtfTmfTestTraceUtils.getSyntheticTrace();
-        Matcher<IEditorReference> matcher = WidgetMatcherFactory.withPartName(trace.getName());
-        IEditorPart iep = fBot.editor(matcher).getReference().getEditor(true);
-        final TmfEventsEditor tmfEd = (TmfEventsEditor) iep;
-
-        fDesired1 = getEvent(trace, 100);
-        fDesired2 = getEvent(trace, 10000);
-
-        UIThreadRunnable.syncExec(new VoidResult() {
-            @Override
-            public void run() {
-                tmfEd.setFocus();
-                tmfEd.selectionChanged(new SelectionChangedEvent(tmfEd, new StructuredSelection(fDesired1)));
-            }
-        });
-        testHV(getViewPart("Histogram"));
-        testCFV((ControlFlowView) getViewPart("Control Flow"));
-        testRV((ResourcesView) getViewPart("Resources"));
-        testStateSystemExplorer();
-
-        trace.dispose();
+        try {
+            Matcher<IEditorReference> matcher = WidgetMatcherFactory.withPartName(trace.getName());
+            IEditorPart iep = fBot.editor(matcher).getReference().getEditor(true);
+            final TmfEventsEditor tmfEd = (TmfEventsEditor) iep;
+
+            fDesired1 = getEvent(trace, 100);
+            fDesired2 = getEvent(trace, 10000);
+
+            UIThreadRunnable.syncExec(new VoidResult() {
+                @Override
+                public void run() {
+                    tmfEd.setFocus();
+                    tmfEd.selectionChanged(new SelectionChangedEvent(tmfEd, new StructuredSelection(fDesired1)));
+                }
+            });
+            testHV(getViewPart("Histogram"));
+            testCFV((ControlFlowView) getViewPart("Control Flow"));
+            testRV((ResourcesView) getViewPart("Resources"));
+            testStateSystemExplorer();
+        } finally {
+            trace.dispose();
+        }
     }
 
     private static void testCFV(ControlFlowView vp) {
@@ -176,15 +192,13 @@ public class ImportAndReadKernelSmokeTest extends KernelTestBase {
     private void testStateSystemExplorer() {
         // Set up
         SWTWorkbenchBot bot = new SWTWorkbenchBot();
-        List<String> expectedAnalyses = new ArrayList<>();
-        expectedAnalyses.addAll(EXPECTED_ANALYSES);
         // Open the view
         SWTBotUtils.openView(TmfStateSystemExplorer.ID);
         SWTBotView sseBot = bot.viewByTitle("State System Explorer");
         sseBot.show();
         // get the list and compare it.
         List<String> actual = getSSNames(sseBot);
-        assertTrue("State systems are not what expected : " + EXPECTED_ANALYSES + " instead " + actual, actual.containsAll(EXPECTED_ANALYSES));
+        assertTrue("State systems are not what expected : " + EXPECTED_ANALYSES.keySet() + " instead " + actual, actual.containsAll(EXPECTED_ANALYSES.keySet()));
         // Re-open the view and make sure it has the same results
         sseBot.close();
         SWTBotUtils.openView(TmfStateSystemExplorer.ID);
index 7d803b447fc7596a22865a29408e902bdeec185e..dc947721d09e210c78a792376228f7676063d7cd 100644 (file)
@@ -208,16 +208,13 @@ public class TmfStateSystemViewer extends AbstractTmfTreeViewer {
         for (IAnalysisModule module : modules) {
             if (module instanceof ITmfAnalysisModuleWithStateSystems) {
                 ITmfAnalysisModuleWithStateSystems moduleWithStateSystem = (ITmfAnalysisModuleWithStateSystems) module;
-                /*
-                 * Just schedule the module, the data will be filled when
-                 * available
-                 */
-                moduleWithStateSystem.schedule();
-                if (!moduleWithStateSystem.waitForInitialization()) {
-                    continue;
-                }
+                // Add the module as an entry to the trace
+                TmfTreeViewerEntry moduleEntry = new ModuleEntry(moduleWithStateSystem);
+                traceEntry.addChild(moduleEntry);
+                // Add the state system as children of the module, they may not
+                // be initialized yet, the list will be empty in that case
                 for (ITmfStateSystem ss : moduleWithStateSystem.getStateSystems()) {
-                    traceEntry.addChild(new StateSystemEntry(ss));
+                    moduleEntry.addChild(new StateSystemEntry(ss));
                 }
             }
         }
@@ -235,17 +232,26 @@ public class TmfStateSystemViewer extends AbstractTmfTreeViewer {
     private boolean updateStateSystemEntries(ITmfTreeViewerEntry root, long timestamp) {
         boolean changed = false;
         for (ITmfTreeViewerEntry traceEntry : root.getChildren()) {
-            for (ITmfTreeViewerEntry ssEntry : traceEntry.getChildren()) {
-                StateSystemEntry stateSystemEntry = (StateSystemEntry) ssEntry;
-                ITmfStateSystem ss = stateSystemEntry.getSS();
-                try {
-                    List<ITmfStateInterval> fullState = ss.queryFullState(timestamp);
-                    changed |= updateStateEntries(ss, fullState, stateSystemEntry, -1, timestamp);
-                } catch (TimeRangeException e) {
-                    markOutOfRange(stateSystemEntry);
-                    changed = true;
-                } catch (StateSystemDisposedException e) {
-                    /* Ignored */
+            for (ITmfTreeViewerEntry moduleEntry : traceEntry.getChildren()) {
+                // If there are no children, see if new state systems are
+                // available now
+                if (moduleEntry.getChildren().isEmpty()) {
+                    for (ITmfStateSystem ss : ((ModuleEntry) moduleEntry).getModule().getStateSystems()) {
+                        ((ModuleEntry) moduleEntry).addChild(new StateSystemEntry(ss));
+                    }
+                }
+                for (ITmfTreeViewerEntry ssEntry : moduleEntry.getChildren()) {
+                    StateSystemEntry stateSystemEntry = (StateSystemEntry) ssEntry;
+                    ITmfStateSystem ss = stateSystemEntry.getSS();
+                    try {
+                        List<ITmfStateInterval> fullState = ss.queryFullState(timestamp);
+                        changed |= updateStateEntries(ss, fullState, stateSystemEntry, -1, timestamp);
+                    } catch (TimeRangeException e) {
+                        markOutOfRange(stateSystemEntry);
+                        changed = true;
+                    } catch (StateSystemDisposedException e) {
+                        /* Ignored */
+                    }
                 }
             }
         }
@@ -360,6 +366,19 @@ public class TmfStateSystemViewer extends AbstractTmfTreeViewer {
         }
     }
 
+    private static class ModuleEntry extends TmfTreeViewerEntry {
+        private final @NonNull ITmfAnalysisModuleWithStateSystems fModule;
+
+        public ModuleEntry(@NonNull ITmfAnalysisModuleWithStateSystems moduleWithStateSystem) {
+            super(moduleWithStateSystem.getName());
+            fModule = moduleWithStateSystem;
+        }
+
+        public @NonNull ITmfAnalysisModuleWithStateSystems getModule() {
+            return fModule;
+        }
+    }
+
     private class StateEntry extends TmfTreeViewerEntry {
 
         private final int fQuark;
This page took 0.028616 seconds and 5 git commands to generate.